summaryrefslogtreecommitdiffstats
path: root/media/tests/MediaFrameworkTest
diff options
context:
space:
mode:
authorBasavapatna Dattaguru <dattaguru@google.com>2011-02-13 13:26:46 -0800
committerBasavapatna Dattaguru <dattaguru@google.com>2011-02-14 18:00:57 -0800
commitc0171d3e7b3459168e8db76b7f5d72b07f69f42a (patch)
treea0e5f5c757b67cfb751e28ad4918ab91db695bb4 /media/tests/MediaFrameworkTest
parentb27a1ca53e43c97d206d19c2b219f53690b324eb (diff)
downloadframeworks_base-c0171d3e7b3459168e8db76b7f5d72b07f69f42a.zip
frameworks_base-c0171d3e7b3459168e8db76b7f5d72b07f69f42a.tar.gz
frameworks_base-c0171d3e7b3459168e8db76b7f5d72b07f69f42a.tar.bz2
VideoEditor: IssueID:3396697:Added TN,MP,Exp,API test codes
Updated with review comments: code cleaning in MP. Change-Id: Ide5ee82b24806a52b4e612db4bc3c34f75e4465a
Diffstat (limited to 'media/tests/MediaFrameworkTest')
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java7
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java954
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java734
-rw-r--r--media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java17
-rwxr-xr-xmedia/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java818
5 files changed, 2512 insertions, 18 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
index 1862fd5..be97e90 100755
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java
@@ -33,8 +33,10 @@ import com.android.mediaframeworktest.functional.MediaPresetReverbTest;
import com.android.mediaframeworktest.functional.MediaVirtualizerTest;
import com.android.mediaframeworktest.functional.MediaVisualizerTest;
/*import for VideoEditor Test cases*/
+import com.android.mediaframeworktest.functional.MediaItemThumbnailTest;
+import com.android.mediaframeworktest.functional.MediaPropertiesTest;
import com.android.mediaframeworktest.functional.VideoEditorAPITest;
-
+import com.android.mediaframeworktest.functional.VideoEditorExportTest;
import junit.framework.TestSuite;
import android.test.InstrumentationTestRunner;
@@ -73,7 +75,10 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner {
suite.addTestSuite(MediaVirtualizerTest.class);
suite.addTestSuite(MediaVisualizerTest.class);
/*Test for Video Editor*/
+ suite.addTestSuite(MediaItemThumbnailTest.class);
+ suite.addTestSuite(MediaPropertiesTest.class);
suite.addTestSuite(VideoEditorAPITest.class);
+ suite.addTestSuite(VideoEditorExportTest.class);
return suite;
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java
new file mode 100755
index 0000000..895ca25
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaItemThumbnailTest.java
@@ -0,0 +1,954 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package com.android.mediaframeworktest.functional;
+
+import java.io.File;
+import java.io.IOException;
+
+import android.graphics.Bitmap;
+import android.media.videoeditor.MediaImageItem;
+import android.media.videoeditor.MediaItem;
+import android.media.videoeditor.MediaVideoItem;
+import android.media.videoeditor.VideoEditor;
+import android.os.Environment;
+import android.test.ActivityInstrumentationTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
+import com.android.mediaframeworktest.MediaFrameworkTest;
+import com.android.mediaframeworktest.VideoEditorHelper;
+
+public class MediaItemThumbnailTest extends
+ ActivityInstrumentationTestCase<MediaFrameworkTest> {
+ private final String TAG = "MediaItemThumbailTest";
+
+ private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
+
+ private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
+
+ private VideoEditor mVideoEditor;
+
+ private VideoEditorHelper mVideoEditorHelper;
+
+ public MediaItemThumbnailTest() {
+ super("com.android.mediaframeworktest", MediaFrameworkTest.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // setup for each test case.
+ super.setUp();
+ mVideoEditorHelper = new VideoEditorHelper();
+ // Create a random String which will be used as project path, where all
+ // project related files will be stored.
+ final String projectPath = mVideoEditorHelper.
+ createRandomFile(PROJECT_LOCATION);
+ mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
+ // Clean the directory created as project path
+ mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
+ System.gc();
+ super.tearDown();
+ }
+
+ protected void validateThumbnail(Bitmap thumbNailBmp, int outWidth,
+ int outHeight) throws Exception {
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Height", outHeight, thumbNailBmp.getHeight());
+ assertEquals("Thumbnail Width", outWidth, thumbNailBmp.getWidth());
+ thumbNailBmp.recycle();
+ }
+
+ // -----------------------------------------------------------------
+ // THUMBNAIL
+ // -----------------------------------------------------------------
+ /**
+ * To test thumbnail / frame extraction on H.263 QCIF.
+ */
+ // TODO : TC_TN_001
+ @LargeTest
+ public void testThumbnailForH263QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = mediaVideoItem.getHeight();
+
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on MPEG4 VGA .
+ */
+ // TODO : TC_TN_002
+ @LargeTest
+ public void testThumbnailForMPEG4VGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "MPEG4_SP_640x480_30fps_512Kbps_0_23.3gp";
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = mediaVideoItem.getHeight();
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on MPEG4 NTSC.
+ */
+ // TODO : TC_TN_003
+ @LargeTest
+ public void testThumbnailForMPEG4NTSC() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on MPEG4 WVGA.
+ */
+ // TODO : TC_TN_004
+ @LargeTest
+ public void testThumbnailForMPEG4WVGA() throws Exception {
+
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth() * 2;
+ final int outHeight = mediaVideoItem.getHeight();
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on MPEG4 QCIF.
+ */
+ // TODO : TC_TN_005
+ @LargeTest
+ public void testThumbnailForMPEG4QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth();
+ final int outHeight = mediaVideoItem.getHeight() * 2;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on H264 QCIF.
+ */
+ // TODO : TC_TN_006
+ @LargeTest
+ public void testThumbnailForH264QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_176x144_15fps_144kbps_AMRNB_8kHz_12.2kbps_m_1_17.3gp";
+
+ final int atTime = 0;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth() * 2;
+ final int outHeight = mediaVideoItem.getHeight() * 2;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on H264 VGA.
+ */
+ // TODO : TC_TN_007
+ @LargeTest
+ public void testThumbnailForH264VGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_640x480_30fps_192kbps_1_5.mp4";
+ final int outWidth = 32;
+ final int outHeight = 32;
+ final int atTime = 0;
+
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+ /**
+ * To test thumbnail / frame extraction on H264 WVGA.
+ */
+ // TODO : TC_TN_008
+ @LargeTest
+ public void testThumbnailForH264WVGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int outWidth = 64;
+ final int outHeight = 64;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final long atTime = mediaVideoItem.getDuration() / 2;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on H264 854x480.
+ */
+ // TODO : TC_TN_009
+ @LargeTest
+ public void testThumbnailForH264854_480() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
+ final int outWidth = 128;
+ final int outHeight = 128;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ MediaVideoItem mediaVideoItem = null;
+ mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final long atTime = mediaVideoItem.getDuration() - 1000;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on H264 960x720.
+ */
+ // TODO : TC_TN_010
+ @LargeTest
+ public void testThumbnailForH264HD960() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
+ final int outWidth = 75;
+ final int outHeight = 75;
+
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final long atTime = mediaVideoItem.getDuration() - 1000;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on H264 1080x720 .
+ */
+ // TODO : TC_TN_011
+ @LargeTest
+ public void testThumbnailForH264HD1080() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final long atTime = mediaVideoItem.getDuration() / 4;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * Check the thumbnail / frame extraction precision at 0,100 and 200 ms
+ */
+ // TODO : TC_TN_012
+ @LargeTest
+ public void testThumbnailForH264VGADifferentDuration() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_640x480_30fps_256kbps_1_17.mp4";
+ final int atTime = 0;
+ final int atTime1 = 100;
+ final int atTime2 = 200;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth();
+ final int outHeight = mediaVideoItem.getHeight();
+
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+
+ // get Thumbnail @ 100ms
+ final Bitmap thumbNailBmpAt100 =
+ mediaVideoItem.getThumbnail(outWidth, outHeight, atTime1);
+ validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
+
+ // get Thumbnail @ 200ms
+ final Bitmap thumbNailBmpAt200 = mediaVideoItem.getThumbnail(
+ outWidth, outHeight, atTime2);
+ validateThumbnail(thumbNailBmpAt200, outWidth, outHeight);
+ }
+
+ /**
+ *Check the thumbnail / frame extraction precision at
+ * FileDuration,FileDuration/2 + 100 andFileDuration/2 + 200 ms
+ */
+ // TODO : TC_TN_013
+ @LargeTest
+ public void testThumbnailForMP4VGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, MediaItem.RENDERING_MODE_BLACK_BORDER);
+
+ final int outWidth = mediaVideoItem.getWidth();
+ final int outHeight = mediaVideoItem.getHeight();
+ final long atTime = mediaVideoItem.getDuration() / 2;
+ final long atTime1 = atTime + 100;
+ final long atTime2 = atTime + 200;
+
+ // get Thumbnail @ duration/2
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+
+ // get Thumbnail @ duration/2 + 100ms
+ final Bitmap thumbNailBmpAt100 = mediaVideoItem.getThumbnail(
+ outWidth, outHeight, atTime1);
+ validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
+
+ // get Thumbnail @ duration/2 + 200ms
+ final Bitmap thumbNailBmpAt200 = mediaVideoItem.getThumbnail(
+ outWidth, outHeight, atTime2);
+ validateThumbnail(thumbNailBmpAt200, outWidth, outHeight);
+ }
+
+ /**
+ * Check the thumbnail / frame extraction on JPEG file
+ */
+ // TODO : TC_TN_014
+ @LargeTest
+ public void testThumbnailForImage() throws Exception {
+ final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final int mediaDuration = 1000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ int outWidth = 0;
+ int outHeight = 0;
+
+ final MediaImageItem mii = mVideoEditorHelper.createMediaItem(
+ mVideoEditor, "m1", imageItemFilename, mediaDuration, renderingMode);
+ assertNotNull("Media Image Item is Null", mii);
+ outWidth = mii.getWidth() / 2;
+ outHeight = mii.getHeight() / 2;
+
+ final Bitmap thumbNailBmp = mii.getThumbnail(outWidth,
+ outHeight, mediaDuration);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+ /**
+ *To test ThumbnailList for H263 QCIF
+ */
+ // TODO : TC_TN_015
+ @LargeTest
+ public void testThumbnailListH263QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
+ final int startTime = 0;
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = mediaVideoItem.getWidth() / 4;
+ final int outHeight = mediaVideoItem.getHeight() / 4;
+ final long endTime = mediaVideoItem.getDuration() / 2;
+
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
+ outWidth, outHeight, startTime, endTime, tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for MPEG4 QCIF
+ */
+ // TODO : TC_TN_016
+ @LargeTest
+ public void testThumbnailListMPEG4QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final long startTime = mediaVideoItem.getDuration() / 2;
+ final long endTime = mediaVideoItem.getDuration();
+
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
+ outWidth, outHeight, startTime, endTime, tnCount);
+
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for H264 VGA
+ */
+ // TODO : TC_TN_017
+ @LargeTest
+ public void testThumbnailListH264VGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_640x480_30fps_256kbps_1_17.mp4";
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final long startTime = mediaVideoItem.getDuration() / 3;
+ final long endTime = mediaVideoItem.getDuration() / 2;
+
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
+ outWidth, outHeight, startTime, endTime, tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for H264 WVGA
+ */
+ // TODO : TC_TN_018
+ @LargeTest
+ public void testThumbnailListH264WVGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final long startTime = mediaVideoItem.getDuration() / 3;
+ final long endTime = mediaVideoItem.getDuration() / 2;
+
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
+ outWidth, outHeight, startTime, endTime, tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for H264 VGA ,Time exceeding file duration
+ */
+ // TODO : TC_TN_019
+ @LargeTest
+ public void testThumbnailH264VGAExceedingFileDuration() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_640x480_30fps_256kbps_1_17.mp4";
+ boolean flagForException = false;
+ int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth() / 2;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ final long atTime = mediaVideoItem.getDuration() + 2000;
+ mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Exception in Extracting thumbanil with Invalid Time",
+ flagForException);
+ }
+
+ /**
+ *To test ThumbnailList for VGA Image
+ */
+ // TODO : TC_TN_020
+ @LargeTest
+ public void testThumbnailListVGAImage() throws Exception {
+ final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final int imageItemDuration = 10000;
+ final int startTime = 0;
+ final int endTime = 0;
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaImageItem mediaImageItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ imageItemFilename, imageItemDuration, renderingMode);
+ final int outWidth = mediaImageItem.getWidth() / 2;
+ final int outHeight = mediaImageItem.getHeight() / 2;
+
+ final Bitmap thumbNailBmp[] = mediaImageItem.getThumbnailList
+ (outWidth, outHeight, startTime, endTime, tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for Invalid file path
+ */
+ // TODO : TC_TN_021
+ @LargeTest
+ public void testThumbnailForInvalidFilePath() throws Exception {
+ final String imageItemFileName = INPUT_FILE_PATH + "/sdcard/abc.jpg";
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try{
+ final MediaImageItem mii = new MediaImageItem(mVideoEditor, "m1",
+ imageItemFileName, 3000, renderingMode);
+ }catch (IllegalArgumentException e){
+ flagForException = true;
+ }
+ assertTrue(" Invalid File Path", flagForException);
+ }
+
+ /**
+ * To test thumbnail / frame extraction with setBoundaries
+ */
+ // TODO : TC_TN_022
+ @LargeTest
+ public void testThumbnailForMPEG4WVGAWithSetBoundaries() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
+ final int atTime = 10000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ mediaVideoItem.setExtractBoundaries(1000,
+ (mediaVideoItem.getDuration() - 21000));
+
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ *To test ThumbnailList for H264 WVGA with setExtractboundaries
+ */
+ // TODO : TC_TN_023
+ @LargeTest
+ public void testThumbnailListForH264WVGAWithSetBoundaries() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_1_17.mp4";
+ final int thumbNailStartTime = 10000;
+ final int thumbNailEndTime = 12000;
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+
+ mediaVideoItem.setExtractBoundaries(10000, 12000);
+
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList
+ (outWidth, outHeight, thumbNailStartTime, thumbNailEndTime,
+ tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertTrue("Thumbnail Size", (thumbNailBmp.length > 0) ? true : false);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList for H264 WVGA with count > frame available
+ */
+ // TODO : TC_TN_024
+ @LargeTest
+ public void testThumbnailListForH264WVGAWithCount() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int tnCount = 100;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+ final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
+ final long thumbNailEndTime = thumbNailStartTime + 4000;
+ Bitmap thumbNailBmp[] = null;
+ boolean flagForException = false;
+ try{
+ thumbNailBmp = mediaVideoItem.getThumbnailList(outWidth, outHeight,
+ thumbNailStartTime, thumbNailEndTime, tnCount);
+ }catch (Exception e){
+ assertTrue("Unable to get Thumbnail list", flagForException);
+ }
+ if (thumbNailBmp.length <= tnCount) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail count more than asked", flagForException);
+ }
+
+ /**
+ *To test ThumbnailList for H264 WVGA with startTime > End Time
+ */
+ // TODO : TC_TN_025
+ @LargeTest
+ public void testThumbnailListH264WVGAWithStartGreaterEnd() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final int tnCount = 10;
+ boolean flagForException = false;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+ final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
+ final long thumbNailEndTime = thumbNailStartTime - 1000;
+ try{
+ mediaVideoItem.getThumbnailList(outWidth, outHeight,
+ thumbNailStartTime, thumbNailEndTime, tnCount);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail Extraction where start time > end time",
+ flagForException);
+ }
+
+ /**
+ *To test ThumbnailList TC_TN_026 for H264 WVGA with startTime = End Time
+ */
+ // TODO : TC_TN_026
+ @LargeTest
+ public void testThumbnailListH264WVGAWithStartEqualEnd() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int tnCount = 1;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+ final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
+ final long thumbNailEndTime = thumbNailStartTime;
+ final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(outWidth,
+ outHeight, thumbNailStartTime, thumbNailEndTime, tnCount);
+ assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
+ assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
+ for (int i = 0; i < thumbNailBmp.length; i++) {
+ validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
+ thumbNailBmp[i] = null;
+ }
+ }
+
+ /**
+ *To test ThumbnailList TC_TN_027 for file where video duration is less
+ * than file duration.
+ */
+ // TODO : TC_TN_027
+ @LargeTest
+ public void testThumbnailForVideoDurationLessFileDuration() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = (mediaVideoItem.getHeight() / 2);
+ final long atTime = mediaVideoItem.getDuration() - 2000;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+
+ }
+
+ /**
+ *To test ThumbnailList TC_TN_028 for file which has video part corrupted
+ */
+ // TODO : TC_TN_028
+ @LargeTest
+ public void testThumbnailWithCorruptedVideoPart() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "corrupted_H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth();
+ final int outHeight = mediaVideoItem.getHeight() * 2;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail
+ (outWidth, outHeight, mediaVideoItem.getDuration()/2);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Corrupted File cannot be read", flagForException);
+ }
+
+ /**
+ * Check the thumbnail / frame list extraction for Height as Negative Value
+ */
+ // TODO : TC_TN_029
+ @LargeTest
+ public void testThumbnailWithNegativeHeight() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = -1;
+ final long thumbNailStartTime =
+ mediaVideoItem.getBoundaryBeginTime()/2;
+ final long thumbNailEndTime = mediaVideoItem.getBoundaryEndTime();
+ mediaVideoItem.getThumbnailList(outWidth, outHeight,
+ thumbNailStartTime, thumbNailEndTime, tnCount);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail List with negative Height", flagForException);
+ }
+
+ /**
+ * Check the thumbnail for Height as Zero
+ */
+ // TODO : TC_TN_030
+ @LargeTest
+ public void testThumbnailWithHeightAsZero() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int atTime = 100;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = -1;
+ mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail List with Zero Height", flagForException);
+ }
+
+ /**
+ * Check the thumbnail for Height = 10
+ */
+ // TODO : TC_TN_031
+ @LargeTest
+ public void testThumbnailWithHeight() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int atTime = 1000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = (mediaVideoItem.getWidth() / 2);
+ final int outHeight = 10;
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * Check the thumbnail / frame list extraction for Width as Negative Value
+ */
+ // TODO : TC_TN_032
+ @LargeTest
+ public void testThumbnailWithNegativeWidth() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int tnCount = 10;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = -1;
+ final int outHeight = mediaVideoItem.getHeight();
+ final long thumbNailStartTime =
+ mediaVideoItem.getBoundaryBeginTime()/2;
+ final long thumbNailEndTime = mediaVideoItem.getBoundaryEndTime();
+ mediaVideoItem.getThumbnailList(outWidth, outHeight, thumbNailStartTime,
+ thumbNailEndTime, tnCount);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail List with negative Height", flagForException);
+ }
+
+ /**
+ * Check the thumbnail / frame list extraction for Width zero
+ */
+ // TODO : TC_TN_033
+ @LargeTest
+ public void testThumbnailWithWidthAsZero() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int atTime = 1000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try {
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = 0;
+ final int outHeight = mediaVideoItem.getHeight() / 2;
+ mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail List with Zero Width", flagForException);
+ }
+
+ /**
+ * Check the thumbnail for Width = 10
+ */
+ // TODO : TC_TN_034
+ @LargeTest
+ public void testThumbnailWithWidth() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ final int atTime = 1000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = 10;
+ final int outHeight = mediaVideoItem.getHeight();
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
+ outHeight, atTime);
+ validateThumbnail(thumbNailBmp, outWidth, outHeight);
+ }
+
+ /**
+ * To test thumbnail / frame extraction on MPEG4 (time beyond file duration).
+ */
+ // TODO : TC_TN_035
+ @LargeTest
+ public void testThumbnailMPEG4withMorethanFileDuration() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
+ boolean flagForException = false;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename, renderingMode);
+ final int outWidth = mediaVideoItem.getWidth()/2;
+ final int outHeight = mediaVideoItem.getHeight()/2;
+ final long atTime = mediaVideoItem.getDuration() + 100;
+ try{
+ final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
+ outHeight, atTime);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Thumbnail duration is more than file duration",
+ flagForException);
+ }
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
new file mode 100755
index 0000000..3efa5b2
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaPropertiesTest.java
@@ -0,0 +1,734 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest.functional;
+
+import java.io.File;
+import java.io.IOException;
+
+import android.media.videoeditor.AudioTrack;
+import android.media.videoeditor.MediaImageItem;
+import android.media.videoeditor.MediaItem;
+import android.media.videoeditor.MediaProperties;
+import android.media.videoeditor.MediaVideoItem;
+import android.media.videoeditor.VideoEditor;
+import android.os.Environment;
+import android.test.ActivityInstrumentationTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
+import com.android.mediaframeworktest.MediaFrameworkTest;
+import com.android.mediaframeworktest.VideoEditorHelper;
+
+public class MediaPropertiesTest extends
+ ActivityInstrumentationTestCase<MediaFrameworkTest> {
+ private final String TAG = "MediaPropertiesTest";
+
+ private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
+
+ private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
+
+ private VideoEditor mVideoEditor;
+
+ private VideoEditorHelper mVideoEditorHelper;
+
+ public MediaPropertiesTest() {
+ super("com.android.mediaframeworktest", MediaFrameworkTest.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // setup for each test case.
+ super.setUp();
+ mVideoEditorHelper = new VideoEditorHelper();
+ // Create a random String which will be used as project path,
+ // where all project related files will be stored.
+ final String projectPath = mVideoEditorHelper.
+ createRandomFile(PROJECT_LOCATION);
+ mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
+ // Clean the directory created as project path
+ mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
+ System.gc();
+ super.tearDown();
+ }
+
+ protected void validateVideoProperties(int aspectRatio, int fileType,
+ int videoCodecType, int duration, int videoBitrate, int fps,
+ int videoProfile, int width, int height, int audioCodecType,
+ int audioSamplingFrequency, int audioChannel, int audioBitrate,
+ MediaVideoItem mvi) throws Exception {
+ assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio());
+ assertEquals("File Type Mismatch", fileType, mvi.getFileType());
+ assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
+
+ assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
+ duration, mvi.getDuration(), 10));
+ assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile,
+ mvi.getVideoProfile());
+ assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight());
+ assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth());
+ /** Check FPS with 10% range */
+ assertTrue("fps Mismatch" + mvi.getFps(),
+ mVideoEditorHelper.checkRange(fps, mvi.getFps(), 10));
+
+ assertEquals("AudioType Mismatch ", audioCodecType, mvi.getAudioType());
+ assertEquals("Audio Sampling " + mvi.getAudioSamplingFrequency(),
+ audioSamplingFrequency, mvi.getAudioSamplingFrequency());
+ assertEquals("Audio Channels " + mvi.getAudioChannels(), audioChannel,
+ mvi.getAudioChannels());
+ }
+
+ protected void validateAudioProperties(int audioCodecType, int duration,
+ int audioSamplingFrequency, int audioChannel, int audioBitrate,
+ AudioTrack aT) throws Exception {
+ assertEquals("AudioType Mismatch ", audioCodecType, aT.getAudioType());
+ assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
+ duration, aT.getDuration(), 10));
+ assertEquals("Audio Sampling " + aT.getAudioSamplingFrequency(),
+ audioSamplingFrequency, aT.getAudioSamplingFrequency());
+ assertEquals("Audio Channels " + aT.getAudioChannels(), audioChannel,
+ aT.getAudioChannels());
+ }
+
+ protected void validateImageProperties(int aspectRatio, int fileType,
+ int width, int height, MediaImageItem mii)
+ throws Exception {
+ assertEquals("Aspect Ratio Mismatch", aspectRatio, mii.getAspectRatio());
+ assertEquals("File Type Mismatch", fileType, mii.getFileType());
+ assertEquals("Image height " + mii.getHeight(), height, mii.getHeight());
+ assertEquals("Image width " + mii.getWidth(), width, mii.getWidth());
+ }
+
+
+ /**
+ *To test Media Properties for file MPEG4 854 x 480
+ */
+ // TODO : Remove TC_MP_001
+ @LargeTest
+ public void testPropertiesMPEG4854_480() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_MPEG4;
+ final int duration = 26933;
+ final int videoBitrate = 319000;
+ final int audioBitrate = 48000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 16000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int width = 854;
+ final int height = MediaProperties.HEIGHT_480;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+
+ /**
+ *To test Media Properties for file MPEG4 WVGA
+ */
+ // TODO : Remove TC_MP_002
+ @LargeTest
+ public void testPropertiesMPEGWVGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_MPEG4;
+ final int duration = 26933;
+ final int videoBitrate = 384000;
+ final int audioBitrate = 12800;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AMRNB;
+ final int audioSamplingFrequency = 8000;
+ final int audioChannel = 1;
+ final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int width = 800;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test media properties for MPEG4 720x480 (NTSC) + AAC file.
+ */
+ // TODO : Remove TC_MP_003
+ @LargeTest
+ public void testPropertiesMPEGNTSC() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_MPEG4;
+ final int duration = 26866;
+ final int videoBitrate = 403000;
+ final int audioBitrate = 160000;
+ final int fps = 30;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 48000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int width = 720;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file MPEG4 VGA
+ */
+ // TODO : Remove TC_MP_004
+ @LargeTest
+ public void testPropertiesMPEGVGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_MPEG4;
+ final int duration = 26933;
+ final int videoBitrate = 533000;
+ final int audioBitrate = 128000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 48000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int width = 640;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file MPEG4 QCIF
+ */
+ // TODO : Remove TC_MP_005
+ @LargeTest
+ public void testPropertiesMPEGQCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "MPEG4_SP_176x144_12fps_92kbps_AMRNB_8KHz_12.2kbps_m_0_27.3gp";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
+ final int fileType = MediaProperties.FILE_3GP;
+ final int videoCodecType = MediaProperties.VCODEC_MPEG4;
+ final int duration = 27000;
+ final int videoBitrate = 384000;
+ final int audioBitrate = 12200;
+ final int fps = 12;
+ final int audioCodecType = MediaProperties.ACODEC_AMRNB;
+ final int audioSamplingFrequency = 8000;
+ final int audioChannel = 1;
+ final int videoProfile = MediaProperties.MPEG4_SP_LEVEL_1;
+ final int width = 176;
+ final int height = MediaProperties.HEIGHT_144;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file.
+ */
+ // TODO : Remove TC_MP_006
+ @LargeTest
+ public void testPropertiesH263QCIF() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_16kHz_32kbps_m_0_26.3gp";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
+ final int fileType = MediaProperties.FILE_3GP;
+ final int videoCodecType = MediaProperties.VCODEC_H263;
+ final int duration = 26933;
+ final int videoBitrate = 384000;
+ final int audioBitrate = 64000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 16000;
+ final int audioChannel = 1;
+ final int videoProfile = MediaProperties.H263_PROFILE_0_LEVEL_10;
+ final int width = 176;
+ final int height = MediaProperties.HEIGHT_144;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file H264 VGA
+ */
+ // TODO : Remove TC_MP_007
+ @LargeTest
+ public void testPropertiesH264VGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ final int fileType = MediaProperties.FILE_3GP;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 77600;
+ final int videoBitrate = 745000;
+ final int audioBitrate = 64000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 48000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 640;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file H264 NTSC
+ */
+ // TODO : Remove TC_MP_008
+ @LargeTest
+ public void testPropertiesH264NTSC() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 26880;
+ final int videoBitrate = 244000;
+ final int audioBitrate = 12200;
+ final int fps = 25;
+ final int audioCodecType = MediaProperties.ACODEC_AMRNB;
+ final int audioSamplingFrequency = 8000;
+ final int audioChannel = 1;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 720;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test media properties for H264 800x480 (WVGA) + AAC file.
+ */
+ // TODO : Remove TC_MP_009
+ @LargeTest
+ public void testPropertiesH264WVGA() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 77466;
+ final int videoBitrate = 528000;
+ final int audioBitrate = 38000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 24000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 800;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file H264 HD1280
+ */
+ // TODO : Remove TC_MP_010
+ @LargeTest
+ public void testPropertiesH264HD1280() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 77600;
+ final int videoBitrate = 606000;
+ final int audioBitrate = 48000;
+ final int fps = 15;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 16000;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 1280;
+ final int height = MediaProperties.HEIGHT_720;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test media properties for H264 1080x720 + AAC file
+ */
+ // TODO : Remove TC_MP_011
+ @LargeTest
+ public void testPropertiesH264HD1080WithAudio() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 77500;
+ final int videoBitrate = 1190000;
+ final int audioBitrate = 64000;
+ final int fps = 10;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 44100;
+ final int audioChannel = 2;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 1080;
+ final int height = MediaProperties.HEIGHT_720;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for file WMV - Unsupported type
+ */
+ // TODO : Remove TC_MP_012
+ @LargeTest
+ public void testPropertiesWMVFile() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "WMV_V7_640x480_15fps_512Kbps_wma_V9_44khz_48Kbps_s_1_30.wmv";
+ boolean flagForException = false;
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for a WMV File -- Unsupported file type",
+ flagForException);
+ }
+
+ /**
+ *To test media properties for H.264 Main/Advanced profile. (unsupported profile input)
+ */
+ // TODO : Remove TC_MP_013
+ @LargeTest
+ public void testPropertiesH264MainLineProfile() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH
+ + "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ //final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int videoCodecType = MediaProperties.VCODEC_H264MP;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+
+ try {
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+ assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
+ }catch (IllegalArgumentException e){
+ flagForException = true;
+ }
+ assertTrue("Unsupported Main Profile", flagForException);
+ }
+
+ /**
+ *To test Media Properties for non existing file.
+ */
+ // TODO : Remove TC_MP_014
+ @LargeTest
+ public void testPropertiesForNonExsitingFile() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp";
+ boolean flagForException = false;
+
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for non exsisting file", flagForException);
+ }
+
+ /**
+ *To test Media Properties for file H264 HD1080
+ */
+ // TODO : Remove TC_MP_015
+ @LargeTest
+ public void testPropertiesH264HD1080WithoutAudio() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "H264_BP_1080x720_30fps_800kbps_1_17.mp4";
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
+ final int fileType = MediaProperties.FILE_MP4;
+ final int videoCodecType = MediaProperties.VCODEC_H264BP;
+ final int duration = 77366;
+ final int videoBitrate = 859000;
+ final int audioBitrate = 0;
+ final int fps = 30;
+ final int audioCodecType = -1;
+ final int audioSamplingFrequency = 0;
+ final int audioChannel = 0;
+ final int videoProfile = MediaProperties.H264_PROFILE_0_LEVEL_1_3;
+ final int width = 1080;
+ final int height = MediaProperties.HEIGHT_720;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", videoItemFilename, renderingMode);
+
+ validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
+ videoBitrate, fps, videoProfile, width, height, audioCodecType,
+ audioSamplingFrequency, audioChannel, audioBitrate, mvi);
+ }
+
+ /**
+ *To test Media Properties for Image file of JPEG Type
+ */
+ // TODO : Remove TC_MP_016
+ @LargeTest
+ public void testPropertiesVGAImage() throws Exception {
+ final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final int imageItemDuration = 10000;
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ final int fileType = MediaProperties.FILE_JPEG;
+ final int width = 640;
+ final int height = MediaProperties.HEIGHT_480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+
+ final MediaImageItem mii = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
+ renderingMode);
+ validateImageProperties(aspectRatio, fileType, width, height, mii);
+ }
+
+ /**
+ *To test Media Properties for Image file of PNG Type
+ */
+ // TODO : Remove TC_MP_017
+ @LargeTest
+ public void testPropertiesPNG() throws Exception {
+ final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
+ final int imageItemDuration = 10000;
+ final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
+ final int fileType = MediaProperties.FILE_PNG;
+ final int width = 640;
+ final int height = 480;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final MediaImageItem mii = mVideoEditorHelper.createMediaItem
+ (mVideoEditor, "m1", imageItemFilename, imageItemDuration,
+ renderingMode);
+ validateImageProperties(aspectRatio, fileType, width, height, mii);
+ }
+
+ /**
+ *To test Media Properties for file GIF - Unsupported type
+ */
+ // TODO : Remove TC_MP_018
+ @LargeTest
+ public void testPropertiesGIFFile() throws Exception {
+
+ final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.gif";
+ final int imageItemDuration = 10000;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ boolean flagForException = false;
+ try {
+ new MediaImageItem(mVideoEditor, "m1", imageItemFilename,
+ imageItemDuration, renderingMode);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for a GIF File -- Unsupported file type",
+ flagForException);
+ }
+
+ /**
+ *To test Media Properties for file Text file named as 3GP
+ */
+ // TODO : Remove TC_MP_019
+ @LargeTest
+ public void testPropertiesofDirtyFile() throws Exception {
+
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "Text_FileRenamedTo3gp.3gp";
+ boolean flagForException = false;
+
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for a Dirty File ",
+ flagForException);
+ }
+
+ /**
+ *To test Media Properties for file name as NULL
+ */
+ // TODO : Remove TC_MP_020
+ @LargeTest
+ public void testPropertieNULLFile() throws Exception {
+ final String videoItemFilename = null;
+ boolean flagForException = false;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
+ renderingMode);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for NULL File ",
+ flagForException);
+ }
+
+ /**
+ *To test Media Properties for file which is of type MPEG2
+ */
+ // TODO : Remove TC_MP_021
+ @LargeTest
+ public void testPropertiesMPEG2File() throws Exception {
+ final String videoItemFilename = INPUT_FILE_PATH +
+ "MPEG2_640x480_30fps_192kbps_1_5.mp4";
+ boolean flagForException = false;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
+ renderingMode);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Media Properties for a MPEG2 File --Unsupported file type",
+ flagForException);
+ }
+
+ /**
+ *To test Media Properties TC_MP_023 for file without Video only Audio
+ */
+ // TODO : Remove TC_MP_023
+ @LargeTest
+ public void testProperties3GPWithoutVideoMediaItem() throws Exception {
+ final String audioFilename = INPUT_FILE_PATH +
+ "AACLC_48KHz_256Kbps_s_1_17.3gp";
+ boolean flagForException = false;
+ final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ try {
+ new MediaVideoItem(mVideoEditor, "m1", audioFilename,
+ renderingMode);
+ } catch (IllegalArgumentException e) {
+ flagForException = true;
+ }
+ assertTrue("Exception in Creaing Media Video item object without video",
+ flagForException);
+ }
+
+ /**
+ *To test media properties for Audio Track file. (No Video, AAC Audio)
+ */
+ // TODO : Remove TC_MP_024
+ @LargeTest
+ public void testProperties3GPWithoutVideoAudioTrack() throws Exception {
+
+ final String audioFilename = INPUT_FILE_PATH +
+ "AACLC_44.1kHz_256kbps_s_1_17.mp4";
+ final int duration = 77554;
+ final int audioBitrate = 384000;
+ final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
+ final int audioSamplingFrequency = 44100;
+ final int audioChannel = 2;
+
+ final AudioTrack audioTrack = mVideoEditorHelper.createAudio
+ (mVideoEditor, "a1", audioFilename);
+
+ validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
+ audioChannel, audioBitrate, audioTrack);
+ }
+
+ /**
+ *To test media properties for Audio Track file. MP3 file
+ */
+ // TODO : Remove TC_MP_025
+ @LargeTest
+ public void testPropertiesMP3AudioTrack() throws Exception {
+
+ final String audioFilename = INPUT_FILE_PATH +
+ "MP3_48KHz_128kbps_s_1_17.mp3";
+ final int duration = 77640;
+ final int audioBitrate = 128000;
+ final int audioCodecType = MediaProperties.ACODEC_MP3;
+ final int audioSamplingFrequency = 48000;
+ final int audioChannel = 2;
+
+ final AudioTrack audioTrack = mVideoEditorHelper.createAudio
+ (mVideoEditor, "a1", audioFilename);
+
+ validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
+ audioChannel, audioBitrate, audioTrack);
+ }
+}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java
index 6a87656..0dadaa5 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorAPITest.java
@@ -89,7 +89,6 @@ public class VideoEditorAPITest extends
* To Test Creation of Media Video Item.
*/
// TODO : remove TC_API_001
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItem() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -132,7 +131,6 @@ public class VideoEditorAPITest extends
* the Begin and End Time.
*/
// TODO : remove TC_API_002
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemExtractBoundaries() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -202,7 +200,6 @@ public class VideoEditorAPITest extends
* To test creation of Media Video Item with Set and Get rendering Mode
*/
// TODO : remove TC_API_003
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemRenderingModes() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -247,7 +244,6 @@ public class VideoEditorAPITest extends
* To Test the Media Video API : Set Audio Volume, Get Audio Volume and Mute
*/
// TODO : remove TC_API_005
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemAudioFeatures() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -306,7 +302,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_006
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemGetWaveformData() throws Exception {
@@ -349,7 +344,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_007
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemEffect() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -391,7 +385,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_008
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemTransitions() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -439,7 +432,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_009
- @SuppressWarnings("unused")
@LargeTest
public void testMediaVideoItemOverlays() throws Exception {
final String videoItemFileName = INPUT_FILE_PATH
@@ -1404,8 +1396,6 @@ public class VideoEditorAPITest extends
final Rect endRect1 = new Rect(10, 10, mediaImageItem.getWidth() / 4,
mediaImageItem.getHeight() / 4);
- //kbEffectOnMediaItem.setStartRect(startRect1);
- //kbEffectOnMediaItem.setEndRect(endRect1);
/* Added newly to take care of removal set APIs */
kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_changed",
startRect1, endRect1, 500, 3000);
@@ -1417,7 +1407,6 @@ public class VideoEditorAPITest extends
final Rect zeroRect = new Rect(0, 0, 0, 0);
try {
- //kbEffectOnMediaItem.setStartRect(zeroRect);
kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroStart",
zeroRect, endRect, 500, 3000);
@@ -1428,7 +1417,6 @@ public class VideoEditorAPITest extends
flagForException = false;
try {
- //kbEffectOnMediaItem.setEndRect(zeroRect);
kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroEnd",
startRect, zeroRect, 500, 3000);
} catch (IllegalArgumentException e) {
@@ -1443,7 +1431,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_037
- @SuppressWarnings("unused")
@LargeTest
public void testTransitionFadeBlack() throws Exception {
@@ -1592,7 +1579,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_038
- @SuppressWarnings("unused")
@LargeTest
public void testTransitionCrossFade() throws Exception {
@@ -1744,7 +1730,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_039
- @SuppressWarnings("unused")
@LargeTest
public void testTransitionSliding() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH +
@@ -1935,7 +1920,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_040
- @SuppressWarnings("unused")
@LargeTest
public void testTransitionAlpha() throws Exception {
@@ -2115,7 +2099,6 @@ public class VideoEditorAPITest extends
*/
// TODO : remove TC_API_041
- @SuppressWarnings("unused")
@LargeTest
public void testFrameOverlayVideoItem() throws Exception {
final String videoItemFilename1 = INPUT_FILE_PATH +
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
new file mode 100755
index 0000000..37b1f54
--- /dev/null
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/VideoEditorExportTest.java
@@ -0,0 +1,818 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mediaframeworktest.functional;
+
+import java.io.File;
+
+import android.graphics.Bitmap;
+import android.graphics.Rect;
+import android.media.videoeditor.AudioTrack;
+import android.media.videoeditor.EffectColor;
+import android.media.videoeditor.EffectKenBurns;
+import android.media.videoeditor.MediaImageItem;
+import android.media.videoeditor.MediaItem;
+import android.media.videoeditor.MediaProperties;
+import android.media.videoeditor.MediaVideoItem;
+import android.media.videoeditor.OverlayFrame;
+import android.media.videoeditor.Transition;
+import android.media.videoeditor.TransitionAlpha;
+import android.media.videoeditor.TransitionCrossfade;
+import android.media.videoeditor.TransitionFadeBlack;
+import android.media.videoeditor.TransitionSliding;
+import android.media.videoeditor.VideoEditor;
+import android.media.videoeditor.VideoEditor.ExportProgressListener;
+import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
+import android.os.Environment;
+import android.test.ActivityInstrumentationTestCase;
+
+
+import android.util.Log;
+
+import com.android.mediaframeworktest.MediaFrameworkTest;
+import android.test.suitebuilder.annotation.LargeTest;
+import com.android.mediaframeworktest.VideoEditorHelper;
+
+public class VideoEditorExportTest extends
+ ActivityInstrumentationTestCase<MediaFrameworkTest> {
+ private final String TAG = "TransitionTest";
+
+ private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
+
+ private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
+
+ private VideoEditor mVideoEditor;
+
+ private VideoEditorHelper mVideoEditorHelper;
+
+ // Declares the annotation for Preview Test Cases
+ public @interface TransitionTests {
+ }
+
+ public VideoEditorExportTest() {
+ super("com.android.mediaframeworktest", MediaFrameworkTest.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // setup for each test case.
+ super.setUp();
+ mVideoEditorHelper = new VideoEditorHelper();
+ // Create a random String which will be used as project path, where all
+ // project related files will be stored.
+ final String projectPath =
+ mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
+ mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
+ // Clean the directory created as project path
+ mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
+ System.gc();
+ super.tearDown();
+ }
+
+ /**
+ * To Test export : Merge and Trim different types of Video and Image files
+ */
+ // TODO :remove TC_EXP_001
+ @LargeTest
+ public void testExportMergeTrim() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
+ final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
+ final String videoItemFilename2 = INPUT_FILE_PATH
+ + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final String videoItemFilename3 = INPUT_FILE_PATH
+ + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
+ final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
+ final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/")
+ + ".3gp";
+
+ final MediaVideoItem mediaVideoItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem1.setExtractBoundaries(2000, 7000);
+ mVideoEditor.addMediaItem(mediaVideoItem1);
+
+ final MediaImageItem mediaImageItem2 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem2);
+
+ final MediaVideoItem mediaVideoItem3 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
+ videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem3.setExtractBoundaries(0, 2000);
+ mVideoEditor.addMediaItem(mediaVideoItem3);
+
+ final MediaVideoItem mediaVideoItem4 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
+ videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration()-5000,
+ mediaVideoItem4.getDuration());
+ mVideoEditor.addMediaItem(mediaVideoItem4);
+
+ final MediaImageItem mediaImageItem5 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
+ imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem5);
+
+ final MediaImageItem mediaImageItem6 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
+ imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem6);
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ final long storyBoardDuration = mediaVideoItem1.getTimelineDuration()
+ + mediaImageItem2.getDuration() + mediaVideoItem3.getTimelineDuration()
+ + mediaVideoItem4.getTimelineDuration() + mediaImageItem5.getDuration()
+ + mediaImageItem6.getDuration();
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, storyBoardDuration,
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ *To Test export : With Effect and Overlays on Different Media Items
+ */
+ // TODO :remove TC_EXP_002
+ @LargeTest
+ public void testExportEffectOverlay() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
+ final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
+ final String videoItemFilename2 = INPUT_FILE_PATH
+ + "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
+ final String videoItemFilename3 = INPUT_FILE_PATH
+ + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
+ final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
+ final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+
+ final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
+
+ final MediaVideoItem mediaVideoItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem1.setExtractBoundaries(2000, 7000);
+ mVideoEditor.addMediaItem(mediaVideoItem1);
+
+ final EffectColor effectPink =
+ mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectPink",
+ 0, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
+ mediaVideoItem1.addEffect(effectPink);
+
+ final EffectColor effectNegative =
+ mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative",
+ 3000, 4000, EffectColor.TYPE_NEGATIVE, 0);
+ mediaVideoItem1.addEffect(effectNegative);
+
+ final MediaImageItem mediaImageItem2 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem2);
+
+ final EffectColor effectFifties =
+ mVideoEditorHelper.createEffectItem(mediaImageItem2, "effectFifties",
+ 0, 3000, EffectColor.TYPE_FIFTIES, 0);
+ mediaImageItem2.addEffect(effectFifties);
+
+ final MediaVideoItem mediaVideoItem3 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
+ videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaVideoItem3);
+ mediaVideoItem3.setExtractBoundaries(0, 8000);
+
+ final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile,
+ 640, 480);
+ final OverlayFrame overlayFrame =
+ mVideoEditorHelper.createOverlay(mediaVideoItem3, "overlay",
+ mBitmap, 2000, 5000);
+ mediaVideoItem3.addOverlay(overlayFrame);
+
+ final EffectColor effectGreen =
+ mVideoEditorHelper.createEffectItem(mediaVideoItem3, "effectGreen",
+ 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
+ mediaVideoItem3.addEffect(effectGreen);
+
+ final MediaVideoItem mediaVideoItem4 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
+ videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration()-5000,
+ mediaVideoItem4.getDuration());
+ mVideoEditor.addMediaItem(mediaVideoItem4);
+
+ final EffectColor effectSepia =
+ mVideoEditorHelper.createEffectItem(mediaVideoItem4, "effectSepia",
+ 0, 2000, EffectColor.TYPE_SEPIA, 0);
+ mediaVideoItem4.addEffect(effectSepia);
+
+ final MediaImageItem mediaImageItem5 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
+ imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem5);
+
+ final EffectColor effectGray =
+ mVideoEditorHelper.createEffectItem(mediaImageItem5, "effectGray",
+ 0, 2000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
+ mediaImageItem5.addEffect(effectGray);
+
+ final MediaImageItem mediaImageItem6 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
+ imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem6);
+
+ final EffectColor effectGradient =
+ mVideoEditorHelper.createEffectItem(mediaImageItem6,
+ "effectGradient", 0, 2000, EffectColor.TYPE_GRADIENT,
+ EffectColor.PINK);
+ mediaImageItem6.addEffect(effectGradient);
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ final long storyBoardDuration = mediaVideoItem1.getTimelineDuration()
+ + mediaImageItem2.getDuration()
+ + mediaVideoItem3.getTimelineDuration()
+ + mediaVideoItem4.getTimelineDuration()
+ + mediaImageItem5.getDuration()
+ + mediaImageItem6.getDuration();
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, storyBoardDuration,
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ * To test export : with Image with KenBurnEffect
+ */
+ // TODO : remove TC_EXP_003
+ @LargeTest
+ public void testExportEffectKenBurn() throws Exception {
+ final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+
+ final MediaImageItem mediaImageItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1",
+ imageItemFileName, 5000, imageItemRenderingMode);
+ mVideoEditor.addMediaItem(mediaImageItem);
+
+ final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
+ (mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
+ (mediaImageItem.getWidth() / 2));
+
+ final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
+ mediaImageItem.getHeight());
+
+ final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(
+ mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
+ assertNotNull("EffectKenBurns", kbEffectOnMediaItem);
+ mediaImageItem.addEffect(kbEffectOnMediaItem);
+
+ assertEquals("KenBurn Start Rect", startRect,
+ kbEffectOnMediaItem.getStartRect());
+ assertEquals("KenBurn End Rect", endRect,
+ kbEffectOnMediaItem.getEndRect());
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, mediaImageItem.getDuration(),
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ * To Test Export : With Video and Image and An Audio BackGround Track
+ */
+ // TODO : remove TC_EXP_004
+ @LargeTest
+ public void testExportAudio() throws Exception {
+ final String videoItemFileName = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
+ final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+ final String audioTrackFilename = INPUT_FILE_PATH +
+ "AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaVideoItem.setExtractBoundaries(0, 10000);
+ mVideoEditor.addMediaItem(mediaVideoItem);
+
+ final MediaImageItem mediaImageItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFileName, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaImageItem);
+
+ final AudioTrack audioTrack = mVideoEditorHelper.createAudio(
+ mVideoEditor, "a1", audioTrackFilename);
+ audioTrack.setExtractBoundaries(2000, 5000);
+ mVideoEditor.addAudioTrack(audioTrack);
+
+ audioTrack.disableDucking();
+ audioTrack.enableLoop();
+ audioTrack.setVolume(75);
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, (mediaVideoItem.getTimelineDuration() +
+ mediaImageItem.getDuration()),
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ *To Test export : With Transition on Different Media Items
+ */
+ // TODO :remove TC_EXP_005
+ @LargeTest
+ public void testExportTransition() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
+ final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
+ final String videoItemFilename2 = INPUT_FILE_PATH
+ + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final String videoItemFilename3 = INPUT_FILE_PATH +
+ "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
+
+ final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
+ final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+ final String maskFilename = INPUT_FILE_PATH +
+ "TransitionSpiral_QVGA.jpg";
+
+ final MediaVideoItem mediaItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaItem1.setExtractBoundaries(2000, 7000);
+ mVideoEditor.addMediaItem(mediaItem1);
+
+ final TransitionAlpha transition1 =
+ mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
+ 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
+ mVideoEditor.addTransition(transition1);
+
+ final MediaImageItem mediaItem2 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem2);
+
+ final MediaVideoItem mediaItem3 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
+ videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaItem3.setExtractBoundaries(0, 8000);
+ mVideoEditor.addMediaItem(mediaItem3);
+
+ final TransitionSliding transition2And3 =
+ mVideoEditorHelper.createTSliding("transition2", mediaItem2,
+ mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
+ TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
+ mVideoEditor.addTransition(transition2And3);
+
+ final MediaVideoItem mediaItem4 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
+ videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem4);
+ mediaItem4.setExtractBoundaries(0, 8000);
+
+ final TransitionCrossfade transition3And4 =
+ mVideoEditorHelper.createTCrossFade("transition3", mediaItem3,
+ mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
+ mVideoEditor.addTransition(transition3And4);
+
+ final MediaImageItem mediaItem5 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
+ imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem5);
+
+ final TransitionFadeBlack transition4And5 =
+ mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4,
+ mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
+ mVideoEditor.addTransition(transition4And5);
+
+ final MediaImageItem mediaItem6 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
+ imageItemFilename3, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem6);
+
+ final TransitionSliding transition5And6 =
+ mVideoEditorHelper.createTSliding("transition5", mediaItem5,
+ mediaItem6, 1000/*4000*/, Transition.BEHAVIOR_SPEED_UP,
+ TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
+ mVideoEditor.addTransition(transition5And6);
+
+ final TransitionSliding transition6 =
+ mVideoEditorHelper.createTSliding("transition6", mediaItem6, null,
+ 1000 /*4000*/, Transition.BEHAVIOR_SPEED_UP,
+ TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN);
+ mVideoEditor.addTransition(transition6);
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ final long storyBoardDuration = mediaItem1.getTimelineDuration()
+ + mediaItem2.getTimelineDuration()
+ + mediaItem3.getTimelineDuration() - transition2And3.getDuration()
+ + mediaItem4.getTimelineDuration() - transition3And4.getDuration()
+ + mediaItem5.getTimelineDuration() - transition4And5.getDuration()
+ + mediaItem6.getTimelineDuration() - transition5And6.getDuration();
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, storyBoardDuration,
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ * To Test Export : Without any Media Items in the story Board
+ *
+ * @throws Exception
+ */
+ // TODO :remove TC_EXP_006
+ @LargeTest
+ public void testExportWithoutMediaItems() throws Exception {
+ boolean flagForException = false;
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (IllegalStateException e) {
+ flagForException = true;
+ }
+ assertTrue("Export without any MediaItems", flagForException);
+ }
+
+ /**
+ * To Test Export : With Media Items add and removed in the story Board
+ *
+ * @throws Exception
+ */
+ // TODO :remove TC_EXP_007
+ @LargeTest
+ public void testExportWithoutMediaItemsAddRemove() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH +
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
+ final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
+ final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
+ boolean flagForException = false;
+
+ final MediaVideoItem mediaItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaItem1.setExtractBoundaries(0, 15000);
+ mVideoEditor.addMediaItem(mediaItem1);
+
+ final MediaImageItem mediaItem2 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFilename1, 15000,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem2);
+
+ final TransitionAlpha transition1 =
+ mVideoEditorHelper.createTAlpha("transition1", mediaItem1, mediaItem2,
+ 3000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, false);
+ mVideoEditor.addTransition(transition1);
+
+ final EffectColor effectColor =
+ mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 12000,
+ 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
+ mediaItem2.addEffect(effectColor);
+
+ mVideoEditor.removeMediaItem(mediaItem1.getId());
+ mVideoEditor.removeMediaItem(mediaItem2.getId());
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (IllegalStateException e) {
+ flagForException = true;
+ }
+ assertTrue("Export with MediaItem added and removed", flagForException);
+ }
+
+ /**
+ * To Test Export : With Video and Image : MMS use case
+ *
+ * @throws Exception
+ */
+ // TODO :remove TC_EXP_008
+ @LargeTest
+ public void testExportMMS() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
+ final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
+ final String videoItemFilename2 = INPUT_FILE_PATH
+ + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+
+ final MediaVideoItem mediaItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaItem1.setExtractBoundaries(2000, 7000);
+ mVideoEditor.addMediaItem(mediaItem1);
+
+ final TransitionAlpha transition1 =
+ mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
+ 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
+ mVideoEditor.addTransition(transition1);
+
+ final MediaImageItem mediaItem2 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem2);
+
+ final MediaVideoItem mediaItem3 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
+ videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mediaItem3.setExtractBoundaries(0, 8000);
+ mVideoEditor.addMediaItem(mediaItem3);
+
+ final TransitionSliding transition2And3 =
+ mVideoEditorHelper.createTSliding("transition2", mediaItem2,
+ mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
+ TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
+ mVideoEditor.addTransition(transition2And3);
+
+ final TransitionCrossfade transition3 =
+ mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, null,
+ 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
+ mVideoEditor.addTransition(transition3);
+
+ final EffectColor effectColor =
+ mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 0,
+ 3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
+ mediaItem2.addEffect(effectColor);
+
+ mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_11_9);
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ final long storyBoardDuration = mediaItem1.getTimelineDuration()
+ + mediaItem2.getTimelineDuration() + mediaItem3.getTimelineDuration()
+ - transition2And3.getDuration();
+
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_144, 0, storyBoardDuration,
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ * To Test Export :Media Item having duration of 1 Hour
+ *
+ * @throws Exception
+ */
+ @LargeTest
+ public void testExportDuration1Hour() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH +
+ "H264_BP_640x480_15fps_384kbps_60_0.mp4";
+ final String outFilename = mVideoEditorHelper.createRandomFile(
+ mVideoEditor.getPath() + "/") + ".3gp";
+
+ final MediaVideoItem mediaItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaItem1);
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ }catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0, mediaItem1.getDuration(),
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+
+ /**
+ * To Test Export : Storage location having very less space (Less than 100
+ * KB)
+ *
+ * @throws Exception
+ */
+ @LargeTest
+ public void testExportWithStorageFull() throws Exception {
+ final String videoItemFilename1 = INPUT_FILE_PATH
+ + "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+ boolean flagForException = false;
+
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1,
+ MediaItem.RENDERING_MODE_BLACK_BORDER);
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ flagForException = true;
+ }
+ assertTrue("Error in exporting file due to lack of storage space",
+ flagForException);
+ }
+
+ /**
+ * To Test Export :Two Media Items added
+ *
+ * @throws Exception
+ */
+ @LargeTest
+ public void testExportTwoVideos() throws Exception {
+ final String videoItemFileName = INPUT_FILE_PATH
+ + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
+ final String videoItemFileName1 = INPUT_FILE_PATH +
+ "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
+ final String outFilename = mVideoEditorHelper
+ .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
+
+ final MediaVideoItem mediaVideoItem =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
+ videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaVideoItem);
+
+ final MediaVideoItem mediaVideoItem1 =
+ mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
+ videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
+ mVideoEditor.addMediaItem(mediaVideoItem1);
+
+ mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
+ public void onProgress(Object item, int action, int progress) {
+ }
+ });
+
+ try {
+ final int[] progressUpdate = new int[100];
+ mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
+ MediaProperties.BITRATE_800K, new ExportProgressListener() {
+ int i = 0;
+ public void onProgress(VideoEditor ve, String outFileName,
+ int progress) {
+ progressUpdate[i++] = progress;
+ }
+ });
+ mVideoEditorHelper.checkProgressCBValues(progressUpdate);
+ } catch (Exception e) {
+ assertTrue("Error in Export" + e.toString(), false);
+ }
+ mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
+ MediaProperties.HEIGHT_720, 0,
+ (mediaVideoItem.getDuration()+ mediaVideoItem1.getDuration()),
+ MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
+ mVideoEditorHelper.checkDeleteExistingFile(outFilename);
+ }
+}