Java Code Examples for android.media.MediaCodecInfo.CodecProfileLevel#AACObjectXHE
The following examples show how to use
android.media.MediaCodecInfo.CodecProfileLevel#AACObjectXHE .
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: MediaCodecInfo.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * 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; }
Example 2
Source File: MediaCodecInfo.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * 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; } }
Example 3
Source File: MediaCodecInfo.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 4
Source File: MediaCodecInfo.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 5
Source File: MediaCodecInfo.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example 6
Source File: MediaCodecInfo.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * 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; } }
Example 7
Source File: MediaCodecInfo.java From MediaSDK with Apache License 2.0 | 3 votes |
/** * 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; } }
Example 8
Source File: MediaCodecInfo.java From Telegram-FOSS with GNU General Public License v2.0 | 3 votes |
/** * 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; } }
Example 9
Source File: MediaCodecInfo.java From Telegram with GNU General Public License v2.0 | 3 votes |
/** * 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; } }