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

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

Issue 2685673003: Define RtpTransportControllerSendInterface. (Closed)
Patch Set: Minor comment update. Created 3 years, 8 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_send_stream.h" 11 #include "webrtc/audio/audio_send_stream.h"
12 12
13 #include <string> 13 #include <string>
14 14
15 #include "webrtc/audio/audio_state.h" 15 #include "webrtc/audio/audio_state.h"
16 #include "webrtc/audio/conversion.h" 16 #include "webrtc/audio/conversion.h"
17 #include "webrtc/audio/scoped_voe_interface.h" 17 #include "webrtc/audio/scoped_voe_interface.h"
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/event.h" 19 #include "webrtc/base/event.h"
20 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
21 #include "webrtc/base/task_queue.h" 21 #include "webrtc/base/task_queue.h"
22 #include "webrtc/call/rtp_transport_controller_send.h"
22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 23 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
23 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 24 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
24 #include "webrtc/modules/pacing/paced_sender.h" 25 #include "webrtc/modules/pacing/paced_sender.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.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/transmit_mixer.h" 29 #include "webrtc/voice_engine/transmit_mixer.h"
29 #include "webrtc/voice_engine/voice_engine_impl.h" 30 #include "webrtc/voice_engine/voice_engine_impl.h"
30 31
31 namespace webrtc { 32 namespace webrtc {
32 33
33 namespace { 34 namespace {
34 35
35 constexpr char kOpusCodecName[] = "opus"; 36 constexpr char kOpusCodecName[] = "opus";
36 37
37 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { 38 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) {
38 return (STR_CASE_CMP(codec.plname, ref_name) == 0); 39 return (STR_CASE_CMP(codec.plname, ref_name) == 0);
39 } 40 }
40 } // namespace 41 } // namespace
41 42
42 namespace internal { 43 namespace internal {
43 AudioSendStream::AudioSendStream( 44 AudioSendStream::AudioSendStream(
44 const webrtc::AudioSendStream::Config& config, 45 const webrtc::AudioSendStream::Config& config,
45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, 46 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
46 rtc::TaskQueue* worker_queue, 47 rtc::TaskQueue* worker_queue,
47 PacketRouter* packet_router, 48 RtpTransportControllerSendInterface* transport,
48 SendSideCongestionController* send_side_cc,
49 BitrateAllocator* bitrate_allocator, 49 BitrateAllocator* bitrate_allocator,
50 RtcEventLog* event_log, 50 RtcEventLog* event_log,
51 RtcpRttStats* rtcp_rtt_stats) 51 RtcpRttStats* rtcp_rtt_stats)
52 : worker_queue_(worker_queue), 52 : worker_queue_(worker_queue),
53 config_(config), 53 config_(config),
54 audio_state_(audio_state), 54 audio_state_(audio_state),
55 bitrate_allocator_(bitrate_allocator), 55 bitrate_allocator_(bitrate_allocator),
56 send_side_cc_(send_side_cc) { 56 transport_(transport) {
57 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); 57 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString();
58 RTC_DCHECK_NE(config_.voe_channel_id, -1); 58 RTC_DCHECK_NE(config_.voe_channel_id, -1);
59 RTC_DCHECK(audio_state_.get()); 59 RTC_DCHECK(audio_state_.get());
60 RTC_DCHECK(send_side_cc); 60 RTC_DCHECK(transport);
61 RTC_DCHECK(transport->send_side_cc());
61 62
62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); 63 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); 64 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id);
64 channel_proxy_->SetRtcEventLog(event_log); 65 channel_proxy_->SetRtcEventLog(event_log);
65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); 66 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats);
66 channel_proxy_->SetRTCPStatus(true); 67 channel_proxy_->SetRTCPStatus(true);
67 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); 68 channel_proxy_->SetLocalSSRC(config.rtp.ssrc);
68 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); 69 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name);
69 // TODO(solenberg): Config NACK history window (which is a packet count), 70 // TODO(solenberg): Config NACK history window (which is a packet count),
70 // using the actual packet size for the configured codec. 71 // using the actual packet size for the configured codec.
71 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, 72 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0,
72 config_.rtp.nack.rtp_history_ms / 20); 73 config_.rtp.nack.rtp_history_ms / 20);
73 74
74 channel_proxy_->RegisterExternalTransport(config.send_transport); 75 channel_proxy_->RegisterExternalTransport(config.send_transport);
75 76
76 for (const auto& extension : config.rtp.extensions) { 77 for (const auto& extension : config.rtp.extensions) {
77 if (extension.uri == RtpExtension::kAudioLevelUri) { 78 if (extension.uri == RtpExtension::kAudioLevelUri) {
78 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); 79 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id);
79 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { 80 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
80 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); 81 channel_proxy_->EnableSendTransportSequenceNumber(extension.id);
81 send_side_cc->EnablePeriodicAlrProbing(true); 82 transport->send_side_cc()->EnablePeriodicAlrProbing(true);
82 bandwidth_observer_.reset( 83 bandwidth_observer_.reset(transport->send_side_cc()
83 send_side_cc->GetBitrateController()->CreateRtcpBandwidthObserver()); 84 ->GetBitrateController()
85 ->CreateRtcpBandwidthObserver());
84 } else { 86 } else {
85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; 87 RTC_NOTREACHED() << "Registering unsupported RTP extension.";
86 } 88 }
87 } 89 }
88 channel_proxy_->RegisterSenderCongestionControlObjects( 90 channel_proxy_->RegisterSenderCongestionControlObjects(
89 send_side_cc->pacer(), send_side_cc, packet_router, 91 transport, bandwidth_observer_.get());
90 bandwidth_observer_.get());
91 if (!SetupSendCodec()) { 92 if (!SetupSendCodec()) {
92 LOG(LS_ERROR) << "Failed to set up send codec state."; 93 LOG(LS_ERROR) << "Failed to set up send codec state.";
93 } 94 }
94 } 95 }
95 96
96 AudioSendStream::~AudioSendStream() { 97 AudioSendStream::~AudioSendStream() {
97 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 98 RTC_DCHECK(thread_checker_.CalledOnValidThread());
98 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); 99 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString();
99 channel_proxy_->DeRegisterExternalTransport(); 100 channel_proxy_->DeRegisterExternalTransport();
100 channel_proxy_->ResetCongestionControlObjects(); 101 channel_proxy_->ResetCongestionControlObjects();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 return 0; 248 return 0;
248 } 249 }
249 250
250 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { 251 const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
251 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 252 RTC_DCHECK(thread_checker_.CalledOnValidThread());
252 return config_; 253 return config_;
253 } 254 }
254 255
255 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { 256 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) {
256 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 257 RTC_DCHECK(thread_checker_.CalledOnValidThread());
257 send_side_cc_->SetTransportOverhead(transport_overhead_per_packet); 258 transport_->send_side_cc()->SetTransportOverhead(
259 transport_overhead_per_packet);
258 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); 260 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet);
259 } 261 }
260 262
261 VoiceEngine* AudioSendStream::voice_engine() const { 263 VoiceEngine* AudioSendStream::voice_engine() const {
262 internal::AudioState* audio_state = 264 internal::AudioState* audio_state =
263 static_cast<internal::AudioState*>(audio_state_.get()); 265 static_cast<internal::AudioState*>(audio_state_.get());
264 VoiceEngine* voice_engine = audio_state->voice_engine(); 266 VoiceEngine* voice_engine = audio_state->voice_engine();
265 RTC_DCHECK(voice_engine); 267 RTC_DCHECK(voice_engine);
266 return voice_engine; 268 return voice_engine;
267 } 269 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 LOG(LS_WARNING) << "SetVADStatus() failed."; 375 LOG(LS_WARNING) << "SetVADStatus() failed.";
374 return false; 376 return false;
375 } 377 }
376 } 378 }
377 } 379 }
378 return true; 380 return true;
379 } 381 }
380 382
381 } // namespace internal 383 } // namespace internal
382 } // namespace webrtc 384 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698