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

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

Issue 1885473004: Adding codecs to the RtpParameters returned by an RtpSender. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Responding to review comments. Created 4 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) 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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1411 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpParameters( 1411 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpParameters(
1412 uint32_t ssrc) const { 1412 uint32_t ssrc) const {
1413 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1413 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1414 auto it = send_streams_.find(ssrc); 1414 auto it = send_streams_.find(ssrc);
1415 if (it == send_streams_.end()) { 1415 if (it == send_streams_.end()) {
1416 LOG(LS_WARNING) << "Attempting to get RTP parameters for stream with ssrc " 1416 LOG(LS_WARNING) << "Attempting to get RTP parameters for stream with ssrc "
1417 << ssrc << " which doesn't exist."; 1417 << ssrc << " which doesn't exist.";
1418 return webrtc::RtpParameters(); 1418 return webrtc::RtpParameters();
1419 } 1419 }
1420 1420
1421 return it->second->rtp_parameters(); 1421 webrtc::RtpParameters rtp_params = it->second->rtp_parameters();
1422 // Need to add the common list of codecs to the send stream-specific
1423 // RTP parameters.
1424 for (const AudioCodec& codec : send_codecs_) {
1425 rtp_params.codecs.push_back(codec.ToCodecParameters());
1426 }
1427 return rtp_params;
1422 } 1428 }
1423 1429
1424 bool WebRtcVoiceMediaChannel::SetRtpParameters( 1430 bool WebRtcVoiceMediaChannel::SetRtpParameters(
1425 uint32_t ssrc, 1431 uint32_t ssrc,
1426 const webrtc::RtpParameters& parameters) { 1432 const webrtc::RtpParameters& parameters) {
1427 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1433 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1428 if (!ValidateRtpParameters(parameters)) { 1434 if (!ValidateRtpParameters(parameters)) {
1429 return false; 1435 return false;
1430 } 1436 }
1431 auto it = send_streams_.find(ssrc); 1437 auto it = send_streams_.find(ssrc);
1432 if (it == send_streams_.end()) { 1438 if (it == send_streams_.end()) {
1433 LOG(LS_WARNING) << "Attempting to set RTP parameters for stream with ssrc " 1439 LOG(LS_WARNING) << "Attempting to set RTP parameters for stream with ssrc "
1434 << ssrc << " which doesn't exist."; 1440 << ssrc << " which doesn't exist.";
1435 return false; 1441 return false;
1436 } 1442 }
1437 1443
1438 if (!SetChannelParameters(it->second->channel(), parameters)) { 1444 if (!SetChannelParameters(it->second->channel(), parameters)) {
1439 LOG(LS_WARNING) << "Failed to set RtpParameters."; 1445 LOG(LS_WARNING) << "Failed to set RtpParameters.";
1440 return false; 1446 return false;
1441 } 1447 }
1442 it->second->set_rtp_parameters(parameters); 1448 // Codecs are handled at the WebRtcVoiceMediaChannel level.
1449 webrtc::RtpParameters reduced_params = parameters;
1450 reduced_params.codecs.clear();
1451 it->second->set_rtp_parameters(reduced_params);
1443 return true; 1452 return true;
1444 } 1453 }
1445 1454
1446 bool WebRtcVoiceMediaChannel::ValidateRtpParameters( 1455 bool WebRtcVoiceMediaChannel::ValidateRtpParameters(
1447 const webrtc::RtpParameters& rtp_parameters) { 1456 const webrtc::RtpParameters& rtp_parameters) {
1448 if (rtp_parameters.encodings.size() != 1) { 1457 if (rtp_parameters.encodings.size() != 1) {
1449 LOG(LS_ERROR) 1458 LOG(LS_ERROR)
1450 << "Attempted to set RtpParameters without exactly one encoding"; 1459 << "Attempted to set RtpParameters without exactly one encoding";
1451 return false; 1460 return false;
1452 } 1461 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 // and in that case reconfigure all receive streams. 1672 // and in that case reconfigure all receive streams.
1664 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled) { 1673 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled) {
1665 LOG(LS_INFO) << "Recreate all the receive streams because the send " 1674 LOG(LS_INFO) << "Recreate all the receive streams because the send "
1666 "codec has changed."; 1675 "codec has changed.";
1667 recv_transport_cc_enabled_ = send_codec_spec_.transport_cc_enabled; 1676 recv_transport_cc_enabled_ = send_codec_spec_.transport_cc_enabled;
1668 for (auto& kv : recv_streams_) { 1677 for (auto& kv : recv_streams_) {
1669 kv.second->RecreateAudioReceiveStream(recv_transport_cc_enabled_); 1678 kv.second->RecreateAudioReceiveStream(recv_transport_cc_enabled_);
1670 } 1679 }
1671 } 1680 }
1672 1681
1682 send_codecs_ = codecs;
1673 return true; 1683 return true;
1674 } 1684 }
1675 1685
1676 // Apply current codec settings to a single voe::Channel used for sending. 1686 // Apply current codec settings to a single voe::Channel used for sending.
1677 bool WebRtcVoiceMediaChannel::SetSendCodecs( 1687 bool WebRtcVoiceMediaChannel::SetSendCodecs(
1678 int channel, 1688 int channel,
1679 const webrtc::RtpParameters& rtp_parameters) { 1689 const webrtc::RtpParameters& rtp_parameters) {
1680 // Disable VAD, FEC, and RED unless we know the other side wants them. 1690 // Disable VAD, FEC, and RED unless we know the other side wants them.
1681 engine()->voe()->codec()->SetVADStatus(channel, false); 1691 engine()->voe()->codec()->SetVADStatus(channel, false);
1682 engine()->voe()->rtp()->SetNACKStatus(channel, false, 0); 1692 engine()->voe()->rtp()->SetNACKStatus(channel, false, 0);
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 return false; 2392 return false;
2383 } 2393 }
2384 } 2394 }
2385 return true; 2395 return true;
2386 } 2396 }
2387 2397
2388 bool WebRtcVoiceMediaChannel::SetChannelParameters( 2398 bool WebRtcVoiceMediaChannel::SetChannelParameters(
2389 int channel, 2399 int channel,
2390 const webrtc::RtpParameters& parameters) { 2400 const webrtc::RtpParameters& parameters) {
2391 RTC_CHECK_EQ(1UL, parameters.encodings.size()); 2401 RTC_CHECK_EQ(1UL, parameters.encodings.size());
2402 // TODO(deadbeef): Handle setting parameters with a list of codecs in a
2403 // different order (which should change the send codec).
2392 return SetSendBitrate( 2404 return SetSendBitrate(
2393 channel, 2405 channel,
2394 MinPositive(send_bitrate_bps_, parameters.encodings[0].max_bitrate_bps)); 2406 MinPositive(send_bitrate_bps_, parameters.encodings[0].max_bitrate_bps));
2395 } 2407 }
2396 2408
2397 bool WebRtcVoiceMediaChannel::SetSendBitrate(int channel, int bps) { 2409 bool WebRtcVoiceMediaChannel::SetSendBitrate(int channel, int bps) {
2398 // Bitrate is auto by default. 2410 // Bitrate is auto by default.
2399 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by 2411 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by
2400 // SetMaxSendBandwith(0), the second call removes the previous limit. 2412 // SetMaxSendBandwith(0), the second call removes the previous limit.
2401 if (bps <= 0) 2413 if (bps <= 0)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2562 } 2574 }
2563 } else { 2575 } else {
2564 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2576 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2565 engine()->voe()->base()->StopPlayout(channel); 2577 engine()->voe()->base()->StopPlayout(channel);
2566 } 2578 }
2567 return true; 2579 return true;
2568 } 2580 }
2569 } // namespace cricket 2581 } // namespace cricket
2570 2582
2571 #endif // HAVE_WEBRTC_VOICE 2583 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698