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

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

Issue 2206223002: Removed calls to VoE::SetPlayout() from WebRTCVoiceEngine. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated comments in test. Created 4 years, 4 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 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1356 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1357 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1357 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1358 stream_->SetSink(std::move(sink)); 1358 stream_->SetSink(std::move(sink));
1359 } 1359 }
1360 1360
1361 void SetOutputVolume(double volume) { 1361 void SetOutputVolume(double volume) {
1362 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1362 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1363 stream_->SetGain(volume); 1363 stream_->SetGain(volume);
1364 } 1364 }
1365 1365
1366 void SetPlayout(bool playout) {
1367 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1368 RTC_DCHECK(stream_);
1369 if (playout) {
1370 LOG(LS_INFO) << "Starting playout for channel #" << channel();
1371 stream_->Start();
1372 } else {
1373 LOG(LS_INFO) << "Stopping playout for channel #" << channel();
1374 stream_->Stop();
1375 }
1376 }
1377
1366 private: 1378 private:
1367 void RecreateAudioReceiveStream( 1379 void RecreateAudioReceiveStream(
1368 uint32_t local_ssrc, 1380 uint32_t local_ssrc,
1369 bool use_transport_cc, 1381 bool use_transport_cc,
1370 bool use_nack, 1382 bool use_nack,
1371 const std::vector<webrtc::RtpExtension>& extensions) { 1383 const std::vector<webrtc::RtpExtension>& extensions) {
1372 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1384 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1373 if (stream_) { 1385 if (stream_) {
1374 call_->DestroyAudioReceiveStream(stream_); 1386 call_->DestroyAudioReceiveStream(stream_);
1375 stream_ = nullptr; 1387 stream_ = nullptr;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 } 1647 }
1636 if (new_codecs.empty()) { 1648 if (new_codecs.empty()) {
1637 // There are no new codecs to configure. Already configured codecs are 1649 // There are no new codecs to configure. Already configured codecs are
1638 // never removed. 1650 // never removed.
1639 return true; 1651 return true;
1640 } 1652 }
1641 1653
1642 if (playout_) { 1654 if (playout_) {
1643 // Receive codecs can not be changed while playing. So we temporarily 1655 // Receive codecs can not be changed while playing. So we temporarily
1644 // pause playout. 1656 // pause playout.
1645 PausePlayout(); 1657 ChangePlayout(false);
1646 } 1658 }
1647 1659
1648 bool result = true; 1660 bool result = true;
1649 for (const AudioCodec& codec : new_codecs) { 1661 for (const AudioCodec& codec : new_codecs) {
1650 webrtc::CodecInst voe_codec = {0}; 1662 webrtc::CodecInst voe_codec = {0};
1651 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) { 1663 if (WebRtcVoiceEngine::ToCodecInst(codec, &voe_codec)) {
1652 LOG(LS_INFO) << ToString(codec); 1664 LOG(LS_INFO) << ToString(codec);
1653 voe_codec.pltype = codec.id; 1665 voe_codec.pltype = codec.id;
1654 for (const auto& ch : recv_streams_) { 1666 for (const auto& ch : recv_streams_) {
1655 if (engine()->voe()->codec()->SetRecPayloadType( 1667 if (engine()->voe()->codec()->SetRecPayloadType(
1656 ch.second->channel(), voe_codec) == -1) { 1668 ch.second->channel(), voe_codec) == -1) {
1657 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(), 1669 LOG_RTCERR2(SetRecPayloadType, ch.second->channel(),
1658 ToString(voe_codec)); 1670 ToString(voe_codec));
1659 result = false; 1671 result = false;
1660 } 1672 }
1661 } 1673 }
1662 } else { 1674 } else {
1663 LOG(LS_WARNING) << "Unknown codec " << ToString(codec); 1675 LOG(LS_WARNING) << "Unknown codec " << ToString(codec);
1664 result = false; 1676 result = false;
1665 break; 1677 break;
1666 } 1678 }
1667 } 1679 }
1668 if (result) { 1680 if (result) {
1669 recv_codecs_ = codecs; 1681 recv_codecs_ = codecs;
1670 } 1682 }
1671 1683
1672 if (desired_playout_ && !playout_) { 1684 if (desired_playout_ && !playout_) {
1673 ResumePlayout(); 1685 ChangePlayout(desired_playout_);
1674 } 1686 }
1675 return result; 1687 return result;
1676 } 1688 }
1677 1689
1678 // Utility function called from SetSendParameters() to extract current send 1690 // Utility function called from SetSendParameters() to extract current send
1679 // codec settings from the given list of codecs (originally from SDP). Both send 1691 // codec settings from the given list of codecs (originally from SDP). Both send
1680 // and receive streams may be reconfigured based on the new settings. 1692 // and receive streams may be reconfigured based on the new settings.
1681 bool WebRtcVoiceMediaChannel::SetSendCodecs( 1693 bool WebRtcVoiceMediaChannel::SetSendCodecs(
1682 const std::vector<AudioCodec>& codecs) { 1694 const std::vector<AudioCodec>& codecs) {
1683 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1695 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 return true; 1930 return true;
1919 } 1931 }
1920 1932
1921 if (engine()->voe()->codec()->SetSendCodec(channel, send_codec) == -1) { 1933 if (engine()->voe()->codec()->SetSendCodec(channel, send_codec) == -1) {
1922 LOG_RTCERR2(SetSendCodec, channel, ToString(send_codec)); 1934 LOG_RTCERR2(SetSendCodec, channel, ToString(send_codec));
1923 return false; 1935 return false;
1924 } 1936 }
1925 return true; 1937 return true;
1926 } 1938 }
1927 1939
1928 bool WebRtcVoiceMediaChannel::SetPlayout(bool playout) { 1940 void WebRtcVoiceMediaChannel::SetPlayout(bool playout) {
1929 desired_playout_ = playout; 1941 desired_playout_ = playout;
1930 return ChangePlayout(desired_playout_); 1942 return ChangePlayout(desired_playout_);
1931 } 1943 }
1932 1944
1933 bool WebRtcVoiceMediaChannel::PausePlayout() { 1945 void WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
1934 return ChangePlayout(false);
1935 }
1936
1937 bool WebRtcVoiceMediaChannel::ResumePlayout() {
1938 return ChangePlayout(desired_playout_);
1939 }
1940
1941 bool WebRtcVoiceMediaChannel::ChangePlayout(bool playout) {
1942 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout"); 1946 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::ChangePlayout");
1943 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1947 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1944 if (playout_ == playout) { 1948 if (playout_ == playout) {
1945 return true; 1949 return;
1946 } 1950 }
1947 1951
1948 for (const auto& ch : recv_streams_) { 1952 for (const auto& kv : recv_streams_) {
1949 if (!SetPlayout(ch.second->channel(), playout)) { 1953 kv.second->SetPlayout(playout);
1950 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel "
1951 << ch.second->channel() << " failed";
1952 return false;
1953 }
1954 } 1954 }
1955 playout_ = playout; 1955 playout_ = playout;
1956 return true;
1957 } 1956 }
1958 1957
1959 void WebRtcVoiceMediaChannel::SetSend(bool send) { 1958 void WebRtcVoiceMediaChannel::SetSend(bool send) {
1960 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend"); 1959 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend");
1961 if (send_ == send) { 1960 if (send_ == send) {
1962 return; 1961 return;
1963 } 1962 }
1964 1963
1965 // Apply channel specific options, and initialize the ADM for recording (this 1964 // Apply channel specific options, and initialize the ADM for recording (this
1966 // may take time on some platforms, e.g. Android). 1965 // may take time on some platforms, e.g. Android).
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 << " is associated with channel #" << send_channel << "."; 2172 << " is associated with channel #" << send_channel << ".";
2174 } 2173 }
2175 2174
2176 recv_streams_.insert(std::make_pair( 2175 recv_streams_.insert(std::make_pair(
2177 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_, 2176 ssrc, new WebRtcAudioReceiveStream(channel, ssrc, receiver_reports_ssrc_,
2178 recv_transport_cc_enabled_, 2177 recv_transport_cc_enabled_,
2179 recv_nack_enabled_, 2178 recv_nack_enabled_,
2180 sp.sync_label, recv_rtp_extensions_, 2179 sp.sync_label, recv_rtp_extensions_,
2181 call_, this, 2180 call_, this,
2182 engine()->decoder_factory_))); 2181 engine()->decoder_factory_)));
2183 SetPlayout(channel, playout_); 2182 recv_streams_[ssrc]->SetPlayout(playout_);
2184 2183
2185 return true; 2184 return true;
2186 } 2185 }
2187 2186
2188 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) { 2187 bool WebRtcVoiceMediaChannel::RemoveRecvStream(uint32_t ssrc) {
2189 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream"); 2188 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveRecvStream");
2190 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2189 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2191 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc; 2190 LOG(LS_INFO) << "RemoveRecvStream: " << ssrc;
2192 2191
2193 const auto it = recv_streams_.find(ssrc); 2192 const auto it = recv_streams_.find(ssrc);
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2607 } 2606 }
2608 2607
2609 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { 2608 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const {
2610 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2609 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2611 const auto it = send_streams_.find(ssrc); 2610 const auto it = send_streams_.find(ssrc);
2612 if (it != send_streams_.end()) { 2611 if (it != send_streams_.end()) {
2613 return it->second->channel(); 2612 return it->second->channel();
2614 } 2613 }
2615 return -1; 2614 return -1;
2616 } 2615 }
2617
2618 bool WebRtcVoiceMediaChannel::SetPlayout(int channel, bool playout) {
2619 if (playout) {
2620 LOG(LS_INFO) << "Starting playout for channel #" << channel;
2621 if (engine()->voe()->base()->StartPlayout(channel) == -1) {
2622 LOG_RTCERR1(StartPlayout, channel);
2623 return false;
2624 }
2625 } else {
2626 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2627 engine()->voe()->base()->StopPlayout(channel);
2628 }
2629 return true;
2630 }
2631 } // namespace cricket 2616 } // namespace cricket
2632 2617
2633 #endif // HAVE_WEBRTC_VOICE 2618 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698