OLD | NEW |
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/base/android/media_decoder_job.h" | 5 #include "media/base/android/media_decoder_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - | 488 time_to_render = presentation_timestamp - (base::TimeTicks::Now() - |
489 start_time_ticks + start_presentation_timestamp); | 489 start_time_ticks + start_presentation_timestamp); |
490 } | 490 } |
491 | 491 |
492 if (time_to_render > base::TimeDelta()) { | 492 if (time_to_render > base::TimeDelta()) { |
493 decoder_task_runner_->PostDelayedTask( | 493 decoder_task_runner_->PostDelayedTask( |
494 FROM_HERE, | 494 FROM_HERE, |
495 base::Bind(&MediaDecoderJob::ReleaseOutputBuffer, | 495 base::Bind(&MediaDecoderJob::ReleaseOutputBuffer, |
496 base::Unretained(this), | 496 base::Unretained(this), |
497 buffer_index, | 497 buffer_index, |
| 498 offset, |
498 size, | 499 size, |
499 render_output, | 500 render_output, |
500 presentation_timestamp, | 501 presentation_timestamp, |
501 base::Bind(callback, status)), | 502 base::Bind(callback, status)), |
502 time_to_render); | 503 time_to_render); |
503 return; | 504 return; |
504 } | 505 } |
505 | 506 |
506 // TODO(qinmin): The codec is lagging behind, need to recalculate the | 507 // TODO(qinmin): The codec is lagging behind, need to recalculate the |
507 // |start_presentation_timestamp_| and |start_time_ticks_| in | 508 // |start_presentation_timestamp_| and |start_time_ticks_| in |
508 // media_source_player.cc. | 509 // media_source_player.cc. |
509 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds(); | 510 DVLOG(1) << "codec is lagging behind :" << time_to_render.InMicroseconds(); |
510 if (render_output) { | 511 if (render_output) { |
511 // The player won't expect a timestamp smaller than the | 512 // The player won't expect a timestamp smaller than the |
512 // |start_presentation_timestamp|. However, this could happen due to decoder | 513 // |start_presentation_timestamp|. However, this could happen due to decoder |
513 // errors. | 514 // errors. |
514 presentation_timestamp = std::max( | 515 presentation_timestamp = std::max( |
515 presentation_timestamp, start_presentation_timestamp); | 516 presentation_timestamp, start_presentation_timestamp); |
516 } else { | 517 } else { |
517 presentation_timestamp = kNoTimestamp(); | 518 presentation_timestamp = kNoTimestamp(); |
518 } | 519 } |
519 ReleaseOutputCompletionCallback completion_callback = base::Bind( | 520 ReleaseOutputCompletionCallback completion_callback = base::Bind( |
520 callback, status); | 521 callback, status); |
521 ReleaseOutputBuffer(buffer_index, size, render_output, presentation_timestamp, | 522 ReleaseOutputBuffer(buffer_index, offset, size, render_output, |
522 completion_callback); | 523 presentation_timestamp, completion_callback); |
523 } | 524 } |
524 | 525 |
525 void MediaDecoderJob::OnDecodeCompleted( | 526 void MediaDecoderJob::OnDecodeCompleted( |
526 MediaCodecStatus status, base::TimeDelta current_presentation_timestamp, | 527 MediaCodecStatus status, base::TimeDelta current_presentation_timestamp, |
527 base::TimeDelta max_presentation_timestamp) { | 528 base::TimeDelta max_presentation_timestamp) { |
528 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 529 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
529 | 530 |
530 if (destroy_pending_) { | 531 if (destroy_pending_) { |
531 DVLOG(1) << __FUNCTION__ << " : completing pending deletion"; | 532 DVLOG(1) << __FUNCTION__ << " : completing pending deletion"; |
532 delete this; | 533 delete this; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 | 687 |
687 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 688 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
688 if (!media_codec_bridge_) | 689 if (!media_codec_bridge_) |
689 return; | 690 return; |
690 | 691 |
691 media_codec_bridge_.reset(); | 692 media_codec_bridge_.reset(); |
692 input_buf_index_ = -1; | 693 input_buf_index_ = -1; |
693 } | 694 } |
694 | 695 |
695 } // namespace media | 696 } // namespace media |
OLD | NEW |