| Index: media/cast/sender/video_sender.cc
|
| diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc
|
| index f0e3a1440c6c32dc3d59cc7344ee49cf68c6d330..4cd71bd46ce446b11c4087e5cbf4192ec0ecc82f 100644
|
| --- a/media/cast/sender/video_sender.cc
|
| +++ b/media/cast/sender/video_sender.cc
|
| @@ -126,7 +126,7 @@ void VideoSender::InsertRawVideoFrame(
|
| "timestamp", capture_time.ToInternalValue(),
|
| "rtp_timestamp", rtp_timestamp);
|
|
|
| - if (AreTooManyFramesInFlight()) {
|
| + if (ShouldDropNextFrame(capture_time)) {
|
| VLOG(1) << "Dropping frame due to too many frames currently in-flight.";
|
| return;
|
| }
|
| @@ -174,6 +174,8 @@ void VideoSender::SendEncodedVideoFrame(
|
| // Also, schedule the periodic frame re-send checks.
|
| if (is_first_frame_to_be_sent) {
|
| latest_acked_frame_id_ = frame_id - 1;
|
| + frame_id_to_rtp_timestamp_[latest_acked_frame_id_ & 0xff] =
|
| + encoded_frame->rtp_timestamp;
|
| ScheduleNextResendCheck();
|
| }
|
|
|
| @@ -338,18 +340,35 @@ void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) {
|
| }
|
| }
|
|
|
| -bool VideoSender::AreTooManyFramesInFlight() const {
|
| +bool VideoSender::ShouldDropNextFrame(base::TimeTicks capture_time) const {
|
| DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
|
| - int frames_in_flight = frames_in_encoder_;
|
| + int frames_in_flight = 0;
|
| + base::TimeDelta duration_in_flight;
|
| if (!last_send_time_.is_null()) {
|
| - frames_in_flight +=
|
| + 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;
|
| + base::TimeTicks oldest_unacked_capture_time;
|
| + if (rtp_timestamp_helper_.EstimateTimeTicks(
|
| + frame_id_to_rtp_timestamp_[oldest_unacked_frame_id & 0xff],
|
| + &oldest_unacked_capture_time)) {
|
| + duration_in_flight = capture_time - oldest_unacked_capture_time;
|
| + }
|
| + }
|
| }
|
| + 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_;
|
| - return frames_in_flight >= max_unacked_frames_;
|
| + << "; 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_;
|
| }
|
|
|
| void VideoSender::ResendForKickstart() {
|
|
|