Home | History | Annotate | Download | only in mediaframeworktest
      1 /*
      2  * Copyright (C) 2009 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 com.android.mediaframeworktest;
     18 
     19 import android.media.CamcorderProfile;
     20 import android.media.MediaRecorder;
     21 import android.os.Bundle;
     22 import android.test.InstrumentationTestRunner;
     23 import android.test.InstrumentationTestSuite;
     24 import com.android.mediaframeworktest.stress.MediaRecorderStressTest;
     25 
     26 import java.util.List;
     27 import junit.framework.TestSuite;
     28 
     29 public class MediaRecorderStressTestRunner extends InstrumentationTestRunner {
     30 
     31     // MediaRecorder stress test sets one of the cameras as the video source. As
     32     // a result, we should make sure that the encoding parameters as input to
     33     // the test must be supported by the corresponding camera.
     34     public static int mCameraId = 0;
     35     public static int mProfileQuality = CamcorderProfile.QUALITY_HIGH;
     36     public static CamcorderProfile profile = CamcorderProfile.get(mCameraId, mProfileQuality);
     37     public static int mIterations = 15;
     38     public static int mVideoEncoder = profile.videoCodec;
     39     public static int mAudioEncoder = profile.audioCodec;
     40     public static int mFrameRate = profile.videoFrameRate;
     41     public static int mVideoWidth = profile.videoFrameWidth;
     42     public static int mVideoHeight = profile.videoFrameHeight;
     43     public static int mBitRate = profile.videoBitRate;
     44     public static boolean mRemoveVideo = true;
     45     public static int mDuration = 60 * 1000; // 60 seconds
     46     public static int mTimeLapseDuration = 15 * 60 * 1000; // 15 minutes
     47     public static double mCaptureRate = 0.5; // 2 sec timelapse interval
     48 
     49     @Override
     50     public TestSuite getAllTests() {
     51         TestSuite suite = new InstrumentationTestSuite(this);
     52         suite.addTestSuite(MediaRecorderStressTest.class);
     53         return suite;
     54     }
     55 
     56     @Override
     57     public ClassLoader getLoader() {
     58         return MediaRecorderStressTestRunner.class.getClassLoader();
     59     }
     60 
     61     @Override
     62     public void onCreate(Bundle icicle) {
     63         super.onCreate(icicle);
     64         String iterations = (String) icicle.get("iterations");
     65         String videoEncoder = (String) icicle.get("video_encoder");
     66         String audioEncoder = (String) icicle.get("audio_encoder");
     67         String frameRate = (String) icicle.get("frame_rate");
     68         String videoWidth = (String) icicle.get("video_width");
     69         String videoHeight = (String) icicle.get("video_height");
     70         String bitRate = (String) icicle.get("bit_rate");
     71         String recordDuration = (String) icicle.get("record_duration");
     72         String removeVideos = (String) icicle.get("remove_videos");
     73 
     74         if (iterations != null ) {
     75             mIterations = Integer.parseInt(iterations);
     76         }
     77         if (videoEncoder != null) {
     78             mVideoEncoder = Integer.parseInt(videoEncoder);
     79         }
     80         if (audioEncoder != null) {
     81             mAudioEncoder = Integer.parseInt(audioEncoder);
     82         }
     83         if (frameRate != null) {
     84             mFrameRate = Integer.parseInt(frameRate);
     85         }
     86         if (videoWidth != null) {
     87             mVideoWidth = Integer.parseInt(videoWidth);
     88         }
     89         if (videoHeight != null) {
     90             mVideoHeight = Integer.parseInt(videoHeight);
     91         }
     92         if (bitRate != null) {
     93             mBitRate = Integer.parseInt(bitRate);
     94         }
     95         if (recordDuration != null) {
     96             mDuration = Integer.parseInt(recordDuration);
     97         }
     98         if (removeVideos != null) {
     99             if (removeVideos.compareTo("true") == 0) {
    100                 mRemoveVideo = true;
    101             } else {
    102                 mRemoveVideo = false;
    103             }
    104         }
    105     }
    106 }
    107