# MediaCodec.CryptoInfo.Pattern

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Pattern

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/MediaCodec.CryptoInfo.Pattern "View this page in Java")  

```
class Pattern
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                             ||
| ↳ | [android.media.MediaCodec.CryptoInfo.Pattern](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CryptoInfo.Pattern#) |

Metadata describing an encryption pattern for the protected bytes in a subsample. An encryption pattern consists of a repeating sequence of crypto blocks comprised of a number of encrypted blocks followed by a number of unencrypted, or skipped, blocks.

## Summary

|                                                                                                                                                                                                               Public constructors                                                                                                                                                                                                                ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Pattern](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CryptoInfo.Pattern#Pattern(kotlin.Int,%20kotlin.Int))`(`blocksToEncrypt:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `blocksToSkip:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Construct a sample encryption pattern given the number of blocks to encrypt and skip in the pattern. |

|                                                                                                                                                                                                                                       Public methods                                                                                                                                                                                                                                        ||
|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)   | [getEncryptBlocks](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CryptoInfo.Pattern#getEncryptBlocks())`()` Return the number of blocks to encrypt in a sample encryption pattern.                                                                                                                                                                                                  |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)   | [getSkipBlocks](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CryptoInfo.Pattern#getSkipBlocks())`()` Return the number of blocks to skip in a sample encryption pattern.                                                                                                                                                                                                           |
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [set](https://developer.android.com/reference/kotlin/android/media/MediaCodec.CryptoInfo.Pattern#set(kotlin.Int,%20kotlin.Int))`(`blocksToEncrypt:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `blocksToSkip:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the number of blocks to encrypt and skip in a sample encryption pattern. |

## Public constructors

### Pattern

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Pattern(
    blocksToEncrypt: Int, 
    blocksToSkip: Int)
```

Construct a sample encryption pattern given the number of blocks to encrypt and skip in the pattern. If both parameters are zero, pattern encryption is inoperative.

## Public methods

### getEncryptBlocks

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getEncryptBlocks(): Int
```

Return the number of blocks to encrypt in a sample encryption pattern.  

### getSkipBlocks

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun getSkipBlocks(): Int
```

Return the number of blocks to skip in a sample encryption pattern.  

### set

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun set(
    blocksToEncrypt: Int, 
    blocksToSkip: Int
): Unit
```

Set the number of blocks to encrypt and skip in a sample encryption pattern. If both parameters are zero, pattern encryption is inoperative.