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

The following examples show how to use com.google.android.exoplayer2.extractor.ts.TsPayloadReader.EsInfo. 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: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_ADTS:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_LATM:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new LatmReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_DTS:
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    case TsExtractor.TS_STREAM_TYPE_DVBSUBS:
      return new PesReader(
          new DvbSubtitleReader(esInfo.dvbSubtitleInfos));
    default:
      return null;
  }
}
 
Example #2
Source File: TsExtractor.java    From K-Sonic with MIT License 5 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;
  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 = new String(data.data, data.getPosition(), 3).trim();
      // Audio type is ignored.
    }
    // Skip unused bytes of current descriptor.
    data.skipBytes(positionOfNextDescriptor - data.getPosition());
  }
  data.setPosition(descriptorsEndPosition);
  return new EsInfo(streamType, language,
      Arrays.copyOfRange(data.data, descriptorsStartPosition, descriptorsEndPosition));
}
 
Example #3
Source File: DefaultTsPayloadReaderFactory.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_DTS:
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader());
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    default:
      return null;
  }
}
 
Example #4
Source File: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_ADTS:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_LATM:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new LatmReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_DTS:
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    case TsExtractor.TS_STREAM_TYPE_DVBSUBS:
      return new PesReader(
          new DvbSubtitleReader(esInfo.dvbSubtitleInfos));
    default:
      return null;
  }
}
 
Example #5
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 #6
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 #7
Source File: DefaultTsPayloadReaderFactory.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_ADTS:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_LATM:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new LatmReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC4:
      return new PesReader(new Ac4Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      if (!isSet(FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS)) {
        return null;
      }
      // Fall through.
    case TsExtractor.TS_STREAM_TYPE_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    case TsExtractor.TS_STREAM_TYPE_DVBSUBS:
      return new PesReader(
          new DvbSubtitleReader(esInfo.dvbSubtitleInfos));
    default:
      return null;
  }
}
 
Example #8
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 #9
Source File: DefaultTsPayloadReaderFactory.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_ADTS:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_LATM:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new LatmReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC4:
      return new PesReader(new Ac4Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      if (!isSet(FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS)) {
        return null;
      }
      // Fall through.
    case TsExtractor.TS_STREAM_TYPE_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    case TsExtractor.TS_STREAM_TYPE_DVBSUBS:
      return new PesReader(
          new DvbSubtitleReader(esInfo.dvbSubtitleInfos));
    default:
      return null;
  }
}
 
Example #10
Source File: DefaultTsPayloadReaderFactory.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo) {
  switch (streamType) {
    case TsExtractor.TS_STREAM_TYPE_MPA:
    case TsExtractor.TS_STREAM_TYPE_MPA_LSF:
      return new PesReader(new MpegAudioReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_ADTS:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new AdtsReader(false, esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AAC_LATM:
      return isSet(FLAG_IGNORE_AAC_STREAM)
          ? null : new PesReader(new LatmReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC3:
    case TsExtractor.TS_STREAM_TYPE_E_AC3:
      return new PesReader(new Ac3Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_AC4:
      return new PesReader(new Ac4Reader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_HDMV_DTS:
      if (!isSet(FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS)) {
        return null;
      }
      // Fall through.
    case TsExtractor.TS_STREAM_TYPE_DTS:
      return new PesReader(new DtsReader(esInfo.language));
    case TsExtractor.TS_STREAM_TYPE_H262:
      return new PesReader(new H262Reader(buildUserDataReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_H264:
      return isSet(FLAG_IGNORE_H264_STREAM) ? null
          : new PesReader(new H264Reader(buildSeiReader(esInfo),
              isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS)));
    case TsExtractor.TS_STREAM_TYPE_H265:
      return new PesReader(new H265Reader(buildSeiReader(esInfo)));
    case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO:
      return isSet(FLAG_IGNORE_SPLICE_INFO_STREAM)
          ? null : new SectionReader(new SpliceInfoSectionReader());
    case TsExtractor.TS_STREAM_TYPE_ID3:
      return new PesReader(new Id3Reader());
    case TsExtractor.TS_STREAM_TYPE_DVBSUBS:
      return new PesReader(
          new DvbSubtitleReader(esInfo.dvbSubtitleInfos));
    default:
      return null;
  }
}
 
Example #11
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 #12
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 #13
Source File: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link UserDataReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link UserDataReader} for the declared formats, or {@link #closedCaptionFormats} if the
 * descriptor is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link UserDataReader} for closed caption tracks.
 */
private UserDataReader buildUserDataReader(EsInfo esInfo) {
  return new UserDataReader(getClosedCaptionFormats(esInfo));
}
 
Example #14
Source File: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link SeiReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link SeiReader} for the declared formats, or {@link #closedCaptionFormats} if the descriptor
 * is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link SeiReader} for closed caption tracks.
 */
private SeiReader buildSeiReader(EsInfo esInfo) {
  return new SeiReader(getClosedCaptionFormats(esInfo));
}
 
Example #15
Source File: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link UserDataReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link UserDataReader} for the declared formats, or {@link #closedCaptionFormats} if the
 * descriptor is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link UserDataReader} for closed caption tracks.
 */
private UserDataReader buildUserDataReader(EsInfo esInfo) {
  return new UserDataReader(getClosedCaptionFormats(esInfo));
}
 
Example #16
Source File: DefaultTsPayloadReaderFactory.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link SeiReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link SeiReader} for the declared formats, or {@link #closedCaptionFormats} if the descriptor
 * is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link SeiReader} for closed caption tracks.
 */
private SeiReader buildSeiReader(EsInfo esInfo) {
  return new SeiReader(getClosedCaptionFormats(esInfo));
}
 
Example #17
Source File: DefaultTsPayloadReaderFactory.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link SeiReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link SeiReader} for the declared formats, or {@link #closedCaptionFormats} if the descriptor
 * is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link SeiReader} for closed caption tracks.
 */
private SeiReader buildSeiReader(EsInfo esInfo) {
  return new SeiReader(getClosedCaptionFormats(esInfo));
}
 
Example #18
Source File: DefaultTsPayloadReaderFactory.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link UserDataReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link UserDataReader} for the declared formats, or {@link #closedCaptionFormats} if the
 * descriptor is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link UserDataReader} for closed caption tracks.
 */
private UserDataReader buildUserDataReader(EsInfo esInfo) {
  return new UserDataReader(getClosedCaptionFormats(esInfo));
}
 
Example #19
Source File: DefaultTsPayloadReaderFactory.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link UserDataReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link UserDataReader} for the declared formats, or {@link #closedCaptionFormats} if the
 * descriptor is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link UserDataReader} for closed caption tracks.
 */
private UserDataReader buildUserDataReader(EsInfo esInfo) {
  return new UserDataReader(getClosedCaptionFormats(esInfo));
}
 
Example #20
Source File: DefaultTsPayloadReaderFactory.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link SeiReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link SeiReader} for the declared formats, or {@link #closedCaptionFormats} if the descriptor
 * is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link SeiReader} for closed caption tracks.
 */
private SeiReader buildSeiReader(EsInfo esInfo) {
  return new SeiReader(getClosedCaptionFormats(esInfo));
}
 
Example #21
Source File: DefaultTsPayloadReaderFactory.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link UserDataReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link UserDataReader} for the declared formats, or {@link #closedCaptionFormats} if the
 * descriptor is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link UserDataReader} for closed caption tracks.
 */
private UserDataReader buildUserDataReader(EsInfo esInfo) {
  return new UserDataReader(getClosedCaptionFormats(esInfo));
}
 
Example #22
Source File: DefaultTsPayloadReaderFactory.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * If {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, returns a {@link SeiReader} for
 * {@link #closedCaptionFormats}. If unset, parses the PMT descriptor information and returns a
 * {@link SeiReader} for the declared formats, or {@link #closedCaptionFormats} if the descriptor
 * is not present.
 *
 * @param esInfo The {@link EsInfo} passed to {@link #createPayloadReader(int, EsInfo)}.
 * @return A {@link SeiReader} for closed caption tracks.
 */
private SeiReader buildSeiReader(EsInfo esInfo) {
  return new SeiReader(getClosedCaptionFormats(esInfo));
}