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

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: addressed comments Created 4 years, 8 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') | webrtc/test/mock_voe_channel_proxy.h » ('j') | 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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 return; 1071 return;
1072 } 1072 }
1073 LOG_RTCERR0(StopRtcEventLog); 1073 LOG_RTCERR0(StopRtcEventLog);
1074 } 1074 }
1075 1075
1076 int WebRtcVoiceEngine::CreateVoEChannel() { 1076 int WebRtcVoiceEngine::CreateVoEChannel() {
1077 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1077 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1078 return voe_wrapper_->base()->CreateChannel(voe_config_); 1078 return voe_wrapper_->base()->CreateChannel(voe_config_);
1079 } 1079 }
1080 1080
1081 webrtc::AudioDeviceModule* WebRtcVoiceEngine::adm() {
1082 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1083 RTC_DCHECK(adm_);
1084 return adm_;
1085 }
1086
1081 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1087 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
1082 : public AudioSource::Sink { 1088 : public AudioSource::Sink {
1083 public: 1089 public:
1084 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, 1090 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport,
1085 uint32_t ssrc, const std::string& c_name, 1091 uint32_t ssrc, const std::string& c_name,
1086 const std::vector<webrtc::RtpExtension>& extensions, 1092 const std::vector<webrtc::RtpExtension>& extensions,
1087 webrtc::Call* call) 1093 webrtc::Call* call)
1088 : voe_audio_transport_(voe_audio_transport), 1094 : voe_audio_transport_(voe_audio_transport),
1089 call_(call), 1095 call_(call),
1090 config_(nullptr) { 1096 config_(nullptr) {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 } 1798 }
1793 playout_ = playout; 1799 playout_ = playout;
1794 return true; 1800 return true;
1795 } 1801 }
1796 1802
1797 void WebRtcVoiceMediaChannel::SetSend(bool send) { 1803 void WebRtcVoiceMediaChannel::SetSend(bool send) {
1798 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend"); 1804 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetSend");
1799 if (send_ == send) { 1805 if (send_ == send) {
1800 return; 1806 return;
1801 } 1807 }
1808 send_ = send;
1802 1809
1803 // Apply channel specific options when channel is enabled for sending. 1810 // Apply channel specific options.
1804 if (send) { 1811 if (send_) {
1805 engine()->ApplyOptions(options_); 1812 engine()->ApplyOptions(options_);
1806 } 1813 }
1807 1814
1815 SetupRecording();
juberti2 2016/03/31 18:57:38 Won't this happen anyway as a result of SetSend?
the sun 2016/04/01 09:07:46 Well, it used to, but in the patch set you comment
1816
1808 // Change the settings on each send channel. 1817 // Change the settings on each send channel.
1809 for (auto& kv : send_streams_) { 1818 for (auto& kv : send_streams_) {
1810 kv.second->SetSend(send); 1819 kv.second->SetSend(send);
1811 } 1820 }
1812
1813 send_ = send;
1814 } 1821 }
1815 1822
1816 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, 1823 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
1817 bool enable, 1824 bool enable,
1818 const AudioOptions* options, 1825 const AudioOptions* options,
1819 AudioSource* source) { 1826 AudioSource* source) {
1820 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1827 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1821 // TODO(solenberg): The state change should be fully rolled back if any one of 1828 // TODO(solenberg): The state change should be fully rolled back if any one of
1822 // these calls fail. 1829 // these calls fail.
1823 if (!SetLocalSource(ssrc, source)) { 1830 if (!SetLocalSource(ssrc, source)) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { 1908 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) {
1902 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); 1909 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
1903 return false; 1910 return false;
1904 } 1911 }
1905 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); 1912 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
1906 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel 1913 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
1907 << " is associated with channel #" << channel << "."; 1914 << " is associated with channel #" << channel << ".";
1908 } 1915 }
1909 } 1916 }
1910 1917
1918 SetupRecording();
1919
1911 send_streams_[ssrc]->SetSend(send_); 1920 send_streams_[ssrc]->SetSend(send_);
1912 return true; 1921 return true;
1913 } 1922 }
1914 1923
1915 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { 1924 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
1916 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream"); 1925 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::RemoveSendStream");
1917 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1926 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1918 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; 1927 LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
1919 1928
1920 auto it = send_streams_.find(ssrc); 1929 auto it = send_streams_.find(ssrc);
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 if (engine()->voe()->base()->StartPlayout(channel) == -1) { 2498 if (engine()->voe()->base()->StartPlayout(channel) == -1) {
2490 LOG_RTCERR1(StartPlayout, channel); 2499 LOG_RTCERR1(StartPlayout, channel);
2491 return false; 2500 return false;
2492 } 2501 }
2493 } else { 2502 } else {
2494 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2503 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2495 engine()->voe()->base()->StopPlayout(channel); 2504 engine()->voe()->base()->StopPlayout(channel);
2496 } 2505 }
2497 return true; 2506 return true;
2498 } 2507 }
2508
2509 void WebRtcVoiceMediaChannel::SetupRecording() {
2510 if (send_ && !engine()->adm()->Recording()) {
2511 // InitRecording() is called as soon as we know we will be sending, as it
2512 // may take time on some platforms (e.g. Android).
2513 if (engine()->adm()->InitRecording() != 0) {
2514 LOG(LS_WARNING) << "Failed to initialize recording";
juberti2 2016/03/31 18:57:38 Shouldn't we propagate this error upwards instead
the sun 2016/04/01 09:07:46 We used to propagate it up, but eventually, in pc/
2515 return;
2516 }
2517 // StartRecording() is only called once we actually have a stream to send.
2518 if (!send_streams_.empty() && engine()->adm()->StartRecording() != 0) {
2519 LOG(LS_WARNING) << "Failed to start recording";
2520 return;
2521 }
2522 }
2523 }
2499 } // namespace cricket 2524 } // namespace cricket
2500 2525
2501 #endif // HAVE_WEBRTC_VOICE 2526 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/test/mock_voe_channel_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698