Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" | 24 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
| 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
| 26 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
| 26 #include "webrtc/voice_engine/channel_proxy.h" | 27 #include "webrtc/voice_engine/channel_proxy.h" |
| 27 #include "webrtc/voice_engine/include/voe_base.h" | 28 #include "webrtc/voice_engine/include/voe_base.h" |
| 28 #include "webrtc/voice_engine/voice_engine_impl.h" | 29 #include "webrtc/voice_engine/voice_engine_impl.h" |
| 29 | 30 |
| 30 namespace webrtc { | 31 namespace webrtc { |
| 31 | 32 |
| 32 std::string AudioReceiveStream::Config::Rtp::ToString() const { | 33 std::string AudioReceiveStream::Config::Rtp::ToString() const { |
| 33 std::stringstream ss; | 34 std::stringstream ss; |
| 34 ss << "{remote_ssrc: " << remote_ssrc; | 35 ss << "{remote_ssrc: " << remote_ssrc; |
| 35 ss << ", local_ssrc: " << local_ssrc; | 36 ss << ", local_ssrc: " << local_ssrc; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 60 return ss.str(); | 61 return ss.str(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 namespace internal { | 64 namespace internal { |
| 64 AudioReceiveStream::AudioReceiveStream( | 65 AudioReceiveStream::AudioReceiveStream( |
| 65 PacketRouter* packet_router, | 66 PacketRouter* packet_router, |
| 66 const webrtc::AudioReceiveStream::Config& config, | 67 const webrtc::AudioReceiveStream::Config& config, |
| 67 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 68 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 68 webrtc::RtcEventLog* event_log) | 69 webrtc::RtcEventLog* event_log) |
| 69 : config_(config), | 70 : config_(config), |
| 71 rtp_header_extensions_(config.rtp.extensions), | |
|
pthatcher1
2017/04/29 00:58:46
Why not just use the config_.rtp.extensions? Why
nisse-webrtc
2017/05/02 09:34:47
This is also a type conversion, from a vector to t
| |
| 70 audio_state_(audio_state) { | 72 audio_state_(audio_state) { |
| 71 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); | 73 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); |
| 72 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 74 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 73 RTC_DCHECK(audio_state_.get()); | 75 RTC_DCHECK(audio_state_.get()); |
| 74 RTC_DCHECK(packet_router); | 76 RTC_DCHECK(packet_router); |
| 75 | 77 |
| 76 module_process_thread_checker_.DetachFromThread(); | 78 module_process_thread_checker_.DetachFromThread(); |
| 77 | 79 |
| 78 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 80 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| 79 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 81 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
| 80 channel_proxy_->SetRtcEventLog(event_log); | 82 channel_proxy_->SetRtcEventLog(event_log); |
| 81 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); | 83 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); |
| 82 // TODO(solenberg): Config NACK history window (which is a packet count), | 84 // TODO(solenberg): Config NACK history window (which is a packet count), |
| 83 // using the actual packet size for the configured codec. | 85 // using the actual packet size for the configured codec. |
| 84 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, | 86 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, |
| 85 config_.rtp.nack.rtp_history_ms / 20); | 87 config_.rtp.nack.rtp_history_ms / 20); |
| 86 | 88 |
| 87 // TODO(ossu): This is where we'd like to set the decoder factory to | 89 // TODO(ossu): This is where we'd like to set the decoder factory to |
| 88 // use. However, since it needs to be included when constructing Channel, we | 90 // use. However, since it needs to be included when constructing Channel, we |
| 89 // cannot do that until we're able to move Channel ownership into the | 91 // cannot do that until we're able to move Channel ownership into the |
| 90 // Audio{Send,Receive}Streams. The best we can do is check that we're not | 92 // Audio{Send,Receive}Streams. The best we can do is check that we're not |
| 91 // trying to use two different factories using the different interfaces. | 93 // trying to use two different factories using the different interfaces. |
| 92 RTC_CHECK(config.decoder_factory); | 94 RTC_CHECK(config.decoder_factory); |
| 93 RTC_CHECK_EQ(config.decoder_factory, | 95 RTC_CHECK_EQ(config.decoder_factory, |
| 94 channel_proxy_->GetAudioDecoderFactory()); | 96 channel_proxy_->GetAudioDecoderFactory()); |
| 95 | 97 |
| 96 channel_proxy_->RegisterExternalTransport(config.rtcp_send_transport); | 98 channel_proxy_->RegisterExternalTransport(config.rtcp_send_transport); |
| 97 channel_proxy_->SetReceiveCodecs(config.decoder_map); | 99 channel_proxy_->SetReceiveCodecs(config.decoder_map); |
| 98 | 100 |
| 99 for (const auto& extension : config.rtp.extensions) { | |
| 100 if (extension.uri == RtpExtension::kAudioLevelUri) { | |
| 101 channel_proxy_->SetReceiveAudioLevelIndicationStatus(true, extension.id); | |
| 102 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { | |
| 103 channel_proxy_->EnableReceiveTransportSequenceNumber(extension.id); | |
| 104 } else { | |
| 105 RTC_NOTREACHED() << "Unsupported RTP extension."; | |
| 106 } | |
| 107 } | |
| 108 // Configure bandwidth estimation. | 101 // Configure bandwidth estimation. |
| 109 channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router); | 102 channel_proxy_->RegisterReceiverCongestionControlObjects(packet_router); |
| 110 } | 103 } |
| 111 | 104 |
| 112 AudioReceiveStream::~AudioReceiveStream() { | 105 AudioReceiveStream::~AudioReceiveStream() { |
| 113 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 106 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 114 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); | 107 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); |
| 115 if (playing_) { | 108 if (playing_) { |
| 116 Stop(); | 109 Stop(); |
| 117 } | 110 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 } | 291 } |
| 299 | 292 |
| 300 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 293 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 301 // TODO(solenberg): Tests call this function on a network thread, libjingle | 294 // TODO(solenberg): Tests call this function on a network thread, libjingle |
| 302 // calls on the worker thread. We should move towards always using a network | 295 // calls on the worker thread. We should move towards always using a network |
| 303 // thread. Then this check can be enabled. | 296 // thread. Then this check can be enabled. |
| 304 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 297 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
| 305 return channel_proxy_->ReceivedRTCPPacket(packet, length); | 298 return channel_proxy_->ReceivedRTCPPacket(packet, length); |
| 306 } | 299 } |
| 307 | 300 |
| 308 void AudioReceiveStream::OnRtpPacket(const RtpPacketReceived& packet) { | 301 bool AudioReceiveStream::OnRtpPacketReceive(RtpPacketReceived* packet) { |
| 309 // TODO(solenberg): Tests call this function on a network thread, libjingle | 302 // TODO(solenberg): Tests call this function on a network thread, libjingle |
| 310 // calls on the worker thread. We should move towards always using a network | 303 // calls on the worker thread. We should move towards always using a network |
| 311 // thread. Then this check can be enabled. | 304 // thread. Then this check can be enabled. |
| 312 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 305 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
| 313 channel_proxy_->OnRtpPacket(packet); | 306 packet->IdentifyExtensions(rtp_header_extensions_); |
| 307 channel_proxy_->OnRtpPacket(*packet); | |
| 308 return true; | |
| 314 } | 309 } |
| 315 | 310 |
| 316 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { | 311 const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const { |
| 317 RTC_DCHECK_RUN_ON(&worker_thread_checker_); | 312 RTC_DCHECK_RUN_ON(&worker_thread_checker_); |
| 318 return config_; | 313 return config_; |
| 319 } | 314 } |
| 320 | 315 |
| 321 VoiceEngine* AudioReceiveStream::voice_engine() const { | 316 VoiceEngine* AudioReceiveStream::voice_engine() const { |
| 322 auto* voice_engine = audio_state()->voice_engine(); | 317 auto* voice_engine = audio_state()->voice_engine(); |
| 323 RTC_DCHECK(voice_engine); | 318 RTC_DCHECK(voice_engine); |
| 324 return voice_engine; | 319 return voice_engine; |
| 325 } | 320 } |
| 326 | 321 |
| 327 internal::AudioState* AudioReceiveStream::audio_state() const { | 322 internal::AudioState* AudioReceiveStream::audio_state() const { |
| 328 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get()); | 323 auto* audio_state = static_cast<internal::AudioState*>(audio_state_.get()); |
| 329 RTC_DCHECK(audio_state); | 324 RTC_DCHECK(audio_state); |
| 330 return audio_state; | 325 return audio_state; |
| 331 } | 326 } |
| 332 | 327 |
| 333 int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) { | 328 int AudioReceiveStream::SetVoiceEnginePlayout(bool playout) { |
| 334 ScopedVoEInterface<VoEBase> base(voice_engine()); | 329 ScopedVoEInterface<VoEBase> base(voice_engine()); |
| 335 if (playout) { | 330 if (playout) { |
| 336 return base->StartPlayout(config_.voe_channel_id); | 331 return base->StartPlayout(config_.voe_channel_id); |
| 337 } else { | 332 } else { |
| 338 return base->StopPlayout(config_.voe_channel_id); | 333 return base->StopPlayout(config_.voe_channel_id); |
| 339 } | 334 } |
| 340 } | 335 } |
| 341 } // namespace internal | 336 } // namespace internal |
| 342 } // namespace webrtc | 337 } // namespace webrtc |
| OLD | NEW |