Add basic HTTP and RTSP streaming tests to CTS.

Reviewers from Media team: Most of the work for this was done in previous CLs -
you'll probably want to look at the functions that actually do the work of
playing the video to make sure they're okay.

Change-Id: Ia8d9cbc23ddacef2ba2cf862377033ecca7e1260
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerStreamingTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerStreamingTest.java
index 7d2bc81..3388b9d 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerStreamingTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerStreamingTest.java
@@ -25,6 +25,89 @@
 public class MediaPlayerStreamingTest extends MediaPlayerTestBase {
     private CtsTestServer mServer;
 
+    // Streaming RTSP video from YouTube
+    // TODO: Enable RTSP tests once network issues are sorted out.
+    /*
+    public void testRTSP_H263_AMR_Video1() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0x271de9756065677e"
+                + "&fmt=13&user=android-device-test", 176, 144);
+    }
+    public void testRTSP_H263_AMR_Video2() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0xc80658495af60617"
+                + "&fmt=13&user=android-device-test", 176, 144);
+    }
+
+    public void testRTSP_MPEG4SP_AAC_Video1() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0x271de9756065677e"
+                + "&fmt=17&user=android-device-test", 176, 144);
+    }
+    public void testRTSP_MPEG4SP_AAC_Video2() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0xc80658495af60617"
+                + "&fmt=17&user=android-device-test", 176, 144);
+    }
+
+    public void testRTSP_H264Base_AAC_Video1() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0x271de9756065677e"
+                + "&fmt=18&user=android-device-test", 176, 144);
+    }
+    public void testRTSP_H264Base_AAC_Video2() throws Exception {
+        playVideoTest("rtsp://v2.cache7.c.youtube.com/video.3gp?cid=0xc80658495af60617"
+                + "&fmt=18&user=android-device-test", 176, 144);
+    }
+    */
+
+    // Streaming HTTP video from YouTube
+    public void testHTTP_H263_AMR_Video1() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=271de9756065677e"
+                + "&itag=13&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=372FA4C532AA49D14EAF049BCDA66460EEE161E9"
+                + ".6D8BF096B73B7A68A7032CA8685053CFB498D30A"
+                + "&key=test_key1&user=android-device-test", 176, 144);
+    }
+    public void testHTTP_H263_AMR_Video2() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=c80658495af60617"
+                + "&itag=13&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=191FCD5C4B7400065C20845D7AC2B437B1291F26"
+                + ".66F8B8D7EFF7F144141AC67E8E35E078468CE6FB"
+                + "&key=test_key1&user=android-device-test", 176, 144);
+    }
+
+    public void testHTTP_MPEG4SP_AAC_Video1() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=271de9756065677e"
+                + "&itag=17&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=3DCD3F79E045F95B6AF661765F046FB0440FF016"
+                + ".06A42661B3AF6BAF046F012549CC9BA34EBC80A9"
+                + "&key=test_key1&user=android-device-test", 176, 144);
+    }
+    public void testHTTP_MPEG4SP_AAC_Video2() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=c80658495af60617"
+                + "&itag=17&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=242B7AEF3AB38519F593203FDEF420E2A585DA6E"
+                + ".4A57C03AF6859FE4694CD69C3225E386373A98B0"
+                + "&key=test_key1&user=android-device-test", 176, 144);
+    }
+
+    public void testHTTP_H264Base_AAC_Video1() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=271de9756065677e"
+                + "&itag=18&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=1219C2B07AF0638C27916307A6093C0E43CB894E"
+                + ".126B6B916BD57157782738AA7C03E59F21DBC168"
+                + "&key=test_key1&user=android-device-test", 480, 270);
+    }
+    public void testHTTP_H264Base_AAC_Video2() throws Exception {
+        playVideoTest("http://v20.lscache8.c.youtube.com/videoplayback?id=c80658495af60617"
+                + "&itag=18&ip=0.0.0.0&ipbits=0&expire=999999999999999999"
+                + "&sparams=ip,ipbits,expire,ip,ipbits,expire,id,itag"
+                + "&signature=61674BC069F2C812A18C390DE785CECD296228C7"
+                + ".11F5FCE823FB8FA31269A06A483C2F9B2C22F357"
+                + "&key=test_key1&user=android-device-test", 480, 270);
+    }
+
     // Streaming audio from local HTTP server
     public void testPlayMp3Stream1() throws Throwable {
         localHttpAudioStreamTest("ringer.mp3", false, false);
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
index 660b539..1c3b28a 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTestBase.java
@@ -100,11 +100,20 @@
         }
     }
 
-    protected void playVideoTest(int resid, final int width, final int height) throws Exception {
+    protected void playVideoTest(String path, int width, int height) throws Exception {
+        mMediaPlayer.setDataSource(path);
+        playLoadedVideo(width, height);
+    }
+
+    protected void playVideoTest(int resid, int width, int height) throws Exception {
+        loadResource(resid);
+        playLoadedVideo(width, height);
+    }
+
+    private void playLoadedVideo(final int width, final int height) throws Exception {
         final float leftVolume = 0.5f;
         final float rightVolume = 0.5f;
 
-        loadResource(resid);
         mMediaPlayer.setDisplay(getActivity().getSurfaceHolder());
         mMediaPlayer.setScreenOnWhilePlaying(true);
         mMediaPlayer.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {