Skip to content

Commit b78d7c7

Browse files
committed
release: 1.4.0.
1 parent 6ac191b commit b78d7c7

File tree

5 files changed

+36
-9
lines changed

5 files changed

+36
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

33
--------------------------------------------
4+
[1.4.0] - 2024-04-09
5+
6+
* Fixed bug for RTCConfiguration convert.
7+
48
[1.3.3] - 2024-04-09
59

610
* Fix DC data parse.

lib/src/factory_impl.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'media_stream_impl.dart';
1111
import 'navigator_impl.dart';
1212
import 'rtc_peerconnection_impl.dart';
1313
import 'rtc_rtp_capailities_imp.dart';
14+
import 'utils.dart';
1415

1516
@JS('RTCRtpSender')
1617
@anonymous
@@ -41,7 +42,7 @@ class RTCFactoryWeb extends RTCFactory {
4142
],
4243
};
4344
final jsRtcPc = web.RTCPeerConnection(
44-
jsify({...constr, ...configuration}) as web.RTCConfiguration);
45+
convertRTCConfiguration({...constr, ...configuration}));
4546
final _peerConnectionId = base64Encode(jsRtcPc.toString().codeUnits);
4647
return RTCPeerConnectionWeb(_peerConnectionId, jsRtcPc);
4748
}

lib/src/rtc_peerconnection_impl.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import 'rtc_dtmf_sender_impl.dart';
1515
import 'rtc_rtp_receiver_impl.dart';
1616
import 'rtc_rtp_sender_impl.dart';
1717
import 'rtc_rtp_transceiver_impl.dart';
18+
import 'utils.dart';
1819

1920
extension on web.RTCDataChannelInit {
2021
external set binaryType(String value);
@@ -263,13 +264,7 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
263264
@override
264265
Future<void> setConfiguration(Map<String, dynamic> configuration) {
265266
_configuration.addAll(configuration);
266-
267-
final object = jsutil.newObject();
268-
for (var key in configuration.keys) {
269-
jsutil.setProperty(object, key, configuration[key]);
270-
}
271-
272-
_jsPc.setConfiguration(object as web.RTCConfiguration);
267+
_jsPc.setConfiguration(convertRTCConfiguration(configuration));
273268
return Future.value();
274269
}
275270

lib/src/utils.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import 'dart:js_util' as jsutil;
12
import 'dart:math';
3+
24
import 'package:web/web.dart' as web;
35

46
bool get isMobile {
@@ -25,3 +27,28 @@ String randomString(int length) {
2527
}
2628
return buf.toString();
2729
}
30+
31+
web.RTCConfiguration convertRTCConfiguration(
32+
Map<String, dynamic> configuration) {
33+
final object = jsutil.newObject();
34+
for (var key in configuration.keys) {
35+
if (key == 'iceServers') {
36+
final servers = configuration[key] as List<dynamic>;
37+
final jsServers = <web.RTCIceServer>[];
38+
for (var server in servers) {
39+
var iceServer = web.RTCIceServer(urls: server['urls']);
40+
if (server['username'] != null) {
41+
iceServer.username = server['username'];
42+
}
43+
if (server['credential'] != null) {
44+
iceServer.credential = server['credential'];
45+
}
46+
jsServers.add(iceServer);
47+
}
48+
jsutil.setProperty(object, key, jsServers);
49+
} else {
50+
jsutil.setProperty(object, key, configuration[key]);
51+
}
52+
}
53+
return object as web.RTCConfiguration;
54+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dart_webrtc
22
description: Use the dart/js library to re-wrap the webrtc js interface of the browser, to adapted common browsers.
3-
version: 1.3.3
3+
version: 1.4.0
44
homepage: https://github.com/flutter-webrtc/dart-webrtc
55

66
environment:

0 commit comments

Comments
 (0)