Skip to content

Commit

Permalink
release: 1.4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Apr 9, 2024
1 parent 6ac191b commit b78d7c7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

--------------------------------------------
[1.4.0] - 2024-04-09

* Fixed bug for RTCConfiguration convert.

[1.3.3] - 2024-04-09

* Fix DC data parse.
Expand Down
3 changes: 2 additions & 1 deletion lib/src/factory_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'media_stream_impl.dart';
import 'navigator_impl.dart';
import 'rtc_peerconnection_impl.dart';
import 'rtc_rtp_capailities_imp.dart';
import 'utils.dart';

@JS('RTCRtpSender')
@anonymous
Expand Down Expand Up @@ -41,7 +42,7 @@ class RTCFactoryWeb extends RTCFactory {
],
};
final jsRtcPc = web.RTCPeerConnection(
jsify({...constr, ...configuration}) as web.RTCConfiguration);
convertRTCConfiguration({...constr, ...configuration}));
final _peerConnectionId = base64Encode(jsRtcPc.toString().codeUnits);
return RTCPeerConnectionWeb(_peerConnectionId, jsRtcPc);
}
Expand Down
9 changes: 2 additions & 7 deletions lib/src/rtc_peerconnection_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'rtc_dtmf_sender_impl.dart';
import 'rtc_rtp_receiver_impl.dart';
import 'rtc_rtp_sender_impl.dart';
import 'rtc_rtp_transceiver_impl.dart';
import 'utils.dart';

extension on web.RTCDataChannelInit {
external set binaryType(String value);
Expand Down Expand Up @@ -263,13 +264,7 @@ class RTCPeerConnectionWeb extends RTCPeerConnection {
@override
Future<void> setConfiguration(Map<String, dynamic> configuration) {
_configuration.addAll(configuration);

final object = jsutil.newObject();
for (var key in configuration.keys) {
jsutil.setProperty(object, key, configuration[key]);
}

_jsPc.setConfiguration(object as web.RTCConfiguration);
_jsPc.setConfiguration(convertRTCConfiguration(configuration));
return Future.value();
}

Expand Down
27 changes: 27 additions & 0 deletions lib/src/utils.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'dart:js_util' as jsutil;
import 'dart:math';

import 'package:web/web.dart' as web;

bool get isMobile {
Expand All @@ -25,3 +27,28 @@ String randomString(int length) {
}
return buf.toString();
}

web.RTCConfiguration convertRTCConfiguration(
Map<String, dynamic> configuration) {
final object = jsutil.newObject();
for (var key in configuration.keys) {
if (key == 'iceServers') {
final servers = configuration[key] as List<dynamic>;
final jsServers = <web.RTCIceServer>[];
for (var server in servers) {
var iceServer = web.RTCIceServer(urls: server['urls']);
if (server['username'] != null) {
iceServer.username = server['username'];
}
if (server['credential'] != null) {
iceServer.credential = server['credential'];
}
jsServers.add(iceServer);
}
jsutil.setProperty(object, key, jsServers);
} else {
jsutil.setProperty(object, key, configuration[key]);
}
}
return object as web.RTCConfiguration;
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_webrtc
description: Use the dart/js library to re-wrap the webrtc js interface of the browser, to adapted common browsers.
version: 1.3.3
version: 1.4.0
homepage: https://github.com/flutter-webrtc/dart-webrtc

environment:
Expand Down

0 comments on commit b78d7c7

Please sign in to comment.