@@ -67,6 +67,9 @@ class Signaling {
67
67
DataChannelMessageCallback onDataChannelMessage;
68
68
DataChannelCallback onDataChannel;
69
69
70
+ String get sdpSemantics =>
71
+ WebRTC .platformIsWindows ? 'plan-b' : 'unified-plan' ;
72
+
70
73
Map <String , dynamic > _iceServers = {
71
74
'iceServers' : [
72
75
{'url' : 'stun:stun.l.google.com:19302' },
@@ -320,12 +323,30 @@ class Signaling {
320
323
print (_iceServers);
321
324
RTCPeerConnection pc = await createPeerConnection ({
322
325
..._iceServers,
323
- ...{'sdpSemantics' : 'unified-plan' }
326
+ ...{'sdpSemantics' : sdpSemantics }
324
327
}, _config);
325
328
if (media != 'data' ) {
326
- _localStream
327
- .getTracks ()
328
- .forEach ((track) async => await pc.addTrack (track, _localStream));
329
+ switch (sdpSemantics) {
330
+ case 'plan-b' :
331
+ pc.onAddStream = (MediaStream stream) {
332
+ onAddRemoteStream? .call (newSession, stream);
333
+ _remoteStreams.add (stream);
334
+ };
335
+ await pc.addStream (_localStream);
336
+ break ;
337
+ case 'unified-plan' :
338
+
339
+ // Unified-Plan
340
+ pc.onTrack = (event) {
341
+ if (event.track.kind == 'video' ) {
342
+ onAddRemoteStream? .call (newSession, event.streams[0 ]);
343
+ }
344
+ };
345
+ _localStream.getTracks ().forEach ((track) {
346
+ pc.addTrack (track, _localStream);
347
+ });
348
+ break ;
349
+ }
329
350
330
351
// Unified-Plan: Simuclast
331
352
/*
@@ -390,18 +411,6 @@ class Signaling {
390
411
391
412
pc.onIceConnectionState = (state) {};
392
413
393
- //pc.onAddStream = (stream) {
394
- // onAddRemoteStream?.call(stream);
395
- // _remoteStreams.add(stream);
396
- //};
397
-
398
- // Unified-Plan
399
- pc.onTrack = (event) {
400
- if (event.track.kind == 'video' ) {
401
- onAddRemoteStream? .call (newSession, event.streams[0 ]);
402
- }
403
- };
404
-
405
414
pc.onRemoveStream = (stream) {
406
415
onRemoveRemoteStream? .call (newSession, stream);
407
416
_remoteStreams.removeWhere ((it) {
0 commit comments