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

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

Issue 2409483003: Removed the legacy behavior of stopping playout when setting new receive codecs. (Closed)
Patch Set: Created 4 years, 2 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/webrtcvoiceengine.h ('k') | no next file » | 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 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 } else { 1698 } else {
1699 new_codecs.push_back(codec); 1699 new_codecs.push_back(codec);
1700 } 1700 }
1701 } 1701 }
1702 if (new_codecs.empty()) { 1702 if (new_codecs.empty()) {
1703 // There are no new codecs to configure. Already configured codecs are 1703 // There are no new codecs to configure. Already configured codecs are
1704 // never removed. 1704 // never removed.
1705 return true; 1705 return true;
1706 } 1706 }
1707 1707
1708 if (playout_) {
1709 // Receive codecs can not be changed while playing. So we temporarily
1710 // pause playout.
1711 ChangePlayout(false);
1712 }
1713
1714 bool result = true; 1708 bool result = true;
1715 for (const AudioCodec& codec : new_codecs) { 1709 for (const AudioCodec& codec : new_codecs) {
1716 webrtc::CodecInst voe_codec = {0}; 1710 webrtc::CodecInst voe_codec = {0};
1717 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) { 1711 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) {
1718 LOG(LS_INFO) << ToString(codec); 1712 LOG(LS_INFO) << ToString(codec);
1719 voe_codec.pltype = codec.id; 1713 voe_codec.pltype = codec.id;
1720 for (const auto& ch : recv_streams_) { 1714 for (const auto& ch : recv_streams_) {
1721 if (engine()->voe()->codec()->SetRecPayloadType( 1715 if (engine()->voe()->codec()->SetRecPayloadType(
1722 ch.second->channel(), voe_codec) == -1) { 1716 ch.second->channel(), voe_codec) == -1) {
1723 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(), 1717 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(),
1724 ToString(voe_codec)); 1718 ToString(voe_codec));
1725 result = false; 1719 result = false;
1726 } 1720 }
1727 } 1721 }
1728 } else { 1722 } else {
1729 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 1723 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
1730 result = false; 1724 result = false;
1731 break; 1725 break;
1732 } 1726 }
1733 } 1727 }
1734 if (result) { 1728 if (result) {
1735 recv_codecs_ = codecs; 1729 recv_codecs_ = codecs;
1736 } 1730 }
1737 1731
1738 if (desired_playout_ && !playout_) {
1739 ChangePlayout(desired_playout_);
1740 }
1741 return result; 1732 return result;
1742 } 1733 }
1743 1734
1744 // Utility function called from SetSendParameters() to extract current send 1735 // Utility function called from SetSendParameters() to extract current send
1745 // codec settings from the given list of codecs (originally from SDP). Both send 1736 // codec settings from the given list of codecs (originally from SDP). Both send
1746 // and receive streams may be reconfigured based on the new settings. 1737 // and receive streams may be reconfigured based on the new settings.
1747 bool WebRtcVoiceMediaChannel::SetSendCodecs( 1738 bool WebRtcVoiceMediaChannel::SetSendCodecs(
1748 const std::vector<AudioCodec>& codecs) { 1739 const std::vector<AudioCodec>& codecs) {
1749 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1740 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1750 // TODO(solenberg): Validate input - that payload types don't overlap, are 1741 // TODO(solenberg): Validate input - that payload types don't overlap, are
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 } 1976 }
1986 1977
1987 if (engine()->voe()->codec()->SetSendCodec(channel, send_codec) == -1) { 1978 if (engine()->voe()->codec()->SetSendCodec(channel, send_codec) == -1) {
1988 LOG_RTCERR2(SetSendCodec, channel, ToString(send_codec)); 1979 LOG_RTCERR2(SetSendCodec, channel, ToString(send_codec));
1989 return false; 1980 return false;
1990 } 1981 }
1991 return true; 1982 return true;
1992 } 1983 }
1993 1984
1994 void WebRtcVoiceMediaChannel::SetPlayout(bool playout) { 1985 void WebRtcVoiceMediaChannel::SetPlayout(bool playout) {
1995 desired_playout_ = playout; 1986 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetPlayout");
1996 return ChangePlayout(desired_playout_);
1997 }
1998
1999 void WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
2000 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout");
2001 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1987 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2002 if (playout_ == playout) { 1988 if (playout_ == playout) {
2003 return; 1989 return;
2004 } 1990 }
2005 1991
2006 for (const auto& kv : recv_streams_) { 1992 for (const auto& kv : recv_streams_) {
2007 kv.second->SetPlayout(playout); 1993 kv.second->SetPlayout(playout);
2008 } 1994 }
2009 playout_ = playout; 1995 playout_ = playout;
2010 } 1996 }
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2650 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2665 const auto it = send_streams_.find(ssrc); 2651 const auto it = send_streams_.find(ssrc);
2666 if (it != send_streams_.end()) { 2652 if (it != send_streams_.end()) {
2667 return it->second->channel(); 2653 return it->second->channel();
2668 } 2654 }
2669 return -1; 2655 return -1;
2670 } 2656 }
2671 } // namespace cricket 2657 } // namespace cricket
2672 2658
2673 #endif // HAVE_WEBRTC_VOICE 2659 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698