Skip to content

Commit

Permalink
Add audioBitrate option for publishAudioTrack. (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc authored Jun 6, 2022
1 parent 9ed0c53 commit f092e2e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,25 @@ 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.
/// https://en.wikipedia.org/wiki/Discontinuous_transmission
/// Defaults to true.
final bool dtx;

/// max audio bitrate
final int audioBitrate;

const AudioPublishOptions({
this.dtx = true,
this.audioBitrate = AudioPreset.speech,
});

@override
Expand Down
4 changes: 4 additions & 0 deletions lib/src/participant/local.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class LocalParticipant extends Participant<LocalTrackPublication> {

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(
Expand Down

0 comments on commit f092e2e

Please sign in to comment.