OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 void SetSend(bool send) { | |
1186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1187 send_ = send; | |
1188 UpdateSendState(); | |
1189 } | |
1190 | |
1185 webrtc::AudioSendStream::Stats GetStats() const { | 1191 webrtc::AudioSendStream::Stats GetStats() const { |
1186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1192 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1187 RTC_DCHECK(stream_); | 1193 RTC_DCHECK(stream_); |
1188 return stream_->GetStats(); | 1194 return stream_->GetStats(); |
1189 } | 1195 } |
1190 | 1196 |
1191 // Starts the rendering by setting a sink to the renderer to get data | 1197 bool HasSource() const { |
the sun
2016/03/07 21:24:54
Only used internally; make private
Taylor Brandstetter
2016/03/08 00:00:31
I removed the method since it's only called in one
| |
1192 // callback. | 1198 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1199 return source_ != nullptr; | |
1200 } | |
1201 | |
1202 // Starts the sending by setting ourselves as a sink to the AudioSource to | |
1203 // get data callbacks. | |
1193 // This method is called on the libjingle worker thread. | 1204 // This method is called on the libjingle worker thread. |
1194 // TODO(xians): Make sure Start() is called only once. | 1205 // TODO(xians): Make sure Start() is called only once. |
1195 void Start(AudioRenderer* renderer) { | 1206 void SetSource(AudioSource* source) { |
1196 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1207 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1197 RTC_DCHECK(renderer); | 1208 RTC_DCHECK(source); |
1198 if (renderer_) { | 1209 if (source_) { |
1199 RTC_DCHECK(renderer_ == renderer); | 1210 RTC_DCHECK(source_ == source); |
1200 return; | 1211 return; |
1201 } | 1212 } |
1202 renderer->SetSink(this); | 1213 source->SetSink(this); |
1203 renderer_ = renderer; | 1214 source_ = source; |
1215 UpdateSendState(); | |
1204 } | 1216 } |
1205 | 1217 |
1206 // Stops rendering by setting the sink of the renderer to nullptr. No data | 1218 // Stops sending by setting the sink of the AudioSource to nullptr. No data |
1207 // callback will be received after this method. | 1219 // callback will be received after this method. |
1208 // This method is called on the libjingle worker thread. | 1220 // This method is called on the libjingle worker thread. |
1209 void Stop() { | 1221 void ClearSource() { |
1210 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1222 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1211 if (renderer_) { | 1223 if (source_) { |
1212 renderer_->SetSink(nullptr); | 1224 source_->SetSink(nullptr); |
1213 renderer_ = nullptr; | 1225 source_ = nullptr; |
1214 } | 1226 } |
1227 UpdateSendState(); | |
1215 } | 1228 } |
1216 | 1229 |
1217 // AudioRenderer::Sink implementation. | 1230 // AudioSource::Sink implementation. |
1218 // This method is called on the audio thread. | 1231 // This method is called on the audio thread. |
1219 void OnData(const void* audio_data, | 1232 void OnData(const void* audio_data, |
1220 int bits_per_sample, | 1233 int bits_per_sample, |
1221 int sample_rate, | 1234 int sample_rate, |
1222 size_t number_of_channels, | 1235 size_t number_of_channels, |
1223 size_t number_of_frames) override { | 1236 size_t number_of_frames) override { |
1224 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread()); | 1237 RTC_DCHECK(!worker_thread_checker_.CalledOnValidThread()); |
1225 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); | 1238 RTC_DCHECK(audio_capture_thread_checker_.CalledOnValidThread()); |
1226 RTC_DCHECK(voe_audio_transport_); | 1239 RTC_DCHECK(voe_audio_transport_); |
1227 voe_audio_transport_->OnData(config_.voe_channel_id, | 1240 voe_audio_transport_->OnData(config_.voe_channel_id, |
1228 audio_data, | 1241 audio_data, |
1229 bits_per_sample, | 1242 bits_per_sample, |
1230 sample_rate, | 1243 sample_rate, |
1231 number_of_channels, | 1244 number_of_channels, |
1232 number_of_frames); | 1245 number_of_frames); |
1233 } | 1246 } |
1234 | 1247 |
1235 // Callback from the |renderer_| when it is going away. In case Start() has | 1248 // Callback from the |source_| when it is going away. In case Start() has |
1236 // never been called, this callback won't be triggered. | 1249 // never been called, this callback won't be triggered. |
1237 void OnClose() override { | 1250 void OnClose() override { |
1238 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1251 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1239 // Set |renderer_| to nullptr to make sure no more callback will get into | 1252 // Set |source_| to nullptr to make sure no more callback will get into |
1240 // the renderer. | 1253 // the source. |
1241 renderer_ = nullptr; | 1254 source_ = nullptr; |
the sun
2016/03/07 21:24:53
UpdateSendState() ?
Taylor Brandstetter
2016/03/08 00:00:31
Good catch.
| |
1242 } | 1255 } |
1243 | 1256 |
1244 // Accessor to the VoE channel ID. | 1257 // Accessor to the VoE channel ID. |
1245 int channel() const { | 1258 int channel() const { |
1246 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1259 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1247 return config_.voe_channel_id; | 1260 return config_.voe_channel_id; |
1248 } | 1261 } |
1249 | 1262 |
1250 private: | 1263 private: |
1264 void UpdateSendState() { | |
1265 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1266 RTC_DCHECK(stream_); | |
1267 if (send_ && HasSource()) { | |
1268 stream_->Start(); | |
1269 } else { // !send || !HasSource() | |
1270 stream_->Stop(); | |
1271 } | |
1272 } | |
1273 | |
1251 rtc::ThreadChecker worker_thread_checker_; | 1274 rtc::ThreadChecker worker_thread_checker_; |
1252 rtc::ThreadChecker audio_capture_thread_checker_; | 1275 rtc::ThreadChecker audio_capture_thread_checker_; |
1253 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; | 1276 webrtc::AudioTransport* const voe_audio_transport_ = nullptr; |
1254 webrtc::Call* call_ = nullptr; | 1277 webrtc::Call* call_ = nullptr; |
1255 webrtc::AudioSendStream::Config config_; | 1278 webrtc::AudioSendStream::Config config_; |
1256 // The stream is owned by WebRtcAudioSendStream and may be reallocated if | 1279 // The stream is owned by WebRtcAudioSendStream and may be reallocated if |
1257 // configuration changes. | 1280 // configuration changes. |
1258 webrtc::AudioSendStream* stream_ = nullptr; | 1281 webrtc::AudioSendStream* stream_ = nullptr; |
1259 | 1282 |
1260 // Raw pointer to AudioRenderer owned by LocalAudioTrackHandler. | 1283 // Raw pointer to AudioSource owned by LocalAudioTrackHandler. |
1261 // PeerConnection will make sure invalidating the pointer before the object | 1284 // PeerConnection will make sure invalidating the pointer before the object |
1262 // goes away. | 1285 // goes away. |
1263 AudioRenderer* renderer_ = nullptr; | 1286 AudioSource* source_ = nullptr; |
1287 bool send_ = false; | |
1264 | 1288 |
1265 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1289 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
1266 }; | 1290 }; |
1267 | 1291 |
1268 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { | 1292 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { |
1269 public: | 1293 public: |
1270 WebRtcAudioReceiveStream(int ch, | 1294 WebRtcAudioReceiveStream(int ch, |
1271 uint32_t remote_ssrc, | 1295 uint32_t remote_ssrc, |
1272 uint32_t local_ssrc, | 1296 uint32_t local_ssrc, |
1273 bool use_transport_cc, | 1297 bool use_transport_cc, |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1796 if (!SetPlayout(ch.second->channel(), playout)) { | 1820 if (!SetPlayout(ch.second->channel(), playout)) { |
1797 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " | 1821 LOG(LS_ERROR) << "SetPlayout " << playout << " on channel " |
1798 << ch.second->channel() << " failed"; | 1822 << ch.second->channel() << " failed"; |
1799 return false; | 1823 return false; |
1800 } | 1824 } |
1801 } | 1825 } |
1802 playout_ = playout; | 1826 playout_ = playout; |
1803 return true; | 1827 return true; |
1804 } | 1828 } |
1805 | 1829 |
1806 bool WebRtcVoiceMediaChannel::SetSend(SendFlags send) { | 1830 bool WebRtcVoiceMediaChannel::SetSend(bool 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) { | 1831 if (send_ == send) { |
the sun
2016/03/07 21:24:53
Add "|| send_streams_.empty()" to maintain current
Taylor Brandstetter
2016/03/08 00:00:31
Done.
| |
1824 return true; | 1832 return true; |
1825 } | 1833 } |
1826 | 1834 |
1827 // Apply channel specific options when channel is enabled for sending. | 1835 // Apply channel specific options when channel is enabled for sending. |
1828 if (send == SEND_MICROPHONE) { | 1836 if (send) { |
1829 engine()->ApplyOptions(options_); | 1837 engine()->ApplyOptions(options_); |
1830 } | 1838 } |
1831 | 1839 |
1832 // Change the settings on each send channel. | 1840 // Change the settings on each send channel. |
1833 for (const auto& ch : send_streams_) { | 1841 for (auto& kv : send_streams_) { |
1834 if (!ChangeSend(ch.second->channel(), send)) { | 1842 kv.second->SetSend(send); |
1835 return false; | |
1836 } | |
1837 } | 1843 } |
1838 | 1844 |
1839 send_ = send; | 1845 send_ = send; |
1840 return true; | 1846 return true; |
1841 } | 1847 } |
1842 | 1848 |
1843 bool WebRtcVoiceMediaChannel::ChangeSend(int channel, SendFlags send) { | |
1844 if (send == SEND_MICROPHONE) { | |
1845 if (engine()->voe()->base()->StartSend(channel) == -1) { | |
1846 LOG_RTCERR1(StartSend, channel); | |
1847 return false; | |
1848 } | |
1849 } else { // SEND_NOTHING | |
1850 RTC_DCHECK(send == SEND_NOTHING); | |
1851 if (engine()->voe()->base()->StopSend(channel) == -1) { | |
1852 LOG_RTCERR1(StopSend, channel); | |
1853 return false; | |
1854 } | |
1855 } | |
1856 | |
1857 return true; | |
1858 } | |
1859 | |
1860 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, | 1849 bool WebRtcVoiceMediaChannel::SetAudioSend(uint32_t ssrc, |
1861 bool enable, | 1850 bool enable, |
1862 const AudioOptions* options, | 1851 const AudioOptions* options, |
1863 AudioRenderer* renderer) { | 1852 AudioSource* source) { |
1864 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1853 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1865 // TODO(solenberg): The state change should be fully rolled back if any one of | 1854 // TODO(solenberg): The state change should be fully rolled back if any one of |
1866 // these calls fail. | 1855 // these calls fail. |
1867 if (!SetLocalRenderer(ssrc, renderer)) { | 1856 if (!SetLocalSource(ssrc, source)) { |
1868 return false; | 1857 return false; |
1869 } | 1858 } |
1870 if (!MuteStream(ssrc, !enable)) { | 1859 if (!MuteStream(ssrc, !enable)) { |
1871 return false; | 1860 return false; |
1872 } | 1861 } |
1873 if (enable && options) { | 1862 if (enable && options) { |
1874 return SetOptions(*options); | 1863 return SetOptions(*options); |
1875 } | 1864 } |
1876 return true; | 1865 return true; |
1877 } | 1866 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1944 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { | 1933 if (engine()->voe()->rtp()->SetLocalSSRC(recv_channel, ssrc) != 0) { |
1945 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); | 1934 LOG_RTCERR2(SetLocalSSRC, recv_channel, ssrc); |
1946 return false; | 1935 return false; |
1947 } | 1936 } |
1948 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); | 1937 engine()->voe()->base()->AssociateSendChannel(recv_channel, channel); |
1949 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel | 1938 LOG(LS_INFO) << "VoiceEngine channel #" << recv_channel |
1950 << " is associated with channel #" << channel << "."; | 1939 << " is associated with channel #" << channel << "."; |
1951 } | 1940 } |
1952 } | 1941 } |
1953 | 1942 |
1954 return ChangeSend(channel, desired_send_); | 1943 send_streams_[ssrc]->SetSend(send_); |
1944 return true; | |
1955 } | 1945 } |
1956 | 1946 |
1957 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { | 1947 bool WebRtcVoiceMediaChannel::RemoveSendStream(uint32_t ssrc) { |
1958 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1948 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1959 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; | 1949 LOG(LS_INFO) << "RemoveSendStream: " << ssrc; |
1960 | 1950 |
1961 auto it = send_streams_.find(ssrc); | 1951 auto it = send_streams_.find(ssrc); |
1962 if (it == send_streams_.end()) { | 1952 if (it == send_streams_.end()) { |
1963 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc | 1953 LOG(LS_WARNING) << "Try to remove stream with ssrc " << ssrc |
1964 << " which doesn't exist."; | 1954 << " which doesn't exist."; |
1965 return false; | 1955 return false; |
1966 } | 1956 } |
1967 | 1957 |
1968 int channel = it->second->channel(); | 1958 it->second->SetSend(false); |
1969 ChangeSend(channel, SEND_NOTHING); | |
1970 | 1959 |
1971 // Clean up and delete the send stream+channel. | 1960 // Clean up and delete the send stream+channel. |
1961 int channel = it->second->channel(); | |
1972 LOG(LS_INFO) << "Removing audio send stream " << ssrc | 1962 LOG(LS_INFO) << "Removing audio send stream " << ssrc |
1973 << " with VoiceEngine channel #" << channel << "."; | 1963 << " with VoiceEngine channel #" << channel << "."; |
1974 delete it->second; | 1964 delete it->second; |
1975 send_streams_.erase(it); | 1965 send_streams_.erase(it); |
1976 if (!DeleteVoEChannel(channel)) { | 1966 if (!DeleteVoEChannel(channel)) { |
1977 return false; | 1967 return false; |
1978 } | 1968 } |
1979 if (send_streams_.empty()) { | 1969 if (send_streams_.empty()) { |
1980 ChangeSend(SEND_NOTHING); | 1970 SetSend(false); |
1981 } | 1971 } |
1982 return true; | 1972 return true; |
1983 } | 1973 } |
1984 | 1974 |
1985 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { | 1975 bool WebRtcVoiceMediaChannel::AddRecvStream(const StreamParams& sp) { |
1986 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1976 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1987 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); | 1977 LOG(LS_INFO) << "AddRecvStream: " << sp.ToString(); |
1988 | 1978 |
1989 if (!ValidateStreamParams(sp)) { | 1979 if (!ValidateStreamParams(sp)) { |
1990 return false; | 1980 return false; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2081 | 2071 |
2082 // Clean up and delete the receive stream+channel. | 2072 // Clean up and delete the receive stream+channel. |
2083 LOG(LS_INFO) << "Removing audio receive stream " << ssrc | 2073 LOG(LS_INFO) << "Removing audio receive stream " << ssrc |
2084 << " with VoiceEngine channel #" << channel << "."; | 2074 << " with VoiceEngine channel #" << channel << "."; |
2085 it->second->SetRawAudioSink(nullptr); | 2075 it->second->SetRawAudioSink(nullptr); |
2086 delete it->second; | 2076 delete it->second; |
2087 recv_streams_.erase(it); | 2077 recv_streams_.erase(it); |
2088 return DeleteVoEChannel(channel); | 2078 return DeleteVoEChannel(channel); |
2089 } | 2079 } |
2090 | 2080 |
2091 bool WebRtcVoiceMediaChannel::SetLocalRenderer(uint32_t ssrc, | 2081 bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc, |
2092 AudioRenderer* renderer) { | 2082 AudioSource* source) { |
2093 auto it = send_streams_.find(ssrc); | 2083 auto it = send_streams_.find(ssrc); |
2094 if (it == send_streams_.end()) { | 2084 if (it == send_streams_.end()) { |
2095 if (renderer) { | 2085 if (source) { |
2096 // Return an error if trying to set a valid renderer with an invalid ssrc. | 2086 // Return an error if trying to set a valid source with an invalid ssrc. |
2097 LOG(LS_ERROR) << "SetLocalRenderer failed with ssrc "<< ssrc; | 2087 LOG(LS_ERROR) << "SetLocalSource failed with ssrc " << ssrc; |
2098 return false; | 2088 return false; |
2099 } | 2089 } |
2100 | 2090 |
2101 // The channel likely has gone away, do nothing. | 2091 // The channel likely has gone away, do nothing. |
2102 return true; | 2092 return true; |
2103 } | 2093 } |
2104 | 2094 |
2105 if (renderer) { | 2095 if (source) { |
2106 it->second->Start(renderer); | 2096 it->second->SetSource(source); |
2107 } else { | 2097 } else { |
2108 it->second->Stop(); | 2098 it->second->ClearSource(); |
2109 } | 2099 } |
2110 | 2100 |
2111 return true; | 2101 return true; |
2112 } | 2102 } |
2113 | 2103 |
2114 bool WebRtcVoiceMediaChannel::GetActiveStreams( | 2104 bool WebRtcVoiceMediaChannel::GetActiveStreams( |
2115 AudioInfo::StreamList* actives) { | 2105 AudioInfo::StreamList* actives) { |
2116 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2106 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2117 actives->clear(); | 2107 actives->clear(); |
2118 for (const auto& ch : recv_streams_) { | 2108 for (const auto& ch : recv_streams_) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2416 sinfo.codec_name = stats.codec_name; | 2406 sinfo.codec_name = stats.codec_name; |
2417 sinfo.ext_seqnum = stats.ext_seqnum; | 2407 sinfo.ext_seqnum = stats.ext_seqnum; |
2418 sinfo.jitter_ms = stats.jitter_ms; | 2408 sinfo.jitter_ms = stats.jitter_ms; |
2419 sinfo.rtt_ms = stats.rtt_ms; | 2409 sinfo.rtt_ms = stats.rtt_ms; |
2420 sinfo.audio_level = stats.audio_level; | 2410 sinfo.audio_level = stats.audio_level; |
2421 sinfo.aec_quality_min = stats.aec_quality_min; | 2411 sinfo.aec_quality_min = stats.aec_quality_min; |
2422 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms; | 2412 sinfo.echo_delay_median_ms = stats.echo_delay_median_ms; |
2423 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms; | 2413 sinfo.echo_delay_std_ms = stats.echo_delay_std_ms; |
2424 sinfo.echo_return_loss = stats.echo_return_loss; | 2414 sinfo.echo_return_loss = stats.echo_return_loss; |
2425 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement; | 2415 sinfo.echo_return_loss_enhancement = stats.echo_return_loss_enhancement; |
2426 sinfo.typing_noise_detected = | 2416 sinfo.typing_noise_detected = (send_ ? stats.typing_noise_detected : false); |
2427 (send_ == SEND_NOTHING ? false : stats.typing_noise_detected); | |
2428 info->senders.push_back(sinfo); | 2417 info->senders.push_back(sinfo); |
2429 } | 2418 } |
2430 | 2419 |
2431 // Get SSRC and stats for each receiver. | 2420 // Get SSRC and stats for each receiver. |
2432 RTC_DCHECK(info->receivers.size() == 0); | 2421 RTC_DCHECK(info->receivers.size() == 0); |
2433 for (const auto& stream : recv_streams_) { | 2422 for (const auto& stream : recv_streams_) { |
2434 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); | 2423 webrtc::AudioReceiveStream::Stats stats = stream.second->GetStats(); |
2435 VoiceReceiverInfo rinfo; | 2424 VoiceReceiverInfo rinfo; |
2436 rinfo.add_ssrc(stats.remote_ssrc); | 2425 rinfo.add_ssrc(stats.remote_ssrc); |
2437 rinfo.bytes_rcvd = stats.bytes_rcvd; | 2426 rinfo.bytes_rcvd = stats.bytes_rcvd; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2520 } | 2509 } |
2521 } else { | 2510 } else { |
2522 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2511 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2523 engine()->voe()->base()->StopPlayout(channel); | 2512 engine()->voe()->base()->StopPlayout(channel); |
2524 } | 2513 } |
2525 return true; | 2514 return true; |
2526 } | 2515 } |
2527 } // namespace cricket | 2516 } // namespace cricket |
2528 | 2517 |
2529 #endif // HAVE_WEBRTC_VOICE | 2518 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |