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

## Class TrackEncryptionBox

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

-     public final class TrackEncryptionBox
      extends Object

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

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `TrackOutput.CryptoData` | `cryptoData` | A `TrackOutput.CryptoData` instance containing the encryption information from this `TrackEncryptionBox`.
    `byte[]` | `defaultInitializationVector` | If `perSampleIvSize` is 0, holds the default initialization vector as defined in the track encryption box or sample group description box.
    `boolean` | `isEncrypted` | Indicates the encryption state of the samples in the sample group.
    `int` | `perSampleIvSize` | The initialization vector size in bytes for the samples in the corresponding sample group.
    `String` | `schemeType` | The protection scheme type, as defined by the 'schm' box, or null if unknown.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TrackEncryptionBox​(boolean isEncrypted, String schemeType, int perSampleIvSize, byte[] keyId, int defaultEncryptedBlocks, int defaultClearBlocks, byte[] defaultInitializationVector)` |

  - ### Method Summary

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

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

- - ### Field Detail

    - #### isEncrypted

          public final boolean isEncrypted

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

    - #### schemeType

          @Nullable
          public final String schemeType

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

    - #### cryptoData

          public final TrackOutput.CryptoData cryptoData

      A `TrackOutput.CryptoData` instance containing the encryption information from this `TrackEncryptionBox`.

    - #### perSampleIvSize

          public final int perSampleIvSize

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

    - #### defaultInitializationVector

          @Nullable
          public final byte[] defaultInitializationVector

      If `perSampleIvSize` is 0, holds the default initialization vector as defined in the track encryption box or sample group description box. Null otherwise.

  - ### Constructor Detail

    - #### TrackEncryptionBox

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

      Parameters:
        `isEncrypted` - See `isEncrypted`.
        `schemeType` - See `schemeType`.
        `perSampleIvSize` - See `perSampleIvSize`.
        `keyId` - See `TrackOutput.CryptoData.encryptionKey`.
        `defaultEncryptedBlocks` - See `TrackOutput.CryptoData.encryptedBlocks`.
        `defaultClearBlocks` - See `TrackOutput.CryptoData.clearBlocks`.
        `defaultInitializationVector` - See `defaultInitializationVector`.