Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Unified Diff: media/cast/sender/frame_sender.cc

Issue 545593002: [Cast] Track audio queued in encoder; account for it in ShouldDropNextFrame(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698