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

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: Fixing patch conflict. 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 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 } 1129 }
1130 LOG_RTCERR0(StopRtcEventLog); 1130 LOG_RTCERR0(StopRtcEventLog);
1131 } 1131 }
1132 1132
1133 int WebRtcVoiceEngine::CreateVoEChannel() { 1133 int WebRtcVoiceEngine::CreateVoEChannel() {
1134 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1134 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1135 return voe_wrapper_->base()->CreateChannel(voe_config_); 1135 return voe_wrapper_->base()->CreateChannel(voe_config_);
1136 } 1136 }
1137 1137
1138 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream 1138 class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
1139 : public AudioRenderer::Sink { 1139 : public AudioSource::Sink {
1140 public: 1140 public:
1141 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport, 1141 WebRtcAudioSendStream(int ch, webrtc::AudioTransport* voe_audio_transport,
1142 uint32_t ssrc, const std::string& c_name, 1142 uint32_t ssrc, const std::string& c_name,
1143 const std::vector<webrtc::RtpExtension>& extensions, 1143 const std::vector<webrtc::RtpExtension>& extensions,
1144 webrtc::Call* call) 1144 webrtc::Call* call)
1145 : voe_audio_transport_(voe_audio_transport), 1145 : voe_audio_transport_(voe_audio_transport),
1146 call_(call), 1146 call_(call),
1147 config_(nullptr) { 1147 config_(nullptr) {
1148 RTC_DCHECK_GE(ch, 0); 1148 RTC_DCHECK_GE(ch, 0);
1149 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore: 1149 // TODO(solenberg): Once we're not using FakeWebRtcVoiceEngine anymore:
1150 // RTC_DCHECK(voe_audio_transport); 1150 // RTC_DCHECK(voe_audio_transport);
1151 RTC_DCHECK(call); 1151 RTC_DCHECK(call);
1152 audio_capture_thread_checker_.DetachFromThread(); 1152 audio_capture_thread_checker_.DetachFromThread();
1153 config_.rtp.ssrc = ssrc; 1153 config_.rtp.ssrc = ssrc;
1154 config_.rtp.c_name = c_name; 1154 config_.rtp.c_name = c_name;
1155 config_.voe_channel_id = ch; 1155 config_.voe_channel_id = ch;
1156 RecreateAudioSendStream(extensions); 1156 RecreateAudioSendStream(extensions);
1157 } 1157 }
1158 1158
1159 ~WebRtcAudioSendStream() override { 1159 ~WebRtcAudioSendStream() override {
1160 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1160 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1161 Stop(); 1161 ClearSource();
1162 call_->DestroyAudioSendStream(stream_); 1162 call_->DestroyAudioSendStream(stream_);
1163 } 1163 }
1164 1164
1165 void RecreateAudioSendStream( 1165 void RecreateAudioSendStream(
1166 const std::vector<webrtc::RtpExtension>& extensions) { 1166 const std::vector<webrtc::RtpExtension>& extensions) {
1167 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1167 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1168 if (stream_) { 1168 if (stream_) {
1169 call_->DestroyAudioSendStream(stream_); 1169 call_->DestroyAudioSendStream(stream_);
1170 stream_ = nullptr; 1170 stream_ = nullptr;
1171 } 1171 }
1172 config_.rtp.extensions = extensions; 1172 config_.rtp.extensions = extensions;
1173 RTC_DCHECK(!stream_); 1173 RTC_DCHECK(!stream_);
1174 stream_ = call_->CreateAudioSendStream(config_); 1174 stream_ = call_->CreateAudioSendStream(config_);
1175 RTC_CHECK(stream_); 1175 RTC_CHECK(stream_);
1176 } 1176 }
1177 1177
1178 bool SendTelephoneEvent(int payload_type, uint8_t event, 1178 bool SendTelephoneEvent(int payload_type, uint8_t event,
1179 uint32_t duration_ms) { 1179 uint32_t duration_ms) {
1180 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1180 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1181 RTC_DCHECK(stream_); 1181 RTC_DCHECK(stream_);
1182 return stream_->SendTelephoneEvent(payload_type, event, duration_ms); 1182 return stream_->SendTelephoneEvent(payload_type, event, duration_ms);
1183 } 1183 }
1184 1184
1185 webrtc::AudioSendStream::Stats GetStats() const { 1185 webrtc::AudioSendStream::Stats GetStats() const {
1186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1187 RTC_DCHECK(stream_); 1187 RTC_DCHECK(stream_);
1188 return stream_->GetStats(); 1188 return stream_->GetStats();
1189 } 1189 }
1190 1190
1191 // Starts the rendering by setting a sink to the renderer to get data 1191 bool HasSource() const {
1192 // callback. 1192 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1193 return source_ != nullptr;
1194 }
1195
1196 // Starts the sending by setting ourselves as a sink to the AudioSource to
1197 // get data callbacks.
1193 // This method is called on the libjingle worker thread. 1198 // This method is called on the libjingle worker thread.
1194 // TODO(xians): Make sure Start() is called only once. 1199 // TODO(xians): Make sure Start() is called only once.
1195 void Start(AudioRenderer* renderer) { 1200 void SetSource(AudioSource* source) {
1196 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1201 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1197 RTC_DCHECK(renderer); 1202 RTC_DCHECK(source);
1198 if (renderer_) { 1203 if (source_) {
1199 RTC_DCHECK(renderer_ == renderer); 1204 RTC_DCHECK(source_ == source);
1200 return; 1205 return;
1201 } 1206 }
1202 renderer->SetSink(this); 1207 source->SetSink(this);
1203 renderer_ = renderer; 1208 source_ = source;
1204 } 1209 }
1205 1210
1206 // Stops rendering by setting the sink of the renderer to nullptr. No data 1211 // Stops sending by setting the sink of the AudioSource to nullptr. No data
1207 // callback will be received after this method. 1212 // callback will be received after this method.
1208 // This method is called on the libjingle worker thread. 1213 // This method is called on the libjingle worker thread.
1209 void Stop() { 1214 void ClearSource() {
1210 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1215 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1211 if (renderer_) { 1216 if (source_) {
1212 renderer_->SetSink(nullptr); 1217 source_->SetSink(nullptr);
1213 renderer_ = nullptr; 1218 source_ = nullptr;
1214 } 1219 }
1215 } 1220 }
1216 1221
1217 // AudioRenderer::Sink implementation. 1222 // AudioSource::Sink implementation.
1218 // This method is called on the audio thread. 1223 // This method is called on the audio thread.
1219 void OnData(const void* audio_data, 1224 void OnData(const void* audio_data,
1220 int bits_per_sample, 1225 int bits_per_sample,
1221 int sample_rate, 1226 int sample_rate,
1222 size_t number_of_channels, 1227 size_t number_of_channels,
1223 size_t number_of_frames) override { 1228 size_t number_of_frames) override {
1224 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread()); 1229 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread());
1225 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); 1230 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread());
1226 RTC_DCHECK(voe_audio_transport_); 1231 RTC_DCHECK(voe_audio_transport_);
1227 voe_audio_transport_->OnData(config_.voe_channel_id, 1232 voe_audio_transport_->OnData(config_.voe_channel_id,
1228 audio_data, 1233 audio_data,
1229 bits_per_sample, 1234 bits_per_sample,
1230 sample_rate, 1235 sample_rate,
1231 number_of_channels, 1236 number_of_channels,
1232 number_of_frames); 1237 number_of_frames);
1233 } 1238 }
1234 1239
1235 // Callback from the |renderer_| when it is going away. In case Start() has 1240 // Callback from the |source_| when it is going away. In case Start() has
1236 // never been called, this callback won't be triggered. 1241 // never been called, this callback won't be triggered.
1237 void OnClose() override { 1242 void OnClose() override {
1238 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1243 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1239 // Set |renderer_| to nullptr to make sure no more callback will get into 1244 // Set |source_| to nullptr to make sure no more callback will get into
1240 // the renderer. 1245 // the source.
1241 renderer_ = nullptr; 1246 source_ = nullptr;
1242 } 1247 }
1243 1248
1244 // Accessor to the VoE channel ID. 1249 // Accessor to the VoE channel ID.
1245 int channel() const { 1250 int channel() const {
1246 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1251 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1247 return config_.voe_channel_id; 1252 return config_.voe_channel_id;
1248 } 1253 }
1249 1254
1250 private: 1255 private:
1251 rtc::ThreadChecker worker_thread_checker_; 1256 rtc::ThreadChecker worker_thread_checker_;
1252 rtc::ThreadChecker audio_capture_thread_checker_; 1257 rtc::ThreadChecker audio_capture_thread_checker_;
1253 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; 1258 webrtc::AudioTransport* const voe_audio_transport_ = nullptr;
1254 webrtc::Call* call_ = nullptr; 1259 webrtc::Call* call_ = nullptr;
1255 webrtc::AudioSendStream::Config config_; 1260 webrtc::AudioSendStream::Config config_;
1256 // The stream is owned by WebRtcAudioSendStream and may be reallocated if 1261 // The stream is owned by WebRtcAudioSendStream and may be reallocated if
1257 // configuration changes. 1262 // configuration changes.
1258 webrtc::AudioSendStream* stream_ = nullptr; 1263 webrtc::AudioSendStream* stream_ = nullptr;
1259 1264
1260 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. 1265 // Raw pointer to AudioSource owned by LocalAudioTrackHandler.
1261 // PeerConnection will make sure invalidating the pointer before the object 1266 // PeerConnection will make sure invalidating the pointer before the object
1262 // goes away. 1267 // goes away.
1263 AudioRenderer* renderer_ = nullptr; 1268 AudioSource* source_ = nullptr;
1264 1269
1265 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); 1270 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream);
1266 }; 1271 };
1267 1272
1268 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { 1273 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream {
1269 public: 1274 public:
1270 WebRtcAudioReceiveStream(int ch, 1275 WebRtcAudioReceiveStream(int ch,
1271 uint32_t remote_ssrc, 1276 uint32_t remote_ssrc,
1272 uint32_t local_ssrc, 1277 uint32_t local_ssrc,
1273 bool use_transport_cc, 1278 bool use_transport_cc,
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " 1802 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel "
1798 << ch.second->channel() << " failed"; 1803 << ch.second->channel() << " failed";
1799 return false; 1804 return false;
1800 } 1805 }
1801 } 1806 }
1802 playout_ = playout; 1807 playout_ = playout;
1803 return true; 1808 return true;
1804 } 1809 }
1805 1810
1806 bool WebRtcVoiceMediaChannel::SetSend(SendFlags send) { 1811 bool WebRtcVoiceMediaChannel::SetSend(SendFlags send) {
1807 desired_send_ = send;
1808 if (!send_streams_.empty()) {
1809 return ChangeSend(desired_send_);
1810 }
1811 return true;
1812 }
1813
1814 bool WebRtcVoiceMediaChannel::PauseSend() {
1815 return ChangeSend(SEND_NOTHING);
1816 }
1817
1818 bool WebRtcVoiceMediaChannel::ResumeSend() {
1819 return ChangeSend(desired_send_);
1820 }
1821
1822 bool WebRtcVoiceMediaChannel::ChangeSend(SendFlags send) {
1823 if (send_ == send) { 1812 if (send_ == send) {
1824 return true; 1813 return true;
1825 } 1814 }
1826 1815
1827 // Apply channel specific options when channel is enabled for sending. 1816 // Apply channel specific options when channel is enabled for sending
1828 if (send == SEND_MICROPHONE) { 1817 // and we have at least one stream.
1818 if (!send_streams_.empty() && send == SEND_MICROPHONE) {
the sun 2016/03/03 15:15:25 nit: can we consistently check "send == SEND_..."
Taylor Brandstetter 2016/03/04 16:06:56 Done.
1829 engine()->ApplyOptions(options_); 1819 engine()->ApplyOptions(options_);
1830 } 1820 }
1831 1821
1832 // Change the settings on each send channel. 1822 // Change the settings on each send channel.
1833 for (const auto& ch : send_streams_) { 1823 for (const auto& kv : send_streams_) {
1834 if (!ChangeSend(ch.second->channel(), send)) { 1824 if (!UpdateChannelSendState(kv.first, send)) {
1835 return false; 1825 return false;
1836 } 1826 }
1837 } 1827 }
1838 1828
1839 send_ = send; 1829 send_ = send;
1840 return true; 1830 return true;
1841 } 1831 }
1842 1832
1843 bool WebRtcVoiceMediaChannel::ChangeSend(int channel, SendFlags send) { 1833 bool WebRtcVoiceMediaChannel::UpdateChannelSendState(uint32_t ssrc,
1844 if (send == SEND_MICROPHONE) { 1834 SendFlags send) {
the sun 2016/03/03 15:15:25 You could remove the SendFlags enum while you're a
Taylor Brandstetter 2016/03/04 16:06:56 Done.
1835 RTC_DCHECK(send == SEND_NOTHING || send == SEND_MICROPHONE);
1836
1837 auto it = send_streams_.find(ssrc);
1838 if (it == send_streams_.end()) {
1839 RTC_DCHECK(false && "UpdateChannelSendState called with invalid SSRC.");
1840 return false;
1841 }
1842
1843 int channel = it->second->channel();
1844 if (send == SEND_MICROPHONE && it->second->HasSource()) {
1845 if (engine()->voe()->base()->StartSend(channel) == -1) { 1845 if (engine()->voe()->base()->StartSend(channel) == -1) {
1846 LOG_RTCERR1(StartSend, channel); 1846 LOG_RTCERR1(StartSend, channel);
1847 return false; 1847 return false;
1848 } 1848 }
1849 } else { // SEND_NOTHING 1849 } else { // send == SEND_NOTHING || !it->second->HasSource()
1850 RTC_DCHECK(send == SEND_NOTHING);
1851 if (engine()->voe()->base()->StopSend(channel) == -1) { 1850 if (engine()->voe()->base()->StopSend(channel) == -1) {
1852 LOG_RTCERR1(StopSend, channel); 1851 LOG_RTCERR1(StopSend, channel);
1853 return false; 1852 return false;
1854 } 1853 }
1855 } 1854 }
1856 1855
1857 return true; 1856 return true;
1858 } 1857 }
1859 1858
1860 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, 1859 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc,
1861 bool enable, 1860 bool enable,
1862 const AudioOptions* options, 1861 const AudioOptions* options,
1863 AudioRenderer* renderer) { 1862 AudioSource* source) {
1864 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1863 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1865 // TODO(solenberg): The state change should be fully rolled back if any one of 1864 // TODO(solenberg): The state change should be fully rolled back if any one of
1866 // these calls fail. 1865 // these calls fail.
1867 if (!SetLocalRenderer(ssrc, renderer)) { 1866 if (!SetLocalSource(ssrc, source)) {
1868 return false; 1867 return false;
1869 } 1868 }
1870 if (!MuteStream(ssrc, !enable)) { 1869 if (!MuteStream(ssrc, !enable)) {
1871 return false; 1870 return false;
1872 } 1871 }
1872 // If the source was set or unset we may need to update the sending
1873 // state of the voe::Channel.
1874 if (!UpdateChannelSendState(ssrc, send_)) {
1875 return false;
1876 }
1873 if (enable && options) { 1877 if (enable && options) {
1874 return SetOptions(*options); 1878 return SetOptions(*options);
1875 } 1879 }
1876 return true; 1880 return true;
1877 } 1881 }
1878 1882
1879 int WebRtcVoiceMediaChannel::CreateVoEChannel() { 1883 int WebRtcVoiceMediaChannel::CreateVoEChannel() {
1880 int id = engine()->CreateVoEChannel(); 1884 int id = engine()->CreateVoEChannel();
1881 if (id == -1) { 1885 if (id == -1) {
1882 LOG_RTCERR0(CreateVoEChannel); 1886 LOG_RTCERR0(CreateVoEChannel);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { 1948 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) {
1945 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); 1949 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc);
1946 return false; 1950 return false;
1947 } 1951 }
1948 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); 1952 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel);
1949 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel 1953 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel
1950 << " is associated with channel #" << channel << "."; 1954 << " is associated with channel #" << channel << ".";
1951 } 1955 }
1952 } 1956 }
1953 1957
1954 return ChangeSend(channel, desired_send_); 1958 // Apply channel specific options when channel is enabled for sending
1959 // and we have at least one stream.
the sun 2016/03/03 15:15:25 nit: at least -> exactly
Taylor Brandstetter 2016/03/04 16:06:56 Done.
1960 if (send_streams_.size() == 1u && send_ == SEND_MICROPHONE) {
1961 engine()->ApplyOptions(options_);
1962 }
1963 return UpdateChannelSendState(ssrc, send_);
1955 } 1964 }
1956 1965
1957 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { 1966 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) {
1958 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1967 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1959 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; 1968 LOG(LS_INFO) << "RemoveSendStream: " << ssrc;
1960 1969
1961 auto it = send_streams_.find(ssrc); 1970 auto it = send_streams_.find(ssrc);
1962 if (it == send_streams_.end()) { 1971 if (it == send_streams_.end()) {
1963 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc 1972 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc
1964 << " which doesn't exist."; 1973 << " which doesn't exist.";
1965 return false; 1974 return false;
1966 } 1975 }
1967 1976
1968 int channel = it->second->channel(); 1977 UpdateChannelSendState(ssrc, SEND_NOTHING);
1969 ChangeSend(channel, SEND_NOTHING);
1970 1978
1971 // Clean up and delete the send stream+channel. 1979 // Clean up and delete the send stream+channel.
1980 int channel = it->second->channel();
1972 LOG(LS_INFO) << "Removing audio send stream " << ssrc 1981 LOG(LS_INFO) << "Removing audio send stream " << ssrc
1973 << " with VoiceEngine channel #" << channel << "."; 1982 << " with VoiceEngine channel #" << channel << ".";
1974 delete it->second; 1983 delete it->second;
1975 send_streams_.erase(it); 1984 send_streams_.erase(it);
1976 if (!DeleteVoEChannel(channel)) { 1985 if (!DeleteVoEChannel(channel)) {
1977 return false; 1986 return false;
1978 } 1987 }
1979 if (send_streams_.empty()) {
1980 ChangeSend(SEND_NOTHING);
1981 }
the sun 2016/03/03 15:15:25 Note that this had the effect of setting send_ = S
Taylor Brandstetter 2016/03/04 16:06:56 Actually, the new stream was created with desired_
1982 return true; 1988 return true;
1983 } 1989 }
1984 1990
1985 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { 1991 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) {
1986 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1992 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1987 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); 1993 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString();
1988 1994
1989 if (!ValidateStreamParams(sp)) { 1995 if (!ValidateStreamParams(sp)) {
1990 return false; 1996 return false;
1991 } 1997 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2081 2087
2082 // Clean up and delete the receive stream+channel. 2088 // Clean up and delete the receive stream+channel.
2083 LOG(LS_INFO) << "Removing audio receive stream " << ssrc 2089 LOG(LS_INFO) << "Removing audio receive stream " << ssrc
2084 << " with VoiceEngine channel #" << channel << "."; 2090 << " with VoiceEngine channel #" << channel << ".";
2085 it->second->SetRawAudioSink(nullptr); 2091 it->second->SetRawAudioSink(nullptr);
2086 delete it->second; 2092 delete it->second;
2087 recv_streams_.erase(it); 2093 recv_streams_.erase(it);
2088 return DeleteVoEChannel(channel); 2094 return DeleteVoEChannel(channel);
2089 } 2095 }
2090 2096
2091 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, 2097 bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc,
2092 AudioRenderer* renderer) { 2098 AudioSource* source) {
2093 auto it = send_streams_.find(ssrc); 2099 auto it = send_streams_.find(ssrc);
2094 if (it == send_streams_.end()) { 2100 if (it == send_streams_.end()) {
2095 if (renderer) { 2101 if (source) {
2096 // Return an error if trying to set a valid renderer with an invalid ssrc. 2102 // Return an error if trying to set a valid source with an invalid ssrc.
2097 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; 2103 LOG(LS_ERROR) << "SetLocalSource failed with ssrc " << ssrc;
2098 return false; 2104 return false;
2099 } 2105 }
2100 2106
2101 // The channel likely has gone away, do nothing. 2107 // The channel likely has gone away, do nothing.
2102 return true; 2108 return true;
2103 } 2109 }
2104 2110
2105 if (renderer) { 2111 if (source) {
2106 it->second->Start(renderer); 2112 it->second->SetSource(source);
2107 } else { 2113 } else {
2108 it->second->Stop(); 2114 it->second->ClearSource();
2109 } 2115 }
2110 2116
2111 return true; 2117 return true;
2112 } 2118 }
2113 2119
2114 bool WebRtcVoiceMediaChannel::GetActiveStreams( 2120 bool WebRtcVoiceMediaChannel::GetActiveStreams(
2115 AudioInfo::StreamList* actives) { 2121 AudioInfo::StreamList* actives) {
2116 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2122 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2117 actives->clear(); 2123 actives->clear();
2118 for (const auto& ch : recv_streams_) { 2124 for (const auto& ch : recv_streams_) {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2520 } 2526 }
2521 } else { 2527 } else {
2522 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2528 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2523 engine()->voe()->base()->StopPlayout(channel); 2529 engine()->voe()->base()->StopPlayout(channel);
2524 } 2530 }
2525 return true; 2531 return true;
2526 } 2532 }
2527 } // namespace cricket 2533 } // namespace cricket
2528 2534
2529 #endif // HAVE_WEBRTC_VOICE 2535 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698