aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.WebRTC
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.WebRTC')
-rw-r--r--Software/Visual_Studio/Tango.WebRTC/Tango.WebRTC.csproj4
-rw-r--r--Software/Visual_Studio/Tango.WebRTC/WebRtcClient.cs76
2 files changed, 43 insertions, 37 deletions
diff --git a/Software/Visual_Studio/Tango.WebRTC/Tango.WebRTC.csproj b/Software/Visual_Studio/Tango.WebRTC/Tango.WebRTC.csproj
index 0d85bb902..d9cea42dc 100644
--- a/Software/Visual_Studio/Tango.WebRTC/Tango.WebRTC.csproj
+++ b/Software/Visual_Studio/Tango.WebRTC/Tango.WebRTC.csproj
@@ -59,6 +59,10 @@
<Project>{a07e6cb4-0132-4eb1-9a38-c8c057884dc2}</Project>
<Name>WebRtc.NET</Name>
</ProjectReference>
+ <ProjectReference Include="..\Tango.Core\Tango.Core.csproj">
+ <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
+ <Name>Tango.Core</Name>
+ </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Tango.WebRTC/WebRtcClient.cs b/Software/Visual_Studio/Tango.WebRTC/WebRtcClient.cs
index 9866395ae..bbbabb4e4 100644
--- a/Software/Visual_Studio/Tango.WebRTC/WebRtcClient.cs
+++ b/Software/Visual_Studio/Tango.WebRTC/WebRtcClient.cs
@@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Tango.Core.Threading;
using WebRtc.NET;
namespace Tango.WebRTC
@@ -192,14 +193,15 @@ namespace Tango.WebRTC
completion.SetResult(true);
- Stopwatch watch = new Stopwatch();
- watch.Start();
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
while (!_isDisposed)
{
- watch.Restart();
+ //watch.Restart();
_conductor.ProcessMessages(1000);
- Thread.Sleep(Math.Max(10, (int)watch.ElapsedMilliseconds));
+ Thread.Sleep(10);
+ //Thread.Sleep(Math.Max(10, (int)watch.ElapsedMilliseconds));
}
IsInitialized = false;
@@ -211,9 +213,35 @@ namespace Tango.WebRTC
_conductor.OnFailure -= _conductor_OnFailure;
_conductor.OnIceStateChanged -= _conductor_OnIceStateChanged;
+ unsafe
+ {
+ _conductor.OnRenderRemote -= _conductor_OnRenderRemote;
+ }
+
_conductor.Dispose();
+
+ try
+ {
+ if (_sendFrame != null)
+ {
+ _sendFrame.Dispose();
+ }
+
+ }
+ catch { }
+
+
+ try
+ {
+ if (_bufHandle != null)
+ {
+ _bufHandle.Free();
+ }
+ }
+ catch { }
});
+ _conductorThread.SetApartmentState(ApartmentState.STA);
_conductorThread.IsBackground = true;
_conductorThread.Start();
@@ -320,16 +348,14 @@ namespace Tango.WebRTC
_conductor.OnSuccessOffer += del;
- Task.Factory.StartNew(async () =>
+ TimeoutTask.StartNew(() =>
{
- await Task.Delay(10000);
-
if (!completed)
{
completed = true;
completion.SetException(new TimeoutException("The offer was not created within the given time."));
}
- });
+ }, TimeSpan.FromSeconds(10));
_conductor.CreateOffer();
@@ -358,16 +384,14 @@ namespace Tango.WebRTC
_conductor.OnSuccessAnswer += del;
- Task.Factory.StartNew(async () =>
+ TimeoutTask.StartNew(() =>
{
- await Task.Delay(10000);
-
if (!completed)
{
completed = true;
completion.SetException(new TimeoutException("The answer was not created within the given time."));
}
- });
+ }, TimeSpan.FromSeconds(10));
_conductor.OnOfferRequest(offer.Sdp);
@@ -392,7 +416,7 @@ namespace Tango.WebRTC
{
EnsureInitialized();
- Task.Factory.StartNew(() =>
+ ThreadFactory.StartNew(() =>
{
_conductor.AddIceCandidate(ice.SdpMid, ice.SdpMLineIndex, ice.Sdp);
});
@@ -437,16 +461,14 @@ namespace Tango.WebRTC
{
if (timeout != null)
{
- Task.Factory.StartNew(async () =>
+ TimeoutTask.StartNew(() =>
{
- await Task.Delay(timeout.Value);
-
if (!IsReady)
{
_readyCompletionSource.SetException(new TimeoutException("The connection was not ready within the given time."));
_readyCompletionSource = null;
}
- });
+ }, timeout.Value);
}
_readyCompletionSource = new TaskCompletionSource<bool>();
@@ -463,26 +485,6 @@ namespace Tango.WebRTC
if (!_isDisposed)
{
_isDisposed = true;
-
- try
- {
- if (_sendFrame != null)
- {
- _sendFrame.Dispose();
- }
-
- }
- catch { }
-
-
- try
- {
- if (_bufHandle != null)
- {
- _bufHandle.Free();
- }
- }
- catch { }
}
}