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