Cleanup following #884
This commit is contained in:
parent
e252dddeb0
commit
02cc495f1c
@ -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;
|
||||
@ -47,19 +47,16 @@ public final class MediaFormatTest extends TestCase {
|
||||
testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat(
|
||||
null, "video/xyz", 5000, 102400, 1000L, 1280, 720, initData));
|
||||
testConversionToFrameworkFormatV16(MediaFormat.createVideoFormat(
|
||||
null, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720,
|
||||
null));
|
||||
null, "video/xyz", 5000, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 1280, 720, null));
|
||||
testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat(
|
||||
null, "audio/xyz", 500, 128, 1000L, 5, 44100, initData, null));
|
||||
testConversionToFrameworkFormatV16(MediaFormat.createAudioFormat(
|
||||
null, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100,
|
||||
null, null));
|
||||
null, "audio/xyz", 500, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, 5, 44100, null, null));
|
||||
testConversionToFrameworkFormatV16(
|
||||
MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, 1000L,
|
||||
"eng"));
|
||||
MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, 1000L, "eng"));
|
||||
testConversionToFrameworkFormatV16(
|
||||
MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE,
|
||||
C.UNKNOWN_TIME_US, null));
|
||||
MediaFormat.createTextFormat(null, "text/xyz", MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US,
|
||||
null));
|
||||
}
|
||||
|
||||
@SuppressLint("InlinedApi")
|
||||
|
@ -315,10 +315,10 @@ 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(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);
|
||||
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);
|
||||
mediaFormat.setFrameworkFormatV16(format);
|
||||
return mediaFormat;
|
||||
}
|
||||
|
@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.google.android.exoplayer;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
||||
import com.google.android.exoplayer.util.Assertions;
|
||||
import com.google.android.exoplayer.util.Util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -40,8 +40,7 @@ public final class MediaFormat {
|
||||
public static final long OFFSET_SAMPLE_RELATIVE = Long.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* The identifier for the track represented by the format, or null if unknown or not
|
||||
* applicable.
|
||||
* The identifier for the track represented by the format, or null if unknown or not applicable.
|
||||
*/
|
||||
public final String trackId;
|
||||
/**
|
||||
@ -229,8 +228,8 @@ public final class MediaFormat {
|
||||
subsampleOffsetUs, initializationData, adaptive, maxWidth, maxHeight);
|
||||
}
|
||||
|
||||
public MediaFormat copyAsAdaptive() {
|
||||
return new MediaFormat(null, mimeType, NO_VALUE, NO_VALUE, durationUs, NO_VALUE, NO_VALUE,
|
||||
public MediaFormat copyAsAdaptive(String trackId) {
|
||||
return new MediaFormat(trackId, 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);
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ public class DashChunkSource implements ChunkSource, Output {
|
||||
Log.w(TAG, "Skipped adaptive track (unknown media format)");
|
||||
return;
|
||||
}
|
||||
tracks.add(new ExposedTrack(trackFormat.copyAsAdaptive(), adaptationSetIndex,
|
||||
tracks.add(new ExposedTrack(trackFormat.copyAsAdaptive(null), adaptationSetIndex,
|
||||
representationFormats, maxWidth, maxHeight));
|
||||
}
|
||||
|
||||
|
@ -332,10 +332,9 @@ public final class Mp3Extractor implements Extractor {
|
||||
if (seeker == null) {
|
||||
setupSeeker(extractorInput, headerPosition);
|
||||
extractorOutput.seekMap(seeker);
|
||||
trackOutput.format(MediaFormat.createAudioFormat(null,
|
||||
synchronizedHeader.mimeType, MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES,
|
||||
seeker.getDurationUs(), synchronizedHeader.channels, synchronizedHeader.sampleRate, null,
|
||||
null));
|
||||
trackOutput.format(MediaFormat.createAudioFormat(null, synchronizedHeader.mimeType,
|
||||
MediaFormat.NO_VALUE, MpegAudioHeader.MAX_FRAME_SIZE_BYTES, seeker.getDurationUs(),
|
||||
synchronizedHeader.channels, synchronizedHeader.sampleRate, null, null));
|
||||
}
|
||||
|
||||
return headerPosition;
|
||||
|
@ -744,17 +744,20 @@ import java.util.List;
|
||||
// TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
|
||||
// TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
|
||||
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
||||
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, trackId, durationUs, language);
|
||||
out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent, Integer.toString(trackId),
|
||||
durationUs, language);
|
||||
return;
|
||||
} else if (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) {
|
||||
parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
|
||||
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, trackId, durationUs, language);
|
||||
out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent, Integer.toString(trackId),
|
||||
durationUs, language);
|
||||
return;
|
||||
} 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(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE,
|
||||
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language);
|
||||
out.mediaFormat = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType,
|
||||
MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null,
|
||||
language);
|
||||
return;
|
||||
}
|
||||
childPosition += childAtomSize;
|
||||
|
@ -155,8 +155,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
|
||||
sampleSize = Ac3Util.parseFrameSize(headerScratchBits);
|
||||
if (mediaFormat == null) {
|
||||
headerScratchBits.setPosition(0);
|
||||
mediaFormat = Ac3Util.parseFrameAc3Format(headerScratchBits, MediaFormat.NO_VALUE,
|
||||
C.UNKNOWN_TIME_US, null);
|
||||
mediaFormat = Ac3Util.parseFrameAc3Format(headerScratchBits, null, C.UNKNOWN_TIME_US, null);
|
||||
output.format(mediaFormat);
|
||||
bitrate = Ac3Util.getBitrate(sampleSize, mediaFormat.sampleRate);
|
||||
}
|
||||
|
@ -170,10 +170,9 @@ import java.util.Collections;
|
||||
Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig(
|
||||
audioSpecificConfig);
|
||||
|
||||
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);
|
||||
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);
|
||||
frameDurationUs = (C.MICROS_PER_SECOND * 1024L) / mediaFormat.sampleRate;
|
||||
output.format(mediaFormat);
|
||||
hasOutputFormat = true;
|
||||
|
@ -210,10 +210,9 @@ import java.util.List;
|
||||
SpsData parsedSpsData = CodecSpecificDataUtil.parseSpsNalUnit(bitArray);
|
||||
|
||||
// Construct and output the format.
|
||||
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));
|
||||
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));
|
||||
hasOutputFormat = true;
|
||||
}
|
||||
|
||||
|
@ -294,10 +294,9 @@ import java.util.Collections;
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
hasOutputFormat = true;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ import com.google.android.exoplayer.util.ParsableByteArray;
|
||||
|
||||
public Id3Reader(TrackOutput output) {
|
||||
super(output);
|
||||
output.format(MediaFormat.createFormatForMimeType(null,
|
||||
MimeTypes.APPLICATION_ID3, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US));
|
||||
output.format(MediaFormat.createFormatForMimeType(null, MimeTypes.APPLICATION_ID3,
|
||||
MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1227,17 +1227,18 @@ 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?
|
||||
// TODO: Consider reading the name elements of the tracks and, if present, incorporating them
|
||||
// into the trackId passed when creating the formats.
|
||||
if (MimeTypes.isAudio(mimeType)) {
|
||||
format = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE,
|
||||
maxInputSize, durationUs, channelCount, sampleRate, initializationData, language);
|
||||
format = MediaFormat.createAudioFormat(Integer.toString(trackId), mimeType,
|
||||
MediaFormat.NO_VALUE, maxInputSize, durationUs, channelCount, sampleRate,
|
||||
initializationData, language);
|
||||
} else if (MimeTypes.isVideo(mimeType)) {
|
||||
format = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE,
|
||||
maxInputSize, durationUs, width, height, initializationData);
|
||||
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(Integer.toString(trackId), mimeType, MediaFormat.NO_VALUE, durationUs,
|
||||
language);
|
||||
format = MediaFormat.createTextFormat(Integer.toString(trackId), mimeType,
|
||||
MediaFormat.NO_VALUE, durationUs, language);
|
||||
} else {
|
||||
throw new ParserException("Unexpected MIME type.");
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
|
||||
for (int i = 0; i < trackCount; i++) {
|
||||
MediaFormat format = extractor.getMediaFormat(i).copyWithDurationUs(durationUs);
|
||||
if (MimeTypes.isVideo(format.mimeType)) {
|
||||
format = format.copyAsAdaptive();
|
||||
format = format.copyAsAdaptive(null);
|
||||
}
|
||||
trackFormat[i] = format;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ public class SmoothStreamingChunkSource implements ChunkSource,
|
||||
maxHeight = Math.max(maxHeight, mediaFormat.height);
|
||||
}
|
||||
Arrays.sort(formats, new DecreasingBandwidthComparator());
|
||||
MediaFormat adaptiveMediaFormat = maxHeightMediaFormat.copyAsAdaptive();
|
||||
MediaFormat adaptiveMediaFormat = maxHeightMediaFormat.copyAsAdaptive(null);
|
||||
tracks.add(new ExposedTrack(adaptiveMediaFormat, element, formats, maxWidth, maxHeight));
|
||||
}
|
||||
|
||||
@ -398,9 +398,8 @@ public class SmoothStreamingChunkSource implements ChunkSource,
|
||||
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));
|
||||
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:
|
||||
@ -411,14 +410,14 @@ public class SmoothStreamingChunkSource implements ChunkSource,
|
||||
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);
|
||||
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);
|
||||
mediaFormat = MediaFormat.createTextFormat(format.id, format.mimeType, format.bitrate,
|
||||
durationUs, format.language);
|
||||
mp4TrackType = Track.TYPE_text;
|
||||
break;
|
||||
default:
|
||||
|
@ -38,12 +38,12 @@ public final class Ac3Util {
|
||||
* ETSI TS 102 366 Annex F.
|
||||
*
|
||||
* @param data The AC3SpecificBox.
|
||||
* @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}.
|
||||
* @param trackId The track identifier to set on the format, or null.
|
||||
* @param durationUs The duration to set on the format, in microseconds.
|
||||
* @param language The language to set on the format.
|
||||
* @return The AC-3 format parsed from data in the header.
|
||||
*/
|
||||
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, int trackId,
|
||||
public static MediaFormat parseAnnexFAc3Format(ParsableByteArray data, String trackId,
|
||||
long durationUs, String language) {
|
||||
// fscod (sample rate code)
|
||||
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
|
||||
@ -55,7 +55,7 @@ public final class Ac3Util {
|
||||
if ((nextByte & 0x04) != 0) {
|
||||
channelCount++;
|
||||
}
|
||||
return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||
return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language);
|
||||
}
|
||||
|
||||
@ -64,12 +64,12 @@ public final class Ac3Util {
|
||||
* ETSI TS 102 366 Annex F.
|
||||
*
|
||||
* @param data The EC3SpecificBox.
|
||||
* @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}.
|
||||
* @param trackId The track identifier to set on the format, or null.
|
||||
* @param durationUs The duration to set on the format, in microseconds.
|
||||
* @param language The language to set on the format.
|
||||
* @return The E-AC-3 format parsed from data in the header.
|
||||
*/
|
||||
public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data, int trackId,
|
||||
public static MediaFormat parseAnnexFEAc3Format(ParsableByteArray data, String trackId,
|
||||
long durationUs, String language) {
|
||||
data.skipBytes(2); // Skip data_rate and num_ind_sub.
|
||||
|
||||
@ -85,7 +85,7 @@ public final class Ac3Util {
|
||||
if ((nextByte & 0x01) != 0) {
|
||||
channelCount++;
|
||||
}
|
||||
return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE,
|
||||
return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_EC3, MediaFormat.NO_VALUE,
|
||||
MediaFormat.NO_VALUE, durationUs, channelCount, sampleRate, null, language);
|
||||
}
|
||||
|
||||
@ -94,13 +94,13 @@ public final class Ac3Util {
|
||||
* word.
|
||||
*
|
||||
* @param data Data to parse, positioned at the start of the syncword.
|
||||
* @param trackId The identifier for the track in its container, or {@link MediaFormat#NO_VALUE}.
|
||||
* @param trackId The track identifier to set on the format, or null.
|
||||
* @param durationUs The duration to set on the format, in microseconds.
|
||||
* @param language The language to set on the format.
|
||||
* @return The AC-3 format parsed from data in the header.
|
||||
*/
|
||||
public static MediaFormat parseFrameAc3Format(ParsableBitArray data, int trackId, long durationUs,
|
||||
String language) {
|
||||
public static MediaFormat parseFrameAc3Format(ParsableBitArray data, String trackId,
|
||||
long durationUs, String language) {
|
||||
// Skip syncword and crc1.
|
||||
data.skipBits(4 * 8);
|
||||
|
||||
@ -117,7 +117,7 @@ public final class Ac3Util {
|
||||
data.skipBits(2); // dsurmod
|
||||
}
|
||||
boolean lfeon = data.readBit();
|
||||
return MediaFormat.createAudioFormat(Integer.toString(trackId), MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||
return MediaFormat.createAudioFormat(trackId, MimeTypes.AUDIO_AC3, MediaFormat.NO_VALUE,
|
||||
MediaFormat.NO_VALUE, durationUs, CHANNEL_COUNTS[acmod] + (lfeon ? 1 : 0),
|
||||
SAMPLE_RATES[fscod], null, language);
|
||||
}
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package com.google.android.exoplayer.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
/**
|
||||
* Defines common MIME types and helper methods.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user