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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2072783002: - Remove use of VoERTP_RTCP::SetLocalSSRC() for receive streams; recreate them instead. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 6 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 | « webrtc/media/engine/webrtcvoe.h ('k') | webrtc/media/engine/webrtcvoiceengine_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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 bool use_nack, 1278 bool use_nack,
1279 const std::string& sync_group, 1279 const std::string& sync_group,
1280 const std::vector<webrtc::RtpExtension>& extensions, 1280 const std::vector<webrtc::RtpExtension>& extensions,
1281 webrtc::Call* call, 1281 webrtc::Call* call,
1282 webrtc::Transport* rtcp_send_transport, 1282 webrtc::Transport* rtcp_send_transport,
1283 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory) 1283 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory)
1284 : call_(call), config_() { 1284 : call_(call), config_() {
1285 RTC_DCHECK_GE(ch, 0); 1285 RTC_DCHECK_GE(ch, 0);
1286 RTC_DCHECK(call); 1286 RTC_DCHECK(call);
1287 config_.rtp.remote_ssrc = remote_ssrc; 1287 config_.rtp.remote_ssrc = remote_ssrc;
1288 config_.rtp.local_ssrc = local_ssrc;
1289 config_.rtcp_send_transport = rtcp_send_transport; 1288 config_.rtcp_send_transport = rtcp_send_transport;
1290 config_.voe_channel_id = ch; 1289 config_.voe_channel_id = ch;
1291 config_.sync_group = sync_group; 1290 config_.sync_group = sync_group;
1292 config_.decoder_factory = decoder_factory; 1291 config_.decoder_factory = decoder_factory;
1293 RecreateAudioReceiveStream(use_transport_cc, use_nack, extensions); 1292 RecreateAudioReceiveStream(local_ssrc,
1293 use_transport_cc,
1294 use_nack,
1295 extensions);
1294 } 1296 }
1295 1297
1296 ~WebRtcAudioReceiveStream() { 1298 ~WebRtcAudioReceiveStream() {
1297 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1299 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1298 call_->DestroyAudioReceiveStream(stream_); 1300 call_->DestroyAudioReceiveStream(stream_);
1299 } 1301 }
1300 1302
1303 void RecreateAudioReceiveStream(uint32_t local_ssrc) {
1304 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1305 RecreateAudioReceiveStream(local_ssrc,
1306 config_.rtp.transport_cc,
1307 config_.rtp.nack.rtp_history_ms != 0,
1308 config_.rtp.extensions);
1309 }
1310
1311 void RecreateAudioReceiveStream(bool use_transport_cc, bool use_nack) {
1312 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1313 RecreateAudioReceiveStream(config_.rtp.local_ssrc,
1314 use_transport_cc,
1315 use_nack,
1316 config_.rtp.extensions);
1317 }
1318
1301 void RecreateAudioReceiveStream( 1319 void RecreateAudioReceiveStream(
1302 const std::vector<webrtc::RtpExtension>& extensions) { 1320 const std::vector<webrtc::RtpExtension>& extensions) {
1303 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1321 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1304 RecreateAudioReceiveStream(config_.rtp.transport_cc, 1322 RecreateAudioReceiveStream(config_.rtp.local_ssrc,
1323 config_.rtp.transport_cc,
1305 config_.rtp.nack.rtp_history_ms != 0, 1324 config_.rtp.nack.rtp_history_ms != 0,
1306 extensions); 1325 extensions);
1307 } 1326 }
1308 1327
1309 void RecreateAudioReceiveStream(bool use_transport_cc, bool use_nack) {
1310 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1311 RecreateAudioReceiveStream(use_transport_cc,
1312 use_nack,
1313 config_.rtp.extensions);
1314 }
1315
1316 webrtc::AudioReceiveStream::Stats GetStats() const { 1328 webrtc::AudioReceiveStream::Stats GetStats() const {
1317 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1329 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1318 RTC_DCHECK(stream_); 1330 RTC_DCHECK(stream_);
1319 return stream_->GetStats(); 1331 return stream_->GetStats();
1320 } 1332 }
1321 1333
1322 int channel() const { 1334 int channel() const {
1323 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1335 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1324 return config_.voe_channel_id; 1336 return config_.voe_channel_id;
1325 } 1337 }
1326 1338
1327 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1339 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1328 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1340 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1329 stream_->SetSink(std::move(sink)); 1341 stream_->SetSink(std::move(sink));
1330 } 1342 }
1331 1343
1332 private: 1344 private:
1333 void RecreateAudioReceiveStream( 1345 void RecreateAudioReceiveStream(
1346 uint32_t local_ssrc,
1334 bool use_transport_cc, 1347 bool use_transport_cc,
1335 bool use_nack, 1348 bool use_nack,
1336 const std::vector<webrtc::RtpExtension>& extensions) { 1349 const std::vector<webrtc::RtpExtension>& extensions) {
1337 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1350 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1338 if (stream_) { 1351 if (stream_) {
1339 call_->DestroyAudioReceiveStream(stream_); 1352 call_->DestroyAudioReceiveStream(stream_);
1340 stream_ = nullptr; 1353 stream_ = nullptr;
1341 } 1354 }
1355 config_.rtp.local_ssrc = local_ssrc;
1342 config_.rtp.transport_cc = use_transport_cc; 1356 config_.rtp.transport_cc = use_transport_cc;
1343 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0; 1357 config_.rtp.nack.rtp_history_ms = use_nack ? kNackRtpHistoryMs : 0;
1344 config_.rtp.extensions = extensions; 1358 config_.rtp.extensions = extensions;
1345 RTC_DCHECK(!stream_); 1359 RTC_DCHECK(!stream_);
1346 stream_ = call_->CreateAudioReceiveStream(config_); 1360 stream_ = call_->CreateAudioReceiveStream(config_);
1347 RTC_CHECK(stream_); 1361 RTC_CHECK(stream_);
1348 } 1362 }
1349 1363
1350 rtc::ThreadChecker worker_thread_checker_; 1364 rtc::ThreadChecker worker_thread_checker_;
1351 webrtc::Call* call_ = nullptr; 1365 webrtc::Call* call_ = nullptr;
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 send_streams_.insert(std::make_pair(ssrc, stream)); 2029 send_streams_.insert(std::make_pair(ssrc, stream));
2016 2030
2017 // Set the current codecs to be used for the new channel. We need to do this 2031 // Set the current codecs to be used for the new channel. We need to do this
2018 // after adding the channel to send_channels_, because of how max bitrate is 2032 // after adding the channel to send_channels_, because of how max bitrate is
2019 // currently being configured by SetSendCodec(). 2033 // currently being configured by SetSendCodec().
2020 if (HasSendCodec() && !SetSendCodecs(channel, stream->rtp_parameters())) { 2034 if (HasSendCodec() && !SetSendCodecs(channel, stream->rtp_parameters())) {
2021 RemoveSendStream(ssrc); 2035 RemoveSendStream(ssrc);
2022 return false; 2036 return false;
2023 } 2037 }
2024 2038
2025 // At this point the channel's local SSRC has been updated. If the channel is 2039 // At this point the stream's local SSRC has been updated. If it is the first
2026 // the first send channel make sure that all the receive channels are updated 2040 // send stream, make sure that all the receive streams are updated with the
2027 // with the same SSRC in order to send receiver reports. 2041 // same SSRC in order to send receiver reports.
2028 if (send_streams_.size() == 1) { 2042 if (send_streams_.size() == 1) {
2029 receiver_reports_ssrc_ = ssrc; 2043 receiver_reports_ssrc_ = ssrc;
2030 for (const auto& stream : recv_streams_) { 2044 for (const auto& kv : recv_streams_) {
2031 int recv_channel = stream.second->channel(); 2045 kv.second->RecreateAudioReceiveStream(ssrc);
2032 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { 2046 int recv_channel = kv.second->channel();
pthatcher1 2016/06/16 19:20:02 Could you make a comment that this may cause calle
the sun 2016/06/16 19:34:21 Done.
2033 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
2034 return false;
2035 }
2036 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); 2047 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
2037 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel 2048 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
2038 << " is associated with channel #" << channel << "."; 2049 << " is associated with channel #" << channel << ".";
2039 } 2050 }
2040 } 2051 }
2041 2052
2042 send_streams_[ssrc]->SetSend(send_); 2053 send_streams_[ssrc]->SetSend(send_);
2043 return true; 2054 return true;
2044 } 2055 }
2045 2056
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 } 2605 }
2595 } else { 2606 } else {
2596 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2607 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2597 engine()->voe()->base()->StopPlayout(channel); 2608 engine()->voe()->base()->StopPlayout(channel);
2598 } 2609 }
2599 return true; 2610 return true;
2600 } 2611 }
2601 } // namespace cricket 2612 } // namespace cricket
2602 2613
2603 #endif // HAVE_WEBRTC_VOICE 2614 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoe.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698