本文整理汇总了Java中com.google.android.exoplayer2.mediacodec.MediaCodecUtil类的典型用法代码示例。如果您正苦于以下问题:Java MediaCodecUtil类的具体用法?Java MediaCodecUtil怎么用?Java MediaCodecUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaCodecUtil类属于com.google.android.exoplayer2.mediacodec包,在下文中一共展示了MediaCodecUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isL1WidevineAvailable
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@TargetApi(18)
@SuppressWarnings("ResourceType")
private static boolean isL1WidevineAvailable(String videoMimeType) {
try {
// Force L3 if secure decoder is not available.
if (MediaCodecUtil.getDecoderInfo(videoMimeType, true) == null) {
return false;
}
MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID);
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
mediaDrm.release();
return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty);
} catch (DecoderQueryException | UnsupportedSchemeException e) {
throw new IllegalStateException(e);
}
}
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:18,代码来源:DashTest.java
示例2: isL1WidevineAvailable
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@SuppressWarnings("ResourceType")
public static boolean isL1WidevineAvailable(String mimeType) {
if (Util.SDK_INT >= 18) {
try {
// Force L3 if secure decoder is not available.
if (MediaCodecUtil.getDecoderInfo(mimeType, true) == null) {
return false;
}
MediaDrm mediaDrm = MediaDrmBuilder.build();
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
mediaDrm.release();
return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty);
} catch (MediaCodecUtil.DecoderQueryException e) {
throw new IllegalStateException(e);
}
}
return false;
}
开发者ID:y20k,项目名称:transistor,代码行数:19,代码来源:DashTestRunner.java
示例3: onPlayerError
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
public void onPlayerError(ExoPlaybackException e) {
String errorString = null;
if (e.type == ExoPlaybackException.TYPE_RENDERER) {
Exception cause = e.getRendererException();
if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
// Special case for decoder initialization failures.
MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
(MediaCodecRenderer.DecoderInitializationException) cause;
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
errorString = getResources().getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
errorString = getResources().getString(R.string.error_no_secure_decoder,
decoderInitializationException.mimeType);
} else {
errorString = getResources().getString(R.string.error_no_decoder,
decoderInitializationException.mimeType);
}
} else {
errorString = getResources().getString(R.string.error_instantiating_decoder,
decoderInitializationException.decoderName);
}
}
}
if (errorString != null) {
eventEmitter.error(errorString, e);
}
playerNeedsSource = true;
}
开发者ID:12d,项目名称:react-native-videoplayer,代码行数:31,代码来源:ReactExoplayerView.java
示例4: shouldSkipAdaptiveTest
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
private static boolean shouldSkipAdaptiveTest(String mimeType) throws DecoderQueryException {
MediaCodecInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
assertNotNull(decoderInfo);
if (decoderInfo.adaptive) {
return false;
}
assertTrue(Util.SDK_INT < 21);
return true;
}
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:10,代码来源:DashTest.java
示例5: onPlayerError
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
/**
* Called when an error occurs. The playback state will transition to {@link ExoPlayer#STATE_IDLE}
* immediately after this method is called. The player instance can still be used, and
* {@link #release()} must still be called on the player should it no longer be required.
*
* @param e The error.
*/
@Override
public void onPlayerError(ExoPlaybackException e) {
MediaError error = null;
if (e == null) {
error = new MediaError(MediaError.ERROR_UNKNOWN);
} else {
if (e.type == ExoPlaybackException.TYPE_RENDERER) {
Exception cause = e.getRendererException();
if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
// Special case for decoder initialization failures.
MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
(MediaCodecRenderer.DecoderInitializationException) cause;
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
error = new MediaError(MediaError.EXO_ERROR_QUERYING_DECODERS);
} else if (decoderInitializationException.secureDecoderRequired) {
error = new MediaError(MediaError.EXO_ERROR_NO_SECURE_DECODER);
} else {
error = new MediaError(MediaError.EXO_ERROR_NO_DECODER);
}
} else {
error = new MediaError(MediaError.EXO_ERROR_INSTANTIATING_DECODER);
}
}
}
}
if (error == null) {
error = new MediaError(MediaError.ERROR_UNKNOWN);
}
notifyOnError(error);
PlayerLog.d(TAG, "onPlayerError " + error.toString());
}
开发者ID:xinpianchang,项目名称:NSMPlayer-Android,代码行数:41,代码来源:WrapExoPlayer.java
示例6: supportsFormat
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
boolean requiresSecureDecryption = false;
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
for (int i = 0; i < drmInitData.schemeDataCount; i++) {
requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
}
}
MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
requiresSecureDecryption);
if (decoderInfo == null) {
return FORMAT_UNSUPPORTED_SUBTYPE;
}
boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
if (decoderCapable && format.width > 0 && format.height > 0) {
if (Util.SDK_INT >= 21) {
decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
format.frameRate);
} else {
decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
if (!decoderCapable) {
Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
+ Util.DEVICE_DEBUG_INFO + "]");
}
}
}
int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
int tunnelingSupport = decoderInfo.tunneling ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
return adaptiveSupport | tunnelingSupport | formatSupport;
}
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:40,代码来源:MediaCodecVideoRenderer.java
示例7: getCodecMaxSize
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
/**
* Returns a maximum video size to use when configuring a codec for {@code format} in a way
* that will allow possible adaptation to other compatible formats that are expected to have the
* same aspect ratio, but whose sizes are unknown.
*
* @param codecInfo Information about the {@link MediaCodec} being configured.
* @param format The format for which the codec is being configured.
* @return The maximum video size to use, or null if the size of {@code format} should be used.
* @throws DecoderQueryException If an error occurs querying {@code codecInfo}.
*/
private static Point getCodecMaxSize(MediaCodecInfo codecInfo, Format format)
throws DecoderQueryException {
boolean isVerticalVideo = format.height > format.width;
int formatLongEdgePx = isVerticalVideo ? format.height : format.width;
int formatShortEdgePx = isVerticalVideo ? format.width : format.height;
float aspectRatio = (float) formatShortEdgePx / formatLongEdgePx;
for (int longEdgePx : STANDARD_LONG_EDGE_VIDEO_PX) {
int shortEdgePx = (int) (longEdgePx * aspectRatio);
if (longEdgePx <= formatLongEdgePx || shortEdgePx <= formatShortEdgePx) {
// Don't return a size not larger than the format for which the codec is being configured.
return null;
} else if (Util.SDK_INT >= 21) {
Point alignedSize = codecInfo.alignVideoSizeV21(isVerticalVideo ? shortEdgePx : longEdgePx,
isVerticalVideo ? longEdgePx : shortEdgePx);
float frameRate = format.frameRate;
if (codecInfo.isVideoSizeAndRateSupportedV21(alignedSize.x, alignedSize.y, frameRate)) {
return alignedSize;
}
} else {
// Conservatively assume the codec requires 16px width and height alignment.
longEdgePx = Util.ceilDivide(longEdgePx, 16) * 16;
shortEdgePx = Util.ceilDivide(shortEdgePx, 16) * 16;
if (longEdgePx * shortEdgePx <= MediaCodecUtil.maxH264DecodableFrameSize()) {
return new Point(isVerticalVideo ? shortEdgePx : longEdgePx,
isVerticalVideo ? longEdgePx : shortEdgePx);
}
}
}
return null;
}
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:41,代码来源:MediaCodecVideoRenderer.java
示例8: onPlayerError
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
public void onPlayerError(ExoPlaybackException e) {
String errorString = null;
if (e.type == ExoPlaybackException.TYPE_RENDERER) {
Exception cause = e.getRendererException();
if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
// Special case for decoder initialization failures.
MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
(MediaCodecRenderer.DecoderInitializationException) cause;
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
errorString = context.getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
errorString = context.getString(R.string.error_no_secure_decoder,
decoderInitializationException.mimeType);
} else {
errorString = context.getString(R.string.error_no_decoder,
decoderInitializationException.mimeType);
}
} else {
errorString = context.getString(R.string.error_instantiating_decoder,
decoderInitializationException.decoderName);
}
}
}
if (errorString != null) {
showToast(errorString);
}
if (isBehindLiveWindow(e)) {
clearResumePosition();
initializePlayer();
} else {
updateResumePosition();
}
}
开发者ID:riggaroo,项目名称:android-arch-components-lifecycle,代码行数:37,代码来源:VideoPlayerComponent.java
示例9: whenContentIsSecure_thenRequiresSecureDecoderIsFalse
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Test
public void whenContentIsSecure_thenRequiresSecureDecoderIsFalse() throws MediaCodecUtil.DecoderQueryException {
SecurityDowngradingCodecSelector securityDowngradingCodecSelector = new SecurityDowngradingCodecSelector(internalMediaCodecUtil);
securityDowngradingCodecSelector.getDecoderInfo(ANY_MIME_TYPE, CONTENT_SECURE);
ArgumentCaptor<Boolean> argumentCaptor = ArgumentCaptor.forClass(Boolean.class);
verify(internalMediaCodecUtil).getDecoderInfo(eq(ANY_MIME_TYPE), argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).isFalse();
}
开发者ID:novoda,项目名称:no-player,代码行数:11,代码来源:SecurityDowngradingCodecSelectorTest.java
示例10: whenContentIsInsecure_thenRequiresSecureDecoderIsFalse
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Test
public void whenContentIsInsecure_thenRequiresSecureDecoderIsFalse() throws MediaCodecUtil.DecoderQueryException {
SecurityDowngradingCodecSelector securityDowngradingCodecSelector = new SecurityDowngradingCodecSelector(internalMediaCodecUtil);
securityDowngradingCodecSelector.getDecoderInfo(ANY_MIME_TYPE, CONTENT_INSECURE);
ArgumentCaptor<Boolean> argumentCaptor = ArgumentCaptor.forClass(Boolean.class);
verify(internalMediaCodecUtil).getDecoderInfo(eq(ANY_MIME_TYPE), argumentCaptor.capture());
assertThat(argumentCaptor.getValue()).isFalse();
}
开发者ID:novoda,项目名称:no-player,代码行数:11,代码来源:SecurityDowngradingCodecSelectorTest.java
示例11: whenGettingPassthroughDecoderInfo_thenDelegates
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Test
public void whenGettingPassthroughDecoderInfo_thenDelegates() throws MediaCodecUtil.DecoderQueryException {
SecurityDowngradingCodecSelector securityDowngradingCodecSelector = new SecurityDowngradingCodecSelector(internalMediaCodecUtil);
securityDowngradingCodecSelector.getPassthroughDecoderInfo();
verify(internalMediaCodecUtil).getPassthroughDecoderInfo();
}
开发者ID:novoda,项目名称:no-player,代码行数:9,代码来源:SecurityDowngradingCodecSelectorTest.java
示例12: supportsFormat
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
boolean requiresSecureDecryption = false;
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
for (int i = 0; i < drmInitData.schemeDataCount; i++) {
requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
}
}
MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
requiresSecureDecryption);
if (decoderInfo == null) {
return FORMAT_UNSUPPORTED_SUBTYPE;
}
boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
if (decoderCapable && format.width > 0 && format.height > 0) {
if (Util.SDK_INT >= 21) {
if (format.frameRate > 0) {
decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
format.frameRate);
} else {
decoderCapable = decoderInfo.isVideoSizeSupportedV21(format.width, format.height);
}
} else {
decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
}
}
int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
return adaptiveSupport | formatSupport;
}
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:39,代码来源:MediaCodecVideoRenderer.java
示例13: testDecoderInfoH264
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
public void testDecoderInfoH264() throws DecoderQueryException {
if (Util.SDK_INT < 16) {
// Pass.
return;
}
MediaCodecInfo decoderInfo = MediaCodecUtil.getDecoderInfo(MimeTypes.VIDEO_H264, false);
assertNotNull(decoderInfo);
assertTrue(Util.SDK_INT < 21 || decoderInfo.adaptive);
}
开发者ID:y20k,项目名称:transistor,代码行数:10,代码来源:DashStreamingTest.java
示例14: testDecoderInfoH265V24
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
public void testDecoderInfoH265V24() throws DecoderQueryException {
if (Util.SDK_INT < 24) {
// Pass.
return;
}
assertTrue(MediaCodecUtil.getDecoderInfo(MimeTypes.VIDEO_H265, false).adaptive);
}
开发者ID:y20k,项目名称:transistor,代码行数:8,代码来源:DashStreamingTest.java
示例15: testDecoderInfoVP9V24
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
public void testDecoderInfoVP9V24() throws DecoderQueryException {
if (Util.SDK_INT < 24) {
// Pass.
return;
}
assertTrue(MediaCodecUtil.getDecoderInfo(MimeTypes.VIDEO_VP9, false).adaptive);
}
开发者ID:y20k,项目名称:transistor,代码行数:8,代码来源:DashStreamingTest.java
示例16: getDecoderInfo
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
public MediaCodecInfo getDecoderInfo(String mimeType, boolean contentRequiresSecureDecoder)
throws MediaCodecUtil.DecoderQueryException {
return internalMediaCodecUtil.getDecoderInfo(mimeType, USE_INSECURE_DECODER);
}
开发者ID:novoda,项目名称:no-player,代码行数:6,代码来源:SecurityDowngradingCodecSelector.java
示例17: getPassthroughDecoderInfo
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
public MediaCodecInfo getPassthroughDecoderInfo() throws MediaCodecUtil.DecoderQueryException {
return internalMediaCodecUtil.getPassthroughDecoderInfo();
}
开发者ID:novoda,项目名称:no-player,代码行数:5,代码来源:SecurityDowngradingCodecSelector.java
示例18: shouldSkipAdaptiveTest
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
private static boolean shouldSkipAdaptiveTest(String mimeType) throws DecoderQueryException {
MediaCodecInfo decoderInfo = MediaCodecUtil.getDecoderInfo(mimeType, false);
return decoderInfo == null || !decoderInfo.adaptive;
}
开发者ID:y20k,项目名称:transistor,代码行数:5,代码来源:DashStreamingTest.java
示例19: supportsFormat
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format)
throws DecoderQueryException {
String mimeType = format.sampleMimeType;
if (!MimeTypes.isVideo(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
boolean requiresSecureDecryption = false;
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
for (int i = 0; i < drmInitData.schemeDataCount; i++) {
requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
}
}
MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
requiresSecureDecryption);
if (decoderInfo == null) {
return requiresSecureDecryption && mediaCodecSelector.getDecoderInfo(mimeType, false) != null
? FORMAT_UNSUPPORTED_DRM : FORMAT_UNSUPPORTED_SUBTYPE;
}
if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
return FORMAT_UNSUPPORTED_DRM;
}
boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
if (decoderCapable && format.width > 0 && format.height > 0) {
if (Util.SDK_INT >= 21) {
decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
format.frameRate);
} else {
decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
if (!decoderCapable) {
Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
+ Util.DEVICE_DEBUG_INFO + "]");
}
}
}
int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
int tunnelingSupport = decoderInfo.tunneling ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
return adaptiveSupport | tunnelingSupport | formatSupport;
}
开发者ID:y20k,项目名称:transistor,代码行数:44,代码来源:MediaCodecVideoRenderer.java
示例20: onPlayerError
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil; //导入依赖的package包/类
@Override
public void onPlayerError(ExoPlaybackException error) {
String errorString = null;
if (error.type == ExoPlaybackException.TYPE_RENDERER) {
Exception cause = error.getRendererException();
if (cause instanceof MediaCodecRenderer.DecoderInitializationException) {
// Special case for decoder initialization failures.
MediaCodecRenderer.DecoderInitializationException decoderInitializationException =
(MediaCodecRenderer.DecoderInitializationException) cause;
if (decoderInitializationException.decoderName == null) {
if (decoderInitializationException.getCause() instanceof MediaCodecUtil.DecoderQueryException) {
errorString = getString(R.string.error_querying_decoders);
} else if (decoderInitializationException.secureDecoderRequired) {
errorString = getString(R.string.error_no_secure_decoder,
decoderInitializationException.mimeType);
} else {
errorString = getString(R.string.error_no_decoder,
decoderInitializationException.mimeType);
}
} else {
errorString = getString(R.string.error_instantiating_decoder,
decoderInitializationException.decoderName);
}
}
}
if (errorString != null) {
Log.e(TAG, errorString);
}
if (isBehindLiveWindow(error)) {
clearResumePosition();
preparePlayer();
} else {
Log.e("VIDEO FAILED","VIDEO FAILED LOADING NEW ONE.");
updateResumePosition();
onVideoLoadFailed();
}
/* Log.e(TAG, "onError");
onVideoLoadFailed();
playerNeedsPrepare = true;*/
}
开发者ID:evercam,项目名称:evercam-android,代码行数:46,代码来源:VideoActivity.java
注:本文中的com.google.android.exoplayer2.mediacodec.MediaCodecUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论