下面列出了android.media.MediaCodecInfo.CodecProfileLevel# HEVCProfileMain10 ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Nullable
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
@Nullable String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
@Nullable String levelString = parts[3];
@Nullable Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(levelString);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + levelString);
return null;
}
return new Pair<>(profile, level);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(parts[3]);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + matcher.group(1));
return null;
}
return new Pair<>(profile, level);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(parts[3]);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + matcher.group(1));
return null;
}
return new Pair<>(profile, level);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(parts[3]);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + matcher.group(1));
return null;
}
return new Pair<>(profile, level);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
String levelString = parts[3];
Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(levelString);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + levelString);
return null;
}
return new Pair<>(profile, level);
}
private static Pair<Integer, Integer> getHevcProfileAndLevel(String codec, String[] parts) {
if (parts.length < 4) {
// The codec has fewer parts than required by the HEVC codec string format.
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
// The profile_space gets ignored.
Matcher matcher = PROFILE_PATTERN.matcher(parts[1]);
if (!matcher.matches()) {
Log.w(TAG, "Ignoring malformed HEVC codec string: " + codec);
return null;
}
String profileString = matcher.group(1);
int profile;
if ("1".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain;
} else if ("2".equals(profileString)) {
profile = CodecProfileLevel.HEVCProfileMain10;
} else {
Log.w(TAG, "Unknown HEVC profile string: " + profileString);
return null;
}
String levelString = parts[3];
Integer level = HEVC_CODEC_STRING_TO_PROFILE_LEVEL.get(levelString);
if (level == null) {
Log.w(TAG, "Unknown HEVC level string: " + levelString);
return null;
}
return new Pair<>(profile, level);
}
private static int mediaCodecProfileToChromiumMediaProfile(int codec, int profile) {
switch (codec) {
case VideoCodec.CODEC_H264:
switch (profile) {
case CodecProfileLevel.AVCProfileBaseline:
return VideoCodecProfile.H264PROFILE_BASELINE;
case CodecProfileLevel.AVCProfileMain:
return VideoCodecProfile.H264PROFILE_MAIN;
case CodecProfileLevel.AVCProfileExtended:
return VideoCodecProfile.H264PROFILE_EXTENDED;
case CodecProfileLevel.AVCProfileHigh:
return VideoCodecProfile.H264PROFILE_HIGH;
case CodecProfileLevel.AVCProfileHigh10:
return VideoCodecProfile.H264PROFILE_HIGH10PROFILE;
case CodecProfileLevel.AVCProfileHigh422:
return VideoCodecProfile.H264PROFILE_HIGH422PROFILE;
case CodecProfileLevel.AVCProfileHigh444:
return VideoCodecProfile.H264PROFILE_HIGH444PREDICTIVEPROFILE;
default:
throw new UnsupportedCodecProfileException();
}
case VideoCodec.CODEC_VP8:
switch (profile) {
case CodecProfileLevel.VP8ProfileMain:
return VideoCodecProfile.VP8PROFILE_ANY;
default:
throw new UnsupportedCodecProfileException();
}
case VideoCodec.CODEC_VP9:
switch (profile) {
case CodecProfileLevel.VP9Profile0:
return VideoCodecProfile.VP9PROFILE_PROFILE0;
case CodecProfileLevel.VP9Profile1:
return VideoCodecProfile.VP9PROFILE_PROFILE1;
case CodecProfileLevel.VP9Profile2:
return VideoCodecProfile.VP9PROFILE_PROFILE2;
case CodecProfileLevel.VP9Profile3:
return VideoCodecProfile.VP9PROFILE_PROFILE3;
default:
throw new UnsupportedCodecProfileException();
}
case VideoCodec.CODEC_HEVC:
switch (profile) {
case CodecProfileLevel.HEVCProfileMain:
return VideoCodecProfile.HEVCPROFILE_MAIN;
case CodecProfileLevel.HEVCProfileMain10:
return VideoCodecProfile.HEVCPROFILE_MAIN10;
case CodecProfileLevel.HEVCProfileMain10HDR10:
return VideoCodecProfile.HEVCPROFILE_MAIN_STILL_PICTURE;
default:
throw new UnsupportedCodecProfileException();
}
default:
throw new UnsupportedCodecProfileException();
}
}