VideoEditorPerformance.java revision 3ced044154945f9d60983032278e00fe28f4ab1b
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_H264;
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_H264;
643        final int duration = 77366;
644        final int videoBitrate = 3169971;
645        final int fps = 30;
646        final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline;
647        final int videoLevel = MediaProperties.H264Level.H264Level13;
648        final int width = 1080;
649        final int height = MediaProperties.HEIGHT_720;
650        int timeTaken = 0;
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                assertEquals("Video Profile ",
668                    videoProfile, mediaVideoItem.getVideoProfile());
669                assertEquals("Video Level ",
670                    videoLevel, mediaVideoItem.getVideoLevel());
671                assertEquals("Video height ",
672                    height, mediaVideoItem.getHeight());
673                assertEquals("Video width ",
674                    width, mediaVideoItem.getWidth());
675            } catch (Exception e1) {
676                assertTrue("Can not create Video Item with file name = "
677                    + e1.toString(), false);
678            }
679        }
680        timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS*10));
681        loggingInfo[0] = "Time taken to get Media Properties :"
682            + timeTaken;
683        writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo);
684    }
685
686    /**
687     * To test the performance of generatePreview : with Transitions
688     *
689     * @throws Exception
690     */
691    // TODO : remove PRF_008
692    @LargeTest
693    public void testPerformanceGeneratePreviewWithTransitions()
694        throws Exception {
695        final String videoItemFileName = INPUT_FILE_PATH +
696            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
697        final String imageItemFileName = INPUT_FILE_PATH +
698            "IMG_1600x1200.jpg";
699        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
700        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
701        long averageTime = 0;
702        final String[] loggingInfo = new String[1];
703
704        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
705            "mediaItem1", videoItemFileName, renderingMode);
706        mediaVideoItem.setExtractBoundaries(0, 10000);
707        mVideoEditor.addMediaItem(mediaVideoItem);
708
709        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
710            "mediaItem2", imageItemFileName, 10000, renderingMode);
711        mVideoEditor.addMediaItem(mediaImageItem);
712
713        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
714            "transitionCrossFade", mediaVideoItem, mediaImageItem,
715            5000, transitionBehavior);
716        mVideoEditor.addTransition(transitionCrossFade);
717
718        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
719            final long duration1 = SystemClock.uptimeMillis();
720            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
721                public void onProgress(Object item, int action, int progress) {
722                }
723            });
724            final long duration2 = SystemClock.uptimeMillis();
725            mVideoEditor.removeTransition(transitionCrossFade.getId());
726            mVideoEditor.addTransition(transitionCrossFade);
727            averageTime += (duration2 - duration1);
728        }
729        final long durationToAddObjects = averageTime;
730        final float timeTaken = (float)durationToAddObjects *
731            1.0f/(float)NUM_OF_ITERATIONS;
732        loggingInfo[0] = "Time taken to Generate Preview with transition :"
733            + timeTaken;
734        writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:",
735            loggingInfo);
736    }
737
738    /**
739     * To test the performance of generatePreview : with KenBurn
740     *
741     * @throws Exception
742     */
743    // TODO : remove PRF_009
744    @LargeTest
745    public void testPerformanceWithKenBurn() throws Exception {
746        final String videoItemFileName = INPUT_FILE_PATH +
747            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
748        final String imageItemFileName = INPUT_FILE_PATH +
749            "IMG_1600x1200.jpg";
750        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
751        long averageTime = 0;
752        final String[] loggingInfo = new String[1];
753        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
754            "mediaItem1", videoItemFileName, renderingMode);
755        mediaVideoItem.setExtractBoundaries(0, 10000);
756        mVideoEditor.addMediaItem(mediaVideoItem);
757
758        final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor,
759            "mediaItem2", imageItemFileName, 10000, renderingMode);
760        mVideoEditor.addMediaItem(mediaImageItem);
761
762        final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
763            (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
764            (mediaImageItem.getWidth() / 2));
765        final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
766            mediaImageItem.getHeight());
767        final EffectKenBurns kbEffectOnMediaItem =
768            new EffectKenBurns(mediaImageItem, "KBOnM2", startRect, endRect,
769                500, 3000);
770        mediaImageItem.addEffect(kbEffectOnMediaItem);
771
772        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
773            final long duration1 = SystemClock.uptimeMillis();
774            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
775                public void onProgress(Object item, int action, int progress) {
776                }
777            });
778            final long duration2 = SystemClock.uptimeMillis();
779            mediaImageItem.removeEffect(kbEffectOnMediaItem.getId());
780            mediaImageItem.addEffect(kbEffectOnMediaItem);
781            averageTime += duration2 - duration1;
782        }
783
784        final long durationToAddObjects = (averageTime);
785        final float timeTaken = (float)durationToAddObjects *
786            1.0f/(float)NUM_OF_ITERATIONS;
787        loggingInfo[0] = "Time taken to Generate KenBurn Effect :"
788            + timeTaken;
789        writeTimingInfo("testPerformanceWithKenBurn", loggingInfo);
790    }
791
792    /**
793     * To test the performance of generatePreview : with Transitions and
794     * Effect,Overlapping scenario
795     *
796     * @throws Exception
797     */
798    // TODO : remove PRF_010
799    @LargeTest
800    public void testPerformanceEffectOverlappingTransition() throws Exception {
801        final String videoItemFileName1 = INPUT_FILE_PATH +
802            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
803        final String videoItemFileName2 = INPUT_FILE_PATH
804            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
805        final int videoStartTime1 = 0;
806        final int videoEndTime1 = 10000;
807        final int videoStartTime2 = 0;
808        final int videoEndTime2 = 10000;
809        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
810        final int transitionDuration = 5000;
811        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
812        final int effectItemStartTime = 5000;
813        final int effectItemDurationTime = 5000;
814        final int effectType = EffectColor.TYPE_COLOR;
815        final int effectColorType = EffectColor.GREEN;
816        long averageDuration = 0;
817
818        final String[] loggingInfo = new String[1];
819        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
820            "mediaItem1", videoItemFileName1, renderingMode);
821        mediaVideoItem1.setExtractBoundaries(videoStartTime1, videoEndTime1);
822        mVideoEditor.addMediaItem(mediaVideoItem1);
823
824        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
825            "mediaItem2", videoItemFileName2, renderingMode);
826        mediaVideoItem2.setExtractBoundaries(videoStartTime2, videoEndTime2);
827        mVideoEditor.addMediaItem(mediaVideoItem2);
828
829        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
830            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
831            transitionDuration, transitionBehavior);
832        mVideoEditor.addTransition(transitionCrossFade);
833
834        final EffectColor effectColor = new EffectColor(mediaVideoItem1,
835            "effect", effectItemStartTime, effectItemDurationTime, effectType,
836             effectColorType);
837        mediaVideoItem1.addEffect(effectColor);
838
839        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
840            final long duration1 = SystemClock.uptimeMillis();
841            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
842                public void onProgress(Object item, int action, int progress) {
843                }
844            });
845            final long duration2 = SystemClock.uptimeMillis();
846            mVideoEditor.removeTransition(transitionCrossFade.getId());
847            mVideoEditor.addTransition(transitionCrossFade);
848            averageDuration += (duration2 - duration1);
849        }
850        SystemClock.uptimeMillis();
851        final long durationToAddObjects = (averageDuration);
852        final float timeTaken = (float)durationToAddObjects *
853            1.0f/(float)NUM_OF_ITERATIONS;
854        loggingInfo[0] =
855            "Time taken to testPerformanceEffectOverlappingTransition :"
856            + timeTaken;
857        writeTimingInfo("testPerformanceEffectOverlappingTransition:",
858            loggingInfo);
859    }
860
861    /**
862     * To test creation of story board with Transition and Two Effects, Effect
863     * overlapping transitions
864     *
865     * @throws Exception
866     */
867    // TODO : remove PRF_011
868    @LargeTest
869    public void testPerformanceTransitionWithEffectOverlapping() throws Exception {
870        final String videoItemFileName1 = INPUT_FILE_PATH +
871            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
872        final String videoItemFileName2 = INPUT_FILE_PATH
873            + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
874        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
875        final int transitionDuration = 5000;
876        final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST;
877        final int effectItemStartTime1 = 5000;
878        final int effectItemDurationTime1 = 5000;
879        final int effectType1 = EffectColor.TYPE_COLOR;
880        final int effectColorType1 = EffectColor.GREEN;
881        final int effectItemStartTime2 = 5000;
882        final int effectItemDurationTime2 = 5000;
883        final int effectType2 = EffectColor.TYPE_COLOR;
884        final int effectColorType2 = EffectColor.GREEN;
885        int averageTime = 0;
886        final String[] loggingInfo = new String[1];
887
888        final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor,
889            "mediaItem1", videoItemFileName1, renderingMode);
890        mVideoEditor.addMediaItem(mediaVideoItem1);
891
892        final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor,
893            "mediaItem2", videoItemFileName2, renderingMode);
894        mVideoEditor.addMediaItem(mediaVideoItem2);
895
896        final TransitionCrossfade transitionCrossFade = new TransitionCrossfade(
897            "transitionCrossFade", mediaVideoItem1, mediaVideoItem2,
898            transitionDuration, transitionBehavior);
899        mVideoEditor.addTransition(transitionCrossFade);
900
901        final EffectColor effectColor1 = new EffectColor(mediaVideoItem1,
902            "effect1", effectItemStartTime1, effectItemDurationTime1,
903            effectType1, effectColorType1);
904        mediaVideoItem1.addEffect(effectColor1);
905
906        final EffectColor effectColor2 = new EffectColor(mediaVideoItem2,
907            "effect2", effectItemStartTime2, effectItemDurationTime2,
908            effectType2, effectColorType2);
909        mediaVideoItem2.addEffect(effectColor2);
910
911        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
912            final long duration1 = SystemClock.uptimeMillis();
913            mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
914                public void onProgress(Object item, int action, int progress) {
915                }
916            });
917            final long duration2 = SystemClock.uptimeMillis();
918            mVideoEditor.removeTransition(transitionCrossFade.getId());
919            mVideoEditor.addTransition(transitionCrossFade);
920            averageTime += duration2 - duration1;
921        }
922        final long durationToAddObjects = (averageTime);
923        final float timeTaken = (float)durationToAddObjects *
924            1.0f/(float)NUM_OF_ITERATIONS;
925        loggingInfo[0] = "Time taken to TransitionWithEffectOverlapping :"
926            + timeTaken;
927        writeTimingInfo("testPerformanceTransitionWithEffectOverlapping",
928            loggingInfo);
929    }
930
931    /**
932     *To test ThumbnailList for H264
933     */
934    // TODO : TC_PRF_12
935    @LargeTest
936    public void testThumbnailH264NonIFrame() throws Exception {
937        final String videoItemFilename = INPUT_FILE_PATH +
938            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
939        final int outWidth = 1080;
940        final int outHeight = 720;
941        final int atTime = 2400;
942        long durationToAddObjects = 0;
943        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
944        final String[] loggingInfo = new String[1];
945        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
946            "m1", videoItemFilename, renderingMode);
947        assertNotNull("MediaVideoItem", mediaVideoItem);
948
949        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
950            final long duration1 = SystemClock.uptimeMillis();
951            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
952            final long duration2 = SystemClock.uptimeMillis();
953            durationToAddObjects += (duration2 - duration1);
954        }
955        final float timeTaken = (float)durationToAddObjects *
956            1.0f/(float)NUM_OF_ITERATIONS;
957        loggingInfo[0] = "Time taken for Thumbnail generation :"
958            + timeTaken;
959        writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo);
960    }
961
962    /**
963     *To test ThumbnailList for H264
964     */
965    // TODO : TC_PRF_13
966    @LargeTest
967    public void testThumbnailH264AnIFrame() throws Exception {
968        final String videoItemFilename = INPUT_FILE_PATH +
969            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
970        final int outWidth = 1080;
971        final int outHeight = 720;
972        final int atTime = 3000;
973        int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
974        final String[] loggingInfo = new String[1];
975        long durationToAddObjects = 0;
976
977        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
978            "m1", videoItemFilename, renderingMode);
979        assertNotNull("MediaVideoItem", mediaVideoItem);
980
981        for (int i = 0; i < NUM_OF_ITERATIONS; i++) {
982            final long duration1 = SystemClock.uptimeMillis();
983            mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i);
984            final long duration2 = SystemClock.uptimeMillis();
985            durationToAddObjects += (duration2 - duration1);
986        }
987        final float timeTaken = (float)durationToAddObjects *
988            1.0f/(float)NUM_OF_ITERATIONS;
989        loggingInfo[0] = "Time taken Thumbnail generation :"
990            + timeTaken;
991        writeTimingInfo("testThumbnailH264AnIFrame", loggingInfo);
992    }
993
994    /**
995     * To test the performance : With an audio track
996     *
997     * @throws Exception
998     */
999    // TODO : remove PRF_014
1000    @LargeTest
1001    public void testPerformanceWithAudioTrack() throws Exception {
1002        final String videoItemFileName1 = INPUT_FILE_PATH +
1003            "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
1004        final String audioFilename1 = INPUT_FILE_PATH +
1005            "AACLC_44.1kHz_256kbps_s_1_17.mp4";
1006        final String audioFilename2 = INPUT_FILE_PATH +
1007            "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
1008        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
1009        final int audioVolume = 50;
1010        final String[] loggingInfo = new String[2];
1011        int timeTaken = 0;
1012
1013        final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor,
1014            "mediaItem1", videoItemFileName1, renderingMode);
1015        mVideoEditor.addMediaItem(mediaVideoItem);
1016
1017        final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor,
1018            "Audio Track1", audioFilename1);
1019        audioTrack1.disableDucking();
1020        audioTrack1.setVolume(audioVolume);
1021        mVideoEditor.addAudioTrack(audioTrack1);
1022
1023        long beginTime = SystemClock.uptimeMillis();
1024        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
1025            public void onProgress(Object item, int action, int progress) {
1026            }
1027        });
1028        timeTaken = calculateTimeTaken(beginTime, 1);
1029        loggingInfo[0] = "Time taken for 1st Audio Track (AACLC) :"
1030            + timeTaken;
1031
1032        final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor,
1033            "Audio Track2", audioFilename2);
1034        audioTrack2.enableLoop();
1035
1036        beginTime = SystemClock.uptimeMillis();
1037        mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
1038            public void onProgress(Object item, int action, int progress) {
1039            }
1040        });
1041        timeTaken = calculateTimeTaken(beginTime, 1);
1042        loggingInfo[1] = "\n\tTime taken for 2nd Audio Track(AMRNB) :"
1043            + timeTaken;
1044
1045        writeTimingInfo("testPerformanceWithAudioTrack", loggingInfo);
1046    }
1047
1048    /**
1049     * To test the performance of adding and removing the
1050     * image media item with 640 x 480
1051     *
1052     * @throws Exception
1053     */
1054    // TODO : remove PRF_015
1055    @LargeTest
1056    public void testPerformanceAddRemoveImageItem640x480() throws Exception {
1057        final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
1058        final int imageItemDuration = 0;
1059        final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
1060        final String[] loggingInfo = new String[3];
1061
1062        int timeTaken = 0;
1063
1064        final MediaImageItem[] mediaImageItem =
1065            new MediaImageItem[NUM_OF_ITERATIONS];
1066        long beginTime = SystemClock.uptimeMillis();
1067        createImageItems(mediaImageItem, imageItemFileName, renderingMode,
1068            imageItemDuration);
1069        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1070        loggingInfo[0] = "Time taken to Create  Media Image Item (640x480) :"
1071            + timeTaken;
1072
1073        beginTime = SystemClock.uptimeMillis();
1074        addImageItems(mediaImageItem);
1075        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1076        loggingInfo[1] = "\n\tTime taken to add  Media Image Item (640x480) :"
1077            + timeTaken;
1078
1079        beginTime = SystemClock.uptimeMillis();
1080        removeImageItems(mediaImageItem);
1081        timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS);
1082        loggingInfo[2] = "\n\tTime taken to remove  Media Image Item (640x480) :"
1083            + timeTaken;
1084        writeTimingInfo("testPerformanceAddRemoveImageItem640x480 (in mSec)", loggingInfo);
1085    }
1086
1087
1088}
1089