OLD | NEW |
---|---|
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 Loading... | |
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_) { |
the sun
2017/04/18 18:27:20
Checking !unsignaled_recv_ssrcs_.empty() should be
Taylor Brandstetter
2017/04/20 07:16:22
The reason I check default_sink_ instead is that I
| |
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 if (!unsignaled_recv_ssrcs_.empty()) { | |
1769 rtp_params.encodings[0].ssrc.emplace(unsignaled_recv_ssrcs_.back()); | |
1770 } | |
1771 } else { | |
1772 auto it = recv_streams_.find(ssrc); | |
1773 if (it == recv_streams_.end()) { | |
1774 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream " | |
1775 << "with ssrc " << ssrc << " which doesn't exist."; | |
1776 return webrtc::RtpParameters(); | |
1777 } | |
1778 rtp_params.encodings.emplace_back(); | |
1779 // TODO(deadbeef): Return stream-specific parameters. | |
1780 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc); | |
1763 } | 1781 } |
1764 | 1782 |
1765 // TODO(deadbeef): Return stream-specific parameters. | |
1766 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding(); | |
1767 for (const AudioCodec& codec : recv_codecs_) { | 1783 for (const AudioCodec& codec : recv_codecs_) { |
1768 rtp_params.codecs.push_back(codec.ToCodecParameters()); | 1784 rtp_params.codecs.push_back(codec.ToCodecParameters()); |
1769 } | 1785 } |
1770 rtp_params.encodings[0].ssrc = rtc::Optional<uint32_t>(ssrc); | |
1771 return rtp_params; | 1786 return rtp_params; |
1772 } | 1787 } |
1773 | 1788 |
1774 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( | 1789 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( |
1775 uint32_t ssrc, | 1790 uint32_t ssrc, |
1776 const webrtc::RtpParameters& parameters) { | 1791 const webrtc::RtpParameters& parameters) { |
1777 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1792 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1778 auto it = recv_streams_.find(ssrc); | 1793 // SSRC of 0 represents the default receive stream. |
1779 if (it == recv_streams_.end()) { | 1794 if (ssrc == 0) { |
1780 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream " | 1795 if (!default_sink_) { |
1781 << "with ssrc " << ssrc << " which doesn't exist."; | 1796 LOG(LS_WARNING) << "Attempting to set RTP parameters for the default, " |
1782 return false; | 1797 "unsignaled audio receive stream, but not yet " |
1798 "configured to receive such a stream."; | |
1799 return false; | |
1800 } | |
1801 } else { | |
1802 auto it = recv_streams_.find(ssrc); | |
1803 if (it == recv_streams_.end()) { | |
1804 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream " | |
1805 << "with ssrc " << ssrc << " which doesn't exist."; | |
1806 return false; | |
1807 } | |
1783 } | 1808 } |
1784 | 1809 |
1785 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc); | 1810 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc); |
1786 if (current_parameters != parameters) { | 1811 if (current_parameters != parameters) { |
1787 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently " | 1812 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently " |
1788 << "unsupported."; | 1813 << "unsupported."; |
1789 return false; | 1814 return false; |
1790 } | 1815 } |
1791 return true; | 1816 return true; |
1792 } | 1817 } |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2313 int highest = 0; | 2338 int highest = 0; |
2314 for (const auto& ch : recv_streams_) { | 2339 for (const auto& ch : recv_streams_) { |
2315 highest = std::max(ch.second->GetOutputLevel(), highest); | 2340 highest = std::max(ch.second->GetOutputLevel(), highest); |
2316 } | 2341 } |
2317 return highest; | 2342 return highest; |
2318 } | 2343 } |
2319 | 2344 |
2320 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { | 2345 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { |
2321 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2346 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2322 std::vector<uint32_t> ssrcs(1, ssrc); | 2347 std::vector<uint32_t> ssrcs(1, ssrc); |
2348 // SSRC of 0 represents the default receive stream. | |
2323 if (ssrc == 0) { | 2349 if (ssrc == 0) { |
2324 default_recv_volume_ = volume; | 2350 default_recv_volume_ = volume; |
2325 ssrcs = unsignaled_recv_ssrcs_; | 2351 ssrcs = unsignaled_recv_ssrcs_; |
2326 } | 2352 } |
2327 for (uint32_t ssrc : ssrcs) { | 2353 for (uint32_t ssrc : ssrcs) { |
2328 const auto it = recv_streams_.find(ssrc); | 2354 const auto it = recv_streams_.find(ssrc); |
2329 if (it == recv_streams_.end()) { | 2355 if (it == recv_streams_.end()) { |
2330 LOG(LS_WARNING) << "SetOutputVolume: no recv stream " << ssrc; | 2356 LOG(LS_WARNING) << "SetOutputVolume: no recv stream " << ssrc; |
2331 return false; | 2357 return false; |
2332 } | 2358 } |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2641 ssrc); | 2667 ssrc); |
2642 if (it != unsignaled_recv_ssrcs_.end()) { | 2668 if (it != unsignaled_recv_ssrcs_.end()) { |
2643 unsignaled_recv_ssrcs_.erase(it); | 2669 unsignaled_recv_ssrcs_.erase(it); |
2644 return true; | 2670 return true; |
2645 } | 2671 } |
2646 return false; | 2672 return false; |
2647 } | 2673 } |
2648 } // namespace cricket | 2674 } // namespace cricket |
2649 | 2675 |
2650 #endif // HAVE_WEBRTC_VOICE | 2676 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |