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

Side by Side Diff: webrtc/audio/audio_receive_stream.cc

Issue 2452163004: Stop using VoEVideoSync in Call/VideoReceiveStream. (Closed)
Patch Set: Don't expose RtpRtcp module in Syncable Created 3 years, 11 months 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
11 #include "webrtc/audio/audio_receive_stream.h" 11 #include "webrtc/audio/audio_receive_stream.h"
12 12
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 15
16 #include "webrtc/api/call/audio_sink.h" 16 #include "webrtc/api/call/audio_sink.h"
17 #include "webrtc/audio/audio_send_stream.h" 17 #include "webrtc/audio/audio_send_stream.h"
18 #include "webrtc/audio/audio_state.h" 18 #include "webrtc/audio/audio_state.h"
19 #include "webrtc/audio/conversion.h" 19 #include "webrtc/audio/conversion.h"
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/timeutils.h" 22 #include "webrtc/base/timeutils.h"
23 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h" 23 #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimat or.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
24 #include "webrtc/voice_engine/channel_proxy.h" 26 #include "webrtc/voice_engine/channel_proxy.h"
25 #include "webrtc/voice_engine/include/voe_base.h" 27 #include "webrtc/voice_engine/include/voe_base.h"
26 #include "webrtc/voice_engine/include/voe_codec.h" 28 #include "webrtc/voice_engine/include/voe_codec.h"
27 #include "webrtc/voice_engine/include/voe_neteq_stats.h" 29 #include "webrtc/voice_engine/include/voe_neteq_stats.h"
28 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" 30 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h"
29 #include "webrtc/voice_engine/include/voe_video_sync.h" 31 #include "webrtc/voice_engine/include/voe_video_sync.h"
30 #include "webrtc/voice_engine/include/voe_volume_control.h" 32 #include "webrtc/voice_engine/include/voe_volume_control.h"
31 #include "webrtc/voice_engine/voice_engine_impl.h" 33 #include "webrtc/voice_engine/voice_engine_impl.h"
32 34
33 namespace webrtc { 35 namespace webrtc {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) { 220 void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
219 RTC_DCHECK_RUN_ON(&thread_checker_); 221 RTC_DCHECK_RUN_ON(&thread_checker_);
220 channel_proxy_->SetSink(std::move(sink)); 222 channel_proxy_->SetSink(std::move(sink));
221 } 223 }
222 224
223 void AudioReceiveStream::SetGain(float gain) { 225 void AudioReceiveStream::SetGain(float gain) {
224 RTC_DCHECK_RUN_ON(&thread_checker_); 226 RTC_DCHECK_RUN_ON(&thread_checker_);
225 channel_proxy_->SetChannelOutputVolumeScaling(gain); 227 channel_proxy_->SetChannelOutputVolumeScaling(gain);
226 } 228 }
227 229
228 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { 230 AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo(
231 int sample_rate_hz,
232 AudioFrame* audio_frame) {
233 return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
234 }
235
236 int AudioReceiveStream::Ssrc() const {
237 return config_.rtp.remote_ssrc;
238 }
239
240 int AudioReceiveStream::PreferredSampleRate() const {
241 return channel_proxy_->NeededFrequency();
242 }
243
244 int AudioReceiveStream::id() const {
229 RTC_DCHECK_RUN_ON(&thread_checker_); 245 RTC_DCHECK_RUN_ON(&thread_checker_);
230 return config_; 246 return config_.rtp.remote_ssrc;
247 }
248
249 rtc::Optional<Syncable::Info> AudioReceiveStream::GetInfo() const {
stefan-webrtc 2017/01/19 11:59:59 Should you make sure this runs on the right thread
the sun 2017/01/19 13:15:36 id() is called when sync is set up, part of stream
250 // Called on Call's module_process_thread_.
251 Syncable::Info info;
252
253 RtpRtcp* rtp_rtcp = nullptr;
254 RtpReceiver* rtp_receiver = nullptr;
255 channel_proxy_->GetRtpRtcp(&rtp_rtcp, &rtp_receiver);
256 RTC_DCHECK(rtp_rtcp);
257 RTC_DCHECK(rtp_receiver);
258
259 if (!rtp_receiver->Timestamp(&info.latest_timestamp))
260 return rtc::Optional<Syncable::Info>();
261 if (!rtp_receiver->LastReceivedTimeMs(&info.latest_receive_time_ms))
262 return rtc::Optional<Syncable::Info>();
263 if (rtp_rtcp->RemoteNTP(&info.ntp_secs, &info.ntp_frac, nullptr, nullptr,
264 &info.rtp_timestamp) != 0) {
265 return rtc::Optional<Syncable::Info>();
266 }
267
268 int jitter_buffer_delay_ms = 0;
269 int playout_buffer_delay_ms = 0;
270 channel_proxy_->GetDelayEstimate(&jitter_buffer_delay_ms,
271 &playout_buffer_delay_ms);
272 info.current_delay_ms = jitter_buffer_delay_ms + playout_buffer_delay_ms;
273 return rtc::Optional<Syncable::Info>(info);
274 }
275
276 uint32_t AudioReceiveStream::GetPlayoutTimestamp() const {
277 // Called on video capture thread.
278 return channel_proxy_->GetPlayoutTimestamp();
279 }
280
281 void AudioReceiveStream::SetMinimumPlayoutDelay(int delay_ms) {
282 // Called on Call's module_process_thread_.
283 return channel_proxy_->SetMinimumPlayoutDelay(delay_ms);
231 } 284 }
232 285
233 void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) { 286 void AudioReceiveStream::AssociateSendStream(AudioSendStream* send_stream) {
234 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 287 RTC_DCHECK_RUN_ON(&thread_checker_);
235 if (send_stream) { 288 if (send_stream) {
236 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); 289 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
237 std::unique_ptr<voe::ChannelProxy> send_channel_proxy = 290 std::unique_ptr<voe::ChannelProxy> send_channel_proxy =
238 voe_impl->GetChannelProxy(send_stream->config().voe_channel_id); 291 voe_impl->GetChannelProxy(send_stream->config().voe_channel_id);
239 channel_proxy_->AssociateSendChannel(*send_channel_proxy.get()); 292 channel_proxy_->AssociateSendChannel(*send_channel_proxy.get());
240 } else { 293 } else {
241 channel_proxy_->DisassociateSendChannel(); 294 channel_proxy_->DisassociateSendChannel();
242 } 295 }
243 } 296 }
244 297
(...skipping 30 matching lines...) Expand all
275 if (packet_time.timestamp >= 0) 328 if (packet_time.timestamp >= 0)
276 arrival_time_ms = (packet_time.timestamp + 500) / 1000; 329 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
277 size_t payload_size = length - header.headerLength; 330 size_t payload_size = length - header.headerLength;
278 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, 331 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size,
279 header); 332 header);
280 } 333 }
281 334
282 return channel_proxy_->ReceivedRTPPacket(packet, length, packet_time); 335 return channel_proxy_->ReceivedRTPPacket(packet, length, packet_time);
283 } 336 }
284 337
285 AudioMixer::Source::AudioFrameInfo AudioReceiveStream::GetAudioFrameWithInfo( 338 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
286 int sample_rate_hz, 339 RTC_DCHECK_RUN_ON(&thread_checker_);
287 AudioFrame* audio_frame) { 340 return config_;
288 return channel_proxy_->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
289 } 341 }
290 342
291 int AudioReceiveStream::PreferredSampleRate() const { 343 VoiceEngine* AudioReceiveStream::voice_engine() const {
292 return channel_proxy_->NeededFrequency(); 344 auto* voice_engine = audio_state()->voice_engine();
293 } 345 RTC_DCHECK(voice_engine);
294 346 return voice_engine;
295 int AudioReceiveStream::Ssrc() const {
296 return config_.rtp.remote_ssrc;
297 } 347 }
298 348
299 internal::AudioState* AudioReceiveStream::audio_state() const { 349 internal::AudioState* AudioReceiveStream::audio_state() const {
300 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get()); 350 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get());
301 RTC_DCHECK(audio_state); 351 RTC_DCHECK(audio_state);
302 return audio_state; 352 return audio_state;
303 } 353 }
304 354
305 VoiceEngine* AudioReceiveStream::voice_engine() const {
306 auto* voice_engine = audio_state()->voice_engine();
307 RTC_DCHECK(voice_engine);
308 return voice_engine;
309 }
310
311 int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) { 355 int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) {
312 ScopedVoEInterface<VoEBase> base(voice_engine()); 356 ScopedVoEInterface<VoEBase> base(voice_engine());
313 if (playout) { 357 if (playout) {
314 return base->StartPlayout(config_.voe_channel_id); 358 return base->StartPlayout(config_.voe_channel_id);
315 } else { 359 } else {
316 return base->StopPlayout(config_.voe_channel_id); 360 return base->StopPlayout(config_.voe_channel_id);
317 } 361 }
318 } 362 }
319
320 } // namespace internal 363 } // namespace internal
321 } // namespace webrtc 364 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698