Java Code Examples for com.google.android.exoplayer2.util.Util#getCodecsOfType()
The following examples show how to use
com.google.android.exoplayer2.util.Util#getCodecsOfType() .
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 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 4
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 5
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 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: 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 8
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 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: 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 11
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 12
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 13
Source File: Format.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("ReferenceEquality") public Format copyWithManifestFormatInfo(Format manifestFormat) { if (this == manifestFormat) { // No need to copy from ourselves. return this; } int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. String label = manifestFormat.label != null ? manifestFormat.label : this.label; String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; } // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. String codecsOfType = Util.getCodecsOfType(manifestFormat.codecs, trackType); if (Util.splitCodecs(codecsOfType).length == 1) { codecs = codecsOfType; } } float frameRate = this.frameRate; if (frameRate == NO_VALUE && trackType == C.TRACK_TYPE_VIDEO) { frameRate = manifestFormat.frameRate; } // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); return new Format( id, label, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags, language, accessibilityChannel, subsampleOffsetUs, initializationData, drmInitData, metadata); }
Example 14
Source File: Format.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("ReferenceEquality") public Format copyWithManifestFormatInfo(Format manifestFormat) { if (this == manifestFormat) { // No need to copy from ourselves. return this; } int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. String label = manifestFormat.label != null ? manifestFormat.label : this.label; String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; } // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. String codecsOfType = Util.getCodecsOfType(manifestFormat.codecs, trackType); if (Util.splitCodecs(codecsOfType).length == 1) { codecs = codecsOfType; } } Metadata metadata = this.metadata == null ? manifestFormat.metadata : this.metadata.copyWithAppendedEntriesFrom(manifestFormat.metadata); float frameRate = this.frameRate; if (frameRate == NO_VALUE && trackType == C.TRACK_TYPE_VIDEO) { frameRate = manifestFormat.frameRate; } // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; @C.RoleFlags int roleFlags = this.roleFlags | manifestFormat.roleFlags; DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); return new Format( id, label, selectionFlags, roleFlags, bitrate, codecs, metadata, containerMimeType, sampleMimeType, maxInputSize, initializationData, drmInitData, subsampleOffsetUs, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, language, accessibilityChannel); }
Example 15
Source File: Format.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("ReferenceEquality") public Format copyWithManifestFormatInfo(Format manifestFormat) { if (this == manifestFormat) { // No need to copy from ourselves. return this; } int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. String label = manifestFormat.label != null ? manifestFormat.label : this.label; String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; } // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. String codecsOfType = Util.getCodecsOfType(manifestFormat.codecs, trackType); if (Util.splitCodecs(codecsOfType).length == 1) { codecs = codecsOfType; } } float frameRate = this.frameRate; if (frameRate == NO_VALUE && trackType == C.TRACK_TYPE_VIDEO) { frameRate = manifestFormat.frameRate; } // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); return new Format( id, label, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags, language, accessibilityChannel, subsampleOffsetUs, initializationData, drmInitData, metadata); }
Example 16
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 17
Source File: Format.java From Telegram with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("ReferenceEquality") public Format copyWithManifestFormatInfo(Format manifestFormat) { if (this == manifestFormat) { // No need to copy from ourselves. return this; } int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. String label = manifestFormat.label != null ? manifestFormat.label : this.label; String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; } // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. String codecsOfType = Util.getCodecsOfType(manifestFormat.codecs, trackType); if (Util.splitCodecs(codecsOfType).length == 1) { codecs = codecsOfType; } } Metadata metadata = this.metadata == null ? manifestFormat.metadata : this.metadata.copyWithAppendedEntriesFrom(manifestFormat.metadata); float frameRate = this.frameRate; if (frameRate == NO_VALUE && trackType == C.TRACK_TYPE_VIDEO) { frameRate = manifestFormat.frameRate; } // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; @C.RoleFlags int roleFlags = this.roleFlags | manifestFormat.roleFlags; DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); return new Format( id, label, selectionFlags, roleFlags, bitrate, codecs, metadata, containerMimeType, sampleMimeType, maxInputSize, initializationData, drmInitData, subsampleOffsetUs, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, language, accessibilityChannel); }
Example 18
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); }
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: Format.java From MediaSDK with Apache License 2.0 | 4 votes |
@SuppressWarnings("ReferenceEquality") public Format copyWithManifestFormatInfo(Format manifestFormat) { if (this == manifestFormat) { // No need to copy from ourselves. return this; } int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. String label = manifestFormat.label != null ? manifestFormat.label : this.label; String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; } // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. String codecsOfType = Util.getCodecsOfType(manifestFormat.codecs, trackType); if (Util.splitCodecs(codecsOfType).length == 1) { codecs = codecsOfType; } } Metadata metadata = this.metadata == null ? manifestFormat.metadata : this.metadata.copyWithAppendedEntriesFrom(manifestFormat.metadata); float frameRate = this.frameRate; if (frameRate == NO_VALUE && trackType == C.TRACK_TYPE_VIDEO) { frameRate = manifestFormat.frameRate; } // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; @C.RoleFlags int roleFlags = this.roleFlags | manifestFormat.roleFlags; DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); return new Format( id, label, selectionFlags, roleFlags, bitrate, codecs, metadata, containerMimeType, sampleMimeType, maxInputSize, initializationData, drmInitData, subsampleOffsetUs, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, colorInfo, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, language, accessibilityChannel, exoMediaCryptoType); }