Merge "Fix for MediaPlayerStreamingStressTest/HLS" into oc-dev am: a72902a079
am: abf54a61bc

Change-Id: I1b5e5717811398e6f2b7b2c1edd6008cdf75754d
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
index 9e50490..48b2878 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/CodecTest.java
@@ -789,11 +789,12 @@
     };
 
     public static boolean playMediaSamples(String filePath) throws Exception {
-        return playMediaSamples(filePath, 2000);
+        return playMediaSamples(filePath, 2000, false /* streamingTest */);
     }
 
     // For each media file, forward twice and backward once, then play to the end
-    public static boolean playMediaSamples(String filePath, int buffertime) throws Exception {
+    public static boolean playMediaSamples(String filePath, int buffertime, boolean streamingTest)
+            throws Exception {
         int duration = 0;
         int curPosition = 0;
         int nextPosition = 0;
@@ -808,27 +809,32 @@
         mFailedToCompleteWithNoError = true;
         String testResult;
 
-        final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
-        final MediaExtractor extractor = new MediaExtractor();
         boolean hasSupportedVideo = false;
 
-        try {
-            extractor.setDataSource(filePath);
+        if (!streamingTest) {
+            final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
+            final MediaExtractor extractor = new MediaExtractor();
 
-            for (int index = 0; index < extractor.getTrackCount(); ++index) {
-                MediaFormat format = extractor.getTrackFormat(index);
-                String mime = format.getString(MediaFormat.KEY_MIME);
-                if (!mime.startsWith("video/")) {
-                    continue;
-                }
+            try {
+                extractor.setDataSource(filePath);
 
-                if (list.findDecoderForFormat(format) != null) {
-                    hasSupportedVideo = true;
-                    break;
+                for (int index = 0; index < extractor.getTrackCount(); ++index) {
+                    MediaFormat format = extractor.getTrackFormat(index);
+                    String mime = format.getString(MediaFormat.KEY_MIME);
+                    if (!mime.startsWith("video/")) {
+                        continue;
+                    }
+
+                    if (list.findDecoderForFormat(format) != null) {
+                        hasSupportedVideo = true;
+                        break;
+                    }
                 }
+            } finally {
+                extractor.release();
             }
-        } finally {
-            extractor.release();
+        } else { // streamingTest
+            hasSupportedVideo = true;
         }
 
         initializeMessageLooper();
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStreamingStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStreamingStressTest.java
index d92c857..6a820ec 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStreamingStressTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/MediaPlayerStreamingStressTest.java
@@ -144,7 +144,7 @@
                 //Get url
                 String filename = urls.get(i);
                 onCompleteSuccess =
-                    CodecTest.playMediaSamples(filename, 60000);
+                    CodecTest.playMediaSamples(filename, 60000, true /* streamingTest */);
                 if (!onCompleteSuccess){
                     //Don't fail the test right away, print out the failure file.
                     fileWithError += filename + '\n';