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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 // Otherwise MediaDrm will report errors. | 282 // Otherwise MediaDrm will report errors. |
283 if (status == MEDIA_CODEC_NO_KEY) | 283 if (status == MEDIA_CODEC_NO_KEY) |
284 input_buf_index_ = input_buf_index; | 284 input_buf_index_ = input_buf_index; |
285 | 285 |
286 return status; | 286 return status; |
287 } | 287 } |
288 | 288 |
289 bool MediaDecoderJob::HasData() const { | 289 bool MediaDecoderJob::HasData() const { |
290 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 290 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
291 // When |input_eos_encountered_| is set, |access_unit_index_| and | 291 // When |input_eos_encountered_| is set, |access_unit_index_| and |
292 // |current_demuxer_data_index_| must be pointing to an EOS unit. | 292 // |current_demuxer_data_index_| must be pointing to an EOS unit. |
wolenetz
2014/06/06 23:28:06
nit: or a kConfigChanged unit and drain_decoder_ i
qinmin
2014/06/07 01:31:55
Done. Rephrased the comment.
| |
293 // We'll reuse this unit to flush the decoder until we hit output EOS. | 293 // We'll reuse this unit to flush the decoder until we hit output EOS. |
294 DCHECK(!input_eos_encountered_ || !NoAccessUnitsRemainingInChunk(true)); | 294 DCHECK(!input_eos_encountered_ || !NoAccessUnitsRemainingInChunk(true)); |
295 return !NoAccessUnitsRemainingInChunk(true) || | 295 return !NoAccessUnitsRemainingInChunk(true) || |
296 !NoAccessUnitsRemainingInChunk(false); | 296 !NoAccessUnitsRemainingInChunk(false); |
297 } | 297 } |
298 | 298 |
299 void MediaDecoderJob::RequestData(const base::Closure& done_cb) { | 299 void MediaDecoderJob::RequestData(const base::Closure& done_cb) { |
300 DVLOG(1) << __FUNCTION__; | 300 DVLOG(1) << __FUNCTION__; |
301 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 301 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
302 DCHECK(data_received_cb_.is_null()); | 302 DCHECK(data_received_cb_.is_null()); |
(...skipping 22 matching lines...) Expand all Loading... | |
325 void MediaDecoderJob::DecodeCurrentAccessUnit( | 325 void MediaDecoderJob::DecodeCurrentAccessUnit( |
326 base::TimeTicks start_time_ticks, | 326 base::TimeTicks start_time_ticks, |
327 base::TimeDelta start_presentation_timestamp) { | 327 base::TimeDelta start_presentation_timestamp) { |
328 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 328 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
329 DCHECK(!decode_cb_.is_null()); | 329 DCHECK(!decode_cb_.is_null()); |
330 | 330 |
331 RequestCurrentChunkIfEmpty(); | 331 RequestCurrentChunkIfEmpty(); |
332 const AccessUnit& access_unit = CurrentAccessUnit(); | 332 const AccessUnit& access_unit = CurrentAccessUnit(); |
333 if (CurrentAccessUnit().status == DemuxerStream::kConfigChanged) { | 333 if (CurrentAccessUnit().status == DemuxerStream::kConfigChanged) { |
334 int index = CurrentReceivedDataChunkIndex(); | 334 int index = CurrentReceivedDataChunkIndex(); |
335 bool config_changed = SetDemuxerConfigs( | 335 const DemuxerConfigs& configs = received_data_[index].demuxer_configs[0]; |
336 received_data_[index].demuxer_configs[0]); | 336 bool reconfigure_needed = IsCodecReconfigureNeeded(configs); |
337 if (config_changed) | 337 if (SetDemuxerConfigs(configs)) |
338 config_changed_cb_.Run(); | 338 config_changed_cb_.Run(); |
wolenetz
2014/06/06 23:28:07
Should we wait to tell the renderer that the confi
qinmin
2014/06/07 01:31:55
Yes, that should be the correct behavior. However,
| |
339 if (!drain_decoder_) { | 339 if (!drain_decoder_) { |
wolenetz
2014/06/06 23:28:07
If !reconfigure_needed, we still drain previous de
qinmin
2014/06/07 01:31:55
If !reconfigure_needed, we will keep the previous
wolenetz
2014/06/09 18:22:39
Thank you for clarifying. Yes, I was misreading.
| |
340 // If we haven't decoded any data yet, just skip the current access unit | 340 // If we haven't decoded any data yet, just skip the current access unit |
341 // and request the MediaCodec to be recreated on next Decode(). | 341 // and request the MediaCodec to be recreated on next Decode(). |
342 if (skip_eos_enqueue_ || !config_changed) { | 342 if (skip_eos_enqueue_ || !reconfigure_needed) { |
343 need_to_reconfig_decoder_job_ = | 343 need_to_reconfig_decoder_job_ = |
344 need_to_reconfig_decoder_job_ || config_changed; | 344 need_to_reconfig_decoder_job_ || reconfigure_needed; |
345 ui_task_runner_->PostTask(FROM_HERE, base::Bind( | 345 ui_task_runner_->PostTask(FROM_HERE, base::Bind( |
346 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this), | 346 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this), |
347 MEDIA_CODEC_OUTPUT_FORMAT_CHANGED, kNoTimestamp(), kNoTimestamp())); | 347 MEDIA_CODEC_OUTPUT_FORMAT_CHANGED, kNoTimestamp(), kNoTimestamp())); |
348 return; | 348 return; |
349 } | 349 } |
350 // Start draining the decoder so that all the remaining frames are | 350 // Start draining the decoder so that all the remaining frames are |
351 // rendered. | 351 // rendered. |
352 drain_decoder_ = true; | 352 drain_decoder_ = true; |
353 } | 353 } |
354 } | 354 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
625 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); | 625 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); |
626 if (is_content_encrypted_ && media_crypto.is_null()) | 626 if (is_content_encrypted_ && media_crypto.is_null()) |
627 return false; | 627 return false; |
628 | 628 |
629 ReleaseMediaCodecBridge(); | 629 ReleaseMediaCodecBridge(); |
630 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge"; | 630 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge"; |
631 | 631 |
632 return CreateMediaCodecBridgeInternal(); | 632 return CreateMediaCodecBridgeInternal(); |
633 } | 633 } |
634 | 634 |
635 bool MediaDecoderJob::IsCodecReconfigureNeeded( | |
636 const DemuxerConfigs& configs) const { | |
637 if (!AreDemuxerConfigsChanged(configs)) | |
638 return false; | |
639 return true; | |
640 } | |
641 | |
635 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 642 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
636 if (!media_codec_bridge_) | 643 if (!media_codec_bridge_) |
637 return; | 644 return; |
638 | 645 |
639 media_codec_bridge_.reset(); | 646 media_codec_bridge_.reset(); |
640 OnMediaCodecBridgeReleased(); | 647 OnMediaCodecBridgeReleased(); |
641 } | 648 } |
642 | 649 |
643 } // namespace media | 650 } // namespace media |
OLD | NEW |