Bug 1341990 - Part 2: Make ExoPlayer (r2.4.0) build against Android SDK 23. draft
authorKilik Kuo <kikuo@mozilla.com>
Tue, 23 May 2017 15:44:41 +0800
changeset 583168 c3e0fedc3a25b813ec6ad5126e2f2b25d54e3b70
parent 583167 af12643a49c4231aca96c149bc76e2cf9827ffac
child 583169 ea5b0e54f3dbd67018570f700d49eb86daadc977
push id60314
push userbmo:kikuo@mozilla.com
push dateTue, 23 May 2017 18:56:39 +0000
bugs1341990, 1365543, 1259098
milestone55.0a1
Bug 1341990 - Part 2: Make ExoPlayer (r2.4.0) build against Android SDK 23. Right now, Fennec builds against Android SDK 23. ExoPlayer expects to build against Android SDK 24 (but targets Android platform 9 and above). We replace constant values introduced in Android SDK 24 with values manually copied from https://developer.android.com/index.html and we cull unused code from CryptoInfo.java. Together, these changes allow ExoPlayer to build against Android SDK 23. Bug 1365543 tracks reverting these changes once Bug 1259098 lands and Fennec builds against Android SDK 24. MozReview-Commit-ID: 7wz5qIROCN
mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/C.java
mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/Format.java
mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/decoder/CryptoInfo.java
--- a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/C.java
+++ b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/C.java
@@ -107,17 +107,17 @@ public final class C {
    * @see MediaCodec#CRYPTO_MODE_AES_CTR
    */
   @SuppressWarnings("InlinedApi")
   public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
   /**
    * @see MediaCodec#CRYPTO_MODE_AES_CBC
    */
   @SuppressWarnings("InlinedApi")
-  public static final int CRYPTO_MODE_AES_CBC = MediaCodec.CRYPTO_MODE_AES_CBC;
+  public static final int CRYPTO_MODE_AES_CBC = 0x2;
 
   /**
    * Represents an unset {@link android.media.AudioTrack} session identifier. Equal to
    * {@link AudioManager#AUDIO_SESSION_ID_GENERATE}.
    */
   @SuppressWarnings("InlinedApi")
   public static final int AUDIO_SESSION_ID_UNSET = AudioManager.AUDIO_SESSION_ID_GENERATE;
 
@@ -560,66 +560,66 @@ public final class C {
    */
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({Format.NO_VALUE, COLOR_SPACE_BT709, COLOR_SPACE_BT601, COLOR_SPACE_BT2020})
   public @interface ColorSpace {}
   /**
    * @see MediaFormat#COLOR_STANDARD_BT709
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_SPACE_BT709 = MediaFormat.COLOR_STANDARD_BT709;
+  public static final int COLOR_SPACE_BT709 = 0x01;
   /**
    * @see MediaFormat#COLOR_STANDARD_BT601_PAL
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_SPACE_BT601 = MediaFormat.COLOR_STANDARD_BT601_PAL;
+  public static final int COLOR_SPACE_BT601 = 0x02;
   /**
    * @see MediaFormat#COLOR_STANDARD_BT2020
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_SPACE_BT2020 = MediaFormat.COLOR_STANDARD_BT2020;
+  public static final int COLOR_SPACE_BT2020 = 0x06;
 
   /**
    * Video color transfer characteristics.
    */
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({Format.NO_VALUE, COLOR_TRANSFER_SDR, COLOR_TRANSFER_ST2084, COLOR_TRANSFER_HLG})
   public @interface ColorTransfer {}
   /**
    * @see MediaFormat#COLOR_TRANSFER_SDR_VIDEO
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_TRANSFER_SDR = MediaFormat.COLOR_TRANSFER_SDR_VIDEO;
+  public static final int COLOR_TRANSFER_SDR = 0x03;
   /**
    * @see MediaFormat#COLOR_TRANSFER_ST2084
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_TRANSFER_ST2084 = MediaFormat.COLOR_TRANSFER_ST2084;
+  public static final int COLOR_TRANSFER_ST2084 = 0x06;
   /**
    * @see MediaFormat#COLOR_TRANSFER_HLG
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_TRANSFER_HLG = MediaFormat.COLOR_TRANSFER_HLG;
+  public static final int COLOR_TRANSFER_HLG = 0x07;
 
   /**
    * Video color range.
    */
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({Format.NO_VALUE, COLOR_RANGE_LIMITED, COLOR_RANGE_FULL})
   public @interface ColorRange {}
   /**
    * @see MediaFormat#COLOR_RANGE_LIMITED
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_RANGE_LIMITED = MediaFormat.COLOR_RANGE_LIMITED;
+  public static final int COLOR_RANGE_LIMITED = 0x02;
   /**
    * @see MediaFormat#COLOR_RANGE_FULL
    */
   @SuppressWarnings("InlinedApi")
-  public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL;
+  public static final int COLOR_RANGE_FULL = 0x01;
 
   /**
    * Priority for media playback.
    *
    * <p>Larger values indicate higher priorities.
    */
   public static final int PRIORITY_PLAYBACK = 0;
 
--- a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/Format.java
+++ b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/Format.java
@@ -591,20 +591,20 @@ public final class Format implements Par
     return true;
   }
 
   @TargetApi(24)
   private static void maybeSetColorInfoV24(MediaFormat format, ColorInfo colorInfo) {
     if (colorInfo == null) {
       return;
     }
-    maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_TRANSFER, colorInfo.colorTransfer);
-    maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_STANDARD, colorInfo.colorSpace);
-    maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_RANGE, colorInfo.colorRange);
-    maybeSetByteBufferV16(format, MediaFormat.KEY_HDR_STATIC_INFO, colorInfo.hdrStaticInfo);
+    maybeSetIntegerV16(format, "color-transfer", colorInfo.colorTransfer);
+    maybeSetIntegerV16(format, "color-standard", colorInfo.colorSpace);
+    maybeSetIntegerV16(format, "color-range", colorInfo.colorRange);
+    maybeSetByteBufferV16(format, "hdr-static-info", colorInfo.hdrStaticInfo);
   }
 
   @TargetApi(16)
   private static void maybeSetStringV16(MediaFormat format, String key, String value) {
     if (value != null) {
       format.setString(key, value);
     }
   }
--- a/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/decoder/CryptoInfo.java
+++ b/mobile/android/geckoview/src/thirdparty/java/com/google/android/exoplayer2/decoder/CryptoInfo.java
@@ -125,23 +125,25 @@ public final class CryptoInfo {
       patternHolder.set(patternBlocksToEncrypt, patternBlocksToSkip);
     }
   }
 
   @TargetApi(24)
   private static final class PatternHolderV24 {
 
     private final android.media.MediaCodec.CryptoInfo frameworkCryptoInfo;
-    private final android.media.MediaCodec.CryptoInfo.Pattern pattern;
+
+    // Reference to the two tickets (Bug 1259098, Bug 1365543)
+    // private final android.media.MediaCodec.CryptoInfo.Pattern pattern;
 
     private PatternHolderV24(android.media.MediaCodec.CryptoInfo frameworkCryptoInfo) {
       this.frameworkCryptoInfo = frameworkCryptoInfo;
-      pattern = new android.media.MediaCodec.CryptoInfo.Pattern(0, 0);
+      // pattern = new android.media.MediaCodec.CryptoInfo.Pattern(0, 0);
     }
 
     private void set(int blocksToEncrypt, int blocksToSkip) {
-      pattern.set(blocksToEncrypt, blocksToSkip);
-      frameworkCryptoInfo.setPattern(pattern);
+      // pattern.set(blocksToEncrypt, blocksToSkip);
+      // frameworkCryptoInfo.setPattern(pattern);
     }
 
   }
 
 }