Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: media/base/android/media_decoder_job.cc

Issue 323563002: support adaptive playback in MSE (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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,
293 // We'll reuse this unit to flush the decoder until we hit output EOS. 293 // or a |kConfigChanged| unit if |drain_decoder_| is true. In both cases,
294 // We'll reuse this unit to drain the decoder until we hit output EOS.
wolenetz 2014/06/09 18:22:39 nit: s/We'll/we'll/ and s/reuse this/feed an EOS i
qinmin 2014/06/09 18:55:39 Done.
294 DCHECK(!input_eos_encountered_ || !NoAccessUnitsRemainingInChunk(true)); 295 DCHECK(!input_eos_encountered_ || !NoAccessUnitsRemainingInChunk(true));
295 return !NoAccessUnitsRemainingInChunk(true) || 296 return !NoAccessUnitsRemainingInChunk(true) ||
296 !NoAccessUnitsRemainingInChunk(false); 297 !NoAccessUnitsRemainingInChunk(false);
297 } 298 }
298 299
299 void MediaDecoderJob::RequestData(const base::Closure& done_cb) { 300 void MediaDecoderJob::RequestData(const base::Closure& done_cb) {
300 DVLOG(1) << __FUNCTION__; 301 DVLOG(1) << __FUNCTION__;
301 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 302 DCHECK(ui_task_runner_->BelongsToCurrentThread());
302 DCHECK(data_received_cb_.is_null()); 303 DCHECK(data_received_cb_.is_null());
303 DCHECK(!input_eos_encountered_); 304 DCHECK(!input_eos_encountered_);
(...skipping 21 matching lines...) Expand all
325 void MediaDecoderJob::DecodeCurrentAccessUnit( 326 void MediaDecoderJob::DecodeCurrentAccessUnit(
326 base::TimeTicks start_time_ticks, 327 base::TimeTicks start_time_ticks,
327 base::TimeDelta start_presentation_timestamp) { 328 base::TimeDelta start_presentation_timestamp) {
328 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 329 DCHECK(ui_task_runner_->BelongsToCurrentThread());
329 DCHECK(!decode_cb_.is_null()); 330 DCHECK(!decode_cb_.is_null());
330 331
331 RequestCurrentChunkIfEmpty(); 332 RequestCurrentChunkIfEmpty();
332 const AccessUnit& access_unit = CurrentAccessUnit(); 333 const AccessUnit& access_unit = CurrentAccessUnit();
333 if (CurrentAccessUnit().status == DemuxerStream::kConfigChanged) { 334 if (CurrentAccessUnit().status == DemuxerStream::kConfigChanged) {
334 int index = CurrentReceivedDataChunkIndex(); 335 int index = CurrentReceivedDataChunkIndex();
335 bool config_changed = SetDemuxerConfigs( 336 const DemuxerConfigs& configs = received_data_[index].demuxer_configs[0];
336 received_data_[index].demuxer_configs[0]); 337 bool reconfigure_needed = IsCodecReconfigureNeeded(configs);
337 if (config_changed) 338 // TODO(qinmin): |config_changed_cb_| should be ran after draining finishes.
wolenetz 2014/06/09 18:22:39 nit: s/ran/run/ (http://wiki.answers.com/Q/Should_
qinmin 2014/06/09 18:55:39 Done.
339 // http://crbug.com/381975.
340 if (SetDemuxerConfigs(configs))
338 config_changed_cb_.Run(); 341 config_changed_cb_.Run();
339 if (!drain_decoder_) { 342 if (!drain_decoder_) {
340 // If we haven't decoded any data yet, just skip the current access unit 343 // 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(). 344 // and request the MediaCodec to be recreated on next Decode().
342 if (skip_eos_enqueue_ || !config_changed) { 345 // TODO(qinmin): If adaptive playback is enabled, we need to make sure
346 // that the new SPS/PPS and IDR are passed to the decoder in a single
347 // access unit. Need to either combine the access units here or do it at
348 // the chunk demuxer side. See http://crbug.com/381984 and
349 // https://developer.android.com/about/versions/android-4.4.html.
wolenetz 2014/06/09 18:22:39 How will we know if this SPS/PPS/IDR expectation i
qinmin 2014/06/09 18:55:39 Since SPS/PPS/IDR is guaranteed to be the first AU
350 if (skip_eos_enqueue_ || !reconfigure_needed) {
343 need_to_reconfig_decoder_job_ = 351 need_to_reconfig_decoder_job_ =
344 need_to_reconfig_decoder_job_ || config_changed; 352 need_to_reconfig_decoder_job_ || reconfigure_needed;
345 ui_task_runner_->PostTask(FROM_HERE, base::Bind( 353 ui_task_runner_->PostTask(FROM_HERE, base::Bind(
346 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this), 354 &MediaDecoderJob::OnDecodeCompleted, base::Unretained(this),
347 MEDIA_CODEC_OUTPUT_FORMAT_CHANGED, kNoTimestamp(), kNoTimestamp())); 355 MEDIA_CODEC_OUTPUT_FORMAT_CHANGED, kNoTimestamp(), kNoTimestamp()));
348 return; 356 return;
349 } 357 }
350 // Start draining the decoder so that all the remaining frames are 358 // Start draining the decoder so that all the remaining frames are
351 // rendered. 359 // rendered.
352 drain_decoder_ = true; 360 drain_decoder_ = true;
353 } 361 }
354 } 362 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); 633 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto();
626 if (is_content_encrypted_ && media_crypto.is_null()) 634 if (is_content_encrypted_ && media_crypto.is_null())
627 return false; 635 return false;
628 636
629 ReleaseMediaCodecBridge(); 637 ReleaseMediaCodecBridge();
630 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge"; 638 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge";
631 639
632 return CreateMediaCodecBridgeInternal(); 640 return CreateMediaCodecBridgeInternal();
633 } 641 }
634 642
643 bool MediaDecoderJob::IsCodecReconfigureNeeded(
644 const DemuxerConfigs& configs) const {
645 if (!AreDemuxerConfigsChanged(configs))
646 return false;
647 return true;
648 }
649
635 void MediaDecoderJob::ReleaseMediaCodecBridge() { 650 void MediaDecoderJob::ReleaseMediaCodecBridge() {
636 if (!media_codec_bridge_) 651 if (!media_codec_bridge_)
637 return; 652 return;
638 653
639 media_codec_bridge_.reset(); 654 media_codec_bridge_.reset();
640 OnMediaCodecBridgeReleased(); 655 OnMediaCodecBridgeReleased();
641 } 656 }
642 657
643 } // namespace media 658 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/media_source_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698