# TrackEncryptionBox

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/TrackEncryptionBox.java+class:androidx.media3.extractor.mp4.TrackEncryptionBox)

*** ** * ** ***


```
@UnstableApi
public final class TrackEncryptionBox
```

<br />

*** ** * ** ***

Encapsulates information parsed from a track encryption (tenc) box or sample group description (sgpd) box in an MP4 stream.

## Summary

| ### Public fields |
|---|---|
| `final https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#cryptoData()` A `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData` instance containing the encryption information from this `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox`. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#defaultInitializationVector()` If `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#perSampleIvSize()` is 0, holds the default initialization vector as defined in the track encryption box or sample group description box. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#isEncrypted()` Indicates the encryption state of the samples in the sample group. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#perSampleIvSize()` The initialization vector size in bytes for the samples in the corresponding sample group. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#schemeType()` The protection scheme type, as defined by the 'schm' box, or null if unknown. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#TrackEncryptionBox(boolean,java.lang.String,int,byte[],int,int,byte[])( boolean isEncrypted, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html schemeType, int perSampleIvSize, byte[] keyId, int defaultEncryptedBlocks, int defaultClearBlocks, @https://developer.android.com/reference/androidx/annotation/Nullable byte[] defaultInitializationVector )` |

## Public fields

### cryptoData

```
public final TrackOutput.CryptoData cryptoData
```

A `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData` instance containing the encryption information from this `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox`.

### defaultInitializationVector

```
public final @Nullable byte[] defaultInitializationVector
```

If `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#perSampleIvSize()` is 0, holds the default initialization vector as defined in the track encryption box or sample group description box. Null otherwise.

### isEncrypted

```
public final boolean isEncrypted
```

Indicates the encryption state of the samples in the sample group.

### perSampleIvSize

```
public final int perSampleIvSize
```

The initialization vector size in bytes for the samples in the corresponding sample group.

### schemeType

```
public final @Nullable String schemeType
```

The protection scheme type, as defined by the 'schm' box, or null if unknown.

## Public constructors

### TrackEncryptionBox

```
public TrackEncryptionBox(
    boolean isEncrypted,
    @Nullable String schemeType,
    int perSampleIvSize,
    byte[] keyId,
    int defaultEncryptedBlocks,
    int defaultClearBlocks,
    @Nullable byte[] defaultInitializationVector
)
```

| Parameters |
|---|---|
| `boolean isEncrypted` | See `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#isEncrypted()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html schemeType` | See `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#schemeType()`. |
| `int perSampleIvSize` | See `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#perSampleIvSize()`. |
| `byte[] keyId` | See `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData#encryptionKey()`. |
| `int defaultEncryptedBlocks` | See `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData#encryptedBlocks()`. |
| `int defaultClearBlocks` | See `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData#clearBlocks()`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[] defaultInitializationVector` | See `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackEncryptionBox#defaultInitializationVector()`. |