Skip to content

Commit

Permalink
fixed crash in debug mode by removing thread arguments to peer connec…
Browse files Browse the repository at this point in the history
…tion factory creator; a couple of new examples (mostly sanity checks); disabled data channels and media streams (for now)
  • Loading branch information
Alan K committed Apr 24, 2014
1 parent e87b003 commit 3642bee
Show file tree
Hide file tree
Showing 21 changed files with 332 additions and 240 deletions.
Empty file added .valgrind.supp
Empty file.
2 changes: 2 additions & 0 deletions .valgrindrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--suppressions=.valgrind.supp
--track-origins=yes
2 changes: 1 addition & 1 deletion bin/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
var PLATFORM = process.platform;
var LIBWEBRTC_REVISION = parsed['libwebrtc-revision'] || 'r5459';
var CONFIGURATION = parsed['configuration'] || 'Release'
//var CONFIGURATION = 'Release';

console.log("TARGET_ARCH="+TARGET_ARCH, LIBWEBRTC_REVISION, CONFIGURATION);

Expand Down Expand Up @@ -150,7 +151,6 @@

function build() {
process.stdout.write('Building libjingle ... ');
process.env.BUILDTYPE = CONFIGURATION;
var args = ['-C', 'trunk/out/' + CONFIGURATION];

switch(PLATFORM) {
Expand Down
13 changes: 9 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'variables': {
'libwebrtc%': 'third_party/libwebrtc/trunk',
'libwebrtc_revision%': 'r5936'
#'libwebrtc_revision%': 'r5385'
},
'conditions': [
['OS=="linux"', {
Expand Down Expand Up @@ -40,6 +41,7 @@
'dependencies': [ 'action_before_build' ],
'variables': {
'libwebrtc_out%': '<(libwebrtc)/out/<(configuration)/obj',
# 'libwebrtc_out%': '<(libwebrtc)/out/Release/obj',
},
'cflags': [
'-pthread',
Expand Down Expand Up @@ -149,7 +151,6 @@
'../<(libwebrtc_out)/third_party/libvpx/libvpx_intrinsics_sse2.a',
'../<(libwebrtc_out)/third_party/libvpx/libvpx_intrinsics_ssse3.a',
'-Wl,--end-group',
#'../<(libwebrtc_out)/third_party/openssl/libopenssl.a',
'../<(libwebrtc_out)/net/third_party/nss/libcrssl.a',
'../<(libwebrtc_out)/third_party/usrsctp/libusrsctplib.a',
'-lssl',
Expand Down Expand Up @@ -228,10 +229,14 @@
},
'sources': [
'src/binding.cc',
'src/create-offer-observer.cc',
'src/create-answer-observer.cc',
'src/set-local-description-observer.cc',
'src/set-remote-description-observer.cc',
'src/peerconnection.cc',
'src/datachannel.cc',
'src/mediastream.cc',
'src/mediastreamtrack.cc'
# 'src/datachannel.cc',
# 'src/mediastream.cc',
# 'src/mediastreamtrack.cc',
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions examples/minimal-memory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var wrtc = require('../');

var pc = new wrtc.RTCPeerConnection();
pc.close();
1 change: 1 addition & 0 deletions examples/nop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var wrtc = require('../');
7 changes: 4 additions & 3 deletions examples/sanity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function handle_error(error)

var checks = 0;
var expected = 2;

/*
function create_data_channels() {
var dc1 = pc1.createDataChannel('test');
dc1.onopen = function() {
Expand All @@ -44,7 +44,7 @@ function create_data_channels() {
create_offer();
}

*/
function create_offer() {
console.log('pc1: create offer');
pc1.createOffer(set_pc1_local_description, handle_error);
Expand Down Expand Up @@ -99,7 +99,8 @@ function wait() {
}

function run() {
create_data_channels();
//create_data_channels();
create_offer();
}

function done() {
Expand Down
20 changes: 6 additions & 14 deletions lib/peerconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var EventTarget = require('./eventtarget');

var MediaStream = require('./mediastream');
var MediaStreamEvent = require('./mediastreamevent');
var RTCDataChannel = require('./datachannel');
var RTCDataChannelEvent = require('./datachannelevent');
//var RTCDataChannel = require('./datachannel');
//var RTCDataChannelEvent = require('./datachannelevent');
var RTCError = require('./error');
var RTCIceCandidate = require('./icecandidate');
var RTCPeerConnectionIceEvent = require('./rtcpeerconnectioniceevent');
Expand Down Expand Up @@ -128,23 +128,15 @@ function RTCPeerConnection(configuration, constraints) {
};

// [ToDo] onnegotiationneeded

/*
pc.ondatachannel = function ondatachannel(internalDC) {
dataChannels[internalDC.label] = internalDC;
var dc = new RTCDataChannel(internalDC);
that.dispatchEvent(new RTCDataChannelEvent('datachannel', {channel: dc}));

// Data channel may have transitioned to open before callbacks could be bound, so dispatch another event
/*if('open' == dc.readyState) {
process.nextTick(function() {
dc.dispatchEvent({type: 'open'});
console.log('@');
});
}*/
};

*/
pc.onaddstream = function onaddstream(internalMS) {
var ms = new MediaStream(internalMS);

Expand Down Expand Up @@ -277,7 +269,7 @@ function RTCPeerConnection(configuration, constraints) {
onError: failureCallback
});
};

/*
this.createDataChannel = function createDataChannel(label, dataChannelDict) {
dataChannelDict = dataChannelDict || {};
Expand All @@ -289,7 +281,7 @@ function RTCPeerConnection(configuration, constraints) {
dataChannels[label] = channel;
return new RTCDataChannel(channel);
};

*/
this.addStream = function addStream(stream, constraintsDict) {
constraintsDict = constraintsDict || {};

Expand Down
12 changes: 6 additions & 6 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
#include "talk/base/ssladapter.h"

#include "peerconnection.h"
#include "datachannel.h"
#include "mediastream.h"
#include "mediastreamtrack.h"
//#include "datachannel.h"
//#include "mediastream.h"
//#include "mediastreamtrack.h"

using namespace v8;

void init(Handle<Object> exports) {
talk_base::InitializeSSL();
PeerConnection::Init(exports);
DataChannel::Init(exports);
MediaStream::Init(exports);
MediaStreamTrack::Init(exports);
//DataChannel::Init(exports);
//MediaStream::Init(exports);
//MediaStreamTrack::Init(exports);
}

NODE_MODULE(wrtc, init)
19 changes: 19 additions & 0 deletions src/create-answer-observer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "create-answer-observer.h"
#include "peerconnection.h"
#include "common.h"

void CreateAnswerObserver::OnSuccess(webrtc::SessionDescriptionInterface* sdp)
{
TRACE_CALL;
PeerConnection::SdpEvent* data = new PeerConnection::SdpEvent(sdp);
parent->QueueEvent(PeerConnection::CREATE_ANSWER_SUCCESS, static_cast<void*>(data));
TRACE_END;
}

void CreateAnswerObserver::OnFailure(const std::string& msg)
{
TRACE_CALL;
PeerConnection::ErrorEvent* data = new PeerConnection::ErrorEvent(msg);
parent->QueueEvent(PeerConnection::CREATE_ANSWER_ERROR, (void*)data);
TRACE_END;
}
16 changes: 16 additions & 0 deletions src/create-answer-observer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "talk/app/webrtc/peerconnectioninterface.h"

class PeerConnection;

class CreateAnswerObserver
: public webrtc::CreateSessionDescriptionObserver
{
private:
PeerConnection* parent;

public:
CreateAnswerObserver( PeerConnection* connection ): parent(connection) {};

virtual void OnSuccess( webrtc::SessionDescriptionInterface* sdp );
virtual void OnFailure( const std::string& msg );
};
19 changes: 19 additions & 0 deletions src/create-offer-observer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "create-offer-observer.h"
#include "peerconnection.h"
#include "common.h"

void CreateOfferObserver::OnSuccess(webrtc::SessionDescriptionInterface* sdp)
{
TRACE_CALL;
PeerConnection::SdpEvent* data = new PeerConnection::SdpEvent(sdp);
parent->QueueEvent(PeerConnection::CREATE_OFFER_SUCCESS, static_cast<void*>(data));
TRACE_END;
}

void CreateOfferObserver::OnFailure(const std::string& msg)
{
TRACE_CALL;
PeerConnection::ErrorEvent* data = new PeerConnection::ErrorEvent(msg);
parent->QueueEvent(PeerConnection::CREATE_OFFER_ERROR, (void*)data);
TRACE_END;
}
16 changes: 16 additions & 0 deletions src/create-offer-observer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "talk/app/webrtc/peerconnectioninterface.h"

class PeerConnection;

class CreateOfferObserver
: public webrtc::CreateSessionDescriptionObserver
{
private:
PeerConnection* parent;

public:
CreateOfferObserver( PeerConnection* connection ): parent(connection) {};

virtual void OnSuccess( webrtc::SessionDescriptionInterface* sdp );
virtual void OnFailure( const std::string& msg );
};
Loading

0 comments on commit 3642bee

Please sign in to comment.