| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.media.MediaCodec; | 8 import android.media.MediaCodec; |
| 9 import android.media.MediaCodec.CryptoInfo; | 9 import android.media.MediaCodec.CryptoInfo; |
| 10 import android.media.MediaCodecInfo; | 10 import android.media.MediaCodecInfo; |
| 11 import android.media.MediaCodecInfo.CodecCapabilities; | 11 import android.media.MediaCodecInfo.CodecCapabilities; |
| 12 import android.media.MediaCodecInfo.CodecProfileLevel; | 12 import android.media.MediaCodecInfo.CodecProfileLevel; |
| 13 import android.media.MediaCodecInfo.VideoCapabilities; | 13 import android.media.MediaCodecInfo.VideoCapabilities; |
| 14 import android.media.MediaCodecList; | 14 import android.media.MediaCodecList; |
| 15 import android.media.MediaFormat; |
| 15 import android.os.Build; | 16 import android.os.Build; |
| 16 | 17 |
| 17 import org.chromium.base.Log; | 18 import org.chromium.base.Log; |
| 18 import org.chromium.base.annotations.CalledByNative; | 19 import org.chromium.base.annotations.CalledByNative; |
| 19 import org.chromium.base.annotations.JNINamespace; | 20 import org.chromium.base.annotations.JNINamespace; |
| 20 import org.chromium.base.annotations.MainDex; | 21 import org.chromium.base.annotations.MainDex; |
| 21 | 22 |
| 22 import java.util.Arrays; | 23 import java.util.Arrays; |
| 23 import java.util.Iterator; | 24 import java.util.Iterator; |
| 24 import java.util.List; | 25 import java.util.List; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 result.supportsAdaptivePlayback = | 302 result.supportsAdaptivePlayback = |
| 302 codecSupportsAdaptivePlayback(insecureCodec, mime); | 303 codecSupportsAdaptivePlayback(insecureCodec, mime); |
| 303 insecureCodec.release(); | 304 insecureCodec.release(); |
| 304 } | 305 } |
| 305 result.mediaCodec = MediaCodec.createByCodecName(decoderName + "
.secure"); | 306 result.mediaCodec = MediaCodec.createByCodecName(decoderName + "
.secure"); |
| 306 } else { | 307 } else { |
| 307 if (requireSoftwareCodec) { | 308 if (requireSoftwareCodec) { |
| 308 String decoderName = getDefaultCodecName( | 309 String decoderName = getDefaultCodecName( |
| 309 mime, MediaCodecDirection.DECODER, requireSoftwareCo
dec); | 310 mime, MediaCodecDirection.DECODER, requireSoftwareCo
dec); |
| 310 result.mediaCodec = MediaCodec.createByCodecName(decoderName
); | 311 result.mediaCodec = MediaCodec.createByCodecName(decoderName
); |
| 312 } else if (mime.equals(MediaFormat.MIMETYPE_AUDIO_RAW)) { |
| 313 result.mediaCodec = MediaCodec.createByCodecName("OMX.google
.raw.decoder"); |
| 311 } else { | 314 } else { |
| 312 result.mediaCodec = MediaCodec.createDecoderByType(mime); | 315 result.mediaCodec = MediaCodec.createDecoderByType(mime); |
| 313 } | 316 } |
| 314 result.supportsAdaptivePlayback = | 317 result.supportsAdaptivePlayback = |
| 315 codecSupportsAdaptivePlayback(result.mediaCodec, mime); | 318 codecSupportsAdaptivePlayback(result.mediaCodec, mime); |
| 316 } | 319 } |
| 317 } catch (Exception e) { | 320 } catch (Exception e) { |
| 318 Log.e(TAG, "Failed to create MediaCodec: %s, isSecure: %s, requireSo
ftwareCodec: %s", | 321 Log.e(TAG, "Failed to create MediaCodec: %s, isSecure: %s, requireSo
ftwareCodec: %s", |
| 319 mime, isSecure, requireSoftwareCodec ? "yes" : "no", e); | 322 mime, isSecure, requireSoftwareCodec ? "yes" : "no", e); |
| 320 result.mediaCodec = null; | 323 result.mediaCodec = null; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 * supported. | 636 * supported. |
| 634 * This method was introduced in Android N. Note that if platformSupportsCbc
sEncryption | 637 * This method was introduced in Android N. Note that if platformSupportsCbc
sEncryption |
| 635 * returns true, then this function will set the pattern. | 638 * returns true, then this function will set the pattern. |
| 636 */ | 639 */ |
| 637 static void setPatternIfSupported(CryptoInfo cryptoInfo, int encrypt, int sk
ip) { | 640 static void setPatternIfSupported(CryptoInfo cryptoInfo, int encrypt, int sk
ip) { |
| 638 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 641 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 639 cryptoInfo.setPattern(new CryptoInfo.Pattern(encrypt, skip)); | 642 cryptoInfo.setPattern(new CryptoInfo.Pattern(encrypt, skip)); |
| 640 } | 643 } |
| 641 } | 644 } |
| 642 } | 645 } |
| OLD | NEW |