Java Code Examples for com.google.android.exoplayer2.Format#copyWithContainerInfo()
The following examples show how to use
com.google.android.exoplayer2.Format#copyWithContainerInfo() .
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: 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 2
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 3
Source File: HlsSampleStreamWrapper.java From K-Sonic with MIT License | 6 votes |
/** * Derives a track format corresponding to a given container format, by combining it with sample * level information obtained from the samples. * * @param containerFormat The container format for which the track format should be derived. * @param sampleFormat A sample format from which to obtain sample level information. * @return The derived track format. */ private static Format deriveFormat(Format containerFormat, Format sampleFormat) { if (containerFormat == null) { return sampleFormat; } String codecs = null; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); if (sampleTrackType == C.TRACK_TYPE_AUDIO) { codecs = getAudioCodecs(containerFormat.codecs); } else if (sampleTrackType == C.TRACK_TYPE_VIDEO) { codecs = getVideoCodecs(containerFormat.codecs); } return sampleFormat.copyWithContainerInfo(containerFormat.id, codecs, containerFormat.bitrate, containerFormat.width, containerFormat.height, containerFormat.selectionFlags, containerFormat.language); }
Example 4
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 5
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 6
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); }