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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // Configure bandwidth estimation. 131 // Configure bandwidth estimation.
132 channel_proxy_->RegisterReceiverCongestionControlObjects( 132 channel_proxy_->RegisterReceiverCongestionControlObjects(
133 congestion_controller->packet_router()); 133 congestion_controller->packet_router());
134 if (UseSendSideBwe(config)) { 134 if (UseSendSideBwe(config)) {
135 remote_bitrate_estimator_ = 135 remote_bitrate_estimator_ =
136 congestion_controller->GetRemoteBitrateEstimator(true); 136 congestion_controller->GetRemoteBitrateEstimator(true);
137 } 137 }
138 } 138 }
139 139
140 AudioReceiveStream::~AudioReceiveStream() { 140 AudioReceiveStream::~AudioReceiveStream() {
141 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 141 RTC_DCHECK_RUN_ON(&thread_checker_);
142 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); 142 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
143 Stop(); 143 if (playing_) {
144 Stop();
145 }
144 channel_proxy_->DisassociateSendChannel(); 146 channel_proxy_->DisassociateSendChannel();
145 channel_proxy_->DeRegisterExternalTransport(); 147 channel_proxy_->DeRegisterExternalTransport();
146 channel_proxy_->ResetCongestionControlObjects(); 148 channel_proxy_->ResetCongestionControlObjects();
147 channel_proxy_->SetRtcEventLog(nullptr); 149 channel_proxy_->SetRtcEventLog(nullptr);
148 if (remote_bitrate_estimator_) { 150 if (remote_bitrate_estimator_) {
149 remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc); 151 remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc);
150 } 152 }
151 } 153 }
152 154
153 void AudioReceiveStream::Start() { 155 void AudioReceiveStream::Start() {
154 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 156 RTC_DCHECK_RUN_ON(&thread_checker_);
155 ScopedVoEInterface<VoEBase> base(voice_engine()); 157 if (playing_) {
156 int error = base->StartPlayout(config_.voe_channel_id); 158 return;
159 }
160
161 int error = SetVoiceEnginePlayout(true);
157 if (error != 0) { 162 if (error != 0) {
158 LOG(LS_ERROR) << "AudioReceiveStream::Start failed with error: " << error; 163 LOG(LS_ERROR) << "AudioReceiveStream::Start failed with error: " << error;
164 return;
159 } 165 }
166
167 auto* const the_audio_state = audio_state();
168
169 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.
170 LOG(LS_ERROR) << "Failed to add source to mixer.";
171 SetVoiceEnginePlayout(false);
172 return;
173 }
174
175 playing_ = true;
160 } 176 }
161 177
162 void AudioReceiveStream::Stop() { 178 void AudioReceiveStream::Stop() {
163 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 179 RTC_DCHECK_RUN_ON(&thread_checker_);
164 ScopedVoEInterface<VoEBase> base(voice_engine()); 180
the sun 2016/11/18 16:30:17 dd
aleloi 2016/11/21 11:59:11 Remove empty line? If so, done.
165 base->StopPlayout(config_.voe_channel_id); 181 if (!playing_) {
182 return;
183 }
184 playing_ = false;
185
186 audio_state()->mixer()->RemoveSource(this);
187
the sun 2016/11/18 16:30:17 dd
aleloi 2016/11/21 11:59:11 Same here.
188 SetVoiceEnginePlayout(false);
166 } 189 }
167 190
168 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { 191 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
169 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 192 RTC_DCHECK_RUN_ON(&thread_checker_);
170 webrtc::AudioReceiveStream::Stats stats; 193 webrtc::AudioReceiveStream::Stats stats;
171 stats.remote_ssrc = config_.rtp.remote_ssrc; 194 stats.remote_ssrc = config_.rtp.remote_ssrc;
172 ScopedVoEInterface<VoECodec> codec(voice_engine()); 195 ScopedVoEInterface<VoECodec> codec(voice_engine());
173 196
174 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics(); 197 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics();
175 webrtc::CodecInst codec_inst = {0}; 198 webrtc::CodecInst codec_inst = {0};
176 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) { 199 if (codec->GetRecCodec(config_.voe_channel_id, codec_inst) == -1) {
177 return stats; 200 return stats;
178 } 201 }
179 202
(...skipping 28 matching lines...) Expand all
208 stats.decoding_normal = ds.decoded_normal; 231 stats.decoding_normal = ds.decoded_normal;
209 stats.decoding_plc = ds.decoded_plc; 232 stats.decoding_plc = ds.decoded_plc;
210 stats.decoding_cng = ds.decoded_cng; 233 stats.decoding_cng = ds.decoded_cng;
211 stats.decoding_plc_cng = ds.decoded_plc_cng; 234 stats.decoding_plc_cng = ds.decoded_plc_cng;
212 stats.decoding_muted_output = ds.decoded_muted_output; 235 stats.decoding_muted_output = ds.decoded_muted_output;
213 236
214 return stats; 237 return stats;
215 } 238 }
216 239
217 void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) { 240 void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
218 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 241 RTC_DCHECK_RUN_ON(&thread_checker_);
219 channel_proxy_->SetSink(std::move(sink)); 242 channel_proxy_->SetSink(std::move(sink));
220 } 243 }
221 244
222 void AudioReceiveStream::SetGain(float gain) { 245 void AudioReceiveStream::SetGain(float gain) {
223 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 246 RTC_DCHECK_RUN_ON(&thread_checker_);
224 channel_proxy_->SetChannelOutputVolumeScaling(gain); 247 channel_proxy_->SetChannelOutputVolumeScaling(gain);
225 } 248 }
226 249
227 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { 250 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
228 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 251 RTC_DCHECK_RUN_ON(&thread_checker_);
229 return config_; 252 return config_;
230 } 253 }
231 254
232 void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) { 255 void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
233 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 256 RTC_DCHECK(thread_checker_.CalledOnValidThread());
234 if (send_stream) { 257 if (send_stream) {
235 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); 258 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
236 std::unique_ptr<voe::ChannelProxy> send_channel_proxy = 259 std::unique_ptr<voe::ChannelProxy> send_channel_proxy =
237 voe_impl->GetChannelProxy(send_stream->config().voe_channel_id); 260 voe_impl->GetChannelProxy(send_stream->config().voe_channel_id);
238 channel_proxy_->AssociateSendChannel(*send_channel_proxy.get()); 261 channel_proxy_->AssociateSendChannel(*send_channel_proxy.get());
239 } else { 262 } else {
240 channel_proxy_->DisassociateSendChannel(); 263 channel_proxy_->DisassociateSendChannel();
241 } 264 }
242 } 265 }
243 266
244 void AudioReceiveStream::SignalNetworkState(NetworkState state) { 267 void AudioReceiveStream::SignalNetworkState(NetworkState state) {
245 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 268 RTC_DCHECK_RUN_ON(&thread_checker_);
246 } 269 }
247 270
248 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { 271 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
249 // TODO(solenberg): Tests call this function on a network thread, libjingle 272 // TODO(solenberg): Tests call this function on a network thread, libjingle
250 // calls on the worker thread. We should move towards always using a network 273 // calls on the worker thread. We should move towards always using a network
251 // thread. Then this check can be enabled. 274 // thread. Then this check can be enabled.
252 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); 275 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
253 return channel_proxy_->ReceivedRTCPPacket(packet, length); 276 return channel_proxy_->ReceivedRTCPPacket(packet, length);
254 } 277 }
255 278
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 311 }
289 312
290 int AudioReceiveStream::PreferredSampleRate() const { 313 int AudioReceiveStream::PreferredSampleRate() const {
291 return channel_proxy_->NeededFrequency(); 314 return channel_proxy_->NeededFrequency();
292 } 315 }
293 316
294 int AudioReceiveStream::Ssrc() const { 317 int AudioReceiveStream::Ssrc() const {
295 return config_.rtp.local_ssrc; 318 return config_.rtp.local_ssrc;
296 } 319 }
297 320
321 internal::AudioState* AudioReceiveStream::audio_state() const {
322 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
323 RTC_DCHECK(audio_state);
324 return audio_state;
325 }
326
298 VoiceEngine* AudioReceiveStream::voice_engine() const { 327 VoiceEngine* AudioReceiveStream::voice_engine() const {
299 internal::AudioState* audio_state = 328 auto* voice_engine = audio_state()->voice_engine();
300 static_cast<internal::AudioState*>(audio_state_.get());
301 VoiceEngine* voice_engine = audio_state->voice_engine();
302 RTC_DCHECK(voice_engine); 329 RTC_DCHECK(voice_engine);
303 return voice_engine; 330 return voice_engine;
304 } 331 }
332
333 int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) {
334 ScopedVoEInterface<VoEBase> base(voice_engine());
335 if (playout) {
336 return base->StartPlayout(config_.voe_channel_id);
337 } else {
338 return base->StopPlayout(config_.voe_channel_id);
339 }
340 }
341
305 } // namespace internal 342 } // namespace internal
306 } // namespace webrtc 343 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698