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 30 matching lines...) Expand all Loading... |
41 is_requesting_demuxer_data_(false), | 41 is_requesting_demuxer_data_(false), |
42 is_incoming_data_invalid_(false), | 42 is_incoming_data_invalid_(false), |
43 release_resources_pending_(false), | 43 release_resources_pending_(false), |
44 drm_bridge_(NULL), | 44 drm_bridge_(NULL), |
45 drain_decoder_(false) { | 45 drain_decoder_(false) { |
46 InitializeReceivedData(); | 46 InitializeReceivedData(); |
47 eos_unit_.end_of_stream = true; | 47 eos_unit_.end_of_stream = true; |
48 } | 48 } |
49 | 49 |
50 MediaDecoderJob::~MediaDecoderJob() { | 50 MediaDecoderJob::~MediaDecoderJob() { |
51 DCHECK(!media_codec_bridge_); | 51 ReleaseMediaCodecBridge(); |
52 } | 52 } |
53 | 53 |
54 void MediaDecoderJob::OnDataReceived(const DemuxerData& data) { | 54 void MediaDecoderJob::OnDataReceived(const DemuxerData& data) { |
55 DVLOG(1) << __FUNCTION__ << ": " << data.access_units.size() << " units"; | 55 DVLOG(1) << __FUNCTION__ << ": " << data.access_units.size() << " units"; |
56 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 56 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
57 DCHECK(NoAccessUnitsRemainingInChunk(false)); | 57 DCHECK(NoAccessUnitsRemainingInChunk(false)); |
58 | 58 |
59 TRACE_EVENT_ASYNC_END2( | 59 TRACE_EVENT_ASYNC_END2( |
60 "media", "MediaDecoderJob::RequestData", this, | 60 "media", "MediaDecoderJob::RequestData", this, |
61 "Data type", data.type == media::DemuxerStream::AUDIO ? "AUDIO" : "VIDEO", | 61 "Data type", data.type == media::DemuxerStream::AUDIO ? "AUDIO" : "VIDEO", |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 request_data_cb_.Reset(); | 226 request_data_cb_.Reset(); |
227 data_received_cb_.Reset(); | 227 data_received_cb_.Reset(); |
228 decode_cb_.Reset(); | 228 decode_cb_.Reset(); |
229 | 229 |
230 if (destroy_pending_) { | 230 if (destroy_pending_) { |
231 DVLOG(1) << __FUNCTION__ << " : delete is pending decode completion"; | 231 DVLOG(1) << __FUNCTION__ << " : delete is pending decode completion"; |
232 return; | 232 return; |
233 } | 233 } |
234 | 234 |
235 ReleaseMediaCodecBridge(); | |
236 delete this; | 235 delete this; |
237 } | 236 } |
238 | 237 |
239 MediaCodecStatus MediaDecoderJob::QueueInputBuffer(const AccessUnit& unit) { | 238 MediaCodecStatus MediaDecoderJob::QueueInputBuffer(const AccessUnit& unit) { |
240 DVLOG(1) << __FUNCTION__; | 239 DVLOG(1) << __FUNCTION__; |
241 DCHECK(decoder_task_runner_->BelongsToCurrentThread()); | 240 DCHECK(decoder_task_runner_->BelongsToCurrentThread()); |
242 TRACE_EVENT0("media", __FUNCTION__); | 241 TRACE_EVENT0("media", __FUNCTION__); |
243 | 242 |
244 int input_buf_index = input_buf_index_; | 243 int input_buf_index = input_buf_index_; |
245 input_buf_index_ = -1; | 244 input_buf_index_ = -1; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 completion_callback); | 493 completion_callback); |
495 } | 494 } |
496 | 495 |
497 void MediaDecoderJob::OnDecodeCompleted( | 496 void MediaDecoderJob::OnDecodeCompleted( |
498 MediaCodecStatus status, base::TimeDelta current_presentation_timestamp, | 497 MediaCodecStatus status, base::TimeDelta current_presentation_timestamp, |
499 base::TimeDelta max_presentation_timestamp) { | 498 base::TimeDelta max_presentation_timestamp) { |
500 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 499 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
501 | 500 |
502 if (destroy_pending_) { | 501 if (destroy_pending_) { |
503 DVLOG(1) << __FUNCTION__ << " : completing pending deletion"; | 502 DVLOG(1) << __FUNCTION__ << " : completing pending deletion"; |
504 ReleaseMediaCodecBridge(); | |
505 delete this; | 503 delete this; |
506 return; | 504 return; |
507 } | 505 } |
508 | 506 |
509 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) | 507 if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) |
510 output_eos_encountered_ = true; | 508 output_eos_encountered_ = true; |
511 | 509 |
512 DCHECK(!decode_cb_.is_null()); | 510 DCHECK(!decode_cb_.is_null()); |
513 | 511 |
514 // If output was queued for rendering, then we have completed prerolling. | 512 // If output was queued for rendering, then we have completed prerolling. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 645 |
648 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 646 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
649 if (!media_codec_bridge_) | 647 if (!media_codec_bridge_) |
650 return; | 648 return; |
651 | 649 |
652 media_codec_bridge_.reset(); | 650 media_codec_bridge_.reset(); |
653 input_buf_index_ = -1; | 651 input_buf_index_ = -1; |
654 } | 652 } |
655 | 653 |
656 } // namespace media | 654 } // namespace media |
OLD | NEW |