| Index: media/cast/sender/audio_sender.cc
|
| diff --git a/media/cast/sender/audio_sender.cc b/media/cast/sender/audio_sender.cc
|
| index 4bf93b30cd615ce90f4b061070fcb2955283af8e..2d1790481e8fa752d59eb1469b261427c668123f 100644
|
| --- a/media/cast/sender/audio_sender.cc
|
| +++ b/media/cast/sender/audio_sender.cc
|
| @@ -90,7 +90,7 @@ void AudioSender::InsertAudio(scoped_ptr<AudioBus> audio_bus,
|
| }
|
| DCHECK(audio_encoder_.get()) << "Invalid internal state";
|
|
|
| - if (AreTooManyFramesInFlight()) {
|
| + if (ShouldDropNextFrame(recorded_time)) {
|
| VLOG(1) << "Dropping frame due to too many frames currently in-flight.";
|
| return;
|
| }
|
| @@ -112,6 +112,8 @@ void AudioSender::SendEncodedAudioFrame(
|
| // 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();
|
| }
|
|
|
| @@ -244,17 +246,32 @@ void AudioSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) {
|
| }
|
| }
|
|
|
| -bool AudioSender::AreTooManyFramesInFlight() const {
|
| +bool AudioSender::ShouldDropNextFrame(base::TimeTicks capture_time) const {
|
| DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
|
| int frames_in_flight = 0;
|
| + int32 rtp_duration_in_flight = 0;
|
| if (!last_send_time_.is_null()) {
|
| - frames_in_flight +=
|
| + frames_in_flight =
|
| static_cast<int32>(last_sent_frame_id_ - latest_acked_frame_id_);
|
| + uint32 estimated_rtp_timestamp;
|
| + if (frames_in_flight > 0 &&
|
| + rtp_timestamp_helper_.EstimateRtpTimestamp(capture_time,
|
| + &estimated_rtp_timestamp)) {
|
| + const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1;
|
| + rtp_duration_in_flight = static_cast<int32>(
|
| + estimated_rtp_timestamp -
|
| + frame_id_to_rtp_timestamp_[oldest_unacked_frame_id & 0xff]);
|
| + }
|
| }
|
| VLOG(2) << frames_in_flight
|
| << " frames in flight; last sent: " << last_sent_frame_id_
|
| - << " latest acked: " << latest_acked_frame_id_;
|
| - return frames_in_flight >= max_unacked_frames_;
|
| + << "; latest acked: " << latest_acked_frame_id_
|
| + << "; duration in flight: "
|
| + << (max_unacked_rtp_delta_ > 0 ?
|
| + 100 * rtp_duration_in_flight / max_unacked_rtp_delta_ :
|
| + kint32max) << "%";
|
| + return frames_in_flight >= max_unacked_frames_ ||
|
| + rtp_duration_in_flight >= max_unacked_rtp_delta_;
|
| }
|
|
|
| void AudioSender::ResendForKickstart() {
|
|
|