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

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: 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 656
660 if (!HasStream()) { 657 if (!HasStream()) {
661 ReleaseMediaCodecBridge(); 658 ReleaseMediaCodecBridge();
662 return STATUS_FAILURE; 659 return STATUS_FAILURE;
663 } 660 }
664 661
665 // Create |media_codec_bridge_| only if config changes. 662 // Create |media_codec_bridge_| only if config changes.
666 if (media_codec_bridge_ && !need_to_reconfig_decoder_job_) 663 if (media_codec_bridge_ && !need_to_reconfig_decoder_job_)
667 return STATUS_SUCCESS; 664 return STATUS_SUCCESS;
668 665
669 base::android::ScopedJavaLocalRef<jobject> media_crypto = GetMediaCrypto(); 666 if (is_content_encrypted_ && !GetMediaCrypto())
670 if (is_content_encrypted_ && media_crypto.is_null())
671 return STATUS_FAILURE; 667 return STATUS_FAILURE;
672 668
673 ReleaseMediaCodecBridge(); 669 ReleaseMediaCodecBridge();
674 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge"; 670 DVLOG(1) << __FUNCTION__ << " : creating new media codec bridge";
675 671
676 return CreateMediaCodecBridgeInternal(); 672 return CreateMediaCodecBridgeInternal();
677 } 673 }
678 674
679 bool MediaDecoderJob::IsCodecReconfigureNeeded( 675 bool MediaDecoderJob::IsCodecReconfigureNeeded(
680 const DemuxerConfigs& configs) const { 676 const DemuxerConfigs& configs) const {
(...skipping 10 matching lines...) Expand all
691 687
692 void MediaDecoderJob::ReleaseMediaCodecBridge() { 688 void MediaDecoderJob::ReleaseMediaCodecBridge() {
693 if (!media_codec_bridge_) 689 if (!media_codec_bridge_)
694 return; 690 return;
695 691
696 media_codec_bridge_.reset(); 692 media_codec_bridge_.reset();
697 input_buf_index_ = -1; 693 input_buf_index_ = -1;
698 } 694 }
699 695
700 } // namespace media 696 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698