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 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1140 RTC_DCHECK(stream_); | 1140 RTC_DCHECK(stream_); |
1141 return stream_->SendTelephoneEvent(payload_type, event, duration_ms); | 1141 return stream_->SendTelephoneEvent(payload_type, event, duration_ms); |
1142 } | 1142 } |
1143 | 1143 |
1144 void SetSend(bool send) { | 1144 void SetSend(bool send) { |
1145 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1145 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1146 send_ = send; | 1146 send_ = send; |
1147 UpdateSendState(); | 1147 UpdateSendState(); |
1148 } | 1148 } |
1149 | 1149 |
1150 void SetMuted(bool muted) { | |
1151 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1152 RTC_DCHECK(stream_); | |
1153 stream_->SetMuted(muted); | |
1154 muted_ = muted; | |
1155 } | |
1156 | |
1157 bool muted() const { | |
1158 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
1159 return muted_; | |
1160 } | |
1161 | |
1150 webrtc::AudioSendStream::Stats GetStats() const { | 1162 webrtc::AudioSendStream::Stats GetStats() const { |
1151 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1163 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1152 RTC_DCHECK(stream_); | 1164 RTC_DCHECK(stream_); |
1153 return stream_->GetStats(); | 1165 return stream_->GetStats(); |
1154 } | 1166 } |
1155 | 1167 |
1156 // Starts the sending by setting ourselves as a sink to the AudioSource to | 1168 // Starts the sending by setting ourselves as a sink to the AudioSource to |
1157 // get data callbacks. | 1169 // get data callbacks. |
1158 // This method is called on the libjingle worker thread. | 1170 // This method is called on the libjingle worker thread. |
1159 // TODO(xians): Make sure Start() is called only once. | 1171 // TODO(xians): Make sure Start() is called only once. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 webrtc::AudioSendStream::Config config_; | 1257 webrtc::AudioSendStream::Config config_; |
1246 // The stream is owned by WebRtcAudioSendStream and may be reallocated if | 1258 // The stream is owned by WebRtcAudioSendStream and may be reallocated if |
1247 // configuration changes. | 1259 // configuration changes. |
1248 webrtc::AudioSendStream* stream_ = nullptr; | 1260 webrtc::AudioSendStream* stream_ = nullptr; |
1249 | 1261 |
1250 // Raw pointer to AudioSource owned by LocalAudioTrackHandler. | 1262 // Raw pointer to AudioSource owned by LocalAudioTrackHandler. |
1251 // PeerConnection will make sure invalidating the pointer before the object | 1263 // PeerConnection will make sure invalidating the pointer before the object |
1252 // goes away. | 1264 // goes away. |
1253 AudioSource* source_ = nullptr; | 1265 AudioSource* source_ = nullptr; |
1254 bool send_ = false; | 1266 bool send_ = false; |
1267 bool muted_ = false; | |
1255 webrtc::RtpParameters rtp_parameters_; | 1268 webrtc::RtpParameters rtp_parameters_; |
1256 | 1269 |
1257 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); | 1270 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioSendStream); |
1258 }; | 1271 }; |
1259 | 1272 |
1260 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { | 1273 class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { |
1261 public: | 1274 public: |
1262 WebRtcAudioReceiveStream( | 1275 WebRtcAudioReceiveStream( |
1263 int ch, | 1276 int ch, |
1264 uint32_t remote_ssrc, | 1277 uint32_t remote_ssrc, |
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2356 } | 2369 } |
2357 | 2370 |
2358 void WebRtcVoiceMediaChannel::OnNetworkRouteChanged( | 2371 void WebRtcVoiceMediaChannel::OnNetworkRouteChanged( |
2359 const std::string& transport_name, | 2372 const std::string& transport_name, |
2360 const rtc::NetworkRoute& network_route) { | 2373 const rtc::NetworkRoute& network_route) { |
2361 call_->OnNetworkRouteChanged(transport_name, network_route); | 2374 call_->OnNetworkRouteChanged(transport_name, network_route); |
2362 } | 2375 } |
2363 | 2376 |
2364 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { | 2377 bool WebRtcVoiceMediaChannel::MuteStream(uint32_t ssrc, bool muted) { |
2365 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2378 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
2366 int channel = GetSendChannelId(ssrc); | 2379 const auto it = send_streams_.find(ssrc); |
2367 if (channel == -1) { | 2380 if (it == send_streams_.end()) { |
2368 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; | 2381 LOG(LS_WARNING) << "The specified ssrc " << ssrc << " is not in use."; |
2369 return false; | 2382 return false; |
2370 } | 2383 } |
2371 if (engine()->voe()->volume()->SetInputMute(channel, muted) == -1) { | 2384 it->second->SetMuted(muted); |
2372 LOG_RTCERR2(SetInputMute, channel, muted); | 2385 |
2373 return false; | 2386 // TODO(solenberg): |
2374 } | |
2375 // We set the AGC to mute state only when all the channels are muted. | 2387 // We set the AGC to mute state only when all the channels are muted. |
2376 // This implementation is not ideal, instead we should signal the AGC when | 2388 // This implementation is not ideal, instead we should signal the AGC when |
2377 // the mic channel is muted/unmuted. We can't do it today because there | 2389 // the mic channel is muted/unmuted. We can't do it today because there |
2378 // is no good way to know which stream is mapping to the mic channel. | 2390 // is no good way to know which stream is mapping to the mic channel. |
2379 bool all_muted = muted; | 2391 bool all_muted = muted; |
2380 for (const auto& ch : send_streams_) { | 2392 for (const auto& kv : send_streams_) { |
2381 if (!all_muted) { | 2393 all_muted = all_muted && kv.second->muted(); |
kwiberg-webrtc
2016/06/16 09:33:45
This looks like a job for std::all_of.
the sun
2016/06/16 12:31:38
That sounds neat, but it turns out it doesn't help
kwiberg-webrtc
2016/06/16 12:41:40
Bummer. auto in lambda parameter lists is in C++14
| |
2382 break; | |
2383 } | |
2384 if (engine()->voe()->volume()->GetInputMute(ch.second->channel(), | |
2385 all_muted)) { | |
2386 LOG_RTCERR1(GetInputMute, ch.second->channel()); | |
2387 return false; | |
2388 } | |
2389 } | 2394 } |
2390 | 2395 |
2391 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); | 2396 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); |
2392 if (ap) { | 2397 if (ap) { |
2393 ap->set_output_will_be_muted(all_muted); | 2398 ap->set_output_will_be_muted(all_muted); |
2394 } | 2399 } |
2395 return true; | 2400 return true; |
2396 } | 2401 } |
2397 | 2402 |
2398 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) { | 2403 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2591 } | 2596 } |
2592 } else { | 2597 } else { |
2593 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2598 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2594 engine()->voe()->base()->StopPlayout(channel); | 2599 engine()->voe()->base()->StopPlayout(channel); |
2595 } | 2600 } |
2596 return true; | 2601 return true; |
2597 } | 2602 } |
2598 } // namespace cricket | 2603 } // namespace cricket |
2599 | 2604 |
2600 #endif // HAVE_WEBRTC_VOICE | 2605 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |