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

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

Issue 1909333002: Switch voice transport to use Call and Stream instead of VoENetwork. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed coments on ps#6 Created 4 years, 7 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
« no previous file with comments | « no previous file | webrtc/audio/audio_receive_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 ss << ']'; 60 ss << ']';
61 ss << ", transport_cc: " << (transport_cc ? "on" : "off"); 61 ss << ", transport_cc: " << (transport_cc ? "on" : "off");
62 ss << '}'; 62 ss << '}';
63 return ss.str(); 63 return ss.str();
64 } 64 }
65 65
66 std::string AudioReceiveStream::Config::ToString() const { 66 std::string AudioReceiveStream::Config::ToString() const {
67 std::stringstream ss; 67 std::stringstream ss;
68 ss << "{rtp: " << rtp.ToString(); 68 ss << "{rtp: " << rtp.ToString();
69 ss << ", receive_transport: "
70 << (receive_transport ? "(Transport)" : "nullptr");
71 ss << ", rtcp_send_transport: " 69 ss << ", rtcp_send_transport: "
72 << (rtcp_send_transport ? "(Transport)" : "nullptr"); 70 << (rtcp_send_transport ? "(Transport)" : "nullptr");
73 ss << ", voe_channel_id: " << voe_channel_id; 71 ss << ", voe_channel_id: " << voe_channel_id;
74 if (!sync_group.empty()) { 72 if (!sync_group.empty()) {
75 ss << ", sync_group: " << sync_group; 73 ss << ", sync_group: " << sync_group;
76 } 74 }
77 ss << '}'; 75 ss << '}';
78 return ss.str(); 76 return ss.str();
79 } 77 }
80 78
81 namespace internal { 79 namespace internal {
82 AudioReceiveStream::AudioReceiveStream( 80 AudioReceiveStream::AudioReceiveStream(
83 CongestionController* congestion_controller, 81 CongestionController* congestion_controller,
84 const webrtc::AudioReceiveStream::Config& config, 82 const webrtc::AudioReceiveStream::Config& config,
85 const rtc::scoped_refptr<webrtc::AudioState>& audio_state) 83 const rtc::scoped_refptr<webrtc::AudioState>& audio_state)
86 : config_(config), 84 : config_(config),
87 audio_state_(audio_state), 85 audio_state_(audio_state),
88 rtp_header_parser_(RtpHeaderParser::Create()) { 86 rtp_header_parser_(RtpHeaderParser::Create()) {
89 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); 87 LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString();
90 RTC_DCHECK_NE(config_.voe_channel_id, -1); 88 RTC_DCHECK_NE(config_.voe_channel_id, -1);
91 RTC_DCHECK(audio_state_.get()); 89 RTC_DCHECK(audio_state_.get());
92 RTC_DCHECK(congestion_controller); 90 RTC_DCHECK(congestion_controller);
93 RTC_DCHECK(rtp_header_parser_); 91 RTC_DCHECK(rtp_header_parser_);
94 92
95 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); 93 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine());
96 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); 94 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id);
97 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc); 95 channel_proxy_->SetLocalSSRC(config.rtp.local_ssrc);
96
97 channel_proxy_->RegisterExternalTransport(config.rtcp_send_transport);
98
98 for (const auto& extension : config.rtp.extensions) { 99 for (const auto& extension : config.rtp.extensions) {
99 if (extension.name == RtpExtension::kAudioLevel) { 100 if (extension.name == RtpExtension::kAudioLevel) {
100 channel_proxy_->SetReceiveAudioLevelIndicationStatus(true, extension.id); 101 channel_proxy_->SetReceiveAudioLevelIndicationStatus(true, extension.id);
101 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( 102 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension(
102 kRtpExtensionAudioLevel, extension.id); 103 kRtpExtensionAudioLevel, extension.id);
103 RTC_DCHECK(registered); 104 RTC_DCHECK(registered);
104 } else if (extension.name == RtpExtension::kAbsSendTime) { 105 } else if (extension.name == RtpExtension::kAbsSendTime) {
105 channel_proxy_->SetReceiveAbsoluteSenderTimeStatus(true, extension.id); 106 channel_proxy_->SetReceiveAbsoluteSenderTimeStatus(true, extension.id);
106 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( 107 bool registered = rtp_header_parser_->RegisterRtpHeaderExtension(
107 kRtpExtensionAbsoluteSendTime, extension.id); 108 kRtpExtensionAbsoluteSendTime, extension.id);
(...skipping 12 matching lines...) Expand all
120 congestion_controller->packet_router()); 121 congestion_controller->packet_router());
121 if (UseSendSideBwe(config)) { 122 if (UseSendSideBwe(config)) {
122 remote_bitrate_estimator_ = 123 remote_bitrate_estimator_ =
123 congestion_controller->GetRemoteBitrateEstimator(true); 124 congestion_controller->GetRemoteBitrateEstimator(true);
124 } 125 }
125 } 126 }
126 127
127 AudioReceiveStream::~AudioReceiveStream() { 128 AudioReceiveStream::~AudioReceiveStream() {
128 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 129 RTC_DCHECK(thread_checker_.CalledOnValidThread());
129 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); 130 LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString();
131 channel_proxy_->DeRegisterExternalTransport();
130 channel_proxy_->ResetCongestionControlObjects(); 132 channel_proxy_->ResetCongestionControlObjects();
131 if (remote_bitrate_estimator_) { 133 if (remote_bitrate_estimator_) {
132 remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc); 134 remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc);
133 } 135 }
134 } 136 }
135 137
136 void AudioReceiveStream::Start() { 138 void AudioReceiveStream::Start() {
137 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 139 RTC_DCHECK(thread_checker_.CalledOnValidThread());
138 } 140 }
139 141
140 void AudioReceiveStream::Stop() { 142 void AudioReceiveStream::Stop() {
141 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 143 RTC_DCHECK(thread_checker_.CalledOnValidThread());
142 } 144 }
143 145
144 void AudioReceiveStream::SignalNetworkState(NetworkState state) { 146 void AudioReceiveStream::SignalNetworkState(NetworkState state) {
145 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 147 RTC_DCHECK(thread_checker_.CalledOnValidThread());
146 } 148 }
147 149
148 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { 150 bool AudioReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
149 // TODO(solenberg): Tests call this function on a network thread, libjingle 151 // TODO(solenberg): Tests call this function on a network thread, libjingle
150 // calls on the worker thread. We should move towards always using a network 152 // calls on the worker thread. We should move towards always using a network
151 // thread. Then this check can be enabled. 153 // thread. Then this check can be enabled.
152 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); 154 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
153 return false; 155 return channel_proxy_->ReceivedRTCPPacket(packet, length);
154 } 156 }
155 157
156 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, 158 bool AudioReceiveStream::DeliverRtp(const uint8_t* packet,
157 size_t length, 159 size_t length,
158 const PacketTime& packet_time) { 160 const PacketTime& packet_time) {
159 // TODO(solenberg): Tests call this function on a network thread, libjingle 161 // TODO(solenberg): Tests call this function on a network thread, libjingle
160 // calls on the worker thread. We should move towards always using a network 162 // calls on the worker thread. We should move towards always using a network
161 // thread. Then this check can be enabled. 163 // thread. Then this check can be enabled.
162 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); 164 // RTC_DCHECK(!thread_checker_.CalledOnValidThread());
163 RTPHeader header; 165 RTPHeader header;
164 if (!rtp_header_parser_->Parse(packet, length, &header)) { 166 if (!rtp_header_parser_->Parse(packet, length, &header)) {
165 return false; 167 return false;
166 } 168 }
167 169
168 // Only forward if the parsed header has one of the headers necessary for 170 // Only forward if the parsed header has one of the headers necessary for
169 // bandwidth estimation. RTP timestamps has different rates for audio and 171 // bandwidth estimation. RTP timestamps has different rates for audio and
170 // video and shouldn't be mixed. 172 // video and shouldn't be mixed.
171 if (remote_bitrate_estimator_ && 173 if (remote_bitrate_estimator_ &&
172 header.extension.hasTransportSequenceNumber) { 174 header.extension.hasTransportSequenceNumber) {
173 int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); 175 int64_t arrival_time_ms = TickTime::MillisecondTimestamp();
174 if (packet_time.timestamp >= 0) 176 if (packet_time.timestamp >= 0)
175 arrival_time_ms = (packet_time.timestamp + 500) / 1000; 177 arrival_time_ms = (packet_time.timestamp + 500) / 1000;
176 size_t payload_size = length - header.headerLength; 178 size_t payload_size = length - header.headerLength;
177 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, 179 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size,
178 header, false); 180 header, false);
179 } 181 }
180 return true; 182
183 return channel_proxy_->ReceivedRTPPacket(packet, length, packet_time);
181 } 184 }
182 185
183 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { 186 webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const {
184 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 187 RTC_DCHECK(thread_checker_.CalledOnValidThread());
185 webrtc::AudioReceiveStream::Stats stats; 188 webrtc::AudioReceiveStream::Stats stats;
186 stats.remote_ssrc = config_.rtp.remote_ssrc; 189 stats.remote_ssrc = config_.rtp.remote_ssrc;
187 ScopedVoEInterface<VoECodec> codec(voice_engine()); 190 ScopedVoEInterface<VoECodec> codec(voice_engine());
188 191
189 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics(); 192 webrtc::CallStatistics call_stats = channel_proxy_->GetRTCPStatistics();
190 webrtc::CodecInst codec_inst = {0}; 193 webrtc::CodecInst codec_inst = {0};
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 243
241 VoiceEngine* AudioReceiveStream::voice_engine() const { 244 VoiceEngine* AudioReceiveStream::voice_engine() const {
242 internal::AudioState* audio_state = 245 internal::AudioState* audio_state =
243 static_cast<internal::AudioState*>(audio_state_.get()); 246 static_cast<internal::AudioState*>(audio_state_.get());
244 VoiceEngine* voice_engine = audio_state->voice_engine(); 247 VoiceEngine* voice_engine = audio_state->voice_engine();
245 RTC_DCHECK(voice_engine); 248 RTC_DCHECK(voice_engine);
246 return voice_engine; 249 return voice_engine;
247 } 250 }
248 } // namespace internal 251 } // namespace internal
249 } // namespace webrtc 252 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/audio/audio_receive_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698