| Index: webrtc/audio/audio_send_stream.cc
|
| diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc
|
| index d8bc84858a6a3e33936a89dd1dfa6c6c173d68b9..be7672d7cbb6e55a16d9f77649fa39bf19919867 100644
|
| --- a/webrtc/audio/audio_send_stream.cc
|
| +++ b/webrtc/audio/audio_send_stream.cc
|
| @@ -11,6 +11,8 @@
|
| #include "webrtc/audio/audio_send_stream.h"
|
|
|
| #include <string>
|
| +#include <vector>
|
| +#include <utility>
|
|
|
| #include "webrtc/audio/audio_state.h"
|
| #include "webrtc/audio/conversion.h"
|
| @@ -18,6 +20,7 @@
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/base/event.h"
|
| #include "webrtc/base/logging.h"
|
| +#include "webrtc/base/mod_ops.h"
|
| #include "webrtc/base/task_queue.h"
|
| #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
| #include "webrtc/modules/pacing/paced_sender.h"
|
| @@ -76,6 +79,7 @@ AudioSendStream::AudioSendStream(
|
| config_.rtp.nack.rtp_history_ms / 20);
|
|
|
| channel_proxy_->RegisterExternalTransport(config.send_transport);
|
| + congestion_controller_->RegisterTransportFeedbackAdapterObserver(this);
|
|
|
| for (const auto& extension : config.rtp.extensions) {
|
| if (extension.uri == RtpExtension::kAudioLevelUri) {
|
| @@ -95,6 +99,7 @@ AudioSendStream::AudioSendStream(
|
| AudioSendStream::~AudioSendStream() {
|
| RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| LOG(LS_INFO) << "~AudioSendStream: " << config_.ToString();
|
| + congestion_controller_->DeRegisterTransportFeedbackAdapterObserver(this);
|
| channel_proxy_->DeRegisterExternalTransport();
|
| channel_proxy_->ResetCongestionControlObjects();
|
| channel_proxy_->SetRtcEventLog(nullptr);
|
| @@ -253,6 +258,51 @@ uint32_t AudioSendStream::OnBitrateUpdated(uint32_t bitrate_bps,
|
| return 0;
|
| }
|
|
|
| +void AudioSendStream::OnPacketAdded(uint32_t ssrc,
|
| + uint16_t transport_sequence_number) {
|
| + if (ssrc != config_.rtp.ssrc)
|
| + return;
|
| +
|
| + // To make sure everything happens on the same thread, we'll buffer
|
| + // this information and pass it down with the first OnTransportFeedback,
|
| + // which is called on the thread which channel_proxy_ mostly works on.
|
| + rtc::CritScope lock(&packets_sent_since_last_feedback_cs_);
|
| +
|
| + // Prevent unbounded memory consumption if OnTransportFeedback ends up
|
| + // never being called. Messages which are 0x8000 (or more) sequence numbers
|
| + // away from the newest message will end up having no effect, so we can
|
| + // discard those.
|
| + if (!packets_sent_since_last_feedback_.empty() &&
|
| + ForwardDiff(packets_sent_since_last_feedback_[0],
|
| + transport_sequence_number) >= 0x8000) {
|
| + // The element are ordered (circularly), so we can batch-remove. No need
|
| + // for binary search, because we expect to usually find the edge in the
|
| + // beginning of the container.
|
| + auto it = packets_sent_since_last_feedback_.cbegin();
|
| + while (it != packets_sent_since_last_feedback_.cend() &&
|
| + ForwardDiff(*it, transport_sequence_number) >= 0x8000) {
|
| + ++it;
|
| + }
|
| + packets_sent_since_last_feedback_.erase(
|
| + packets_sent_since_last_feedback_.cbegin(), it);
|
| + }
|
| +
|
| + packets_sent_since_last_feedback_.push_back(transport_sequence_number);
|
| +}
|
| +
|
| +void AudioSendStream::OnTransportFeedback(
|
| + const rtcp::TransportFeedback& feedback) {
|
| + RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| + std::vector<uint16_t> packets_sent_since_last_feedback;
|
| + {
|
| + rtc::CritScope lock(&packets_sent_since_last_feedback_cs_);
|
| + std::swap(packets_sent_since_last_feedback_,
|
| + packets_sent_since_last_feedback);
|
| + }
|
| + channel_proxy_->HandleTransportFeedback(
|
| + packets_sent_since_last_feedback, feedback);
|
| +}
|
| +
|
| const webrtc::AudioSendStream::Config& AudioSendStream::config() const {
|
| RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
| return config_;
|
|
|