Permalink
Browse files

Move to libuv.

  • Loading branch information...
1 parent ca98ca9 commit 7688126dab51cfe86d18beb9fd68a8cf8495f05c @jpemartins committed Jul 11, 2012
Showing with 69 additions and 51 deletions.
  1. +17 −4 Makefile
  2. +35 −26 src/binding.cc
  3. +11 −11 src/{peerconnection.cc → peerconnectionproxy.cc}
  4. +5 −9 src/{peerconnection.h → peerconnectionproxy.h}
  5. +1 −1 src/utils.h
View
@@ -51,11 +51,10 @@ CCFLAGS = -fno-rtti \
INCLUDE_DIRS = -I/usr/include/nodejs/ \
-I$(WEBRTC_ROOT_PATH)/third_party/webrtc \
+ -I$(WEBRTC_ROOT_PATH)/third_party/webrtc/modules/interface \
-I$(WEBRTC_ROOT_PATH)/third_party/ \
-I$(WEBRTC_ROOT_PATH)/third_party/libjingle/source \
-I$(WEBRTC_ROOT_PATH)/third_party/libjingle/overrides \
- -I$(WEBRTC_ROOT_PATH)/src \
- -I$(WEBRTC_ROOT_PATH)/src/modules/interface \
-I$(WEBRTC_ROOT_PATH)/testing/gtest/include
BUILD_DIR = build/
@@ -122,14 +121,28 @@ NODE_WEBRTC_LDFLAGS = -pthread -Wl,-z,noexecstack -fPIC -L/usr/lib/i386-linux-gn
WEBRTC_LDFLAGS = -pthread -Wl,-z,noexecstack -fPIC -L/usr/lib/i386-linux-gnu -m32 $(FLAGS) -Wl,--start-group $(SAMPLE_OBJS) $(WEBRTC_LIBS_TRUNK) -Wl,--end-group -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lm -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lX11 -lXext -lexpat -ldl -lasound -lpulse
-all: node_module
+all: clean node_module
+
+node_module_edge: clean
+ifndef WEBRTC_ROOT_PATH
+ $(error WEBRTC_ROOT_PATH is undefined)
+endif
+ mkdir -p build
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/peerconnectionwrapper.cc -c -o $(BUILD_DIR)/peerconnectionwrapper.o
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/peerconnectionfactory.cc -c -o $(BUILD_DIR)/peerconnectionfactory.o
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/peerconnectionwrapperproxy.cc -c -o $(BUILD_DIR)/peerconnectionwrapperproxy.o
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/gtk_video_renderer.cc -c -o $(BUILD_DIR)/gtk_video_renderer.o
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/binding.cc -c -o $(BUILD_DIR)/binding.o
+ g++ $(NODE_WEBRTC_LDFLAGS)
+ #strip build/webrtc.node
+ unlink webrtc.node; ln -s build/webrtc.node webrtc.node
node_module:
ifndef WEBRTC_ROOT_PATH
$(error WEBRTC_ROOT_PATH is undefined)
endif
mkdir -p build
- g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/peerconnection.cc -c -o $(BUILD_DIR)/peerconnection.o
+ g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/peerconnectionproxy.cc -c -o $(BUILD_DIR)/peerconnectionproxy.o
g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/gtk_video_renderer.cc -c -o $(BUILD_DIR)/gtk_video_renderer.o
g++ $(DEFS) $(CFLAGS) $(CCFLAGS) $(INCLUDE_DIRS) src/binding.cc -c -o $(BUILD_DIR)/binding.o
g++ $(NODE_WEBRTC_LDFLAGS)
View
@@ -1,12 +1,12 @@
#include <v8.h>
#include <node.h>
-#include <ev.h>
+#include <uv.h>
#include <gtk/gtk.h>
#include "talk/app/webrtc/peerconnection.h"
#include "gtk_video_renderer.h"
-#include "peerconnection.h"
+#include "peerconnectionwrapperproxy.h"
#include "utils.h"
using namespace node;
@@ -16,13 +16,16 @@ static void GtkIteration();
class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
private:
- node_webrtc::PeerConnection* connection_proxy;
+ node_webrtc::PeerConnectionProxy* connection_proxy;
public:
- static ev_async eio_signal_ev;
- static std::string message;
+ static uv_async_t uv_signal;
+
+ static std::string message;
+ static ObjectWrap* wrap;
static Local<Value> callback;
+ static std::string callback_name;
static GtkMainWnd window;
static Persistent<FunctionTemplate> function_template;
@@ -50,7 +53,7 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
}
PeerConnection() {
- connection_proxy = new node_webrtc::PeerConnection(this);
+ connection_proxy = new node_webrtc::PeerConnectionProxy(this);
connection_proxy->SetWindow(&window);
}
@@ -75,16 +78,18 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
void OnError(const std::string& msg) {
message = msg;
- callback = this->handle_->Get(NODE_PSYMBOL("onerror"));
+ wrap = this;
+ callback_name = "onerror";
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnError() {
message = std::string("");
- callback = this->handle_->Get(NODE_PSYMBOL("onerror"));
+ wrap = this;
+ callback_name = "onerror";
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnStateChange(webrtc::PeerConnectionObserver::StateType state) {
@@ -98,7 +103,7 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
callback = this->handle_->Get(NODE_PSYMBOL("onconnecting"));
message = std::string();
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(EV_DEFAULT_UC_ &uv_signal);
return;
}
//Trigger onconnecting
@@ -108,9 +113,10 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
void OnMessage(const std::string& msg) {
message = msg;
- callback = this->handle_->Get(NODE_PSYMBOL("onmessage"));
+ wrap = this;
+ callback_name = "onmessage";
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnAddStream(webrtc::MediaStreamInterface* stream) {
@@ -125,23 +131,26 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
stream->Release();
message = std::string();
- callback = this->handle_->Get(NODE_PSYMBOL("onaddstream"));
+ wrap = this;
+ callback_name = "onaddstream";
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnRemoveStream(webrtc::MediaStreamInterface* stream) {
message = std::string();
- callback = this->handle_->Get(NODE_PSYMBOL("onremovestream"));
+ wrap = this;
+ callback_name = "onremovestream";
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnSignalingMessage(const std::string& msg) {
message = msg;
- callback = this->handle_->Get(NODE_PSYMBOL("onsignalingmessage"));
+ callback_name = "onsignalingmessage";
+ wrap = this;
- ev_async_send(EV_DEFAULT_UC_ &eio_signal_ev);
+ uv_async_send(&uv_signal);
}
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) {
@@ -150,10 +159,10 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
void OnIceComplete() {
}
- static void OnCallback(EV_P_ ev_async *watcher, int revents) {
+ static void OnCallback(uv_async_t *watcher, int status) {
HandleScope scope;
-
- assert(watcher == &eio_signal_ev);
+
+ callback = wrap->handle_->Get(NODE_PSYMBOL(callback_name.c_str()));
if (!callback->IsFunction()) {
return;
@@ -167,9 +176,7 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
static Handle<Value> New(const Arguments& args) {
- ev_async_init(&eio_signal_ev, &OnCallback);
- ev_async_start(EV_DEFAULT_UC_ &eio_signal_ev);
- ev_unref(EV_DEFAULT_UC);
+ uv_async_init(uv_default_loop(), &uv_signal, OnCallback);
HandleScope scope;
PeerConnection* peerconnection = new PeerConnection();
@@ -217,10 +224,12 @@ class PeerConnection: ObjectWrap, webrtc::PeerConnectionObserver {
Persistent<FunctionTemplate> PeerConnection::function_template;
-ev_async PeerConnection::eio_signal_ev;
+uv_async_t PeerConnection::uv_signal;
std::string PeerConnection::message;
Local<Value> PeerConnection::callback;
+std::string PeerConnection::callback_name;
GtkMainWnd PeerConnection::window;
+ObjectWrap* PeerConnection::wrap;
static void GtkIteration() {
while (gtk_events_pending())
@@ -1,4 +1,4 @@
-#include "peerconnection.h"
+#include "peerconnectionproxy.h"
#include <vector>
@@ -7,7 +7,7 @@
using namespace node_webrtc;
-PeerConnection::PeerConnection(webrtc::PeerConnectionObserver *observer) {
+PeerConnectionProxy::PeerConnectionProxy(webrtc::PeerConnectionObserver *observer) {
connection_factory = webrtc::CreatePeerConnectionFactory();
connection_factory_impl = (webrtc::PeerConnectionFactory*) connection_factory.get();
@@ -25,14 +25,14 @@ PeerConnection::PeerConnection(webrtc::PeerConnectionObserver *observer) {
proxy_observer = observer;
}
-PeerConnection::~PeerConnection() {
+PeerConnectionProxy::~PeerConnectionProxy() {
}
-void PeerConnection::SetWindow(GtkMainWnd* window_) {
+void PeerConnectionProxy::SetWindow(GtkMainWnd* window_) {
window = window_;
}
-talk_base::scoped_refptr<webrtc::VideoCaptureModule> PeerConnection::OpenVideoCaptureDevice()
+talk_base::scoped_refptr<webrtc::VideoCaptureModule> PeerConnectionProxy::OpenVideoCaptureDevice()
{
webrtc::VideoCaptureModule::DeviceInfo* device_info(
webrtc::VideoCaptureFactory::CreateDeviceInfo(0));
@@ -73,7 +73,7 @@ talk_base::scoped_refptr<webrtc::VideoCaptureModule> PeerConnection::OpenVideoCa
return video_device;
}
-void PeerConnection::AddStream() {
+void PeerConnectionProxy::AddStream() {
talk_base::scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track(
connection_factory->CreateLocalAudioTrack(
"audio_label", NULL));
@@ -92,22 +92,22 @@ void PeerConnection::AddStream() {
connection->CommitStreamChanges();
}
-void PeerConnection::Send(const std::string& text) {
+void PeerConnectionProxy::Send(const std::string& text) {
connection->Send(text);
}
-void PeerConnection::ProcessSignalingMessage(const std::string& text) {
+void PeerConnectionProxy::ProcessSignalingMessage(const std::string& text) {
connection->ProcessSignalingMessage(text);
}
-void PeerConnection::Close() {
+void PeerConnectionProxy::Close() {
connection->Close();
}
-int PeerConnection::sdp_state() {
+int PeerConnectionProxy::sdp_state() {
return connection->sdp_state();
}
-int PeerConnection::ready_state() {
+int PeerConnectionProxy::ready_state() {
return connection->ready_state();
}
@@ -3,6 +3,7 @@
#include "talk/base/scoped_ptr.h"
+#include "talk/app/webrtc/peerconnectionfactory.h"
#include "talk/app/webrtc/peerconnection.h"
#include "talk/app/webrtc/webrtcsession.h"
@@ -11,16 +12,13 @@
#include "talk/p2p/client/httpportallocator.h"
-#include "video_engine/include/vie_base.h"
-#include "video_engine/include/vie_render.h"
-
#include "utils.h"
#include "gtk_video_renderer.h"
namespace node_webrtc {
-class PeerConnection /*: public webrtc::PeerConnectionObserver*/ {
+class PeerConnectionProxy {
private:
talk_base::scoped_refptr<webrtc::PeerConnectionFactoryInterface> connection_factory;
webrtc::PeerConnectionFactory* connection_factory_impl;
@@ -29,17 +27,15 @@ class PeerConnection /*: public webrtc::PeerConnectionObserver*/ {
cricket::ChannelManager* channel_manager;
talk_base::scoped_ptr<cricket::PortAllocator> port_allocator;
- talk_base::scoped_ptr<webrtc::WebRtcSession> session;
webrtc::PeerConnectionObserver* proxy_observer;
GtkMainWnd* window;
- webrtc::ViERender* vie;
public:
- PeerConnection();
- PeerConnection(webrtc::PeerConnectionObserver *observer);
- ~PeerConnection();
+ PeerConnectionProxy();
+ PeerConnectionProxy(webrtc::PeerConnectionObserver *observer);
+ ~PeerConnectionProxy();
void SetWindow(GtkMainWnd* window_);
talk_base::scoped_refptr<webrtc::VideoCaptureModule> OpenVideoCaptureDevice();
View
@@ -7,4 +7,4 @@
#define ERROR(msg) fprintf(stdout, "\033[01;32m native:%s \033[00m\n", msg)
#define INFO(msg) fprintf(stdout, "\033[01;34m native:%s \033[00m\n", msg)
-#endif
+#endif

0 comments on commit 7688126

Please sign in to comment.