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 17package com.android.mediaframeworktest.functional.videoeditor; 18 19import java.io.File; 20import java.io.IOException; 21 22import android.media.videoeditor.AudioTrack; 23import android.media.videoeditor.MediaImageItem; 24import android.media.videoeditor.MediaItem; 25import android.media.videoeditor.MediaProperties; 26import android.media.videoeditor.MediaVideoItem; 27import android.media.videoeditor.VideoEditor; 28import android.os.Environment; 29import android.test.ActivityInstrumentationTestCase; 30import android.test.suitebuilder.annotation.LargeTest; 31import com.android.mediaframeworktest.MediaFrameworkTest; 32import com.android.mediaframeworktest.VideoEditorHelper; 33import com.android.mediaframeworktest.MediaProfileReader; 34 35public class MediaPropertiesTest extends 36 ActivityInstrumentationTestCase<MediaFrameworkTest> { 37 private final String TAG = "MediaPropertiesTest"; 38 39 private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; 40 41 private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; 42 43 private VideoEditor mVideoEditor; 44 45 private VideoEditorHelper mVideoEditorHelper; 46 47 public MediaPropertiesTest() { 48 super("com.android.mediaframeworktest", MediaFrameworkTest.class); 49 } 50 51 @Override 52 protected void setUp() throws Exception { 53 // setup for each test case. 54 super.setUp(); 55 mVideoEditorHelper = new VideoEditorHelper(); 56 // Create a random String which will be used as project path, 57 // where all project related files will be stored. 58 final String projectPath = mVideoEditorHelper. 59 createRandomFile(PROJECT_LOCATION); 60 mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath); 61 } 62 63 @Override 64 protected void tearDown() throws Exception { 65 mVideoEditorHelper.destroyVideoEditor(mVideoEditor); 66 // Clean the directory created as project path 67 mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath())); 68 System.gc(); 69 super.tearDown(); 70 } 71 72 protected void validateVideoProperties(int aspectRatio, int fileType, 73 int videoCodecType, int duration, int videoBitrate, int fps, 74 int videoProfile, int videoLevel, int width, int height, int audioCodecType, 75 int audioSamplingFrequency, int audioChannel, int audioBitrate, 76 MediaVideoItem mvi) throws Exception { 77 assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio()); 78 assertEquals("File Type Mismatch", fileType, mvi.getFileType()); 79 assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType()); 80 81 assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange ( 82 duration, mvi.getDuration(), 10)); 83 assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile, 84 mvi.getVideoProfile()); 85 assertEquals("Video Level " + mvi.getVideoLevel(), videoLevel, 86 mvi.getVideoLevel()); 87 assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight()); 88 assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth()); 89 /** Check FPS with 10% range */ 90 assertTrue("fps Mismatch" + mvi.getFps(), 91 mVideoEditorHelper.checkRange(fps, mvi.getFps(), 10)); 92 93 assertEquals("AudioType Mismatch ", audioCodecType, mvi.getAudioType()); 94 assertEquals("Audio Sampling " + mvi.getAudioSamplingFrequency(), 95 audioSamplingFrequency, mvi.getAudioSamplingFrequency()); 96 // PV SW AAC codec always returns number of channels as Stereo. 97 // So we do not assert for number of audio channels for AAC_LC 98 if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) { 99 assertEquals("Audio Channels " + mvi.getAudioChannels(), audioChannel, 100 mvi.getAudioChannels()); 101 } 102 } 103 104 protected void validateAudioProperties(int audioCodecType, int duration, 105 int audioSamplingFrequency, int audioChannel, int audioBitrate, 106 AudioTrack aT) throws Exception { 107 assertEquals("AudioType Mismatch ", audioCodecType, aT.getAudioType()); 108 assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange ( 109 duration, aT.getDuration(), 10)); 110 assertEquals("Audio Sampling " + aT.getAudioSamplingFrequency(), 111 audioSamplingFrequency, aT.getAudioSamplingFrequency()); 112 // PV SW AAC codec always returns number of channels as Stereo. 113 // So we do not assert for number of audio channels for AAC_LC 114 if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) { 115 assertEquals("Audio Channels " + aT.getAudioChannels(), audioChannel, 116 aT.getAudioChannels()); 117 } 118 } 119 120 protected void validateImageProperties(int aspectRatio, int fileType, 121 int width, int height, MediaImageItem mii) 122 throws Exception { 123 assertEquals("Aspect Ratio Mismatch", aspectRatio, mii.getAspectRatio()); 124 assertEquals("File Type Mismatch", fileType, mii.getFileType()); 125 assertEquals("Image height " + mii.getHeight(), height, mii.getHeight()); 126 assertEquals("Image width " + mii.getWidth(), width, mii.getWidth()); 127 } 128 129 130 /** 131 *To test Media Properties for file MPEG4 854 x 480 132 */ 133 // TODO : Remove TC_MP_001 134 @LargeTest 135 public void testPropertiesMPEG4854_480() throws Exception { 136 final String videoItemFilename = INPUT_FILE_PATH 137 + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4"; 138 final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9; 139 final int fileType = MediaProperties.FILE_MP4; 140 final int videoCodecType = MediaProperties.VCODEC_MPEG4; 141 final int duration = 26933; 142 final int videoBitrate = 319000; 143 final int audioBitrate = 48000; 144 final int fps = 15; 145 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 146 final int audioSamplingFrequency = 16000; 147 final int audioChannel = 2; 148 final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple; 149 final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; 150 final int width = 854; 151 final int height = MediaProperties.HEIGHT_480; 152 153 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 154 (mVideoEditor, "m1", videoItemFilename, 155 MediaItem.RENDERING_MODE_BLACK_BORDER); 156 157 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 158 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 159 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 160 } 161 162 163 /** 164 *To test Media Properties for file MPEG4 WVGA 165 */ 166 // TODO : Remove TC_MP_002 167 @LargeTest 168 public void testPropertiesMPEGWVGA() throws Exception { 169 final String videoItemFilename = INPUT_FILE_PATH 170 + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4"; 171 final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3; 172 final int fileType = MediaProperties.FILE_MP4; 173 final int videoCodecType = MediaProperties.VCODEC_MPEG4; 174 final int duration = 26933; 175 final int videoBitrate = 384000; 176 final int audioBitrate = 12800; 177 final int fps = 15; 178 final int audioCodecType = MediaProperties.ACODEC_AMRNB; 179 final int audioSamplingFrequency = 8000; 180 final int audioChannel = 1; 181 final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple; 182 final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; 183 final int width = 800; 184 final int height = MediaProperties.HEIGHT_480; 185 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 186 187 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 188 (mVideoEditor, "m1", videoItemFilename, renderingMode); 189 190 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 191 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 192 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 193 } 194 195 /** 196 *To test media properties for MPEG4 720x480 (NTSC) + AAC file. 197 */ 198 // TODO : Remove TC_MP_003 199 @LargeTest 200 public void testPropertiesMPEGNTSC() throws Exception { 201 final String videoItemFilename = INPUT_FILE_PATH 202 + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4"; 203 final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; 204 final int fileType = MediaProperties.FILE_MP4; 205 final int videoCodecType = MediaProperties.VCODEC_MPEG4; 206 final int duration = 26866; 207 final int videoBitrate = 403000; 208 final int audioBitrate = 160000; 209 final int fps = 30; 210 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 211 final int audioSamplingFrequency = 48000; 212 final int audioChannel = 2; 213 final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple; 214 final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; 215 final int width = 720; 216 final int height = MediaProperties.HEIGHT_480; 217 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 218 219 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 220 (mVideoEditor, "m1", videoItemFilename, renderingMode); 221 222 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 223 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 224 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 225 } 226 227 /** 228 *To test Media Properties for file MPEG4 VGA 229 */ 230 // TODO : Remove TC_MP_004 231 @LargeTest 232 public void testPropertiesMPEGVGA() throws Exception { 233 final String videoItemFilename = INPUT_FILE_PATH 234 + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; 235 final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3; 236 final int fileType = MediaProperties.FILE_MP4; 237 final int videoCodecType = MediaProperties.VCODEC_MPEG4; 238 final int duration = 26933; 239 final int videoBitrate = 533000; 240 final int audioBitrate = 128000; 241 final int fps = 15; 242 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 243 final int audioSamplingFrequency = 48000; 244 final int audioChannel = 2; 245 final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple; 246 final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; 247 final int width = 640; 248 final int height = MediaProperties.HEIGHT_480; 249 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 250 251 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 252 (mVideoEditor, "m1", videoItemFilename, renderingMode); 253 254 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 255 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 256 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 257 } 258 259 /** 260 *To test Media Properties for file MPEG4 QCIF 261 */ 262 // TODO : Remove TC_MP_005 263 @LargeTest 264 public void testPropertiesMPEGQCIF() throws Exception { 265 final String videoItemFilename = INPUT_FILE_PATH 266 + "MPEG4_SP_176x144_12fps_92kbps_AMRNB_8KHz_12.2kbps_m_0_27.3gp"; 267 final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9; 268 final int fileType = MediaProperties.FILE_3GP; 269 final int videoCodecType = MediaProperties.VCODEC_MPEG4; 270 final int duration = 27000; 271 final int videoBitrate = 384000; 272 final int audioBitrate = 12200; 273 final int fps = 12; 274 final int audioCodecType = MediaProperties.ACODEC_AMRNB; 275 final int audioSamplingFrequency = 8000; 276 final int audioChannel = 1; 277 final int videoProfile = MediaProperties.MPEG4Profile.MPEG4ProfileSimple; 278 final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; 279 final int width = 176; 280 final int height = MediaProperties.HEIGHT_144; 281 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 282 283 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 284 (mVideoEditor, "m1", videoItemFilename, renderingMode); 285 286 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 287 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 288 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 289 } 290 291 /** 292 *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file. 293 */ 294 // TODO : Remove TC_MP_006 295 @LargeTest 296 public void testPropertiesH263QCIF() throws Exception { 297 final String videoItemFilename = INPUT_FILE_PATH 298 + "H263_profile0_176x144_15fps_256kbps_AACLC_16kHz_32kbps_m_0_26.3gp"; 299 final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9; 300 final int fileType = MediaProperties.FILE_3GP; 301 final int videoCodecType = MediaProperties.VCODEC_H263; 302 final int duration = 26933; 303 final int videoBitrate = 384000; 304 final int audioBitrate = 64000; 305 final int fps = 15; 306 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 307 final int audioSamplingFrequency = 16000; 308 final int audioChannel = 1; 309 final int videoProfile = MediaProperties.H263Profile.H263ProfileBaseline; 310 final int videoLevel = MediaProperties.H263Level.H263Level10; 311 final int width = 176; 312 final int height = MediaProperties.HEIGHT_144; 313 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 314 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 315 (mVideoEditor, "m1", videoItemFilename, renderingMode); 316 317 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 318 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 319 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 320 } 321 322 /** 323 *To test Media Properties for file H264 VGA 324 */ 325 // TODO : Remove TC_MP_007 326 @LargeTest 327 public void testPropertiesH264VGA() throws Exception { 328 final String videoItemFilename = INPUT_FILE_PATH 329 + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp"; 330 final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3; 331 final int fileType = MediaProperties.FILE_3GP; 332 final int videoCodecType = MediaProperties.VCODEC_H264; 333 final int duration = 77600; 334 final int videoBitrate = 745000; 335 final int audioBitrate = 64000; 336 final int fps = 15; 337 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 338 final int audioSamplingFrequency = 48000; 339 final int audioChannel = 2; 340 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 341 final int videoLevel = MediaProperties.H264Level.H264Level13; 342 final int width = 640; 343 final int height = MediaProperties.HEIGHT_480; 344 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 345 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 346 (mVideoEditor, "m1", videoItemFilename, renderingMode); 347 348 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 349 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 350 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 351 } 352 353 /** 354 *To test Media Properties for file H264 NTSC 355 */ 356 // TODO : Remove TC_MP_008 357 @LargeTest 358 public void testPropertiesH264NTSC() throws Exception { 359 final String videoItemFilename = INPUT_FILE_PATH 360 + "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4"; 361 final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; 362 final int fileType = MediaProperties.FILE_MP4; 363 final int videoCodecType = MediaProperties.VCODEC_H264; 364 final int duration = 26880; 365 final int videoBitrate = 244000; 366 final int audioBitrate = 12200; 367 final int fps = 25; 368 final int audioCodecType = MediaProperties.ACODEC_AMRNB; 369 final int audioSamplingFrequency = 8000; 370 final int audioChannel = 1; 371 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 372 final int videoLevel = MediaProperties.H264Level.H264Level13; 373 final int width = 720; 374 final int height = MediaProperties.HEIGHT_480; 375 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 376 377 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 378 (mVideoEditor, "m1", videoItemFilename, renderingMode); 379 380 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 381 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 382 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 383 } 384 385 /** 386 *To test media properties for H264 800x480 (WVGA) + AAC file. 387 */ 388 // TODO : Remove TC_MP_009 389 @LargeTest 390 public void testPropertiesH264WVGA() throws Exception { 391 final String videoItemFilename = INPUT_FILE_PATH + 392 "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4"; 393 final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3; 394 final int fileType = MediaProperties.FILE_MP4; 395 final int videoCodecType = MediaProperties.VCODEC_H264; 396 final int duration = 77466; 397 final int videoBitrate = 528000; 398 final int audioBitrate = 38000; 399 final int fps = 15; 400 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 401 final int audioSamplingFrequency = 24000; 402 final int audioChannel = 2; 403 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 404 final int videoLevel = MediaProperties.H264Level.H264Level13; 405 final int width = 800; 406 final int height = MediaProperties.HEIGHT_480; 407 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 408 409 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 410 (mVideoEditor, "m1", videoItemFilename, renderingMode); 411 412 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 413 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 414 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 415 } 416 417 /** 418 *To test Media Properties for file H264 HD1280 419 */ 420 // TODO : Remove TC_MP_010 421 @LargeTest 422 public void testPropertiesH264HD1280() throws Exception { 423 final String videoItemFilename = INPUT_FILE_PATH 424 + "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4"; 425 final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9; 426 final int fileType = MediaProperties.FILE_MP4; 427 final int videoCodecType = MediaProperties.VCODEC_H264; 428 final int duration = 77600; 429 final int videoBitrate = 606000; 430 final int audioBitrate = 48000; 431 final int fps = 15; 432 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 433 final int audioSamplingFrequency = 16000; 434 final int audioChannel = 2; 435 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 436 final int videoLevel = MediaProperties.H264Level.H264Level13; 437 final int width = 1280; 438 final int height = MediaProperties.HEIGHT_720; 439 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 440 441 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 442 (mVideoEditor, "m1", videoItemFilename, renderingMode); 443 444 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 445 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 446 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 447 } 448 449 /** 450 *To test media properties for H264 1080x720 + AAC file 451 */ 452 // TODO : Remove TC_MP_011 453 @LargeTest 454 public void testPropertiesH264HD1080WithAudio() throws Exception { 455 final String videoItemFilename = INPUT_FILE_PATH 456 + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4"; 457 final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; 458 final int fileType = MediaProperties.FILE_MP4; 459 final int videoCodecType = MediaProperties.VCODEC_H264; 460 final int duration = 77500; 461 final int videoBitrate = 1190000; 462 final int audioBitrate = 64000; 463 final int fps = 10; 464 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 465 final int audioSamplingFrequency = 44100; 466 final int audioChannel = 2; 467 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 468 final int videoLevel = MediaProperties.H264Level.H264Level13; 469 final int width = 1080; 470 final int height = MediaProperties.HEIGHT_720; 471 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 472 473 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 474 (mVideoEditor, "m1", videoItemFilename, renderingMode); 475 476 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 477 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 478 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 479 } 480 481 /** 482 *To test Media Properties for file WMV - Unsupported type 483 */ 484 // TODO : Remove TC_MP_012 485 @LargeTest 486 public void testPropertiesWMVFile() throws Exception { 487 final String videoItemFilename = INPUT_FILE_PATH + 488 "WMV_V7_640x480_15fps_512Kbps_wma_V9_44khz_48Kbps_s_1_30.wmv"; 489 boolean flagForException = false; 490 if (MediaProfileReader.getWMVEnable() == false) { 491 flagForException = true; 492 } else { 493 try { 494 new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, 495 MediaItem.RENDERING_MODE_BLACK_BORDER); 496 } catch (IllegalArgumentException e) { 497 flagForException = true; 498 } catch (IOException e) { 499 flagForException = true; 500 } 501 } 502 assertTrue("Media Properties for a WMV File -- Unsupported file type", 503 flagForException); 504 } 505 506 /** 507 *To test media properties for H.264 Main/Advanced profile. 508 */ 509 // TODO : Remove TC_MP_013 510 @LargeTest 511 public void testPropertiesH264MainLineProfile() throws Exception { 512 final String videoItemFilename = INPUT_FILE_PATH 513 + "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4"; 514 final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3; 515 final int videoCodecType = MediaProperties.VCODEC_H264; 516 final int fileType = MediaProperties.FILE_MP4; 517 final int duration = 77500; 518 final int videoBitrate = 800000; 519 final int audioBitrate = 192000; 520 final int fps = 25; 521 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 522 final int audioSamplingFrequency = 48000; 523 final int audioChannel = 2; 524 final int videoProfile = MediaProperties.H264Profile.H264ProfileMain; 525 final int videoLevel = MediaProperties.H264Level.H264Level31; 526 final int width = 960; 527 final int height = MediaProperties.HEIGHT_720; 528 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 529 530 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 531 (mVideoEditor, "m1", videoItemFilename, renderingMode); 532 533 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 534 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 535 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 536 537 } 538 539 /** 540 *To test Media Properties for non existing file. 541 */ 542 // TODO : Remove TC_MP_014 543 @LargeTest 544 public void testPropertiesForNonExsitingFile() throws Exception { 545 final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp"; 546 boolean flagForException = false; 547 548 try { 549 new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, 550 MediaItem.RENDERING_MODE_BLACK_BORDER); 551 } catch (IllegalArgumentException e) { 552 flagForException = true; 553 } catch (IOException e) { 554 flagForException = true; 555 } 556 assertTrue("Media Properties for non exsisting file", flagForException); 557 } 558 559 /** 560 *To test Media Properties for file H264 HD1080 561 */ 562 // TODO : Remove TC_MP_015 563 @LargeTest 564 public void testPropertiesH264HD1080WithoutAudio() throws Exception { 565 final String videoItemFilename = INPUT_FILE_PATH + 566 "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; 567 final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; 568 final int fileType = MediaProperties.FILE_MP4; 569 final int videoCodecType = MediaProperties.VCODEC_H264; 570 final int duration = 77366; 571 final int videoBitrate = 859000; 572 final int audioBitrate = 0; 573 final int fps = 30; 574 final int audioCodecType = -1; 575 final int audioSamplingFrequency = 0; 576 final int audioChannel = 0; 577 final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; 578 final int videoLevel = MediaProperties.H264Level.H264Level13; 579 final int width = 1080; 580 final int height = MediaProperties.HEIGHT_720; 581 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 582 583 final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem 584 (mVideoEditor, "m1", videoItemFilename, renderingMode); 585 586 validateVideoProperties(aspectRatio, fileType, videoCodecType, duration, 587 videoBitrate, fps, videoProfile, videoLevel, width, height, audioCodecType, 588 audioSamplingFrequency, audioChannel, audioBitrate, mvi); 589 } 590 591 /** 592 *To test Media Properties for Image file of JPEG Type 593 */ 594 // TODO : Remove TC_MP_016 595 @LargeTest 596 public void testPropertiesVGAImage() throws Exception { 597 final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg"; 598 final int imageItemDuration = 10000; 599 final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3; 600 final int fileType = MediaProperties.FILE_JPEG; 601 final int width = 640; 602 final int height = MediaProperties.HEIGHT_480; 603 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 604 605 final MediaImageItem mii = mVideoEditorHelper.createMediaItem 606 (mVideoEditor, "m1", imageItemFilename, imageItemDuration, 607 renderingMode); 608 validateImageProperties(aspectRatio, fileType, width, height, mii); 609 } 610 611 /** 612 *To test Media Properties for Image file of PNG Type 613 */ 614 // TODO : Remove TC_MP_017 615 @LargeTest 616 public void testPropertiesPNG() throws Exception { 617 final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png"; 618 final int imageItemDuration = 10000; 619 final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3; 620 final int fileType = MediaProperties.FILE_PNG; 621 final int width = 640; 622 final int height = 480; 623 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 624 final MediaImageItem mii = mVideoEditorHelper.createMediaItem 625 (mVideoEditor, "m1", imageItemFilename, imageItemDuration, 626 renderingMode); 627 validateImageProperties(aspectRatio, fileType, width, height, mii); 628 } 629 630 /** 631 *To test Media Properties for file GIF - Unsupported type 632 */ 633 // TODO : Remove TC_MP_018 634 @LargeTest 635 public void testPropertiesGIFFile() throws Exception { 636 637 final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.gif"; 638 final int imageItemDuration = 10000; 639 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 640 boolean flagForException = false; 641 try { 642 new MediaImageItem(mVideoEditor, "m1", imageItemFilename, 643 imageItemDuration, renderingMode); 644 } catch (IllegalArgumentException e) { 645 flagForException = true; 646 } 647 assertTrue("Media Properties for a GIF File -- Unsupported file type", 648 flagForException); 649 } 650 651 /** 652 *To test Media Properties for file Text file named as 3GP 653 */ 654 // TODO : Remove TC_MP_019 655 @LargeTest 656 public void testPropertiesofDirtyFile() throws Exception { 657 658 final String videoItemFilename = INPUT_FILE_PATH + 659 "Text_FileRenamedTo3gp.3gp"; 660 boolean flagForException = false; 661 662 try { 663 new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, 664 MediaItem.RENDERING_MODE_BLACK_BORDER); 665 } catch (IllegalArgumentException e) { 666 flagForException = true; 667 } 668 assertTrue("Media Properties for a Dirty File ", 669 flagForException); 670 } 671 672 /** 673 *To test Media Properties for file name as NULL 674 */ 675 // TODO : Remove TC_MP_020 676 @LargeTest 677 public void testPropertieNULLFile() throws Exception { 678 final String videoItemFilename = null; 679 boolean flagForException = false; 680 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 681 try { 682 new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, 683 renderingMode); 684 } catch (IllegalArgumentException e) { 685 flagForException = true; 686 } 687 assertTrue("Media Properties for NULL File ", 688 flagForException); 689 } 690 691 /** 692 *To test Media Properties for file which is of type MPEG2 693 */ 694 // TODO : Remove TC_MP_021 695 @LargeTest 696 public void testPropertiesMPEG2File() throws Exception { 697 final String videoItemFilename = INPUT_FILE_PATH + 698 "MPEG2_640x480_30fps_192kbps_1_5.mp4"; 699 boolean flagForException = false; 700 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 701 try { 702 new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, 703 renderingMode); 704 } catch (IllegalArgumentException e) { 705 flagForException = true; 706 } 707 assertTrue("Media Properties for a MPEG2 File --Unsupported file type", 708 flagForException); 709 } 710 711 /** 712 *To test Media Properties TC_MP_023 for file without Video only Audio 713 */ 714 // TODO : Remove TC_MP_023 715 @LargeTest 716 public void testProperties3GPWithoutVideoMediaItem() throws Exception { 717 final String audioFilename = INPUT_FILE_PATH + 718 "AACLC_48KHz_256Kbps_s_1_17.3gp"; 719 boolean flagForException = false; 720 final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; 721 try { 722 new MediaVideoItem(mVideoEditor, "m1", audioFilename, 723 renderingMode); 724 } catch (IllegalArgumentException e) { 725 flagForException = true; 726 } 727 assertTrue("Exception in Creaing Media Video item object without video", 728 flagForException); 729 } 730 731 /** 732 *To test media properties for Audio Track file. (No Video, AAC Audio) 733 */ 734 // TODO : Remove TC_MP_024 735 @LargeTest 736 public void testProperties3GPWithoutVideoAudioTrack() throws Exception { 737 738 final String audioFilename = INPUT_FILE_PATH + 739 "AACLC_44.1kHz_256kbps_s_1_17.mp4"; 740 final int duration = 77554; 741 final int audioBitrate = 384000; 742 final int audioCodecType = MediaProperties.ACODEC_AAC_LC; 743 final int audioSamplingFrequency = 44100; 744 final int audioChannel = 2; 745 746 final AudioTrack audioTrack = mVideoEditorHelper.createAudio 747 (mVideoEditor, "a1", audioFilename); 748 749 validateAudioProperties(audioCodecType, duration, audioSamplingFrequency, 750 audioChannel, audioBitrate, audioTrack); 751 } 752 753 /** 754 *To test media properties for Audio Track file. MP3 file 755 */ 756 // TODO : Remove TC_MP_025 757 @LargeTest 758 public void testPropertiesMP3AudioTrack() throws Exception { 759 760 final String audioFilename = INPUT_FILE_PATH + 761 "MP3_48KHz_128kbps_s_1_17.mp3"; 762 final int duration = 77640; 763 final int audioBitrate = 128000; 764 final int audioCodecType = MediaProperties.ACODEC_MP3; 765 final int audioSamplingFrequency = 48000; 766 final int audioChannel = 2; 767 768 final AudioTrack audioTrack = mVideoEditorHelper.createAudio 769 (mVideoEditor, "a1", audioFilename); 770 771 validateAudioProperties(audioCodecType, duration, audioSamplingFrequency, 772 audioChannel, audioBitrate, audioTrack); 773 } 774} 775