import android.content.res.AssetFileDescriptor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
+import android.media.MediaCodecInfo;
import android.media.MediaCodecList;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import java.io.OutputStream;
import java.io.Writer;
import java.io.FileOutputStream;
+import java.util.HashSet;
import java.util.Random;
+import java.util.Set;
/**
* Junit / Instrumentation test case for the media player api
public static int mMediaInfoBadInterleavingCount = 0;
public static int mMediaInfoNotSeekableCount = 0;
public static int mMediaInfoMetdataUpdateCount = 0;
+ private static Set<String> mSupportedTypes = new HashSet<>();
public static String printCpuInfo(){
String cm = "dumpsys cpuinfo";
return playMediaSamples(filePath, 2000, false /* streamingTest */);
}
- // For each media file, forward twice and backward once, then play to the end
+ // For each media file, just play to the end
public static boolean playMediaSamples(String filePath, int buffertime, boolean streamingTest)
throws Exception {
int duration = 0;
boolean hasSupportedVideo = false;
if (!streamingTest) {
- final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
+ if (mSupportedTypes.isEmpty()) {
+ final MediaCodecList list = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
+ for (MediaCodecInfo info : list.getCodecInfos()) {
+ for (String type : info.getSupportedTypes()) {
+ mSupportedTypes.add(type);
+ }
+ }
+ }
final MediaExtractor extractor = new MediaExtractor();
try {
for (int index = 0; index < extractor.getTrackCount(); ++index) {
MediaFormat format = extractor.getTrackFormat(index);
- String mime = format.getString(MediaFormat.KEY_MIME);
- if (!mime.startsWith("video/")) {
+ String type = format.getString(MediaFormat.KEY_MIME);
+ if (!type.startsWith("video/")) {
continue;
}
- if (list.findDecoderForFormat(format) != null) {
+ if (mSupportedTypes.contains(type)) {
hasSupportedVideo = true;
break;
}