Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 if (have_multiple_complete_frames && now > playout_time) { | 210 if (have_multiple_complete_frames && now > playout_time) { |
| 211 framer_.ReleaseFrame(encoded_frame->frame_id); | 211 framer_.ReleaseFrame(encoded_frame->frame_id); |
| 212 continue; | 212 continue; |
| 213 } | 213 } |
| 214 | 214 |
| 215 // If |framer_| has a frame ready that is out of sequence, examine the | 215 // If |framer_| has a frame ready that is out of sequence, examine the |
| 216 // playout time to determine whether it's acceptable to continue, thereby | 216 // playout time to determine whether it's acceptable to continue, thereby |
| 217 // skipping one or more frames. Skip if the missing frame wouldn't complete | 217 // skipping one or more frames. Skip if the missing frame wouldn't complete |
| 218 // playing before the start of playback of the available frame. | 218 // playing before the start of playback of the available frame. |
| 219 if (!is_consecutively_next_frame) { | 219 if (!is_consecutively_next_frame) { |
| 220 // TODO(miu): Also account for expected decode time here? | 220 // This assumes that decoding takes as long as playing, which might |
| 221 // not be true. | |
| 221 const base::TimeTicks earliest_possible_end_time_of_missing_frame = | 222 const base::TimeTicks earliest_possible_end_time_of_missing_frame = |
| 222 now + expected_frame_duration_; | 223 now + expected_frame_duration_ * 2; |
| 223 if (earliest_possible_end_time_of_missing_frame < playout_time) { | 224 if (earliest_possible_end_time_of_missing_frame < playout_time) { |
| 224 VLOG(1) << "Wait for next consecutive frame instead of skipping."; | 225 VLOG(1) << "Wait for next consecutive frame instead of skipping."; |
| 225 if (!is_waiting_for_consecutive_frame_) { | 226 if (!is_waiting_for_consecutive_frame_) { |
| 226 is_waiting_for_consecutive_frame_ = true; | 227 is_waiting_for_consecutive_frame_ = true; |
| 227 cast_environment_->PostDelayedTask( | 228 cast_environment_->PostDelayedTask( |
| 228 CastEnvironment::MAIN, | 229 CastEnvironment::MAIN, |
| 229 FROM_HERE, | 230 FROM_HERE, |
| 230 base::Bind(&FrameReceiver::EmitAvailableEncodedFramesAfterWaiting, | 231 base::Bind(&FrameReceiver::EmitAvailableEncodedFramesAfterWaiting, |
| 231 weak_factory_.GetWeakPtr()), | 232 weak_factory_.GetWeakPtr()), |
| 232 playout_time - now); | 233 playout_time - now); |
| 233 } | 234 } |
| 234 return; | 235 return; |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 239 framer_.AckFrame(encoded_frame->frame_id); | |
|
Alpha Left Google
2014/08/25 23:23:44
Please add a comment to explain why frame is ACKed
hubbe
2014/08/27 04:14:03
Done.
| |
| 240 | |
| 238 // Decrypt the payload data in the frame, if crypto is being used. | 241 // Decrypt the payload data in the frame, if crypto is being used. |
| 239 if (decryptor_.is_activated()) { | 242 if (decryptor_.is_activated()) { |
| 240 std::string decrypted_data; | 243 std::string decrypted_data; |
| 241 if (!decryptor_.Decrypt(encoded_frame->frame_id, | 244 if (!decryptor_.Decrypt(encoded_frame->frame_id, |
| 242 encoded_frame->data, | 245 encoded_frame->data, |
| 243 &decrypted_data)) { | 246 &decrypted_data)) { |
| 244 // Decryption failed. Give up on this frame. | 247 // Decryption failed. Give up on this frame. |
| 245 framer_.ReleaseFrame(encoded_frame->frame_id); | 248 framer_.ReleaseFrame(encoded_frame->frame_id); |
| 246 continue; | 249 continue; |
| 247 } | 250 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 } | 315 } |
| 313 | 316 |
| 314 void FrameReceiver::SendNextRtcpReport() { | 317 void FrameReceiver::SendNextRtcpReport() { |
| 315 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 318 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 316 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_); | 319 rtcp_.SendRtcpFromRtpReceiver(NULL, base::TimeDelta(), NULL, &stats_); |
| 317 ScheduleNextRtcpReport(); | 320 ScheduleNextRtcpReport(); |
| 318 } | 321 } |
| 319 | 322 |
| 320 } // namespace cast | 323 } // namespace cast |
| 321 } // namespace media | 324 } // namespace media |
| OLD | NEW |