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