Skip to content

Commit 6129876

Browse files
committed
Fix issue for windows.
i
1 parent 54771c5 commit 6129876

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

lib/src/call_sample/signaling.dart

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class Signaling {
6767
DataChannelMessageCallback onDataChannelMessage;
6868
DataChannelCallback onDataChannel;
6969

70+
String get sdpSemantics =>
71+
WebRTC.platformIsWindows ? 'plan-b' : 'unified-plan';
72+
7073
Map<String, dynamic> _iceServers = {
7174
'iceServers': [
7275
{'url': 'stun:stun.l.google.com:19302'},
@@ -320,12 +323,30 @@ class Signaling {
320323
print(_iceServers);
321324
RTCPeerConnection pc = await createPeerConnection({
322325
..._iceServers,
323-
...{'sdpSemantics': 'unified-plan'}
326+
...{'sdpSemantics': sdpSemantics}
324327
}, _config);
325328
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+
}
329350

330351
// Unified-Plan: Simuclast
331352
/*
@@ -390,18 +411,6 @@ class Signaling {
390411

391412
pc.onIceConnectionState = (state) {};
392413

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-
405414
pc.onRemoveStream = (stream) {
406415
onRemoveRemoteStream?.call(newSession, stream);
407416
_remoteStreams.removeWhere((it) {

windows/flutter/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ add_custom_command(
9191
${FLUTTER_TOOL_ENVIRONMENT}
9292
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
9393
windows-x64 $<CONFIG>
94+
VERBATIM
9495
)
9596
add_custom_target(flutter_assemble DEPENDS
9697
"${FLUTTER_LIBRARY}"

0 commit comments

Comments
 (0)