| Index: media/cast/rtcp/rtcp.cc
|
| diff --git a/media/cast/rtcp/rtcp.cc b/media/cast/rtcp/rtcp.cc
|
| index a1720ffe1a2e433c9026d21c6482df8e79e6bb86..263a65ced258b65a2d8fda7369960eca7e9a4b27 100644
|
| --- a/media/cast/rtcp/rtcp.cc
|
| +++ b/media/cast/rtcp/rtcp.cc
|
| @@ -4,10 +4,10 @@
|
|
|
| #include "media/cast/rtcp/rtcp.h"
|
|
|
| -#include "base/debug/trace_event.h"
|
| #include "base/rand_util.h"
|
| #include "media/cast/cast_config.h"
|
| #include "media/cast/cast_defines.h"
|
| +#include "media/cast/cast_environment.h"
|
| #include "media/cast/rtcp/rtcp_defines.h"
|
| #include "media/cast/rtcp/rtcp_receiver.h"
|
| #include "media/cast/rtcp/rtcp_sender.h"
|
| @@ -84,7 +84,7 @@ class LocalRtcpReceiverFeedback : public RtcpReceiverFeedback {
|
| Rtcp* rtcp_;
|
| };
|
|
|
| -Rtcp::Rtcp(base::TickClock* clock,
|
| +Rtcp::Rtcp(scoped_refptr<CastEnvironment> cast_environment,
|
| RtcpSenderFeedback* sender_feedback,
|
| PacedPacketSender* paced_packet_sender,
|
| RtpSenderStatistics* rtp_sender_statistics,
|
| @@ -102,7 +102,8 @@ Rtcp::Rtcp(base::TickClock* clock,
|
| rtp_receiver_statistics_(rtp_receiver_statistics),
|
| receiver_feedback_(new LocalRtcpReceiverFeedback(this)),
|
| rtt_feedback_(new LocalRtcpRttFeedback(this)),
|
| - rtcp_sender_(new RtcpSender(paced_packet_sender, local_ssrc, c_name)),
|
| + rtcp_sender_(new RtcpSender(cast_environment, paced_packet_sender,
|
| + local_ssrc, c_name)),
|
| last_report_sent_(0),
|
| last_report_received_(0),
|
| last_received_rtp_timestamp_(0),
|
| @@ -110,8 +111,9 @@ Rtcp::Rtcp(base::TickClock* clock,
|
| last_received_ntp_fraction_(0),
|
| min_rtt_(base::TimeDelta::FromMilliseconds(kMaxRttMs)),
|
| number_of_rtt_in_avg_(0),
|
| - clock_(clock) {
|
| - rtcp_receiver_.reset(new RtcpReceiver(sender_feedback,
|
| + cast_environment_(cast_environment) {
|
| + rtcp_receiver_.reset(new RtcpReceiver(cast_environment,
|
| + sender_feedback,
|
| receiver_feedback_.get(),
|
| rtt_feedback_.get(),
|
| local_ssrc));
|
| @@ -164,7 +166,7 @@ void Rtcp::IncomingRtcpPacket(const uint8* rtcp_buffer, size_t length) {
|
|
|
| void Rtcp::SendRtcpCast(const RtcpCastMessage& cast_message) {
|
| uint32 packet_type_flags = 0;
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
|
|
| if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) {
|
| if (sending_media_) {
|
| @@ -175,12 +177,15 @@ void Rtcp::SendRtcpCast(const RtcpCastMessage& cast_message) {
|
| }
|
| packet_type_flags |= RtcpSender::kRtcpCast;
|
|
|
| + cast_environment_->Logging()->InsertGenericEvent(kAckSent,
|
| + cast_message.ack_frame_id_);
|
| +
|
| SendRtcp(now, packet_type_flags, 0, &cast_message);
|
| }
|
|
|
| void Rtcp::SendRtcpPli(uint32 pli_remote_ssrc) {
|
| uint32 packet_type_flags = 0;
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
|
|
| if (rtcp_mode_ == kRtcpCompound || now >= next_time_to_send_rtcp_) {
|
| if (sending_media_) {
|
| @@ -195,7 +200,7 @@ void Rtcp::SendRtcpPli(uint32 pli_remote_ssrc) {
|
|
|
| void Rtcp::SendRtcpReport(uint32 media_ssrc) {
|
| uint32 packet_type_flags;
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
| if (sending_media_) {
|
| packet_type_flags = RtcpSender::kRtcpSr;
|
| } else {
|
| @@ -255,6 +260,11 @@ void Rtcp::SendRtcp(const base::TimeTicks& now,
|
| &report_block.cumulative_lost,
|
| &report_block.extended_high_sequence_number,
|
| &report_block.jitter);
|
| + cast_environment_->Logging()->InsertGenericEvent(kJitterMs,
|
| + report_block.jitter);
|
| + cast_environment_->Logging()->InsertGenericEvent(kPacketLoss,
|
| + report_block.fraction_lost);
|
| +
|
| }
|
|
|
| report_block.last_sr = last_report_received_;
|
| @@ -291,7 +301,7 @@ void Rtcp::SendRtcp(const base::TimeTicks& now,
|
| void Rtcp::OnReceivedNtp(uint32 ntp_seconds, uint32 ntp_fraction) {
|
| last_report_received_ = (ntp_seconds << 16) + (ntp_fraction >> 16);
|
|
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
| time_last_report_received_ = now;
|
| }
|
|
|
| @@ -304,7 +314,7 @@ void Rtcp::OnReceivedLipSyncInfo(uint32 rtp_timestamp,
|
| }
|
|
|
| void Rtcp::OnReceivedSendReportRequest() {
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
|
|
| // Trigger a new RTCP report at next timer.
|
| next_time_to_send_rtcp_ = now;
|
| @@ -347,7 +357,8 @@ void Rtcp::OnReceivedDelaySinceLastReport(uint32 receivers_ssrc,
|
| if (last_report_sent_ != last_report) return; // Feedback on another report.
|
| if (time_last_report_sent_.is_null()) return;
|
|
|
| - base::TimeDelta sender_delay = clock_->NowTicks() - time_last_report_sent_;
|
| + base::TimeDelta sender_delay = cast_environment_->Clock()->NowTicks()
|
| + - time_last_report_sent_;
|
| UpdateRtt(sender_delay, ConvertFromNtpDiff(delay_since_last_report));
|
| }
|
|
|
| @@ -367,7 +378,6 @@ void Rtcp::UpdateRtt(const base::TimeDelta& sender_delay,
|
| avg_rtt_ms_ = rtt.InMilliseconds();
|
| }
|
| number_of_rtt_in_avg_++;
|
| - TRACE_COUNTER_ID1("cast_rtcp", "RTT", local_ssrc_, rtt.InMilliseconds());
|
| }
|
|
|
| bool Rtcp::Rtt(base::TimeDelta* rtt,
|
| @@ -379,7 +389,9 @@ bool Rtcp::Rtt(base::TimeDelta* rtt,
|
| DCHECK(min_rtt) << "Invalid argument";
|
| DCHECK(max_rtt) << "Invalid argument";
|
|
|
| - if (number_of_rtt_in_avg_ == 0) return false;
|
| + if (number_of_rtt_in_avg_ == 0) return false;
|
| + cast_environment_->Logging()->InsertGenericEvent(kRttMs,
|
| + rtt->InMilliseconds());
|
|
|
| *rtt = rtt_;
|
| *avg_rtt = base::TimeDelta::FromMilliseconds(avg_rtt_ms_);
|
| @@ -410,7 +422,7 @@ void Rtcp::UpdateNextTimeToSendRtcp() {
|
| base::TimeDelta time_to_next = (rtcp_interval_ / 2) +
|
| (rtcp_interval_ * random / 1000);
|
|
|
| - base::TimeTicks now = clock_->NowTicks();
|
| + base::TimeTicks now = cast_environment_->Clock()->NowTicks();
|
| next_time_to_send_rtcp_ = now + time_to_next;
|
| }
|
|
|
|
|