VideoEditorPerformance.java revision 8b9ba616444a265df6cd2b4f4a0a39d808c65ade
1/*
2 * Copyright (C) 2011 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
18package com.android.mediaframeworktest.performance;
19
20import java.io.BufferedWriter;
21import java.io.File;
22import java.io.FileWriter;
23import java.io.Writer;
24
25import android.graphics.Bitmap;
26import android.graphics.Rect;
27import android.media.videoeditor.AudioTrack;
28import android.media.videoeditor.EffectColor;
29import android.media.videoeditor.EffectKenBurns;
30import android.media.videoeditor.MediaImageItem;
31import android.media.videoeditor.MediaItem;
32import android.media.videoeditor.MediaProperties;
33import android.media.videoeditor.MediaVideoItem;
34import android.media.videoeditor.OverlayFrame;
35import android.media.videoeditor.Transition;
36import android.media.videoeditor.TransitionCrossfade;
37import android.media.videoeditor.TransitionAlpha;
38import android.media.videoeditor.TransitionFadeBlack;
39import android.media.videoeditor.TransitionSliding;
40import android.media.videoeditor.VideoEditor;
41import android.os.Environment;
42import android.test.ActivityInstrumentationTestCase;
43import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
44import android.os.Environment;
45import android.os.SystemClock;
46import android.test.ActivityInstrumentationTestCase;
47import android.media.videoeditor.VideoEditor.ExportProgressListener;
48
49import android.util.Log;
50
51import com.android.mediaframeworktest.MediaFrameworkTest;
52import android.test.suitebuilder.annotation.LargeTest;
53import com.android.mediaframeworktest.VideoEditorHelper;
54
55/**
56 * Junit / Instrumentation - performance measurement for media player and
57 * recorder
58 */
59public class VideoEditorPerformance extends
60    ActivityInstrumentationTestCase<MediaFrameworkTest> {
61
62    private final String TAG = "VideoEditorPerformance";
63
64    private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
65
66    private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
67
68    private final String VIDEOEDITOR_OUTPUT = PROJECT_LOCATION +
69        "VideoEditorPerformance.txt";
70
71    public VideoEditorPerformance() {
72        super("com.android.mediaframeworktest", MediaFrameworkTest.class);
73    }
74
75    private final String PROJECT_CLASS_NAME =
76        "android.media.videoeditor.VideoEditorImpl";
77    private VideoEditor mVideoEditor;
78    private VideoEditorHelper mVideoEditorHelper;
79
80    @Override
81    protected void setUp() throws Exception {
82        // setup for each test case.
83        super.setUp();
84        mVideoEditorHelper = new VideoEditorHelper();
85        // Create a random String which will be used as project path, where all
86        // project related files will be stored.
87        final String projectPath =
88            mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
89        mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
90    }
91
92    @Override
93    protected void tearDown() throws Exception {
94        mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
95        // Clean the directory created as project path
96        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
97        System.gc();
98        super.tearDown();
99    }
100
101    private void writeTimingInfo(String testCaseName, String[] information)
102        throws Exception {
103        File outFile = new File(VIDEOEDITOR_OUTPUT);
104        Writer output = new BufferedWriter(new FileWriter(outFile, true));
105        output.write(testCaseName + "\n\t");
106        for (int i = 0; i < information.length; i++) {
107            output.write(information[i]);
108        }
109        output.write("\n\n");
110        output.close();
111    }
112
113    private final int NUM_OF_ITERATIONS=20;
114
115    private float calculateTimeTaken(long beginTime, int numIterations)
116        throws Exception {
117        final long duration2 = SystemClock.uptimeMillis();
118        final long durationToCreateMediaItem = (duration2 - beginTime);
119        final float timeTaken1 = (float)durationToCreateMediaItem *
120            1.0f/(float)numIterations;
121        return (timeTaken1);
122    }
123
124    private void createVideoItems(MediaVideoItem[] mediaVideoItem,
125        String videoItemFileName, int renderingMode, int startTime, int endTime) throws Exception {
126        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
127            try {
128                mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
129                    videoItemFileName, renderingMode);
130                mediaVideoItem[i].setExtractBoundaries(startTime, endTime);
131            } catch (Exception e1) {
132                assertTrue(
133                    "Can not create an object of Video Item with file name = "
134                    + videoItemFileName + "------ID:m" + i + "       Issue = "
135                    + e1.toString(), false);
136            }
137        }
138    }
139
140    private void addVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
141        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
142            try {
143                mVideoEditor.addMediaItem(mediaVideoItem[i]);
144            } catch (Exception e1) {
145                assertTrue(
146                    "Can not add an object of Video Item with ID:m" + i +
147                    "    Issue = " + e1.toString(), false);
148            }
149        }
150    }
151
152    private void removeVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception {
153            for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
154            try {
155            mVideoEditor.removeMediaItem(mediaVideoItem[i].getId());
156            } catch (Exception e1) {
157                assertTrue(
158                    "Can not Remove an object of Video Item with ID:m" + i +
159                    "    Issue = " + e1.toString(), false);
160            }
161        }
162    }
163
164    private void createImageItems(MediaImageItem[] mIi,
165        String imageItemFileName, int renderingMode, int duration) throws Exception {
166        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
167            try {
168                mIi[i] = new MediaImageItem(mVideoEditor, "m" + i,
169                    imageItemFileName, duration, renderingMode);
170            } catch (Exception e1) {
171                assertTrue( " Cannot create Image Item", false);
172            }
173        }
174    }
175
176    private void addImageItems(MediaImageItem[] mIi) throws Exception {
177        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
178            try {
179                mVideoEditor.addMediaItem(mIi[i]);
180            } catch (Exception e1) {
181                assertTrue("Cannot add Image item", false);
182            }
183        }
184    }
185
186    private void removeImageItems(MediaImageItem[] mIi) throws Exception {
187            for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
188            try {
189            mVideoEditor.removeMediaItem(mIi[i].getId());
190            } catch (Exception e1) {
191                assertTrue("Cannot remove image item", false);
192            }
193        }
194    }
195    /**
196     * To test the performance of adding and removing the video media item
197     *
198     * @throws Exception
199     */
200    // TODO : remove PRF_001
201    @LargeTest
202    public void testPerformanceAddRemoveVideoItem() throws Exception {
203        final String videoItemFileName = INPUT_FILE_PATH +
204            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
205        final int videoItemStartTime = 0;
206        final int videoItemEndTime = 5000;
207        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
208        final String[] loggingInfo = new String[3];
209        final MediaVideoItem[] mediaVideoItem =
210            new MediaVideoItem[NUM_OF_ITERATIONS];
211        float timeTaken = 0.0f;
212        long startTime = 0;
213
214        /** Time Take for creation of Media Video Item */
215        startTime = SystemClock.uptimeMillis();
216        createVideoItems(mediaVideoItem, videoItemFileName, renderingMode,
217            videoItemStartTime, videoItemEndTime);
218
219        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
220        loggingInfo[0] = "Time taken to Create Media Video Item\t" +
221            timeTaken;
222
223        /** Time Take for Addition of Media Video Item */
224        startTime = SystemClock.uptimeMillis();
225        addVideoItems(mediaVideoItem);
226        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
227        loggingInfo[1] = "\n\tTime taken to Add  Media Video Item\t"
228            + timeTaken;
229
230        /** Time Take for Removal of Media Video Item */
231        startTime = SystemClock.uptimeMillis();
232        removeVideoItems(mediaVideoItem);
233        timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS);
234        loggingInfo[2] = "\n\tTime taken to remove  Media Video Item\t"
235            + timeTaken;
236
237        writeTimingInfo("testPerformanceAddRemoveVideoItem (in mSec)", loggingInfo);
238    }
239
240    /**
241     * To test the performance of adding and removing the image media item
242     *
243     * @throws Exception
244     */
245    // TODO : remove PRF_002
246    @LargeTest
247    public void testPerformanceAddRemoveImageItem() throws Exception {
248        final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
249        final int imageItemDuration = 0;
250        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
251        final String[] loggingInfo = new String[3];
252        final MediaImageItem[] mediaImageItem =
253            new MediaImageItem[NUM_OF_ITERATIONS];
254        float timeTaken = 0.0f;
255
256        long beginTime = SystemClock.uptimeMillis();
257        createImageItems(mediaImageItem, imageItemFileName, renderingMode,
258            imageItemDuration);
259        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
260        loggingInfo[0] = "Time taken to Create  Media Image Item\t" +
261            timeTaken;
262
263        beginTime = SystemClock.uptimeMillis();
264        addImageItems(mediaImageItem);
265        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
266        loggingInfo[1] = "\n\tTime taken to add  Media Image Item\t" +
267            timeTaken;
268
269        beginTime = SystemClock.uptimeMillis();
270        removeImageItems(mediaImageItem);
271        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
272        loggingInfo[2] = "\n\tTime taken to remove  Media Image Item\t"
273            + timeTaken;
274
275        writeTimingInfo("testPerformanceAddRemoveImageItem (in mSec)",
276            loggingInfo);
277    }
278
279    /**
280     * To test the performance of adding and removing the transition
281     *
282     * @throws Exception
283     */
284    // TODO : remove PRF_003
285    @LargeTest
286    public void testPerformanceAddRemoveTransition() throws Exception {
287        final String videoItemFileName1 = INPUT_FILE_PATH +
288        "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
289        final int videoItemStartTime1 = 0;
290        final int videoItemEndTime1 = 20000;
291        final String videoItemFileName2 = INPUT_FILE_PATH
292            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
293        final int videoItemStartTime2 = 0;
294        final int videoItemEndTime2 = 20000;
295        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
296        final int transitionDuration = 5000;
297        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
298        final String[] loggingInfo = new String[3];
299        float timeTaken = 0.0f;
300
301        final MediaVideoItem[] mediaVideoItem =
302            new MediaVideoItem[(NUM_OF_ITERATIONS *10) + 1];
303
304        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i+=2) {
305            try {
306                mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i,
307                    videoItemFileName1, renderingMode);
308                mediaVideoItem[i+1] = new MediaVideoItem(mVideoEditor,
309                    "m" + (i+1), videoItemFileName2, renderingMode);
310                mediaVideoItem[i].setExtractBoundaries(videoItemStartTime1,
311                    videoItemEndTime1);
312                mediaVideoItem[i+1].setExtractBoundaries(videoItemStartTime2,
313                    videoItemEndTime2);
314            } catch (Exception e1) {
315                assertTrue("Can not create Video Object Item with file name = "
316                    + e1.toString(), false);
317            }
318            mVideoEditor.addMediaItem(mediaVideoItem[i]);
319            mVideoEditor.addMediaItem(mediaVideoItem[i+1]);
320        }
321        mediaVideoItem[(NUM_OF_ITERATIONS *10)] = new MediaVideoItem(mVideoEditor,
322            "m" + (NUM_OF_ITERATIONS *10), videoItemFileName1, renderingMode);
323        mediaVideoItem[(NUM_OF_ITERATIONS *10)].setExtractBoundaries(
324            videoItemStartTime1, videoItemEndTime1);
325        mVideoEditor.addMediaItem(mediaVideoItem[(NUM_OF_ITERATIONS *10)]);
326        final TransitionCrossfade tranCrossfade[] =
327            new TransitionCrossfade[(NUM_OF_ITERATIONS *10)];
328
329        long beginTime = SystemClock.uptimeMillis();
330        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
331            tranCrossfade[i] = new TransitionCrossfade("transition" + i,
332                mediaVideoItem[i], mediaVideoItem[i+1], transitionDuration,
333                transitionBehavior);
334        }
335        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
336        loggingInfo[0] = "Time taken to Create CrossFade Transition\t" +
337            timeTaken;
338
339        beginTime = SystemClock.uptimeMillis();
340        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
341            mVideoEditor.addTransition(tranCrossfade[i]);
342        }
343        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
344        loggingInfo[1] = "\n\tTime taken to add CrossFade Transition\t" +
345            timeTaken;
346
347        beginTime = SystemClock.uptimeMillis();
348        for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) {
349            assertEquals("Removing Transitions", tranCrossfade[i], mVideoEditor
350                .removeTransition(tranCrossfade[i].getId()));
351        }
352        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10));
353        loggingInfo[2] = "\n\tTime taken to remove CrossFade Transition\t" +
354            timeTaken;
355
356        writeTimingInfo("testPerformanceAddRemoveTransition (in mSec)", loggingInfo);
357    }
358
359    /**
360     * To test performance of Export
361     *
362     * @throws Exception
363     */
364    // TODO : remove PRF_004
365    @LargeTest
366    public void testPerformanceExport() throws Exception {
367        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
368        final int outHeight = MediaProperties.HEIGHT_480;
369        final int outBitrate = MediaProperties.BITRATE_256K;
370        final int outVcodec = MediaProperties.VCODEC_H264BP;
371        final String[] loggingInfo = new String[1];
372        final String outFilename = mVideoEditorHelper
373            .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
374        final String videoItemFileName1 = INPUT_FILE_PATH +
375            "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
376        final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
377        final String videoItemFileName2 = INPUT_FILE_PATH +
378            "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp";
379        final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
380        final String videoItemFileName3 = INPUT_FILE_PATH +
381            "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
382        final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
383        final String audioTrackFilename = INPUT_FILE_PATH +
384            "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
385        final String maskFilename = INPUT_FILE_PATH +
386            "TransitionSpiral_QVGA.jpg";
387
388        final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor,
389            "m1", videoItemFileName1, renderingMode);
390        mediaItem1.setExtractBoundaries(0, 20000);
391        mVideoEditor.addMediaItem(mediaItem1);
392
393        final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor,
394            "m2", imageItemFileName1, 10000, renderingMode);
395        mVideoEditor.addMediaItem(mediaItem2);
396
397        final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor,
398            "m3", videoItemFileName2, renderingMode);
399        mediaItem3.setExtractBoundaries(0, 20000);
400        mVideoEditor.addMediaItem(mediaItem3);
401
402        final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor,
403            "m4", imageItemFileName2, 10000, renderingMode);
404        mVideoEditor.addMediaItem(mediaItem4);
405
406        final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor,
407            "m5", videoItemFileName3, renderingMode);
408        mediaItem5.setExtractBoundaries(0, 20000);
409        mVideoEditor.addMediaItem(mediaItem5);
410        /**
411         * 7.Add TransitionAlpha, Apply this  Transition as Begin for Media Item 1
412         *  with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name =
413         * TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true;
414         * */
415        final TransitionAlpha transition1 =
416            mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
417                2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
418        mVideoEditor.addTransition(transition1);
419
420        /**
421         * 8.Add Transition Sliding between MediaItem 2 and 3 ,
422         *  Sliding Direction  = DIRECTION_RIGHT_OUT_LEFT_IN,
423         *  behavior  = BEHAVIOR_MIDDLE_FAST and duration = 4sec
424         * */
425        final TransitionSliding transition2And3 =
426            mVideoEditorHelper.createTSliding("transition2", mediaItem2,
427                mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
428                TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
429        mVideoEditor.addTransition(transition2And3);
430
431        /**
432         * 9.Add Transition Crossfade between  Media Item 3 and 4,
433         *  behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec
434         * */
435        final TransitionCrossfade transition3And4 =
436            mVideoEditorHelper.createTCrossFade("transition3", mediaItem3,
437                mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
438        mVideoEditor.addTransition(transition3And4);
439
440        /**
441         * 10.Add Transition Fadeblack between  Media Item 4 and 5,
442         *  behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec
443         * */
444        final TransitionFadeBlack transition4And5 =
445            mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4,
446                mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
447        mVideoEditor.addTransition(transition4And5);
448
449        /**
450         * 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1,
451         *  start time=1sec and duration =4secs
452         * */
453        final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem(
454            mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0);
455        mediaItem1.addEffect(effectColor1);
456
457        /**
458         * 12.Add Overlay 1  to the MediaItem 3: Frame Overlay with start time = 1 sec
459         * duration = 4 sec with item  = IMG_640x480_Overlay1.png
460         * */
461        final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFile, 640,
462            480);
463        final OverlayFrame overlayFrame =
464            mVideoEditorHelper.createOverlay(mediaItem3, "overlay",
465                mBitmap, 1000, 4000);
466        mediaItem3.addOverlay(overlayFrame);
467        /**
468         * 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2,
469         *  start time=8sec and duration =2secs
470         * */
471        final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem(
472            mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0);
473        mediaItem2.addEffect(effectColor2);
474        /**
475         * 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK",
476         *  start time=5 sec and duration =3secs
477         * */
478        final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem(
479            mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR,
480            EffectColor.PINK);
481        mediaItem3.addEffect(effectColor3);
482        /**
483         * 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4,
484         *  start time=2 sec and duration =1secs
485        * */
486        final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem(
487            mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0);
488        mediaItem4.addEffect(effectColor4);
489        /**
490         * 16.Add KenBurnsEffect for MediaItem 4 with
491         *  duration = 3 sec and startTime = 4 sec
492         *  StartRect
493         *  left = org_height/3  ;  top = org_width/3
494         *  bottom = org_width/2  ;  right = org_height/2
495         *  EndRect
496         *  left = 0  ;  top = 0
497         *  bottom =  org_height;  right =  org_width
498         * */
499
500        final Rect startRect = new Rect((mediaItem4.getHeight() / 3),
501            (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2),
502            (mediaItem4.getWidth() / 2));
503        final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(),
504            mediaItem4.getHeight());
505        final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(
506            mediaItem4, "KBOnM2", startRect, endRect,4000 , 3000);
507        mediaItem4.addEffect(kbEffectOnMediaItem);
508
509        /** 17.Add Audio Track,Set extract boundaries o to 10 sec.
510         * */
511        final AudioTrack audioTrack = mVideoEditorHelper.createAudio(
512            mVideoEditor, "audioTrack", audioTrackFilename);
513        mVideoEditor.addAudioTrack(audioTrack);
514        /** 18.Enable Looping for Audio Track.
515         * */
516        audioTrack.enableLoop();
517        float timeTaken = 0.0f;
518        final long beginTime = SystemClock.uptimeMillis();
519            try {
520                mVideoEditor.export(outFilename, outHeight, outBitrate, /*0,
521                    outVcodec,*/ new ExportProgressListener() {
522                        public void onProgress(VideoEditor ve,
523                            String outFileName, int progress) {
524                        }
525                    });
526            } catch (Exception e) {
527                assertTrue("Error in Export" + e.toString(), false);
528            }
529        mVideoEditorHelper.checkDeleteExistingFile(outFilename);
530
531        timeTaken = calculateTimeTaken(beginTime, 1);
532        loggingInfo[0] = "Time taken to do ONE export of storyboard duration\t"
533            + mVideoEditor.getDuration() + "   is   :\t" + timeTaken;
534
535        writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo);
536        mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
537    }
538
539
540    /**
541     * To test the performance of thumbnail extraction
542     *
543     * @throws Exception
544     */
545    // TODO : remove PRF_005
546    @LargeTest
547    public void testPerformanceThumbnailVideoItem() throws Exception {
548        final String videoItemFileName = INPUT_FILE_PATH
549            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
550        final int videoItemStartTime = 0;
551        final int videoItemEndTime = 20000;
552        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
553        final String[] loggingInfo = new String[1];
554
555        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
556            "m1", videoItemFileName, renderingMode);
557        mediaVideoItem.setExtractBoundaries(videoItemStartTime,
558            videoItemEndTime);
559
560        float timeTaken = 0.0f;
561        long beginTime = SystemClock.uptimeMillis();
562        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
563            mediaVideoItem.getThumbnail(mediaVideoItem.getWidth() / 2,
564                mediaVideoItem.getHeight() / 2, i);
565        }
566        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
567        loggingInfo[0] = "Duration taken to get Video Thumbnails\t" +
568            timeTaken;
569
570        writeTimingInfo("testPerformanceThumbnailVideoItem (in mSec)", loggingInfo);
571    }
572
573    /**
574     * To test the performance of adding and removing the overlay to media item
575     *
576     * @throws Exception
577     */
578    // TODO : remove PRF_006
579    @LargeTest
580    public void testPerformanceOverlayVideoItem() throws Exception {
581        final String videoItemFileName1 = INPUT_FILE_PATH +
582            "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
583        final int videoItemStartTime1 = 0;
584        final int videoItemEndTime1 = 10000;
585        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
586        final String overlayFilename = INPUT_FILE_PATH
587            + "IMG_640x480_Overlay1.png";
588        final int overlayStartTime = 1000;
589        final int overlayDuration = 5000;
590
591        final String[] loggingInfo = new String[2];
592        MediaVideoItem mediaVideoItem = null;
593
594        try {
595            mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0",
596                videoItemFileName1, renderingMode);
597            mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
598                videoItemEndTime1);
599        } catch (Exception e1) {
600            assertTrue("Can not create Video Item with file name = "
601                + e1.toString(), false);
602        }
603        final OverlayFrame overlayFrame[] = new OverlayFrame[NUM_OF_ITERATIONS];
604        final Bitmap mBitmap =  mVideoEditorHelper.getBitmap(overlayFilename,
605            640, 480);
606        float timeTaken = 0.0f;
607        long beginTime = SystemClock.uptimeMillis();
608        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
609            overlayFrame[i] = new OverlayFrame(mediaVideoItem, "overlay" + i,
610            mBitmap, overlayStartTime, overlayDuration);
611            mediaVideoItem.addOverlay(overlayFrame[i]);
612        }
613        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
614        loggingInfo[0] = "Time taken to add & create Overlay\t" + timeTaken;
615
616        beginTime = SystemClock.uptimeMillis();
617        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
618            assertEquals("Removing Overlays", overlayFrame[i],
619                mediaVideoItem.removeOverlay((overlayFrame[i].getId())));
620        }
621        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
622        loggingInfo[1] = "\n\tTime taken to remove  Overlay\t" +
623            timeTaken;
624
625        writeTimingInfo("testPerformanceOverlayVideoItem (in mSec)", loggingInfo);
626    }
627
628    /**
629     * To test the performance of get properties of a Video media item
630     *
631     * @throws Exception
632     */
633    // TODO : remove PRF_007
634    @LargeTest
635    public void testPerformanceVideoItemProperties() throws Exception {
636        final String videoItemFileName1 = INPUT_FILE_PATH +
637            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
638        final int videoItemStartTime1 = 0;
639        final int videoItemEndTime1 = 10100;
640        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
641        final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
642        final int fileType = MediaProperties.FILE_MP4;
643        final int videoCodecType = MediaProperties.VCODEC_H264BP;
644        final int duration = 77366;
645        final int videoBitrate = 3169971;
646        final int fps = 30;
647        final int videoProfile = 0;
648        final int width = 1080;
649        final int height = MediaProperties.HEIGHT_720;
650        float timeTaken = 0.0f;
651        final String[] loggingInfo = new String[1];
652        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
653            "m0", videoItemFileName1, renderingMode);
654        mediaVideoItem.setExtractBoundaries(videoItemStartTime1,
655            videoItemEndTime1);
656        long beginTime = SystemClock.uptimeMillis();
657        for (int i = 0; i < (NUM_OF_ITERATIONS*10); i++) {
658            try {
659                assertEquals("Aspect Ratio Mismatch",
660                    aspectRatio, mediaVideoItem.getAspectRatio());
661                assertEquals("File Type Mismatch",
662                    fileType, mediaVideoItem.getFileType());
663                assertEquals("VideoCodec Mismatch",
664                    videoCodecType, mediaVideoItem.getVideoType());
665                assertEquals("duration Mismatch",
666                    duration, mediaVideoItem.getDuration());
667/*
668                if (videoBitrate != 0) {
669                    assertTrue("VideoBitrate Mismatch <expected> " + videoBitrate + "\t<actual> "
670                        + mediaVideoItem.getVideoBitrate(), mVideoEditorHelper.checkRange(
671                        videoBitrate, mediaVideoItem.getVideoBitrate(), 10));
672                }
673
674                assertTrue("fps Mismatch", mVideoEditorHelper.checkRange(fps,
675                    mediaVideoItem.getFps(), 10));
676*/
677                assertEquals("Video Profile ",
678                    videoProfile, mediaVideoItem.getVideoProfile());
679                assertEquals("Video height ",
680                    height, mediaVideoItem.getHeight());
681                assertEquals("Video width ",
682                    width, mediaVideoItem.getWidth());
683            } catch (Exception e1) {
684                assertTrue("Can not create Video Item with file name = "
685                    + e1.toString(), false);
686            }
687        }
688        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS*10));
689        loggingInfo[0] = "Time taken to get Media Properties\t"
690            + timeTaken;
691        writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo);
692    }
693
694    /**
695     * To test the performance of generatePreview : with Transitions
696     *
697     * @throws Exception
698     */
699    // TODO : remove PRF_008
700    @LargeTest
701    public void testPerformanceGeneratePreviewWithTransitions()
702        throws Exception {
703        final String videoItemFileName = INPUT_FILE_PATH +
704            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
705        final String imageItemFileName = INPUT_FILE_PATH +
706            "IMG_1600x1200.jpg";
707        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
708        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
709        long averageTime = 0;
710        final String[] loggingInfo = new String[1];
711
712        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
713            "mediaItem1", videoItemFileName, renderingMode);
714        mediaVideoItem.setExtractBoundaries(0, 10000);
715        mVideoEditor.addMediaItem(mediaVideoItem);
716
717        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
718            "mediaItem2", imageItemFileName, 10000, renderingMode);
719        mVideoEditor.addMediaItem(mediaImageItem);
720
721        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
722            "transitionCrossFade", mediaVideoItem, mediaImageItem,
723            5000, transitionBehavior);
724        mVideoEditor.addTransition(transitionCrossFade);
725
726        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
727            final long duration1 = SystemClock.uptimeMillis();
728            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
729                public void onProgress(Object item, int action, int progress) {
730                }
731            });
732            final long duration2 = SystemClock.uptimeMillis();
733            mVideoEditor.removeTransition(transitionCrossFade.getId());
734            mVideoEditor.addTransition(transitionCrossFade);
735            averageTime += (duration2 - duration1);
736        }
737        final long durationToAddObjects = averageTime;
738        final float timeTaken = (float)durationToAddObjects *
739            1.0f/(float)NUM_OF_ITERATIONS;
740        loggingInfo[0] = "Time taken to Generate Preview with transition\t"
741            + timeTaken;
742        writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:",
743            loggingInfo);
744    }
745
746    /**
747     * To test the performance of generatePreview : with KenBurn
748     *
749     * @throws Exception
750     */
751    // TODO : remove PRF_009
752    @LargeTest
753    public void testPerformanceWithKenBurn() throws Exception {
754        final String videoItemFileName = INPUT_FILE_PATH +
755            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
756        final String imageItemFileName = INPUT_FILE_PATH +
757            "IMG_1600x1200.jpg";
758        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
759        long averageTime = 0;
760        final String[] loggingInfo = new String[1];
761        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
762            "mediaItem1", videoItemFileName, renderingMode);
763        mediaVideoItem.setExtractBoundaries(0, 10000);
764        mVideoEditor.addMediaItem(mediaVideoItem);
765
766        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
767            "mediaItem2", imageItemFileName, 10000, renderingMode);
768        mVideoEditor.addMediaItem(mediaImageItem);
769
770        final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
771            (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
772            (mediaImageItem.getWidth() / 2));
773        final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
774            mediaImageItem.getHeight());
775        final EffectKenBurns kbEffectOnMediaItem =
776            new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect,
777                500, 3000);
778        mediaImageItem.addEffect(kbEffectOnMediaItem);
779
780        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
781            final long duration1 = SystemClock.uptimeMillis();
782            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
783                public void onProgress(Object item, int action, int progress) {
784                }
785            });
786            final long duration2 = SystemClock.uptimeMillis();
787            mediaImageItem.removeEffect(kbEffectOnMediaItem.getId());
788            mediaImageItem.addEffect(kbEffectOnMediaItem);
789            averageTime += duration2 - duration1;
790        }
791
792        final long durationToAddObjects = (averageTime);
793        final float timeTaken = (float)durationToAddObjects *
794            1.0f/(float)NUM_OF_ITERATIONS;
795        loggingInfo[0] = "Time taken to Generate KenBurn Effect \t"
796            + timeTaken;
797        writeTimingInfo("testPerformanceWithKenBurn", loggingInfo);
798    }
799
800    /**
801     * To test the performance of generatePreview : with Transitions and
802     * Effect,Overlapping scenario
803     *
804     * @throws Exception
805     */
806    // TODO : remove PRF_010
807    @LargeTest
808    public void testPerformanceEffectOverlappingTransition() throws Exception {
809        final String videoItemFileName1 = INPUT_FILE_PATH +
810            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
811        final String videoItemFileName2 = INPUT_FILE_PATH
812            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
813        final int videoStartTime1 = 0;
814        final int videoEndTime1 = 10000;
815        final int videoStartTime2 = 0;
816        final int videoEndTime2 = 10000;
817        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
818        final int transitionDuration = 5000;
819        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
820        final int effectItemStartTime = 5000;
821        final int effectItemDurationTime = 5000;
822        final int effectType = EffectColor.TYPE_COLOR;
823        final int effectColorType = EffectColor.GREEN;
824        long averageDuration = 0;
825
826        final String[] loggingInfo = new String[1];
827        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
828            "mediaItem1", videoItemFileName1, renderingMode);
829        mediaVideoItem1.setExtractBoundaries(videoStartTime1, videoEndTime1);
830        mVideoEditor.addMediaItem(mediaVideoItem1);
831
832        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
833            "mediaItem2", videoItemFileName2, renderingMode);
834        mediaVideoItem2.setExtractBoundaries(videoStartTime2, videoEndTime2);
835        mVideoEditor.addMediaItem(mediaVideoItem2);
836
837        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
838            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
839            transitionDuration, transitionBehavior);
840        mVideoEditor.addTransition(transitionCrossFade);
841
842        final EffectColor effectColor = new EffectColor(mediaVideoItem1,
843            "effect", effectItemStartTime, effectItemDurationTime, effectType,
844             effectColorType);
845        mediaVideoItem1.addEffect(effectColor);
846
847        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
848            final long duration1 = SystemClock.uptimeMillis();
849            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
850                public void onProgress(Object item, int action, int progress) {
851                }
852            });
853            final long duration2 = SystemClock.uptimeMillis();
854            mVideoEditor.removeTransition(transitionCrossFade.getId());
855            mVideoEditor.addTransition(transitionCrossFade);
856            averageDuration += (duration2 - duration1);
857        }
858        SystemClock.uptimeMillis();
859        final long durationToAddObjects = (averageDuration);
860        final float timeTaken = (float)durationToAddObjects *
861            1.0f/(float)NUM_OF_ITERATIONS;
862        loggingInfo[0] =
863            "Time taken to testPerformanceEffectOverlappingTransition\t"
864            + timeTaken;
865        writeTimingInfo("testPerformanceEffectOverlappingTransition:",
866            loggingInfo);
867    }
868
869    /**
870     * To test creation of story board with Transition and Two Effects, Effect
871     * overlapping transitions
872     *
873     * @throws Exception
874     */
875    // TODO : remove PRF_011
876    @LargeTest
877    public void testPerformanceTransitionWithEffectOverlapping() throws Exception {
878        final String videoItemFileName1 = INPUT_FILE_PATH +
879            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
880        final String videoItemFileName2 = INPUT_FILE_PATH
881            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
882        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
883        final int transitionDuration = 5000;
884        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
885        final int effectItemStartTime1 = 5000;
886        final int effectItemDurationTime1 = 5000;
887        final int effectType1 = EffectColor.TYPE_COLOR;
888        final int effectColorType1 = EffectColor.GREEN;
889        final int effectItemStartTime2 = 5000;
890        final int effectItemDurationTime2 = 5000;
891        final int effectType2 = EffectColor.TYPE_COLOR;
892        final int effectColorType2 = EffectColor.GREEN;
893        int averageTime = 0;
894        final String[] loggingInfo = new String[1];
895
896        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
897            "mediaItem1", videoItemFileName1, renderingMode);
898        mVideoEditor.addMediaItem(mediaVideoItem1);
899
900        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
901            "mediaItem2", videoItemFileName2, renderingMode);
902        mVideoEditor.addMediaItem(mediaVideoItem2);
903
904        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
905            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
906            transitionDuration, transitionBehavior);
907        mVideoEditor.addTransition(transitionCrossFade);
908
909        final EffectColor effectColor1 = new EffectColor(mediaVideoItem1,
910            "effect1", effectItemStartTime1, effectItemDurationTime1,
911            effectType1, effectColorType1);
912        mediaVideoItem1.addEffect(effectColor1);
913
914        final EffectColor effectColor2 = new EffectColor(mediaVideoItem2,
915            "effect2", effectItemStartTime2, effectItemDurationTime2,
916            effectType2, effectColorType2);
917        mediaVideoItem2.addEffect(effectColor2);
918
919        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
920            final long duration1 = SystemClock.uptimeMillis();
921            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
922                public void onProgress(Object item, int action, int progress) {
923                }
924            });
925            final long duration2 = SystemClock.uptimeMillis();
926            mVideoEditor.removeTransition(transitionCrossFade.getId());
927            mVideoEditor.addTransition(transitionCrossFade);
928            averageTime += duration2 - duration1;
929        }
930        final long durationToAddObjects = (averageTime);
931        final float timeTaken = (float)durationToAddObjects *
932            1.0f/(float)NUM_OF_ITERATIONS;
933        loggingInfo[0] = "Time taken to TransitionWithEffectOverlapping\t"
934            + timeTaken;
935        writeTimingInfo("testPerformanceTransitionWithEffectOverlapping",
936            loggingInfo);
937    }
938
939    /**
940     *To test ThumbnailList for H264
941     */
942    // TODO : TC_PRF_12
943    @LargeTest
944    public void testThumbnailH264NonIFrame() throws Exception {
945        final String videoItemFilename = INPUT_FILE_PATH +
946            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
947        final int outWidth = 1080;
948        final int outHeight = 720;
949        final int atTime = 2400;
950        long durationToAddObjects = 0;
951        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
952        final String[] loggingInfo = new String[1];
953        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
954            "m1", videoItemFilename, renderingMode);
955        assertNotNull("MediaVideoItem", mediaVideoItem);
956
957        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
958            final long duration1 = SystemClock.uptimeMillis();
959            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
960            final long duration2 = SystemClock.uptimeMillis();
961            durationToAddObjects += (duration2 - duration1);
962        }
963        final float timeTaken = (float)durationToAddObjects *
964            1.0f/(float)NUM_OF_ITERATIONS;
965        loggingInfo[0] = "Time taken for Thumbnail generation \t"
966            + timeTaken;
967        writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo);
968    }
969
970    /**
971     *To test ThumbnailList for H264
972     */
973    // TODO : TC_PRF_13
974    @LargeTest
975    public void testThumbnailH264AnIFrame() throws Exception {
976        final String videoItemFilename = INPUT_FILE_PATH +
977            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
978        final int outWidth = 1080;
979        final int outHeight = 720;
980        final int atTime = 3000;
981        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
982        final String[] loggingInfo = new String[1];
983        long durationToAddObjects = 0;
984
985        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
986            "m1", videoItemFilename, renderingMode);
987        assertNotNull("MediaVideoItem", mediaVideoItem);
988
989        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
990            final long duration1 = SystemClock.uptimeMillis();
991            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
992            final long duration2 = SystemClock.uptimeMillis();
993            durationToAddObjects += (duration2 - duration1);
994        }
995        final float timeTaken = (float)durationToAddObjects *
996            1.0f/(float)NUM_OF_ITERATIONS;
997        loggingInfo[0] = "Time taken Thumbnail generation \t"
998            + timeTaken;
999        writeTimingInfo("testThumbnailH264AnIFrame", loggingInfo);
1000    }
1001
1002    /**
1003     * To test the performance : With an audio track
1004     *
1005     * @throws Exception
1006     */
1007    // TODO : remove PRF_014
1008    @LargeTest
1009    public void testPerformanceWithAudioTrack() throws Exception {
1010        final String videoItemFileName1 = INPUT_FILE_PATH +
1011            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
1012        final String audioFilename1 = INPUT_FILE_PATH +
1013            "AACLC_44.1kHz_256kbps_s_1_17.mp4";
1014        final String audioFilename2 = INPUT_FILE_PATH +
1015            "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
1016        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
1017        final int audioVolume = 50;
1018        final String[] loggingInfo = new String[2];
1019        float timeTaken = 0.0f;
1020
1021        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
1022            "mediaItem1", videoItemFileName1, renderingMode);
1023        mVideoEditor.addMediaItem(mediaVideoItem);
1024
1025        final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor,
1026            "Audio Track1", audioFilename1);
1027        audioTrack1.disableDucking();
1028        audioTrack1.setVolume(audioVolume);
1029        mVideoEditor.addAudioTrack(audioTrack1);
1030
1031        long beginTime = SystemClock.uptimeMillis();
1032        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
1033            public void onProgress(Object item, int action, int progress) {
1034            }
1035        });
1036        timeTaken = calculateTimeTaken(beginTime, 1);
1037        loggingInfo[0] = "Time taken for 1st Audio Track (AACLC)\t"
1038            + timeTaken;
1039
1040        final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor,
1041            "Audio Track2", audioFilename2);
1042        audioTrack2.enableLoop();
1043
1044        beginTime = SystemClock.uptimeMillis();
1045        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
1046            public void onProgress(Object item, int action, int progress) {
1047            }
1048        });
1049        timeTaken = calculateTimeTaken(beginTime, 1);
1050        loggingInfo[1] = "\n\tTime taken for 2nd Audio Track(AMRNB)\t"
1051            + timeTaken;
1052
1053        writeTimingInfo("testPerformanceWithAudioTrack", loggingInfo);
1054    }
1055
1056    /**
1057     * To test the performance of adding and removing the
1058     * image media item with 640 x 480
1059     *
1060     * @throws Exception
1061     */
1062    // TODO : remove PRF_015
1063    @LargeTest
1064    public void testPerformanceAddRemoveImageItem640x480() throws Exception {
1065        final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
1066        final int imageItemDuration = 0;
1067        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
1068        final String[] loggingInfo = new String[3];
1069
1070        float timeTaken = 0.0f;
1071
1072        final MediaImageItem[] mediaImageItem =
1073            new MediaImageItem[NUM_OF_ITERATIONS];
1074        long beginTime = SystemClock.uptimeMillis();
1075        createImageItems(mediaImageItem, imageItemFileName, renderingMode,
1076            imageItemDuration);
1077        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1078        loggingInfo[0] = "Time taken to Create  Media Image Item (640x480)\t"
1079            + timeTaken;
1080
1081        beginTime = SystemClock.uptimeMillis();
1082        addImageItems(mediaImageItem);
1083        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1084        loggingInfo[1] = "\n\tTime taken to add  Media Image Item (640x480)\t"
1085            + timeTaken;
1086
1087        beginTime = SystemClock.uptimeMillis();
1088        removeImageItems(mediaImageItem);
1089        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1090        loggingInfo[2] = "\n\tTime taken to remove  Media Image Item (640x480)\t"
1091            + timeTaken;
1092        writeTimingInfo("testPerformanceAddRemoveImageItem640x480 (in mSec)", loggingInfo);
1093    }
1094
1095
1096}
1097