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

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

Issue 2806173002: Fix RtpReceiver.GetParameters when SSRCs aren't signaled. (Closed)
Patch Set: Changing behavior slightly in response to comment on https://github.com/w3c/webrtc-pc/issues/1116 Created 3 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 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 1748
1749 // Codecs are handled at the WebRtcVoiceMediaChannel level. 1749 // Codecs are handled at the WebRtcVoiceMediaChannel level.
1750 webrtc::RtpParameters reduced_params = parameters; 1750 webrtc::RtpParameters reduced_params = parameters;
1751 reduced_params.codecs.clear(); 1751 reduced_params.codecs.clear();
1752 return it->second->SetRtpParameters(reduced_params); 1752 return it->second->SetRtpParameters(reduced_params);
1753 } 1753 }
1754 1754
1755 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters( 1755 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters(
1756 uint32_t ssrc) const { 1756 uint32_t ssrc) const {
1757 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1757 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1758 auto it = recv_streams_.find(ssrc); 1758 webrtc::RtpParameters rtp_params;
1759 if (it == recv_streams_.end()) { 1759 // SSRC of 0 represents the default receive stream.
1760 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream " 1760 if (ssrc == 0) {
1761 << "with ssrc " << ssrc << " which doesn't exist."; 1761 if (!default_sink_) {
1762 return webrtc::RtpParameters(); 1762 LOG(LS_WARNING) << "Attempting to get RTP parameters for the default, "
1763 "unsignaled audio receive stream, but not yet "
1764 "configured to receive such a stream.";
1765 return rtp_params;
1766 }
1767 rtp_params.encodings.emplace_back();
1768 } else {
1769 auto it = recv_streams_.find(ssrc);
1770 if (it == recv_streams_.end()) {
1771 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream "
1772 << "with ssrc " << ssrc << " which doesn't exist.";
1773 return webrtc::RtpParameters();
1774 }
1775 rtp_params.encodings.emplace_back();
1776 // TODO(deadbeef): Return stream-specific parameters.
1777 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc);
1763 } 1778 }
1764 1779
1765 // TODO(deadbeef): Return stream-specific parameters.
1766 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding();
1767 for (const AudioCodec& codec : recv_codecs_) { 1780 for (const AudioCodec& codec : recv_codecs_) {
1768 rtp_params.codecs.push_back(codec.ToCodecParameters()); 1781 rtp_params.codecs.push_back(codec.ToCodecParameters());
1769 } 1782 }
1770 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc);
1771 return rtp_params; 1783 return rtp_params;
1772 } 1784 }
1773 1785
1774 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( 1786 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters(
1775 uint32_t ssrc, 1787 uint32_t ssrc,
1776 const webrtc::RtpParameters& parameters) { 1788 const webrtc::RtpParameters& parameters) {
1777 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1789 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1778 auto it = recv_streams_.find(ssrc); 1790 // SSRC of 0 represents the default receive stream.
1779 if (it == recv_streams_.end()) { 1791 if (ssrc == 0) {
1780 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream " 1792 if (!default_sink_) {
1781 << "with ssrc " << ssrc << " which doesn't exist."; 1793 LOG(LS_WARNING) << "Attempting to set RTP parameters for the default, "
1782 return false; 1794 "unsignaled audio receive stream, but not yet "
1795 "configured to receive such a stream.";
1796 return false;
1797 }
1798 } else {
1799 auto it = recv_streams_.find(ssrc);
1800 if (it == recv_streams_.end()) {
1801 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream "
1802 << "with ssrc " << ssrc << " which doesn't exist.";
1803 return false;
1804 }
1783 } 1805 }
1784 1806
1785 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc); 1807 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc);
1786 if (current_parameters != parameters) { 1808 if (current_parameters != parameters) {
1787 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently " 1809 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently "
1788 << "unsupported."; 1810 << "unsupported.";
1789 return false; 1811 return false;
1790 } 1812 }
1791 return true; 1813 return true;
1792 } 1814 }
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 int highest = 0; 2335 int highest = 0;
2314 for (const auto& ch : recv_streams_) { 2336 for (const auto& ch : recv_streams_) {
2315 highest = std::max(ch.second->GetOutputLevel(), highest); 2337 highest = std::max(ch.second->GetOutputLevel(), highest);
2316 } 2338 }
2317 return highest; 2339 return highest;
2318 } 2340 }
2319 2341
2320 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { 2342 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
2321 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2343 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2322 std::vector<uint32_t> ssrcs(1, ssrc); 2344 std::vector<uint32_t> ssrcs(1, ssrc);
2345 // SSRC of 0 represents the default receive stream.
2323 if (ssrc == 0) { 2346 if (ssrc == 0) {
2324 default_recv_volume_ = volume; 2347 default_recv_volume_ = volume;
2325 ssrcs = unsignaled_recv_ssrcs_; 2348 ssrcs = unsignaled_recv_ssrcs_;
2326 } 2349 }
2327 for (uint32_t ssrc : ssrcs) { 2350 for (uint32_t ssrc : ssrcs) {
2328 const auto it = recv_streams_.find(ssrc); 2351 const auto it = recv_streams_.find(ssrc);
2329 if (it == recv_streams_.end()) { 2352 if (it == recv_streams_.end()) {
2330 LOG(LS_WARNING) << "SetOutputVolume: no recv stream " << ssrc; 2353 LOG(LS_WARNING) << "SetOutputVolume: no recv stream " << ssrc;
2331 return false; 2354 return false;
2332 } 2355 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 ssrc); 2664 ssrc);
2642 if (it != unsignaled_recv_ssrcs_.end()) { 2665 if (it != unsignaled_recv_ssrcs_.end()) {
2643 unsignaled_recv_ssrcs_.erase(it); 2666 unsignaled_recv_ssrcs_.erase(it);
2644 return true; 2667 return true;
2645 } 2668 }
2646 return false; 2669 return false;
2647 } 2670 }
2648 } // namespace cricket 2671 } // namespace cricket
2649 2672
2650 #endif // HAVE_WEBRTC_VOICE 2673 #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