diff --git a/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java b/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java index c49e12753f..f36dabf21e 100644 --- a/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java +++ b/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java @@ -508,8 +508,7 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, } private static String buildTrackIdString(MediaFormat format) { - return format.trackId == MediaFormat.NO_VALUE ? "" - : String.format(Locale.US, " (%d)", format.trackId); + return format.trackId == null ? "" : " (" + format.trackId + ")"; } private boolean onTrackItemClick(MenuItem item, int type) { diff --git a/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java b/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java index a22bc07567..836ca27048 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java @@ -15,11 +15,11 @@ */ package com.google.android.exoplayer; -import com.google.android.exoplayer.util.Util; - import android.annotation.SuppressLint; import android.annotation.TargetApi; +import com.google.android.exoplayer.util.Util; + import junit.framework.TestCase; import java.nio.ByteBuffer; @@ -45,20 +45,20 @@ public final class MediaFormatTest extends TestCase { initData.add(initData2); testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat( - MediaFormat.NO_VALUE, "video/xyz", 5000, 102400, 1000L, 1280, 720, initData)); + null, "video/xyz", 5000, 102400, 1000L, 1280, 720, initData)); testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat( - MediaFormat.NO_VALUE, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720, + null, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720, null)); testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat( - MediaFormat.NO_VALUE, "audio/xyz", 500, 128, 1000L, 5, 44100, initData, null)); + null, "audio/xyz", 500, 128, 1000L, 5, 44100, initData, null)); testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat( - MediaFormat.NO_VALUE, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100, + null, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100, null, null)); testConversionToFrameworkFormatV16( - MediaFormat.createTextFormat(MediaFormat.NO_VALUE, "text/xyz", MediaFormat.NO_VALUE, 1000L, + MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, 1000L, "eng")); testConversionToFrameworkFormatV16( - MediaFormat.createTextFormat(MediaFormat.NO_VALUE, "text/xyz", MediaFormat.NO_VALUE, + MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, null)); } diff --git a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java index 6c0cf25b7a..e83738c4c1 100644 --- a/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java @@ -315,7 +315,7 @@ public final class FrameworkSampleSource implements SampleSource, SampleSourceRe } long durationUs = format.containsKey(android.media.MediaFormat.KEY_DURATION) ? format.getLong(android.media.MediaFormat.KEY_DURATION) : C.UNKNOWN_TIME_US; - MediaFormat mediaFormat = new MediaFormat(MediaFormat.NO_VALUE, mimeType, MediaFormat.NO_VALUE, + MediaFormat mediaFormat = new MediaFormat(null, mimeType, MediaFormat.NO_VALUE, maxInputSize, durationUs, width, height, rotationDegrees, MediaFormat.NO_VALUE, channelCount, sampleRate, language, MediaFormat.OFFSET_SAMPLE_RELATIVE, initializationData, false, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE); diff --git a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java index f97fbdcdec..2a81d92472 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java @@ -15,12 +15,12 @@ */ package com.google.android.exoplayer; -import com.google.android.exoplayer.util.Assertions; -import com.google.android.exoplayer.util.Util; - import android.annotation.SuppressLint; import android.annotation.TargetApi; +import com.google.android.exoplayer.util.Assertions; +import com.google.android.exoplayer.util.Util; + import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collections; @@ -40,10 +40,10 @@ public final class MediaFormat { public static final long OFFSET_SAMPLE_RELATIVE = Long.MAX_VALUE; /** - * The identifier for the track represented by the format, or {@link #NO_VALUE} if unknown or not + * The identifier for the track represented by the format, or null if unknown or not * applicable. */ - public final int trackId; + public final String trackId; /** * The mime type of the format. */ @@ -139,13 +139,13 @@ public final class MediaFormat { private int hashCode; private android.media.MediaFormat frameworkMediaFormat; - public static MediaFormat createVideoFormat(int trackId, String mimeType, int bitrate, + public static MediaFormat createVideoFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, List initializationData) { return createVideoFormat(trackId, mimeType, bitrate, maxInputSize, durationUs, width, height, initializationData, NO_VALUE, NO_VALUE); } - public static MediaFormat createVideoFormat(int trackId, String mimeType, int bitrate, + public static MediaFormat createVideoFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, List initializationData, int rotationDegrees, float pixelWidthHeightRatio) { return new MediaFormat(trackId, mimeType, bitrate, maxInputSize, durationUs, width, height, @@ -153,7 +153,7 @@ public final class MediaFormat { initializationData, false, NO_VALUE, NO_VALUE); } - public static MediaFormat createAudioFormat(int trackId, String mimeType, int bitrate, + public static MediaFormat createAudioFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int channelCount, int sampleRate, List initializationData, String language) { return new MediaFormat(trackId, mimeType, bitrate, maxInputSize, durationUs, NO_VALUE, NO_VALUE, @@ -161,27 +161,27 @@ public final class MediaFormat { initializationData, false, NO_VALUE, NO_VALUE); } - public static MediaFormat createTextFormat(int trackId, String mimeType, int bitrate, + public static MediaFormat createTextFormat(String trackId, String mimeType, int bitrate, long durationUs, String language) { return createTextFormat(trackId, mimeType, bitrate, durationUs, language, OFFSET_SAMPLE_RELATIVE); } - public static MediaFormat createTextFormat(int trackId, String mimeType, int bitrate, + public static MediaFormat createTextFormat(String trackId, String mimeType, int bitrate, long durationUs, String language, long subsampleOffsetUs) { return new MediaFormat(trackId, mimeType, bitrate, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, language, subsampleOffsetUs, null, false, NO_VALUE, NO_VALUE); } - public static MediaFormat createFormatForMimeType(int trackId, String mimeType, int bitrate, + public static MediaFormat createFormatForMimeType(String trackId, String mimeType, int bitrate, long durationUs) { return new MediaFormat(trackId, mimeType, bitrate, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, null, OFFSET_SAMPLE_RELATIVE, null, false, NO_VALUE, NO_VALUE); } - /* package */ MediaFormat(int trackId, String mimeType, int bitrate, int maxInputSize, + /* package */ MediaFormat(String trackId, String mimeType, int bitrate, int maxInputSize, long durationUs, int width, int height, int rotationDegrees, float pixelWidthHeightRatio, int channelCount, int sampleRate, String language, long subsampleOffsetUs, List initializationData, boolean adaptive, int maxWidth, int maxHeight) { @@ -230,7 +230,7 @@ public final class MediaFormat { } public MediaFormat copyAsAdaptive() { - return new MediaFormat(trackId, mimeType, NO_VALUE, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, + return new MediaFormat(null, mimeType, NO_VALUE, NO_VALUE, durationUs, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, NO_VALUE, null, OFFSET_SAMPLE_RELATIVE, null, true, maxWidth, maxHeight); } @@ -288,7 +288,7 @@ public final class MediaFormat { public int hashCode() { if (hashCode == 0) { int result = 17; - result = 31 * result + trackId; + result = 31 * result + (trackId == null ? 0 : trackId.hashCode()); result = 31 * result + (mimeType == null ? 0 : mimeType.hashCode()); result = 31 * result + bitrate; result = 31 * result + maxInputSize; diff --git a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java index 36265aa5ab..50e10e378d 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java @@ -610,14 +610,14 @@ public class DashChunkSource implements ChunkSource, Output { String mediaMimeType, long durationUs) { switch (adaptationSetType) { case AdaptationSet.TYPE_VIDEO: - return MediaFormat.createVideoFormat(MediaFormat.NO_VALUE, mediaMimeType, format.bitrate, + return MediaFormat.createVideoFormat(format.id, mediaMimeType, format.bitrate, MediaFormat.NO_VALUE, durationUs, format.width, format.height, null); case AdaptationSet.TYPE_AUDIO: - return MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, mediaMimeType, format.bitrate, + return MediaFormat.createAudioFormat(format.id, mediaMimeType, format.bitrate, MediaFormat.NO_VALUE, durationUs, format.audioChannels, format.audioSamplingRate, null, format.language); case AdaptationSet.TYPE_TEXT: - return MediaFormat.createTextFormat(MediaFormat.NO_VALUE, mediaMimeType, format.bitrate, + return MediaFormat.createTextFormat(format.id, mediaMimeType, format.bitrate, durationUs, format.language); default: return null; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/flv/AudioTagPayloadReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/flv/AudioTagPayloadReader.java index 0aa42cded7..239fe69b7d 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/flv/AudioTagPayloadReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/flv/AudioTagPayloadReader.java @@ -95,10 +95,9 @@ import java.util.Collections; Pair audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig( audioSpecificConfig); - MediaFormat mediaFormat = MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, - MimeTypes.AUDIO_AAC, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, getDurationUs(), - audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig), - null); + MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, MimeTypes.AUDIO_AAC, + MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, getDurationUs(), audioParams.second, + audioParams.first, Collections.singletonList(audioSpecificConfig), null); output.format(mediaFormat); hasOutputFormat = true; } else if (packetType == AAC_PACKET_TYPE_AAC_RAW) { diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java index 897913d647..599ea01636 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java @@ -95,9 +95,9 @@ import java.util.List; nalUnitLengthFieldLength = avcData.nalUnitLengthFieldLength; // Construct and output the format. - MediaFormat mediaFormat = MediaFormat.createVideoFormat(MediaFormat.NO_VALUE, - MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, getDurationUs(), - avcData.width, avcData.height, avcData.initializationData, MediaFormat.NO_VALUE, + MediaFormat mediaFormat = MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H264, + MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, getDurationUs(), avcData.width, + avcData.height, avcData.initializationData, MediaFormat.NO_VALUE, avcData.pixelWidthAspectRatio); output.format(mediaFormat); hasOutputFormat = true; diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java index ddeea484f5..03f761d5b2 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java @@ -332,7 +332,7 @@ public final class Mp3Extractor implements Extractor { if (seeker == null) { setupSeeker(extractorInput, headerPosition); extractorOutput.seekMap(seeker); - trackOutput.format(MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, + trackOutput.format(MediaFormat.createAudioFormat(null, synchronizedHeader.mimeType, MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(), synchronizedHeader.channels, synchronizedHeader.sampleRate, null, null)); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java index b149e11d9d..a7807aeab0 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java @@ -454,13 +454,13 @@ import java.util.List; parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, durationUs, language, out, i); } else if (childAtomType == Atom.TYPE_TTML) { - out.mediaFormat = MediaFormat.createTextFormat(trackId, MimeTypes.APPLICATION_TTML, + out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TTML, MediaFormat.NO_VALUE, durationUs, language); } else if (childAtomType == Atom.TYPE_tx3g) { - out.mediaFormat = MediaFormat.createTextFormat(trackId, MimeTypes.APPLICATION_TX3G, + out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TX3G, MediaFormat.NO_VALUE, durationUs, language); } else if (childAtomType == Atom.TYPE_stpp) { - out.mediaFormat = MediaFormat.createTextFormat(trackId, MimeTypes.APPLICATION_TTML, + out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId), MimeTypes.APPLICATION_TTML, MediaFormat.NO_VALUE, durationUs, language, 0 /* subsample timing is absolute */); } stsd.setPosition(childStartPosition + childAtomSize); @@ -531,7 +531,7 @@ import java.util.List; return; } - out.mediaFormat = MediaFormat.createVideoFormat(trackId, mimeType, MediaFormat.NO_VALUE, + out.mediaFormat = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, width, height, initializationData, rotationDegrees, pixelWidthHeightRatio); } @@ -753,7 +753,7 @@ import java.util.List; } else if ((atomType == Atom.TYPE_dtsc || atomType == Atom.TYPE_dtse || atomType == Atom.TYPE_dtsh || atomType == Atom.TYPE_dtsl) && childAtomType == Atom.TYPE_ddts) { - out.mediaFormat = MediaFormat.createAudioFormat(trackId, mimeType, MediaFormat.NO_VALUE, + out.mediaFormat = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); return; } @@ -765,7 +765,7 @@ import java.util.List; return; } - out.mediaFormat = MediaFormat.createAudioFormat(trackId, mimeType, MediaFormat.NO_VALUE, + out.mediaFormat = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, sampleSize, durationUs, channelCount, sampleRate, initializationData == null ? null : Collections.singletonList(initializationData), language); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java index cbdc58872a..ba3d69e024 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java @@ -170,7 +170,7 @@ import java.util.Collections; Pair audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig( audioSpecificConfig); - MediaFormat mediaFormat = MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, + MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, MimeTypes.AUDIO_AAC, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, audioParams.second, audioParams.first, Collections.singletonList(audioSpecificConfig), null); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java index 848e40b29d..efa3a8e5a2 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java @@ -210,7 +210,7 @@ import java.util.List; SpsData parsedSpsData = CodecSpecificDataUtil.parseSpsNalUnit(bitArray); // Construct and output the format. - output.format(MediaFormat.createVideoFormat(MediaFormat.NO_VALUE, MimeTypes.VIDEO_H264, + output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H264, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, parsedSpsData.width, parsedSpsData.height, initializationData, MediaFormat.NO_VALUE, parsedSpsData.pixelWidthAspectRatio)); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java index a4429ab90c..47bc512a27 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java @@ -294,7 +294,7 @@ import java.util.Collections; } } - output.format(MediaFormat.createVideoFormat(MediaFormat.NO_VALUE, MimeTypes.VIDEO_H265, + output.format(MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_H265, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, picWidthInLumaSamples, picHeightInLumaSamples, Collections.singletonList(csd), MediaFormat.NO_VALUE, pixelWidthHeightRatio)); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java index 553aae6499..ffbeafc295 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java @@ -35,7 +35,7 @@ import com.google.android.exoplayer.util.ParsableByteArray; public Id3Reader(TrackOutput output) { super(output); - output.format(MediaFormat.createFormatForMimeType(MediaFormat.NO_VALUE, + output.format(MediaFormat.createFormatForMimeType(null, MimeTypes.APPLICATION_ID3, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US)); } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/MpegAudioReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/MpegAudioReader.java index 8e268e53fe..ee8f84cfde 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/MpegAudioReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/MpegAudioReader.java @@ -160,7 +160,7 @@ import com.google.android.exoplayer.util.ParsableByteArray; frameSize = header.frameSize; if (!hasOutputFormat) { frameDurationUs = (C.MICROS_PER_SECOND * header.samplesPerFrame) / header.sampleRate; - MediaFormat mediaFormat = MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, header.mimeType, + MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, header.mimeType, MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, C.UNKNOWN_TIME_US, header.channels, header.sampleRate, null, null); output.format(mediaFormat); diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java index 81378d1685..2aa143d44a 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java @@ -32,7 +32,7 @@ import com.google.android.exoplayer.util.ParsableByteArray; public SeiReader(TrackOutput output) { super(output); - output.format(MediaFormat.createTextFormat(MediaFormat.NO_VALUE, MimeTypes.APPLICATION_EIA608, + output.format(MediaFormat.createTextFormat(null, MimeTypes.APPLICATION_EIA608, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, null)); } diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java index 38ce691844..a8e74b539d 100644 --- a/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java +++ b/library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java @@ -1227,14 +1227,16 @@ public final class WebmExtractor implements Extractor { } MediaFormat format; + // TODO: Read the name of the track from the header of the webm container and + // supply this as id instead of trackId? if (MimeTypes.isAudio(mimeType)) { - format = MediaFormat.createAudioFormat(trackId, mimeType, MediaFormat.NO_VALUE, + format = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, maxInputSize, durationUs, channelCount, sampleRate, initializationData, language); } else if (MimeTypes.isVideo(mimeType)) { - format = MediaFormat.createVideoFormat(trackId, mimeType, MediaFormat.NO_VALUE, + format = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, maxInputSize, durationUs, width, height, initializationData); } else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) { - format = MediaFormat.createTextFormat(trackId, mimeType, MediaFormat.NO_VALUE, durationUs, + format = MediaFormat.createTextFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, durationUs, language); } else { throw new ParserException("Unexpected MIME type."); diff --git a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java index 1c82d4b1e9..1dc88ca25d 100644 --- a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java @@ -398,7 +398,7 @@ public class SmoothStreamingChunkSource implements ChunkSource, int mp4TrackType; switch (element.type) { case StreamElement.TYPE_VIDEO: - mediaFormat = MediaFormat.createVideoFormat(MediaFormat.NO_VALUE, format.mimeType, + mediaFormat = MediaFormat.createVideoFormat(format.id, format.mimeType, format.bitrate, MediaFormat.NO_VALUE, durationUs, format.width, format.height, Arrays.asList(csdArray)); mp4TrackType = Track.TYPE_vide; @@ -411,13 +411,13 @@ public class SmoothStreamingChunkSource implements ChunkSource, csd = Collections.singletonList(CodecSpecificDataUtil.buildAacAudioSpecificConfig( format.audioSamplingRate, format.audioChannels)); } - mediaFormat = MediaFormat.createAudioFormat(MediaFormat.NO_VALUE, format.mimeType, + 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(MediaFormat.NO_VALUE, format.mimeType, + mediaFormat = MediaFormat.createTextFormat(format.id, format.mimeType, format.bitrate, durationUs, format.language); mp4TrackType = Track.TYPE_text; break; diff --git a/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java b/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java index 6f1b6764aa..041983fc67 100644 --- a/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java +++ b/library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java @@ -55,7 +55,7 @@ public final class Ac3Util { if ((nextByte & 0x04) != 0) { channelCount++; } - return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); } @@ -85,7 +85,7 @@ public final class Ac3Util { if ((nextByte & 0x01) != 0) { channelCount++; } - return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language); } @@ -117,7 +117,7 @@ public final class Ac3Util { data.skipBits(2); // dsurmod } boolean lfeon = data.readBit(); - return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, + return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0), SAMPLE_RATES[fscod], null, language); }