aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-08 01:19:58 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-08 01:19:58 +0200
commit436ceaea56ecff755476a3796cff72e1da39dfc6 (patch)
tree5d8ebc02e999f777378df5e699f0b13a9827d622 /Software/Visual_Studio/SideChains
parent9d18d9ec9658af3716814625b608d58ad3daa14c (diff)
downloadTango-436ceaea56ecff755476a3796cff72e1da39dfc6.tar.gz
Tango-436ceaea56ecff755476a3796cff72e1da39dfc6.zip
Integrated WebRTC channel to PPC/FSE.
Diffstat (limited to 'Software/Visual_Studio/SideChains')
-rw-r--r--Software/Visual_Studio/SideChains/WebRtc.NET/WebRtc.NET.vcxproj2
-rw-r--r--Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.cc110
-rw-r--r--Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.h1
-rw-r--r--Software/Visual_Studio/SideChains/WebRtc.NET/src/managed.cpp14
4 files changed, 78 insertions, 49 deletions
diff --git a/Software/Visual_Studio/SideChains/WebRtc.NET/WebRtc.NET.vcxproj b/Software/Visual_Studio/SideChains/WebRtc.NET/WebRtc.NET.vcxproj
index a90ba240a..661997d3f 100644
--- a/Software/Visual_Studio/SideChains/WebRtc.NET/WebRtc.NET.vcxproj
+++ b/Software/Visual_Studio/SideChains/WebRtc.NET/WebRtc.NET.vcxproj
@@ -102,6 +102,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
+ <ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -148,6 +149,7 @@
</AdditionalUsingDirectories>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ <ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
diff --git a/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.cc b/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.cc
index 0bca34800..c7c4f3ba5 100644
--- a/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.cc
+++ b/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.cc
@@ -64,11 +64,11 @@ namespace Native
onIceCandidate = nullptr;
width_ = 640;
- height_ = 360;
+ height_ = 360;
caputureFps = 5;
audioEnabled = false;
- barcodeEnabled = false;
+ barcodeEnabled = false;
turnServer = nullptr;
data_channel = nullptr;
@@ -79,43 +79,67 @@ namespace Native
void Conductor::Dispose()
{
- DeletePeerConnection();
- ASSERT(peer_connection_ == nullptr);
-
- if (turnServer)
+ if (!_disposed)
{
- turnServer->disconnect_all();
- }
+ _disposed = true;
- if (stunServer)
- {
- stunServer->disconnect_all();
- }
+ try
+ {
+ DeletePeerConnection();
+ ASSERT(peer_connection_ == nullptr);
- if (turnServer || stunServer)
- {
- rtc::Thread::Current()->Quit();
+ if (turnServer)
+ {
+ turnServer->disconnect_all();
+ }
+
+ if (stunServer)
+ {
+ stunServer->disconnect_all();
+ }
+
+ if (turnServer || stunServer)
+ {
+ rtc::Thread::Current()->Quit();
+ }
+ }
+ catch (const std::exception&)
+ {
+ LOG(WARNING) << "Error in disposing conductor.cc";
+ }
}
}
Conductor::~Conductor()
{
- DeletePeerConnection();
- ASSERT(peer_connection_ == nullptr);
-
- if (turnServer)
+ if (!_disposed)
{
- turnServer->disconnect_all();
- }
+ _disposed = true;
- if (stunServer)
- {
- stunServer->disconnect_all();
- }
+ try
+ {
+ DeletePeerConnection();
+ ASSERT(peer_connection_ == nullptr);
- if (turnServer || stunServer)
- {
- rtc::Thread::Current()->Quit();
+ if (turnServer)
+ {
+ turnServer->disconnect_all();
+ }
+
+ if (stunServer)
+ {
+ stunServer->disconnect_all();
+ }
+
+ if (turnServer || stunServer)
+ {
+ rtc::Thread::Current()->Quit();
+ }
+ }
+ catch (const std::exception&)
+ {
+ LOG(WARNING) << "Error in disposing conductor.cc";
+ }
}
}
@@ -137,15 +161,17 @@ namespace Native
pc_factory_ = nullptr;
- if (data_channel)
- {
- data_channel->UnregisterObserver();
- data_channel = nullptr;
- }
- serverConfigs.clear();
+ //if (data_channel)
+ //{
+ //data_channel->Close();
+ //data_channel->UnregisterObserver();
+ //data_channel = nullptr;
+ //}
+
+ //serverConfigs.clear();
- capturer_internal = nullptr;
- capturer = nullptr;
+ //capturer_internal = nullptr;
+ //capturer = nullptr;
}
bool Conductor::InitializePeerConnection()
@@ -309,7 +335,7 @@ namespace Native
}
return device_names;
}
-
+
bool Conductor::OpenVideoCaptureDevice(std::string & name)
{
if (!capturer_internal)
@@ -345,7 +371,7 @@ namespace Native
if (onRenderLocal)
{
local_video.reset(new VideoRenderer(*this, false, video_track));
- }
+ }
auto stream = pc_factory_->CreateLocalMediaStream(kStreamLabel);
{
@@ -464,9 +490,9 @@ namespace Native
dc_options.maxRetransmits = 1;
dc_options.negotiated = false;
dc_options.ordered = false;
-
+
data_channel = peer_connection_->CreateDataChannel(label, &dc_options);
- data_channel->RegisterObserver(this);
+ data_channel->RegisterObserver(this);
}
void Conductor::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> channel)
@@ -536,7 +562,7 @@ namespace Native
}
bool Conductor::RunTurnServer(const std::string & bindIp, const std::string & ip,
- const std::string & realm, const std::string & authFile)
+ const std::string & realm, const std::string & authFile)
{
rtc::SocketAddress int_addr;
if (!int_addr.FromString(bindIp))
@@ -576,7 +602,7 @@ namespace Native
t->set_auth_hook(auth);
t->AddInternalSocket(int_socket, cricket::PROTO_UDP);
t->SetExternalSocketFactory(new rtc::BasicPacketSocketFactory(),
- rtc::SocketAddress(ext_addr, 0));
+ rtc::SocketAddress(ext_addr, 0));
LOG(INFO) << "Listening internally at " << int_addr.ToString() << std::endl;
diff --git a/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.h b/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.h
index 4f1a216ec..c002bc760 100644
--- a/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.h
+++ b/Software/Visual_Studio/SideChains/WebRtc.NET/src/conductor.h
@@ -208,6 +208,7 @@ namespace Native
private:
+ bool _disposed;
bool CreatePeerConnection(bool dtls);
void DeletePeerConnection();
void AddStreams();
diff --git a/Software/Visual_Studio/SideChains/WebRtc.NET/src/managed.cpp b/Software/Visual_Studio/SideChains/WebRtc.NET/src/managed.cpp
index 63db79dc2..284fc7e7f 100644
--- a/Software/Visual_Studio/SideChains/WebRtc.NET/src/managed.cpp
+++ b/Software/Visual_Studio/SideChains/WebRtc.NET/src/managed.cpp
@@ -233,6 +233,8 @@ namespace WebRtc
if (m_isDisposed)
return;
+ m_isDisposed = true;
+
cd->Dispose();
// dispose managed data
@@ -246,8 +248,6 @@ namespace WebRtc
FreeGCHandle(onDataMessageHandle);
//this->!ManagedConductor(); // call finalizer
-
- m_isDisposed = true;
}
static void InitializeSSL()
@@ -405,11 +405,11 @@ namespace WebRtc
!ManagedConductor()
{
// free unmanaged data
- if (cd != NULL)
- {
- delete cd;
- }
- cd = NULL;
+ //if (cd != NULL)
+ //{
+ // delete cd;
+ //}
+ //cd = NULL;
}
};
}