Merge "Fix for MediaPlayerStreamingStressTest/HLS" into oc-dev

am: a72902a079

Change-Id: I6825cfec699dbe1135ee12df0ce81052d7e57304
This commit is contained in:
Hassan Shojania
2017-04-21 21:42:07 +00:00
committed by android-build-merger
2 changed files with 24 additions and 18 deletions

View File

@@ -789,11 +789,12 @@ public class CodecTest {
}; };
public static boolean playMediaSamples(String filePath) throws Exception { 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 // 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 duration = 0;
int curPosition = 0; int curPosition = 0;
int nextPosition = 0; int nextPosition = 0;
@@ -808,27 +809,32 @@ public class CodecTest {
mFailedToCompleteWithNoError = true; mFailedToCompleteWithNoError = true;
String testResult; String testResult;
final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
final MediaExtractor extractor = new MediaExtractor();
boolean hasSupportedVideo = false; boolean hasSupportedVideo = false;
try { if (!streamingTest) {
extractor.setDataSource(filePath); final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
final MediaExtractor extractor = new MediaExtractor();
for (int index = 0; index < extractor.getTrackCount(); ++index) { try {
MediaFormat format = extractor.getTrackFormat(index); extractor.setDataSource(filePath);
String mime = format.getString(MediaFormat.KEY_MIME);
if (!mime.startsWith("video/")) {
continue;
}
if (list.findDecoderForFormat(format) != null) { for (int index = 0; index < extractor.getTrackCount(); ++index) {
hasSupportedVideo = true; MediaFormat format = extractor.getTrackFormat(index);
break; String mime = format.getString(MediaFormat.KEY_MIME);
if (!mime.startsWith("video/")) {
continue;
}
if (list.findDecoderForFormat(format) != null) {
hasSupportedVideo = true;
break;
}
} }
} finally {
extractor.release();
} }
} finally { } else { // streamingTest
extractor.release(); hasSupportedVideo = true;
} }
initializeMessageLooper(); initializeMessageLooper();

View File

@@ -144,7 +144,7 @@ public class MediaPlayerStreamingStressTest extends ActivityInstrumentationTestC
//Get url //Get url
String filename = urls.get(i); String filename = urls.get(i);
onCompleteSuccess = onCompleteSuccess =
CodecTest.playMediaSamples(filename, 60000); CodecTest.playMediaSamples(filename, 60000, true /* streamingTest */);
if (!onCompleteSuccess){ if (!onCompleteSuccess){
//Don't fail the test right away, print out the failure file. //Don't fail the test right away, print out the failure file.
fileWithError += filename + '\n'; fileWithError += filename + '\n';