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

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

Issue 502333002: [Cast] In Audio/VideoSender, drop frames when too-long a duration is in-flight. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Based on TimeDelta rather than RTP delta. Created 6 years, 4 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
« no previous file with comments | « media/cast/sender/audio_sender.h ('k') | media/cast/sender/frame_sender.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..08f99c4c605941b28f41890d360abfae3b9e74d8 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;
hubbe 2014/08/28 17:34:45 why don't we save the reference time here instead?
miu 2014/08/28 18:57:58 We never save the reference time (see line 126 bel
hubbe 2014/08/28 19:03:10 I think another map would be better than translati
miu 2014/08/28 20:37:15 Done. This led me to move a few "common members"
ScheduleNextResendCheck();
}
@@ -244,17 +246,33 @@ 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;
+ 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;
+ }
+ }
}
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: "
+ << 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 AudioSender::ResendForKickstart() {
« no previous file with comments | « media/cast/sender/audio_sender.h ('k') | media/cast/sender/frame_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698