# PsshAtomUtil

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/mp4/PsshAtomUtil.java+class:androidx.media3.extractor.mp4.PsshAtomUtil)

*** ** * ** ***

<br />

```
@UnstableApi
class PsshAtomUtil
```

<br />

*** ** * ** ***

Utility methods for handling PSSH atoms.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil.PsshAtom` A class representing the mp4 PSSH Atom as specified in ISO/IEC 23001-7. |

| ### Public functions |
|---|---|
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#buildPsshAtom(java.util.UUID,byte[])(systemId: https://developer.android.com/reference/java/util/UUID.html!, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?)` Builds a version 0 PSSH atom for a given system id, containing the given data. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#buildPsshAtom(java.util.UUID,java.util.UUID[],byte[])(systemId: https://developer.android.com/reference/java/util/UUID.html!, keyIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/util/UUID.html!>?, data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?)` Builds a PSSH atom for the given system id, containing the given key ids and data. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#isPsshAtom(byte[])(data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Returns whether the data is a valid PSSH atom. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil.PsshAtom?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#parsePsshAtom(byte[])(atom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Parses a PSSH atom. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#parseSchemeSpecificData(byte[],java.util.UUID)(atom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!, uuid: https://developer.android.com/reference/java/util/UUID.html!)` Parses the scheme specific data from a PSSH atom. |
| `java-static https://developer.android.com/reference/java/util/UUID.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#parseUuid(byte[])(atom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Parses the UUID from a PSSH atom. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil#parseVersion(byte[])(atom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!)` Parses the version from a PSSH atom. |

## Public functions

### buildPsshAtom

```
java-static fun buildPsshAtom(systemId: UUID!, data: ByteArray<Byte>?): Array<Byte>!
```

Builds a version 0 PSSH atom for a given system id, containing the given data.

| Parameters |
|---|---|
| `systemId: https://developer.android.com/reference/java/util/UUID.html!` | The system id of the scheme. |
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | The scheme specific data. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The PSSH atom. |

### buildPsshAtom

```
java-static fun buildPsshAtom(systemId: UUID!, keyIds: Array<UUID!>?, data: ByteArray<Byte>?): Array<Byte>!
```

Builds a PSSH atom for the given system id, containing the given key ids and data.

| Parameters |
|---|---|
| `systemId: https://developer.android.com/reference/java/util/UUID.html!` | The system id of the scheme. |
| `keyIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/util/UUID.html!>?` | The key ids for a version 1 PSSH atom, or null for a version 0 PSSH atom. |
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | The scheme specific data. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The PSSH atom. |

### isPsshAtom

```
java-static fun isPsshAtom(data: ByteArray<Byte>!): Boolean
```

Returns whether the data is a valid PSSH atom.

| Parameters |
|---|---|
| `data: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The data to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the data is a valid PSSH atom. |

### parsePsshAtom

```
java-static fun parsePsshAtom(atom: ByteArray<Byte>!): PsshAtomUtil.PsshAtom?
```

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

| Parameters |
|---|---|
| `atom: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The atom to parse. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/PsshAtomUtil.PsshAtom?` | The parsed PSSH atom. Null if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version. |

### parseSchemeSpecificData

```
java-static fun parseSchemeSpecificData(atom: ByteArray<Byte>!, uuid: UUID!): Array<Byte>?
```

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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The atom to parse. |
| `uuid: https://developer.android.com/reference/java/util/UUID.html!` | The required UUID of the PSSH atom, or null to accept any UUID. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>?` | 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. |

### parseUuid

```
java-static fun parseUuid(atom: ByteArray<Byte>!): UUID?
```

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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The atom to parse. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/UUID.html?` | The parsed UUID. Null if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version. |

### parseVersion

```
java-static fun parseVersion(atom: ByteArray<Byte>!): Int
```

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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!` | The atom to parse. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The parsed version. -1 if the input is not a valid PSSH atom, or if the PSSH atom has an unsupported version. |