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

Side by Side Diff: media/cast/receiver/frame_receiver.cc

Issue 339743002: Cast: Make vp8 3-buffer mode work (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor test fix Created 6 years, 3 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
« no previous file with comments | « media/cast/net/rtp/framer.cc ('k') | media/cast/sender/video_encoder_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/receiver/frame_receiver.h" 5 #include "media/cast/receiver/frame_receiver.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/big_endian.h" 9 #include "base/big_endian.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (have_multiple_complete_frames && now > playout_time) { 209 if (have_multiple_complete_frames && now > playout_time) {
210 framer_.ReleaseFrame(encoded_frame->frame_id); 210 framer_.ReleaseFrame(encoded_frame->frame_id);
211 continue; 211 continue;
212 } 212 }
213 213
214 // If |framer_| has a frame ready that is out of sequence, examine the 214 // If |framer_| has a frame ready that is out of sequence, examine the
215 // playout time to determine whether it's acceptable to continue, thereby 215 // playout time to determine whether it's acceptable to continue, thereby
216 // skipping one or more frames. Skip if the missing frame wouldn't complete 216 // skipping one or more frames. Skip if the missing frame wouldn't complete
217 // playing before the start of playback of the available frame. 217 // playing before the start of playback of the available frame.
218 if (!is_consecutively_next_frame) { 218 if (!is_consecutively_next_frame) {
219 // TODO(miu): Also account for expected decode time here? 219 // This assumes that decoding takes as long as playing, which might
220 // not be true.
220 const base::TimeTicks earliest_possible_end_time_of_missing_frame = 221 const base::TimeTicks earliest_possible_end_time_of_missing_frame =
221 now + expected_frame_duration_; 222 now + expected_frame_duration_ * 2;
222 if (earliest_possible_end_time_of_missing_frame < playout_time) { 223 if (earliest_possible_end_time_of_missing_frame < playout_time) {
223 VLOG(1) << "Wait for next consecutive frame instead of skipping."; 224 VLOG(1) << "Wait for next consecutive frame instead of skipping.";
224 if (!is_waiting_for_consecutive_frame_) { 225 if (!is_waiting_for_consecutive_frame_) {
225 is_waiting_for_consecutive_frame_ = true; 226 is_waiting_for_consecutive_frame_ = true;
226 cast_environment_->PostDelayedTask( 227 cast_environment_->PostDelayedTask(
227 CastEnvironment::MAIN, 228 CastEnvironment::MAIN,
228 FROM_HERE, 229 FROM_HERE,
229 base::Bind(&FrameReceiver::EmitAvailableEncodedFramesAfterWaiting, 230 base::Bind(&FrameReceiver::EmitAvailableEncodedFramesAfterWaiting,
230 weak_factory_.GetWeakPtr()), 231 weak_factory_.GetWeakPtr()),
231 playout_time - now); 232 playout_time - now);
232 } 233 }
233 return; 234 return;
234 } 235 }
235 } 236 }
236 237
238 // At this point, we have the complete next frame, or a decodable
239 // frame from somewhere later in the stream, AND we have given up
240 // on waiting for any frames in between, so now we can ACK the frame.
241 framer_.AckFrame(encoded_frame->frame_id);
242
237 // Decrypt the payload data in the frame, if crypto is being used. 243 // Decrypt the payload data in the frame, if crypto is being used.
238 if (decryptor_.is_activated()) { 244 if (decryptor_.is_activated()) {
239 std::string decrypted_data; 245 std::string decrypted_data;
240 if (!decryptor_.Decrypt(encoded_frame->frame_id, 246 if (!decryptor_.Decrypt(encoded_frame->frame_id,
241 encoded_frame->data, 247 encoded_frame->data,
242 &decrypted_data)) { 248 &decrypted_data)) {
243 // Decryption failed. Give up on this frame. 249 // Decryption failed. Give up on this frame.
244 framer_.ReleaseFrame(encoded_frame->frame_id); 250 framer_.ReleaseFrame(encoded_frame->frame_id);
245 continue; 251 continue;
246 } 252 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 335 }
330 336
331 void FrameReceiver::SendNextRtcpReport() { 337 void FrameReceiver::SendNextRtcpReport() {
332 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); 338 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN));
333 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_); 339 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_);
334 ScheduleNextRtcpReport(); 340 ScheduleNextRtcpReport();
335 } 341 }
336 342
337 } // namespace cast 343 } // namespace cast
338 } // namespace media 344 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/net/rtp/framer.cc ('k') | media/cast/sender/video_encoder_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698