Modular DRM for MediaPlayer/SampleAES CTS Tests

Bug: 34559906
Test: CTS Tests
Change-Id: I5cbadeb1938b51ea4076e989d09b813cd91981ab
diff --git a/tests/tests/media/AndroidManifest.xml b/tests/tests/media/AndroidManifest.xml
index 5123f2c..4ade829 100644
--- a/tests/tests/media/AndroidManifest.xml
+++ b/tests/tests/media/AndroidManifest.xml
@@ -105,5 +105,10 @@
             android:value="com.android.cts.runner.CtsTestRunListener" />
     </instrumentation>
 
+    <instrumentation android:name="android.test.InstrumentationTestRunner"
+                     android:targetPackage="android.media.cts"
+                     android:label="MediaPlayer Streaming tests InstrumentationRunner">
+    </instrumentation>
+
 </manifest>
 
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index e22d8a7..6b2a0b5 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -21,9 +21,11 @@
 import android.media.MediaPlayer.TrackInfo;
 import android.media.TimedMetaData;
 import android.net.Uri;
+import android.os.Bundle;
 import android.os.Looper;
 import android.os.PowerManager;
 import android.os.SystemClock;
+import android.test.InstrumentationTestRunner;
 import android.util.Log;
 import android.webkit.cts.CtsTestServer;
 
@@ -59,8 +61,23 @@
 
     private CtsTestServer mServer;
 
+    private String mInputUrl;
+
     @Override
     protected void setUp() throws Exception {
+        // if launched with InstrumentationTestRunner to pass a command line argument
+        if (getInstrumentation() instanceof InstrumentationTestRunner) {
+            InstrumentationTestRunner testRunner =
+                    (InstrumentationTestRunner)getInstrumentation();
+
+            Bundle arguments = testRunner.getArguments();
+            mInputUrl = arguments.getString("url");
+            Log.v(TAG, "setUp: arguments: " + arguments);
+            if (mInputUrl != null) {
+                Log.v(TAG, "setUp: arguments[url] " + mInputUrl);
+            }
+        }
+
         super.setUp();
         dynamicConfig = new DynamicConfigDeviceSide(MODULE_NAME);
     }
@@ -200,6 +217,36 @@
         playLiveVideoTest(uri, headers, cookies, 60 * 1000);
     }
 
+    public void testHlsSampleAes_bbb_audio_only_overridable() throws Exception {
+        if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
+            return; // skip
+        }
+
+        String defaultUrl = "http://storage.googleapis.com/wvmedia/cenc/hls/sample_aes/" +
+                            "bbb_1080p_30fps_11min/audio_only/prog_index.m3u8";
+
+        // if url override provided
+        String testUrl = (mInputUrl != null) ? mInputUrl : defaultUrl;
+
+        // Play stream for 60 seconds
+        playLiveVideoTest(
+                testUrl,
+                60 * 1000);
+    }
+
+    public void testHlsSampleAes_bbb_unmuxed_1500k() throws Exception {
+        if (!MediaUtils.checkDecoder(MediaFormat.MIMETYPE_VIDEO_AVC)) {
+            return; // skip
+        }
+
+        // Play stream for 60 seconds
+        playLiveVideoTest(
+                "http://storage.googleapis.com/wvmedia/cenc/hls/sample_aes/" +
+                "bbb_1080p_30fps_11min/unmuxed_1500k/prog_index.m3u8",
+                60 * 1000);
+    }
+
+
     // Streaming audio from local HTTP server
     public void testPlayMp3Stream1() throws Throwable {
         localHttpAudioStreamTest("ringer.mp3", false, false);