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

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

Issue 1741933002: Prevent a voice channel from sending data before a renderer is set. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Modifying copyright header to satisfy presubmit bot. 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 15 matching lines...) Expand all
26 #include "webrtc/base/base64.h" 26 #include "webrtc/base/base64.h"
27 #include "webrtc/base/byteorder.h" 27 #include "webrtc/base/byteorder.h"
28 #include "webrtc/base/common.h" 28 #include "webrtc/base/common.h"
29 #include "webrtc/base/helpers.h" 29 #include "webrtc/base/helpers.h"
30 #include "webrtc/base/logging.h" 30 #include "webrtc/base/logging.h"
31 #include "webrtc/base/stringencode.h" 31 #include "webrtc/base/stringencode.h"
32 #include "webrtc/base/stringutils.h" 32 #include "webrtc/base/stringutils.h"
33 #include "webrtc/call/rtc_event_log.h" 33 #include "webrtc/call/rtc_event_log.h"
34 #include "webrtc/common.h" 34 #include "webrtc/common.h"
35 #include "webrtc/media/base/audioframe.h" 35 #include "webrtc/media/base/audioframe.h"
36 #include "webrtc/media/base/audiorenderer.h" 36 #include "webrtc/media/base/audiosource.h"
37 #include "webrtc/media/base/mediaconstants.h" 37 #include "webrtc/media/base/mediaconstants.h"
38 #include "webrtc/media/base/streamparams.h" 38 #include "webrtc/media/base/streamparams.h"
39 #include "webrtc/media/engine/webrtcmediaengine.h" 39 #include "webrtc/media/engine/webrtcmediaengine.h"
40 #include "webrtc/media/engine/webrtcvoe.h" 40 #include "webrtc/media/engine/webrtcvoe.h"
41 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" 41 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
42 #include "webrtc/modules/audio_processing/include/audio_processing.h" 42 #include "webrtc/modules/audio_processing/include/audio_processing.h"
43 #include "webrtc/system_wrappers/include/field_trial.h" 43 #include "webrtc/system_wrappers/include/field_trial.h"
44 #include "webrtc/system_wrappers/include/trace.h" 44 #include "webrtc/system_wrappers/include/trace.h"
45 45
46 namespace cricket { 46 namespace cricket {
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 } 1131 }
1132 LOG_RTCERR0(StopRtcEventLog); 1132 LOG_RTCERR0(StopRtcEventLog);
1133 } 1133 }
1134 1134
1135 int WebRtcVoiceEngine::CreateVoEChannel() { 1135 int WebRtcVoiceEngine::CreateVoEChannel() {
1136 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1136 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1137 return voe_wrapper_->base()->CreateChannel(voe_config_); 1137 return voe_wrapper_->base()->CreateChannel(voe_config_);
1138 } 1138 }
1139 1139
1140 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1140 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
1141 : public AudioRenderer::Sink { 1141 : public AudioSource::Sink {
1142 public: 1142 public:
1143 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, 1143 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport,
1144 uint32_t ssrc, const std::string& c_name, 1144 uint32_t ssrc, const std::string& c_name,
1145 const std::vector<webrtc::RtpExtension>& extensions, 1145 const std::vector<webrtc::RtpExtension>& extensions,
1146 webrtc::Call* call) 1146 webrtc::Call* call)
1147 : voe_audio_transport_(voe_audio_transport), 1147 : voe_audio_transport_(voe_audio_transport),
1148 call_(call), 1148 call_(call),
1149 config_(nullptr) { 1149 config_(nullptr) {
1150 RTC_DCHECK_GE(ch, 0); 1150 RTC_DCHECK_GE(ch, 0);
1151 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore: 1151 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore:
1152 // RTC_DCHECK(voe_audio_transport); 1152 // RTC_DCHECK(voe_audio_transport);
1153 RTC_DCHECK(call); 1153 RTC_DCHECK(call);
1154 audio_capture_thread_checker_.DetachFromThread(); 1154 audio_capture_thread_checker_.DetachFromThread();
1155 config_.rtp.ssrc = ssrc; 1155 config_.rtp.ssrc = ssrc;
1156 config_.rtp.c_name = c_name; 1156 config_.rtp.c_name = c_name;
1157 config_.voe_channel_id = ch; 1157 config_.voe_channel_id = ch;
1158 RecreateAudioSendStream(extensions); 1158 RecreateAudioSendStream(extensions);
1159 } 1159 }
1160 1160
1161 ~WebRtcAudioSendStream() override { 1161 ~WebRtcAudioSendStream() override {
1162 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1162 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1163 Stop(); 1163 ClearSource();
1164 call_->DestroyAudioSendStream(stream_); 1164 call_->DestroyAudioSendStream(stream_);
1165 } 1165 }
1166 1166
1167 void RecreateAudioSendStream( 1167 void RecreateAudioSendStream(
1168 const std::vector<webrtc::RtpExtension>& extensions) { 1168 const std::vector<webrtc::RtpExtension>& extensions) {
1169 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1169 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1170 if (stream_) { 1170 if (stream_) {
1171 call_->DestroyAudioSendStream(stream_); 1171 call_->DestroyAudioSendStream(stream_);
1172 stream_ = nullptr; 1172 stream_ = nullptr;
1173 } 1173 }
1174 config_.rtp.extensions = extensions; 1174 config_.rtp.extensions = extensions;
1175 RTC_DCHECK(!stream_); 1175 RTC_DCHECK(!stream_);
1176 stream_ = call_->CreateAudioSendStream(config_); 1176 stream_ = call_->CreateAudioSendStream(config_);
1177 RTC_CHECK(stream_); 1177 RTC_CHECK(stream_);
1178 } 1178 }
1179 1179
1180 bool SendTelephoneEvent(int payload_type, uint8_t event, 1180 bool SendTelephoneEvent(int payload_type, uint8_t event,
1181 uint32_t duration_ms) { 1181 uint32_t duration_ms) {
1182 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1182 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1183 RTC_DCHECK(stream_); 1183 RTC_DCHECK(stream_);
1184 return stream_->SendTelephoneEvent(payload_type, event, duration_ms); 1184 return stream_->SendTelephoneEvent(payload_type, event, duration_ms);
1185 } 1185 }
1186 1186
1187 void SetSend(bool send) {
1188 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1189 send_ = send;
1190 UpdateSendState();
1191 }
1192
1187 webrtc::AudioSendStream::Stats GetStats() const { 1193 webrtc::AudioSendStream::Stats GetStats() const {
1188 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1194 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1189 RTC_DCHECK(stream_); 1195 RTC_DCHECK(stream_);
1190 return stream_->GetStats(); 1196 return stream_->GetStats();
1191 } 1197 }
1192 1198
1193 // Starts the rendering by setting a sink to the renderer to get data 1199 // Starts the sending by setting ourselves as a sink to the AudioSource to
1194 // callback. 1200 // get data callbacks.
1195 // This method is called on the libjingle worker thread. 1201 // This method is called on the libjingle worker thread.
1196 // TODO(xians): Make sure Start() is called only once. 1202 // TODO(xians): Make sure Start() is called only once.
1197 void Start(AudioRenderer* renderer) { 1203 void SetSource(AudioSource* source) {
1198 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1204 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1199 RTC_DCHECK(renderer); 1205 RTC_DCHECK(source);
1200 if (renderer_) { 1206 if (source_) {
1201 RTC_DCHECK(renderer_ == renderer); 1207 RTC_DCHECK(source_ == source);
1202 return; 1208 return;
1203 } 1209 }
1204 renderer->SetSink(this); 1210 source->SetSink(this);
1205 renderer_ = renderer; 1211 source_ = source;
1212 UpdateSendState();
1206 } 1213 }
1207 1214
1208 // Stops rendering by setting the sink of the renderer to nullptr. No data 1215 // Stops sending by setting the sink of the AudioSource to nullptr. No data
1209 // callback will be received after this method. 1216 // callback will be received after this method.
1210 // This method is called on the libjingle worker thread. 1217 // This method is called on the libjingle worker thread.
1211 void Stop() { 1218 void ClearSource() {
1212 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1219 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1213 if (renderer_) { 1220 if (source_) {
1214 renderer_->SetSink(nullptr); 1221 source_->SetSink(nullptr);
1215 renderer_ = nullptr; 1222 source_ = nullptr;
1216 } 1223 }
1224 UpdateSendState();
1217 } 1225 }
1218 1226
1219 // AudioRenderer::Sink implementation. 1227 // AudioSource::Sink implementation.
1220 // This method is called on the audio thread. 1228 // This method is called on the audio thread.
1221 void OnData(const void* audio_data, 1229 void OnData(const void* audio_data,
1222 int bits_per_sample, 1230 int bits_per_sample,
1223 int sample_rate, 1231 int sample_rate,
1224 size_t number_of_channels, 1232 size_t number_of_channels,
1225 size_t number_of_frames) override { 1233 size_t number_of_frames) override {
1226 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread()); 1234 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread());
1227 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); 1235 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread());
1228 RTC_DCHECK(voe_audio_transport_); 1236 RTC_DCHECK(voe_audio_transport_);
1229 voe_audio_transport_->OnData(config_.voe_channel_id, 1237 voe_audio_transport_->OnData(config_.voe_channel_id,
1230 audio_data, 1238 audio_data,
1231 bits_per_sample, 1239 bits_per_sample,
1232 sample_rate, 1240 sample_rate,
1233 number_of_channels, 1241 number_of_channels,
1234 number_of_frames); 1242 number_of_frames);
1235 } 1243 }
1236 1244
1237 // Callback from the |renderer_| when it is going away. In case Start() has 1245 // Callback from the |source_| when it is going away. In case Start() has
1238 // never been called, this callback won't be triggered. 1246 // never been called, this callback won't be triggered.
1239 void OnClose() override { 1247 void OnClose() override {
1240 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1248 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1241 // Set |renderer_| to nullptr to make sure no more callback will get into 1249 // Set |source_| to nullptr to make sure no more callback will get into
1242 // the renderer. 1250 // the source.
1243 renderer_ = nullptr; 1251 source_ = nullptr;
1252 UpdateSendState();
1244 } 1253 }
1245 1254
1246 // Accessor to the VoE channel ID. 1255 // Accessor to the VoE channel ID.
1247 int channel() const { 1256 int channel() const {
1248 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1257 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1249 return config_.voe_channel_id; 1258 return config_.voe_channel_id;
1250 } 1259 }
1251 1260
1252 private: 1261 private:
1262 void UpdateSendState() {
1263 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1264 RTC_DCHECK(stream_);
1265 if (send_ && source_ != nullptr) {
1266 stream_->Start();
1267 } else { // !send || source_ = nullptr
1268 stream_->Stop();
1269 }
1270 }
1271
1253 rtc::ThreadChecker worker_thread_checker_; 1272 rtc::ThreadChecker worker_thread_checker_;
1254 rtc::ThreadChecker audio_capture_thread_checker_; 1273 rtc::ThreadChecker audio_capture_thread_checker_;
1255 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; 1274 webrtc::AudioTransport* const voe_audio_transport_ = nullptr;
1256 webrtc::Call* call_ = nullptr; 1275 webrtc::Call* call_ = nullptr;
1257 webrtc::AudioSendStream::Config config_; 1276 webrtc::AudioSendStream::Config config_;
1258 // The stream is owned by WebRtcAudioSendStream and may be reallocated if 1277 // The stream is owned by WebRtcAudioSendStream and may be reallocated if
1259 // configuration changes. 1278 // configuration changes.
1260 webrtc::AudioSendStream* stream_ = nullptr; 1279 webrtc::AudioSendStream* stream_ = nullptr;
1261 1280
1262 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. 1281 // Raw pointer to AudioSource owned by LocalAudioTrackHandler.
1263 // PeerConnection will make sure invalidating the pointer before the object 1282 // PeerConnection will make sure invalidating the pointer before the object
1264 // goes away. 1283 // goes away.
1265 AudioRenderer* renderer_ = nullptr; 1284 AudioSource* source_ = nullptr;
1285 bool send_ = false;
1266 1286
1267 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); 1287 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream);
1268 }; 1288 };
1269 1289
1270 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { 1290 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
1271 public: 1291 public:
1272 WebRtcAudioReceiveStream(int ch, 1292 WebRtcAudioReceiveStream(int ch,
1273 uint32_t remote_ssrc, 1293 uint32_t remote_ssrc,
1274 uint32_t local_ssrc, 1294 uint32_t local_ssrc,
1275 bool use_transport_cc, 1295 bool use_transport_cc,
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 if (!SetPlayout(ch.second->channel(), playout)) { 1840 if (!SetPlayout(ch.second->channel(), playout)) {
1821 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " 1841 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel "
1822 << ch.second->channel() << " failed"; 1842 << ch.second->channel() << " failed";
1823 return false; 1843 return false;
1824 } 1844 }
1825 } 1845 }
1826 playout_ = playout; 1846 playout_ = playout;
1827 return true; 1847 return true;
1828 } 1848 }
1829 1849
1830 bool WebRtcVoiceMediaChannel::SetSend(SendFlags send) { 1850 void WebRtcVoiceMediaChannel::SetSend(bool send) {
1831 desired_send_ = send;
1832 if (!send_streams_.empty()) {
1833 return ChangeSend(desired_send_);
1834 }
1835 return true;
1836 }
1837
1838 bool WebRtcVoiceMediaChannel::PauseSend() {
1839 return ChangeSend(SEND_NOTHING);
1840 }
1841
1842 bool WebRtcVoiceMediaChannel::ResumeSend() {
1843 return ChangeSend(desired_send_);
1844 }
1845
1846 bool WebRtcVoiceMediaChannel::ChangeSend(SendFlags send) {
1847 if (send_ == send) { 1851 if (send_ == send) {
1848 return true; 1852 return;
1849 } 1853 }
1850 1854
1851 // Apply channel specific options when channel is enabled for sending. 1855 // Apply channel specific options when channel is enabled for sending.
1852 if (send == SEND_MICROPHONE) { 1856 if (send) {
1853 engine()->ApplyOptions(options_); 1857 engine()->ApplyOptions(options_);
1854 } 1858 }
1855 1859
1856 // Change the settings on each send channel. 1860 // Change the settings on each send channel.
1857 for (const auto& ch : send_streams_) { 1861 for (auto& kv : send_streams_) {
1858 if (!ChangeSend(ch.second->channel(), send)) { 1862 kv.second->SetSend(send);
1859 return false;
1860 }
1861 } 1863 }
1862 1864
1863 send_ = send; 1865 send_ = send;
1864 return true;
1865 }
1866
1867 bool WebRtcVoiceMediaChannel::ChangeSend(int channel, SendFlags send) {
1868 if (send == SEND_MICROPHONE) {
1869 if (engine()->voe()->base()->StartSend(channel) == -1) {
1870 LOG_RTCERR1(StartSend, channel);
1871 return false;
1872 }
1873 } else { // SEND_NOTHING
1874 RTC_DCHECK(send == SEND_NOTHING);
1875 if (engine()->voe()->base()->StopSend(channel) == -1) {
1876 LOG_RTCERR1(StopSend, channel);
1877 return false;
1878 }
1879 }
1880
1881 return true;
1882 } 1866 }
1883 1867
1884 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, 1868 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
1885 bool enable, 1869 bool enable,
1886 const AudioOptions* options, 1870 const AudioOptions* options,
1887 AudioRenderer* renderer) { 1871 AudioSource* source) {
1888 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1872 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1889 // TODO(solenberg): The state change should be fully rolled back if any one of 1873 // TODO(solenberg): The state change should be fully rolled back if any one of
1890 // these calls fail. 1874 // these calls fail.
1891 if (!SetLocalRenderer(ssrc, renderer)) { 1875 if (!SetLocalSource(ssrc, source)) {
1892 return false; 1876 return false;
1893 } 1877 }
1894 if (!MuteStream(ssrc, !enable)) { 1878 if (!MuteStream(ssrc, !enable)) {
1895 return false; 1879 return false;
1896 } 1880 }
1897 if (enable && options) { 1881 if (enable && options) {
1898 return SetOptions(*options); 1882 return SetOptions(*options);
1899 } 1883 }
1900 return true; 1884 return true;
1901 } 1885 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { 1952 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) {
1969 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); 1953 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
1970 return false; 1954 return false;
1971 } 1955 }
1972 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); 1956 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
1973 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel 1957 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
1974 << " is associated with channel #" << channel << "."; 1958 << " is associated with channel #" << channel << ".";
1975 } 1959 }
1976 } 1960 }
1977 1961
1978 return ChangeSend(channel, desired_send_); 1962 send_streams_[ssrc]->SetSend(send_);
1963 return true;
1979 } 1964 }
1980 1965
1981 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { 1966 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
1982 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1967 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1983 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; 1968 LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
1984 1969
1985 auto it = send_streams_.find(ssrc); 1970 auto it = send_streams_.find(ssrc);
1986 if (it == send_streams_.end()) { 1971 if (it == send_streams_.end()) {
1987 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc 1972 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
1988 << " which doesn't exist."; 1973 << " which doesn't exist.";
1989 return false; 1974 return false;
1990 } 1975 }
1991 1976
1992 int channel = it->second->channel(); 1977 it->second->SetSend(false);
1993 ChangeSend(channel, SEND_NOTHING);
1994 1978
1995 // Clean up and delete the send stream+channel. 1979 // Clean up and delete the send stream+channel.
1980 int channel = it->second->channel();
1996 LOG(LS_INFO) << "Removing audio send stream " << ssrc 1981 LOG(LS_INFO) << "Removing audio send stream " << ssrc
1997 << " with VoiceEngine channel #" << channel << "."; 1982 << " with VoiceEngine channel #" << channel << ".";
1998 delete it->second; 1983 delete it->second;
1999 send_streams_.erase(it); 1984 send_streams_.erase(it);
2000 if (!DeleteVoEChannel(channel)) { 1985 if (!DeleteVoEChannel(channel)) {
2001 return false; 1986 return false;
2002 } 1987 }
2003 if (send_streams_.empty()) { 1988 if (send_streams_.empty()) {
2004 ChangeSend(SEND_NOTHING); 1989 SetSend(false);
2005 } 1990 }
2006 return true; 1991 return true;
2007 } 1992 }
2008 1993
2009 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { 1994 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
2010 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1995 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2011 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); 1996 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString();
2012 1997
2013 if (!ValidateStreamParams(sp)) { 1998 if (!ValidateStreamParams(sp)) {
2014 return false; 1999 return false;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 2088
2104 // Clean up and delete the receive stream+channel. 2089 // Clean up and delete the receive stream+channel.
2105 LOG(LS_INFO) << "Removing audio receive stream " << ssrc 2090 LOG(LS_INFO) << "Removing audio receive stream " << ssrc
2106 << " with VoiceEngine channel #" << channel << "."; 2091 << " with VoiceEngine channel #" << channel << ".";
2107 it->second->SetRawAudioSink(nullptr); 2092 it->second->SetRawAudioSink(nullptr);
2108 delete it->second; 2093 delete it->second;
2109 recv_streams_.erase(it); 2094 recv_streams_.erase(it);
2110 return DeleteVoEChannel(channel); 2095 return DeleteVoEChannel(channel);
2111 } 2096 }
2112 2097
2113 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, 2098 bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc,
2114 AudioRenderer* renderer) { 2099 AudioSource* source) {
2115 auto it = send_streams_.find(ssrc); 2100 auto it = send_streams_.find(ssrc);
2116 if (it == send_streams_.end()) { 2101 if (it == send_streams_.end()) {
2117 if (renderer) { 2102 if (source) {
2118 // Return an error if trying to set a valid renderer with an invalid ssrc. 2103 // Return an error if trying to set a valid source with an invalid ssrc.
2119 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; 2104 LOG(LS_ERROR) << "SetLocalSource failed with ssrc " << ssrc;
2120 return false; 2105 return false;
2121 } 2106 }
2122 2107
2123 // The channel likely has gone away, do nothing. 2108 // The channel likely has gone away, do nothing.
2124 return true; 2109 return true;
2125 } 2110 }
2126 2111
2127 if (renderer) { 2112 if (source) {
2128 it->second->Start(renderer); 2113 it->second->SetSource(source);
2129 } else { 2114 } else {
2130 it->second->Stop(); 2115 it->second->ClearSource();
2131 } 2116 }
2132 2117
2133 return true; 2118 return true;
2134 } 2119 }
2135 2120
2136 bool WebRtcVoiceMediaChannel::GetActiveStreams( 2121 bool WebRtcVoiceMediaChannel::GetActiveStreams(
2137 AudioInfo::StreamList* actives) { 2122 AudioInfo::StreamList* actives) {
2138 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2123 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2139 actives->clear(); 2124 actives->clear();
2140 for (const auto& ch : recv_streams_) { 2125 for (const auto& ch : recv_streams_) {
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 sinfo.codec_name = stats.codec_name; 2423 sinfo.codec_name = stats.codec_name;
2439 sinfo.ext_seqnum = stats.ext_seqnum; 2424 sinfo.ext_seqnum = stats.ext_seqnum;
2440 sinfo.jitter_ms = stats.jitter_ms; 2425 sinfo.jitter_ms = stats.jitter_ms;
2441 sinfo.rtt_ms = stats.rtt_ms; 2426 sinfo.rtt_ms = stats.rtt_ms;
2442 sinfo.audio_level = stats.audio_level; 2427 sinfo.audio_level = stats.audio_level;
2443 sinfo.aec_quality_min = stats.aec_quality_min; 2428 sinfo.aec_quality_min = stats.aec_quality_min;
2444 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms; 2429 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms;
2445 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms; 2430 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms;
2446 sinfo.echo_return_loss = stats.echo_return_loss; 2431 sinfo.echo_return_loss = stats.echo_return_loss;
2447 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement; 2432 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement;
2448 sinfo.typing_noise_detected = 2433 sinfo.typing_noise_detected = (send_ ? stats.typing_noise_detected : false);
2449 (send_ == SEND_NOTHING ? false : stats.typing_noise_detected);
2450 info->senders.push_back(sinfo); 2434 info->senders.push_back(sinfo);
2451 } 2435 }
2452 2436
2453 // Get SSRC and stats for each receiver. 2437 // Get SSRC and stats for each receiver.
2454 RTC_DCHECK(info->receivers.size() == 0); 2438 RTC_DCHECK(info->receivers.size() == 0);
2455 for (const auto& stream : recv_streams_) { 2439 for (const auto& stream : recv_streams_) {
2456 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); 2440 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats();
2457 VoiceReceiverInfo rinfo; 2441 VoiceReceiverInfo rinfo;
2458 rinfo.add_ssrc(stats.remote_ssrc); 2442 rinfo.add_ssrc(stats.remote_ssrc);
2459 rinfo.bytes_rcvd = stats.bytes_rcvd; 2443 rinfo.bytes_rcvd = stats.bytes_rcvd;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 } 2526 }
2543 } else { 2527 } else {
2544 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2528 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2545 engine()->voe()->base()->StopPlayout(channel); 2529 engine()->voe()->base()->StopPlayout(channel);
2546 } 2530 }
2547 return true; 2531 return true;
2548 } 2532 }
2549 } // namespace cricket 2533 } // namespace cricket
2550 2534
2551 #endif // HAVE_WEBRTC_VOICE 2535 #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