diff --git a/lib/src/options.dart b/lib/src/options.dart index 30e115b8..9a6cc3cd 100644 --- a/lib/src/options.dart +++ b/lib/src/options.dart @@ -105,6 +105,12 @@ class VideoPublishOptions { '${runtimeType}(videoEncoding: ${videoEncoding}, simulcast: ${simulcast})'; } +class AudioPreset { + static const telephone = 12000; + static const speech = 20000; + static const music = 32000; +} + /// Options used when publishing audio. class AudioPublishOptions { /// Whether to enable DTX (Discontinuous Transmission) or not. @@ -112,8 +118,12 @@ class AudioPublishOptions { /// Defaults to true. final bool dtx; + /// max audio bitrate + final int audioBitrate; + const AudioPublishOptions({ this.dtx = true, + this.audioBitrate = AudioPreset.speech, }); @override diff --git a/lib/src/participant/local.dart b/lib/src/participant/local.dart index e1ba405e..2fe68750 100644 --- a/lib/src/participant/local.dart +++ b/lib/src/participant/local.dart @@ -64,6 +64,10 @@ class LocalParticipant extends Participant { final transceiverInit = rtc.RTCRtpTransceiverInit( direction: rtc.TransceiverDirection.SendOnly, + sendEncodings: [ + if (publishOptions.audioBitrate > 0) + rtc.RTCRtpEncoding(maxBitrate: publishOptions.audioBitrate), + ], ); // addTransceiver cannot pass in a kind parameter due to a bug in flutter-webrtc (web) track.transceiver = await room.engine.publisher?.pc.addTransceiver(