Skip to content

Instantly share code, notes, and snippets.

@amitu
Created May 25, 2015 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitu/fc5ee75ed9f46c41e380 to your computer and use it in GitHub Desktop.
Save amitu/fc5ee75ed9f46c41e380 to your computer and use it in GitHub Desktop.
gowrap
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc
index 5226041..4e5daea 100644
--- a/talk/app/webrtc/peerconnection.cc
+++ b/talk/app/webrtc/peerconnection.cc
@@ -41,6 +41,8 @@
#include "webrtc/base/stringencode.h"
#include "webrtc/system_wrappers/interface/field_trial.h"
+// extern void (*go_Println)(const char*);
+
namespace {
using webrtc::PeerConnectionInterface;
@@ -505,8 +507,10 @@ PeerConnection::CreateDataChannel(
void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) {
+ // go_Println("ICC1");
if (!VERIFY(observer != NULL)) {
LOG(LS_ERROR) << "CreateOffer - observer is NULL.";
+ // go_Println("ICC1: NULL");
return;
}
RTCOfferAnswerOptions options;
@@ -551,15 +555,19 @@ void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
options.use_rtp_mux = value;
}
+ // go_Println("ICC22");
CreateOffer(observer, options);
}
void PeerConnection::CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {
+ // go_Println("ICC12");
if (!VERIFY(observer != NULL)) {
LOG(LS_ERROR) << "CreateOffer - observer is NULL.";
+ // go_Println("ICC12:NULL");
return;
}
+ // go_Println("ICC1233");
session_->CreateOffer(observer, options);
}
diff --git a/talk/app/webrtc/peerconnectionfactory.cc b/talk/app/webrtc/peerconnectionfactory.cc
index 1c93376..31365b4 100644
--- a/talk/app/webrtc/peerconnectionfactory.cc
+++ b/talk/app/webrtc/peerconnectionfactory.cc
@@ -47,6 +47,8 @@
#include "webrtc/base/bind.h"
#include "webrtc/modules/audio_device/include/audio_device.h"
+#include <iostream>
+
namespace webrtc {
rtc::scoped_refptr<PeerConnectionFactoryInterface>
@@ -207,10 +209,13 @@ PeerConnectionFactory::CreatePeerConnection(
PortAllocatorFactoryInterface* allocator_factory,
DTLSIdentityServiceInterface* dtls_identity_service,
PeerConnectionObserver* observer) {
+ std::cout << "CreatePeerConnection" << std::endl;
DCHECK(signaling_thread_->IsCurrent());
DCHECK(allocator_factory || default_allocator_factory_);
+ std::cout << "CreatePeerConnection2" << std::endl;
if (!dtls_identity_service) {
+ std::cout << "CreatePeerConnection:if" << std::endl;
dtls_identity_service = new DtlsIdentityService(dtls_identity_store_.get());
}
@@ -218,17 +223,28 @@ PeerConnectionFactory::CreatePeerConnection(
allocator_factory ? allocator_factory : default_allocator_factory_.get();
chosen_allocator_factory->SetNetworkIgnoreMask(options_.network_ignore_mask);
+ std::cout << "CreatePeerConnection3" << std::endl;
+
rtc::scoped_refptr<PeerConnection> pc(
new rtc::RefCountedObject<PeerConnection>(this));
+
+ std::cout << "CreatePeerConnection4" << std::endl;
+
if (!pc->Initialize(
configuration,
constraints,
chosen_allocator_factory,
dtls_identity_service,
observer)) {
+ std::cout << "CreatePeerConnection:null" << std::endl;
return NULL;
}
- return PeerConnectionProxy::Create(signaling_thread(), pc);
+
+ std::cout << "CreatePeerConnection4" << std::endl;
+ rtc::scoped_refptr<PeerConnectionInterface> pcp;
+ pcp = PeerConnectionProxy::Create(signaling_thread(), pc);
+ std::cout << "CreatePeerConnection5" << std::endl;
+ return pcp;
}
rtc::scoped_refptr<MediaStreamInterface>
diff --git a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
index aab24cf..0c68c17 100644
--- a/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
+++ b/talk/app/webrtc/webrtcsessiondescriptionfactory.cc
@@ -34,6 +34,8 @@
#include "talk/app/webrtc/mediastreamsignaling.h"
#include "talk/app/webrtc/webrtcsession.h"
+// extern void (*go_Println)(const char*);
+
using cricket::MediaSessionOptions;
namespace webrtc {
@@ -156,6 +158,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
}
if (identity_service_.get()) {
+ // go_Println("identity_service_.get");
identity_request_observer_ =
new rtc::RefCountedObject<WebRtcIdentityRequestObserver>();
@@ -175,6 +178,7 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
identity_request_state_ = IDENTITY_FAILED;
}
} else {
+ // go_Println("identity_service_.else");
identity_request_state_ = IDENTITY_WAITING;
// Do not generate the identity in the constructor since the caller has
// not got a chance to connect to SignalIdentityReady.
@@ -189,6 +193,8 @@ WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
void WebRtcSessionDescriptionFactory::CreateOffer(
CreateSessionDescriptionObserver* observer,
const PeerConnectionInterface::RTCOfferAnswerOptions& options) {
+ // go_Println("WebRtcSessionDescriptionFactory:CreateOffer");
+
cricket::MediaSessionOptions session_options;
std::string error = "CreateOffer";
@@ -196,6 +202,7 @@ void WebRtcSessionDescriptionFactory::CreateOffer(
error += kFailedDueToIdentityFailed;
LOG(LS_ERROR) << error;
PostCreateSessionDescriptionFailed(observer, error);
+ // go_Println("WebRtcSessionDescriptionFactory:err1");
return;
}
@@ -204,12 +211,14 @@ void WebRtcSessionDescriptionFactory::CreateOffer(
error += " called with invalid options.";
LOG(LS_ERROR) << error;
PostCreateSessionDescriptionFailed(observer, error);
+ // go_Println("WebRtcSessionDescriptionFactory:err2");
return;
}
if (!ValidStreams(session_options.streams)) {
error += " called with invalid media streams.";
LOG(LS_ERROR) << error;
+ // go_Println("WebRtcSessionDescriptionFactory:err3");
PostCreateSessionDescriptionFailed(observer, error);
return;
}
@@ -221,11 +230,14 @@ void WebRtcSessionDescriptionFactory::CreateOffer(
CreateSessionDescriptionRequest request(
CreateSessionDescriptionRequest::kOffer, observer, session_options);
+
if (identity_request_state_ == IDENTITY_WAITING) {
create_session_description_requests_.push(request);
+ // go_Println("WebRtcSessionDescriptionFactory:if");
} else {
ASSERT(identity_request_state_ == IDENTITY_SUCCEEDED ||
identity_request_state_ == IDENTITY_NOT_NEEDED);
+ // go_Println("WebRtcSessionDescriptionFactory:if-else");
InternalCreateOffer(request);
}
}
@@ -339,11 +351,13 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
ASSERT(session_version_ + 1 > session_version_);
JsepSessionDescription* offer(new JsepSessionDescription(
JsepSessionDescription::kOffer));
+ // go_Println("WebRtcSessionDescriptionFactory:In1");
if (!offer->Initialize(desc, session_id_,
rtc::ToString(session_version_++))) {
delete offer;
PostCreateSessionDescriptionFailed(request.observer,
"Failed to initialize the offer.");
+ // go_Println("WebRtcSessionDescriptionFactory:In:err1");
return;
}
if (session_->local_description() &&
@@ -352,6 +366,7 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
// the an ice restart has been requested.
CopyCandidatesFromSessionDescription(session_->local_description(), offer);
}
+ // go_Println("WebRtcSessionDescriptionFactory:In2");
PostCreateSessionDescriptionSucceeded(request.observer, offer);
}
@@ -411,12 +426,17 @@ void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionFailed(
void WebRtcSessionDescriptionFactory::PostCreateSessionDescriptionSucceeded(
CreateSessionDescriptionObserver* observer,
SessionDescriptionInterface* description) {
+
+ // go_Println("WebRtcSessionDescriptionFactory:PostCreateSessionDescriptionSucceeded");
+
+
CreateSessionDescriptionMsg* msg = new CreateSessionDescriptionMsg(observer);
msg->description.reset(description);
signaling_thread_->Post(this, MSG_CREATE_SESSIONDESCRIPTION_SUCCESS, msg);
}
void WebRtcSessionDescriptionFactory::OnIdentityRequestFailed(int error) {
+ // go_Println("OnIdentityRequestFailed");
ASSERT(signaling_thread_->IsCurrent());
LOG(LS_ERROR) << "Async identity request failed: error = " << error;
@@ -437,7 +457,7 @@ void WebRtcSessionDescriptionFactory::OnIdentityRequestFailed(int error) {
void WebRtcSessionDescriptionFactory::SetIdentity(
rtc::SSLIdentity* identity) {
LOG(LS_VERBOSE) << "Setting new identity";
-
+ // go_Println("SetIdentity");
identity_request_state_ = IDENTITY_SUCCEEDED;
SignalIdentityReady(identity);
diff --git a/third_party/gowrap/data_channel.cc b/third_party/gowrap/data_channel.cc
new file mode 100644
index 0000000..864b966
--- /dev/null
+++ b/third_party/gowrap/data_channel.cc
@@ -0,0 +1,114 @@
+#include "talk/app/webrtc/datachannelinterface.h"
+#include "talk/app/webrtc/peerconnectioninterface.h"
+
+#include "gowrap.h"
+
+void (*go_Ref_Unregister)(Ref);
+void (*go_DataChannel_OnStateChange)(Ref);
+void (*go_DataChannel_OnMessage)(Ref, void*, int);
+int (*go_DataChannelOptions_Ordered)(Ref);
+int (*go_DataChannelOptions_MaxRetransmitTime)(Ref);
+int (*go_DataChannelOptions_MaxRetransmits)(Ref);
+char* (*go_DataChannelOptions_Protocol)(Ref);
+int (*go_DataChannelOptions_Negotiated)(Ref);
+int (*go_DataChannelOptions_Id)(Ref);
+
+extern "C" {
+
+using rtc::scoped_refptr;
+using rtc::RefCountedObject;
+
+class dataChannelObserver : public webrtc::DataChannelObserver {
+
+public:
+ dataChannelObserver(Ref ref) {
+ _ref = ref;
+ }
+
+ ~dataChannelObserver() {
+ go_Ref_Unregister(_ref);
+ }
+
+ void OnStateChange()
+ {
+ go_DataChannel_OnStateChange(_ref);
+ }
+
+ void OnMessage(const webrtc::DataBuffer& buffer)
+ {
+ go_DataChannel_OnMessage(_ref, (void*)buffer.data.data(), buffer.size());
+ }
+
+private:
+ Ref _ref;
+};
+
+
+void* c_DataChannel_Create(void* _pc, char* label, Ref _ref) {
+ if (_pc == NULL || label == NULL) return NULL;
+ webrtc::PeerConnectionInterface* pc = (webrtc::PeerConnectionInterface*)_pc;
+
+ std::string _label = label;
+ if (label != NULL) free(label);
+
+ webrtc::DataChannelInit* options = new webrtc::DataChannelInit();
+ options->ordered = go_DataChannelOptions_Ordered(_ref) == 1 ? true : false;
+ options->maxRetransmitTime = go_DataChannelOptions_MaxRetransmitTime(_ref);
+ options->maxRetransmits = go_DataChannelOptions_MaxRetransmits(_ref);
+ options->protocol = go_DataChannelOptions_Protocol(_ref);
+ options->negotiated = go_DataChannelOptions_Negotiated(_ref) == 1 ? true : false;
+ options->id = go_DataChannelOptions_Id(_ref);
+
+ scoped_refptr<webrtc::DataChannelInterface> dc =
+ pc->CreateDataChannel(_label, options);
+ if (dc == NULL) {
+ return NULL;
+ }
+
+ dataChannelObserver* observer = new dataChannelObserver(_ref);
+ dc->RegisterObserver(observer);
+
+ webrtc::DataChannelInterface* _dc = dc.get();
+ _dc->AddRef();
+ return _dc;
+}
+
+void c_DataChannel_Accept(void* _dc, Ref _ref)
+{
+ if (_dc == NULL) return;
+ webrtc::DataChannelInterface* dc = (webrtc::DataChannelInterface*)_dc;
+
+ dataChannelObserver* observer = new dataChannelObserver(_ref);
+ dc->RegisterObserver(observer);
+}
+
+void c_DataChannel_Free(void* _dc) {
+ if (_dc == NULL) return;
+ webrtc::DataChannelInterface* dc = (webrtc::DataChannelInterface*)_dc;
+ dc->Release();
+}
+
+int c_DataChannel_State(void* _dc)
+{
+ if (_dc == NULL) return webrtc::DataChannelInterface::kClosed;
+ webrtc::DataChannelInterface* dc = (webrtc::DataChannelInterface*)_dc;
+ return dc->state();
+}
+
+int c_DataChannel_Send(void* _dc, char* bytes, int nbytes)
+{
+ if (_dc == NULL) return 0;
+ webrtc::DataChannelInterface* dc = (webrtc::DataChannelInterface*)_dc;
+ rtc::Buffer buffer(bytes, size_t(nbytes));
+ webrtc::DataBuffer data_buffer(buffer, false);
+ return dc->Send(data_buffer);
+}
+
+void c_DataChannel_Close(void* _dc)
+{
+ if (_dc == NULL) return;
+ webrtc::DataChannelInterface* dc = (webrtc::DataChannelInterface*)_dc;
+ dc->Close();
+}
+
+} // extern "C"
diff --git a/third_party/gowrap/data_channel.h b/third_party/gowrap/data_channel.h
new file mode 100644
index 0000000..3f75f98
--- /dev/null
+++ b/third_party/gowrap/data_channel.h
@@ -0,0 +1,19 @@
+#ifndef _DATA_CHANNEL
+#define _DATA_CHANNEL
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "gowrap.h"
+
+extern void* c_DataChannel_Create(void* _pc, char* label, Ref _ref);
+extern void c_DataChannel_Accept(void* _dc, Ref _ref);
+extern void c_DataChannel_Free(void* _dc);
+extern int c_DataChannel_State(void* _dc);
+extern int c_DataChannel_Send(void* _dc, void* bytes, int nbytes);
+extern void c_DataChannel_Close(void* _dc);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+#endif
diff --git a/third_party/gowrap/dctest.cc b/third_party/gowrap/dctest.cc
new file mode 100644
index 0000000..2b8a955
--- /dev/null
+++ b/third_party/gowrap/dctest.cc
@@ -0,0 +1,25 @@
+#include <iostream>
+#include <unistd.h>
+
+#include "webrtc/base/ssladapter.h"
+
+#include "peerconnection.h"
+
+extern "C" {
+ void go_Println(const char *msg) {
+ std::cout << msg << std::endl;
+ }
+}
+
+int main() {
+ go_Println("yo");
+ rtc::InitializeSSL();
+
+ PeerConnection *pc = new PeerConnection();
+
+ std::cout << pc << std::endl;
+
+ go_Println("gopin to sle");
+ usleep(10 * 1000 * 1000);
+ go_Println("done");
+}
diff --git a/third_party/gowrap/gowrap.cc b/third_party/gowrap/gowrap.cc
new file mode 100644
index 0000000..9e2ae0f
--- /dev/null
+++ b/third_party/gowrap/gowrap.cc
@@ -0,0 +1,251 @@
+#include "webrtc/base/ssladapter.h"
+#include "talk/app/webrtc/peerconnectioninterface.h"
+#include "talk/app/webrtc/peerconnection.h"
+#include "talk/app/webrtc/test/fakeconstraints.h"
+
+#include "gowrap.h"
+#include "media_constraints_prv.h"
+
+void (*go_Println)(const char*);
+char* (*c_ICEServer_Username)(void*);
+char* (*c_ICEServer_URL)(void*);
+char* (*c_ICEServer_Password)(void*);
+extern void (*go_Ref_Unregister)(Ref);
+
+void (*c_RTCPeerConnectionObserver_OnError)(Ref);
+void (*c_RTCPeerConnectionObserver_OnSignalingChange)(Ref, int);
+void (*c_RTCPeerConnectionObserver_OnAddStream)(Ref);
+void (*c_RTCPeerConnectionObserver_OnRemoveStream)(Ref);
+void (*c_RTCPeerConnectionObserver_OnDataChannel)(Ref, void*);
+void (*c_RTCPeerConnectionObserver_OnRenegotiationNeeded)(Ref);
+void (*c_RTCPeerConnectionObserver_OnIceConnectionChange)(Ref, int);
+void (*c_RTCPeerConnectionObserver_OnIceGatheringChange)(Ref, int);
+void (*c_RTCPeerConnectionObserver_OnIceCandidate)(Ref, void*);
+
+void* (*go_IceCandidate_ToGo)(char*, int, char*);
+
+extern "C" {
+
+#define CreateRaw(T, ctor) \
+ rtc::scoped_refptr<T> _ptr = (ctor); \
+ T* _raw = _ptr.get(); \
+ _raw->AddRef(); \
+ return _raw;
+#define CastPtr(T, ptr) ((T*)ptr)
+
+using namespace webrtc;
+
+int WebRTC_InitializeSSL() {
+ return rtc::InitializeSSL();
+}
+
+int WebRTC_CleanupSSL() {
+ return rtc::CleanupSSL();
+}
+
+Factory WebRTC_PeerConnectionFactory_Create() {
+ CreateRaw(PeerConnectionFactoryInterface, webrtc::CreatePeerConnectionFactory());
+}
+
+void WebRTC_PeerConnectionFactory_Free(Factory ptr) {
+ if (ptr == NULL) return;
+ CastPtr(PeerConnectionFactoryInterface, ptr)->Release();
+}
+
+MediaStreamT WebRTC_CreateMediaStreamWithLabel(Factory ptr, char* clabel) {
+ PeerConnectionFactoryInterface* factory = CastPtr(PeerConnectionFactoryInterface, ptr);
+ std::string label = clabel;
+
+ CreateRaw(MediaStreamInterface, factory->CreateLocalMediaStream(label));
+}
+
+void WebRTC_MediaStream_Free(MediaStreamT ptr) {
+ if (ptr == NULL) return;
+ CastPtr(MediaStreamInterface, ptr)->Release();
+}
+
+void WebRTC_PeerConnection_Free(PeerConnectionT ptr) {
+ if (ptr == NULL) return;
+ CastPtr(PeerConnectionInterface, ptr)->Release();
+}
+
+class RTCPeerConnectionObserver : public PeerConnectionObserver {
+
+public:
+ RTCPeerConnectionObserver(Ref ref) {
+ go_Println("RTCPeerConnectionObserver:RTCPeerConnectionObserver()");
+ _ref = ref;
+ }
+
+ void OnError() {
+ go_Println("RTCPeerConnectionObserver:OnError");
+ c_RTCPeerConnectionObserver_OnError(_ref);
+ }
+
+ // Triggered when the SignalingState changed.
+ void OnSignalingChange(
+ PeerConnectionInterface::SignalingState new_state)
+ {
+ go_Println("RTCPeerConnectionObserver:OnSignalingChange");
+ c_RTCPeerConnectionObserver_OnSignalingChange(_ref, int(new_state));
+ }
+
+ // Triggered when media is received on a new stream from remote peer.
+ void OnAddStream(MediaStreamInterface* stream)
+ {
+ go_Println("RTCPeerConnectionObserver:OnAddStream");
+ c_RTCPeerConnectionObserver_OnAddStream(_ref);
+ }
+
+ // Triggered when a remote peer close a stream.
+ void OnRemoveStream(MediaStreamInterface* stream)
+ {
+ go_Println("RTCPeerConnectionObserver:OnRemoveStream");
+ c_RTCPeerConnectionObserver_OnRemoveStream(_ref);
+ }
+
+ // Triggered when a remote peer open a data channel.
+ // TODO(perkj): Make pure
+ void OnDataChannel(DataChannelInterface* data_channel)
+ {
+ // keep the channel
+ go_Println("RTCPeerConnectionObserver:OnDataChannel");
+ data_channel->AddRef();
+ c_RTCPeerConnectionObserver_OnDataChannel(_ref, data_channel);
+ }
+
+ // Triggered when renegotiation is needed, for example the ICE has restarted.
+ void OnRenegotiationNeeded()
+ {
+ go_Println("RTCPeerConnectionObserver:OnRenegotiationNeeded");
+ c_RTCPeerConnectionObserver_OnRenegotiationNeeded(_ref);
+ }
+
+ // Called any time the IceConnectionState changes
+ void OnIceConnectionChange(
+ PeerConnectionInterface::IceConnectionState new_state)
+ {
+ go_Println("RTCPeerConnectionObserver:OnIceConnectionChange");
+ c_RTCPeerConnectionObserver_OnIceConnectionChange(_ref, (int)new_state);
+ }
+
+ // Called any time the IceGatheringState changes
+ void OnIceGatheringChange(
+ PeerConnectionInterface::IceGatheringState new_state)
+ {
+ go_Println("RTCPeerConnectionObserver:OnIceGatheringChange");
+ c_RTCPeerConnectionObserver_OnIceGatheringChange(_ref, (int)new_state);
+ }
+
+ // New Ice candidate have been found.
+ void OnIceCandidate(const IceCandidateInterface* candidate)
+ {
+ go_Println("RTCPeerConnectionObserver:OnIceCandidate");
+ std::string sdp_mid = candidate->sdp_mid();
+ int sdp_mline_index = candidate->sdp_mline_index();
+ std::string sdp;
+
+ if (!candidate->ToString(&sdp)) {
+ return;
+ }
+
+ void* _candidate = go_IceCandidate_ToGo(
+ (char*)sdp_mid.c_str(),
+ sdp_mline_index,
+ (char*)sdp.c_str()
+ );
+
+ c_RTCPeerConnectionObserver_OnIceCandidate(_ref, _candidate);
+ }
+
+ ~RTCPeerConnectionObserver() {
+ go_Println("RTCPeerConnectionObserver:~RTCPeerConnectionObserver");
+ go_Ref_Unregister(_ref);
+ }
+
+private:
+ Ref _ref;
+};
+
+PeerConnectionT WebRTC_PeerConnection_Create(
+ Factory factory,
+ void* servers, int nservers,
+ void* constraints, int nconstraints,
+ Ref observerRef)
+{
+ // factory = NULL;
+ // servers = NULL;
+ // constraints = NULL;
+
+ go_Println("this");
+
+ // PeerConnectionInterface::IceServers iceServers;
+ // void** rservers = (void**)servers;
+ // void** rconstraints = (void**)constraints;
+
+ // // collect servers
+ // for (int i = 0; i < nservers; i++) {
+ // PeerConnectionInterface::IceServer iceServer;
+ // iceServer.uri = c_ICEServer_URL(rservers[i]);
+ // iceServer.username = c_ICEServer_Username(rservers[i]);
+ // iceServer.password = c_ICEServer_Password(rservers[i]);
+ // iceServers.push_back(iceServer);
+ // }
+
+ // setup observer
+ PeerConnectionObserver* observer = new RTCPeerConnectionObserver(observerRef);
+ // MediaConstraintsInterface* mconstraints = new MediaConstraints(rconstraints, nconstraints);
+
+ webrtc::FakeConstraints fconstraints;
+ fconstraints.AddOptional(webrtc::MediaConstraintsInterface::kEnableDtlsSrtp, webrtc::MediaConstraintsInterface::kValueTrue);
+ // FIXME: crashes without these constraints, why?
+ fconstraints.AddMandatory(webrtc::MediaConstraintsInterface::kOfferToReceiveAudio, webrtc::MediaConstraintsInterface::kValueFalse);
+ fconstraints.AddMandatory(webrtc::MediaConstraintsInterface::kOfferToReceiveVideo, webrtc::MediaConstraintsInterface::kValueFalse);
+
+ webrtc::PeerConnectionInterface::IceServers _iceServers;
+ webrtc::PeerConnectionInterface::IceServer iceServer;
+ iceServer.uri = "stun:stun.l.google.com:19302";
+ _iceServers.push_back(iceServer);
+
+ CreateRaw(
+ PeerConnectionInterface,
+ CastPtr(PeerConnectionFactoryInterface, factory)->CreatePeerConnection(
+ _iceServers,
+ &fconstraints,
+ NULL,
+ NULL,
+ observer
+ )
+ );
+}
+
+int WebRTC_PeerConnection_UpdateICE(
+ PeerConnectionT ptr,
+ void* servers, int nservers,
+ void* constraints, int nconstraints)
+{
+ go_Println("yo1");
+ if (ptr == NULL) return 0;
+ go_Println("yo");
+
+ PeerConnectionInterface* pc = CastPtr(PeerConnectionInterface, ptr);
+
+ PeerConnectionInterface::IceServers iceServers;
+ void** rservers = (void**)servers;
+ void** rconstraints = (void**)constraints;
+
+ // collect servers
+ for (int i = 0; i < nservers; i++) {
+ PeerConnectionInterface::IceServer iceServer;
+ iceServer.uri = c_ICEServer_URL(rservers[i]);
+ iceServer.username = c_ICEServer_Username(rservers[i]);
+ iceServer.password = c_ICEServer_Password(rservers[i]);
+ iceServers.push_back(iceServer);
+ }
+
+ MediaConstraintsInterface* mconstraints = new MediaConstraints(rconstraints, nconstraints);
+
+ return pc->UpdateIce(iceServers, mconstraints);
+}
+
+} // extern "C"
diff --git a/third_party/gowrap/gowrap.h b/third_party/gowrap/gowrap.h
new file mode 100644
index 0000000..5710ef0
--- /dev/null
+++ b/third_party/gowrap/gowrap.h
@@ -0,0 +1,46 @@
+#ifndef _GOWRAP_H
+#define _GOWRAP_H
+
+// #include "media_constraints_prv.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdlib.h>
+
+typedef void* Factory;
+typedef uint64_t Ref;
+typedef void* PeerConnectionT;
+typedef void* IceCandidate;
+typedef void* MediaStreamT;
+
+
+int WebRTC_InitializeSSL();
+int WebRTC_CleanupSSL();
+Factory WebRTC_PeerConnectionFactory_Create();
+void WebRTC_PeerConnectionFactory_Free(Factory);
+MediaStreamT WebRTC_CreateMediaStreamWithLabel(Factory ptr, char* clabel);
+void WebRTC_MediaStream_Free(MediaStreamT);
+void WebRTC_PeerConnection_Free(PeerConnectionT ptr);
+
+PeerConnectionT WebRTC_PeerConnection_Create(
+ Factory factory,
+ void* servers, int nservers,
+ void* constraints, int nconstraints,
+ Ref observerRef);
+
+int WebRTC_PeerConnection_UpdateICE(
+ PeerConnectionT ptr,
+ void* servers, int nservers,
+ void* constraints, int nconstraints);
+
+#ifdef __cplusplus
+} // extern "C"
+#else
+
+
+#endif
+
+#endif //_GOWRAP_H
diff --git a/third_party/gowrap/ice_candidate.cc b/third_party/gowrap/ice_candidate.cc
new file mode 100644
index 0000000..d510a7e
--- /dev/null
+++ b/third_party/gowrap/ice_candidate.cc
@@ -0,0 +1,51 @@
+#include <cstdlib>
+#include <cstring>
+#include <string>
+
+#include "talk/app/webrtc/jsep.h"
+#include "talk/app/webrtc/peerconnectioninterface.h"
+
+#include "ice_candidate.h"
+
+char* (*go_IceCandidate_GetSdpMid)(void*);
+int (*go_IceCandidate_GetSdpMlineIndex)(void*);
+char* (*go_IceCandidate_GetCandidate)(void*);
+
+extern "C" {
+
+using rtc::scoped_refptr;
+using rtc::RefCountedObject;
+using webrtc::PeerConnectionInterface;
+
+char* c_PeerConnection_AddIceCandidate(
+ void* _pc, void* _candidate)
+{
+ if (_pc == NULL || _candidate == NULL) return strdup(errNillNotAllowed);
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+
+ std::string sdp_mid;
+ int sdp_mline_index;
+ std::string sdp;
+ webrtc::SdpParseError error;
+ webrtc::IceCandidateInterface* candidate;
+
+ sdp_mid = go_IceCandidate_GetSdpMid(_candidate);
+ sdp_mline_index = go_IceCandidate_GetSdpMlineIndex(_candidate);
+ sdp = go_IceCandidate_GetCandidate(_candidate);
+
+ candidate = webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, sdp, &error);
+ if (candidate == NULL) {
+ return strdup(error.description.c_str());
+ }
+
+ bool ok = pc->AddIceCandidate(candidate);
+ if (!ok) {
+ delete candidate;
+ return strdup(errFailedToAddIceCandidate);
+ }
+
+ delete candidate;
+ return NULL;
+}
+
+} // extern "C"
diff --git a/third_party/gowrap/ice_candidate.h b/third_party/gowrap/ice_candidate.h
new file mode 100644
index 0000000..a0fd8e2
--- /dev/null
+++ b/third_party/gowrap/ice_candidate.h
@@ -0,0 +1,16 @@
+#ifndef _ICE_CANDIDATE
+#define _ICE_CANDIDATE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static const char* errNillNotAllowed = "nil arguments are not allowed";
+static const char* errFailedToAddIceCandidate = "failed to add ice candidate";
+
+extern char* c_PeerConnection_AddIceCandidate(
+ void* _pc, void* _candidate);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+#endif
diff --git a/third_party/gowrap/media_constraints.cc b/third_party/gowrap/media_constraints.cc
new file mode 100644
index 0000000..c52b994
--- /dev/null
+++ b/third_party/gowrap/media_constraints.cc
@@ -0,0 +1,38 @@
+
+#include "media_constraints_prv.h"
+
+int (*go_MediaConstraint_Optional)(void*);
+char* (*go_MediaConstraint_Key)(void*);
+char* (*go_MediaConstraint_Value)(void*);
+
+extern "C" {
+
+MediaConstraints::MediaConstraints(void** ptr, int len) {
+ for (int i=0; i<len; i++) {
+ if (go_MediaConstraint_Optional(ptr[i]) > 0) {
+ optional.push_back(webrtc::MediaConstraintsInterface::Constraint(
+ go_MediaConstraint_Key(ptr[i]),
+ go_MediaConstraint_Value(ptr[i])
+ ));
+ } else {
+ mandatory.push_back(webrtc::MediaConstraintsInterface::Constraint(
+ go_MediaConstraint_Key(ptr[i]),
+ go_MediaConstraint_Value(ptr[i])
+ ));
+ }
+ }
+}
+
+const webrtc::MediaConstraintsInterface::Constraints& MediaConstraints::GetMandatory() const {
+ return mandatory;
+}
+
+const webrtc::MediaConstraintsInterface::Constraints& MediaConstraints::GetOptional() const {
+ return optional;
+}
+
+MediaConstraints::~MediaConstraints() {
+
+}
+
+} // extern "C"
diff --git a/third_party/gowrap/media_constraints_prv.h b/third_party/gowrap/media_constraints_prv.h
new file mode 100644
index 0000000..a5a3b9d
--- /dev/null
+++ b/third_party/gowrap/media_constraints_prv.h
@@ -0,0 +1,18 @@
+#ifndef _MEDIA_CONSTRAINTS
+#define _MEDIA_CONSTRAINTS
+
+#include "talk/app/webrtc/mediaconstraintsinterface.h"
+
+class MediaConstraints : public webrtc::MediaConstraintsInterface {
+public:
+ MediaConstraints(void** ptr, int len);
+ const webrtc::MediaConstraintsInterface::Constraints& GetMandatory() const;
+ const webrtc::MediaConstraintsInterface::Constraints& GetOptional() const;
+ ~MediaConstraints();
+
+private:
+ webrtc::MediaConstraintsInterface::Constraints mandatory;
+ webrtc::MediaConstraintsInterface::Constraints optional;
+};
+
+#endif
diff --git a/third_party/gowrap/offeranswerobserver.cc b/third_party/gowrap/offeranswerobserver.cc
new file mode 100644
index 0000000..696044a
--- /dev/null
+++ b/third_party/gowrap/offeranswerobserver.cc
@@ -0,0 +1,21 @@
+#include "offeranswerobserver.h"
+#include "peerconnection.h"
+
+#include <iostream>
+
+void OfferAnswerObserver::OnSuccess(webrtc::SessionDescriptionInterface* sdp)
+{
+ std::cout << "OfferAnswerObserver::OnSuccess" << parent << std::endl;
+ // PeerConnection::SdpEvent* data = new PeerConnection::SdpEvent(sdp);
+ // parent->QueueEvent(PeerConnection::CREATE_ANSWER_SUCCESS, static_cast<void*>(data));
+ // TRACE_END;
+}
+
+void OfferAnswerObserver::OnFailure(const std::string& msg)
+{
+ std::cout << "OfferAnswerObserver::OnFailure:->" << msg << std::endl;
+ // TRACE_CALL;
+ // PeerConnection::ErrorEvent* data = new PeerConnection::ErrorEvent(msg);
+ // parent->QueueEvent(PeerConnection::CREATE_ANSWER_ERROR, (void*)data);
+ // TRACE_END;
+}
diff --git a/third_party/gowrap/offeranswerobserver.h b/third_party/gowrap/offeranswerobserver.h
new file mode 100644
index 0000000..b081ccc
--- /dev/null
+++ b/third_party/gowrap/offeranswerobserver.h
@@ -0,0 +1,21 @@
+#ifndef __OFFER_ANSWER_OBSERBER
+#define __OFFER_ANSWER_OBSERBER
+
+#include "talk/app/webrtc/peerconnectioninterface.h"
+
+class PeerConnection;
+
+class OfferAnswerObserver
+ : public webrtc::CreateSessionDescriptionObserver
+{
+ private:
+ PeerConnection* parent;
+
+ public:
+ OfferAnswerObserver( PeerConnection* connection ): parent(connection) {};
+
+ virtual void OnSuccess( webrtc::SessionDescriptionInterface* sdp );
+ virtual void OnFailure( const std::string& msg );
+};
+
+#endif
diff --git a/third_party/gowrap/peerconnection.cc b/third_party/gowrap/peerconnection.cc
new file mode 100644
index 0000000..b80b4e3
--- /dev/null
+++ b/third_party/gowrap/peerconnection.cc
@@ -0,0 +1,99 @@
+#include <iostream>
+
+#include "peerconnection.h"
+#include "talk/app/webrtc/peerconnectioninterface.h"
+#include "talk/app/webrtc/peerconnection.h"
+#include "talk/app/webrtc/test/fakeconstraints.h"
+
+PeerConnection::PeerConnection(
+)
+{
+ oaObserver = new rtc::RefCountedObject<OfferAnswerObserver>( this );
+ factory = webrtc::CreatePeerConnectionFactory();
+
+ std::cout << "here" << std::endl;
+ webrtc::PeerConnectionInterface::IceServer iceServer;
+ iceServer.uri = "stun:stun.l.google.com:19302";
+ _iceServers.push_back(iceServer);
+
+ std::cout << "here" << std::endl;
+
+ webrtc::FakeConstraints constraints;
+ constraints.AddOptional(
+ webrtc::MediaConstraintsInterface::kEnableDtlsSrtp,
+ webrtc::MediaConstraintsInterface::kValueTrue
+ );
+
+ std::cout << "here" << std::endl;
+ // FIXME: crashes without these constraints, why?
+ constraints.AddMandatory(
+ webrtc::MediaConstraintsInterface::kOfferToReceiveAudio,
+ webrtc::MediaConstraintsInterface::kValueFalse
+ );
+ constraints.AddMandatory(
+ webrtc::MediaConstraintsInterface::kOfferToReceiveVideo,
+ webrtc::MediaConstraintsInterface::kValueFalse
+ );
+ std::cout << "here " << factory << std::endl;
+
+ pc = factory->CreatePeerConnection(
+ _iceServers, &constraints, NULL, NULL, this
+ );
+
+ webrtc::DataChannelInit dataChannelInit;
+ dataChannelInit.id = 123;
+ dataChannelInit.maxRetransmitTime = 0;
+ dataChannelInit.maxRetransmits = 0;
+ dataChannelInit.negotiated = true;
+ dataChannelInit.ordered = true;
+ // dataChannelInit.protocol =
+
+ const char *label = "asd";
+
+ data_channel_interface = pc->CreateDataChannel(label, &dataChannelInit);
+ // DataChannelObserver* observer = new DataChannelObserver(data_channel_interface);
+
+ std::cout << label << " ->> " << data_channel_interface << std::endl;
+
+ pc->CreateOffer(oaObserver, NULL);
+
+ std::cout << "here" << std::endl;
+}
+
+void PeerConnection::OnError() {
+ std::cout << "PeerConnection::OnError" << std::endl;
+}
+
+void PeerConnection::OnSignalingChange(
+ webrtc::PeerConnectionInterface::SignalingState new_state
+) {
+ std::cout << "PeerConnection::OnSignalingChange" << std::endl;
+}
+
+void PeerConnection::OnIceConnectionChange( webrtc::PeerConnectionInterface::IceConnectionState new_state ) {
+ std::cout << "PeerConnection::OnIceConnectionChange" << std::endl;
+}
+
+void PeerConnection::OnIceGatheringChange( webrtc::PeerConnectionInterface::IceGatheringState new_state ) {
+ std::cout << "PeerConnection::OnIceGatheringChange" << std::endl;
+}
+
+void PeerConnection::OnIceCandidate( const webrtc::IceCandidateInterface* candidate ) {
+ std::cout << "PeerConnection::OnIceCandidate" << std::endl;
+}
+
+void PeerConnection::OnDataChannel( webrtc::DataChannelInterface* jingle_data_channel ) {
+ std::cout << "PeerConnection::OnDataChannel" << std::endl;
+}
+
+void PeerConnection::OnRenegotiationNeeded() {
+ std::cout << "PeerConnection::OnRenegotiationNeeded" << std::endl;
+}
+
+void PeerConnection::OnAddStream(webrtc::MediaStreamInterface* stream){
+ std::cout << "PeerConnection::OnAddStream" << std::endl;
+};
+
+void PeerConnection::OnRemoveStream(webrtc::MediaStreamInterface* stream){
+ std::cout << "PeerConnection::OnRemoveStream" << std::endl;
+};
diff --git a/third_party/gowrap/peerconnection.h b/third_party/gowrap/peerconnection.h
new file mode 100644
index 0000000..46e3412
--- /dev/null
+++ b/third_party/gowrap/peerconnection.h
@@ -0,0 +1,38 @@
+#ifndef __PEER_CONNECTION
+#define __PEER_CONNECTION
+
+#include "talk/app/webrtc/peerconnectioninterface.h"
+#include "offeranswerobserver.h"
+
+class PeerConnection
+: public webrtc::PeerConnectionObserver
+{
+
+public:
+ PeerConnection();
+ ~PeerConnection();
+
+ //
+ // PeerConnectionObserver implementation.
+ //
+ rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> factory;
+ rtc::scoped_refptr<OfferAnswerObserver> oaObserver;
+ webrtc::PeerConnectionInterface::IceServers _iceServers;
+ rtc::scoped_refptr<webrtc::PeerConnectionInterface> pc;
+ rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel_interface;
+
+ virtual void OnError();
+
+ virtual void OnSignalingChange( webrtc::PeerConnectionInterface::SignalingState new_state );
+ virtual void OnIceConnectionChange( webrtc::PeerConnectionInterface::IceConnectionState new_state );
+ virtual void OnIceGatheringChange( webrtc::PeerConnectionInterface::IceGatheringState new_state );
+ virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate );
+ virtual void OnRenegotiationNeeded();
+
+ virtual void OnDataChannel( webrtc::DataChannelInterface* data_channel );
+
+ virtual void OnAddStream(webrtc::MediaStreamInterface*);
+ virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream);
+};
+
+#endif
diff --git a/third_party/gowrap/session_description.cc b/third_party/gowrap/session_description.cc
new file mode 100644
index 0000000..7f3739f
--- /dev/null
+++ b/third_party/gowrap/session_description.cc
@@ -0,0 +1,211 @@
+#include <cstdlib>
+#include <cstring>
+#include <string>
+
+#include "talk/app/webrtc/jsep.h"
+#include "talk/app/webrtc/peerconnectioninterface.h"
+
+#include "session_description.h"
+#include "media_constraints_prv.h"
+
+extern void (*go_Println)(const char*);
+void (*go_SetSessionDescription_OnSuccess)(Ref);
+void (*go_SetSessionDescription_OnFailure)(Ref, char*);
+extern void (*go_Ref_Unregister)(Ref);
+void (*go_CreateSessionDescription_OnSuccess)(Ref, void*);
+void (*go_CreateSessionDescription_OnFailure)(Ref, char*);
+static const char* errNillNotAllowed = "nil arguments are not allowed";
+void* (*go_SessionDescription_New)(char*, char*);
+char* (*go_SessionDescription_GetType)(void*);
+char* (*go_SessionDescription_GetSdp)(void*);
+
+extern "C" {
+
+using rtc::scoped_refptr;
+using rtc::RefCountedObject;
+using webrtc::PeerConnectionInterface;
+
+void* c_SessionDescription_ToGo(const webrtc::SessionDescriptionInterface* desc);
+webrtc::SessionDescriptionInterface* c_SessionDescription_ToWebRTC(
+ void* desc, webrtc::SdpParseError* error);
+
+
+class setSessionDescriptionObserver : public webrtc::SetSessionDescriptionObserver {
+public:
+
+ static scoped_refptr<setSessionDescriptionObserver> Create(Ref ref) {
+ RefCountedObject<setSessionDescriptionObserver>* implementation =
+ new RefCountedObject<setSessionDescriptionObserver>(ref);
+ return implementation;
+ }
+
+ setSessionDescriptionObserver(Ref ref) {
+ _ref = ref;
+ }
+
+ void OnSuccess() {
+ go_SetSessionDescription_OnSuccess(_ref);
+ }
+
+ void OnFailure(const std::string& error) {
+ go_SetSessionDescription_OnFailure(_ref, (char*)error.c_str());
+ }
+
+protected:
+ ~setSessionDescriptionObserver() {
+ go_Ref_Unregister(_ref);
+ }
+
+private:
+ Ref _ref;
+};
+
+class createSessionDescriptionObserver : public webrtc::CreateSessionDescriptionObserver {
+public:
+
+ static scoped_refptr<createSessionDescriptionObserver> Create(Ref ref) {
+ RefCountedObject<createSessionDescriptionObserver>* implementation =
+ new RefCountedObject<createSessionDescriptionObserver>(ref);
+ go_Println("yo, Create");
+ return implementation;
+ }
+
+ createSessionDescriptionObserver(Ref ref) {
+ _ref = ref;
+ }
+
+ void OnSuccess(webrtc::SessionDescriptionInterface* desc) {
+ go_Println("yo, go_CreateSessionDescription_OnSuccess");
+ go_CreateSessionDescription_OnSuccess(_ref, c_SessionDescription_ToGo(desc));
+ }
+
+ void OnFailure(const std::string& error) {
+ go_Println("yo, go_CreateSessionDescription_OnFailure");
+ go_CreateSessionDescription_OnFailure(_ref, (char*)error.c_str());
+ }
+
+protected:
+ ~createSessionDescriptionObserver() {
+ go_Println("yo, go_Ref_Unregister");
+ go_Ref_Unregister(_ref);
+ }
+
+private:
+ Ref _ref;
+};
+
+
+void* c_PeerConnection_GetLocalDescription(void* _pc)
+{
+ if (_pc == NULL) return NULL;
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ return c_SessionDescription_ToGo(pc->local_description());
+}
+
+void* c_PeerConnection_GetRemoteDescription(void* _pc)
+{
+ if (_pc == NULL) return NULL;
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ return c_SessionDescription_ToGo(pc->remote_description());
+}
+
+
+char* c_PeerConnection_SetLocalDescription(
+ void* _pc, Ref _ref, void* _sd)
+{
+ if (_pc == NULL || _sd == NULL) return strdup(errNillNotAllowed);
+
+ webrtc::SdpParseError error;
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ webrtc::SessionDescriptionInterface* sd;
+
+ sd = c_SessionDescription_ToWebRTC(_sd, &error);
+ if (sd == NULL) {
+ return strdup(error.description.c_str());
+ }
+
+ scoped_refptr<setSessionDescriptionObserver> observer =
+ setSessionDescriptionObserver::Create(_ref);
+
+ pc->SetLocalDescription(observer, sd);
+ return NULL;
+}
+
+char* c_PeerConnection_SetRemoteDescription(
+ void* _pc, Ref _ref, void* _sd)
+{
+ if (_pc == NULL || _sd == NULL) return strdup(errNillNotAllowed);
+
+ webrtc::SdpParseError error;
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ webrtc::SessionDescriptionInterface* sd;
+
+ sd = c_SessionDescription_ToWebRTC(_sd, &error);
+ if (sd == NULL) {
+ return strdup(error.description.c_str());
+ }
+
+ scoped_refptr<setSessionDescriptionObserver> observer =
+ setSessionDescriptionObserver::Create(_ref);
+
+ pc->SetRemoteDescription(observer, sd);
+ return NULL;
+}
+
+void c_PeerConnection_CreateOffer(
+ void* _pc, Ref _ref,
+ void* constraints, int nconstraints)
+{
+ go_Println("yo, c_PeerConnection_CreateOffer");
+ if (_pc == NULL) return;
+ go_Println("yo, c_PeerConnection_CreateOffer2");
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ void** rconstraints = (void**)constraints;
+
+ scoped_refptr<createSessionDescriptionObserver> observer =
+ createSessionDescriptionObserver::Create(_ref);
+
+ go_Println("yo, c_PeerConnection_CreateOffer3");
+ pc->CreateOffer(observer,
+ // new MediaConstraints(rconstraints, nconstraints));
+ NULL);
+ go_Println("yo, c_PeerConnection_CreateOffer4");
+}
+
+void c_PeerConnection_CreateAnswer(
+ void* _pc, Ref _ref,
+ void* constraints, int nconstraints)
+{
+ if (_pc == NULL) return;
+ PeerConnectionInterface* pc = (PeerConnectionInterface*)_pc;
+ void** rconstraints = (void**)constraints;
+
+ scoped_refptr<createSessionDescriptionObserver> observer =
+ createSessionDescriptionObserver::Create(_ref);
+
+ pc->CreateAnswer(observer,
+ new MediaConstraints(rconstraints, nconstraints));
+}
+
+void* c_SessionDescription_ToGo(const webrtc::SessionDescriptionInterface* desc)
+{
+ if (desc == NULL) return NULL;
+
+ std::string sdp;
+ std::string type = desc->type();
+
+ if (!desc->ToString(&sdp)) return NULL;
+
+ return go_SessionDescription_New((char*)type.c_str(), (char*)sdp.c_str());
+}
+
+webrtc::SessionDescriptionInterface* c_SessionDescription_ToWebRTC(
+ void* desc, webrtc::SdpParseError* error)
+{
+ std::string type = go_SessionDescription_GetType(desc);
+ std::string sdp = go_SessionDescription_GetSdp(desc);
+ return webrtc::CreateSessionDescription(type, sdp, error);
+}
+
+
+} // extern "C"
diff --git a/third_party/gowrap/session_description.h b/third_party/gowrap/session_description.h
new file mode 100644
index 0000000..3e00492
--- /dev/null
+++ b/third_party/gowrap/session_description.h
@@ -0,0 +1,29 @@
+#ifndef _SESSION_DESCRIPTION
+#define _SESSION_DESCRIPTION
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "gowrap.h"
+
+extern void* c_PeerConnection_GetLocalDescription(
+ void* _pc);
+extern void* c_PeerConnection_GetRemoteDescription(
+ void* _pc);
+
+extern char* c_PeerConnection_SetLocalDescription(
+ void* _pc, Ref _ref, void* _sd);
+extern char* c_PeerConnection_SetRemoteDescription(
+ void* _pc, Ref _ref, void* _sd);
+
+extern void c_PeerConnection_CreateOffer(
+ void* _pc, Ref _ref,
+ void* constraints, int nconstraints);
+extern void c_PeerConnection_CreateAnswer(
+ void* _pc, Ref _ref,
+ void* constraints, int nconstraints);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+#endif
diff --git a/webrtc/base/base.gyp b/webrtc/base/base.gyp
index 6e197a5..c1c268e 100644
--- a/webrtc/base/base.gyp
+++ b/webrtc/base/base.gyp
@@ -92,6 +92,48 @@
],
},
{
+ 'target_name': 'dctest',
+ 'type': 'executable',
+ 'sources': [
+ '../../third_party/gowrap/dctest.cc',
+ '../../third_party/gowrap/peerconnection.cc',
+ '../../third_party/gowrap/peerconnection.h',
+ '../../third_party/gowrap/offeranswerobserver.cc',
+ '../../third_party/gowrap/offeranswerobserver.h',
+ ],
+ 'dependencies': [
+ '<(webrtc_root)/common.gyp:webrtc_common',
+ '../../third_party/boringssl/boringssl.gyp:boringssl',
+ '../base/base.gyp:rtc_base',
+ '../base/base_tests.gyp:rtc_base_tests_utils',
+ '../base/base_tests.gyp:rtc_base_tests',
+ '../libjingle/xmllite/xmllite.gyp:rtc_xmllite',
+ '../libjingle/xmpp/xmpp.gyp:rtc_xmpp',
+ '../p2p/p2p.gyp:rtc_p2p',
+ '../p2p/p2p.gyp:libstunprober',
+ '../sound/sound.gyp:rtc_sound',
+ '../../talk/libjingle.gyp:libjingle_peerconnection',
+ ],
+ },
+ {
+ 'target_name': 'gowrap',
+ 'type': 'static_library',
+ 'dependencies': [
+ ],
+ 'sources': [
+ '../../third_party/gowrap/gowrap.cc',
+ '../../third_party/gowrap/gowrap.h',
+ '../../third_party/gowrap/media_constraints.cc',
+ '../../third_party/gowrap/media_constraints_prv.h',
+ '../../third_party/gowrap/data_channel.cc',
+ '../../third_party/gowrap/data_channel.h',
+ '../../third_party/gowrap/ice_candidate.cc',
+ '../../third_party/gowrap/ice_candidate.h',
+ '../../third_party/gowrap/session_description.cc',
+ '../../third_party/gowrap/session_description.h',
+ ]
+ },
+ {
'target_name': 'rtc_base',
'type': 'static_library',
'dependencies': [
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment