Package com.google.android.exoplayer2.extractor.mp4

## Class PsshAtomUtil

- java.lang.Object
- - com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil

-     public final class PsshAtomUtil
      extends Object

  Utility methods for handling PSSH atoms.

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static byte[]` | `buildPsshAtom​(UUID systemId, byte[] data)` | Builds a version 0 PSSH atom for a given system id, containing the given data.
    `static byte[]` | `buildPsshAtom​(UUID systemId, UUID[] keyIds, byte[] data)` | Builds a PSSH atom for the given system id, containing the given key ids and data.
    `static boolean` | `isPsshAtom​(byte[] data)` | Returns whether the data is a valid PSSH atom.
    `static byte[]` | `parseSchemeSpecificData​(byte[] atom, UUID uuid)` | Parses the scheme specific data from a PSSH atom.
    `static UUID` | `parseUuid​(byte[] atom)` | Parses the UUID from a PSSH atom.
    `static int` | `parseVersion​(byte[] atom)` | Parses the version from a PSSH atom.

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

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

- - ### Method Detail

    - #### buildPsshAtom

          public static byte[] buildPsshAtom​(UUID systemId,
                                             @Nullable
                                             byte[] data)

      Builds a version 0 PSSH atom for a given system id, containing the given data.
      Parameters:
        `systemId` - The system id of the scheme.
        `data` - The scheme specific data.
      Returns:
        The PSSH atom.

    - #### buildPsshAtom

          public static byte[] buildPsshAtom​(UUID systemId,
                                             @Nullable
                                             UUID[] keyIds,
                                             @Nullable
                                             byte[] data)

      Builds a PSSH atom for the given system id, containing the given key ids and data.
      Parameters:
        `systemId` - The system id of the scheme.
        `keyIds` - The key ids for a version 1 PSSH atom, or null for a version 0 PSSH atom.
        `data` - The scheme specific data.
      Returns:
        The PSSH atom.

    - #### isPsshAtom

          public static boolean isPsshAtom​(byte[] data)

      Returns whether the data is a valid PSSH atom.
      Parameters:
        `data` - The data to parse.
      Returns:
        Whether the data is a valid PSSH atom.

    - #### parseUuid

          @Nullable
          public static UUID parseUuid​(byte[] atom)

      Parses the UUID from a PSSH atom. Version 0 and 1 PSSH atoms are supported.

      The UUID is only parsed if the data is a valid PSSH atom.

      Parameters:
        `atom` - The atom to parse.
      Returns:
        The parsed UUID. Null if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version.

    - #### parseVersion

          public static int parseVersion​(byte[] atom)

      Parses the version from a PSSH atom. Version 0 and 1 PSSH atoms are supported.

      The version is only parsed if the data is a valid PSSH atom.

      Parameters:
        `atom` - The atom to parse.
      Returns:
        The parsed version. -1 if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version.

    - #### parseSchemeSpecificData

          @Nullable
          public static byte[] parseSchemeSpecificData​(byte[] atom,
                                                       UUID uuid)

      Parses the scheme specific data from a PSSH atom. Version 0 and 1 PSSH atoms are supported.

      The scheme specific data is only parsed if the data is a valid PSSH atom matching the given UUID, or if the data is a valid PSSH atom of any type in the case that the passed UUID is null.

      Parameters:
        `atom` - The atom to parse.
        `uuid` - The required UUID of the PSSH atom, or null to accept any UUID.
      Returns:
        The parsed scheme specific data. Null if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version, or if the PSSH atom does not match the passed UUID.