Skip to content

Commit 1b7af29

Browse files
committed
chore: update.
1 parent 1b767c7 commit 1b7af29

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/src/whip.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter_webrtc/flutter_webrtc.dart';
2-
import 'package:http/http.dart';
32

43
import 'logger.dart';
54
import 'stream.dart';
@@ -10,7 +9,6 @@ const API_CHANNEL = 'whip-api';
109

1110
class WHIP {
1211
Function(RTCTrackEvent)? onTrack;
13-
Function(RTCDataChannel)? onDataChannel;
1412
Function()? onAPIOpen;
1513

1614
late RTCPeerConnection pc;
@@ -21,17 +19,16 @@ class WHIP {
2119

2220
void initlize() async {
2321
pc = await createPeerConnection({});
24-
25-
api = await pc.createDataChannel(
26-
API_CHANNEL, RTCDataChannelInit()..maxRetransmits = 30);
27-
2822
pc.onRenegotiationNeeded = onnegotiationneeded;
2923
pc.onIceCandidate = onicecandidate;
24+
api = await pc.createDataChannel(
25+
API_CHANNEL, RTCDataChannelInit()..maxRetransmits = 30);
3026
await pc.setLocalDescription(await pc.createOffer());
3127
}
3228

3329
void close() async {
3430
await httpDelete(Uri.parse(url));
31+
await pc.close();
3532
}
3633

3734
Future<List<StatsReport>> getPubStats(MediaStreamTrack? selector) {
@@ -56,6 +53,7 @@ class WHIP {
5653
body: offer,
5754
headers: {'Content-Type': 'application/sdp'},
5855
);
56+
// TODO(cloudwebrtc): handle answer sdp.
5957
//await pc.setRemoteDescription(answer.body);
6058
} catch (err, st) {
6159
log.error('onnegotiationneeded: e => ${err.toString()} $st');
@@ -70,7 +68,7 @@ class WHIP {
7068
headers: {'Content-Type': 'application/trickle-ice-sdpfrag'},
7169
body: candidate.toMap());
7270

73-
// TODO(cloudwebrtc): respose.statusCode
71+
// TODO(cloudwebrtc): Add remote candidate to local pc.
7472
}
7573

7674
void setPreferredCodec(RTCSessionDescription description) {

0 commit comments

Comments
 (0)