diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 0804bc8286..59b0ea5b5e 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -415,11 +415,6 @@ void AudioSendStream::SetMuted(bool muted) { channel_send_->SetInputMute(muted); } -bool AudioSendStream::GetMuted() { - RTC_DCHECK_RUN_ON(&worker_thread_checker_); - return channel_send_->InputMute(); -} - webrtc::AudioSendStream::Stats AudioSendStream::GetStats() const { return GetStats(true); } diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index b7c265fa30..a37c8fd452 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -94,7 +94,6 @@ class AudioSendStream final : public webrtc::AudioSendStream, int payload_frequency, int event, int duration_ms) override; - bool GetMuted() override; void SetMuted(bool muted) override; webrtc::AudioSendStream::Stats GetStats() const override; webrtc::AudioSendStream::Stats GetStats( diff --git a/audio/audio_state.cc b/audio/audio_state.cc index c715bc4cb9..9ff74d6faa 100644 --- a/audio/audio_state.cc +++ b/audio/audio_state.cc @@ -98,26 +98,22 @@ void AudioState::AddSendingStream(webrtc::AudioSendStream* stream, UpdateAudioTransportWithSendingStreams(); // Make sure recording is initialized; start recording if enabled. - if (ShouldRecord()) { - auto* adm = config_.audio_device_module.get(); - if (!adm->Recording()) { - if (adm->InitRecording() == 0) { - if (recording_enabled_) { - - // TODO: Verify if the following windows only logic is still required. + auto* adm = config_.audio_device_module.get(); + if (!adm->Recording()) { + if (adm->InitRecording() == 0) { + if (recording_enabled_) { #if defined(WEBRTC_WIN) - if (adm->BuiltInAECIsAvailable() && !adm->Playing()) { - if (!adm->PlayoutIsInitialized()) { - adm->InitPlayout(); - } - adm->StartPlayout(); + if (adm->BuiltInAECIsAvailable() && !adm->Playing()) { + if (!adm->PlayoutIsInitialized()) { + adm->InitPlayout(); } -#endif - adm->StartRecording(); + adm->StartPlayout(); } - } else { - RTC_DLOG_F(LS_ERROR) << "Failed to initialize recording."; +#endif + adm->StartRecording(); } + } else { + RTC_DLOG_F(LS_ERROR) << "Failed to initialize recording."; } } } @@ -127,10 +123,7 @@ void AudioState::RemoveSendingStream(webrtc::AudioSendStream* stream) { auto count = sending_streams_.erase(stream); RTC_DCHECK_EQ(1, count); UpdateAudioTransportWithSendingStreams(); - - bool should_record = ShouldRecord(); - RTC_LOG(LS_INFO) << "RemoveSendingStream: should_record = " << should_record; - if (!should_record) { + if (sending_streams_.empty()) { config_.audio_device_module->StopRecording(); } } @@ -158,7 +151,7 @@ void AudioState::SetRecording(bool enabled) { if (recording_enabled_ != enabled) { recording_enabled_ = enabled; if (enabled) { - if (ShouldRecord()) { + if (!sending_streams_.empty()) { config_.audio_device_module->StartRecording(); } } else { @@ -218,43 +211,6 @@ void AudioState::UpdateNullAudioPollerState() { null_audio_poller_.Stop(); } } - -void AudioState::OnMuteStreamChanged() { - - auto* adm = config_.audio_device_module.get(); - bool should_record = ShouldRecord(); - - RTC_LOG(LS_INFO) << "OnMuteStreamChanged: should_record = " << should_record; - if (should_record && !adm->Recording()) { - if (adm->InitRecording() == 0) { - adm->StartRecording(); - } - } else if (!should_record && adm->Recording()) { - adm->StopRecording(); - } -} - -bool AudioState::ShouldRecord() { - RTC_LOG(LS_INFO) << "ShouldRecord"; - // no streams to send - if (sending_streams_.empty()) { - RTC_LOG(LS_INFO) << "ShouldRecord: send stream = empty"; - return false; - } - - int stream_count = sending_streams_.size(); - - int muted_count = 0; - for (const auto& kv : sending_streams_) { - if (kv.first->GetMuted()) { - muted_count++; - } - } - - RTC_LOG(LS_INFO) << "ShouldRecord: " << muted_count << " muted, " << stream_count << " sending"; - return muted_count != stream_count; -} - } // namespace internal rtc::scoped_refptr AudioState::Create( diff --git a/audio/audio_state.h b/audio/audio_state.h index f21cca771e..88aaaa3697 100644 --- a/audio/audio_state.h +++ b/audio/audio_state.h @@ -47,8 +47,6 @@ class AudioState : public webrtc::AudioState { void SetStereoChannelSwapping(bool enable) override; - void OnMuteStreamChanged() override; - AudioDeviceModule* audio_device_module() { RTC_DCHECK(config_.audio_device_module); return config_.audio_device_module.get(); @@ -66,9 +64,6 @@ class AudioState : public webrtc::AudioState { void UpdateAudioTransportWithSendingStreams(); void UpdateNullAudioPollerState() RTC_RUN_ON(&thread_checker_); - // Returns true when at least 1 stream exists and all streams are not muted. - bool ShouldRecord(); - SequenceChecker thread_checker_; SequenceChecker process_thread_checker_{SequenceChecker::kDetached}; const webrtc::AudioState::Config config_; diff --git a/audio/channel_send.cc b/audio/channel_send.cc index bc474ee33d..4a2700177b 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -100,8 +100,6 @@ class ChannelSend : public ChannelSendInterface, // Muting, Volume and Level. void SetInputMute(bool enable) override; - bool InputMute() const override; - // Stats. ANAStats GetANAStatistics() const override; @@ -165,6 +163,8 @@ class ChannelSend : public ChannelSendInterface, size_t payloadSize, int64_t absolute_capture_timestamp_ms) override; + bool InputMute() const; + int32_t SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, diff --git a/audio/channel_send.h b/audio/channel_send.h index c16be987b4..b6a6a37bf5 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -83,8 +83,6 @@ class ChannelSendInterface { virtual bool SendTelephoneEventOutband(int event, int duration_ms) = 0; virtual void OnBitrateAllocation(BitrateAllocationUpdate update) = 0; virtual int GetTargetBitrate() const = 0; - - virtual bool InputMute() const = 0; virtual void SetInputMute(bool muted) = 0; virtual void ProcessAndEncodeAudio( diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index 7e73ab2ce6..9c2fad652f 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h @@ -190,7 +190,6 @@ class AudioSendStream : public AudioSender { int event, int duration_ms) = 0; - virtual bool GetMuted() = 0; virtual void SetMuted(bool muted) = 0; virtual Stats GetStats() const = 0; diff --git a/call/audio_state.h b/call/audio_state.h index 85f04758dd..79fb5cf981 100644 --- a/call/audio_state.h +++ b/call/audio_state.h @@ -59,9 +59,6 @@ class AudioState : public rtc::RefCountInterface { virtual void SetStereoChannelSwapping(bool enable) = 0; - // Notify the AudioState that a stream updated it's mute state. - virtual void OnMuteStreamChanged() = 0; - static rtc::scoped_refptr Create( const AudioState::Config& config); diff --git a/media/engine/webrtc_voice_engine.cc b/media/engine/webrtc_voice_engine.cc index 1c6c31020d..efcdcb0bff 100644 --- a/media/engine/webrtc_voice_engine.cc +++ b/media/engine/webrtc_voice_engine.cc @@ -1698,9 +1698,6 @@ bool WebRtcVoiceSendChannel::MuteStream(uint32_t ssrc, bool muted) { ap->set_output_will_be_muted(all_muted); } - // Notfy the AudioState that the mute state has updated. - engine_->audio_state()->OnMuteStreamChanged(); - return true; } diff --git a/media/engine/webrtc_voice_engine.h b/media/engine/webrtc_voice_engine.h index 9d18ef6302..b28b9652bb 100644 --- a/media/engine/webrtc_voice_engine.h +++ b/media/engine/webrtc_voice_engine.h @@ -132,8 +132,6 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { absl::optional GetAudioDeviceStats() override; - // Moved to public so WebRtcVoiceMediaChannel can access it. - webrtc::AudioState* audio_state(); private: // Every option that is "set" will be applied. Every option not "set" will be @@ -147,6 +145,7 @@ class WebRtcVoiceEngine final : public VoiceEngineInterface { webrtc::AudioDeviceModule* adm(); webrtc::AudioProcessing* apm() const; + webrtc::AudioState* audio_state(); std::vector CollectCodecs( const std::vector& specs) const;