| 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.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 received_data_ = data; | 60 received_data_ = data; |
| 61 done_cb.Run(); | 61 done_cb.Run(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void MediaDecoderJob::Prefetch(const base::Closure& prefetch_cb) { | 64 void MediaDecoderJob::Prefetch(const base::Closure& prefetch_cb) { |
| 65 DCHECK(ui_loop_->BelongsToCurrentThread()); | 65 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 66 DCHECK(on_data_received_cb_.is_null()); | 66 DCHECK(on_data_received_cb_.is_null()); |
| 67 DCHECK(decode_cb_.is_null()); | 67 DCHECK(decode_cb_.is_null()); |
| 68 | 68 |
| 69 if (HasData()) { | 69 if (HasData()) { |
| 70 DVLOG(1) << __FUNCTION__ << " : using previously received data"; |
| 70 ui_loop_->PostTask(FROM_HERE, prefetch_cb); | 71 ui_loop_->PostTask(FROM_HERE, prefetch_cb); |
| 71 return; | 72 return; |
| 72 } | 73 } |
| 73 | 74 |
| 75 DVLOG(1) << __FUNCTION__ << " : requesting data"; |
| 74 RequestData(prefetch_cb); | 76 RequestData(prefetch_cb); |
| 75 } | 77 } |
| 76 | 78 |
| 77 bool MediaDecoderJob::Decode( | 79 bool MediaDecoderJob::Decode( |
| 78 const base::TimeTicks& start_time_ticks, | 80 const base::TimeTicks& start_time_ticks, |
| 79 const base::TimeDelta& start_presentation_timestamp, | 81 const base::TimeDelta& start_presentation_timestamp, |
| 80 const DecoderCallback& callback) { | 82 const DecoderCallback& callback) { |
| 81 DCHECK(decode_cb_.is_null()); | 83 DCHECK(decode_cb_.is_null()); |
| 82 DCHECK(on_data_received_cb_.is_null()); | 84 DCHECK(on_data_received_cb_.is_null()); |
| 83 DCHECK(ui_loop_->BelongsToCurrentThread()); | 85 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 DVLOG(1) << __FUNCTION__ << "(" << preroll_timestamp.InSecondsF() << ")"; | 129 DVLOG(1) << __FUNCTION__ << "(" << preroll_timestamp.InSecondsF() << ")"; |
| 128 DCHECK(ui_loop_->BelongsToCurrentThread()); | 130 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 129 DCHECK(!is_decoding()); | 131 DCHECK(!is_decoding()); |
| 130 | 132 |
| 131 preroll_timestamp_ = preroll_timestamp; | 133 preroll_timestamp_ = preroll_timestamp; |
| 132 prerolling_ = true; | 134 prerolling_ = true; |
| 133 } | 135 } |
| 134 | 136 |
| 135 void MediaDecoderJob::Release() { | 137 void MediaDecoderJob::Release() { |
| 136 DCHECK(ui_loop_->BelongsToCurrentThread()); | 138 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 139 DVLOG(1) << __FUNCTION__; |
| 137 | 140 |
| 138 // If the decoder job is not waiting for data, and is still decoding, we | 141 // If the decoder job is not waiting for data, and is still decoding, we |
| 139 // cannot delete the job immediately. | 142 // cannot delete the job immediately. |
| 140 destroy_pending_ = on_data_received_cb_.is_null() && is_decoding(); | 143 destroy_pending_ = on_data_received_cb_.is_null() && is_decoding(); |
| 141 | 144 |
| 142 request_data_cb_.Reset(); | 145 request_data_cb_.Reset(); |
| 143 on_data_received_cb_.Reset(); | 146 on_data_received_cb_.Reset(); |
| 144 decode_cb_.Reset(); | 147 decode_cb_.Reset(); |
| 145 | 148 |
| 146 if (destroy_pending_) | 149 if (destroy_pending_) { |
| 150 DVLOG(1) << __FUNCTION__ << " : delete is pending decode completion"; |
| 147 return; | 151 return; |
| 152 } |
| 148 | 153 |
| 149 delete this; | 154 delete this; |
| 150 } | 155 } |
| 151 | 156 |
| 152 MediaCodecStatus MediaDecoderJob::QueueInputBuffer(const AccessUnit& unit) { | 157 MediaCodecStatus MediaDecoderJob::QueueInputBuffer(const AccessUnit& unit) { |
| 153 DVLOG(1) << __FUNCTION__; | 158 DVLOG(1) << __FUNCTION__; |
| 154 DCHECK(decoder_loop_->BelongsToCurrentThread()); | 159 DCHECK(decoder_loop_->BelongsToCurrentThread()); |
| 155 TRACE_EVENT0("media", __FUNCTION__); | 160 TRACE_EVENT0("media", __FUNCTION__); |
| 156 | 161 |
| 157 int input_buf_index = input_buf_index_; | 162 int input_buf_index = input_buf_index_; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 callback, status, presentation_timestamp); | 370 callback, status, presentation_timestamp); |
| 366 ReleaseOutputBuffer(buffer_index, size, render_output, completion_callback); | 371 ReleaseOutputBuffer(buffer_index, size, render_output, completion_callback); |
| 367 } | 372 } |
| 368 | 373 |
| 369 void MediaDecoderJob::OnDecodeCompleted( | 374 void MediaDecoderJob::OnDecodeCompleted( |
| 370 MediaCodecStatus status, const base::TimeDelta& presentation_timestamp, | 375 MediaCodecStatus status, const base::TimeDelta& presentation_timestamp, |
| 371 size_t audio_output_bytes) { | 376 size_t audio_output_bytes) { |
| 372 DCHECK(ui_loop_->BelongsToCurrentThread()); | 377 DCHECK(ui_loop_->BelongsToCurrentThread()); |
| 373 | 378 |
| 374 if (destroy_pending_) { | 379 if (destroy_pending_) { |
| 380 DVLOG(1) << __FUNCTION__ << " : completing pending deletion"; |
| 375 delete this; | 381 delete this; |
| 376 return; | 382 return; |
| 377 } | 383 } |
| 378 | 384 |
| 379 DCHECK(!decode_cb_.is_null()); | 385 DCHECK(!decode_cb_.is_null()); |
| 380 | 386 |
| 381 // If output was queued for rendering, then we have completed prerolling. | 387 // If output was queued for rendering, then we have completed prerolling. |
| 382 if (presentation_timestamp != kNoTimestamp()) | 388 if (presentation_timestamp != kNoTimestamp()) |
| 383 prerolling_ = false; | 389 prerolling_ = false; |
| 384 | 390 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 400 // Do nothing. | 406 // Do nothing. |
| 401 break; | 407 break; |
| 402 }; | 408 }; |
| 403 | 409 |
| 404 stop_decode_pending_ = false; | 410 stop_decode_pending_ = false; |
| 405 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp, | 411 base::ResetAndReturn(&decode_cb_).Run(status, presentation_timestamp, |
| 406 audio_output_bytes); | 412 audio_output_bytes); |
| 407 } | 413 } |
| 408 | 414 |
| 409 } // namespace media | 415 } // namespace media |
| OLD | NEW |