Package com.google.android.exoplayer2.extractor.ts

## Class TsUtil

- java.lang.Object
- - com.google.android.exoplayer2.extractor.ts.TsUtil

-     public final class TsUtil
      extends Object

  Utilities method for extracting MPEG-TS streams.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static int` | `findSyncBytePosition​(byte[] data, int startPosition, int limitPosition)` | Returns the position of the first TS_SYNC_BYTE within the range [startPosition, limitPosition) from the provided data array, or returns limitPosition if sync byte could not be found.
    `static long` | `readPcrFromPacket​(ParsableByteArray packetBuffer, int startOfPacket, int pcrPid)` | Returns the PCR value read from a given TS packet.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### findSyncBytePosition

          public static int findSyncBytePosition​(byte[] data,
                                                 int startPosition,
                                                 int limitPosition)

      Returns the position of the first TS_SYNC_BYTE within the range [startPosition, limitPosition) from the provided data array, or returns limitPosition if sync byte could not be found.

    - #### readPcrFromPacket

          public static long readPcrFromPacket​(ParsableByteArray packetBuffer,
                                               int startOfPacket,
                                               int pcrPid)

      Returns the PCR value read from a given TS packet.
      Parameters:
        `packetBuffer` - The buffer that holds the packet.
        `startOfPacket` - The starting position of the packet in the buffer.
        `pcrPid` - The PID for valid packets that contain PCR values.
      Returns:
        The PCR value read from the packet, if its PID is equal to `pcrPid` and it contains a valid PCR value. Returns `C.TIME_UNSET` otherwise.