当前位置: 首页>>代码示例>>Java>>正文


Java CodecCapabilities类代码示例

本文整理汇总了Java中android.media.MediaCodecInfo.CodecCapabilities的典型用法代码示例。如果您正苦于以下问题:Java CodecCapabilities类的具体用法?Java CodecCapabilities怎么用?Java CodecCapabilities使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CodecCapabilities类属于android.media.MediaCodecInfo包,在下文中一共展示了CodecCapabilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMediaCodecInfo

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * Returns the name of the best decoder and its capabilities for the given mimeType.
 */
private static synchronized Pair<String, CodecCapabilities> getMediaCodecInfo(
    String mimeType, boolean secure) throws DecoderQueryException {
  CodecKey key = new CodecKey(mimeType, secure);
  if (codecs.containsKey(key)) {
    return codecs.get(key);
  }
  MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
      ? 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;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:25,代码来源:MediaCodecUtil.java

示例2: isH264ProfileSupported

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * @param profile An AVC profile constant from {@link CodecProfileLevel}.
 * @param level An AVC profile level from {@link CodecProfileLevel}.
 * @return Whether the specified profile is supported at the specified level.
 */
public static boolean isH264ProfileSupported(int profile, int level)
    throws DecoderQueryException {
  Pair<String, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264, false);
  if (info == null) {
    return false;
  }

  CodecCapabilities capabilities = info.second;
  for (int i = 0; i < capabilities.profileLevels.length; i++) {
    CodecProfileLevel profileLevel = capabilities.profileLevels[i];
    if (profileLevel.profile == profile && profileLevel.level >= level) {
      return true;
    }
  }

  return false;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:23,代码来源:MediaCodecUtil.java

示例3: getMediaCodecInfo

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * Returns the name of the best decoder and its capabilities for the given mimeType.
 */
private static synchronized Pair<String, CodecCapabilities> getMediaCodecInfo(
    String mimeType, boolean secure) {
  CodecKey key = new CodecKey(mimeType, secure);
  if (codecs.containsKey(key)) {
    return codecs.get(key);
  }
  MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
      ? 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;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:25,代码来源:MediaCodecUtil.java

示例4: isH264ProfileSupported

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * @param profile An AVC profile constant from {@link CodecProfileLevel}.
 * @param level An AVC profile level from {@link CodecProfileLevel}.
 * @return Whether the specified profile is supported at the specified level.
 */
public static boolean isH264ProfileSupported(int profile, int level) {
  Pair<String, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264, false);
  if (info == null) {
    return false;
  }

  CodecCapabilities capabilities = info.second;
  for (int i = 0; i < capabilities.profileLevels.length; i++) {
    CodecProfileLevel profileLevel = capabilities.profileLevels[i];
    if (profileLevel.profile == profile && profileLevel.level >= level) {
      return true;
    }
  }

  return false;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:22,代码来源:MediaCodecUtil.java

示例5: addVp9CodecProfileLevels

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
  * Needed on M and older to get correct information about VP9 support.
  * @param profileLevels The CodecProfileLevelList to add supported profile levels to.
  * @param videoCapabilities The MediaCodecInfo.VideoCapabilities used to infer support.
  */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void addVp9CodecProfileLevels(CodecProfileLevelList profileLevels,
        MediaCodecInfo.CodecCapabilities codecCapabilities) {
    // https://www.webmproject.org/vp9/levels
    final int[][] bitrateMapping = {
            {200, 10}, {800, 11}, {1800, 20}, {3600, 21}, {7200, 30}, {12000, 31}, {18000, 40},
            {30000, 41}, {60000, 50}, {120000, 51}, {180000, 52},
    };
    VideoCapabilities videoCapabilities = codecCapabilities.getVideoCapabilities();
    for (int[] entry : bitrateMapping) {
        int bitrate = entry[0];
        int level = entry[1];
        if (videoCapabilities.getBitrateRange().contains(bitrate)) {
            // Assume all platforms before N only support VP9 profile 0.
            profileLevels.addCodecProfileLevel(
                    VideoCodec.CODEC_VP9, VideoCodecProfile.VP9PROFILE_PROFILE0, level);
        }
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:25,代码来源:MediaCodecUtil.java

示例6: getSupportedCodecProfileLevels

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
  * Return an array of supported codecs and profiles.
  */
@CalledByNative
private static Object[] getSupportedCodecProfileLevels() {
    CodecProfileLevelList profileLevels = new CodecProfileLevelList();
    MediaCodecListHelper codecListHelper = new MediaCodecListHelper();
    for (MediaCodecInfo info : codecListHelper) {
        for (String mime : info.getSupportedTypes()) {
            // On versions L and M, VP9 codecCapabilities do not advertise profile level
            // support. In this case, estimate the level from MediaCodecInfo.VideoCapabilities
            // instead. Assume VP9 is not supported before L. For more information, consult
            // https://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html
            CodecCapabilities codecCapabilities = info.getCapabilitiesForType(mime);
            if (mime.endsWith("vp9") && Build.VERSION_CODES.LOLLIPOP <= Build.VERSION.SDK_INT
                    && Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
                addVp9CodecProfileLevels(profileLevels, codecCapabilities);
                continue;
            }
            for (CodecProfileLevel profileLevel : codecCapabilities.profileLevels) {
                profileLevels.addCodecProfileLevel(mime, profileLevel);
            }
        }
    }
    return profileLevels.toArray();
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:27,代码来源:MediaCodecUtil.java

示例7: codecSupportsAdaptivePlayback

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * Returns true if the given codec supports adaptive playback (dynamic resolution change).
 * @param mediaCodec the codec.
 * @param mime MIME type that corresponds to the codec creation.
 * @return true if this codec and mime type combination supports adaptive playback.
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private static boolean codecSupportsAdaptivePlayback(MediaCodec mediaCodec, String mime) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || mediaCodec == null) {
        return false;
    }
    try {
        MediaCodecInfo info = mediaCodec.getCodecInfo();
        if (info.isEncoder()) {
            return false;
        }

        if (isAdaptivePlaybackBlacklisted(mime)) {
            return false;
        }

        MediaCodecInfo.CodecCapabilities capabilities = info.getCapabilitiesForType(mime);
        return (capabilities != null)
                && capabilities.isFeatureSupported(
                           MediaCodecInfo.CodecCapabilities.FEATURE_AdaptivePlayback);
    } catch (IllegalArgumentException e) {
        Log.e(TAG, "Cannot retrieve codec information", e);
    }
    return false;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:31,代码来源:MediaCodecUtil.java

示例8: getMediaCodecInfo

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * Returns the best decoder and its capabilities for the given mimeType. If there's no decoder
 * returns null.
 */
private static synchronized Pair<MediaCodecInfo, CodecCapabilities> getMediaCodecInfo(
    String mimeType) {
  Pair<MediaCodecInfo, CodecCapabilities> result = codecs.get(mimeType);
  if (result != null) {
    return result;
  }
  int numberOfCodecs = MediaCodecList.getCodecCount();
  // Note: MediaCodecList is sorted by the framework such that the best decoders come first.
  for (int i = 0; i < numberOfCodecs; i++) {
    MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
    String codecName = info.getName();
    if (!info.isEncoder() && isOmxCodec(codecName)) {
      String[] supportedTypes = info.getSupportedTypes();
      for (int j = 0; j < supportedTypes.length; j++) {
        String supportedType = supportedTypes[j];
        if (supportedType.equalsIgnoreCase(mimeType)) {
          result = Pair.create(info, info.getCapabilitiesForType(supportedType));
          codecs.put(mimeType, result);
          return result;
        }
      }
    }
  }
  return null;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:30,代码来源:MediaCodecUtil.java

示例9: isH264ProfileSupported

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
/**
 * @param profile An AVC profile constant from {@link CodecProfileLevel}.
 * @param level An AVC profile level from {@link CodecProfileLevel}.
 * @return Whether the specified profile is supported at the specified level.
 */
public static boolean isH264ProfileSupported(int profile, int level) {
  Pair<MediaCodecInfo, CodecCapabilities> info = getMediaCodecInfo(MimeTypes.VIDEO_H264);
  if (info == null) {
    return false;
  }

  CodecCapabilities capabilities = info.second;
  for (int i = 0; i < capabilities.profileLevels.length; i++) {
    CodecProfileLevel profileLevel = capabilities.profileLevels[i];
    if (profileLevel.profile == profile && profileLevel.level >= level) {
      return true;
    }
  }

  return false;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:22,代码来源:MediaCodecUtil.java

示例10: decoderSupportsAdaptivePlayback

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
public static boolean decoderSupportsAdaptivePlayback(MediaCodecInfo decoderInfo) {
	// Possibly enable adaptive playback on KitKat and above
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
		if (isDecoderInList(blacklistedAdaptivePlaybackPrefixes, decoderInfo.getName())) {
			LimeLog.info("Decoder blacklisted for adaptive playback");
			return false;
		}

		try {
			if (decoderInfo.getCapabilitiesForType("video/avc").
					isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback))
			{
				// This will make getCapabilities() return that adaptive playback is supported
				LimeLog.info("Adaptive playback supported (FEATURE_AdaptivePlayback)");
				return true;
			}
		} catch (Exception e) {
			// Tolerate buggy codecs
		}
	}
	
	return false;
}
 
开发者ID:moonlight-stream,项目名称:moonlight-android,代码行数:24,代码来源:MediaCodecHelper.java

示例11: dumpDecoders

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
@SuppressWarnings("RedundantThrows")
   public static String dumpDecoders() throws Exception {
	String str = "";
	for (MediaCodecInfo codecInfo : getMediaCodecList()) {
		// Skip encoders
		if (codecInfo.isEncoder()) {
			continue;
		}
		
		str += "Decoder: "+codecInfo.getName()+"\n";
		for (String type : codecInfo.getSupportedTypes()) {
			str += "\t"+type+"\n";
			CodecCapabilities caps = codecInfo.getCapabilitiesForType(type);
			
			for (CodecProfileLevel profile : caps.profileLevels) {
				str += "\t\t"+profile.profile+" "+profile.level+"\n";
			}
		}
	}
	return str;
}
 
开发者ID:moonlight-stream,项目名称:moonlight-android,代码行数:22,代码来源:MediaCodecHelper.java

示例12: getAVCLevel

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
public static int getAVCLevel() {
    int maxAVCLevel = 0;
    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, "getAVCLevel()->name:" + mediaCodecInfo.getName());
                for (String type : mediaCodecInfo.getSupportedTypes()) {
                    if (type.contains("avc")) {
                        Log.d(LOG_TAG, "getAVCLevel()->type:" + type);
                        try {
                            CodecCapabilities codecCapabilities = mediaCodecInfo.getCapabilitiesForType(type);
                            for (int colorFormat : codecCapabilities.colorFormats) {
                                Log.d(LOG_TAG, "getAVCLevel()->Color Format: " + colorFormat + " " + colorFormatToString(colorFormat));
                            }
                            for (CodecProfileLevel codecProfileLevel : codecCapabilities.profileLevels) {
                                String level = "unknown type";
                                String sprofile = "unknown type";
                                Log.d(LOG_TAG, "getAVCLevel()->Codec Profile Level:" + avcLevelToString(codecProfileLevel.level) + " profile:" + avcProfileToString(codecProfileLevel.profile));
                                if (codecProfileLevel.level > maxAVCLevel) {
                                    maxAVCLevel = codecProfileLevel.level;
                                }
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
        Log.d(LOG_TAG, "getAVCLevel()->Max AVCLevel:" + maxAVCLevel + " " + avcProfileToString(maxAVCLevel));
    }
    return maxAVCLevel;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:36,代码来源:CodecWrapper.java

示例13: getProfile

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:37,代码来源:CodecWrapper.java

示例14: dumpProfileLevels

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void dumpProfileLevels(String mimeType) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
        return;

    try {
        CodecCapabilities caps = mCodecInfo
                .getCapabilitiesForType(mimeType);
        int maxProfile = 0;
        int maxLevel = 0;
        if (caps != null) {
            if (caps.profileLevels != null) {
                for (CodecProfileLevel profileLevel : caps.profileLevels) {
                    if (profileLevel == null)
                        continue;

                    maxProfile = Math.max(maxProfile, profileLevel.profile);
                    maxLevel = Math.max(maxLevel, profileLevel.level);
                }
            }
        }

        Log.i(TAG,
                String.format(Locale.US, "%s",
                        getProfileLevelName(maxProfile, maxLevel)));
    } catch (Throwable e) {
        Log.i(TAG, "profile-level: exception");
    }
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:30,代码来源:IjkMediaCodecInfo.java

示例15: selectColorFormat

import android.media.MediaCodecInfo.CodecCapabilities; //导入依赖的package包/类
static Integer selectColorFormat(int[] supportedColorFormats, CodecCapabilities capabilities) {
  for (int supportedColorFormat : supportedColorFormats) {
    for (int codecColorFormat : capabilities.colorFormats) {
      if (codecColorFormat == supportedColorFormat) {
        return codecColorFormat;
      }
    }
  }
  return null;
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:11,代码来源:MediaCodecUtils.java


注:本文中的android.media.MediaCodecInfo.CodecCapabilities类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。