summaryrefslogtreecommitdiffstats
path: root/media/cast/audio_receiver/audio_receiver.cc
diff options
context:
space:
mode:
authorhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 12:17:52 +0000
committerhubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-24 12:17:52 +0000
commitb6e2be31d71cbcb78d87ceae277b2bf4279afc95 (patch)
treeb4853c4a0a4b9ed3c9b7e7095ddce3c05d024cac /media/cast/audio_receiver/audio_receiver.cc
parent8304f61a936e26b0be93e5b64dbafced34a528b4 (diff)
downloadchromium_src-b6e2be31d71cbcb78d87ceae277b2bf4279afc95.zip
chromium_src-b6e2be31d71cbcb78d87ceae277b2bf4279afc95.tar.gz
chromium_src-b6e2be31d71cbcb78d87ceae277b2bf4279afc95.tar.bz2
Cast: Only ACK decododable frames
Also, add an optimization to not decode frames if we are behind and multiple frames are currently decodable. Review URL: https://codereview.chromium.org/289483003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/audio_receiver/audio_receiver.cc')
-rw-r--r--media/cast/audio_receiver/audio_receiver.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/media/cast/audio_receiver/audio_receiver.cc b/media/cast/audio_receiver/audio_receiver.cc
index ab06c53..4d6c635 100644
--- a/media/cast/audio_receiver/audio_receiver.cc
+++ b/media/cast/audio_receiver/audio_receiver.cc
@@ -169,19 +169,29 @@ void AudioReceiver::EmitAvailableEncodedFrames() {
scoped_ptr<transport::EncodedFrame> encoded_frame(
new transport::EncodedFrame());
bool is_consecutively_next_frame = false;
- if (!framer_.GetEncodedAudioFrame(encoded_frame.get(),
- &is_consecutively_next_frame)) {
+ bool have_multiple_complete_frames = false;
+ if (!framer_.GetEncodedFrame(encoded_frame.get(),
+ &is_consecutively_next_frame,
+ &have_multiple_complete_frames)) {
VLOG(1) << "Wait for more audio packets to produce a completed frame.";
return; // OnReceivedPayloadData() will invoke this method in the future.
}
+ const base::TimeTicks now = cast_environment_->Clock()->NowTicks();
+ const base::TimeTicks playout_time =
+ GetPlayoutTime(now, encoded_frame->rtp_timestamp);
+
+ // If we have multiple decodable frames, and the current frame is
+ // too old, then skip it and decode the next frame instead.
+ if (have_multiple_complete_frames && now > playout_time) {
+ framer_.ReleaseFrame(encoded_frame->frame_id);
+ continue;
+ }
+
// If |framer_| has a frame ready that is out of sequence, examine the
// playout time to determine whether it's acceptable to continue, thereby
// skipping one or more frames. Skip if the missing frame wouldn't complete
// playing before the start of playback of the available frame.
- const base::TimeTicks now = cast_environment_->Clock()->NowTicks();
- const base::TimeTicks playout_time =
- GetPlayoutTime(now, encoded_frame->rtp_timestamp);
if (!is_consecutively_next_frame) {
// TODO(miu): Also account for expected decode time here?
const base::TimeTicks earliest_possible_end_time_of_missing_frame =