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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 RequestData(prefetch_cb); | 109 RequestData(prefetch_cb); |
110 } | 110 } |
111 | 111 |
112 bool MediaDecoderJob::Decode( | 112 bool MediaDecoderJob::Decode( |
113 base::TimeTicks start_time_ticks, | 113 base::TimeTicks start_time_ticks, |
114 base::TimeDelta start_presentation_timestamp, | 114 base::TimeDelta start_presentation_timestamp, |
115 const DecoderCallback& callback) { | 115 const DecoderCallback& callback) { |
116 DCHECK(decode_cb_.is_null()); | 116 DCHECK(decode_cb_.is_null()); |
117 DCHECK(data_received_cb_.is_null()); | 117 DCHECK(data_received_cb_.is_null()); |
118 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 118 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
119 | |
120 if (!media_codec_bridge_ || need_to_reconfig_decoder_job_) { | 119 if (!media_codec_bridge_ || need_to_reconfig_decoder_job_) { |
121 need_to_reconfig_decoder_job_ = !CreateMediaCodecBridge(); | 120 need_to_reconfig_decoder_job_ = !CreateMediaCodecBridge(); |
122 if (drain_decoder_) { | 121 if (drain_decoder_) { |
123 // Decoder has been recreated, stop draining. | 122 // Decoder has been recreated, stop draining. |
124 drain_decoder_ = false; | 123 drain_decoder_ = false; |
125 input_eos_encountered_ = false; | 124 input_eos_encountered_ = false; |
126 output_eos_encountered_ = false; | 125 output_eos_encountered_ = false; |
127 access_unit_index_[current_demuxer_data_index_]++; | 126 access_unit_index_[current_demuxer_data_index_]++; |
128 } | 127 } |
129 skip_eos_enqueue_ = true; | 128 skip_eos_enqueue_ = true; |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 delete this; | 503 delete this; |
505 return; | 504 return; |
506 } | 505 } |
507 | 506 |
508 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) | 507 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) |
509 output_eos_encountered_ = true; | 508 output_eos_encountered_ = true; |
510 | 509 |
511 DCHECK(!decode_cb_.is_null()); | 510 DCHECK(!decode_cb_.is_null()); |
512 | 511 |
513 // If output was queued for rendering, then we have completed prerolling. | 512 // If output was queued for rendering, then we have completed prerolling. |
514 if (current_presentation_timestamp != kNoTimestamp()) | 513 if (current_presentation_timestamp != kNoTimestamp() || |
| 514 status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) { |
515 prerolling_ = false; | 515 prerolling_ = false; |
| 516 } |
516 | 517 |
517 switch (status) { | 518 switch (status) { |
518 case MEDIA_CODEC_OK: | 519 case MEDIA_CODEC_OK: |
519 case MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: | 520 case MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: |
520 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED: | 521 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED: |
521 case MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: | 522 case MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: |
522 case MEDIA_CODEC_OUTPUT_END_OF_STREAM: | 523 case MEDIA_CODEC_OUTPUT_END_OF_STREAM: |
523 if (!input_eos_encountered_) { | 524 if (!input_eos_encountered_) { |
524 CurrentDataConsumed( | 525 CurrentDataConsumed( |
525 CurrentAccessUnit().status == DemuxerStream::kConfigChanged); | 526 CurrentAccessUnit().status == DemuxerStream::kConfigChanged); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 645 |
645 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 646 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
646 if (!media_codec_bridge_) | 647 if (!media_codec_bridge_) |
647 return; | 648 return; |
648 | 649 |
649 media_codec_bridge_.reset(); | 650 media_codec_bridge_.reset(); |
650 input_buf_index_ = -1; | 651 input_buf_index_ = -1; |
651 } | 652 } |
652 | 653 |
653 } // namespace media | 654 } // namespace media |
OLD | NEW |