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