Java Code Examples for com.google.android.exoplayer2.Format#createTextSampleFormat()
The following examples show how to use
com.google.android.exoplayer2.Format#createTextSampleFormat() .
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: DashMediaPeriod.java From MediaSDK with Apache License 2.0 | 6 votes |
private static Format buildCea608TrackFormat( int adaptationSetId, String language, int accessibilityChannel) { return Format.createTextSampleFormat( adaptationSetId + ":cea608" + (accessibilityChannel != Format.NO_VALUE ? ":" + accessibilityChannel : ""), MimeTypes.APPLICATION_CEA608, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, accessibilityChannel, /* drmInitData= */ null, Format.OFFSET_SAMPLE_RELATIVE, /* initializationData= */ null); }
Example 2
Source File: DashMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static Format buildCea608TrackFormat( int adaptationSetId, String language, int accessibilityChannel) { return Format.createTextSampleFormat( adaptationSetId + ":cea608" + (accessibilityChannel != Format.NO_VALUE ? ":" + accessibilityChannel : ""), MimeTypes.APPLICATION_CEA608, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, accessibilityChannel, /* drmInitData= */ null, Format.OFFSET_SAMPLE_RELATIVE, /* initializationData= */ null); }
Example 3
Source File: DashMediaPeriod.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static Format buildCea608TrackFormat( int adaptationSetId, String language, int accessibilityChannel) { return Format.createTextSampleFormat( adaptationSetId + ":cea608" + (accessibilityChannel != Format.NO_VALUE ? ":" + accessibilityChannel : ""), MimeTypes.APPLICATION_CEA608, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, accessibilityChannel, /* drmInitData= */ null, Format.OFFSET_SAMPLE_RELATIVE, /* initializationData= */ null); }
Example 4
Source File: ExoPlayerHelper.java From ExoPlayer-Wrapper with Apache License 2.0 | 5 votes |
private MediaSource addSubTitlesToMediaSource(MediaSource mediaSource, String subTitlesUrl) { Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, null, Format.NO_VALUE, Format.NO_VALUE, "en", Format.NO_VALUE, null); Uri uri = Uri.parse(subTitlesUrl); MediaSource subtitleSource = new SingleSampleMediaSource.Factory(mDataSourceFactory) .createMediaSource(uri, textFormat, C.TIME_UNSET); return new MergingMediaSource(mediaSource, subtitleSource); }
Example 5
Source File: GSYExoSubTitlePlayer.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
public MediaSource getTextSource(Uri subTitle) { //todo C.SELECTION_FLAG_AUTOSELECT language MimeTypes Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, C.SELECTION_FLAG_FORCED, "en"); DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory(Util.getUserAgent(mAppContext, "GSYExoSubTitlePlayer"), new DefaultBandwidthMeter.Builder(mAppContext).build(), 50000, 50000, true); MediaSource textMediaSource = new SingleSampleMediaSource.Factory(new DefaultDataSourceFactory(mAppContext, null, factory)) .createMediaSource(subTitle, textFormat, C.TIME_UNSET); return textMediaSource; }
Example 6
Source File: AtomParsers.java From MediaSDK with Apache License 2.0 | 4 votes |
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position, int atomSize, int trackId, String language, StsdData out) throws ParserException { parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE); // Default values. List<byte[]> initializationData = null; long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE; String mimeType; if (atomType == Atom.TYPE_TTML) { mimeType = MimeTypes.APPLICATION_TTML; } else if (atomType == Atom.TYPE_tx3g) { mimeType = MimeTypes.APPLICATION_TX3G; int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8; byte[] sampleDescriptionData = new byte[sampleDescriptionLength]; parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength); initializationData = Collections.singletonList(sampleDescriptionData); } else if (atomType == Atom.TYPE_wvtt) { mimeType = MimeTypes.APPLICATION_MP4VTT; } else if (atomType == Atom.TYPE_stpp) { mimeType = MimeTypes.APPLICATION_TTML; subsampleOffsetUs = 0; // Subsample timing is absolute. } else if (atomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. mimeType = MimeTypes.APPLICATION_MP4CEA608; out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else { // Never happens. throw new IllegalStateException(); } out.format = Format.createTextSampleFormat( Integer.toString(trackId), mimeType, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, /* accessibilityChannel= */ Format.NO_VALUE, /* drmInitData= */ null, subsampleOffsetUs, initializationData); }
Example 7
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position, int atomSize, int trackId, String language, StsdData out) throws ParserException { parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE); // Default values. List<byte[]> initializationData = null; long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE; String mimeType; if (atomType == Atom.TYPE_TTML) { mimeType = MimeTypes.APPLICATION_TTML; } else if (atomType == Atom.TYPE_tx3g) { mimeType = MimeTypes.APPLICATION_TX3G; int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8; byte[] sampleDescriptionData = new byte[sampleDescriptionLength]; parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength); initializationData = Collections.singletonList(sampleDescriptionData); } else if (atomType == Atom.TYPE_wvtt) { mimeType = MimeTypes.APPLICATION_MP4VTT; } else if (atomType == Atom.TYPE_stpp) { mimeType = MimeTypes.APPLICATION_TTML; subsampleOffsetUs = 0; // Subsample timing is absolute. } else if (atomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. mimeType = MimeTypes.APPLICATION_MP4CEA608; out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else { // Never happens. throw new IllegalStateException(); } out.format = Format.createTextSampleFormat( Integer.toString(trackId), mimeType, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, /* accessibilityChannel= */ Format.NO_VALUE, /* drmInitData= */ null, subsampleOffsetUs, initializationData); }
Example 8
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position, int atomSize, int trackId, String language, StsdData out) throws ParserException { parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE); // Default values. List<byte[]> initializationData = null; long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE; String mimeType; if (atomType == Atom.TYPE_TTML) { mimeType = MimeTypes.APPLICATION_TTML; } else if (atomType == Atom.TYPE_tx3g) { mimeType = MimeTypes.APPLICATION_TX3G; int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8; byte[] sampleDescriptionData = new byte[sampleDescriptionLength]; parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength); initializationData = Collections.singletonList(sampleDescriptionData); } else if (atomType == Atom.TYPE_wvtt) { mimeType = MimeTypes.APPLICATION_MP4VTT; } else if (atomType == Atom.TYPE_stpp) { mimeType = MimeTypes.APPLICATION_TTML; subsampleOffsetUs = 0; // Subsample timing is absolute. } else if (atomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. mimeType = MimeTypes.APPLICATION_MP4CEA608; out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else { // Never happens. throw new IllegalStateException(); } out.format = Format.createTextSampleFormat( Integer.toString(trackId), mimeType, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, /* accessibilityChannel= */ Format.NO_VALUE, /* drmInitData= */ null, subsampleOffsetUs, initializationData); }
Example 9
Source File: AtomParsers.java From K-Sonic with MIT License | 4 votes |
/** * Parses a stsd atom (defined in 14496-12). * * @param stsd The stsd atom to decode. * @param trackId The track's identifier in its container. * @param rotationDegrees The rotation of the track in degrees. * @param language The language of the track. * @param drmInitData {@link DrmInitData} to be included in the format. * @param isQuickTime True for QuickTime media. False otherwise. * @return An object containing the parsed data. */ private static StsdData parseStsd(ParsableByteArray stsd, int trackId, int rotationDegrees, String language, DrmInitData drmInitData, boolean isQuickTime) throws ParserException { stsd.setPosition(Atom.FULL_HEADER_SIZE); int numberOfEntries = stsd.readInt(); StsdData out = new StsdData(numberOfEntries); for (int i = 0; i < numberOfEntries; i++) { int childStartPosition = stsd.getPosition(); int childAtomSize = stsd.readInt(); Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive"); int childAtomType = stsd.readInt(); if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3 || childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v || childAtomType == Atom.TYPE_hvc1 || childAtomType == Atom.TYPE_hev1 || childAtomType == Atom.TYPE_s263 || childAtomType == Atom.TYPE_vp08 || childAtomType == Atom.TYPE_vp09) { parseVideoSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, rotationDegrees, drmInitData, out, i); } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca || childAtomType == Atom.TYPE_ac_3 || childAtomType == Atom.TYPE_ec_3 || childAtomType == Atom.TYPE_dtsc || childAtomType == Atom.TYPE_dtse || childAtomType == Atom.TYPE_dtsh || childAtomType == Atom.TYPE_dtsl || childAtomType == Atom.TYPE_samr || childAtomType == Atom.TYPE_sawb || childAtomType == Atom.TYPE_lpcm || childAtomType == Atom.TYPE_sowt || childAtomType == Atom.TYPE__mp3 || childAtomType == Atom.TYPE_alac) { parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, language, isQuickTime, drmInitData, out, i); } else if (childAtomType == Atom.TYPE_TTML) { out.format = Format.createTextSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TTML, null, Format.NO_VALUE, 0, language, drmInitData); } else if (childAtomType == Atom.TYPE_tx3g) { out.format = Format.createTextSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TX3G, null, Format.NO_VALUE, 0, language, drmInitData); } else if (childAtomType == Atom.TYPE_wvtt) { out.format = Format.createTextSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_MP4VTT, null, Format.NO_VALUE, 0, language, drmInitData); } else if (childAtomType == Atom.TYPE_stpp) { out.format = Format.createTextSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TTML, null, Format.NO_VALUE, 0, language, drmInitData, 0 /* subsample timing is absolute */); } else if (childAtomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. out.format = Format.createTextSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_MP4CEA608, null, Format.NO_VALUE, 0, language, drmInitData); out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else if (childAtomType == Atom.TYPE_camm) { out.format = Format.createSampleFormat(Integer.toString(trackId), MimeTypes.APPLICATION_CAMERA_MOTION, null, Format.NO_VALUE, drmInitData); } stsd.setPosition(childStartPosition + childAtomSize); } return out; }
Example 10
Source File: ReactExoplayerView.java From react-native-video with MIT License | 4 votes |
private MediaSource buildTextSource(String title, Uri uri, String mimeType, String language) { Format textFormat = Format.createTextSampleFormat(title, mimeType, Format.NO_VALUE, language); return new SingleSampleMediaSource.Factory(mediaDataSourceFactory) .createMediaSource(uri, textFormat, C.TIME_UNSET); }
Example 11
Source File: AtomParsers.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position, int atomSize, int trackId, String language, StsdData out) throws ParserException { parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE); // Default values. List<byte[]> initializationData = null; long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE; String mimeType; if (atomType == Atom.TYPE_TTML) { mimeType = MimeTypes.APPLICATION_TTML; } else if (atomType == Atom.TYPE_tx3g) { mimeType = MimeTypes.APPLICATION_TX3G; int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8; byte[] sampleDescriptionData = new byte[sampleDescriptionLength]; parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength); initializationData = Collections.singletonList(sampleDescriptionData); } else if (atomType == Atom.TYPE_wvtt) { mimeType = MimeTypes.APPLICATION_MP4VTT; } else if (atomType == Atom.TYPE_stpp) { mimeType = MimeTypes.APPLICATION_TTML; subsampleOffsetUs = 0; // Subsample timing is absolute. } else if (atomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. mimeType = MimeTypes.APPLICATION_MP4CEA608; out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else { // Never happens. throw new IllegalStateException(); } out.format = Format.createTextSampleFormat( Integer.toString(trackId), mimeType, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, /* accessibilityChannel= */ Format.NO_VALUE, /* drmInitData= */ null, subsampleOffsetUs, initializationData); }
Example 12
Source File: AtomParsers.java From Telegram with GNU General Public License v2.0 | 4 votes |
private static void parseTextSampleEntry(ParsableByteArray parent, int atomType, int position, int atomSize, int trackId, String language, StsdData out) throws ParserException { parent.setPosition(position + Atom.HEADER_SIZE + StsdData.STSD_HEADER_SIZE); // Default values. List<byte[]> initializationData = null; long subsampleOffsetUs = Format.OFFSET_SAMPLE_RELATIVE; String mimeType; if (atomType == Atom.TYPE_TTML) { mimeType = MimeTypes.APPLICATION_TTML; } else if (atomType == Atom.TYPE_tx3g) { mimeType = MimeTypes.APPLICATION_TX3G; int sampleDescriptionLength = atomSize - Atom.HEADER_SIZE - 8; byte[] sampleDescriptionData = new byte[sampleDescriptionLength]; parent.readBytes(sampleDescriptionData, 0, sampleDescriptionLength); initializationData = Collections.singletonList(sampleDescriptionData); } else if (atomType == Atom.TYPE_wvtt) { mimeType = MimeTypes.APPLICATION_MP4VTT; } else if (atomType == Atom.TYPE_stpp) { mimeType = MimeTypes.APPLICATION_TTML; subsampleOffsetUs = 0; // Subsample timing is absolute. } else if (atomType == Atom.TYPE_c608) { // Defined by the QuickTime File Format specification. mimeType = MimeTypes.APPLICATION_MP4CEA608; out.requiredSampleTransformation = Track.TRANSFORMATION_CEA608_CDAT; } else { // Never happens. throw new IllegalStateException(); } out.format = Format.createTextSampleFormat( Integer.toString(trackId), mimeType, /* codecs= */ null, /* bitrate= */ Format.NO_VALUE, /* selectionFlags= */ 0, language, /* accessibilityChannel= */ Format.NO_VALUE, /* drmInitData= */ null, subsampleOffsetUs, initializationData); }