Format with google-java-format
This commit is contained in:
parent
286b1f52d9
commit
7e21da8b73
@ -1547,31 +1547,6 @@ public final class C {
|
|||||||
/** The first frame was rendered. */
|
/** The first frame was rendered. */
|
||||||
@UnstableApi public static final int FIRST_FRAME_RENDERED = 3;
|
@UnstableApi public static final int FIRST_FRAME_RENDERED = 3;
|
||||||
|
|
||||||
/**
|
|
||||||
* The audio type of the stream, as defined by ISO/IEC 13818-1, section 2.6.18.
|
|
||||||
*
|
|
||||||
* <p>One of {@link #AUDIO_TYPE_UNDEFINED}, {@link #AUDIO_TYPE_CLEAN_EFFECTS},
|
|
||||||
* {@link #AUDIO_TYPE_HEARING_IMPAIRED} or {@link #AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY}.
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
|
|
||||||
@IntDef({
|
|
||||||
AUDIO_TYPE_UNDEFINED,
|
|
||||||
AUDIO_TYPE_CLEAN_EFFECTS,
|
|
||||||
AUDIO_TYPE_HEARING_IMPAIRED,
|
|
||||||
AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY
|
|
||||||
})
|
|
||||||
public @interface AudioType {}
|
|
||||||
|
|
||||||
public static final int AUDIO_TYPE_UNDEFINED = 0;
|
|
||||||
/** Indicates the track has no language. */
|
|
||||||
public static final int AUDIO_TYPE_CLEAN_EFFECTS = 1;
|
|
||||||
/** Indicates the track is prepared for the hearing impaired. */
|
|
||||||
public static final int AUDIO_TYPE_HEARING_IMPAIRED = 2;
|
|
||||||
/** Indicates the track is prepared for the visually impaired viewer. */
|
|
||||||
public static final int AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY = 3;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link Util#usToMs(long)}.
|
* @deprecated Use {@link Util#usToMs(long)}.
|
||||||
*/
|
*/
|
||||||
@ -1633,15 +1608,4 @@ public final class C {
|
|||||||
int mediaDrmErrorCode) {
|
int mediaDrmErrorCode) {
|
||||||
return Util.getErrorCodeForMediaDrmErrorCode(mediaDrmErrorCode);
|
return Util.getErrorCodeForMediaDrmErrorCode(mediaDrmErrorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static @C.RoleFlags int parseRoleFlagsFromAudioType(@AudioType int audioType) {
|
|
||||||
switch (audioType) {
|
|
||||||
case C.AUDIO_TYPE_HEARING_IMPAIRED:
|
|
||||||
return C.ROLE_FLAG_ENHANCED_DIALOG_INTELLIGIBILITY;
|
|
||||||
case C.AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY:
|
|
||||||
return C.ROLE_FLAG_DESCRIBES_VIDEO;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import androidx.media3.common.ParserException;
|
|||||||
import androidx.media3.common.util.ParsableBitArray;
|
import androidx.media3.common.util.ParsableBitArray;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
|
import androidx.media3.extractor.ts.TsUtil;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
@ -266,7 +267,7 @@ public final class DtsUtil {
|
|||||||
byte[] frame,
|
byte[] frame,
|
||||||
@Nullable String trackId,
|
@Nullable String trackId,
|
||||||
@Nullable String language,
|
@Nullable String language,
|
||||||
@C.AudioType int audioType,
|
@TsUtil.AudioType int audioType,
|
||||||
@Nullable DrmInitData drmInitData) {
|
@Nullable DrmInitData drmInitData) {
|
||||||
ParsableBitArray frameBits = getNormalizedFrame(frame);
|
ParsableBitArray frameBits = getNormalizedFrame(frame);
|
||||||
frameBits.skipBits(32 + 1 + 5 + 1 + 7 + 14); // SYNC, FTYPE, SHORT, CPF, NBLKS, FSIZE
|
frameBits.skipBits(32 + 1 + 5 + 1 + 7 + 14); // SYNC, FTYPE, SHORT, CPF, NBLKS, FSIZE
|
||||||
@ -289,7 +290,7 @@ public final class DtsUtil {
|
|||||||
.setSampleRate(sampleRate)
|
.setSampleRate(sampleRate)
|
||||||
.setDrmInitData(drmInitData)
|
.setDrmInitData(drmInitData)
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public final class Ac3Reader implements ElementaryStreamReader {
|
|||||||
private final ParsableBitArray headerScratchBits;
|
private final ParsableBitArray headerScratchBits;
|
||||||
private final ParsableByteArray headerScratchBytes;
|
private final ParsableByteArray headerScratchBytes;
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
|
|
||||||
private @MonotonicNonNull String formatId;
|
private @MonotonicNonNull String formatId;
|
||||||
private @MonotonicNonNull TrackOutput output;
|
private @MonotonicNonNull TrackOutput output;
|
||||||
@ -81,7 +81,7 @@ public final class Ac3Reader implements ElementaryStreamReader {
|
|||||||
|
|
||||||
/** Constructs a new reader for (E-)AC-3 elementary streams. */
|
/** Constructs a new reader for (E-)AC-3 elementary streams. */
|
||||||
public Ac3Reader() {
|
public Ac3Reader() {
|
||||||
this(null, C.AUDIO_TYPE_UNDEFINED);
|
this(null, TsUtil.AUDIO_TYPE_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +90,7 @@ public final class Ac3Reader implements ElementaryStreamReader {
|
|||||||
* @param language Track language.
|
* @param language Track language.
|
||||||
* @param audioType Track audio type.
|
* @param audioType Track audio type.
|
||||||
*/
|
*/
|
||||||
public Ac3Reader(@Nullable String language, @C.AudioType int audioType) {
|
public Ac3Reader(@Nullable String language, @TsUtil.AudioType int audioType) {
|
||||||
headerScratchBits = new ParsableBitArray(new byte[HEADER_SIZE]);
|
headerScratchBits = new ParsableBitArray(new byte[HEADER_SIZE]);
|
||||||
headerScratchBytes = new ParsableByteArray(headerScratchBits.data);
|
headerScratchBytes = new ParsableByteArray(headerScratchBits.data);
|
||||||
state = STATE_FINDING_SYNC;
|
state = STATE_FINDING_SYNC;
|
||||||
@ -219,7 +219,7 @@ public final class Ac3Reader implements ElementaryStreamReader {
|
|||||||
.setChannelCount(frameInfo.channelCount)
|
.setChannelCount(frameInfo.channelCount)
|
||||||
.setSampleRate(frameInfo.sampleRate)
|
.setSampleRate(frameInfo.sampleRate)
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.setPeakBitrate(frameInfo.bitrate);
|
.setPeakBitrate(frameInfo.bitrate);
|
||||||
// AC3 has constant bitrate, so averageBitrate = peakBitrate
|
// AC3 has constant bitrate, so averageBitrate = peakBitrate
|
||||||
if (MimeTypes.AUDIO_AC3.equals(frameInfo.mimeType)) {
|
if (MimeTypes.AUDIO_AC3.equals(frameInfo.mimeType)) {
|
||||||
|
@ -57,7 +57,7 @@ public final class Ac4Reader implements ElementaryStreamReader {
|
|||||||
private final ParsableBitArray headerScratchBits;
|
private final ParsableBitArray headerScratchBits;
|
||||||
private final ParsableByteArray headerScratchBytes;
|
private final ParsableByteArray headerScratchBytes;
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
|
|
||||||
private @MonotonicNonNull String formatId;
|
private @MonotonicNonNull String formatId;
|
||||||
private @MonotonicNonNull TrackOutput output;
|
private @MonotonicNonNull TrackOutput output;
|
||||||
@ -79,7 +79,7 @@ public final class Ac4Reader implements ElementaryStreamReader {
|
|||||||
|
|
||||||
/** Constructs a new reader for AC-4 elementary streams. */
|
/** Constructs a new reader for AC-4 elementary streams. */
|
||||||
public Ac4Reader() {
|
public Ac4Reader() {
|
||||||
this(null, C.AUDIO_TYPE_UNDEFINED);
|
this(null, TsUtil.AUDIO_TYPE_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,7 +88,7 @@ public final class Ac4Reader implements ElementaryStreamReader {
|
|||||||
* @param language Track language.
|
* @param language Track language.
|
||||||
* @param audioType Track audio type.
|
* @param audioType Track audio type.
|
||||||
*/
|
*/
|
||||||
public Ac4Reader(@Nullable String language, @C.AudioType int audioType) {
|
public Ac4Reader(@Nullable String language, @TsUtil.AudioType int audioType) {
|
||||||
headerScratchBits = new ParsableBitArray(new byte[Ac4Util.HEADER_SIZE_FOR_PARSER]);
|
headerScratchBits = new ParsableBitArray(new byte[Ac4Util.HEADER_SIZE_FOR_PARSER]);
|
||||||
headerScratchBytes = new ParsableByteArray(headerScratchBits.data);
|
headerScratchBytes = new ParsableByteArray(headerScratchBits.data);
|
||||||
state = STATE_FINDING_SYNC;
|
state = STATE_FINDING_SYNC;
|
||||||
@ -220,7 +220,7 @@ public final class Ac4Reader implements ElementaryStreamReader {
|
|||||||
.setChannelCount(frameInfo.channelCount)
|
.setChannelCount(frameInfo.channelCount)
|
||||||
.setSampleRate(frameInfo.sampleRate)
|
.setSampleRate(frameInfo.sampleRate)
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
output.format(format);
|
output.format(format);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public final class AdtsReader implements ElementaryStreamReader {
|
|||||||
private final ParsableBitArray adtsScratch;
|
private final ParsableBitArray adtsScratch;
|
||||||
private final ParsableByteArray id3HeaderBuffer;
|
private final ParsableByteArray id3HeaderBuffer;
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
|
|
||||||
private @MonotonicNonNull String formatId;
|
private @MonotonicNonNull String formatId;
|
||||||
private @MonotonicNonNull TrackOutput output;
|
private @MonotonicNonNull TrackOutput output;
|
||||||
@ -106,7 +106,7 @@ public final class AdtsReader implements ElementaryStreamReader {
|
|||||||
* @param exposeId3 True if the reader should expose ID3 information.
|
* @param exposeId3 True if the reader should expose ID3 information.
|
||||||
*/
|
*/
|
||||||
public AdtsReader(boolean exposeId3) {
|
public AdtsReader(boolean exposeId3) {
|
||||||
this(exposeId3, null, C.AUDIO_TYPE_UNDEFINED);
|
this(exposeId3, null, TsUtil.AUDIO_TYPE_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,7 +114,7 @@ public final class AdtsReader implements ElementaryStreamReader {
|
|||||||
* @param language Track language.
|
* @param language Track language.
|
||||||
* @param audioType Track audio type.
|
* @param audioType Track audio type.
|
||||||
*/
|
*/
|
||||||
public AdtsReader(boolean exposeId3, @Nullable String language, @C.AudioType int audioType) {
|
public AdtsReader(boolean exposeId3, @Nullable String language, @TsUtil.AudioType int audioType) {
|
||||||
adtsScratch = new ParsableBitArray(new byte[HEADER_SIZE + CRC_SIZE]);
|
adtsScratch = new ParsableBitArray(new byte[HEADER_SIZE + CRC_SIZE]);
|
||||||
id3HeaderBuffer = new ParsableByteArray(Arrays.copyOf(ID3_IDENTIFIER, ID3_HEADER_SIZE));
|
id3HeaderBuffer = new ParsableByteArray(Arrays.copyOf(ID3_IDENTIFIER, ID3_HEADER_SIZE));
|
||||||
setFindingSampleState();
|
setFindingSampleState();
|
||||||
@ -513,7 +513,7 @@ public final class AdtsReader implements ElementaryStreamReader {
|
|||||||
.setSampleRate(aacConfig.sampleRateHz)
|
.setSampleRate(aacConfig.sampleRateHz)
|
||||||
.setInitializationData(Collections.singletonList(audioSpecificConfig))
|
.setInitializationData(Collections.singletonList(audioSpecificConfig))
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
// In this class a sample is an access unit, but the MediaFormat sample rate specifies the
|
// In this class a sample is an access unit, but the MediaFormat sample rate specifies the
|
||||||
// number of PCM audio samples per second.
|
// number of PCM audio samples per second.
|
||||||
|
@ -172,9 +172,11 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
|
|||||||
// Fall through.
|
// Fall through.
|
||||||
case TsExtractor.TS_STREAM_TYPE_DTS:
|
case TsExtractor.TS_STREAM_TYPE_DTS:
|
||||||
case TsExtractor.TS_STREAM_TYPE_DTS_HD:
|
case TsExtractor.TS_STREAM_TYPE_DTS_HD:
|
||||||
return new PesReader(new DtsReader(esInfo.language, DtsReader.EXTSS_HEADER_SIZE_MAX, esInfo.audioType));
|
return new PesReader(
|
||||||
|
new DtsReader(esInfo.language, DtsReader.EXTSS_HEADER_SIZE_MAX, esInfo.audioType));
|
||||||
case TsExtractor.TS_STREAM_TYPE_DTS_UHD:
|
case TsExtractor.TS_STREAM_TYPE_DTS_UHD:
|
||||||
return new PesReader(new DtsReader(esInfo.language, DtsReader.FTOC_MAX_HEADER_SIZE, esInfo.audioType));
|
return new PesReader(
|
||||||
|
new DtsReader(esInfo.language, DtsReader.FTOC_MAX_HEADER_SIZE, esInfo.audioType));
|
||||||
case TsExtractor.TS_STREAM_TYPE_H262:
|
case TsExtractor.TS_STREAM_TYPE_H262:
|
||||||
case TsExtractor.TS_STREAM_TYPE_DC2_H262:
|
case TsExtractor.TS_STREAM_TYPE_DC2_H262:
|
||||||
return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
|
return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
|
||||||
|
@ -68,7 +68,7 @@ public final class DtsReader implements ElementaryStreamReader {
|
|||||||
private final AtomicInteger uhdAudioChunkId;
|
private final AtomicInteger uhdAudioChunkId;
|
||||||
|
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
|
|
||||||
private @MonotonicNonNull String formatId;
|
private @MonotonicNonNull String formatId;
|
||||||
private @MonotonicNonNull TrackOutput output;
|
private @MonotonicNonNull TrackOutput output;
|
||||||
@ -97,7 +97,7 @@ public final class DtsReader implements ElementaryStreamReader {
|
|||||||
* @param audioType Track audio type.
|
* @param audioType Track audio type.
|
||||||
* @param maxHeaderSize Maximum size of the header in a frame.
|
* @param maxHeaderSize Maximum size of the header in a frame.
|
||||||
*/
|
*/
|
||||||
public DtsReader(@Nullable String language, int maxHeaderSize, @C.AudioType int audioType) {
|
public DtsReader(@Nullable String language, int maxHeaderSize, @TsUtil.AudioType int audioType) {
|
||||||
headerScratchBytes = new ParsableByteArray(new byte[maxHeaderSize]);
|
headerScratchBytes = new ParsableByteArray(new byte[maxHeaderSize]);
|
||||||
state = STATE_FINDING_SYNC;
|
state = STATE_FINDING_SYNC;
|
||||||
timeUs = C.TIME_UNSET;
|
timeUs = C.TIME_UNSET;
|
||||||
@ -317,6 +317,7 @@ public final class DtsReader implements ElementaryStreamReader {
|
|||||||
.setChannelCount(dtsHeader.channelCount)
|
.setChannelCount(dtsHeader.channelCount)
|
||||||
.setSampleRate(dtsHeader.sampleRate)
|
.setSampleRate(dtsHeader.sampleRate)
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
output.format(format);
|
output.format(format);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public final class LatmReader implements ElementaryStreamReader {
|
|||||||
private static final int SYNC_BYTE_SECOND = 0xE0;
|
private static final int SYNC_BYTE_SECOND = 0xE0;
|
||||||
|
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
private final ParsableByteArray sampleDataBuffer;
|
private final ParsableByteArray sampleDataBuffer;
|
||||||
private final ParsableBitArray sampleBitArray;
|
private final ParsableBitArray sampleBitArray;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public final class LatmReader implements ElementaryStreamReader {
|
|||||||
* @param language Track language.
|
* @param language Track language.
|
||||||
* @param audioType Track audio type.
|
* @param audioType Track audio type.
|
||||||
*/
|
*/
|
||||||
public LatmReader(@Nullable String language, @C.AudioType int audioType) {
|
public LatmReader(@Nullable String language, @TsUtil.AudioType int audioType) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
this.audioType = audioType;
|
this.audioType = audioType;
|
||||||
sampleDataBuffer = new ParsableByteArray(INITIAL_BUFFER_SIZE);
|
sampleDataBuffer = new ParsableByteArray(INITIAL_BUFFER_SIZE);
|
||||||
@ -220,7 +220,7 @@ public final class LatmReader implements ElementaryStreamReader {
|
|||||||
.setSampleRate(sampleRateHz)
|
.setSampleRate(sampleRateHz)
|
||||||
.setInitializationData(Collections.singletonList(initData))
|
.setInitializationData(Collections.singletonList(initData))
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
if (!format.equals(this.format)) {
|
if (!format.equals(this.format)) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
|
@ -44,7 +44,7 @@ public final class MpegAudioReader implements ElementaryStreamReader {
|
|||||||
private final ParsableByteArray headerScratch;
|
private final ParsableByteArray headerScratch;
|
||||||
private final MpegAudioUtil.Header header;
|
private final MpegAudioUtil.Header header;
|
||||||
@Nullable private final String language;
|
@Nullable private final String language;
|
||||||
@C.AudioType private final int audioType;
|
@TsUtil.AudioType private final int audioType;
|
||||||
|
|
||||||
private @MonotonicNonNull TrackOutput output;
|
private @MonotonicNonNull TrackOutput output;
|
||||||
private @MonotonicNonNull String formatId;
|
private @MonotonicNonNull String formatId;
|
||||||
@ -64,10 +64,10 @@ public final class MpegAudioReader implements ElementaryStreamReader {
|
|||||||
private long timeUs;
|
private long timeUs;
|
||||||
|
|
||||||
public MpegAudioReader() {
|
public MpegAudioReader() {
|
||||||
this(null, C.AUDIO_TYPE_UNDEFINED);
|
this(null, TsUtil.AUDIO_TYPE_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MpegAudioReader(@Nullable String language, @C.AudioType int audioType) {
|
public MpegAudioReader(@Nullable String language, @TsUtil.AudioType int audioType) {
|
||||||
state = STATE_FINDING_HEADER;
|
state = STATE_FINDING_HEADER;
|
||||||
// The first byte of an MPEG Audio frame header is always 0xFF.
|
// The first byte of an MPEG Audio frame header is always 0xFF.
|
||||||
headerScratch = new ParsableByteArray(4);
|
headerScratch = new ParsableByteArray(4);
|
||||||
@ -202,7 +202,7 @@ public final class MpegAudioReader implements ElementaryStreamReader {
|
|||||||
.setChannelCount(header.channels)
|
.setChannelCount(header.channels)
|
||||||
.setSampleRate(header.sampleRate)
|
.setSampleRate(header.sampleRate)
|
||||||
.setLanguage(language)
|
.setLanguage(language)
|
||||||
.setRoleFlags(C.parseRoleFlagsFromAudioType(audioType))
|
.setRoleFlags(TsUtil.parseRoleFlagsFromAudioType(audioType))
|
||||||
.build();
|
.build();
|
||||||
output.format(format);
|
output.format(format);
|
||||||
hasOutputFormat = true;
|
hasOutputFormat = true;
|
||||||
|
@ -752,7 +752,9 @@ public final class TsExtractor implements Extractor {
|
|||||||
if (mode == MODE_HLS && id3Reader == null) {
|
if (mode == MODE_HLS && id3Reader == null) {
|
||||||
// Setup an ID3 track regardless of whether there's a corresponding entry, in case one
|
// Setup an ID3 track regardless of whether there's a corresponding entry, in case one
|
||||||
// appears intermittently during playback. See [Internal: b/20261500].
|
// appears intermittently during playback. See [Internal: b/20261500].
|
||||||
EsInfo id3EsInfo = new EsInfo(TS_STREAM_TYPE_ID3, null, C.AUDIO_TYPE_UNDEFINED, null, Util.EMPTY_BYTE_ARRAY);
|
EsInfo id3EsInfo =
|
||||||
|
new EsInfo(
|
||||||
|
TS_STREAM_TYPE_ID3, null, TsUtil.AUDIO_TYPE_UNDEFINED, null, Util.EMPTY_BYTE_ARRAY);
|
||||||
id3Reader = payloadReaderFactory.createPayloadReader(TS_STREAM_TYPE_ID3, id3EsInfo);
|
id3Reader = payloadReaderFactory.createPayloadReader(TS_STREAM_TYPE_ID3, id3EsInfo);
|
||||||
if (id3Reader != null) {
|
if (id3Reader != null) {
|
||||||
id3Reader.init(
|
id3Reader.init(
|
||||||
@ -842,7 +844,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
int descriptorsEndPosition = descriptorsStartPosition + length;
|
int descriptorsEndPosition = descriptorsStartPosition + length;
|
||||||
int streamType = -1;
|
int streamType = -1;
|
||||||
String language = null;
|
String language = null;
|
||||||
int audioType = C.AUDIO_TYPE_UNDEFINED;
|
int audioType = TsUtil.AUDIO_TYPE_UNDEFINED;
|
||||||
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
|
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
|
||||||
while (data.getPosition() < descriptorsEndPosition) {
|
while (data.getPosition() < descriptorsEndPosition) {
|
||||||
int descriptorTag = data.readUnsignedByte();
|
int descriptorTag = data.readUnsignedByte();
|
||||||
|
@ -20,7 +20,6 @@ import static java.lang.annotation.ElementType.TYPE_USE;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.common.util.TimestampAdjuster;
|
import androidx.media3.common.util.TimestampAdjuster;
|
||||||
@ -68,7 +67,7 @@ public interface TsPayloadReader {
|
|||||||
|
|
||||||
public final int streamType;
|
public final int streamType;
|
||||||
@Nullable public final String language;
|
@Nullable public final String language;
|
||||||
@C.AudioType public final int audioType;
|
@TsUtil.AudioType public final int audioType;
|
||||||
public final List<DvbSubtitleInfo> dvbSubtitleInfos;
|
public final List<DvbSubtitleInfo> dvbSubtitleInfos;
|
||||||
public final byte[] descriptorBytes;
|
public final byte[] descriptorBytes;
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ public interface TsPayloadReader {
|
|||||||
public EsInfo(
|
public EsInfo(
|
||||||
int streamType,
|
int streamType,
|
||||||
@Nullable String language,
|
@Nullable String language,
|
||||||
@C.AudioType int audioType,
|
@TsUtil.AudioType int audioType,
|
||||||
@Nullable List<DvbSubtitleInfo> dvbSubtitleInfos,
|
@Nullable List<DvbSubtitleInfo> dvbSubtitleInfos,
|
||||||
byte[] descriptorBytes) {
|
byte[] descriptorBytes) {
|
||||||
this.streamType = streamType;
|
this.streamType = streamType;
|
||||||
|
@ -16,14 +16,60 @@
|
|||||||
|
|
||||||
package androidx.media3.extractor.ts;
|
package androidx.media3.extractor.ts;
|
||||||
|
|
||||||
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||||
|
|
||||||
|
import androidx.annotation.IntDef;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.util.ParsableByteArray;
|
import androidx.media3.common.util.ParsableByteArray;
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/** Utilities method for extracting MPEG-TS streams. */
|
/** Utilities method for extracting MPEG-TS streams. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public final class TsUtil {
|
public final class TsUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The audio type of the stream, as defined by ISO/IEC 13818-1, section 2.6.18.
|
||||||
|
*
|
||||||
|
* <p>One of {@link #AUDIO_TYPE_UNDEFINED}, {@link #AUDIO_TYPE_CLEAN_EFFECTS}, {@link
|
||||||
|
* #AUDIO_TYPE_HEARING_IMPAIRED} or {@link #AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY}.
|
||||||
|
*/
|
||||||
|
@Documented
|
||||||
|
@Retention(SOURCE)
|
||||||
|
@Target(TYPE_USE)
|
||||||
|
@IntDef({
|
||||||
|
AUDIO_TYPE_UNDEFINED,
|
||||||
|
AUDIO_TYPE_CLEAN_EFFECTS,
|
||||||
|
AUDIO_TYPE_HEARING_IMPAIRED,
|
||||||
|
AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY
|
||||||
|
})
|
||||||
|
public @interface AudioType {}
|
||||||
|
|
||||||
|
public static final int AUDIO_TYPE_UNDEFINED = 0;
|
||||||
|
|
||||||
|
/** Indicates the track has no language. */
|
||||||
|
public static final int AUDIO_TYPE_CLEAN_EFFECTS = 1;
|
||||||
|
|
||||||
|
/** Indicates the track is prepared for the hearing impaired. */
|
||||||
|
public static final int AUDIO_TYPE_HEARING_IMPAIRED = 2;
|
||||||
|
|
||||||
|
/** Indicates the track is prepared for the visually impaired viewer. */
|
||||||
|
public static final int AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY = 3;
|
||||||
|
|
||||||
|
public static @C.RoleFlags int parseRoleFlagsFromAudioType(@AudioType int audioType) {
|
||||||
|
switch (audioType) {
|
||||||
|
case AUDIO_TYPE_HEARING_IMPAIRED:
|
||||||
|
return C.ROLE_FLAG_ENHANCED_DIALOG_INTELLIGIBILITY;
|
||||||
|
case AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY:
|
||||||
|
return C.ROLE_FLAG_DESCRIBES_VIDEO;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a TS packet starts at {@code searchPosition} according to the MPEG-TS
|
* Returns whether a TS packet starts at {@code searchPosition} according to the MPEG-TS
|
||||||
* synchronization recommendations.
|
* synchronization recommendations.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user