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

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

Issue 1827263002: Early initialize recording on the ADM from WebRtcVoiceMediaChannel. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: set upstream to 1830213002 Created 4 years, 9 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 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 return; 1104 return;
1105 } 1105 }
1106 LOG_RTCERR0(StopRtcEventLog); 1106 LOG_RTCERR0(StopRtcEventLog);
1107 } 1107 }
1108 1108
1109 int WebRtcVoiceEngine::CreateVoEChannel() { 1109 int WebRtcVoiceEngine::CreateVoEChannel() {
1110 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1110 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1111 return voe_wrapper_->base()->CreateChannel(voe_config_); 1111 return voe_wrapper_->base()->CreateChannel(voe_config_);
1112 } 1112 }
1113 1113
1114 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
1115 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1116 RTC_DCHECK(adm_);
1117 return adm_;
1118 }
1119
1114 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1120 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
1115 : public AudioSource::Sink { 1121 : public AudioSource::Sink {
1116 public: 1122 public:
1117 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, 1123 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport,
1118 uint32_t ssrc, const std::string& c_name, 1124 uint32_t ssrc, const std::string& c_name,
1119 const std::vector<webrtc::RtpExtension>& extensions, 1125 const std::vector<webrtc::RtpExtension>& extensions,
1120 webrtc::Call* call) 1126 webrtc::Call* call)
1121 : voe_audio_transport_(voe_audio_transport), 1127 : voe_audio_transport_(voe_audio_transport),
1122 call_(call), 1128 call_(call),
1123 config_(nullptr) { 1129 config_(nullptr) {
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 playout_ = playout; 1832 playout_ = playout;
1827 return true; 1833 return true;
1828 } 1834 }
1829 1835
1830 void WebRtcVoiceMediaChannel::SetSend(bool send) { 1836 void WebRtcVoiceMediaChannel::SetSend(bool send) {
1831 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend"); 1837 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend");
1832 if (send_ == send) { 1838 if (send_ == send) {
1833 return; 1839 return;
1834 } 1840 }
1835 1841
1836 // Apply channel specific options when channel is enabled for sending. 1842 // Apply channel specific options, and initialize ADM for recording, when
1843 // channel is enabled for sending.
1837 if (send) { 1844 if (send) {
1838 engine()->ApplyOptions(options_); 1845 engine()->ApplyOptions(options_);
1846 SetupRecording();
1839 } 1847 }
1840 1848
1841 // Change the settings on each send channel. 1849 // Change the settings on each send channel.
1842 for (auto& kv : send_streams_) { 1850 for (auto& kv : send_streams_) {
1843 kv.second->SetSend(send); 1851 kv.second->SetSend(send);
1844 } 1852 }
1845 1853
1846 send_ = send; 1854 send_ = send;
1847 } 1855 }
1848 1856
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { 1942 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) {
1935 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); 1943 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
1936 return false; 1944 return false;
1937 } 1945 }
1938 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); 1946 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
1939 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel 1947 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
1940 << " is associated with channel #" << channel << "."; 1948 << " is associated with channel #" << channel << ".";
1941 } 1949 }
1942 } 1950 }
1943 1951
1952 // Initialize ADM for recording.
1953 if (send_) {
1954 SetupRecording();
1955 }
1944 send_streams_[ssrc]->SetSend(send_); 1956 send_streams_[ssrc]->SetSend(send_);
1945 return true; 1957 return true;
1946 } 1958 }
1947 1959
1948 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { 1960 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
1949 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream"); 1961 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream");
1950 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1962 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1951 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; 1963 LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
1952 1964
1953 auto it = send_streams_.find(ssrc); 1965 auto it = send_streams_.find(ssrc);
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 if (engine()->voe()->base()->StartPlayout(channel) == -1) { 2527 if (engine()->voe()->base()->StartPlayout(channel) == -1) {
2516 LOG_RTCERR1(StartPlayout, channel); 2528 LOG_RTCERR1(StartPlayout, channel);
2517 return false; 2529 return false;
2518 } 2530 }
2519 } else { 2531 } else {
2520 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2532 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2521 engine()->voe()->base()->StopPlayout(channel); 2533 engine()->voe()->base()->StopPlayout(channel);
2522 } 2534 }
2523 return true; 2535 return true;
2524 } 2536 }
2537
2538 void WebRtcVoiceMediaChannel::SetupRecording() {
Taylor Brandstetter 2016/03/29 01:05:37 Maybe add a comment explaining that this is done a
the sun 2016/03/31 10:49:47 Done.
2539 if (engine()->adm()->InitRecording() != 0) {
2540 LOG(LS_WARNING) << "Foo";
2541 return;
2542 }
2543 if (!send_streams_.empty()) {
2544 if (engine()->adm()->StartRecording() != 0) {
Taylor Brandstetter 2016/03/29 01:05:37 It's really only "InitRecording" that was slow on
the sun 2016/03/31 10:49:47 Note that StartRecording() is only called once we
Taylor Brandstetter 2016/03/31 18:11:25 But after my recent change, a stream won't call "S
the sun 2016/04/01 09:07:46 Ah, thanks for explaining. I decided to leave the
2545 LOG(LS_WARNING) << "Bar";
2546 }
2547 }
2548 }
2525 } // namespace cricket 2549 } // namespace cricket
2526 2550
2527 #endif // HAVE_WEBRTC_VOICE 2551 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698