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 17package com.android.mediaframeworktest; 18 19import android.media.CamcorderProfile; 20import android.media.MediaRecorder; 21import android.os.Bundle; 22import android.test.InstrumentationTestRunner; 23import android.test.InstrumentationTestSuite; 24import com.android.mediaframeworktest.stress.MediaRecorderStressTest; 25 26import java.util.List; 27import junit.framework.TestSuite; 28 29public 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 = 37 CamcorderProfile.get(mCameraId, mProfileQuality); 38 39 public static int mIterations = 100; 40 public static int mVideoEncoder = profile.videoCodec; 41 public static int mAudioEncdoer = profile.audioCodec; 42 public static int mFrameRate = profile.videoFrameRate; 43 public static int mVideoWidth = profile.videoFrameWidth; 44 public static int mVideoHeight = profile.videoFrameHeight; 45 public static int mBitRate = profile.videoBitRate; 46 public static boolean mRemoveVideo = true; 47 public static int mDuration = 10 * 1000; // 10 seconds 48 public static int mTimeLapseDuration = 180 * 1000; // 3 minutes 49 public static double mCaptureRate = 0.5; // 2 sec timelapse interval 50 51 @Override 52 public TestSuite getAllTests() { 53 TestSuite suite = new InstrumentationTestSuite(this); 54 suite.addTestSuite(MediaRecorderStressTest.class); 55 return suite; 56 } 57 58 @Override 59 public ClassLoader getLoader() { 60 return MediaRecorderStressTestRunner.class.getClassLoader(); 61 } 62 63 @Override 64 public void onCreate(Bundle icicle) { 65 super.onCreate(icicle); 66 String iterations = (String) icicle.get("iterations"); 67 String video_encoder = (String) icicle.get("video_encoder"); 68 String audio_encoder = (String) icicle.get("audio_encoder"); 69 String frame_rate = (String) icicle.get("frame_rate"); 70 String video_width = (String) icicle.get("video_width"); 71 String video_height = (String) icicle.get("video_height"); 72 String bit_rate = (String) icicle.get("bit_rate"); 73 String record_duration = (String) icicle.get("record_duration"); 74 String remove_videos = (String) icicle.get("remove_videos"); 75 76 if (iterations != null ) { 77 mIterations = Integer.parseInt(iterations); 78 } 79 if ( video_encoder != null) { 80 mVideoEncoder = Integer.parseInt(video_encoder); 81 } 82 if ( audio_encoder != null) { 83 mAudioEncdoer = Integer.parseInt(audio_encoder); 84 } 85 if (frame_rate != null) { 86 mFrameRate = Integer.parseInt(frame_rate); 87 } 88 if (video_width != null) { 89 mVideoWidth = Integer.parseInt(video_width); 90 } 91 if (video_height != null) { 92 mVideoHeight = Integer.parseInt(video_height); 93 } 94 if (bit_rate != null) { 95 mBitRate = Integer.parseInt(bit_rate); 96 } 97 if (record_duration != null) { 98 mDuration = Integer.parseInt(record_duration); 99 } 100 if (remove_videos != null) { 101 if (remove_videos.compareTo("true") == 0) { 102 mRemoveVideo = true; 103 } else { 104 mRemoveVideo = false; 105 } 106 } 107 } 108} 109