本文整理汇总了Java中android.media.MediaCodecInfo.getSupportedTypes方法的典型用法代码示例。如果您正苦于以下问题:Java MediaCodecInfo.getSupportedTypes方法的具体用法?Java MediaCodecInfo.getSupportedTypes怎么用?Java MediaCodecInfo.getSupportedTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.media.MediaCodecInfo
的用法示例。
在下文中一共展示了MediaCodecInfo.getSupportedTypes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* Initialize HeifReader module.
*
* @param context Context.
*/
public static void initialize(Context context) {
mRenderScript = RenderScript.create(context);
mCacheDir = context.getCacheDir();
// find best HEVC decoder
mDecoderName = null;
mDecoderSupportedSize = new Size(0, 0);
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (codecInfo.isEncoder()) {
continue;
}
for (String type : codecInfo.getSupportedTypes()) {
if (type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC)) {
MediaCodecInfo.CodecCapabilities cap = codecInfo.getCapabilitiesForType(MediaFormat.MIMETYPE_VIDEO_HEVC);
MediaCodecInfo.VideoCapabilities vcap = cap.getVideoCapabilities();
Size supportedSize = new Size(vcap.getSupportedWidths().getUpper(), vcap.getSupportedHeights().getUpper());
Log.d(TAG, "HEVC decoder=\"" + codecInfo.getName() + "\""
+ " supported-size=" + supportedSize
+ " color-formats=" + Arrays.toString(cap.colorFormats)
);
if (mDecoderSupportedSize.getWidth() * mDecoderSupportedSize.getHeight() < supportedSize.getWidth() * supportedSize.getHeight()) {
mDecoderName = codecInfo.getName();
mDecoderSupportedSize = supportedSize;
}
}
}
}
if (mDecoderName == null) {
throw new RuntimeException("no HEVC decoding support");
}
Log.i(TAG, "HEVC decoder=\"" + mDecoderName + "\" supported-size=" + mDecoderSupportedSize);
}
示例2: selectCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* Returns the first codec capable of encoding the specified MIME type, or null if no match was
* found.
*/
@TargetApi(18)
public static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(mimeType)) {
return codecInfo;
}
}
}
return null;
}
示例3: printInfo
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void printInfo() {
MediaCodecList list = new MediaCodecList(MediaCodecList.ALL_CODECS);
MediaCodecInfo[] codecInfos = list.getCodecInfos();
for (MediaCodecInfo info : codecInfos) {
if (info.isEncoder()) {
StringBuilder sb = new StringBuilder();
sb.append(info.getName() + " types=");
String[] supportedTypes = info.getSupportedTypes();
for (String string : supportedTypes) {
sb.append(" " + string);
}
LogUtil.e(sb.toString());
}
}
}
示例4: selectCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@SuppressLint("NewApi")
public static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
MediaCodecInfo lastCodecInfo = null;
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
lastCodecInfo = codecInfo;
if (!lastCodecInfo.getName().equals("OMX.SEC.avc.enc")) {
return lastCodecInfo;
} else if (lastCodecInfo.getName().equals("OMX.SEC.AVC.Encoder")) {
return lastCodecInfo;
}
}
}
}
return lastCodecInfo;
}
示例5: selectAudioCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* select the first codec that match a specific MIME type
* @param mimeType
* @return
*/
private static final MediaCodecInfo selectAudioCodec(final String mimeType) {
if (DEBUG) Log.v(TAG, "selectAudioCodec:");
MediaCodecInfo result = null;
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
LOOP: for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
final String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (DEBUG) Log.i(TAG, "supportedType:" + codecInfo.getName() + ",MIME=" + types[j]);
if (types[j].equalsIgnoreCase(mimeType)) {
if (result == null) {
result = codecInfo;
break LOOP;
}
}
}
}
return result;
}
示例6: selectVideoCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private static MediaCodecInfo selectVideoCodec(final String mimeType) {
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
// select first codec that match a specific MIME type and color format
for (String type : codecInfo.getSupportedTypes()) {
if (type.equalsIgnoreCase(mimeType)) {
final int format = selectColorFormat(codecInfo, mimeType);
if (format > 0) {
return codecInfo;
}
}
}
}
return null;
}
示例7: FindHardWareEncoder16
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private static String FindHardWareEncoder16(String mime) {
int mediaCodecCount = MediaCodecList.getCodecCount();
for (int i = 0; i < mediaCodecCount; i++) {
MediaCodecInfo mediaCodecInfo = MediaCodecList.getCodecInfoAt(i);
if (!mediaCodecInfo.isEncoder()) {
continue;
}
String types[] = mediaCodecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(mime)) {
String decoderName = mediaCodecInfo.getName();
Log.e(ERROR_TAGE, "hwDecoderName = " + decoderName);
boolean isHardwareEncode = (decoderName.indexOf("google") == -1);
if (isHardwareEncode) {
return decoderName;
}
}
}
}
return null;
}
示例8: selectAudioCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private static MediaCodecInfo selectAudioCodec(final String mimeType) {
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
final String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
return codecInfo;
}
}
}
return null;
}
示例9: selectVideoCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* select the first codec that match a specific MIME type
* @param mimeType
* @return null if no codec matched
*/
protected static final MediaCodecInfo selectVideoCodec(final String mimeType) {
if (DEBUG) Log.v(TAG, "selectVideoCodec:");
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
// select first codec that match a specific MIME type and color format
final String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(mimeType)) {
if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]);
final int format = selectColorFormat(codecInfo, mimeType);
if (format > 0) {
return codecInfo;
}
}
}
}
return null;
}
示例10: selectAudioCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* select the first codec that match a specific MIME type
* @param mimeType
* @return
*/
private static final MediaCodecInfo selectAudioCodec(final String mimeType) {
if (DEBUG) Log.v(TAG, "selectAudioCodec:");
MediaCodecInfo result = null;
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
final String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (DEBUG) Log.i(TAG, "supportedType:" + codecInfo.getName() + ",MIME=" + types[j]);
if (types[j].equalsIgnoreCase(mimeType)) {
if (result == null) {
result = codecInfo;
return result;
}
}
}
}
return result;
}
示例11: selectCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
public static MediaCodecInfo selectCodec(String mimeType) {
int numCodecs = MediaCodecList.getCodecCount();
MediaCodecInfo lastCodecInfo = null;
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) {
continue;
}
String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(mimeType)) {
lastCodecInfo = codecInfo;
if (!lastCodecInfo.getName().equals("OMX.SEC.avc.enc")) {
return lastCodecInfo;
} else if (lastCodecInfo.getName().equals("OMX.SEC.AVC.Encoder")) {
return lastCodecInfo;
}
}
}
}
return lastCodecInfo;
}
示例12: selectVideoCodec
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
/**
* select the first codec that match a specific MIME type
*
* @param mimeType
* @return null if no codec matched
*/
protected static final MediaCodecInfo selectVideoCodec(final String mimeType) {
if (DEBUG) Log.v(TAG, "selectVideoCodec:");
// get the list of available codecs
final int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
final MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
if (!codecInfo.isEncoder()) { // skipp decoder
continue;
}
// select first codec that match a specific MIME type and color format
final String[] types = codecInfo.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(mimeType)) {
if (DEBUG) Log.i(TAG, "codec:" + codecInfo.getName() + ",MIME=" + types[j]);
final int format = selectColorFormat(codecInfo, mimeType);
if (format > 0) {
return codecInfo;
}
}
}
}
return null;
}
示例13: chooseVideoEncoder
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
private MediaCodecInfo chooseVideoEncoder(String name) {
int nbCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < nbCodecs; i++) {
MediaCodecInfo mci = MediaCodecList.getCodecInfoAt(i);
if (!mci.isEncoder()) {
continue;
}
String[] types = mci.getSupportedTypes();
for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(VCODEC)) {
Log.i(TAG, String.format("vencoder %s types: %s", mci.getName(), types[j]));
if (name == null) {
return mci;
}
if (mci.getName().contains(name)) {
return mci;
}
}
}
}
return null;
}
示例14: getProfile
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
public static int getProfile() {
int maxProfile = 0;
Log.d(LOG_TAG, "getProfile()->Build.VERSION.SDK_INT:" + String.valueOf(VERSION.SDK_INT));
if (VERSION.SDK_INT >= 16) {
int mediaCodecListCount = MediaCodecList.getCodecCount();
for (int i = 0; i < mediaCodecListCount; i++) {
MediaCodecInfo mediaCodecInfo = MediaCodecList.getCodecInfoAt(i);
if (!(mediaCodecInfo.isEncoder() || mediaCodecInfo.getName().startsWith("OMX.google") || mediaCodecInfo.getName().startsWith("OMX.TI."))) {
Log.d(LOG_TAG, "getProfile()->name:" + mediaCodecInfo.getName());
for (String type : mediaCodecInfo.getSupportedTypes()) {
if (type.contains("avc")) {
Log.d(LOG_TAG, "getProfile()->type:" + type);
try {
CodecCapabilities codecCapabilities = mediaCodecInfo.getCapabilitiesForType(type);
for (int colorFormat : codecCapabilities.colorFormats) {
Log.d(LOG_TAG, "getProfile()->Color Format: " + colorFormat + " " + colorFormatToString(colorFormat));
}
for (CodecProfileLevel codecProfileLevel : codecCapabilities.profileLevels) {
String level = "unknown type";
String sprofile = "unknown type";
Log.d(LOG_TAG, "getProfile()->Codec Profile Level:" + avcLevelToString(codecProfileLevel.level) + " profile:" + avcProfileToString(codecProfileLevel.profile));
if (codecProfileLevel.profile > maxProfile) {
maxProfile = codecProfileLevel.profile;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
Log.d(LOG_TAG, "getProfile()->Max profile:" + maxProfile + " " + avcProfileToString(maxProfile));
}
return maxProfile;
}
示例15: isCodecInfoSupported
import android.media.MediaCodecInfo; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private static boolean isCodecInfoSupported(MediaCodecInfo codecInfo, String codecType, boolean allowSwCodec) {
if (codecInfo.isEncoder())
// || (!allowSwCodec && ( codecInfo.getName().startsWith("OMX.google")
// || codecInfo.getName().toLowerCase().contains("sw") )))
return false;
String[] types = codecInfo.getSupportedTypes();
for (String type : types) {
if (type.equalsIgnoreCase(codecType))
return true;
}
return false;
}