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

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

Issue 1512173003: media: Refactor MediaCrypto creation and notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fire pending callback in dtor Created 5 years 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
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/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Since the decoder job is not decoding data, we can safely destroy 192 // Since the decoder job is not decoding data, we can safely destroy
193 // |media_codec_bridge_|. 193 // |media_codec_bridge_|.
194 ReleaseMediaCodecBridge(); 194 ReleaseMediaCodecBridge();
195 return; 195 return;
196 } 196 }
197 197
198 // Release |media_codec_bridge_| once decoding is completed. 198 // Release |media_codec_bridge_| once decoding is completed.
199 release_resources_pending_ = true; 199 release_resources_pending_ = true;
200 } 200 }
201 201
202 base::android::ScopedJavaLocalRef<jobject> MediaDecoderJob::GetMediaCrypto() { 202 jobject MediaDecoderJob::GetMediaCrypto() {
203 base::android::ScopedJavaLocalRef<jobject> media_crypto; 203 return drm_bridge_ ? drm_bridge_->GetMediaCrypto() : nullptr;
204 if (drm_bridge_)
205 media_crypto = drm_bridge_->GetMediaCrypto();
206 return media_crypto;
207 } 204 }
208 205
209 bool MediaDecoderJob::SetCurrentFrameToPreviouslyCachedKeyFrame() { 206 bool MediaDecoderJob::SetCurrentFrameToPreviouslyCachedKeyFrame() {
210 const std::vector<AccessUnit>& access_units = 207 const std::vector<AccessUnit>& access_units =
211 received_data_[current_demuxer_data_index_].access_units; 208 received_data_[current_demuxer_data_index_].access_units;
212 // If the current data chunk is empty, the player must be in an initial or 209 // If the current data chunk is empty, the player must be in an initial or
213 // seek state. The next access unit will always be a key frame. 210 // seek state. The next access unit will always be a key frame.
214 if (access_units.size() == 0) 211 if (access_units.size() == 0)
215 return true; 212 return true;
216 213
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 652
656 if (!HasStream()) { 653 if (!HasStream()) {
657 ReleaseMediaCodecBridge(); 654 ReleaseMediaCodecBridge();
658 return STATUS_FAILURE; 655 return STATUS_FAILURE;
659 } 656 }
660 657
661 // Create |media_codec_bridge_| only if config changes. 658 // Create |media_codec_bridge_| only if config changes.
662 if (media_codec_bridge_ && !need_to_reconfig_decoder_job_) 659 if (media_codec_bridge_ && !need_to_reconfig_decoder_job_)
663 return STATUS_SUCCESS; 660 return STATUS_SUCCESS;
664 661
665 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); 662 if (is_content_encrypted_ && !GetMediaCrypto())
666 if (is_content_encrypted_ && media_crypto.is_null())
667 return STATUS_FAILURE; 663 return STATUS_FAILURE;
668 664
669 ReleaseMediaCodecBridge(); 665 ReleaseMediaCodecBridge();
670 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge"; 666 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge";
671 667
672 return CreateMediaCodecBridgeInternal(); 668 return CreateMediaCodecBridgeInternal();
673 } 669 }
674 670
675 bool MediaDecoderJob::IsCodecReconfigureNeeded( 671 bool MediaDecoderJob::IsCodecReconfigureNeeded(
676 const DemuxerConfigs& configs) const { 672 const DemuxerConfigs& configs) const {
(...skipping 10 matching lines...) Expand all
687 683
688 void MediaDecoderJob::ReleaseMediaCodecBridge() { 684 void MediaDecoderJob::ReleaseMediaCodecBridge() {
689 if (!media_codec_bridge_) 685 if (!media_codec_bridge_)
690 return; 686 return;
691 687
692 media_codec_bridge_.reset(); 688 media_codec_bridge_.reset();
693 input_buf_index_ = -1; 689 input_buf_index_ = -1;
694 } 690 }
695 691
696 } // namespace media 692 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698