aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/SideChains/WebRtc.NET/src
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/SideChains/WebRtc.NET/src')
-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
3 files changed, 76 insertions, 49 deletions
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;
}
};
}