Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: webrtc/audio/audio_receive_stream.cc

Issue 2436033002: Replace AudioConferenceMixer with AudioMixer. (Closed)
Patch Set: Declare constants and depend on RemoveSource CL. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/audio/audio_receive_stream.cc
diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc
index 0d75307b4b44e4759694a81a15c393b0b65a26d4..69900c577f3658f4b220d8102518170fd799c308 100644
--- a/webrtc/audio/audio_receive_stream.cc
+++ b/webrtc/audio/audio_receive_stream.cc
@@ -138,9 +138,11 @@ AudioReceiveStream::AudioReceiveStream(
}
AudioReceiveStream::~AudioReceiveStream() {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
- Stop();
+ if (playing_) {
+ Stop();
+ }
channel_proxy_->DisassociateSendChannel();
channel_proxy_->DeRegisterExternalTransport();
channel_proxy_->ResetCongestionControlObjects();
@@ -151,22 +153,43 @@ AudioReceiveStream::~AudioReceiveStream() {
}
void AudioReceiveStream::Start() {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
- ScopedVoEInterface<VoEBase> base(voice_engine());
- int error = base->StartPlayout(config_.voe_channel_id);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
+ if (playing_) {
+ return;
+ }
+
+ int error = SetVoiceEnginePlayout(true);
if (error != 0) {
LOG(LS_ERROR) << "AudioReceiveStream::Start failed with error: " << error;
+ return;
}
+
+ auto* const the_audio_state = audio_state();
+
+ if (!the_audio_state->mixer()->AddSource(this)) {
the sun 2016/11/18 16:30:17 nit: make it a one-liner
aleloi 2016/11/21 11:59:11 Done.
+ LOG(LS_ERROR) << "Failed to add source to mixer.";
+ SetVoiceEnginePlayout(false);
+ return;
+ }
+
+ playing_ = true;
}
void AudioReceiveStream::Stop() {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
- ScopedVoEInterface<VoEBase> base(voice_engine());
- base->StopPlayout(config_.voe_channel_id);
+ RTC_DCHECK_RUN_ON(&thread_checker_);
+
the sun 2016/11/18 16:30:17 dd
aleloi 2016/11/21 11:59:11 Remove empty line? If so, done.
+ if (!playing_) {
+ return;
+ }
+ playing_ = false;
+
+ audio_state()->mixer()->RemoveSource(this);
+
the sun 2016/11/18 16:30:17 dd
aleloi 2016/11/21 11:59:11 Same here.
+ SetVoiceEnginePlayout(false);
}
webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
webrtc::AudioReceiveStream::Stats stats;
stats.remote_ssrc = config_.rtp.remote_ssrc;
ScopedVoEInterface<VoECodec> codec(voice_engine());
@@ -215,17 +238,17 @@ webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
}
void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
channel_proxy_->SetSink(std::move(sink));
}
void AudioReceiveStream::SetGain(float gain) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
channel_proxy_->SetChannelOutputVolumeScaling(gain);
}
const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
return config_;
}
@@ -242,7 +265,7 @@ void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
}
void AudioReceiveStream::SignalNetworkState(NetworkState state) {
- RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ RTC_DCHECK_RUN_ON(&thread_checker_);
}
bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
@@ -295,12 +318,26 @@ int AudioReceiveStream::Ssrc() const {
return config_.rtp.local_ssrc;
}
+internal::AudioState* AudioReceiveStream::audio_state() const {
+ auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
+ RTC_DCHECK(audio_state);
+ return audio_state;
+}
+
VoiceEngine* AudioReceiveStream::voice_engine() const {
- internal::AudioState* audio_state =
- static_cast<internal::AudioState*>(audio_state_.get());
- VoiceEngine* voice_engine = audio_state->voice_engine();
+ auto* voice_engine = audio_state()->voice_engine();
RTC_DCHECK(voice_engine);
return voice_engine;
}
+
+int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) {
+ ScopedVoEInterface<VoEBase> base(voice_engine());
+ if (playout) {
+ return base->StartPlayout(config_.voe_channel_id);
+ } else {
+ return base->StopPlayout(config_.voe_channel_id);
+ }
+}
+
} // namespace internal
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698