Here are the examples of the java api class com.google.android.exoplayer.extractor.mp4.Track taken from open source projects.
1. SmoothStreamingChunkSource#initManifestTrack()
Project: ExoPlayer
File: SmoothStreamingChunkSource.java
File: SmoothStreamingChunkSource.java
// Private methods. private MediaFormat initManifestTrack(SmoothStreamingManifest manifest, int elementIndex, int trackIndex) { int manifestTrackKey = getManifestTrackKey(elementIndex, trackIndex); MediaFormat mediaFormat = mediaFormats.get(manifestTrackKey); if (mediaFormat != null) { // Already initialized. return mediaFormat; } // Build the media format. long durationUs = live ? C.UNKNOWN_TIME_US : manifest.durationUs; StreamElement element = manifest.streamElements[elementIndex]; Format format = element.tracks[trackIndex].format; byte[][] csdArray = element.tracks[trackIndex].csd; int mp4TrackType; switch(element.type) { case StreamElement.TYPE_VIDEO: mediaFormat = MediaFormat.createVideoFormat(format.id, format.mimeType, format.bitrate, MediaFormat.NO_VALUE, durationUs, format.width, format.height, Arrays.asList(csdArray)); mp4TrackType = Track.TYPE_vide; break; case StreamElement.TYPE_AUDIO: List<byte[]> csd; if (csdArray != null) { csd = Arrays.asList(csdArray); } else { csd = Collections.singletonList(CodecSpecificDataUtil.buildAacAudioSpecificConfig(format.audioSamplingRate, format.audioChannels)); } mediaFormat = MediaFormat.createAudioFormat(format.id, format.mimeType, format.bitrate, MediaFormat.NO_VALUE, durationUs, format.audioChannels, format.audioSamplingRate, csd, format.language); mp4TrackType = Track.TYPE_soun; break; case StreamElement.TYPE_TEXT: mediaFormat = MediaFormat.createTextFormat(format.id, format.mimeType, format.bitrate, durationUs, format.language); mp4TrackType = Track.TYPE_text; break; default: throw new IllegalStateException("Invalid type: " + element.type); } Track mp4Track = new Track(trackIndex, mp4TrackType, element.timescale, C.UNKNOWN_TIME_US, durationUs, mediaFormat, trackEncryptionBoxes, mp4TrackType == Track.TYPE_vide ? 4 : -1, null, null); // Build the extractor. FragmentedMp4Extractor mp4Extractor = new FragmentedMp4Extractor(FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME | FragmentedMp4Extractor.FLAG_WORKAROUND_IGNORE_TFDT_BOX, mp4Track); // Store the format and a wrapper around the extractor. mediaFormats.put(manifestTrackKey, mediaFormat); extractorWrappers.put(manifestTrackKey, new ChunkExtractorWrapper(mp4Extractor)); return mediaFormat; }