Java源码示例:com.google.android.exoplayer2.extractor.ts.TsPayloadReader.DvbSubtitleInfo
示例1
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
output.format(
Format.createImageSampleFormat(
idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS,
null,
Format.NO_VALUE,
0,
Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language,
null));
outputs[i] = output;
}
}
示例2
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
output.format(
Format.createImageSampleFormat(
idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS,
null,
Format.NO_VALUE,
0,
Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language,
null));
outputs[i] = output;
}
}
示例3
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
output.format(
Format.createImageSampleFormat(
idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS,
null,
Format.NO_VALUE,
0,
Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language,
null));
outputs[i] = output;
}
}
示例4
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
output.format(
Format.createImageSampleFormat(
idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS,
null,
Format.NO_VALUE,
0,
Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language,
null));
outputs[i] = output;
}
}
示例5
@Override
public void createTracks(ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) {
for (int i = 0; i < outputs.length; i++) {
DvbSubtitleInfo subtitleInfo = subtitleInfos.get(i);
idGenerator.generateNewId();
TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT);
output.format(
Format.createImageSampleFormat(
idGenerator.getFormatId(),
MimeTypes.APPLICATION_DVBSUBS,
null,
Format.NO_VALUE,
0,
Collections.singletonList(subtitleInfo.initializationData),
subtitleInfo.language,
null));
outputs[i] = output;
}
}
示例6
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == AC4_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC4;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DVB_EXT) {
// Extension descriptor in DVB (ETSI EN 300 468).
int descriptorTagExt = data.readUnsignedByte();
if (descriptorTagExt == TS_PMT_DESC_DVB_EXT_AC4) {
// AC-4_descriptor in DVB (ETSI EN 300 468).
streamType = TS_STREAM_TYPE_AC4;
}
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例7
/**
* @param subtitleInfos Information about the DVB subtitles associated to the stream.
*/
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
this.subtitleInfos = subtitleInfos;
outputs = new TrackOutput[subtitleInfos.size()];
}
示例8
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例9
/**
* @param subtitleInfos Information about the DVB subtitles associated to the stream.
*/
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
this.subtitleInfos = subtitleInfos;
outputs = new TrackOutput[subtitleInfos.size()];
}
示例10
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例11
/**
* @param subtitleInfos Information about the DVB subtitles associated to the stream.
*/
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
this.subtitleInfos = subtitleInfos;
outputs = new TrackOutput[subtitleInfos.size()];
}
示例12
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == AC4_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC4;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DVB_EXT) {
// Extension descriptor in DVB (ETSI EN 300 468).
int descriptorTagExt = data.readUnsignedByte();
if (descriptorTagExt == TS_PMT_DESC_DVB_EXT_AC4) {
// AC-4_descriptor in DVB (ETSI EN 300 468).
streamType = TS_STREAM_TYPE_AC4;
}
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例13
/**
* @param subtitleInfos Information about the DVB subtitles associated to the stream.
*/
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
this.subtitleInfos = subtitleInfos;
outputs = new TrackOutput[subtitleInfos.size()];
}
示例14
/**
* Returns the stream info read from the available descriptors. Sets {@code data}'s position to
* the end of the descriptors.
*
* @param data A buffer with its position set to the start of the first descriptor.
* @param length The length of descriptors to read from the current position in {@code data}.
* @return The stream info read from the available descriptors.
*/
private EsInfo readEsInfo(ParsableByteArray data, int length) {
int descriptorsStartPosition = data.getPosition();
int descriptorsEndPosition = descriptorsStartPosition + length;
int streamType = -1;
String language = null;
List<DvbSubtitleInfo> dvbSubtitleInfos = null;
while (data.getPosition() < descriptorsEndPosition) {
int descriptorTag = data.readUnsignedByte();
int descriptorLength = data.readUnsignedByte();
int positionOfNextDescriptor = data.getPosition() + descriptorLength;
if (descriptorTag == TS_PMT_DESC_REGISTRATION) { // registration_descriptor
long formatIdentifier = data.readUnsignedInt();
if (formatIdentifier == AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC3;
} else if (formatIdentifier == E_AC3_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_E_AC3;
} else if (formatIdentifier == AC4_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_AC4;
} else if (formatIdentifier == HEVC_FORMAT_IDENTIFIER) {
streamType = TS_STREAM_TYPE_H265;
}
} else if (descriptorTag == TS_PMT_DESC_AC3) { // AC-3_descriptor in DVB (ETSI EN 300 468)
streamType = TS_STREAM_TYPE_AC3;
} else if (descriptorTag == TS_PMT_DESC_EAC3) { // enhanced_AC-3_descriptor
streamType = TS_STREAM_TYPE_E_AC3;
} else if (descriptorTag == TS_PMT_DESC_DVB_EXT) {
// Extension descriptor in DVB (ETSI EN 300 468).
int descriptorTagExt = data.readUnsignedByte();
if (descriptorTagExt == TS_PMT_DESC_DVB_EXT_AC4) {
// AC-4_descriptor in DVB (ETSI EN 300 468).
streamType = TS_STREAM_TYPE_AC4;
}
} else if (descriptorTag == TS_PMT_DESC_DTS) { // DTS_descriptor
streamType = TS_STREAM_TYPE_DTS;
} else if (descriptorTag == TS_PMT_DESC_ISO639_LANG) {
language = data.readString(3).trim();
// Audio type is ignored.
} else if (descriptorTag == TS_PMT_DESC_DVBSUBS) {
streamType = TS_STREAM_TYPE_DVBSUBS;
dvbSubtitleInfos = new ArrayList<>();
while (data.getPosition() < positionOfNextDescriptor) {
String dvbLanguage = data.readString(3).trim();
int dvbSubtitlingType = data.readUnsignedByte();
byte[] initializationData = new byte[4];
data.readBytes(initializationData, 0, 4);
dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType,
initializationData));
}
}
// Skip unused bytes of current descriptor.
data.skipBytes(positionOfNextDescriptor - data.getPosition());
}
data.setPosition(descriptorsEndPosition);
return new EsInfo(streamType, language, dvbSubtitleInfos,
Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
示例15
/**
* @param subtitleInfos Information about the DVB subtitles associated to the stream.
*/
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
this.subtitleInfos = subtitleInfos;
outputs = new TrackOutput[subtitleInfos.size()];
}