Index: media/cast/sender/frame_sender.cc |
diff --git a/media/cast/sender/frame_sender.cc b/media/cast/sender/frame_sender.cc |
index f338dd9b2b065ce91a7ea98332711478916ff16f..c82882cd41eca5a9c0c755b5a106d21b2eed45a0 100644 |
--- a/media/cast/sender/frame_sender.cc |
+++ b/media/cast/sender/frame_sender.cc |
@@ -23,6 +23,7 @@ FrameSender::FrameSender(scoped_refptr<CastEnvironment> cast_environment, |
rtt_available_(false), |
rtcp_interval_(rtcp_interval), |
max_frame_rate_(max_frame_rate), |
+ frames_in_encoder_(0), |
num_aggressive_rtcp_reports_sent_(0), |
last_sent_frame_id_(0), |
latest_acked_frame_id_(0), |
@@ -158,5 +159,32 @@ RtpTimestamp FrameSender::GetRecordedRtpTimestamp(uint32 frame_id) const { |
return frame_rtp_timestamps_[frame_id % arraysize(frame_rtp_timestamps_)]; |
} |
+bool FrameSender::ShouldDropNextFrame(base::TimeTicks capture_time) const { |
+ DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
+ int frames_in_flight = 0; |
+ base::TimeDelta duration_in_flight; |
+ if (!last_send_time_.is_null()) { |
+ frames_in_flight = |
+ static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_); |
+ if (frames_in_flight > 0) { |
+ const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; |
+ duration_in_flight = |
+ capture_time - GetRecordedReferenceTime(oldest_unacked_frame_id); |
+ } |
+ } |
+ frames_in_flight += frames_in_encoder_; |
+ VLOG(2) << frames_in_flight |
+ << " frames in flight; last sent: " << last_sent_frame_id_ |
+ << "; latest acked: " << latest_acked_frame_id_ |
+ << "; frames in encoder: " << frames_in_encoder_ |
+ << "; duration in flight: " |
+ << duration_in_flight.InMicroseconds() << " usec (" |
+ << (target_playout_delay_ > base::TimeDelta() ? |
+ 100 * duration_in_flight / target_playout_delay_ : |
+ kint64max) << "%)"; |
+ return frames_in_flight >= max_unacked_frames_ || |
+ duration_in_flight >= target_playout_delay_; |
Alpha Left Google
2014/09/05 20:02:07
What's the reason of choosing "duration_in_flight
miu
2014/09/05 20:40:27
You can ignore this:
1. hubbe@ has already moved
|
+} |
+ |
} // namespace cast |
} // namespace media |