From d038c52144a276f8615df418136d3a982aebe1c5 Mon Sep 17 00:00:00 2001 From: David Zhao Date: Fri, 29 Oct 2021 14:12:35 -0700 Subject: [PATCH] Use speech as default audio publish rate. Allow overriding defaults in `connect`, without dropping other defaults entirely. --- src/connect.ts | 6 +++--- src/room/defaults.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/connect.ts b/src/connect.ts index 29a4efb4c5..a9839d0f37 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -1,5 +1,5 @@ -import log from './logger'; import { WSSignalClient } from './api/SignalClient'; +import log from './logger'; import { ConnectOptions, LogLevel, @@ -57,10 +57,10 @@ export async function connect( // save default publish options if (options.publishDefaults) { - room.defaultPublishOptions = options.publishDefaults; + Object.assign(room.defaultPublishOptions, options.publishDefaults); } if (options.captureDefaults) { - room.defaultCaptureOptions = options.captureDefaults; + Object.assign(room.defaultCaptureOptions, options.captureDefaults); } const publishAudio: boolean = options.audio; diff --git a/src/room/defaults.ts b/src/room/defaults.ts index c637260387..211cdd9d50 100644 --- a/src/room/defaults.ts +++ b/src/room/defaults.ts @@ -1,6 +1,10 @@ -import { TrackCaptureDefaults, TrackPublishDefaults, VideoPresets } from './track/options'; +import { + AudioPresets, TrackCaptureDefaults, TrackPublishDefaults, VideoPresets, +} from './track/options'; -let publishDefaults: TrackPublishDefaults = {}; +let publishDefaults: TrackPublishDefaults = { + audioBitrate: AudioPresets.speech.maxBitrate, +}; let captureDefaults: TrackCaptureDefaults = { autoGainControl: true,