Java Code Examples for com.google.android.exoplayer2.util.MimeTypes#getMediaMimeType()
The following examples show how to use
com.google.android.exoplayer2.util.MimeTypes#getMediaMimeType() .
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: HlsMediaPeriod.java From MediaSDK with Apache License 2.0 | 6 votes |
private static Format deriveVideoFormat(Format variantFormat) { String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO); String sampleMimeType = MimeTypes.getMediaMimeType(codecs); return Format.createVideoContainerFormat( variantFormat.id, variantFormat.label, variantFormat.containerMimeType, sampleMimeType, codecs, variantFormat.metadata, variantFormat.bitrate, variantFormat.width, variantFormat.height, variantFormat.frameRate, /* initializationData= */ null, variantFormat.selectionFlags, variantFormat.roleFlags); }
Example 2
Source File: HlsMediaPeriod.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static Format deriveVideoFormat(Format variantFormat) { String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO); String sampleMimeType = MimeTypes.getMediaMimeType(codecs); return Format.createVideoContainerFormat( variantFormat.id, variantFormat.label, variantFormat.containerMimeType, sampleMimeType, codecs, variantFormat.metadata, variantFormat.bitrate, variantFormat.width, variantFormat.height, variantFormat.frameRate, /* initializationData= */ null, variantFormat.selectionFlags, variantFormat.roleFlags); }
Example 3
Source File: HlsMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private static Format deriveVideoFormat(Format variantFormat) { String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO); String sampleMimeType = MimeTypes.getMediaMimeType(codecs); return Format.createVideoContainerFormat( variantFormat.id, variantFormat.label, variantFormat.containerMimeType, sampleMimeType, codecs, variantFormat.bitrate, variantFormat.width, variantFormat.height, variantFormat.frameRate, /* initializationData= */ null, variantFormat.selectionFlags); }
Example 4
Source File: HlsMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static Format deriveVideoFormat(Format variantFormat) { String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO); String sampleMimeType = MimeTypes.getMediaMimeType(codecs); return Format.createVideoContainerFormat( variantFormat.id, variantFormat.label, variantFormat.containerMimeType, sampleMimeType, codecs, variantFormat.metadata, variantFormat.bitrate, variantFormat.width, variantFormat.height, variantFormat.frameRate, /* initializationData= */ null, variantFormat.selectionFlags, variantFormat.roleFlags); }
Example 5
Source File: HlsMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private static Format deriveVideoFormat(Format variantFormat) { String codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_VIDEO); String sampleMimeType = MimeTypes.getMediaMimeType(codecs); return Format.createVideoContainerFormat( variantFormat.id, variantFormat.label, variantFormat.containerMimeType, sampleMimeType, codecs, variantFormat.bitrate, variantFormat.width, variantFormat.height, variantFormat.frameRate, /* initializationData= */ null, variantFormat.selectionFlags); }
Example 6
Source File: HlsSampleStreamWrapper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Derives a track sample format from the corresponding format in the master playlist, and a * sample format that may have been obtained from a chunk belonging to a different track. * * @param playlistFormat The format information obtained from the master playlist. * @param sampleFormat The format information obtained from the samples. * @param propagateBitrate Whether the bitrate from the playlist format should be included in the * derived format. * @return The derived track format. */ private static Format deriveFormat( Format playlistFormat, Format sampleFormat, boolean propagateBitrate) { if (playlistFormat == null) { return sampleFormat; } int bitrate = propagateBitrate ? playlistFormat.bitrate : Format.NO_VALUE; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); String mimeType = MimeTypes.getMediaMimeType(codecs); if (mimeType == null) { mimeType = sampleFormat.sampleMimeType; } return sampleFormat.copyWithContainerInfo( playlistFormat.id, playlistFormat.label, mimeType, codecs, bitrate, playlistFormat.width, playlistFormat.height, playlistFormat.selectionFlags, playlistFormat.language); }
Example 7
Source File: HlsSampleStreamWrapper.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Derives a track sample format from the corresponding format in the master playlist, and a * sample format that may have been obtained from a chunk belonging to a different track. * * @param playlistFormat The format information obtained from the master playlist. * @param sampleFormat The format information obtained from the samples. * @param propagateBitrate Whether the bitrate from the playlist format should be included in the * derived format. * @return The derived track format. */ private static Format deriveFormat( Format playlistFormat, Format sampleFormat, boolean propagateBitrate) { if (playlistFormat == null) { return sampleFormat; } int bitrate = propagateBitrate ? playlistFormat.bitrate : Format.NO_VALUE; int channelCount = playlistFormat.channelCount != Format.NO_VALUE ? playlistFormat.channelCount : sampleFormat.channelCount; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); String mimeType = MimeTypes.getMediaMimeType(codecs); if (mimeType == null) { mimeType = sampleFormat.sampleMimeType; } return sampleFormat.copyWithContainerInfo( playlistFormat.id, playlistFormat.label, mimeType, codecs, playlistFormat.metadata, bitrate, playlistFormat.width, playlistFormat.height, channelCount, playlistFormat.selectionFlags, playlistFormat.language); }
Example 8
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 9
Source File: HlsSampleStreamWrapper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Derives a track sample format from the corresponding format in the master playlist, and a * sample format that may have been obtained from a chunk belonging to a different track. * * @param playlistFormat The format information obtained from the master playlist. * @param sampleFormat The format information obtained from the samples. * @param propagateBitrate Whether the bitrate from the playlist format should be included in the * derived format. * @return The derived track format. */ private static Format deriveFormat( Format playlistFormat, Format sampleFormat, boolean propagateBitrate) { if (playlistFormat == null) { return sampleFormat; } int bitrate = propagateBitrate ? playlistFormat.bitrate : Format.NO_VALUE; int channelCount = playlistFormat.channelCount != Format.NO_VALUE ? playlistFormat.channelCount : sampleFormat.channelCount; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); String mimeType = MimeTypes.getMediaMimeType(codecs); if (mimeType == null) { mimeType = sampleFormat.sampleMimeType; } return sampleFormat.copyWithContainerInfo( playlistFormat.id, playlistFormat.label, mimeType, codecs, playlistFormat.metadata, bitrate, playlistFormat.width, playlistFormat.height, channelCount, playlistFormat.selectionFlags, playlistFormat.language); }
Example 10
Source File: MediaCodecInfo.java From K-Sonic with MIT License | 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; } for (CodecProfileLevel capabilities : getProfileLevels()) { if (capabilities.profile == codecProfileAndLevel.first && capabilities.level >= codecProfileAndLevel.second) { return true; } } logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType); return false; }
Example 11
Source File: MediaCodecInfo.java From TelePlus-Android 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; } for (CodecProfileLevel capabilities : getProfileLevels()) { if (capabilities.profile == codecProfileAndLevel.first && capabilities.level >= codecProfileAndLevel.second) { return true; } } logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType); return false; }
Example 12
Source File: HlsMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static Format deriveAudioFormat( Format variantFormat, Format mediaTagFormat, boolean isPrimaryTrackInVariant) { String codecs; int channelCount = Format.NO_VALUE; int selectionFlags = 0; String language = null; String label = null; if (mediaTagFormat != null) { codecs = mediaTagFormat.codecs; channelCount = mediaTagFormat.channelCount; selectionFlags = mediaTagFormat.selectionFlags; language = mediaTagFormat.language; label = mediaTagFormat.label; } else { codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); if (isPrimaryTrackInVariant) { channelCount = variantFormat.channelCount; selectionFlags = variantFormat.selectionFlags; language = variantFormat.label; label = variantFormat.label; } } String sampleMimeType = MimeTypes.getMediaMimeType(codecs); int bitrate = isPrimaryTrackInVariant ? variantFormat.bitrate : Format.NO_VALUE; return Format.createAudioContainerFormat( variantFormat.id, label, variantFormat.containerMimeType, sampleMimeType, codecs, bitrate, channelCount, /* sampleRate= */ Format.NO_VALUE, /* initializationData= */ null, selectionFlags, language); }
Example 13
Source File: MediaCodecInfo.java From TelePlus-Android 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; } for (CodecProfileLevel capabilities : getProfileLevels()) { if (capabilities.profile == codecProfileAndLevel.first && capabilities.level >= codecProfileAndLevel.second) { return true; } } logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType); return false; }
Example 14
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 15
Source File: HlsMediaPeriod.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static Format deriveAudioFormat( Format variantFormat, Format mediaTagFormat, boolean isPrimaryTrackInVariant) { String codecs; int channelCount = Format.NO_VALUE; int selectionFlags = 0; String language = null; String label = null; if (mediaTagFormat != null) { codecs = mediaTagFormat.codecs; channelCount = mediaTagFormat.channelCount; selectionFlags = mediaTagFormat.selectionFlags; language = mediaTagFormat.language; label = mediaTagFormat.label; } else { codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); if (isPrimaryTrackInVariant) { channelCount = variantFormat.channelCount; selectionFlags = variantFormat.selectionFlags; language = variantFormat.label; label = variantFormat.label; } } String sampleMimeType = MimeTypes.getMediaMimeType(codecs); int bitrate = isPrimaryTrackInVariant ? variantFormat.bitrate : Format.NO_VALUE; return Format.createAudioContainerFormat( variantFormat.id, label, variantFormat.containerMimeType, sampleMimeType, codecs, bitrate, channelCount, /* sampleRate= */ Format.NO_VALUE, /* initializationData= */ null, selectionFlags, language); }
Example 16
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 17
Source File: HlsSampleStreamWrapper.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Derives a track sample format from the corresponding format in the master playlist, and a * sample format that may have been obtained from a chunk belonging to a different track. * * @param playlistFormat The format information obtained from the master playlist. * @param sampleFormat The format information obtained from the samples. * @param propagateBitrate Whether the bitrate from the playlist format should be included in the * derived format. * @return The derived track format. */ private static Format deriveFormat( @Nullable Format playlistFormat, Format sampleFormat, boolean propagateBitrate) { if (playlistFormat == null) { return sampleFormat; } int bitrate = propagateBitrate ? playlistFormat.bitrate : Format.NO_VALUE; int channelCount = playlistFormat.channelCount != Format.NO_VALUE ? playlistFormat.channelCount : sampleFormat.channelCount; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); String mimeType = MimeTypes.getMediaMimeType(codecs); if (mimeType == null) { mimeType = sampleFormat.sampleMimeType; } return sampleFormat.copyWithContainerInfo( playlistFormat.id, playlistFormat.label, mimeType, codecs, playlistFormat.metadata, bitrate, playlistFormat.width, playlistFormat.height, channelCount, playlistFormat.selectionFlags, playlistFormat.language); }
Example 18
Source File: HlsMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private static Format deriveAudioFormat( Format variantFormat, Format mediaTagFormat, boolean isPrimaryTrackInVariant) { String codecs; Metadata metadata; int channelCount = Format.NO_VALUE; int selectionFlags = 0; int roleFlags = 0; String language = null; String label = null; if (mediaTagFormat != null) { codecs = mediaTagFormat.codecs; metadata = mediaTagFormat.metadata; channelCount = mediaTagFormat.channelCount; selectionFlags = mediaTagFormat.selectionFlags; roleFlags = mediaTagFormat.roleFlags; language = mediaTagFormat.language; label = mediaTagFormat.label; } else { codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); metadata = variantFormat.metadata; if (isPrimaryTrackInVariant) { channelCount = variantFormat.channelCount; selectionFlags = variantFormat.selectionFlags; roleFlags = variantFormat.roleFlags; language = variantFormat.language; label = variantFormat.label; } } String sampleMimeType = MimeTypes.getMediaMimeType(codecs); int bitrate = isPrimaryTrackInVariant ? variantFormat.bitrate : Format.NO_VALUE; return Format.createAudioContainerFormat( variantFormat.id, label, variantFormat.containerMimeType, sampleMimeType, codecs, metadata, bitrate, channelCount, /* sampleRate= */ Format.NO_VALUE, /* initializationData= */ null, selectionFlags, roleFlags, language); }
Example 19
Source File: HlsMediaPeriod.java From Telegram with GNU General Public License v2.0 | 4 votes |
private static Format deriveAudioFormat( Format variantFormat, Format mediaTagFormat, boolean isPrimaryTrackInVariant) { String codecs; Metadata metadata; int channelCount = Format.NO_VALUE; int selectionFlags = 0; int roleFlags = 0; String language = null; String label = null; if (mediaTagFormat != null) { codecs = mediaTagFormat.codecs; metadata = mediaTagFormat.metadata; channelCount = mediaTagFormat.channelCount; selectionFlags = mediaTagFormat.selectionFlags; roleFlags = mediaTagFormat.roleFlags; language = mediaTagFormat.language; label = mediaTagFormat.label; } else { codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); metadata = variantFormat.metadata; if (isPrimaryTrackInVariant) { channelCount = variantFormat.channelCount; selectionFlags = variantFormat.selectionFlags; roleFlags = variantFormat.roleFlags; language = variantFormat.language; label = variantFormat.label; } } String sampleMimeType = MimeTypes.getMediaMimeType(codecs); int bitrate = isPrimaryTrackInVariant ? variantFormat.bitrate : Format.NO_VALUE; return Format.createAudioContainerFormat( variantFormat.id, label, variantFormat.containerMimeType, sampleMimeType, codecs, metadata, bitrate, channelCount, /* sampleRate= */ Format.NO_VALUE, /* initializationData= */ null, selectionFlags, roleFlags, language); }
Example 20
Source File: HlsMediaPeriod.java From MediaSDK with Apache License 2.0 | 4 votes |
private static Format deriveAudioFormat( Format variantFormat, @Nullable Format mediaTagFormat, boolean isPrimaryTrackInVariant) { String codecs; Metadata metadata; int channelCount = Format.NO_VALUE; int selectionFlags = 0; int roleFlags = 0; String language = null; String label = null; if (mediaTagFormat != null) { codecs = mediaTagFormat.codecs; metadata = mediaTagFormat.metadata; channelCount = mediaTagFormat.channelCount; selectionFlags = mediaTagFormat.selectionFlags; roleFlags = mediaTagFormat.roleFlags; language = mediaTagFormat.language; label = mediaTagFormat.label; } else { codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); metadata = variantFormat.metadata; if (isPrimaryTrackInVariant) { channelCount = variantFormat.channelCount; selectionFlags = variantFormat.selectionFlags; roleFlags = variantFormat.roleFlags; language = variantFormat.language; label = variantFormat.label; } } String sampleMimeType = MimeTypes.getMediaMimeType(codecs); int bitrate = isPrimaryTrackInVariant ? variantFormat.bitrate : Format.NO_VALUE; return Format.createAudioContainerFormat( variantFormat.id, label, variantFormat.containerMimeType, sampleMimeType, codecs, metadata, bitrate, channelCount, /* sampleRate= */ Format.NO_VALUE, /* initializationData= */ null, selectionFlags, roleFlags, language); }