com.google.android.exoplayer2.extractor.ts.TsPayloadReader.DvbSubtitleInfo Java Examples

The following examples show how to use com.google.android.exoplayer2.extractor.ts.TsPayloadReader.DvbSubtitleInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DvbSubtitleReader.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@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;
  }
}
 
Example #2
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
  }
}
 
Example #3
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@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;
  }
}
 
Example #4
Source File: DvbSubtitleReader.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@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;
  }
}
 
Example #5
Source File: DvbSubtitleReader.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@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;
  }
}
 
Example #6
Source File: TsExtractor.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #7
Source File: DvbSubtitleReader.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/**
 * @param subtitleInfos Information about the DVB subtitles associated to the stream.
 */
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
  this.subtitleInfos = subtitleInfos;
  outputs = new TrackOutput[subtitleInfos.size()];
}
 
Example #8
Source File: TsExtractor.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #9
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param subtitleInfos Information about the DVB subtitles associated to the stream.
 */
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
  this.subtitleInfos = subtitleInfos;
  outputs = new TrackOutput[subtitleInfos.size()];
}
 
Example #10
Source File: TsExtractor.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #11
Source File: DvbSubtitleReader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param subtitleInfos Information about the DVB subtitles associated to the stream.
 */
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
  this.subtitleInfos = subtitleInfos;
  outputs = new TrackOutput[subtitleInfos.size()];
}
 
Example #12
Source File: TsExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #13
Source File: DvbSubtitleReader.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param subtitleInfos Information about the DVB subtitles associated to the stream.
 */
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
  this.subtitleInfos = subtitleInfos;
  outputs = new TrackOutput[subtitleInfos.size()];
}
 
Example #14
Source File: TsExtractor.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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));
}
 
Example #15
Source File: DvbSubtitleReader.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @param subtitleInfos Information about the DVB subtitles associated to the stream.
 */
public DvbSubtitleReader(List<DvbSubtitleInfo> subtitleInfos) {
  this.subtitleInfos = subtitleInfos;
  outputs = new TrackOutput[subtitleInfos.size()];
}