Java Code Examples for com.google.android.exoplayer2.C#CryptoMode

The following examples show how to use com.google.android.exoplayer2.C#CryptoMode . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrackEncryptionBox.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example 2
Source File: CryptoInfo.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  // Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
  // object allocation on Android N.
  frameworkCryptoInfo.numSubSamples = numSubSamples;
  frameworkCryptoInfo.numBytesOfClearData = numBytesOfClearData;
  frameworkCryptoInfo.numBytesOfEncryptedData = numBytesOfEncryptedData;
  frameworkCryptoInfo.key = key;
  frameworkCryptoInfo.iv = iv;
  frameworkCryptoInfo.mode = mode;
  if (Util.SDK_INT >= 24) {
    patternHolder.set(encryptedBlocks, clearBlocks);
  }
}
 
Example 3
Source File: TrackEncryptionBox.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example 4
Source File: TrackEncryptionBox.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example 5
Source File: TrackEncryptionBox.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example 6
Source File: CryptoInfo.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  // Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
  // object allocation on Android N.
  frameworkCryptoInfo.numSubSamples = numSubSamples;
  frameworkCryptoInfo.numBytesOfClearData = numBytesOfClearData;
  frameworkCryptoInfo.numBytesOfEncryptedData = numBytesOfEncryptedData;
  frameworkCryptoInfo.key = key;
  frameworkCryptoInfo.iv = iv;
  frameworkCryptoInfo.mode = mode;
  if (Util.SDK_INT >= 24) {
    patternHolder.set(encryptedBlocks, clearBlocks);
  }
}
 
Example 7
Source File: TrackEncryptionBox.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@C.CryptoMode
private static int schemeToCryptoMode(@Nullable String schemeType) {
  if (schemeType == null) {
    // If unknown, assume cenc.
    return C.CRYPTO_MODE_AES_CTR;
  }
  switch (schemeType) {
    case C.CENC_TYPE_cenc:
    case C.CENC_TYPE_cens:
      return C.CRYPTO_MODE_AES_CTR;
    case C.CENC_TYPE_cbc1:
    case C.CENC_TYPE_cbcs:
      return C.CRYPTO_MODE_AES_CBC;
    default:
      Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR "
          + "crypto mode.");
      return C.CRYPTO_MODE_AES_CTR;
  }
}
 
Example 8
Source File: CryptoInfo.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  // Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
  // object allocation on Android N.
  frameworkCryptoInfo.numSubSamples = numSubSamples;
  frameworkCryptoInfo.numBytesOfClearData = numBytesOfClearData;
  frameworkCryptoInfo.numBytesOfEncryptedData = numBytesOfEncryptedData;
  frameworkCryptoInfo.key = key;
  frameworkCryptoInfo.iv = iv;
  frameworkCryptoInfo.mode = mode;
  if (Util.SDK_INT >= 24) {
    patternHolder.set(encryptedBlocks, clearBlocks);
  }
}
 
Example 9
Source File: TrackOutput.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param cryptoMode See {@link #cryptoMode}.
 * @param encryptionKey See {@link #encryptionKey}.
 * @param encryptedBlocks See {@link #encryptedBlocks}.
 * @param clearBlocks See {@link #clearBlocks}.
 */
public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks,
    int clearBlocks) {
  this.cryptoMode = cryptoMode;
  this.encryptionKey = encryptionKey;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
}
 
Example 10
Source File: TrackOutput.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param cryptoMode See {@link #cryptoMode}.
 * @param encryptionKey See {@link #encryptionKey}.
 * @param encryptedBlocks See {@link #encryptedBlocks}.
 * @param clearBlocks See {@link #clearBlocks}.
 */
public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks,
    int clearBlocks) {
  this.cryptoMode = cryptoMode;
  this.encryptionKey = encryptionKey;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
}
 
Example 11
Source File: CryptoInfo.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  if (Util.SDK_INT >= 16) {
    updateFrameworkCryptoInfoV16();
  }
}
 
Example 12
Source File: TrackOutput.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param cryptoMode See {@link #cryptoMode}.
 * @param encryptionKey See {@link #encryptionKey}.
 * @param encryptedBlocks See {@link #encryptedBlocks}.
 * @param clearBlocks See {@link #clearBlocks}.
 */
public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks,
    int clearBlocks) {
  this.cryptoMode = cryptoMode;
  this.encryptionKey = encryptionKey;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
}
 
Example 13
Source File: CryptoInfo.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
  if (Util.SDK_INT >= 16) {
    updateFrameworkCryptoInfoV16();
  }
}
 
Example 14
Source File: CryptoInfo.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int)
 */
public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData,
    byte[] key, byte[] iv, @C.CryptoMode int mode) {
  this.numSubSamples = numSubSamples;
  this.numBytesOfClearData = numBytesOfClearData;
  this.numBytesOfEncryptedData = numBytesOfEncryptedData;
  this.key = key;
  this.iv = iv;
  this.mode = mode;
  if (Util.SDK_INT >= 16) {
    updateFrameworkCryptoInfoV16();
  }
}
 
Example 15
Source File: TrackOutput.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param cryptoMode See {@link #cryptoMode}.
 * @param encryptionKey See {@link #encryptionKey}.
 * @param encryptedBlocks See {@link #encryptedBlocks}.
 * @param clearBlocks See {@link #clearBlocks}.
 */
public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks,
    int clearBlocks) {
  this.cryptoMode = cryptoMode;
  this.encryptionKey = encryptionKey;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
}
 
Example 16
Source File: TrackOutput.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param cryptoMode See {@link #cryptoMode}.
 * @param encryptionKey See {@link #encryptionKey}.
 * @param encryptedBlocks See {@link #encryptedBlocks}.
 * @param clearBlocks See {@link #clearBlocks}.
 */
public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks,
    int clearBlocks) {
  this.cryptoMode = cryptoMode;
  this.encryptionKey = encryptionKey;
  this.encryptedBlocks = encryptedBlocks;
  this.clearBlocks = clearBlocks;
}