Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 // TODO(solenberg): Encoder config. | 52 // TODO(solenberg): Encoder config. |
| 53 ss << ", cng_payload_type: " << cng_payload_type; | 53 ss << ", cng_payload_type: " << cng_payload_type; |
| 54 ss << '}'; | 54 ss << '}'; |
| 55 return ss.str(); | 55 return ss.str(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 namespace internal { | 58 namespace internal { |
| 59 AudioSendStream::AudioSendStream( | 59 AudioSendStream::AudioSendStream( |
| 60 const webrtc::AudioSendStream::Config& config, | 60 const webrtc::AudioSendStream::Config& config, |
| 61 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, | 61 const rtc::scoped_refptr<webrtc::AudioState>& audio_state, |
| 62 CongestionController* congestion_controller) | 62 CongestionController* congestion_controller, |
| 63 : config_(config), audio_state_(audio_state) { | 63 BitrateAllocator* bitrate_allocator) |
| 64 : config_(config), | |
| 65 audio_state_(audio_state), | |
| 66 bitrate_allocator_(bitrate_allocator) { | |
| 64 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); | 67 LOG(LS_INFO) << "AudioSendStream: " << config_.ToString(); |
| 65 RTC_DCHECK_NE(config_.voe_channel_id, -1); | 68 RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| 66 RTC_DCHECK(audio_state_.get()); | 69 RTC_DCHECK(audio_state_.get()); |
| 67 RTC_DCHECK(congestion_controller); | 70 RTC_DCHECK(congestion_controller); |
| 68 | 71 |
| 69 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); | 72 VoiceEngineImpl* voe_impl = static_cast<VoiceEngineImpl*>(voice_engine()); |
| 70 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); | 73 channel_proxy_ = voe_impl->GetChannelProxy(config_.voe_channel_id); |
| 71 channel_proxy_->RegisterSenderCongestionControlObjects( | 74 channel_proxy_->RegisterSenderCongestionControlObjects( |
| 72 congestion_controller->pacer(), | 75 congestion_controller->pacer(), |
| 73 congestion_controller->GetTransportFeedbackObserver(), | 76 congestion_controller->GetTransportFeedbackObserver(), |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 97 | 100 |
| 98 AudioSendStream::~AudioSendStream() { | 101 AudioSendStream::~AudioSendStream() { |
| 99 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 102 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 100 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); | 103 LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString(); |
| 101 channel_proxy_->DeRegisterExternalTransport(); | 104 channel_proxy_->DeRegisterExternalTransport(); |
| 102 channel_proxy_->ResetCongestionControlObjects(); | 105 channel_proxy_->ResetCongestionControlObjects(); |
| 103 } | 106 } |
| 104 | 107 |
| 105 void AudioSendStream::Start() { | 108 void AudioSendStream::Start() { |
| 106 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 109 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 110 if (config_.min_bitrate_kbps != -1 && config_.max_bitrate_kbps != -1) { | |
| 111 RTC_DCHECK_GE(config_.max_bitrate_kbps, config_.min_bitrate_kbps); | |
| 112 bitrate_allocator_->AddObserver(this, config_.min_bitrate_kbps * 1000, | |
| 113 config_.max_bitrate_kbps * 1000, 0, true); | |
| 114 } | |
| 115 | |
| 107 ScopedVoEInterface<VoEBase> base(voice_engine()); | 116 ScopedVoEInterface<VoEBase> base(voice_engine()); |
| 108 int error = base->StartSend(config_.voe_channel_id); | 117 int error = base->StartSend(config_.voe_channel_id); |
| 109 if (error != 0) { | 118 if (error != 0) { |
| 110 LOG(LS_ERROR) << "AudioSendStream::Start failed with error: " << error; | 119 LOG(LS_ERROR) << "AudioSendStream::Start failed with error: " << error; |
| 111 } | 120 } |
| 112 } | 121 } |
| 113 | 122 |
| 114 void AudioSendStream::Stop() { | 123 void AudioSendStream::Stop() { |
| 115 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 124 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 bitrate_allocator_->RemoveObserver(this); | |
| 116 ScopedVoEInterface<VoEBase> base(voice_engine()); | 126 ScopedVoEInterface<VoEBase> base(voice_engine()); |
| 117 int error = base->StopSend(config_.voe_channel_id); | 127 int error = base->StopSend(config_.voe_channel_id); |
| 118 if (error != 0) { | 128 if (error != 0) { |
| 119 LOG(LS_ERROR) << "AudioSendStream::Stop failed with error: " << error; | 129 LOG(LS_ERROR) << "AudioSendStream::Stop failed with error: " << error; |
| 120 } | 130 } |
| 121 } | 131 } |
| 122 | 132 |
| 123 bool AudioSendStream::SendTelephoneEvent(int payload_type, int event, | 133 bool AudioSendStream::SendTelephoneEvent(int payload_type, int event, |
| 124 int duration_ms) { | 134 int duration_ms) { |
| 125 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 135 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 } | 230 } |
| 221 | 231 |
| 222 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { | 232 bool AudioSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 223 // TODO(solenberg): Tests call this function on a network thread, libjingle | 233 // TODO(solenberg): Tests call this function on a network thread, libjingle |
| 224 // calls on the worker thread. We should move towards always using a network | 234 // calls on the worker thread. We should move towards always using a network |
| 225 // thread. Then this check can be enabled. | 235 // thread. Then this check can be enabled. |
| 226 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | 236 // RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
| 227 return channel_proxy_->ReceivedRTCPPacket(packet, length); | 237 return channel_proxy_->ReceivedRTCPPacket(packet, length); |
| 228 } | 238 } |
| 229 | 239 |
| 240 uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps, | |
| 241 uint8_t fraction_loss, | |
| 242 int64_t rtt) { | |
| 243 RTC_DCHECK_GE(bitrate_bps, | |
| 244 static_cast<uint32_t>(config_.min_bitrate_kbps * 1000)); | |
| 245 // The bitrate allocator might allocate an higher than max configured bitrate | |
| 246 // if there is room, to allow for, as example, extra FEC. Ignore that for now. | |
| 247 const uint32_t max_bitrate_bps = config_.max_bitrate_kbps * 1000; | |
| 248 if (bitrate_bps > max_bitrate_bps) | |
| 249 bitrate_bps = max_bitrate_bps; | |
| 250 | |
| 251 channel_proxy_->SetBitrate(bitrate_bps); | |
| 252 | |
| 253 // Possible audio protection used is ignored for now. | |
|
stefan-webrtc
2016/07/20 10:14:59
Maybe rewrite as:
TODO(mflodman): Return amount of
mflodman
2016/07/22 13:50:29
This information isn't available to us and would r
stefan-webrtc
2016/07/25 15:06:20
Acknowledged.
| |
| 254 return 0; | |
|
minyue-webrtc
2016/07/21 10:59:19
do we need to return
max_bitrate_bps - bitrate_bp
mflodman
2016/07/22 13:50:29
We should return the bitrate used for FEC, but we
minyue-webrtc
2016/07/25 14:33:47
OK, the comment on OnBitrateUpdated says
"
Returns
| |
| 255 } | |
| 256 | |
| 230 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { | 257 const webrtc::AudioSendStream::Config& AudioSendStream::config() const { |
| 231 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 258 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 232 return config_; | 259 return config_; |
| 233 } | 260 } |
| 234 | 261 |
| 235 VoiceEngine* AudioSendStream::voice_engine() const { | 262 VoiceEngine* AudioSendStream::voice_engine() const { |
| 236 internal::AudioState* audio_state = | 263 internal::AudioState* audio_state = |
| 237 static_cast<internal::AudioState*>(audio_state_.get()); | 264 static_cast<internal::AudioState*>(audio_state_.get()); |
| 238 VoiceEngine* voice_engine = audio_state->voice_engine(); | 265 VoiceEngine* voice_engine = audio_state->voice_engine(); |
| 239 RTC_DCHECK(voice_engine); | 266 RTC_DCHECK(voice_engine); |
| 240 return voice_engine; | 267 return voice_engine; |
| 241 } | 268 } |
| 242 } // namespace internal | 269 } // namespace internal |
| 243 } // namespace webrtc | 270 } // namespace webrtc |
| OLD | NEW |