mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
commit
035671b722
@ -19,7 +19,7 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:0.14.+'
|
classpath 'com.android.tools.build:gradle:1.0.0-rc1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ apply plugin: 'com.android.application'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 21
|
compileSdkVersion 21
|
||||||
buildToolsVersion "19.1"
|
buildToolsVersion "21.1.1"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.google.android.exoplayer.demo"
|
package="com.google.android.exoplayer.demo"
|
||||||
android:versionCode="1013"
|
android:versionCode="1100"
|
||||||
android:versionName="1.0.13"
|
android:versionName="1.1.00"
|
||||||
android:theme="@style/RootTheme">
|
android:theme="@style/RootTheme">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
@ -15,7 +15,7 @@ apply plugin: 'com.android.library'
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 21
|
compileSdkVersion 21
|
||||||
buildToolsVersion "19.1"
|
buildToolsVersion "21.1.1"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
|
@ -26,15 +26,15 @@ public class ExoPlayerLibraryInfo {
|
|||||||
/**
|
/**
|
||||||
* The version of the library, expressed as a string.
|
* The version of the library, expressed as a string.
|
||||||
*/
|
*/
|
||||||
public static final String VERSION = "1.0.13";
|
public static final String VERSION = "1.1.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The version of the library, expressed as an integer.
|
* The version of the library, expressed as an integer.
|
||||||
* <p>
|
* <p>
|
||||||
* Three digits are used for each component of {@link #VERSION}. For example "1.2.3" has the
|
* Three digits are used for each component of {@link #VERSION}. For example "1.2.3" has the
|
||||||
* corresponding integer version 1002003.
|
* corresponding integer version 001002003.
|
||||||
*/
|
*/
|
||||||
public static final int VERSION_INT = 1000013;
|
public static final int VERSION_INT = 001001000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the library was compiled with {@link com.google.android.exoplayer.util.Assertions}
|
* Whether the library was compiled with {@link com.google.android.exoplayer.util.Assertions}
|
||||||
|
@ -24,6 +24,7 @@ import android.media.MediaCodecInfo.CodecCapabilities;
|
|||||||
import android.media.MediaCodecInfo.CodecProfileLevel;
|
import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||||
import android.media.MediaCodecList;
|
import android.media.MediaCodecList;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -34,6 +35,8 @@ import java.util.HashMap;
|
|||||||
@TargetApi(16)
|
@TargetApi(16)
|
||||||
public class MediaCodecUtil {
|
public class MediaCodecUtil {
|
||||||
|
|
||||||
|
private static final String TAG = "MediaCodecUtil";
|
||||||
|
|
||||||
private static final HashMap<CodecKey, Pair<String, CodecCapabilities>> codecs =
|
private static final HashMap<CodecKey, Pair<String, CodecCapabilities>> codecs =
|
||||||
new HashMap<CodecKey, Pair<String, CodecCapabilities>>();
|
new HashMap<CodecKey, Pair<String, CodecCapabilities>>();
|
||||||
|
|
||||||
@ -77,6 +80,23 @@ public class MediaCodecUtil {
|
|||||||
}
|
}
|
||||||
MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
|
MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
|
||||||
? new MediaCodecListCompatV21(secure) : new MediaCodecListCompatV16();
|
? new MediaCodecListCompatV21(secure) : new MediaCodecListCompatV16();
|
||||||
|
Pair<String, CodecCapabilities> codecInfo = getMediaCodecInfo(key, mediaCodecList);
|
||||||
|
// TODO: Verify this cannot occur on v22, and change >= to == [Internal: b/18678462].
|
||||||
|
if (secure && codecInfo == null && Util.SDK_INT >= 21) {
|
||||||
|
// Some devices don't list secure decoders on API level 21. Try the legacy path.
|
||||||
|
mediaCodecList = new MediaCodecListCompatV16();
|
||||||
|
codecInfo = getMediaCodecInfo(key, mediaCodecList);
|
||||||
|
if (codecInfo != null) {
|
||||||
|
Log.w(TAG, "MediaCodecList API didn't list secure decoder for: " + mimeType
|
||||||
|
+ ". Assuming: " + codecInfo.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return codecInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Pair<String, CodecCapabilities> getMediaCodecInfo(CodecKey key,
|
||||||
|
MediaCodecListCompat mediaCodecList) {
|
||||||
|
String mimeType = key.mimeType;
|
||||||
int numberOfCodecs = mediaCodecList.getCodecCount();
|
int numberOfCodecs = mediaCodecList.getCodecCount();
|
||||||
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
|
boolean secureDecodersExplicit = mediaCodecList.secureDecodersExplicit();
|
||||||
// Note: MediaCodecList is sorted by the framework such that the best decoders come first.
|
// Note: MediaCodecList is sorted by the framework such that the best decoders come first.
|
||||||
@ -90,18 +110,19 @@ public class MediaCodecUtil {
|
|||||||
String supportedType = supportedTypes[j];
|
String supportedType = supportedTypes[j];
|
||||||
if (supportedType.equalsIgnoreCase(mimeType)) {
|
if (supportedType.equalsIgnoreCase(mimeType)) {
|
||||||
CodecCapabilities capabilities = info.getCapabilitiesForType(supportedType);
|
CodecCapabilities capabilities = info.getCapabilitiesForType(supportedType);
|
||||||
|
boolean secure = mediaCodecList.isSecurePlaybackSupported(key.mimeType, capabilities);
|
||||||
if (!secureDecodersExplicit) {
|
if (!secureDecodersExplicit) {
|
||||||
// Cache variants for secure and insecure playback. Note that the secure decoder is
|
// Cache variants for both insecure and (if we think it's supported) secure playback.
|
||||||
// inferred, and may not actually exist.
|
|
||||||
codecs.put(key.secure ? new CodecKey(mimeType, false) : key,
|
codecs.put(key.secure ? new CodecKey(mimeType, false) : key,
|
||||||
Pair.create(codecName, capabilities));
|
Pair.create(codecName, capabilities));
|
||||||
|
if (secure) {
|
||||||
codecs.put(key.secure ? key : new CodecKey(mimeType, true),
|
codecs.put(key.secure ? key : new CodecKey(mimeType, true),
|
||||||
Pair.create(codecName + ".secure", capabilities));
|
Pair.create(codecName + ".secure", capabilities));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// We can only cache this variant. The other should be listed explicitly.
|
// Only cache this variant. If both insecure and secure decoders are available, they
|
||||||
boolean codecSecure = mediaCodecList.isSecurePlaybackSupported(
|
// should both be listed separately.
|
||||||
info.getCapabilitiesForType(supportedType));
|
codecs.put(key.secure == secure ? key : new CodecKey(mimeType, secure),
|
||||||
codecs.put(key.secure == codecSecure ? key : new CodecKey(mimeType, codecSecure),
|
|
||||||
Pair.create(codecName, capabilities));
|
Pair.create(codecName, capabilities));
|
||||||
}
|
}
|
||||||
if (codecs.containsKey(key)) {
|
if (codecs.containsKey(key)) {
|
||||||
@ -219,10 +240,8 @@ public class MediaCodecUtil {
|
|||||||
/**
|
/**
|
||||||
* Whether secure playback is supported for the given {@link CodecCapabilities}, which should
|
* Whether secure playback is supported for the given {@link CodecCapabilities}, which should
|
||||||
* have been obtained from a {@link MediaCodecInfo} obtained from this list.
|
* have been obtained from a {@link MediaCodecInfo} obtained from this list.
|
||||||
* <p>
|
|
||||||
* May only be called if {@link #secureDecodersExplicit()} returns true.
|
|
||||||
*/
|
*/
|
||||||
public boolean isSecurePlaybackSupported(CodecCapabilities capabilities);
|
public boolean isSecurePlaybackSupported(String mimeType, CodecCapabilities capabilities);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +271,7 @@ public class MediaCodecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSecurePlaybackSupported(CodecCapabilities capabilities) {
|
public boolean isSecurePlaybackSupported(String mimeType, CodecCapabilities capabilities) {
|
||||||
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback);
|
return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_SecurePlayback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,8 +296,10 @@ public class MediaCodecUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSecurePlaybackSupported(CodecCapabilities capabilities) {
|
public boolean isSecurePlaybackSupported(String mimeType, CodecCapabilities capabilities) {
|
||||||
throw new UnsupportedOperationException();
|
// Secure decoders weren't explicitly listed prior to API level 21. We assume that a secure
|
||||||
|
// H264 decoder exists.
|
||||||
|
return MimeTypes.VIDEO_H264.equals(mimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user