Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0541332

Browse files
chore: update.
1 parent 9e92c45 commit 0541332

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎lib/src/whip.dart‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /