1- using System ;
2- using System . Threading ;
3- using System . Threading . Tasks ;
1+ using Newtonsoft . Json ;
42using SIPSorcery . Net ;
53using SIPSorceryMedia . Abstractions ;
6- using SIPSorcery . Media ;
7- using System . Linq ;
8- using System . Collections . Generic ;
9- using System . Text ;
10- using Newtonsoft . Json ;
114using SIPSorceryMedia . External ;
125using SIPSorceryMedia . FFmpeg ;
136using SIPSorceryMedia . OpusCodec ;
14- using SIPSorceryMedia . SDL2 ;
7+ using System ;
8+ using System . Collections . Generic ;
159using System . IO ;
10+ using System . Linq ;
11+ using System . Text ;
1612
1713namespace ControlSync . Client
1814{
@@ -22,7 +18,7 @@ public static class HostPeer
2218 private const string STUN_URL2 = "stun:stun1.l.google.com:19302" ;
2319
2420 public static RTCPeerConnectionState ConnectionState => peerConnection != null ? peerConnection . connectionState : RTCPeerConnectionState . disconnected ;
25-
21+
2622 public static FFmpegVideoEndPoint1 VideoEncoder { get ; private set ; }
2723 public static WasAPIAudioSource AudioEncoder { get ; private set ; }
2824
@@ -36,7 +32,7 @@ public static async void StartPeerConnection()
3632 VideoEncoder = new FFmpegVideoEndPoint1 ( ) ;
3733
3834 AudioEncoder = new WasAPIAudioSource ( new OpusAudioEncoder ( ) ) ;
39-
35+
4036 FFmpegInit . Initialise ( FfmpegLogLevelEnum . AV_LOG_DEBUG , ffmpegPath ) ;
4137
4238 peerConnection = CreatePeerConnection ( ) ;
@@ -57,7 +53,7 @@ public static void HandleAnswer(string base64Answer)
5753 string remoteAnswer = Encoding . UTF8 . GetString ( Convert . FromBase64String ( base64Answer ) ) ;
5854
5955 RTCSessionDescriptionInit answerInit = JsonConvert . DeserializeObject < RTCSessionDescriptionInit > ( remoteAnswer ) ;
60-
56+
6157 peerConnection . setRemoteDescription ( answerInit ) ;
6258
6359 ClientPg . Log ( "Received Answer" ) ;
@@ -76,7 +72,7 @@ public static void AddICECandidate(string base64ICECandidate)
7672 }
7773 public static void CloseConnection ( )
7874 {
79- if ( peerConnection == null )
75+ if ( peerConnection == null )
8076 return ;
8177
8278 peerConnection . close ( ) ;
@@ -119,15 +115,15 @@ private static RTCPeerConnection CreatePeerConnection()
119115 {
120116 var jCandidate = candidate . toJSON ( ) ;
121117 var base64ICECandidate = Convert . ToBase64String ( Encoding . UTF8 . GetBytes ( jCandidate ) ) ;
122-
118+
123119 for ( int i = 2 ; i <= Manager . players . Count ; i ++ )
124120 {
125121 var player = Manager . players [ i ] ;
126122 ClientSend . ICECandidate ( base64ICECandidate , player . Id ) ;
127123 }
128124 } ;
129125
130-
126+
131127 // Add a handler for connection state change events.
132128 // This can be used to monitor the status of the WebRTC session.
133129 pc . onconnectionstatechange += ( state ) =>
0 commit comments