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

Side by Side Diff: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java

Issue 60423004: MediaCodecBridge: don't try to create .secure codecs pre-JB-MR2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 package org.chromium.media; 5 package org.chromium.media;
6 6
7 import android.media.AudioFormat; 7 import android.media.AudioFormat;
8 import android.media.AudioManager; 8 import android.media.AudioManager;
9 import android.media.AudioTrack; 9 import android.media.AudioTrack;
10 import android.media.MediaCodec; 10 import android.media.MediaCodec;
11 import android.media.MediaCodecInfo; 11 import android.media.MediaCodecInfo;
12 import android.media.MediaCodecList; 12 import android.media.MediaCodecList;
13 import android.media.MediaCrypto; 13 import android.media.MediaCrypto;
14 import android.media.MediaFormat; 14 import android.media.MediaFormat;
15 import android.os.Build;
16 import android.util.Log;
15 import android.view.Surface; 17 import android.view.Surface;
16 import android.util.Log;
17 18
18 import java.io.IOException; 19 import java.io.IOException;
19 import java.nio.ByteBuffer; 20 import java.nio.ByteBuffer;
20 import java.util.ArrayList; 21 import java.util.ArrayList;
21 import java.util.HashMap; 22 import java.util.HashMap;
22 import java.util.Map; 23 import java.util.Map;
23 24
24 import org.chromium.base.CalledByNative; 25 import org.chromium.base.CalledByNative;
25 import org.chromium.base.JNINamespace; 26 import org.chromium.base.JNINamespace;
26 27
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 @CalledByNative 145 @CalledByNative
145 private static CodecInfo[] getCodecsInfo() { 146 private static CodecInfo[] getCodecsInfo() {
146 Map<String, CodecInfo> CodecInfoMap = new HashMap<String, CodecInfo>(); 147 Map<String, CodecInfo> CodecInfoMap = new HashMap<String, CodecInfo>();
147 int count = MediaCodecList.getCodecCount(); 148 int count = MediaCodecList.getCodecCount();
148 for (int i = 0; i < count; ++i) { 149 for (int i = 0; i < count; ++i) {
149 MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); 150 MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
150 if (info.isEncoder()) { 151 if (info.isEncoder()) {
151 continue; 152 continue;
152 } 153 }
153 154
155 boolean secureDecoderSupported = false;
156 String codecString = info.getName();
157 // ".secure" codecs sometimes crash instead of throwing on pre-JBMR2
158 // platforms, but this code isn't run on them anyway (MediaDrm
159 // unavailable) so we side-step the issue.
wjia(left Chromium) 2013/11/06 02:23:27 Could you add the bug link here? Just for others'
160 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
161 String secureCodecName = codecString + ".secure";
162 try {
163 MediaCodec secureCodec = MediaCodec.createByCodecName(secure CodecName);
164 if (secureCodec != null) {
165 secureDecoderSupported = true;
166 secureCodec.release();
167 }
168 } catch (Exception e) {
169 Log.e(TAG, "Failed to create " + secureCodecName);
170 }
171 }
172
154 String[] supportedTypes = info.getSupportedTypes(); 173 String[] supportedTypes = info.getSupportedTypes();
155 String codecString = info.getName();
156 String secureCodecName = codecString + ".secure";
157 boolean secureDecoderSupported = false;
158 try {
159 MediaCodec secureCodec = MediaCodec.createByCodecName(secureCode cName);
160 secureDecoderSupported = true;
161 secureCodec.release();
162 } catch (Exception e) {
163 Log.e(TAG, "Failed to create " + secureCodecName);
164 }
165 for (int j = 0; j < supportedTypes.length; ++j) { 174 for (int j = 0; j < supportedTypes.length; ++j) {
166 if (!CodecInfoMap.containsKey(supportedTypes[j]) || secureDecode rSupported) { 175 if (!CodecInfoMap.containsKey(supportedTypes[j]) || secureDecode rSupported) {
167 CodecInfoMap.put(supportedTypes[j], new CodecInfo( 176 CodecInfoMap.put(supportedTypes[j], new CodecInfo(
168 supportedTypes[j], codecString, secureDecoderSupported)) ; 177 supportedTypes[j], codecString, secureDecoderSupported)) ;
169 } 178 }
170 } 179 }
171 } 180 }
172 return CodecInfoMap.values().toArray( 181 return CodecInfoMap.values().toArray(
173 new CodecInfo[CodecInfoMap.size()]); 182 new CodecInfo[CodecInfoMap.size()]);
174 } 183 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 489 }
481 490
482 private void resetLastPresentationTimeIfNeeded(long presentationTimeUs) { 491 private void resetLastPresentationTimeIfNeeded(long presentationTimeUs) {
483 if (mFlushed) { 492 if (mFlushed) {
484 mLastPresentationTimeUs = 493 mLastPresentationTimeUs =
485 Math.max(presentationTimeUs - MAX_PRESENTATION_TIMESTAMP_SHI FT_US, 0); 494 Math.max(presentationTimeUs - MAX_PRESENTATION_TIMESTAMP_SHI FT_US, 0);
486 mFlushed = false; 495 mFlushed = false;
487 } 496 }
488 } 497 }
489 } 498 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698