Bug 1595479 - Plumb RtcpEventObserver through Channel and VideoReceiveStream; r=ng

Differential Revision: https://phabricator.services.mozilla.com/D57859

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dan Minor 2019-12-20 20:53:56 +00:00
parent f3e464071c
commit 0cd4afab2d
6 changed files with 42 additions and 2 deletions

View File

@ -226,6 +226,10 @@ class VideoReceiveStream {
// Target delay in milliseconds. A positive value indicates this stream is
// used for streaming instead of a real-time call.
int target_delay_ms = 0;
// Called when a RTCP bye or timeout occurs. 'nullptr' disables the
// callback.
RtcpEventObserver* rtcp_event_observer = nullptr;
};
// Starts stream activity.

View File

@ -51,6 +51,7 @@ constexpr int kPacketBufferMaxSixe = 2048;
std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
ReceiveStatistics* receive_statistics,
Transport* outgoing_transport,
RtcpEventObserver* rtcp_event_observer,
RtcpRttStats* rtt_stats,
RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
TransportSequenceNumberAllocator* transport_sequence_number_allocator) {
@ -59,6 +60,7 @@ std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
configuration.receiver_only = true;
configuration.receive_statistics = receive_statistics;
configuration.outgoing_transport = outgoing_transport;
configuration.event_callback = rtcp_event_observer;
configuration.intra_frame_callback = nullptr;
configuration.rtt_stats = rtt_stats;
configuration.rtcp_packet_type_counter_observer =
@ -108,6 +110,7 @@ RtpVideoStreamReceiver::RtpVideoStreamReceiver(
last_packet_log_ms_(-1),
rtp_rtcp_(CreateRtpRtcpModule(rtp_receive_statistics_,
transport,
config->rtcp_event_observer,
rtt_stats,
receive_stats_proxy,
packet_router)),

View File

@ -446,10 +446,10 @@ class RtpPacketSenderProxy : public RtpPacketSender {
RtpPacketSender* rtp_packet_sender_ RTC_GUARDED_BY(&crit_);
};
class VoERtcpObserver : public RtcpBandwidthObserver {
class VoERtcpObserver : public RtcpBandwidthObserver, public RtcpEventObserver {
public:
explicit VoERtcpObserver(Channel* owner)
: owner_(owner), bandwidth_observer_(nullptr) {}
: owner_(owner), bandwidth_observer_(nullptr), event_observer_(nullptr) {}
virtual ~VoERtcpObserver() {}
void SetBandwidthObserver(RtcpBandwidthObserver* bandwidth_observer) {
@ -457,6 +457,11 @@ class VoERtcpObserver : public RtcpBandwidthObserver {
bandwidth_observer_ = bandwidth_observer;
}
void SetEventObserver(RtcpEventObserver* event_observer) {
rtc::CritScope lock(&crit_);
event_observer_ = event_observer;
}
void OnReceivedEstimatedBitrate(uint32_t bitrate) override {
rtc::CritScope lock(&crit_);
if (bandwidth_observer_) {
@ -513,12 +518,27 @@ class VoERtcpObserver : public RtcpBandwidthObserver {
owner_->OnIncomingReceiverReports(report_blocks, rtt, now_ms);
}
void OnRtcpBye() override {
rtc::CritScope lock(&crit_);
if (event_observer_) {
event_observer_->OnRtcpBye();
}
}
void OnRtcpTimeout() override {
rtc::CritScope lock(&crit_);
if (event_observer_) {
event_observer_->OnRtcpTimeout();
}
}
private:
Channel* owner_;
// Maps remote side ssrc to extended highest sequence number received.
std::map<uint32_t, uint32_t> extended_max_sequence_number_;
rtc::CriticalSection crit_;
RtcpBandwidthObserver* bandwidth_observer_ RTC_GUARDED_BY(crit_);
RtcpEventObserver* event_observer_ RTC_GUARDED_BY(crit_);
};
class Channel::ProcessAndEncodeAudioTask : public rtc::QueuedTask {
@ -935,6 +955,7 @@ Channel::Channel(int32_t channelId,
configuration.overhead_observer = this;
configuration.receive_statistics = rtp_receive_statistics_.get();
configuration.bandwidth_callback = rtcp_observer_.get();
configuration.event_callback = rtcp_observer_.get();
if (pacing_enabled_) {
configuration.paced_sender = rtp_packet_sender_proxy_.get();
configuration.transport_sequence_number_allocator =
@ -1218,6 +1239,10 @@ void Channel::OnRecoverableUplinkPacketLossRate(
});
}
void Channel::SetRtcpEventObserver(RtcpEventObserver* observer) {
rtcp_observer_->SetEventObserver(observer);
}
void Channel::OnUplinkPacketLossRate(float packet_loss_rate) {
if (use_twcc_plr_for_ana_)
return;

View File

@ -360,6 +360,8 @@ class Channel
return 0;
}
void SetRtcpEventObserver(RtcpEventObserver* observer);
private:
class ProcessAndEncodeAudioTask;

View File

@ -409,6 +409,11 @@ void ChannelProxy::SetRtpPacketObserver(RtpPacketObserver* observer) {
channel()->SetRtpPacketObserver(observer);
}
void ChannelProxy::SetRtcpEventObserver(RtcpEventObserver* observer) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
channel()->SetRtcpEventObserver(observer);
}
Channel* ChannelProxy::channel() const {
RTC_DCHECK(channel_owner_.channel());
return channel_owner_.channel();

View File

@ -137,6 +137,7 @@ class ChannelProxy : public RtpPacketSinkInterface {
virtual std::vector<webrtc::RtpSource> GetSources() const;
virtual void SetRtpPacketObserver(RtpPacketObserver* observer);
void SetRtcpEventObserver(RtcpEventObserver* observer);
private:
Channel* channel() const;