Java Code Examples for android.media.MediaCodecList#REGULAR_CODECS

The following examples show how to use android.media.MediaCodecList#REGULAR_CODECS . 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: AudioUtils.java    From AlexaAndroid with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
 
Example 2
Source File: AudioUtils.java    From AlexaAndroid with GNU General Public License v2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(MediaFormatFactory.Type.FLAC, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                if (info.getName().equals(encoderAsStr)) {
                    encoders.add("*** " + info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                } else {
                    encoders.add(info.getName() + ": " + TextUtils.join(", ", info.getSupportedTypes()));
                }
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
 
Example 3
Source File: AudioUtils.java    From speechutils with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static List<String> getAvailableEncoders(String mime, int sampleRate) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        MediaFormat format = MediaFormatFactory.createMediaFormat(mime, sampleRate);
        MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
        String encoderAsStr = mcl.findEncoderForFormat(format);
        List<String> encoders = new ArrayList<>();
        for (MediaCodecInfo info : mcl.getCodecInfos()) {
            if (info.isEncoder()) {
                String name = info.getName();
                String infoAsStr = name + ": " + TextUtils.join(", ", info.getSupportedTypes());
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
                    infoAsStr += String.format(": %s/%s/%s/%s", info.isHardwareAccelerated(), info.isSoftwareOnly(), info.isAlias(), info.isVendor());
                }
                if (name.equals(encoderAsStr)) {
                    infoAsStr = '#' + infoAsStr;
                }
                encoders.add(infoAsStr);
            }
        }
        return encoders;
    }
    return Collections.emptyList();
}
 
Example 4
Source File: MediaCodecUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("nullness:initialization.fields.uninitialized")
public MediaCodecListCompatV21(boolean includeSecure, boolean includeTunneling) {
  codecKind =
      includeSecure || includeTunneling
          ? MediaCodecList.ALL_CODECS
          : MediaCodecList.REGULAR_CODECS;
}
 
Example 5
Source File: MediaCodecCapabilitiesTest.java    From jellyfin-androidtv with GNU General Public License v2.0 5 votes vote down vote up
private boolean supports(
        String mime, boolean isEncoder, int profile, int level) {
    MediaCodecList mcl = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
    for (MediaCodecInfo info : mcl.getCodecInfos()) {
        if (isEncoder != info.isEncoder()) {
            continue;
        }
        try {
            MediaCodecInfo.CodecCapabilities caps = info.getCapabilitiesForType(mime);
            for (MediaCodecInfo.CodecProfileLevel pl : caps.profileLevels) {
                if (pl.profile != profile) {
                    continue;
                }
                // H.263 levels are not completely ordered:
                // Level45 support only implies Level10 support
                if (mime.equalsIgnoreCase(MIMETYPE_VIDEO_H263)) {
                    if (pl.level != level && pl.level == H263Level45 && level > H263Level10) {
                        continue;
                    }
                }
                if (pl.level >= level) {
                    return true;
                }
            }
        } catch (IllegalArgumentException e) {
            Timber.e(e);
        }
    }
    return false;
}
 
Example 6
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public MediaCodecListCompatV21(boolean includeSecure) {
  codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
 
Example 7
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public MediaCodecListCompatV21(boolean includeSecure) {
  codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
 
Example 8
Source File: MediaCodecUtil.java    From K-Sonic with MIT License 4 votes vote down vote up
public MediaCodecListCompatV21(boolean includeSecure) {
  codecKind = includeSecure ? MediaCodecList.ALL_CODECS : MediaCodecList.REGULAR_CODECS;
}
 
Example 9
Source File: MediaCodecUtil.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public MediaCodecListCompatV21(boolean includeSecure, boolean includeTunneling) {
  codecKind =
      includeSecure || includeTunneling
          ? MediaCodecList.ALL_CODECS
          : MediaCodecList.REGULAR_CODECS;
}
 
Example 10
Source File: MediaCodecUtil.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public MediaCodecListCompatV21(boolean includeSecure, boolean includeTunneling) {
  codecKind =
      includeSecure || includeTunneling
          ? MediaCodecList.ALL_CODECS
          : MediaCodecList.REGULAR_CODECS;
}