MediaRecorderStressTestRunner.java revision 55c1ad99949a6011e82528adf0fc6fa162ab0fcd
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.EncoderCapabilities.AudioEncoderCap;
20import android.media.EncoderCapabilities.VideoEncoderCap;
21import android.media.MediaRecorder;
22import android.os.Bundle;
23import android.test.InstrumentationTestRunner;
24import android.test.InstrumentationTestSuite;
25import com.android.mediaframeworktest.stress.MediaRecorderStressTest;
26
27import java.util.List;
28import junit.framework.TestSuite;
29
30public class MediaRecorderStressTestRunner extends InstrumentationTestRunner {
31
32    public static List<VideoEncoderCap> videoEncoders = MediaProfileReader.getVideoEncoders();
33    public static  List<AudioEncoderCap> audioEncoders = MediaProfileReader.getAudioEncoders();
34
35    //Get the first capability as the default
36    public static VideoEncoderCap videoEncoder = videoEncoders.get(0);
37    public static AudioEncoderCap audioEncoder = audioEncoders.get(0);
38
39    public static int mIterations = 100;
40    public static int mVideoEncoder = videoEncoder.mCodec;
41    public static int mAudioEncdoer = audioEncoder.mCodec;
42    public static int mFrameRate = videoEncoder.mMaxFrameRate;
43    public static int mVideoWidth = videoEncoder.mMaxFrameWidth;
44    public static int mVideoHeight = videoEncoder.mMaxFrameHeight;
45    public static int mBitRate = audioEncoder.mMaxBitRate;
46    public static boolean mRemoveVideo = true;
47    public static int mDuration = 10000;
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 video_encoder = (String) icicle.get("video_encoder");
66        String audio_encoder = (String) icicle.get("audio_encoder");
67        String frame_rate = (String) icicle.get("frame_rate");
68        String video_width = (String) icicle.get("video_width");
69        String video_height = (String) icicle.get("video_height");
70        String bit_rate = (String) icicle.get("bit_rate");
71        String record_duration = (String) icicle.get("record_duration");
72        String remove_videos = (String) icicle.get("remove_videos");
73
74        if (iterations != null ) {
75            mIterations = Integer.parseInt(iterations);
76        }
77        if ( video_encoder != null) {
78            mVideoEncoder = Integer.parseInt(video_encoder);
79        }
80        if ( audio_encoder != null) {
81            mAudioEncdoer = Integer.parseInt(audio_encoder);
82        }
83        if (frame_rate != null) {
84            mFrameRate = Integer.parseInt(frame_rate);
85        }
86        if (video_width != null) {
87            mVideoWidth = Integer.parseInt(video_width);
88        }
89        if (video_height != null) {
90            mVideoHeight = Integer.parseInt(video_height);
91        }
92        if (bit_rate != null) {
93            mBitRate = Integer.parseInt(bit_rate);
94        }
95        if (record_duration != null) {
96            mDuration = Integer.parseInt(record_duration);
97        }
98        if (remove_videos != null) {
99            if (remove_videos.compareTo("true") == 0) {
100                mRemoveVideo = true;
101            } else {
102                mRemoveVideo = false;
103            }
104        }
105    }
106}
107