# CryptoInfo

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

*** ** * ** ***


```
@UnstableApi
public final class CryptoInfo
```

<br />

*** ** * ** ***

Metadata describing the structure of an encrypted input sample.

This class is a compatibility wrapper for `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html`.

## Summary

| ### Public fields |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#clearBlocks()` |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#encryptedBlocks()` |
| `final https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#frameworkCryptoInfo()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#iv()` The 16 byte initialization vector. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#key()` The 16 byte key id. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/C.CryptoMode https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#mode()` The type of encryption that has been applied. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable int[]` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfClearData()` The number of leading unencrypted bytes in each sub-sample. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable int[]` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfEncryptedData()` The number of trailing encrypted bytes in each sub-sample. |
| `int` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numSubSamples()` The number of subSamples that make up the buffer's contents. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#CryptoInfo()()` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#getFrameworkCryptoInfo()()` Returns an equivalent `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` instance. |
| `void` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#increaseClearDataFirstSubSampleBy(int)(int count)` Increases the number of clear data for the first sub sample by `count`. |
| `void` | `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#set(int,int[],int[],byte[],byte[],int,int,int)( int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, byte[] key, byte[] iv, @https://developer.android.com/reference/androidx/media3/common/C.CryptoMode int mode, int encryptedBlocks, int clearBlocks )` |

## Public fields

### clearBlocks

```
public int clearBlocks
```

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.Pattern.html` |   |

### encryptedBlocks

```
public int encryptedBlocks
```

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.Pattern.html` |   |

### frameworkCryptoInfo

```
public final MediaCodec.CryptoInfo frameworkCryptoInfo
```

### iv

```
public @Nullable byte[] iv
```

The 16 byte initialization vector. If the initialization vector of the content is shorter than 16 bytes, 0 byte padding is appended to extend the vector to the required 16 byte length.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#iv` |   |

### key

```
public @Nullable byte[] key
```

The 16 byte key id.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#key` |   |

### mode

```
@C.CryptoMode
public int mode
```

The type of encryption that has been applied. Must be one of the `https://developer.android.com/reference/androidx/media3/common/C.CryptoMode` values.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#mode` |   |

### numBytesOfClearData

```
public @Nullable int[] numBytesOfClearData
```

The number of leading unencrypted bytes in each sub-sample. If null, all bytes are treated as encrypted and `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfEncryptedData()` must be specified.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#numBytesOfClearData` |   |

### numBytesOfEncryptedData

```
public @Nullable int[] numBytesOfEncryptedData
```

The number of trailing encrypted bytes in each sub-sample. If null, all bytes are treated as clear and `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfClearData()` must be specified.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#numBytesOfEncryptedData` |   |

### numSubSamples

```
public int numSubSamples
```

The number of subSamples that make up the buffer's contents.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#numSubSamples` |   |

## Public constructors

### CryptoInfo

```
public CryptoInfo()
```

## Public methods

### getFrameworkCryptoInfo

```
public MediaCodec.CryptoInfo getFrameworkCryptoInfo()
```

Returns an equivalent `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` instance.

Successive calls to this method on a single `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo` will return the same instance. Changes to the `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo` will be reflected in the returned object. The return object should not be modified directly.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` | The equivalent `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html` instance. |

### increaseClearDataFirstSubSampleBy

```
public void increaseClearDataFirstSubSampleBy(int count)
```

Increases the number of clear data for the first sub sample by `count`.

If `count` is 0, this method is a no-op. Otherwise, it adds `count` to `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfClearData()`\[0\].

If `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfClearData()` is null (which is permitted), this method will instantiate it to a new `int[1]`.

| Parameters |
|---|---|
| `int count` | The number of bytes to be added to the first subSample of `https://developer.android.com/reference/androidx/media3/decoder/CryptoInfo#numBytesOfClearData()`. |

### set

```
public void set(
    int numSubSamples,
    int[] numBytesOfClearData,
    int[] numBytesOfEncryptedData,
    byte[] key,
    byte[] iv,
    @C.CryptoMode int mode,
    int encryptedBlocks,
    int clearBlocks
)
```

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.html#set(int, int[], int[], byte[], byte[], int)` |   |