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