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

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

Issue 2567333004: Add video send SSRC to RtpParameters, and don't allow changing SSRC. (Closed)
Patch Set: Back out Obj-C and Java changes (were landed separately) Created 3 years, 11 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 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 // Accessor to the VoE channel ID. 1377 // Accessor to the VoE channel ID.
1378 int channel() const { 1378 int channel() const {
1379 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1379 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1380 return config_.voe_channel_id; 1380 return config_.voe_channel_id;
1381 } 1381 }
1382 1382
1383 const webrtc::RtpParameters& rtp_parameters() const { 1383 const webrtc::RtpParameters& rtp_parameters() const {
1384 return rtp_parameters_; 1384 return rtp_parameters_;
1385 } 1385 }
1386 1386
1387 bool ValidateRtpParameters(const webrtc::RtpParameters& rtp_parameters) {
1388 if (rtp_parameters.encodings.size() != 1) {
1389 LOG(LS_ERROR)
1390 << "Attempted to set RtpParameters without exactly one encoding";
1391 return false;
1392 }
1393 if (rtp_parameters.encodings[0].ssrc != rtp_parameters_.encodings[0].ssrc) {
1394 LOG(LS_ERROR) << "Attempted to set RtpParameters with modified SSRC";
1395 return false;
1396 }
1397 return true;
1398 }
1399
1387 bool SetRtpParameters(const webrtc::RtpParameters& parameters) { 1400 bool SetRtpParameters(const webrtc::RtpParameters& parameters) {
1388 RTC_CHECK_EQ(1UL, parameters.encodings.size()); 1401 if (!ValidateRtpParameters(parameters)) {
1402 return false;
1403 }
1389 auto send_rate = ComputeSendBitrate(max_send_bitrate_bps_, 1404 auto send_rate = ComputeSendBitrate(max_send_bitrate_bps_,
1390 parameters.encodings[0].max_bitrate_bps, 1405 parameters.encodings[0].max_bitrate_bps,
1391 send_codec_spec_.codec_inst); 1406 send_codec_spec_.codec_inst);
1392 if (!send_rate) { 1407 if (!send_rate) {
1393 return false; 1408 return false;
1394 } 1409 }
1395 1410
1396 rtp_parameters_ = parameters; 1411 rtp_parameters_ = parameters;
1397 1412
1398 // parameters.encodings[0].encodings[0].max_bitrate_bps could have changed. 1413 // parameters.encodings[0].encodings[0].max_bitrate_bps could have changed.
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 for (const AudioCodec& codec : send_codecs_) { 1712 for (const AudioCodec& codec : send_codecs_) {
1698 rtp_params.codecs.push_back(codec.ToCodecParameters()); 1713 rtp_params.codecs.push_back(codec.ToCodecParameters());
1699 } 1714 }
1700 return rtp_params; 1715 return rtp_params;
1701 } 1716 }
1702 1717
1703 bool WebRtcVoiceMediaChannel::SetRtpSendParameters( 1718 bool WebRtcVoiceMediaChannel::SetRtpSendParameters(
1704 uint32_t ssrc, 1719 uint32_t ssrc,
1705 const webrtc::RtpParameters& parameters) { 1720 const webrtc::RtpParameters& parameters) {
1706 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1721 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1707 if (!ValidateRtpParameters(parameters)) {
1708 return false;
1709 }
1710 auto it = send_streams_.find(ssrc); 1722 auto it = send_streams_.find(ssrc);
1711 if (it == send_streams_.end()) { 1723 if (it == send_streams_.end()) {
1712 LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream " 1724 LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream "
1713 << "with ssrc " << ssrc << " which doesn't exist."; 1725 << "with ssrc " << ssrc << " which doesn't exist.";
1714 return false; 1726 return false;
1715 } 1727 }
1716 1728
1717 // TODO(deadbeef): Handle setting parameters with a list of codecs in a 1729 // TODO(deadbeef): Handle setting parameters with a list of codecs in a
1718 // different order (which should change the send codec). 1730 // different order (which should change the send codec).
1719 webrtc::RtpParameters current_parameters = GetRtpSendParameters(ssrc); 1731 webrtc::RtpParameters current_parameters = GetRtpSendParameters(ssrc);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1753 rtp_params.codecs.push_back(codec.ToCodecParameters()); 1765 rtp_params.codecs.push_back(codec.ToCodecParameters());
1754 } 1766 }
1755 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc); 1767 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc);
1756 return rtp_params; 1768 return rtp_params;
1757 } 1769 }
1758 1770
1759 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( 1771 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters(
1760 uint32_t ssrc, 1772 uint32_t ssrc,
1761 const webrtc::RtpParameters& parameters) { 1773 const webrtc::RtpParameters& parameters) {
1762 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1774 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1763 if (!ValidateRtpParameters(parameters)) {
1764 return false;
1765 }
1766 auto it = recv_streams_.find(ssrc); 1775 auto it = recv_streams_.find(ssrc);
1767 if (it == recv_streams_.end()) { 1776 if (it == recv_streams_.end()) {
1768 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream " 1777 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream "
1769 << "with ssrc " << ssrc << " which doesn't exist."; 1778 << "with ssrc " << ssrc << " which doesn't exist.";
1770 return false; 1779 return false;
1771 } 1780 }
1772 1781
1773 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc); 1782 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc);
1774 if (current_parameters != parameters) { 1783 if (current_parameters != parameters) {
1775 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently " 1784 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently "
1776 << "unsupported."; 1785 << "unsupported.";
1777 return false; 1786 return false;
1778 } 1787 }
1779 return true; 1788 return true;
1780 } 1789 }
1781 1790
1782 bool WebRtcVoiceMediaChannel::ValidateRtpParameters(
1783 const webrtc::RtpParameters& rtp_parameters) {
1784 if (rtp_parameters.encodings.size() != 1) {
1785 LOG(LS_ERROR)
1786 << "Attempted to set RtpParameters without exactly one encoding";
1787 return false;
1788 }
1789 return true;
1790 }
1791
1792 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) { 1791 bool WebRtcVoiceMediaChannel::SetOptions(const AudioOptions& options) {
1793 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1792 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1794 LOG(LS_INFO) << "Setting voice channel options: " 1793 LOG(LS_INFO) << "Setting voice channel options: "
1795 << options.ToString(); 1794 << options.ToString();
1796 1795
1797 // We retain all of the existing options, and apply the given ones 1796 // We retain all of the existing options, and apply the given ones
1798 // on top. This means there is no way to "clear" options such that 1797 // on top. This means there is no way to "clear" options such that
1799 // they go back to the engine default. 1798 // they go back to the engine default.
1800 options_.SetAll(options); 1799 options_.SetAll(options);
1801 if (!engine()->ApplyOptions(options_)) { 1800 if (!engine()->ApplyOptions(options_)) {
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
2662 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2661 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2663 const auto it = send_streams_.find(ssrc); 2662 const auto it = send_streams_.find(ssrc);
2664 if (it != send_streams_.end()) { 2663 if (it != send_streams_.end()) {
2665 return it->second->channel(); 2664 return it->second->channel();
2666 } 2665 }
2667 return -1; 2666 return -1;
2668 } 2667 }
2669 } // namespace cricket 2668 } // namespace cricket
2670 2669
2671 #endif // HAVE_WEBRTC_VOICE 2670 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698