Java Code Examples for android.media.MediaCodecInfo.CodecProfileLevel#HEVCProfileMain10

The following examples show how to use android.media.MediaCodecInfo.CodecProfileLevel#HEVCProfileMain10 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaCodecUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 2
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 3
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 4
Source File: MediaCodecUtil.java    From K-Sonic with MIT License 5 votes vote down vote up
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);
}
 
Example 5
Source File: MediaCodecUtil.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 6
Source File: MediaCodecUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: CodecProfileLevelList.java    From 365browser with Apache License 2.0 4 votes vote down vote up
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();
    }
}