Skip to content

Commit 624fa1d

Browse files
authored
Change default to stop recording when muted (#206)
1 parent adc795e commit 624fa1d

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

api/audio/audio_device.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ class AudioDeviceModule : public webrtc::RefCountInterface {
181181
// not be present in the stats.
182182
virtual std::optional<Stats> GetStats() const { return std::nullopt; }
183183

184+
// Whether to stop recording when all streams are muted.
185+
virtual bool IsStopOnMuteModeEnabled() const { return true; }
186+
184187
// Only supported on iOS.
185188
#if defined(WEBRTC_IOS)
186189
virtual int GetPlayoutAudioParameters(AudioParameters* params) const = 0;

media/engine/webrtc_voice_engine.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,18 @@ bool WebRtcVoiceSendChannel::MuteStream(uint32_t ssrc, bool muted) {
17591759
if (adm) {
17601760
RTC_LOG(LS_INFO) << "WebRtcVoiceSendChannel::MuteStream: ADM:"
17611761
<< is_all_muted;
1762-
adm->SetMicrophoneMute(is_all_muted);
1762+
1763+
if (adm->IsStopOnMuteModeEnabled()) {
1764+
if (!is_all_muted && !adm->Recording()) {
1765+
if (adm->InitRecording() == 0) {
1766+
adm->StartRecording();
1767+
}
1768+
} else if (is_all_muted && adm->Recording()) {
1769+
adm->StopRecording();
1770+
}
1771+
} else {
1772+
adm->SetMicrophoneMute(is_all_muted);
1773+
}
17631774
}
17641775
}
17651776
}

modules/audio_device/audio_engine_device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ class AudioEngineDevice : public AudioDeviceModule, public AudioSessionObserver
372372

373373
int32_t InitAndStartRecording();
374374

375+
bool IsStopOnMuteModeEnabled() const override;
376+
375377
private:
376378
struct EngineStateUpdate {
377379
EngineState prev;

modules/audio_device/audio_engine_device.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
engine_state_.voice_processing_bypassed = voice_processing_bypassed;
8989
}
9090

91+
bool AudioEngineDevice::IsStopOnMuteModeEnabled() const {
92+
return false;
93+
}
94+
9195
AudioEngineDevice::~AudioEngineDevice() {
9296
RTC_DCHECK_RUN_ON(thread_);
9397

0 commit comments

Comments
 (0)