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

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

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