Home | History | Annotate | Download | only in bitstreams
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.media.cts.bitstreams;
     18 
     19 /**
     20  * This class provides constants and utilities shared between the host-side and device-side test
     21  * components.
     22  */
     23 public class MediaBitstreams {
     24 
     25     /* options */
     26     public static final String OPT_HOST_BITSTREAMS_PATH = "host-bitstreams-path";
     27     public static final String OPT_DEVICE_BITSTREAMS_PATH = "device-bitstreams-path";
     28     public static final String OPT_DOWNLOAD_BITSTREAMS = "download-bitstreams";
     29     public static final String OPT_DEBUG_TARGET_DEVICE = "debug-target-device";
     30     public static final String OPT_BITSTREAMS_TO_TEST_TXT = "bitstreams-to-test-txt";
     31     public static final String OPT_UTILIZATION_RATE = "utilization-rate";
     32     public static final String OPT_NUM_BATCHES = "num-batches";
     33     public static final String OPT_LAST_CRASH = "last-crash";
     34     public static final String OPT_BITSTREAMS_PREFIX = "prefix";
     35 
     36     /* defaults */
     37     public static final String DEFAULT_HOST_BITSTREAMS_PATH = "TestVectorsIttiam";
     38     public static final String DEFAULT_DEVICE_BITSTEAMS_PATH = "/data/local/tmp/TestVectorsIttiam";
     39 
     40     /* metric keys */
     41     public static final String KEY_BITSTREAMS_FORMATS_XML = "bitstreams_formats_xml";
     42     public static final String KEY_SUPPORTED_BITSTREAMS_TXT = "supported_bitstreams_txt";
     43     public static final String KEY_BITSTREAMS_VALIDATION_TXT = "bitstreams_validation_txt";
     44     public static final String KEY_APP_CACHE_DIR = "app_cache_dir";
     45     public static final String KEY_ERR_MSG = "err_msg";
     46     public static final String KEY_PATH = "path";
     47     public static final String KEY_CODEC_NAME = "codec_name";
     48     public static final String KEY_STATUS = "status";
     49 
     50     /* constants */
     51     public static final String K_MODULE = "CtsMediaBitstreamsTestCases";
     52     public static final String K_BITSTREAMS_LIST_TXT = "bitstreamsFile.txt";
     53     public static final String K_TEST_GET_SUPPORTED_BITSTREAMS = "testGetSupportedBitstreams";
     54     public static final String K_NATIVE_CRASH = "native crash";
     55     public static final String K_UNSUPPORTED = "unsupported";
     56     public static final String K_UNAVAILABLE = "unavailable";
     57 
     58     public static final String DYNAMIC_CONFIG_XML = "DynamicConfig.xml";
     59     public static final String DYNAMIC_CONFIG = "dynamicConfig";
     60     public static final String DYNAMIC_CONFIG_ENTRY = "entry";
     61     public static final String DYNAMIC_CONFIG_KEY = "key";
     62     public static final String DYNAMIC_CONFIG_VALUE = "value";
     63     public static final String DYNAMIC_CONFIG_PACKAGE = "package";
     64 
     65     /* utilities */
     66     /**
     67      * @param bitstreamPath path of individual bitstream relative to bitstreams root,
     68      * e.g. {@code h264/../../../../*.mp4}
     69      * @return checksum file path for {@code bitstreamPath}, e.g. {@code h264/../../../../*_md5}.
     70      */
     71     public static String getMd5Path(String bitstreamPath) {
     72         String base = bitstreamPath.replaceAll(".mp4$|.webm$", "");
     73         String codec = bitstreamPath.split("/", 2)[0];
     74         String md5Path = String.format("%s_%s_md5", base, codec);
     75         return md5Path;
     76     }
     77 
     78     /**
     79      * @param path relative bitstream path, e.g. {@code h264/../../../../*.mp4}
     80      * @param name codec name, e.g. {@code OMX.google.h264.decoder}
     81      * @return crash signature for a crashed device decoding session,
     82      * in the form of {@code <bitstream path>:<codec name>}
     83      */
     84     public static String generateCrashSignature(String path, String name) {
     85         return String.format("%s:%s", path, name);
     86     }
     87 
     88 }
     89