@@ -41,7 +41,10 @@ class WHIP {
4141 }
4242 this .mode = mode;
4343 pc = await createPeerConnection ({'sdpSemantics' : 'unified-plan' });
44- pc! .onIceCandidate = onicecandidate;
44+ pc? .onIceCandidate = onicecandidate;
45+ pc? .onIceConnectionState = (state) {
46+ print ('state: ${state .toString ()}' );
47+ };
4548 pc! .onTrack = (RTCTrackEvent event) => onTrack? .call (event);
4649 switch (mode) {
4750 case WhipMode .kSend:
@@ -64,14 +67,16 @@ class WHIP {
6467 var desc = await pc! .createOffer ();
6568 setPreferredCodec (desc, videoCodec: videoCodec);
6669 await pc! .setLocalDescription (desc);
70+
6771 var offer = await pc! .getLocalDescription ();
68- log.debug ('Sending offer: $offer ' );
72+ final sdp = offer! .sdp;
73+ log.debug ('Sending offer: $sdp ' );
6974 var respose = await httpPost (Uri .parse (url),
7075 headers: {
7176 'Content-Type' : 'application/sdp' ,
7277 if (headers != null ) ...headers!
7378 },
74- body: offer ! . sdp);
79+ body: sdp);
7580
7681 if (respose.statusCode != 200 && respose.statusCode != 201 ) {
7782 throw Exception ('Failed to send offer: ${respose .statusCode }' );
@@ -115,10 +120,7 @@ class WHIP {
115120 }
116121
117122 void onicecandidate (RTCIceCandidate ? candidate) async {
118- if (resourceURL == null ) {
119- throw 'Resource url not found!' ;
120- }
121- if (candidate == null ) {
123+ if (candidate == null || resourceURL == null ) {
122124 return ;
123125 }
124126 log.debug ('Sending candidate: ${candidate .toMap ().toString ()}' );
0 commit comments