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

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

Issue 2685673003: Define RtpTransportControllerSendInterface. (Closed)
Patch Set: Created 3 years, 10 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.h"
22 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 23 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
23 #include "webrtc/modules/pacing/paced_sender.h" 24 #include "webrtc/modules/pacing/paced_sender.h"
24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 25 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
25 #include "webrtc/voice_engine/channel_proxy.h" 26 #include "webrtc/voice_engine/channel_proxy.h"
26 #include "webrtc/voice_engine/include/voe_base.h" 27 #include "webrtc/voice_engine/include/voe_base.h"
27 #include "webrtc/voice_engine/include/voe_volume_control.h" 28 #include "webrtc/voice_engine/include/voe_volume_control.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 namespace { 33 namespace {
33 34
34 constexpr char kOpusCodecName[] = "opus"; 35 constexpr char kOpusCodecName[] = "opus";
35 36
36 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { 37 bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) {
37 return (_stricmp(codec.plname, ref_name) == 0); 38 return (_stricmp(codec.plname, ref_name) == 0);
38 } 39 }
39 } // namespace 40 } // namespace
40 41
41 namespace internal { 42 namespace internal {
42 AudioSendStream::AudioSendStream( 43 AudioSendStream::AudioSendStream(
43 const webrtc::AudioSendStream::Config& config, 44 const webrtc::AudioSendStream::Config& config,
44 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, 45 const rtc::scoped_refptr<webrtc::AudioState>& audio_state,
45 rtc::TaskQueue* worker_queue, 46 rtc::TaskQueue* worker_queue,
46 PacketRouter* packet_router, 47 RtpTransportControllerSenderInterface* transport,
47 CongestionController* congestion_controller,
48 BitrateAllocator* bitrate_allocator, 48 BitrateAllocator* bitrate_allocator,
49 RtcEventLog* event_log, 49 RtcEventLog* event_log,
50 RtcpRttStats* rtcp_rtt_stats) 50 RtcpRttStats* rtcp_rtt_stats)
51 : worker_queue_(worker_queue), 51 : worker_queue_(worker_queue),
52 config_(config), 52 config_(config),
53 audio_state_(audio_state), 53 audio_state_(audio_state),
54 bitrate_allocator_(bitrate_allocator), 54 bitrate_allocator_(bitrate_allocator),
55 congestion_controller_(congestion_controller) { 55 transport_(transport) {
56 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); 56 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString();
57 RTC_DCHECK_NE(config_.voe_channel_id, -1); 57 RTC_DCHECK_NE(config_.voe_channel_id, -1);
58 RTC_DCHECK(audio_state_.get()); 58 RTC_DCHECK(audio_state_.get());
59 RTC_DCHECK(congestion_controller); 59 RTC_DCHECK(transport);
60 RTC_DCHECK(transport->congestion_controller());
60 61
61 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); 62 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
62 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); 63 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id);
63 channel_proxy_->SetRtcEventLog(event_log); 64 channel_proxy_->SetRtcEventLog(event_log);
64 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats); 65 channel_proxy_->SetRtcpRttStats(rtcp_rtt_stats);
65 channel_proxy_->RegisterSenderCongestionControlObjects( 66 channel_proxy_->RegisterSenderCongestionControlObjects(transport);
66 congestion_controller->pacer(),
67 congestion_controller->GetTransportFeedbackObserver(), packet_router);
68 channel_proxy_->SetRTCPStatus(true); 67 channel_proxy_->SetRTCPStatus(true);
69 channel_proxy_->SetLocalSSRC(config.rtp.ssrc); 68 channel_proxy_->SetLocalSSRC(config.rtp.ssrc);
70 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name); 69 channel_proxy_->SetRTCP_CNAME(config.rtp.c_name);
71 // TODO(solenberg): Config NACK history window (which is a packet count), 70 // TODO(solenberg): Config NACK history window (which is a packet count),
72 // using the actual packet size for the configured codec. 71 // using the actual packet size for the configured codec.
73 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0, 72 channel_proxy_->SetNACKStatus(config_.rtp.nack.rtp_history_ms != 0,
74 config_.rtp.nack.rtp_history_ms / 20); 73 config_.rtp.nack.rtp_history_ms / 20);
75 74
76 channel_proxy_->RegisterExternalTransport(config.send_transport); 75 channel_proxy_->RegisterExternalTransport(config.send_transport);
77 76
78 for (const auto& extension : config.rtp.extensions) { 77 for (const auto& extension : config.rtp.extensions) {
79 if (extension.uri == RtpExtension::kAudioLevelUri) { 78 if (extension.uri == RtpExtension::kAudioLevelUri) {
80 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id); 79 channel_proxy_->SetSendAudioLevelIndicationStatus(true, extension.id);
81 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) { 80 } else if (extension.uri == RtpExtension::kTransportSequenceNumberUri) {
82 channel_proxy_->EnableSendTransportSequenceNumber(extension.id); 81 channel_proxy_->EnableSendTransportSequenceNumber(extension.id);
83 congestion_controller->EnablePeriodicAlrProbing(true); 82 transport->congestion_controller()->EnablePeriodicAlrProbing(true);
84 } else { 83 } else {
85 RTC_NOTREACHED() << "Registering unsupported RTP extension."; 84 RTC_NOTREACHED() << "Registering unsupported RTP extension.";
86 } 85 }
87 } 86 }
88 if (!SetupSendCodec()) { 87 if (!SetupSendCodec()) {
89 LOG(LS_ERROR) << "Failed to set up send codec state."; 88 LOG(LS_ERROR) << "Failed to set up send codec state.";
90 } 89 }
91 } 90 }
92 91
93 AudioSendStream::~AudioSendStream() { 92 AudioSendStream::~AudioSendStream() {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return 0; 248 return 0;
250 } 249 }
251 250
252 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { 251 const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
253 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 252 RTC_DCHECK(thread_checker_.CalledOnValidThread());
254 return config_; 253 return config_;
255 } 254 }
256 255
257 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) { 256 void AudioSendStream::SetTransportOverhead(int transport_overhead_per_packet) {
258 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 257 RTC_DCHECK(thread_checker_.CalledOnValidThread());
259 congestion_controller_->SetTransportOverhead(transport_overhead_per_packet); 258 transport_->congestion_controller()->SetTransportOverhead(
259 transport_overhead_per_packet);
260 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet); 260 channel_proxy_->SetTransportOverhead(transport_overhead_per_packet);
261 } 261 }
262 262
263 VoiceEngine* AudioSendStream::voice_engine() const { 263 VoiceEngine* AudioSendStream::voice_engine() const {
264 internal::AudioState* audio_state = 264 internal::AudioState* audio_state =
265 static_cast<internal::AudioState*>(audio_state_.get()); 265 static_cast<internal::AudioState*>(audio_state_.get());
266 VoiceEngine* voice_engine = audio_state->voice_engine(); 266 VoiceEngine* voice_engine = audio_state->voice_engine();
267 RTC_DCHECK(voice_engine); 267 RTC_DCHECK(voice_engine);
268 return voice_engine; 268 return voice_engine;
269 } 269 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 LOG(LS_WARNING) << "SetVADStatus() failed."; 375 LOG(LS_WARNING) << "SetVADStatus() failed.";
376 return false; 376 return false;
377 } 377 }
378 } 378 }
379 } 379 }
380 return true; 380 return true;
381 } 381 }
382 382
383 } // namespace internal 383 } // namespace internal
384 } // namespace webrtc 384 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698