| 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/bind_to_current_loop.h" |
| 8 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 11 #include "media/base/android/media_codec_bridge.h" | 12 #include "media/base/android/media_codec_bridge.h" |
| 12 #include "media/base/android/media_drm_bridge.h" | 13 #include "media/base/android/media_drm_bridge.h" |
| 13 #include "media/base/bind_to_current_loop.h" | |
| 14 #include "media/base/buffers.h" | 14 #include "media/base/buffers.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 // Timeout value for media codec operations. Because the first | 18 // Timeout value for media codec operations. Because the first |
| 19 // DequeInputBuffer() can take about 150 milliseconds, use 250 milliseconds | 19 // DequeInputBuffer() can take about 150 milliseconds, use 250 milliseconds |
| 20 // here. See http://b/9357571. | 20 // here. See http://b/9357571. |
| 21 static const int kMediaCodecTimeoutInMilliseconds = 250; | 21 static const int kMediaCodecTimeoutInMilliseconds = 250; |
| 22 | 22 |
| 23 MediaDecoderJob::MediaDecoderJob( | 23 MediaDecoderJob::MediaDecoderJob( |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // rendered. | 368 // rendered. |
| 369 drain_decoder_ = true; | 369 drain_decoder_ = true; |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 | 372 |
| 373 DCHECK(!(needs_flush_ && drain_decoder_)); | 373 DCHECK(!(needs_flush_ && drain_decoder_)); |
| 374 decoder_task_runner_->PostTask(FROM_HERE, base::Bind( | 374 decoder_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 375 &MediaDecoderJob::DecodeInternal, base::Unretained(this), | 375 &MediaDecoderJob::DecodeInternal, base::Unretained(this), |
| 376 drain_decoder_ ? eos_unit_ : access_unit, | 376 drain_decoder_ ? eos_unit_ : access_unit, |
| 377 start_time_ticks, start_presentation_timestamp, needs_flush_, | 377 start_time_ticks, start_presentation_timestamp, needs_flush_, |
| 378 media::BindToCurrentLoop(base::Bind( | 378 base::BindToCurrentLoop(base::Bind( |
| 379 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this))))); | 379 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this))))); |
| 380 needs_flush_ = false; | 380 needs_flush_ = false; |
| 381 } | 381 } |
| 382 | 382 |
| 383 void MediaDecoderJob::DecodeInternal( | 383 void MediaDecoderJob::DecodeInternal( |
| 384 const AccessUnit& unit, | 384 const AccessUnit& unit, |
| 385 base::TimeTicks start_time_ticks, | 385 base::TimeTicks start_time_ticks, |
| 386 base::TimeDelta start_presentation_timestamp, | 386 base::TimeDelta start_presentation_timestamp, |
| 387 bool needs_flush, | 387 bool needs_flush, |
| 388 const MediaDecoderJob::DecoderCallback& callback) { | 388 const MediaDecoderJob::DecoderCallback& callback) { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 682 |
| 683 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 683 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
| 684 if (!media_codec_bridge_) | 684 if (!media_codec_bridge_) |
| 685 return; | 685 return; |
| 686 | 686 |
| 687 media_codec_bridge_.reset(); | 687 media_codec_bridge_.reset(); |
| 688 input_buf_index_ = -1; | 688 input_buf_index_ = -1; |
| 689 } | 689 } |
| 690 | 690 |
| 691 } // namespace media | 691 } // namespace media |
| OLD | NEW |