11import 'package:flutter_webrtc/flutter_webrtc.dart' ;
2- import 'package:http/http.dart' ;
32
43import 'logger.dart' ;
54import 'stream.dart' ;
@@ -10,7 +9,6 @@ const API_CHANNEL = 'whip-api';
109
1110class 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