Chromium Code Reviews| Index: webrtc/audio/audio_receive_stream.cc |
| diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc |
| index dfad79f9d76420460267f2fdd0e1265a928b8786..57f83425fa3150e7b98a8eb0dd3ddce3dc0065d5 100644 |
| --- a/webrtc/audio/audio_receive_stream.cc |
| +++ b/webrtc/audio/audio_receive_stream.cc |
| @@ -18,6 +18,7 @@ |
| #include "webrtc/audio/conversion.h" |
| #include "webrtc/base/checks.h" |
| #include "webrtc/base/logging.h" |
| +#include "webrtc/call/congestion_controller.h" |
| #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" |
| #include "webrtc/system_wrappers/include/tick_util.h" |
| #include "webrtc/voice_engine/channel_proxy.h" |
| @@ -30,6 +31,19 @@ |
| #include "webrtc/voice_engine/voice_engine_impl.h" |
| namespace webrtc { |
| +namespace { |
| + |
| +static bool UseSendSideBwe(const webrtc::AudioReceiveStream::Config& config) { |
|
the sun
2015/12/22 00:14:14
no need to declare static inside an anonymous name
stefan-webrtc
2016/01/07 13:43:41
Done.
|
| + if (!config.rtp.transport_cc) |
|
the sun
2015/12/22 00:14:13
nit: This file consistently uses {} for one-line c
stefan-webrtc
2016/01/07 13:43:41
Done.
|
| + return false; |
| + for (const auto& extension : config.rtp.extensions) { |
| + if (extension.name == RtpExtension::kTransportSequenceNumber) |
| + return true; |
| + } |
| + return false; |
| +} |
| +} // namespace |
| + |
| std::string AudioReceiveStream::Config::Rtp::ToString() const { |
| std::stringstream ss; |
| ss << "{remote_ssrc: " << remote_ssrc; |
| @@ -65,16 +79,19 @@ std::string AudioReceiveStream::Config::ToString() const { |
| namespace internal { |
| AudioReceiveStream::AudioReceiveStream( |
| - RemoteBitrateEstimator* remote_bitrate_estimator, |
| + CongestionController* congestion_controller, |
| const webrtc::AudioReceiveStream::Config& config, |
| const rtc::scoped_refptr<webrtc::AudioState>& audio_state) |
| - : remote_bitrate_estimator_(remote_bitrate_estimator), |
| + : remote_bitrate_estimator_( |
| + config.combined_audio_video_bwe |
| + ? congestion_controller->GetRemoteBitrateEstimator( |
|
the sun
2015/12/22 00:14:14
Why not have two accessor methods on the CC? Sendi
stefan-webrtc
2016/01/07 13:43:40
Yes, I agree that it'd be nicer with two accessors
the sun
2016/01/08 10:29:35
In that case, making the CC ref counted would make
|
| + UseSendSideBwe(config)) |
| + : nullptr), |
| config_(config), |
| audio_state_(audio_state), |
| rtp_header_parser_(RtpHeaderParser::Create()) { |
| LOG(LS_INFO) << "AudioReceiveStream: " << config_.ToString(); |
| RTC_DCHECK_NE(config_.voe_channel_id, -1); |
| - RTC_DCHECK(remote_bitrate_estimator_); |
| RTC_DCHECK(audio_state_.get()); |
| RTC_DCHECK(rtp_header_parser_); |
| @@ -93,8 +110,6 @@ AudioReceiveStream::AudioReceiveStream( |
| kRtpExtensionAbsoluteSendTime, extension.id); |
| RTC_DCHECK(registered); |
| } else if (extension.name == RtpExtension::kTransportSequenceNumber) { |
| - // TODO(holmer): Need to do something here or in DeliverRtp() to actually |
| - // handle audio packets with this header extension. |
| bool registered = rtp_header_parser_->RegisterRtpHeaderExtension( |
| kRtpExtensionTransportSequenceNumber, extension.id); |
| RTC_DCHECK(registered); |
| @@ -102,11 +117,20 @@ AudioReceiveStream::AudioReceiveStream( |
| RTC_NOTREACHED() << "Unsupported RTP extension."; |
| } |
| } |
| + if (config.combined_audio_video_bwe && UseSendSideBwe(config)) { |
| + channel_proxy_->SetCongestionControlObjects( |
|
the sun
2015/12/22 00:14:14
We are relying on the underlying channel *only* be
stefan-webrtc
2016/01/07 13:43:41
Yes, but the packet router is needed both when sen
|
| + nullptr, nullptr, congestion_controller->packet_router()); |
| + } |
| } |
| AudioReceiveStream::~AudioReceiveStream() { |
| RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| LOG(LS_INFO) << "~AudioReceiveStream: " << config_.ToString(); |
| + if (config_.combined_audio_video_bwe) { |
| + if (UseSendSideBwe(config_)) |
| + channel_proxy_->SetCongestionControlObjects(nullptr, nullptr, nullptr); |
|
the sun
2015/12/22 00:14:13
Can we always set the CC obj nullptrs? Make the co
stefan-webrtc
2016/01/07 13:43:41
Yes, good suggestion.
|
| + remote_bitrate_estimator_->RemoveStream(config_.rtp.remote_ssrc); |
| + } |
| } |
| void AudioReceiveStream::Start() { |
| @@ -141,10 +165,12 @@ bool AudioReceiveStream::DeliverRtp(const uint8_t* packet, |
| return false; |
| } |
| - // Only forward if the parsed header has absolute sender time. RTP timestamps |
| - // may have different rates for audio and video and shouldn't be mixed. |
| + // Only forward if the parsed header has one of the headers necessary for |
| + // bandwidth estimation. RTP timestamps has different rates for audio and |
| + // video and shouldn't be mixed. |
| if (config_.combined_audio_video_bwe && |
| - header.extension.hasAbsoluteSendTime) { |
| + (header.extension.hasAbsoluteSendTime || |
| + header.extension.hasTransportSequenceNumber)) { |
|
the sun
2015/12/22 00:14:13
No need to logic-and with confg_.rtp.transport_cc
stefan-webrtc
2016/01/07 13:43:41
I think it's a matter of interpretation. Should au
|
| int64_t arrival_time_ms = TickTime::MillisecondTimestamp(); |
| if (packet_time.timestamp >= 0) |
| arrival_time_ms = (packet_time.timestamp + 500) / 1000; |