Class TsExtractor

  • All Implemented Interfaces:
    Extractor

    public final class TsExtractor
    extends Object
    implements Extractor
    Extracts data from the MPEG-2 TS container format.
    • Constructor Detail

      • TsExtractor

        public TsExtractor()
      • TsExtractor

        public TsExtractor​(@Flags
                           int defaultTsPayloadReaderFlags)
        Parameters:
        defaultTsPayloadReaderFlags - A combination of DefaultTsPayloadReaderFactory FLAG_* values that control the behavior of the payload readers.
      • TsExtractor

        public TsExtractor​(@Mode
                           int mode,
                           @Flags
                           int defaultTsPayloadReaderFlags,
                           int timestampSearchBytes)
        Parameters:
        mode - Mode for the extractor. One of MODE_MULTI_PMT, MODE_SINGLE_PMT and MODE_HLS.
        defaultTsPayloadReaderFlags - A combination of DefaultTsPayloadReaderFactory FLAG_* values that control the behavior of the payload readers.
        timestampSearchBytes - The number of bytes searched from a given position in the stream to find a PCR timestamp. If this value is too small, the duration might be unknown and seeking might not be supported for high bitrate progressive streams. Setting a large value for this field might be inefficient though because the extractor stores a buffer of timestampSearchBytes bytes when determining the duration or when performing a seek operation. The default value is DEFAULT_TIMESTAMP_SEARCH_BYTES. If the number of bytes left in the stream from the current position is less than timestampSearchBytes, the search is performed on the bytes left.
      • TsExtractor

        public TsExtractor​(@Mode
                           int mode,
                           TimestampAdjuster timestampAdjuster,
                           TsPayloadReader.Factory payloadReaderFactory,
                           int timestampSearchBytes)
        Parameters:
        mode - Mode for the extractor. One of MODE_MULTI_PMT, MODE_SINGLE_PMT and MODE_HLS.
        timestampAdjuster - A timestamp adjuster for offsetting and scaling sample timestamps.
        payloadReaderFactory - Factory for injecting a custom set of payload readers.
        timestampSearchBytes - The number of bytes searched from a given position in the stream to find a PCR timestamp. If this value is too small, the duration might be unknown and seeking might not be supported for high bitrate progressive streams. Setting a large value for this field might be inefficient though because the extractor stores a buffer of timestampSearchBytes bytes when determining the duration or when performing a seek operation. The default value is DEFAULT_TIMESTAMP_SEARCH_BYTES. If the number of bytes left in the stream from the current position is less than timestampSearchBytes, the search is performed on the bytes left.
    • Method Detail

      • sniff

        public boolean sniff​(ExtractorInput input)
                      throws IOException
        Description copied from interface: Extractor
        Returns whether this extractor can extract samples from the ExtractorInput, which must provide data from the start of the stream.

        If true is returned, the input's reading position may have been modified. Otherwise, only its peek position may have been modified.

        Specified by:
        sniff in interface Extractor
        Parameters:
        input - The ExtractorInput from which data should be peeked/read.
        Returns:
        Whether this extractor can read the provided input.
        Throws:
        IOException - If an error occurred reading from the input.
      • seek

        public void seek​(long position,
                         long timeUs)
        Description copied from interface: Extractor
        Notifies the extractor that a seek has occurred.

        Following a call to this method, the ExtractorInput passed to the next invocation of Extractor.read(ExtractorInput, PositionHolder) is required to provide data starting from position in the stream. Valid random access positions are the start of the stream and positions that can be obtained from any SeekMap passed to the ExtractorOutput.

        Specified by:
        seek in interface Extractor
        Parameters:
        position - The byte offset in the stream from which data will be provided.
        timeUs - The seek time in microseconds.
      • release

        public void release()
        Description copied from interface: Extractor
        Releases all kept resources.
        Specified by:
        release in interface Extractor