diff --git a/CHANGELOG.md b/CHANGELOG.md index 522d448..9cc8489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog -------------------------------------------- +[1.0.11] - 2023-01-30 + +* Add RTCRtpCapabilities interface. + [1.0.10] - 2022-11-12 * Change MediaStream.clone to async. diff --git a/lib/src/factory.dart b/lib/src/factory.dart index 729b2f0..71474d4 100644 --- a/lib/src/factory.dart +++ b/lib/src/factory.dart @@ -2,6 +2,7 @@ import 'media_recorder.dart'; import 'media_stream.dart'; import 'navigator.dart'; import 'rtc_peerconnection.dart'; +import 'rtc_rtp_capabilities.dart'; import 'rtc_video_renderer.dart'; abstract class RTCFactory { @@ -11,6 +12,10 @@ abstract class RTCFactory { Future createLocalMediaStream(String label); + Future getRtpSenderCapabilities(String kind); + + Future getRtpReceiverCapabilities(String kind); + MediaRecorder mediaRecorder(); VideoRenderer videoRenderer(); diff --git a/lib/src/rtc_rtp_capabilities.dart b/lib/src/rtc_rtp_capabilities.dart new file mode 100644 index 0000000..2e3e924 --- /dev/null +++ b/lib/src/rtc_rtp_capabilities.dart @@ -0,0 +1,76 @@ +class RTCRtpCodecCapability { + RTCRtpCodecCapability( + {this.channels, + required this.clockRate, + required this.mimeType, + this.sdpFmtpLine}); + factory RTCRtpCodecCapability.fromMap(Map map) { + return RTCRtpCodecCapability( + channels: map['channels'], + clockRate: map['clockRate'], + mimeType: map['mimeType'], + sdpFmtpLine: map['sdpFmtpLine'], + ); + } + num? channels; + num clockRate; + String mimeType; + String? sdpFmtpLine; + Map toMap() { + return { + if (channels != null) 'channels': channels, + 'clockRate': clockRate, + 'mimeType': mimeType, + if (sdpFmtpLine != null) 'sdpFmtpLine': sdpFmtpLine, + }; + } +} + +class RTCRtpHeaderExtensionCapability { + RTCRtpHeaderExtensionCapability(this.uri); + factory RTCRtpHeaderExtensionCapability.fromMap(Map map) { + return RTCRtpHeaderExtensionCapability(map['uri']); + } + String uri; + Map toMap() { + return { + 'uri': uri, + }; + } +} + +class RTCRtpCapabilities { + RTCRtpCapabilities({this.codecs, this.headerExtensions, this.fecMechanisms}); + factory RTCRtpCapabilities.fromMap(Map map) { + var codecs = []; + dynamic codecsMap = map['codecs']; + codecsMap.forEach((params) { + codecs.add(RTCRtpCodecCapability.fromMap(params)); + }); + var headerExtensions = []; + dynamic headerExtensionsMap = map['headerExtensions']; + headerExtensionsMap.forEach((params) { + headerExtensions.add(RTCRtpHeaderExtensionCapability.fromMap(params)); + }); + var fecMechanisms = []; + dynamic fecMechanismsMap = map['fecMechanisms']; + fecMechanismsMap.forEach((params) { + fecMechanisms.add(params); + }); + return RTCRtpCapabilities( + codecs: codecs, + headerExtensions: headerExtensions, + fecMechanisms: fecMechanisms); + } + List? codecs; + List? headerExtensions; + List? fecMechanisms; + + Map toMap() { + return { + 'codecs': codecs?.map((e) => e.toMap()).toList(), + 'headerExtensions': headerExtensions?.map((e) => e.toMap()).toList(), + if (fecMechanisms != null) 'fecMechanisms': fecMechanisms, + }; + } +} diff --git a/lib/src/rtc_rtp_parameters.dart b/lib/src/rtc_rtp_parameters.dart index ecb511d..41d3300 100644 --- a/lib/src/rtc_rtp_parameters.dart +++ b/lib/src/rtc_rtp_parameters.dart @@ -58,6 +58,7 @@ class RTCRtpEncoding { this.numTemporalLayers = 1, this.scaleResolutionDownBy = 1.0, this.ssrc, + this.scalabilityMode, }); factory RTCRtpEncoding.fromMap(Map map) => RTCRtpEncoding( @@ -69,6 +70,7 @@ class RTCRtpEncoding { numTemporalLayers: map['numTemporalLayers'], scaleResolutionDownBy: map['scaleResolutionDownBy'], ssrc: map['ssrc'], + scalabilityMode: map['scalabilityMode'], ); /// If non-null, this represents the RID that identifies this encoding layer. @@ -101,6 +103,8 @@ class RTCRtpEncoding { /// Can't be changed between getParameters/setParameters. int? ssrc; + String? scalabilityMode; + Map toMap() => { 'active': active, if (rid != null) 'rid': rid, @@ -110,6 +114,7 @@ class RTCRtpEncoding { if (numTemporalLayers != null) 'numTemporalLayers': numTemporalLayers, if (scaleResolutionDownBy != null) 'scaleResolutionDownBy': scaleResolutionDownBy, + if (scalabilityMode != null) 'scalabilityMode': scalabilityMode, if (ssrc != null) 'ssrc': ssrc, }; } diff --git a/lib/src/rtc_rtp_transceiver.dart b/lib/src/rtc_rtp_transceiver.dart index 6e36824..2f0727b 100644 --- a/lib/src/rtc_rtp_transceiver.dart +++ b/lib/src/rtc_rtp_transceiver.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'enums.dart'; import 'media_stream.dart'; +import 'rtc_rtp_capabilities.dart'; import 'rtc_rtp_parameters.dart'; import 'rtc_rtp_receiver.dart'; import 'rtc_rtp_sender.dart'; @@ -30,6 +31,8 @@ abstract class RTCRtpTransceiver { Future getDirection(); + Future setCodecPreferences(List codecs); + String get mid; RTCRtpSender get sender; diff --git a/lib/webrtc_interface.dart b/lib/webrtc_interface.dart index ab3a871..e5d5338 100644 --- a/lib/webrtc_interface.dart +++ b/lib/webrtc_interface.dart @@ -12,6 +12,7 @@ export 'src/rtc_dtmf_sender.dart'; export 'src/rtc_ice_candidate.dart'; export 'src/rtc_peerconnection.dart'; export 'src/rtc_rtcp_parameters.dart'; +export 'src/rtc_rtp_capabilities.dart'; export 'src/rtc_rtp_parameters.dart'; export 'src/rtc_rtp_receiver.dart'; export 'src/rtc_rtp_sender.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index a98dd85..46ccbe3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: webrtc_interface description: WebRTC Interface for Dart-Web/Flutter. -version: 1.0.10 +version: 1.0.11 homepage: https://flutter-webrtc.org environment: