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

Side by Side Diff: media/cast/video_receiver/video_receiver.cc

Issue 289483003: Cast: Only ACK decodable frames (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/video_receiver/video_receiver.h" 5 #include "media/cast/video_receiver/video_receiver.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void VideoReceiver::EmitAvailableEncodedFrames() { 148 void VideoReceiver::EmitAvailableEncodedFrames() {
149 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 149 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
150 150
151 while (!frame_request_queue_.empty()) { 151 while (!frame_request_queue_.empty()) {
152 // Attempt to peek at the next completed frame from the |framer_|. 152 // Attempt to peek at the next completed frame from the |framer_|.
153 // TODO(miu): We should only be peeking at the metadata, and not copying the 153 // TODO(miu): We should only be peeking at the metadata, and not copying the
154 // payload yet! Or, at least, peek using a StringPiece instead of a copy. 154 // payload yet! Or, at least, peek using a StringPiece instead of a copy.
155 scoped_ptr<transport::EncodedVideoFrame> encoded_frame( 155 scoped_ptr<transport::EncodedVideoFrame> encoded_frame(
156 new transport::EncodedVideoFrame()); 156 new transport::EncodedVideoFrame());
157 bool is_consecutively_next_frame = false; 157 bool is_consecutively_next_frame = false;
158 bool have_multiple_complete_frames = false;
miu 2014/05/16 19:45:25 Please make these changes identically in AudioRece
hubbe 2014/05/16 20:50:58 Done.
159
158 if (!framer_.GetEncodedVideoFrame(encoded_frame.get(), 160 if (!framer_.GetEncodedVideoFrame(encoded_frame.get(),
159 &is_consecutively_next_frame)) { 161 &is_consecutively_next_frame,
162 &have_multiple_complete_frames)) {
160 VLOG(1) << "Wait for more video packets to produce a completed frame."; 163 VLOG(1) << "Wait for more video packets to produce a completed frame.";
161 return; // OnReceivedPayloadData() will invoke this method in the future. 164 return; // OnReceivedPayloadData() will invoke this method in the future.
162 } 165 }
163 166
167 const base::TimeTicks now = cast_environment_->Clock()->NowTicks();
168 const base::TimeTicks playout_time =
169 GetPlayoutTime(now, encoded_frame->rtp_timestamp);
170
171 // If we have multiple decodable frames, and the current frame is
172 // too old, then skip it and decode the next frame instead.
173 if (have_multiple_complete_frames && now > playout_time) {
174 framer_.ReleaseFrame(encoded_frame->frame_id);
175 continue;
176 }
177
164 // If |framer_| has a frame ready that is out of sequence, examine the 178 // If |framer_| has a frame ready that is out of sequence, examine the
165 // playout time to determine whether it's acceptable to continue, thereby 179 // playout time to determine whether it's acceptable to continue, thereby
166 // skipping one or more frames. Skip if the missing frame wouldn't complete 180 // skipping one or more frames. Skip if the missing frame wouldn't complete
167 // playing before the start of playback of the available frame. 181 // playing before the start of playback of the available frame.
168 const base::TimeTicks now = cast_environment_->Clock()->NowTicks();
169 const base::TimeTicks playout_time =
170 GetPlayoutTime(now, encoded_frame->rtp_timestamp);
171 if (!is_consecutively_next_frame) { 182 if (!is_consecutively_next_frame) {
172 // TODO(miu): Also account for expected decode time here? 183 // TODO(miu): Also account for expected decode time here?
173 const base::TimeTicks earliest_possible_end_time_of_missing_frame = 184 const base::TimeTicks earliest_possible_end_time_of_missing_frame =
174 now + expected_frame_duration_; 185 now + expected_frame_duration_;
175 if (earliest_possible_end_time_of_missing_frame < playout_time) { 186 if (earliest_possible_end_time_of_missing_frame < playout_time) {
176 VLOG(1) << "Wait for next consecutive frame instead of skipping."; 187 VLOG(1) << "Wait for next consecutive frame instead of skipping.";
177 if (!is_waiting_for_consecutive_frame_) { 188 if (!is_waiting_for_consecutive_frame_) {
178 is_waiting_for_consecutive_frame_ = true; 189 is_waiting_for_consecutive_frame_ = true;
179 cast_environment_->PostDelayedTask( 190 cast_environment_->PostDelayedTask(
180 CastEnvironment::MAIN, 191 CastEnvironment::MAIN,
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } 421 }
411 422
412 void VideoReceiver::SendNextRtcpReport() { 423 void VideoReceiver::SendNextRtcpReport() {
413 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 424 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
414 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL); 425 rtcp_.SendRtcpFromRtpReceiver(NULL, NULL);
415 ScheduleNextRtcpReport(); 426 ScheduleNextRtcpReport();
416 } 427 }
417 428
418 } // namespace cast 429 } // namespace cast
419 } // namespace media 430 } // namespace media
OLDNEW
« media/cast/framer/framer_unittest.cc ('K') | « media/cast/framer/framer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698