下面列出了android.media.MediaCodecInfo.CodecProfileLevel# AACObjectXHE ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Whether the decoder supports the codec of the given {@code format}. If there is insufficient
* information to decide, returns true.
*
* @param format The input media format.
* @return True if the codec of the given {@code format} is supported by the decoder.
*/
public boolean isCodecSupported(Format format) {
if (format.codecs == null || mimeType == null) {
return true;
}
String codecMimeType = MimeTypes.getMediaMimeType(format.codecs);
if (codecMimeType == null) {
return true;
}
if (!mimeType.equals(codecMimeType)) {
logNoSupport("codec.mime " + format.codecs + ", " + codecMimeType);
return false;
}
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(format);
if (codecProfileAndLevel == null) {
// If we don't know any better, we assume that the profile and level are supported.
return true;
}
int profile = codecProfileAndLevel.first;
int level = codecProfileAndLevel.second;
if (!isVideo && profile != CodecProfileLevel.AACObjectXHE) {
// Some devices/builds underreport audio capabilities, so assume support except for xHE-AAC
// which may not be widely supported. See https://github.com/google/ExoPlayer/issues/5145.
return true;
}
for (CodecProfileLevel capabilities : getProfileLevels()) {
if (capabilities.profile == profile && capabilities.level >= level) {
return true;
}
}
logNoSupport("codec.profileLevel, " + format.codecs + ", " + codecMimeType);
return false;
}
/**
* Returns whether it is possible to adapt the decoder seamlessly from {@code oldFormat} to {@code
* newFormat}. If {@code newFormat} may not be completely populated, pass {@code false} for {@code
* isNewFormatComplete}.
*
* @param oldFormat The format being decoded.
* @param newFormat The new format.
* @param isNewFormatComplete Whether {@code newFormat} is populated with format-specific
* metadata.
* @return Whether it is possible to adapt the decoder seamlessly.
*/
public boolean isSeamlessAdaptationSupported(
Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
if (isVideo) {
return oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
&& oldFormat.rotationDegrees == newFormat.rotationDegrees
&& (adaptive
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
&& ((!isNewFormatComplete && newFormat.colorInfo == null)
|| Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
} else {
if (!MimeTypes.AUDIO_AAC.equals(mimeType)
|| !oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
|| oldFormat.channelCount != newFormat.channelCount
|| oldFormat.sampleRate != newFormat.sampleRate) {
return false;
}
// Check the codec profile levels support adaptation.
Pair<Integer, Integer> oldCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(oldFormat);
Pair<Integer, Integer> newCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(newFormat);
if (oldCodecProfileLevel == null || newCodecProfileLevel == null) {
return false;
}
int oldProfile = oldCodecProfileLevel.first;
int newProfile = newCodecProfileLevel.first;
return oldProfile == CodecProfileLevel.AACObjectXHE
&& newProfile == CodecProfileLevel.AACObjectXHE;
}
}
/**
* Whether the decoder supports the given {@code codec}. If there is insufficient information to
* decide, returns true.
*
* @param codec Codec string as defined in RFC 6381.
* @return True if the given codec is supported by the decoder.
*/
public boolean isCodecSupported(String codec) {
if (codec == null || mimeType == null) {
return true;
}
String codecMimeType = MimeTypes.getMediaMimeType(codec);
if (codecMimeType == null) {
return true;
}
if (!mimeType.equals(codecMimeType)) {
logNoSupport("codec.mime " + codec + ", " + codecMimeType);
return false;
}
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(codec);
if (codecProfileAndLevel == null) {
// If we don't know any better, we assume that the profile and level are supported.
return true;
}
int profile = codecProfileAndLevel.first;
int level = codecProfileAndLevel.second;
if (!isVideo && profile != CodecProfileLevel.AACObjectXHE) {
// Some devices/builds underreport audio capabilities, so assume support except for xHE-AAC
// which may not be widely supported. See https://github.com/google/ExoPlayer/issues/5145.
return true;
}
for (CodecProfileLevel capabilities : getProfileLevels()) {
if (capabilities.profile == profile && capabilities.level >= level) {
return true;
}
}
logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType);
return false;
}
/**
* Returns whether it is possible to adapt the decoder seamlessly from {@code oldFormat} to {@code
* newFormat}. If {@code newFormat} may not be completely populated, pass {@code false} for {@code
* isNewFormatComplete}.
*
* @param oldFormat The format being decoded.
* @param newFormat The new format.
* @param isNewFormatComplete Whether {@code newFormat} is populated with format-specific
* metadata.
* @return Whether it is possible to adapt the decoder seamlessly.
*/
public boolean isSeamlessAdaptationSupported(
Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
if (isVideo) {
return oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
&& oldFormat.rotationDegrees == newFormat.rotationDegrees
&& (adaptive
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
&& ((!isNewFormatComplete && newFormat.colorInfo == null)
|| Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
} else {
if (!MimeTypes.AUDIO_AAC.equals(mimeType)
|| !oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
|| oldFormat.channelCount != newFormat.channelCount
|| oldFormat.sampleRate != newFormat.sampleRate) {
return false;
}
// Check the codec profile levels support adaptation.
Pair<Integer, Integer> oldCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(oldFormat.codecs);
Pair<Integer, Integer> newCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(newFormat.codecs);
if (oldCodecProfileLevel == null || newCodecProfileLevel == null) {
return false;
}
int oldProfile = oldCodecProfileLevel.first;
int newProfile = newCodecProfileLevel.first;
return oldProfile == CodecProfileLevel.AACObjectXHE
&& newProfile == CodecProfileLevel.AACObjectXHE;
}
}
/**
* Whether the decoder supports the given {@code codec}. If there is insufficient information to
* decide, returns true.
*
* @param codec Codec string as defined in RFC 6381.
* @return True if the given codec is supported by the decoder.
*/
public boolean isCodecSupported(String codec) {
if (codec == null || mimeType == null) {
return true;
}
String codecMimeType = MimeTypes.getMediaMimeType(codec);
if (codecMimeType == null) {
return true;
}
if (!mimeType.equals(codecMimeType)) {
logNoSupport("codec.mime " + codec + ", " + codecMimeType);
return false;
}
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(codec);
if (codecProfileAndLevel == null) {
// If we don't know any better, we assume that the profile and level are supported.
return true;
}
int profile = codecProfileAndLevel.first;
int level = codecProfileAndLevel.second;
if (!isVideo && profile != CodecProfileLevel.AACObjectXHE) {
// Some devices/builds underreport audio capabilities, so assume support except for xHE-AAC
// which may not be widely supported. See https://github.com/google/ExoPlayer/issues/5145.
return true;
}
for (CodecProfileLevel capabilities : getProfileLevels()) {
if (capabilities.profile == profile && capabilities.level >= level) {
return true;
}
}
logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType);
return false;
}
/**
* Returns whether it is possible to adapt the decoder seamlessly from {@code oldFormat} to {@code
* newFormat}. If {@code newFormat} may not be completely populated, pass {@code false} for {@code
* isNewFormatComplete}.
*
* @param oldFormat The format being decoded.
* @param newFormat The new format.
* @param isNewFormatComplete Whether {@code newFormat} is populated with format-specific
* metadata.
* @return Whether it is possible to adapt the decoder seamlessly.
*/
public boolean isSeamlessAdaptationSupported(
Format oldFormat, Format newFormat, boolean isNewFormatComplete) {
if (isVideo) {
return oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
&& oldFormat.rotationDegrees == newFormat.rotationDegrees
&& (adaptive
|| (oldFormat.width == newFormat.width && oldFormat.height == newFormat.height))
&& ((!isNewFormatComplete && newFormat.colorInfo == null)
|| Util.areEqual(oldFormat.colorInfo, newFormat.colorInfo));
} else {
if (!MimeTypes.AUDIO_AAC.equals(mimeType)
|| !oldFormat.sampleMimeType.equals(newFormat.sampleMimeType)
|| oldFormat.channelCount != newFormat.channelCount
|| oldFormat.sampleRate != newFormat.sampleRate) {
return false;
}
// Check the codec profile levels support adaptation.
Pair<Integer, Integer> oldCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(oldFormat.codecs);
Pair<Integer, Integer> newCodecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(newFormat.codecs);
if (oldCodecProfileLevel == null || newCodecProfileLevel == null) {
return false;
}
int oldProfile = oldCodecProfileLevel.first;
int newProfile = newCodecProfileLevel.first;
return oldProfile == CodecProfileLevel.AACObjectXHE
&& newProfile == CodecProfileLevel.AACObjectXHE;
}
}
/**
* Returns whether it may be possible to adapt to playing a different format when the codec is
* configured to play media in the specified {@code format}. For adaptation to succeed, the codec
* must also be configured with appropriate maximum values and {@link
* #isSeamlessAdaptationSupported(Format, Format, boolean)} must return {@code true} for the
* old/new formats.
*
* @param format The format of media for which the decoder will be configured.
* @return Whether adaptation may be possible
*/
public boolean isSeamlessAdaptationSupported(Format format) {
if (isVideo) {
return adaptive;
} else {
Pair<Integer, Integer> codecProfileLevel = MediaCodecUtil.getCodecProfileAndLevel(format);
return codecProfileLevel != null && codecProfileLevel.first == CodecProfileLevel.AACObjectXHE;
}
}
/**
* Returns whether it may be possible to adapt to playing a different format when the codec is
* configured to play media in the specified {@code format}. For adaptation to succeed, the codec
* must also be configured with appropriate maximum values and {@link
* #isSeamlessAdaptationSupported(Format, Format, boolean)} must return {@code true} for the
* old/new formats.
*
* @param format The format of media for which the decoder will be configured.
* @return Whether adaptation may be possible
*/
public boolean isSeamlessAdaptationSupported(Format format) {
if (isVideo) {
return adaptive;
} else {
Pair<Integer, Integer> codecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(format.codecs);
return codecProfileLevel != null && codecProfileLevel.first == CodecProfileLevel.AACObjectXHE;
}
}
/**
* Returns whether it may be possible to adapt to playing a different format when the codec is
* configured to play media in the specified {@code format}. For adaptation to succeed, the codec
* must also be configured with appropriate maximum values and {@link
* #isSeamlessAdaptationSupported(Format, Format, boolean)} must return {@code true} for the
* old/new formats.
*
* @param format The format of media for which the decoder will be configured.
* @return Whether adaptation may be possible
*/
public boolean isSeamlessAdaptationSupported(Format format) {
if (isVideo) {
return adaptive;
} else {
Pair<Integer, Integer> codecProfileLevel =
MediaCodecUtil.getCodecProfileAndLevel(format.codecs);
return codecProfileLevel != null && codecProfileLevel.first == CodecProfileLevel.AACObjectXHE;
}
}