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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 base::Closure done_cb = base::ResetAndReturn(&data_received_cb_); | 82 base::Closure done_cb = base::ResetAndReturn(&data_received_cb_); |
83 | 83 |
84 // If this data request is for the inactive chunk, or |data_received_cb_| | 84 // If this data request is for the inactive chunk, or |data_received_cb_| |
85 // was set to null by Flush() or Release(), do nothing. | 85 // was set to null by Flush() or Release(), do nothing. |
86 if (done_cb.is_null()) | 86 if (done_cb.is_null()) |
87 return; | 87 return; |
88 | 88 |
89 if (stop_decode_pending_) { | 89 if (stop_decode_pending_) { |
90 DCHECK(is_decoding()); | 90 DCHECK(is_decoding()); |
91 OnDecodeCompleted(MEDIA_CODEC_STOPPED, kNoTimestamp(), kNoTimestamp()); | 91 OnDecodeCompleted(MEDIA_CODEC_ABORT, kNoTimestamp(), kNoTimestamp()); |
92 return; | 92 return; |
93 } | 93 } |
94 | 94 |
95 done_cb.Run(); | 95 done_cb.Run(); |
96 } | 96 } |
97 | 97 |
98 void MediaDecoderJob::Prefetch(const base::Closure& prefetch_cb) { | 98 void MediaDecoderJob::Prefetch(const base::Closure& prefetch_cb) { |
99 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 99 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
100 DCHECK(data_received_cb_.is_null()); | 100 DCHECK(data_received_cb_.is_null()); |
101 DCHECK(decode_cb_.is_null()); | 101 DCHECK(decode_cb_.is_null()); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 } | 375 } |
376 | 376 |
377 // Once output EOS has occurred, we should not be asked to decode again. | 377 // Once output EOS has occurred, we should not be asked to decode again. |
378 // MediaCodec has undefined behavior if similarly asked to decode after output | 378 // MediaCodec has undefined behavior if similarly asked to decode after output |
379 // EOS. | 379 // EOS. |
380 DCHECK(!output_eos_encountered_); | 380 DCHECK(!output_eos_encountered_); |
381 | 381 |
382 // For aborted access unit, just skip it and inform the player. | 382 // For aborted access unit, just skip it and inform the player. |
383 if (unit.status == DemuxerStream::kAborted) { | 383 if (unit.status == DemuxerStream::kAborted) { |
384 // TODO(qinmin): use a new enum instead of MEDIA_CODEC_STOPPED. | 384 callback.Run(MEDIA_CODEC_ABORT, kNoTimestamp(), kNoTimestamp()); |
385 callback.Run(MEDIA_CODEC_STOPPED, kNoTimestamp(), kNoTimestamp()); | |
386 return; | 385 return; |
387 } | 386 } |
388 | 387 |
389 if (skip_eos_enqueue_) { | 388 if (skip_eos_enqueue_) { |
390 if (unit.end_of_stream || unit.data.empty()) { | 389 if (unit.end_of_stream || unit.data.empty()) { |
391 input_eos_encountered_ = true; | 390 input_eos_encountered_ = true; |
392 output_eos_encountered_ = true; | 391 output_eos_encountered_ = true; |
393 callback.Run(MEDIA_CODEC_OUTPUT_END_OF_STREAM, kNoTimestamp(), | 392 callback.Run(MEDIA_CODEC_OUTPUT_END_OF_STREAM, kNoTimestamp(), |
394 kNoTimestamp()); | 393 kNoTimestamp()); |
395 return; | 394 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 if (!input_eos_encountered_) { | 520 if (!input_eos_encountered_) { |
522 CurrentDataConsumed( | 521 CurrentDataConsumed( |
523 CurrentAccessUnit().status == DemuxerStream::kConfigChanged); | 522 CurrentAccessUnit().status == DemuxerStream::kConfigChanged); |
524 access_unit_index_[current_demuxer_data_index_]++; | 523 access_unit_index_[current_demuxer_data_index_]++; |
525 } | 524 } |
526 break; | 525 break; |
527 | 526 |
528 case MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER: | 527 case MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER: |
529 case MEDIA_CODEC_INPUT_END_OF_STREAM: | 528 case MEDIA_CODEC_INPUT_END_OF_STREAM: |
530 case MEDIA_CODEC_NO_KEY: | 529 case MEDIA_CODEC_NO_KEY: |
531 case MEDIA_CODEC_STOPPED: | 530 case MEDIA_CODEC_ABORT: |
532 case MEDIA_CODEC_ERROR: | 531 case MEDIA_CODEC_ERROR: |
533 // Do nothing. | 532 // Do nothing. |
534 break; | 533 break; |
535 | 534 |
536 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED: | 535 case MEDIA_CODEC_OUTPUT_BUFFERS_CHANGED: |
537 DCHECK(false) << "Invalid output status"; | 536 DCHECK(false) << "Invalid output status"; |
538 break; | 537 break; |
539 }; | 538 }; |
540 | 539 |
541 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM && drain_decoder_) { | 540 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM && drain_decoder_) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 | 655 |
657 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 656 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
658 if (!media_codec_bridge_) | 657 if (!media_codec_bridge_) |
659 return; | 658 return; |
660 | 659 |
661 media_codec_bridge_.reset(); | 660 media_codec_bridge_.reset(); |
662 input_buf_index_ = -1; | 661 input_buf_index_ = -1; |
663 } | 662 } |
664 | 663 |
665 } // namespace media | 664 } // namespace media |
OLD | NEW |