Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 486a2021 authored by Hyungtae Kim's avatar Hyungtae Kim Committed by Android (Google) Code Review
Browse files

Merge "MediaFrameworkTest: compare media type only for supported media check" into oc-dev

parents f18e0500 ed0524db
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.mediaframeworktest.MediaNames;
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;
@@ -42,7 +43,9 @@ import java.io.InputStream;
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

@@ -69,6 +72,7 @@ public class CodecTest {
    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";
@@ -792,7 +796,7 @@ public class CodecTest {
        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;
@@ -812,7 +816,14 @@ public class CodecTest {
        boolean hasSupportedVideo = false;

        if (!streamingTest) {
            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 {
@@ -820,12 +831,12 @@ public class CodecTest {

                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;
                    }