diff options
author | Lajos Molnar <lajos@google.com> | 2014-04-21 15:34:02 -0700 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2014-04-21 16:11:51 -0700 |
commit | e0e77cb5bb2885aea3da6823daebf40e06b073bd (patch) | |
tree | d344d6c8b00c9e371d7bf83321d06eac6efff7f3 /media/tests | |
parent | 3fafb4ebf2572578c6d7df742593ee5ed17748a8 (diff) | |
download | frameworks_base-e0e77cb5bb2885aea3da6823daebf40e06b073bd.zip frameworks_base-e0e77cb5bb2885aea3da6823daebf40e06b073bd.tar.gz frameworks_base-e0e77cb5bb2885aea3da6823daebf40e06b073bd.tar.bz2 |
Remove VideoEditor
remove android.media.videoeditor.*
No longer supported and should not be used.
Bug: 13542518
Change-Id: I12de122443f0289ab1dfdd8b553e572a830cf412
Diffstat (limited to 'media/tests')
11 files changed, 0 insertions, 9270 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java index 3d5905d..cfc0881 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkPerfTestRunner.java @@ -17,8 +17,6 @@ package com.android.mediaframeworktest; import com.android.mediaframeworktest.performance.MediaPlayerPerformance; -/*Video Editor performance Test cases*/ -import com.android.mediaframeworktest.performance.VideoEditorPerformance; import junit.framework.TestSuite; import android.os.Bundle; @@ -44,8 +42,6 @@ public class MediaFrameworkPerfTestRunner extends InstrumentationTestRunner { public TestSuite getAllTests() { TestSuite suite = new InstrumentationTestSuite(this); suite.addTestSuite(MediaPlayerPerformance.class); - /* Video Editor performance Test cases */ - suite.addTestSuite(VideoEditorPerformance.class); return suite; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java index cbb6642..a9dc886 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaFrameworkTestRunner.java @@ -32,11 +32,6 @@ import com.android.mediaframeworktest.functional.audio.MediaEqualizerTest; import com.android.mediaframeworktest.functional.audio.MediaPresetReverbTest; import com.android.mediaframeworktest.functional.audio.MediaVirtualizerTest; import com.android.mediaframeworktest.functional.audio.MediaVisualizerTest; -import com.android.mediaframeworktest.functional.videoeditor.MediaItemThumbnailTest; -import com.android.mediaframeworktest.functional.videoeditor.MediaPropertiesTest; -import com.android.mediaframeworktest.functional.videoeditor.VideoEditorAPITest; -import com.android.mediaframeworktest.functional.videoeditor.VideoEditorExportTest; -import com.android.mediaframeworktest.functional.videoeditor.VideoEditorPreviewTest; import junit.framework.TestSuite; import android.os.Bundle; @@ -76,12 +71,6 @@ public class MediaFrameworkTestRunner extends InstrumentationTestRunner { suite.addTestSuite(MediaPresetReverbTest.class); 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); - suite.addTestSuite(VideoEditorPreviewTest.class); return suite; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaPlayerStressTestRunner.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaPlayerStressTestRunner.java index 0cd784c..5438061 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaPlayerStressTestRunner.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaPlayerStressTestRunner.java @@ -19,8 +19,6 @@ package com.android.mediaframeworktest; import android.test.InstrumentationTestRunner; import android.test.InstrumentationTestSuite; import com.android.mediaframeworktest.stress.MediaPlayerStressTest; -/** Import for Video Editor Stress Test cases*/ -import com.android.mediaframeworktest.stress.VideoEditorStressTest; import junit.framework.TestSuite; @@ -30,8 +28,6 @@ public class MediaPlayerStressTestRunner extends InstrumentationTestRunner { public TestSuite getAllTests() { TestSuite suite = new InstrumentationTestSuite(this); suite.addTestSuite(MediaPlayerStressTest.class); - /** Video Editor Stress Test cases*/ - suite.addTestSuite(VideoEditorStressTest.class); return suite; } diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java deleted file mode 100644 index dd7c4c6..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/VideoEditorHelper.java +++ /dev/null @@ -1,479 +0,0 @@ -/* - * 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; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Random; - -import junit.framework.Assert; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.media.videoeditor.AudioTrack; -import android.media.videoeditor.EffectColor; -import android.media.videoeditor.MediaImageItem; -import android.media.videoeditor.MediaItem; -import android.media.videoeditor.MediaVideoItem; -import android.media.videoeditor.OverlayFrame; -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.VideoEditorFactory; -import android.util.Log; -import android.os.Environment; - -/** - * This class has the names of the all the activity name and variables in the - * instrumentation test. - */ -public class VideoEditorHelper extends Assert { - - private final String TAG = "VideoEditorMediaNames"; - - public VideoEditorHelper() { - - } - - public static final String PROJECT_LOCATION_COMMON = - Environment.getExternalStorageDirectory().toString() + "/"; - - public static final String INPUT_FILE_PATH_COMMON = PROJECT_LOCATION_COMMON + - "media_api/videoeditor/"; - - // ----------------------------------------------------------------- - // HELPER METHODS - // ----------------------------------------------------------------- - - /** - * This method creates an object of VideoEditor - * - * @param projectPath the directory where all files related to project will - * be stored - * @param className The class which implements the VideoEditor Class - * @return the object of VideoEditor - */ - public VideoEditor createVideoEditor(String projectPath) { - VideoEditor mVideoEditor = null; - try { - mVideoEditor = VideoEditorFactory.create(projectPath); - assertNotNull("VideoEditor", mVideoEditor); - } catch (Exception e) { - fail("Unable to create Video Editor"); - } - return mVideoEditor; - } - - /** - *This method deletes the VideoEditor object created using - * createVideoEditor method - * - * @param videoEditor the VideoEditor object which needs to be cleaned up - */ - public void destroyVideoEditor(VideoEditor videoEditor) { - // Release VideoEditor - if (videoEditor != null) { - try { - videoEditor.release(); - } catch (Exception e) { - fail("Unable to destory Video Editor"); - } - } - } - - /** - *This Method checks the Range in "RangePercent" (say 10) - * - * @param int Expected data - * @param actual data - * @return boolean flag which confirms the range matching - */ - public boolean checkRange(long expected, long actual, long rangePercent) { - long range = 0; - range = (100 * actual) / expected; - - Log.i("checkRange", "Range = " + range); - if ((range > (100 - rangePercent)) && (range < (100 + rangePercent))) { - return true; - } else { - return false; - } - } - - /** - *This Method Creates a Bitmap with the given input file - * - * @param file the Input whose Bitmap has top be extracted - * @return an Object of EffectColor - */ - public Bitmap getBitmap(String file, int width, int height) throws IOException { - assertNotNull("Bitmap File is Null", file); - FileInputStream inputStream = null; - Bitmap overlayBmp = null; - if (!new File(file).exists()) - throw new IOException("File not Found " + file); - try { - final BitmapFactory.Options dbo = new BitmapFactory.Options(); - dbo.inJustDecodeBounds = true; - dbo.outWidth = width; - dbo.outHeight = height; - File flPtr = new File(file); - inputStream = new FileInputStream(flPtr); - final Bitmap srcBitmap = BitmapFactory.decodeStream(inputStream); - overlayBmp = Bitmap.createBitmap(srcBitmap); - assertNotNull("Bitmap 1", srcBitmap); - assertNotNull("Bitmap 2", overlayBmp); - inputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - return overlayBmp; - } - - /** - *This Method Create a Media Video Item with the specified params - * - * @return an Object of MediaVideoItem - */ - public MediaVideoItem createMediaItem(VideoEditor videoEditor, - String MediaId, String filename, int renderingMode) { - MediaVideoItem mvi = null; - try { - mvi = new MediaVideoItem(videoEditor, MediaId, filename, - renderingMode); - assertNotNull("Can not create an object of MediaVideoItem", mvi); - } catch (IllegalArgumentException e) { - throw new IllegalArgumentException - ("Can not create an object of Media Video Item with file name = " - + filename + " Issue = " + e.toString()); - } catch (IOException e) { - assertTrue - ("Can not create an object of Media Video Item with file name = " - + filename + " Issue = " + e.toString(), false); - } - return mvi; - } - - /** - *This Method Create a Media Image Item with the specified params - * - * @return an Object of MediaImageItem - */ - public MediaImageItem createMediaItem(VideoEditor videoEditor, - String MediaId, String filename, long duration, int renderingMode) { - MediaImageItem mii = null; - try { - mii = new MediaImageItem(videoEditor, MediaId, filename, duration, - renderingMode); - assertNotNull("Can not create an object of MediaImageItem", mii); - - } catch (IllegalArgumentException e) { - assertTrue("Can not create an object of Media Image with file name = " - + filename + " Issue = " + e.toString(), false); - } catch (IOException e) { - assertTrue("Can not create an object of Media Image with file name = " - + filename + " Issue = " + e.toString(), false); - } - return mii; - } - - /** - *This Method Create a Effect with the specified params - * - * @return an Object of EffectColor - */ - public EffectColor createEffectItem(MediaItem mediaItem, String effectId, - long startTime, long duration, int effectType, int colorType) { - EffectColor effectonMVI = null; - effectonMVI = new EffectColor(mediaItem, effectId, startTime, - duration, effectType, colorType); - return effectonMVI; - } - - /** - *This Method creates object of Type Transition Cross fade - * - * @return TransitionCrossfade object - */ - public TransitionCrossfade createTCrossFade(String transitionId, - MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, - int behavior) { - Log.i("TransitionCrossfade Details === ", "Transid ID = " + transitionId + - " Duration= " + durationMs + " Behaviour " + behavior); - - TransitionCrossfade transitionCF = null; - transitionCF = new TransitionCrossfade(transitionId, afterMediaItem, - beforeMediaItem, durationMs, behavior); - return transitionCF; - } - - /** - *This Method creates object of Type TransitionFadeBlack - * - * @return TransitionFadeBlack object - */ - public TransitionFadeBlack createTFadeBlack(String transitionId, - MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, - int behavior) { - TransitionFadeBlack transitionFB = null; - - transitionFB = new TransitionFadeBlack(transitionId, afterMediaItem, - beforeMediaItem, durationMs, behavior); - return transitionFB; - } - - /** - *This Method creates object of Type TransitionSliding - * - * @return TransitionSliding object - */ - public TransitionSliding createTSliding(String transitionId, - MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, - int behavior, int direction) { - TransitionSliding transSlide = null; - transSlide = new TransitionSliding(transitionId, afterMediaItem, - beforeMediaItem, durationMs, behavior, direction); - return transSlide; - } - - /** - *This Method creates object of Type TranistionAlpha - * - * @return TranistionAlpha object - */ - - public TransitionAlpha createTAlpha(String transitionId, - MediaItem afterMediaItem, MediaItem beforeMediaItem, long durationMs, - int behavior, String maskFilename, int blendingPercent, boolean invert) { - TransitionAlpha transA = null; - transA = new TransitionAlpha(transitionId, afterMediaItem, - beforeMediaItem, durationMs, behavior, maskFilename, - blendingPercent, invert); - return transA; - } - - /** - *This Method creates object of Type OverlayFrame - * - * @return OverlayFrame object - */ - - public OverlayFrame createOverlay(MediaItem mediaItem, String overlayId, - Bitmap bitmap, long startTimeMs, long durationMs) { - OverlayFrame overLayFrame = null; - overLayFrame = new OverlayFrame(mediaItem, overlayId, bitmap, - startTimeMs, durationMs); - return overLayFrame; - } - - /** - *This Method creates object of Type AudioTrack - * - * @return OverlayFrame object - */ - public AudioTrack createAudio(VideoEditor videoEditor, String audioTrackId, - String filename) { - AudioTrack audio = null; - try { - audio = new AudioTrack(videoEditor, audioTrackId, filename); - assertNotNull("Cant not create an object of an AudioTrack " + - audioTrackId, audio); - } catch (IllegalArgumentException e) { - assertTrue("Can not create object of an AudioTrack " + - audioTrackId + " Issue = " + e.toString(), false); - } catch (IOException e) { - assertTrue("Can not create object of an AudioTrack " + - audioTrackId + " Issue = " + e.toString(), false); - } - return audio; - } - - /** - *This Method validates the Exported Movie,as per the specified params - * during Export - */ - - public void validateExport(VideoEditor videoEditor, String fileName, - int export_height, int startTime, long endTime, int vCodec, int aCodec) { - File tempFile = new File(fileName); - assertEquals("Exported FileName", tempFile.exists(), true); - final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, - MediaItem.RENDERING_MODE_BLACK_BORDER); - - Log.i(TAG, "VideoCodec for file = " + fileName + - "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + - mvi.getVideoType()); - assertEquals("Export: Video Codec Mismatch for file = " + fileName + - "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), - vCodec, mvi.getVideoType()); - - Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + - export_height + "\tActual VideoHeight = " + mvi.getHeight()); - assertEquals("Export height Mismatch for file " + fileName + - "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), - export_height, mvi.getHeight()); - if (startTime == 0) { - if (endTime != 0) { - Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + - "\t VideoTime= " + mvi.getTimelineDuration()); - assertTrue("Timeline Duration Mismatch for file " + fileName + - "<expected> " + (startTime + endTime) + "\t<actual> " + - mvi.getTimelineDuration(), checkRange((startTime + - endTime), mvi.getTimelineDuration(), 10)); - } - } else { - Log.i(TAG, "TimeLine Expected = " + (endTime - startTime) + - "\t VideoTime= " + mvi.getTimelineDuration()); - assertTrue("Timeline Duration Mismatch for file " + fileName + - "<expected> " + (endTime - startTime) + "\t<actual> " + - mvi.getTimelineDuration(), checkRange((endTime - - startTime), (int)mvi.getTimelineDuration(), 10)); - } - } - - /** - * @param videoEditor - * @param fileName - * @param export_bitrate - * @param export_height - * @param startTime - * @param endTime - * @param vCodec - * @param aCodec - */ - public void validateExport(VideoEditor videoEditor, String fileName, - int export_height, int startTime, int endTime, int vCodec, int aCodec) { - File tempFile = new File(fileName); - assertEquals("Exported FileName", tempFile.exists(), true); - final MediaVideoItem mvi = createMediaItem(videoEditor, "m1", fileName, - MediaItem.RENDERING_MODE_BLACK_BORDER); - Log.i(TAG, "VideoCodec for file = " + fileName + - "\tExpected Video Codec = " + vCodec + "\tActual Video Codec = " + - mvi.getVideoType()); - assertEquals("Export: Video Codec Mismatch for file = " + fileName + - "\t<expected> " + vCodec + "\t<actual> " + mvi.getVideoType(), - vCodec, mvi.getVideoType()); - - Log.i(TAG, "AudioCodec for file = " + fileName + - "\tExpected Audio Codec = " + aCodec + "\tActual Audio Codec = " + - mvi.getAudioType()); - assertEquals("Export: Audio Codec Mismatch for file = " + fileName + - "\t<expected> " + aCodec + "\t<actual> " + mvi.getAudioType(), - aCodec, mvi.getAudioType()); - - Log.i(TAG, "Height for file = " + fileName + "\tExpected Height = " + - export_height + "\tActual VideoHeight = " + mvi.getHeight()); - assertEquals("Export: height Mismatch for file " + fileName + - "\t<expected> " + export_height + "\t<actual> " + mvi.getHeight(), - export_height, mvi.getHeight()); - if (startTime == 0) { - if (endTime != 0) { - Log.i(TAG, "TimeLine Expected = " + (startTime + endTime) + - "\t VideoTime= " + mvi.getTimelineDuration()); - assertTrue("Export :Timeline Duration Mismatch for file " + - fileName + "<expected> " + (startTime + endTime) + - "\t<actual> " + mvi.getTimelineDuration(), - checkRange((startTime + endTime), mvi.getTimelineDuration(), 10)); - } - } else { - Log.i(TAG, "TimeLine Expected = " + (endTime-startTime) + - "\t VideoTime= " + mvi.getTimelineDuration()); - assertTrue("Timeline Duration Mismatch for file " + fileName + - "<expected> " + (endTime - startTime) + "\t<actual> " + - mvi.getTimelineDuration(), checkRange((endTime - - startTime), mvi.getTimelineDuration(), 10)); - } - } - - /** - * Check file and deletes it. - * - * @param filename - */ - public void checkDeleteExistingFile(String filename) { - Log.i(TAG, ">>>>>>>>>>>>>>>>>>checkDeleteExistingFile = " + filename); - if (filename != null) { - File temp = new File(filename); - if (temp != null && temp.exists()) { - temp.delete(); - } - } - } - - /** - * This method creates a Directory and filename - * - * @param location This is path where the file is to be created - * "/sdcard/Output/" - * @return Path in form of /sdcard/Output/200910100000 - */ - public String createRandomFile(String location) { - Random randomGenerator = new Random(); - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssS"); - Date date = new Date(); - final String filePath = location + dateFormat.format(date) + - randomGenerator.nextInt(10); - Log.i(TAG, ">>>>>>>>>>>>>>>>createRandomFile Location= " + location + - "\t FilePath = " + filePath); - return filePath; - } - - /** - * This method recursively deletes all the file and directory - * - * @param directory where the files are located Example = "/sdcard/Input" - * @return boolean True if deletion is successful else False - */ - public boolean deleteProject(File directory) { - Log.i(TAG, ">>>>>>>>>>>>>>>>>>>>>>>>deleteProject directory= " + - directory.toString()); - if (directory.isDirectory()) { - String[] filesInDirecory = directory.list(); - for (int i = 0; i < filesInDirecory.length; i++) { - boolean success = deleteProject(new File(directory, - filesInDirecory[i])); - if (!success) { - return false; - } - } - } - return directory.delete(); - } - - /** - * This method compares the array of Integer from 0 - 100 - * - * @param data set of integer values received as progress - * @return true if sucess else false - */ - public boolean checkProgressCBValues(int[] data) { - boolean retFlag = false; - for (int i = 0; i < 100; i++) { - if (data[i] == 100) { - retFlag = true; - break; - } else { - retFlag = false; - } - } - return retFlag; - } -} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java deleted file mode 100644 index 7dfab7d..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaItemThumbnailTest.java +++ /dev/null @@ -1,921 +0,0 @@ -/* - * 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.videoeditor; - -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. - */ - @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 . - */ - @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. - */ - @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. - */ - @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. - */ - @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. - */ - @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. - */ - @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. - */ - @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. - */ - @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. - */ - @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 . - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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; - } catch (IOException e) { - flagForException = true; - } - assertTrue(" Invalid File Path", flagForException); - } - - /** - * To test thumbnail / frame extraction with setBoundaries - */ - @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 - */ - @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 - */ - @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 = 70; - 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 - */ - @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 for H264 WVGA with startTime = End Time - */ - @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 for file where video duration is less - * than file duration. - */ - @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 for file which has video part corrupted - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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). - */ - @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/videoeditor/MediaPropertiesTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java deleted file mode 100644 index 34cf9f0..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/MediaPropertiesTest.java +++ /dev/null @@ -1,750 +0,0 @@ -/* - * 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.videoeditor; - -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; -import com.android.mediaframeworktest.MediaProfileReader; - -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 videoLevel, 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 Level " + mvi.getVideoLevel(), videoLevel, - mvi.getVideoLevel()); - 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()); - // PV SW AAC codec always returns number of channels as Stereo. - // So we do not assert for number of audio channels for AAC_LC - if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) { - 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()); - // PV SW AAC codec always returns number of channels as Stereo. - // So we do not assert for number of audio channels for AAC_LC - if ( audioCodecType != MediaProperties.ACODEC_AAC_LC ) { - 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 - */ - @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.MPEG4Profile.MPEG4ProfileSimple; - final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - - /** - *To test Media Properties for file MPEG4 WVGA - */ - @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.MPEG4Profile.MPEG4ProfileSimple; - final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test media properties for MPEG4 720x480 (NTSC) + AAC file. - */ - @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.MPEG4Profile.MPEG4ProfileSimple; - final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file MPEG4 VGA - */ - @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.MPEG4Profile.MPEG4ProfileSimple; - final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file MPEG4 QCIF - */ - @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.MPEG4Profile.MPEG4ProfileSimple; - final int videoLevel = MediaProperties.MPEG4Level.MPEG4Level1; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To To test media properties for H263 176x144 (QCIF) + AAC (mono) file. - */ - @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.H263Profile.H263ProfileBaseline; - final int videoLevel = MediaProperties.H263Level.H263Level10; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file H264 VGA - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file H264 NTSC - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test media properties for H264 800x480 (WVGA) + AAC file. - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file H264 HD1280 - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test media properties for H264 1080x720 + AAC file - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for file WMV - Unsupported type - */ - @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; - if (MediaProfileReader.getWMVEnable() == false) { - flagForException = true; - } else { - try { - new MediaVideoItem(mVideoEditor, "m1", videoItemFilename, - MediaItem.RENDERING_MODE_BLACK_BORDER); - } catch (IllegalArgumentException e) { - flagForException = true; - } catch (IOException e) { - flagForException = true; - } - } - assertTrue("Media Properties for a WMV File -- Unsupported file type", - flagForException); - } - - /** - *To test media properties for H.264 Main/Advanced profile. - */ - @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_H264; - final int fileType = MediaProperties.FILE_MP4; - final int duration = 77500; - final int videoBitrate = 800000; - final int audioBitrate = 192000; - final int fps = 25; - final int audioCodecType = MediaProperties.ACODEC_AAC_LC; - final int audioSamplingFrequency = 48000; - final int audioChannel = 2; - final int videoProfile = MediaProperties.H264Profile.H264ProfileMain; - final int videoLevel = MediaProperties.H264Level.H264Level31; - final int width = 960; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - - } - - /** - *To test Media Properties for non existing file. - */ - @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; - } catch (IOException e) { - flagForException = true; - } - assertTrue("Media Properties for non exsisting file", flagForException); - } - - /** - *To test Media Properties for file H264 HD1080 - */ - @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_H264; - 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.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - 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, videoLevel, width, height, audioCodecType, - audioSamplingFrequency, audioChannel, audioBitrate, mvi); - } - - /** - *To test Media Properties for Image file of JPEG Type - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 - */ - @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 for file without Video only Audio - */ - @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) - */ - @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 - */ - @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/videoeditor/VideoEditorAPITest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java deleted file mode 100644 index 6e520c3..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorAPITest.java +++ /dev/null @@ -1,2751 +0,0 @@ -/* - * 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.videoeditor; - -import java.io.File; -import java.util.List; - -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.ExtractAudioWaveformProgressListener; -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.os.Environment; -import android.test.ActivityInstrumentationTestCase; -import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener; - -import android.util.Log; -import java.lang.annotation.Annotation; - -import com.android.mediaframeworktest.MediaFrameworkTest; -import android.test.suitebuilder.annotation.LargeTest; -import com.android.mediaframeworktest.VideoEditorHelper; - -public class VideoEditorAPITest extends - ActivityInstrumentationTestCase<MediaFrameworkTest> { - private final String TAG = "VideoEditorTest"; - - private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; - - private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; - - private final String PROJECT_CLASS_NAME = - "android.media.videoeditor.VideoEditorImpl"; - private VideoEditor mVideoEditor; - private VideoEditorHelper mVideoEditorHelper; - - public VideoEditorAPITest() { - 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 Creation of Media Video Item. - */ - @LargeTest - public void testMediaVideoItem() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode = - MediaItem.RENDERING_MODE_BLACK_BORDER; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - - assertTrue("Media Video ID", - mediaVideoItem1.getId().equals("mediaVideoItem1")); - assertTrue("Media Video Filename", - mediaVideoItem1.getFilename().equals(videoItemFileName)); - assertEquals("Media Video Rendering Mode", - videoItemRenderingMode, mediaVideoItem1.getRenderingMode()); - assertEquals("Media Video Item Duration", mediaVideoItem1.getDuration(), - mediaVideoItem1.getTimelineDuration()); - assertEquals("Media Video Overlay", 0, - mediaVideoItem1.getAllOverlays().size()); - assertEquals("Media Video Effect", 0, - mediaVideoItem1.getAllEffects().size()); - assertNull("Media Video Begin transition", - mediaVideoItem1.getBeginTransition()); - assertNull("Media Video End transition", - mediaVideoItem1.getEndTransition()); - mediaVideoItem1.setExtractBoundaries(1000,11000); - boolean flagForException = false; - if (mediaVideoItem1.getDuration() != - mediaVideoItem1.getTimelineDuration()) { - flagForException = true; - } - assertTrue("Media Video Item Duration & Timeline are same", - flagForException ); - } - - /** - * To test creation of Media Video Item with Set Extract Boundaries With Get - * the Begin and End Time. - */ - @LargeTest - public void testMediaVideoItemExtractBoundaries() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - mediaVideoItem1.setExtractBoundaries(1000, 11000); - assertEquals("Media Item Duration = StoryBoard Duration", - mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); - try { - mediaVideoItem1.setExtractBoundaries(0, 100000000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Set Extract with Invalid Values endTime > FileDuration", - flagForException); - - flagForException = false; - try { - mediaVideoItem1.setExtractBoundaries(100000000, 11000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Set Extract with Invalid Values startTime > endTime", - flagForException); - - flagForException = false; - try { - mediaVideoItem1.setExtractBoundaries(0, 0); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Set Extract with Invalid Values startTime = endTime", - flagForException); - - mediaVideoItem1.setExtractBoundaries(1000, 10000); - assertTrue("Media Item Duration is still the same", - (mediaVideoItem1.getTimelineDuration() == - (mediaVideoItem1.getBoundaryEndTime()- - mediaVideoItem1.getBoundaryBeginTime())) ? true : false); - - mediaVideoItem1.setExtractBoundaries(1,mediaVideoItem1.getDuration()-1); - assertEquals("Media Item Start Time", 1, - mediaVideoItem1.getBoundaryBeginTime()); - assertEquals("Media Item End Time", (mediaVideoItem1.getDuration() - 1), - mediaVideoItem1.getBoundaryEndTime()); - - mediaVideoItem1.setExtractBoundaries(1, mediaVideoItem1.getDuration()); - assertEquals("Media Item Duration = StoryBoard Duration", - mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); - - mediaVideoItem1.setExtractBoundaries(0,mediaVideoItem1.getDuration()/2); - assertEquals("Media Item Duration = StoryBoard Duration", - mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); - - mediaVideoItem1.setExtractBoundaries(0, -1); - assertEquals("Media Item Duration = StoryBoard Duration", - mediaVideoItem1.getTimelineDuration(), mVideoEditor.getDuration()); - } - - /** - * To test creation of Media Video Item with Set and Get rendering Mode - */ - @LargeTest - public void testMediaVideoItemRenderingModes() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode= MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING); - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_CROPPING, - mediaVideoItem1.getRenderingMode()); - try { - mediaVideoItem1.setRenderingMode( - MediaItem.RENDERING_MODE_CROPPING + 911); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Media Item Invalid rendering Mode", flagForException); - flagForException = false; - try { - mediaVideoItem1.setRenderingMode( - MediaItem.RENDERING_MODE_BLACK_BORDER - 11); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Media Item Invalid rendering Mode", flagForException); - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_CROPPING, - mediaVideoItem1.getRenderingMode()); - mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_STRETCH, - mediaVideoItem1.getRenderingMode()); - } - - - /** - * To Test the Media Video API : Set Audio Volume, Get Audio Volume and Mute - */ - @LargeTest - public void testMediaVideoItemAudioFeatures() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - mediaVideoItem1.setVolume(77); - assertEquals("Updated Volume is 77", 77, mediaVideoItem1.getVolume()); - - mediaVideoItem1.setMute(true); - assertTrue("Audio must be Muted", mediaVideoItem1.isMuted()); - - mediaVideoItem1.setVolume(78); - assertEquals("Updated Volume is 78", 78, mediaVideoItem1.getVolume()); - assertTrue("Audio must be Muted", mediaVideoItem1.isMuted()); - - try { - mediaVideoItem1.setVolume(1000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid Set Volume", flagForException); - - mediaVideoItem1.setMute(false); - assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted()); - - mediaVideoItem1.setVolume(0); - assertFalse("Audio must be Un-Muted", mediaVideoItem1.isMuted()); - - flagForException = false; - try { - mediaVideoItem1.setVolume(-1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid Set Volume", flagForException); - - mediaVideoItem1.setVolume(100); - assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume()); - try { - mediaVideoItem1.setVolume(101); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid Set Volume", flagForException); - assertEquals("MediaItem Volume", 100, mediaVideoItem1.getVolume()); - } - - /** - * To Test the Media Video API : GetWaveFormData and - * extractAudioWaveFormData - */ - - @LargeTest - public void testMediaVideoItemGetWaveformData() throws Exception { - - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - assertNull("WaveForm data", mediaVideoItem1.getWaveformData()); - final int[] progressWaveform = new int[105]; - - mediaVideoItem1.extractAudioWaveform(new - ExtractAudioWaveformProgressListener() { - int i = 0; - public void onProgress(int progress) { - Log.i("WaveformData","progress=" +progress); - progressWaveform[i++] = progress; - } - }); - assertTrue("Progress of WaveForm data", mVideoEditorHelper - .checkProgressCBValues(progressWaveform)); - assertNotNull("WaveForm data", mediaVideoItem1.getWaveformData()); - assertTrue("WaveForm Frame Duration", - (mediaVideoItem1.getWaveformData().getFrameDuration() > 0? - true : false)); - assertTrue("WaveForm Frame Count", - (mediaVideoItem1.getWaveformData().getFramesCount() > 0 ? - true : false)); - assertTrue("WaveForm Gain", - (mediaVideoItem1.getWaveformData().getFrameGains().length > 0 ? - true : false)); - - } - - /** - * To Test the Media Video API : Get Effect, GetAllEffects, remove Effect - */ - - @LargeTest - public void testMediaVideoItemEffect() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaVideoItem mediaVideoItem1 = mVideoEditorHelper. - createMediaItem(mVideoEditor, "mediaVideoItem1", videoItemFileName, - videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - assertTrue("Effect List Size", - (mediaVideoItem1.getAllEffects().size() == 0) ? true : false); - assertNull("Effect Item by ID", mediaVideoItem1.getEffect("xyx")); - - final EffectColor effectColor = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, - EffectColor.GRAY); - mediaVideoItem1.addEffect(effectColor); - - assertTrue("Effect List Size", (mediaVideoItem1. - getAllEffects().size() == 1) ? true : false); - assertEquals("Effect Item by Valid ID", effectColor, - mediaVideoItem1.getEffect(effectColor.getId())); - assertNull("Effect Item by Invalid ID", - mediaVideoItem1.getEffect("xyz")); - assertNull("Effect Item by Invalid ID", - mediaVideoItem1.removeEffect("effectId")); - assertTrue("Effect List Size", - (mediaVideoItem1.getAllEffects().size() == 1) ? true : false); - assertEquals("Effect Removed", effectColor, - mediaVideoItem1.removeEffect(effectColor.getId())); - assertTrue("Effect List Size", - (mediaVideoItem1.getAllEffects().size() == 0) ? true : false); - assertNull("Effect Item by ID", mediaVideoItem1.getEffect("effectId")); - } - - /** - * To Test the Media Video API : Get Before and after transition - */ - - @LargeTest - public void testMediaVideoItemTransitions() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - assertNull("Begin Transition", mediaVideoItem1.getBeginTransition()); - assertNull("End Transition", mediaVideoItem1.getEndTransition()); - - TransitionFadeBlack transition1 = - mVideoEditorHelper.createTFadeBlack("transition1", mediaVideoItem1, - null, 0, Transition.BEHAVIOR_SPEED_UP); - mVideoEditor.addTransition(transition1); - assertEquals("Begin transition", transition1, - mediaVideoItem1.getEndTransition()); - - assertNotNull("End Transition", mediaVideoItem1.getEndTransition()); - assertTrue(mediaVideoItem1. - getEndTransition().getId().equals(transition1.getId())); - assertTrue(mediaVideoItem1.getEndTransition().getDuration() == - transition1.getDuration() ? true : false); - assertTrue(mediaVideoItem1.getEndTransition().getBehavior() == - transition1.getBehavior() ? true : false); - - TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack( - "transition2", null,mediaVideoItem1, 0, Transition.BEHAVIOR_LINEAR); - mVideoEditor.addTransition(transition2); - assertNotNull("Begin transition", mediaVideoItem1.getBeginTransition()); - assertEquals("End Transition", transition2, - mediaVideoItem1.getBeginTransition()); - assertTrue(mediaVideoItem1. - getBeginTransition().getId().equals(transition2.getId())); - assertTrue(mediaVideoItem1. getBeginTransition().getDuration() == - transition2.getDuration() ? true : false); - assertTrue(mediaVideoItem1.getBeginTransition().getBehavior() == - transition2.getBehavior() ? true : false); - } - - /** - * To Test the Media Video API : Get All Overlay, Get Overlay and remove Overlay - * - */ - - @LargeTest - public void testMediaVideoItemOverlays() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp"; - final String overlayItemFileName = INPUT_FILE_PATH + - "IMG_176x144_Overlay1.png"; - final int videoItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - assertTrue("Overlay List Size", - (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false); - assertNull("Overlay Item by ID", mediaVideoItem1.getOverlay("xyz")); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, - 176, 144); - final OverlayFrame overlayFrame = mVideoEditorHelper.createOverlay( - mediaVideoItem1, "overlayId", mBitmap, 5000, 5000); - mediaVideoItem1.addOverlay(overlayFrame); - - assertTrue("Overlay List Size", - (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false); - assertEquals("Overlay Item by Valid ID", overlayFrame, mediaVideoItem1 - .getOverlay(overlayFrame.getId())); - assertNull("Overlay Item by Invalid ID", - mediaVideoItem1.getOverlay("xyz")); - assertNull("Overlay Item by Invalid ID", - mediaVideoItem1.removeOverlay("xyz")); - assertTrue("Overlay List Size", - (mediaVideoItem1.getAllOverlays().size() == 1) ? true : false); - assertEquals("Overlay Removed", overlayFrame, - mediaVideoItem1.removeOverlay(overlayFrame.getId())); - assertTrue("Overlay List Size", - (mediaVideoItem1.getAllOverlays().size() == 0) ? true : false); - assertNull("Overlay Item by ID",mediaVideoItem1.getOverlay("effectId")); - } - - /** - * To Test Creation of Media Image Item. - */ - @LargeTest - public void testMediaImageItem() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, 5000, imageItemRenderingMode); - assertTrue("Media Image ID", - mediaImageItem1.getId().equals("mediaImageItem1")); - assertTrue("Media IMage Filename", - mediaImageItem1.getFilename().equals(imageItemFileName)); - assertEquals("Media Image Rendering Mode", - imageItemRenderingMode, mediaImageItem1.getRenderingMode()); - assertEquals("Media Image Item Duration", mediaImageItem1.getDuration(), - mediaImageItem1.getTimelineDuration()); - assertEquals("Media Image Overlay", 0, - mediaImageItem1.getAllOverlays().size()); - assertEquals("Media Image Effect", 0, - mediaImageItem1.getAllEffects().size()); - assertNull("Media Image Begin transition", - mediaImageItem1.getBeginTransition()); - assertNull("Media Image End transition", - mediaImageItem1.getEndTransition()); - assertEquals("Media Image Scaled Height", MediaProperties.HEIGHT_720, - mediaImageItem1.getScaledHeight()); - assertEquals("Media Image Scaled Width", 960, - mediaImageItem1.getScaledWidth()); - assertEquals("Media Image Aspect Ratio", MediaProperties.ASPECT_RATIO_4_3, - mediaImageItem1.getAspectRatio()); - assertNotNull("Media Image Thumbnail", - mediaImageItem1.getThumbnail(960, MediaProperties.HEIGHT_720, 2000)); - } - - /** - * To Test the Media Image API : Get and Set rendering Mode - */ - @LargeTest - public void testMediaImageItemRenderingModes() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, imageItemRenderingMode, 5000); - mVideoEditor.addMediaItem(mediaImageItem1); - - mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_CROPPING); - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_CROPPING, mediaImageItem1.getRenderingMode()); - try { - mediaImageItem1.setRenderingMode( - MediaItem.RENDERING_MODE_CROPPING + 911); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Media Item Invalid rendering Mode", flagForException); - - flagForException = false; - try { - mediaImageItem1.setRenderingMode( - MediaItem.RENDERING_MODE_BLACK_BORDER - 11); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Media Item Invalid rendering Mode", flagForException); - - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_CROPPING, - mediaImageItem1.getRenderingMode()); - mediaImageItem1.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); - assertEquals("MediaVideo Item rendering Mode", - MediaItem.RENDERING_MODE_STRETCH, - mediaImageItem1.getRenderingMode()); - } - - /** - * To Test the Media Image API : GetHeight and GetWidth - */ - @LargeTest - public void testMediaImageItemHeightWidth() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, imageItemRenderingMode, 5000); - mVideoEditor.addMediaItem(mediaImageItem1); - - assertEquals("Image Height = Image Scaled Height", - mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight()); - assertEquals("Image Width = Image Scaled Width", - mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth()); - } - - - -/** This Test Case can be removed as this is already checked in TC 010 */ - /** - * To Test the Media Image API : Scaled Height and Scaled GetWidth - */ - @LargeTest - public void testMediaImageItemScaledHeightWidth() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, imageItemRenderingMode, 5000); - mVideoEditor.addMediaItem(mediaImageItem1); - - assertNotSame("Image Height = Image Scaled Height", - mediaImageItem1.getScaledHeight(), mediaImageItem1.getHeight()); - assertNotSame("Image Width = Image Scaled Width", - mediaImageItem1.getScaledWidth(), mediaImageItem1.getWidth()); - } - - /** - * To Test the Media Image API : Get Effect, GetAllEffects, remove Effect - */ - - @LargeTest - public void testMediaImageItemEffect() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, 5000, imageItemRenderingMode); - mVideoEditor.addMediaItem(mediaImageItem1); - - assertTrue("Effect List Size", - (mediaImageItem1.getAllEffects().size() == 0) ? true : false); - assertNull("Effect Item by ID", mediaImageItem1.getEffect("xyx")); - - final EffectColor effectColor = - mVideoEditorHelper.createEffectItem(mediaImageItem1, - "Effecton MVi1", 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY); - mediaImageItem1.addEffect(effectColor); - - assertTrue("Effect List Size", - (mediaImageItem1.getAllEffects().size() == 1) ? true : false); - assertEquals("Effect Item by Valid ID", - effectColor, mediaImageItem1.getEffect(effectColor.getId())); - assertNull("Effect Item by Invalid ID", - mediaImageItem1.getEffect("xyz")); - assertNull("Effect Item by Invalid ID", - mediaImageItem1.removeEffect("effectId")); - assertTrue("Effect List Size", - (mediaImageItem1.getAllEffects().size() == 1) ? true : false); - assertEquals("Effect Removed", effectColor, - mediaImageItem1.removeEffect(effectColor.getId())); - assertTrue("Effect List Size", - (mediaImageItem1.getAllEffects().size() == 0) ? true : false); - assertNull("Effect Item by ID", mediaImageItem1.getEffect("effectId")); - } - - /** - * To Test the Media Image API : Get Before and after transition - */ - - @LargeTest - public void testMediaImageItemTransitions() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, 5000, imageItemRenderingMode); - mVideoEditor.addMediaItem(mediaImageItem1); - - assertNull("Begin Transition", mediaImageItem1.getBeginTransition()); - assertNull("End Transition", mediaImageItem1.getEndTransition()); - - TransitionFadeBlack transition1 = - mVideoEditorHelper.createTFadeBlack("transition1", mediaImageItem1, - null, 0, Transition.BEHAVIOR_SPEED_UP); - mVideoEditor.addTransition(transition1); - - assertEquals("Begin transition", transition1, - mediaImageItem1.getEndTransition()); - assertNotNull("End Transition", mediaImageItem1.getEndTransition()); - assertTrue(mediaImageItem1.getEndTransition().getId().equals - (transition1.getId())); - assertTrue(mediaImageItem1.getEndTransition().getDuration() == - transition1.getDuration() ? true : false); - assertTrue(mediaImageItem1.getEndTransition().getBehavior() == - transition1.getBehavior() ? true : false); - - TransitionFadeBlack transition2 = mVideoEditorHelper.createTFadeBlack( - "transition2",null, mediaImageItem1, 0, Transition.BEHAVIOR_SPEED_UP); - mVideoEditor.addTransition(transition2); - - assertNotNull("Begin transition", mediaImageItem1.getBeginTransition()); - assertEquals("End Transition", transition2, - mediaImageItem1.getBeginTransition()); - assertTrue(mediaImageItem1.getBeginTransition().getId().equals( - transition2.getId())); - assertTrue(mediaImageItem1.getBeginTransition().getDuration() == - transition2.getDuration() ? true : false); - assertTrue(mediaImageItem1.getBeginTransition().getBehavior() == - transition2.getBehavior() ? true : false); - } - - /** - * To Test the Media Image API : Get All Overlay, Get Overlay and remove - * Overlay - */ - - @LargeTest - public void testMediaImageItemOverlays() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String overlayItemFileName = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, 12000, imageItemRenderingMode); - mVideoEditor.addMediaItem(mediaImageItem1); - - assertTrue("Overlay List Size", - (mediaImageItem1.getAllOverlays().size() == 0) ? true : false); - assertNull("Overlay Item by ID", mediaImageItem1.getOverlay("xyz")); - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayItemFileName, - 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId", - mBitmap, 5000, 5000); - mediaImageItem1.addOverlay(overlayFrame); - - assertTrue("Overlay List Size", - (mediaImageItem1.getAllOverlays().size() == 1) ? true : false); - assertEquals("Overlay Item by Valid ID", overlayFrame, mediaImageItem1 - .getOverlay(overlayFrame.getId())); - assertNull("Overlay Item by Invalid ID", - mediaImageItem1.getOverlay("xyz")); - assertNull("Remove Overlay Item by Invalid ID", - mediaImageItem1.removeOverlay("xyz")); - assertTrue("Overlay List Size", - (mediaImageItem1.getAllOverlays().size() == 1) ? true : false); - assertEquals("Overlay Removed", - overlayFrame, mediaImageItem1.removeOverlay(overlayFrame.getId())); - assertTrue("Overlay List Size", - (mediaImageItem1.getAllOverlays().size() == 0) ? true : false); - assertNull("Overlay Item by ID", - mediaImageItem1.getOverlay("effectId")); - } - - /** - * To test creation of Audio Track - */ - - @LargeTest - public void testAudioTrack() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - assertEquals("Audio Track Item Duration", audioTrack.getDuration(), - audioTrack.getTimelineDuration()); - assertEquals("Audio Track Start Time", 0, audioTrack.getStartTime()); - assertFalse("Audio Track is Looping", audioTrack.isLooping()); - audioTrack.getVolume(); - assertFalse("Audio Track Ducking is Disabled", - audioTrack.isDuckingEnabled()); - assertTrue("Audio Track Filename", - audioTrack.getFilename().equals(audioFileName)); - assertEquals("Audio Ducking Threshold", 0, - audioTrack.getDuckingThreshhold()); - assertFalse("Audio Track Mute", audioTrack.isMuted()); - audioTrack.getDuckedTrackVolume(); - } - - /** - * To test creation of Audio Track with set extract boundaries - */ - @LargeTest - public void testAudioTrackExtractBoundaries() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - audioTrack.setExtractBoundaries(1000, 5000); - assertEquals("Audio Track Start time", 1000, - audioTrack.getBoundaryBeginTime()); - assertEquals("Audio Track End time", 5000, - audioTrack.getBoundaryEndTime()); - try { - audioTrack.setExtractBoundaries(0, 100000000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Audio Track With endTime > FileDuration", flagForException); - flagForException = false; - try { - audioTrack.setExtractBoundaries(100000000, 5000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Audio Track With startTime > FileDuration", - flagForException); - flagForException = false; - try { - audioTrack.setExtractBoundaries(0, 0); - } catch (IllegalArgumentException e) { - flagForException = true; - } - /* This is under discussion. Hence, checked for False */ - assertFalse("Audio Track With startTime = endTime", flagForException); - assertEquals("Audio Track Start time", 0, - audioTrack.getBoundaryBeginTime()); - assertEquals("Audio Track End time", 0, - audioTrack.getBoundaryEndTime()); - assertEquals("Audio Track Start time",0, - audioTrack.getBoundaryBeginTime()); - assertEquals("Audio Track End time", (audioTrack.getTimelineDuration()), - audioTrack.getBoundaryEndTime()); - audioTrack.setExtractBoundaries(0, audioTrack.getDuration() / 2); - assertEquals("Audio Track Start time",0, - audioTrack.getBoundaryBeginTime()); - assertEquals("Audio Track End time", (audioTrack.getDuration() / 2), - audioTrack.getBoundaryEndTime()); - audioTrack.setExtractBoundaries(1, audioTrack.getDuration() - 1); - assertEquals("Audio Track Start time", 1, - audioTrack.getBoundaryBeginTime()); - assertEquals("Audio Track End time", (audioTrack.getDuration() - 1), - audioTrack.getBoundaryEndTime()); - - flagForException = false; - try { - audioTrack.setExtractBoundaries(0, -1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue ("Audio Track end time < 0",flagForException); - } - - /** - * To test creation of Audio Track with set Start Time and Get Time - */ - @LargeTest - public void testAudioTrackSetGetTime() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - /** set StartTime API is removed and start time is always 0 */ - assertEquals("Audio Track Start Time", 0, audioTrack.getStartTime()); - } - - /** - * To Test the Audio Track API: Enable Ducking - */ - @LargeTest - public void testAudioTrackEnableDucking() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - assertFalse("Audio Ducking Disabled by default", - audioTrack.isDuckingEnabled()); - audioTrack.enableDucking(45, 70); - assertTrue("Audio Ducking Enabled", audioTrack.isDuckingEnabled()); - assertEquals("Audio Ducking Threshold", 45, - audioTrack.getDuckingThreshhold()); - assertEquals("Audio Ducking Volume", 70, - audioTrack.getDuckedTrackVolume()); - audioTrack.enableDucking(85, 70); - assertEquals("Audio Ducking Threshold", 85, - audioTrack.getDuckingThreshhold()); - assertEquals("Audio Ducking Volume", 70, - audioTrack.getDuckedTrackVolume()); - try { - audioTrack.enableDucking(91, 70); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Enable ducking threshold > 90", flagForException); - flagForException = false; - try { - audioTrack.enableDucking(90, 101); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Enable ducking volume > 100", flagForException); - flagForException = false; - try { - audioTrack.enableDucking(91, 101); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Enable ducking volume > 100 and threshold > 91", - flagForException); - flagForException = false; - try { - audioTrack.enableDucking(-1, 100); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Enable ducking threshold < 0", flagForException); - flagForException = false; - try { - audioTrack.enableDucking(1, -1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Enable ducking lowVolume < 0", flagForException); - flagForException = false; - try { - audioTrack.enableDucking(0, 50); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertFalse("Enable ducking threshold = 0", flagForException); - } - - /** - * To Test the Audio Track API: Looping - */ - @LargeTest - public void testAudioTrackLooping() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - assertFalse("Audio Looping", audioTrack.isLooping()); - audioTrack.enableLoop(); - assertTrue("Audio Looping", audioTrack.isLooping()); - audioTrack.disableLoop(); - assertFalse("Audio Looping", audioTrack.isLooping()); - } - - /** - * To Test the Audio Track API:Extract waveform data - */ - - @LargeTest - public void testAudioTrackWaveFormData() throws Exception { - /** Image item is added as dummy as Audio track cannot be added without - * a media item in the story board - */ - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1", - imageItemFileName, 5000, imageItemRenderingMode); - mVideoEditor.addMediaItem(mediaImageItem); - - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - - mVideoEditor.addAudioTrack(audioTrack); - assertNull("WaveForm data", audioTrack.getWaveformData()); - - final int[] progressUpdate = new int[105]; - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - int i = 0; - public void onProgress(Object item, int action, int progress) { - progressUpdate[i++] = progress; - } - }); - - final int[] progressWaveform = new int[105]; - - audioTrack.extractAudioWaveform( - new ExtractAudioWaveformProgressListener() { - int i = 0; - public void onProgress(int progress) { - Log.i("AudioWaveformData","progress=" +progress); - progressWaveform[i++] = progress; - } - }); - assertTrue("Progress of WaveForm data", mVideoEditorHelper - .checkProgressCBValues(progressWaveform)); - assertNotNull("WaveForm data", audioTrack.getWaveformData()); - assertTrue("WaveForm Frame Duration", - (audioTrack.getWaveformData().getFrameDuration() > 0 ? - true : false)); - assertTrue("WaveForm Frame Count", - (audioTrack.getWaveformData().getFramesCount() > 0 ? true : false)); - assertTrue("WaveForm Gain", - (audioTrack.getWaveformData().getFrameGains().length > 0 ? - true : false)); - } - - /** - * To Test the Audio Track API: Mute - */ - @LargeTest - public void testAudioTrackMute() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - assertFalse("Audio Track UnMute", audioTrack.isMuted()); - audioTrack.setMute(true); - assertTrue("Audio Track Mute", audioTrack.isMuted()); - audioTrack.setMute(false); - assertFalse("Audio Track UnMute", audioTrack.isMuted()); - } - - /** - * To Test the Audio Track API: Get Volume and Set Volume - */ - @LargeTest - public void testAudioTrackGetSetVolume() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - audioTrack.setVolume(0); - assertEquals("Audio Volume", 0, audioTrack.getVolume()); - assertFalse("Audio Track UnMute", audioTrack.isMuted()); - audioTrack.setVolume(45); - assertEquals("Audio Volume", 45, audioTrack.getVolume()); - assertFalse("Audio Track UnMute", audioTrack.isMuted()); - try { - audioTrack.setVolume(-1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Volume = -1", flagForException); - assertEquals("Audio Volume", 45, audioTrack.getVolume()); - flagForException = false; - try { - audioTrack.setVolume(101); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Volume = 101", flagForException); - flagForException = false; - try { - audioTrack.setVolume(1000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Volume = 10000", flagForException); - assertEquals("Audio Volume", 45, audioTrack.getVolume()); - } - - /** - * To test Effect Color. - */ - @LargeTest - public void testAllEffects() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect1", 1000, 1000, EffectColor.TYPE_COLOR, - EffectColor.PINK); - mediaVideoItem1.addEffect(effectColor1); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor1.getMediaItem()); - assertTrue("Effect Id", effectColor1.getId().equals("effect1")); - assertEquals("Effect StartTime", 1000, effectColor1.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor1.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_COLOR, - effectColor1.getType()); - assertEquals("Effect Color", EffectColor.PINK, effectColor1.getColor()); - - final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect2", 2000, 1000, EffectColor.TYPE_COLOR, - EffectColor.GRAY); - mediaVideoItem1.addEffect(effectColor2); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor2.getMediaItem()); - assertTrue("Effect Id", effectColor2.getId().equals("effect2")); - assertEquals("Effect StartTime", 2000, effectColor2.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor2.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_COLOR, - effectColor2.getType()); - assertEquals("Effect Color", EffectColor.GRAY, effectColor2.getColor()); - - final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect3", 3000, 1000, EffectColor.TYPE_COLOR, - EffectColor.GREEN); - mediaVideoItem1.addEffect(effectColor3); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor3.getMediaItem()); - assertTrue("Effect Id", effectColor3.getId().equals("effect3")); - assertEquals("Effect StartTime", 3000, effectColor3.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor3.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_COLOR, - effectColor3.getType()); - assertEquals("Effect Color", EffectColor.GREEN, effectColor3.getColor()); - - final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect4", 4000, 1000, EffectColor.TYPE_GRADIENT, - EffectColor.PINK); - mediaVideoItem1.addEffect(effectColor4); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor4.getMediaItem()); - assertTrue("Effect Id", effectColor4.getId().equals("effect4")); - assertEquals("Effect StartTime", 4000, effectColor4.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor4.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, - effectColor4.getType()); - assertEquals("Effect Color", EffectColor.PINK, effectColor4.getColor()); - - final EffectColor effectColor5 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect5", 5000, 1000, - EffectColor.TYPE_GRADIENT, EffectColor.GRAY); - mediaVideoItem1.addEffect(effectColor5); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor5.getMediaItem()); - assertTrue("Effect Id", effectColor5.getId().equals("effect5")); - assertEquals("Effect StartTime", 5000, effectColor5.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor5.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_GRADIENT, - effectColor5.getType()); - assertEquals("Effect Color", EffectColor.GRAY, effectColor5.getColor()); - - final EffectColor effectColor6 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect6", 6000, 1000, - EffectColor.TYPE_GRADIENT, EffectColor.GREEN); - mediaVideoItem1.addEffect(effectColor6); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor6.getMediaItem()); - assertTrue("Effect Id", effectColor6.getId().equals("effect6")); - assertEquals("Effect StartTime", 6000, effectColor6.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor6.getDuration()); - assertEquals("Effect Type", - EffectColor.TYPE_GRADIENT, effectColor6.getType()); - assertEquals("Effect Color", - EffectColor.GREEN, effectColor6.getColor()); - - final EffectColor effectColor7 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect7", 7000, 1000, - EffectColor.TYPE_FIFTIES, 0); - mediaVideoItem1.addEffect(effectColor7); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor7.getMediaItem()); - assertTrue("Effect Id", effectColor7.getId().equals("effect7")); - assertEquals("Effect StartTime", 7000, effectColor7.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor7.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_FIFTIES, - effectColor7.getType()); - assertEquals("Effect Color", -1, effectColor7.getColor()); - - final EffectColor effectColor8 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect8", 8000, 1000, EffectColor.TYPE_SEPIA, 0); - mediaVideoItem1.addEffect(effectColor8); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor8.getMediaItem()); - assertTrue("Effect Id", effectColor8.getId().equals("effect8")); - assertEquals("Effect StartTime", 8000, effectColor8.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor8.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_SEPIA, - effectColor8.getType()); - assertEquals("Effect Color", -1, effectColor8.getColor()); - - final EffectColor effectColor9 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect9", 9000, 1000, - EffectColor.TYPE_NEGATIVE, 0); - mediaVideoItem1.addEffect(effectColor9); - - assertEquals("Associated Media Item", mediaVideoItem1, - effectColor9.getMediaItem()); - assertTrue("Effect Id", effectColor9.getId().equals("effect9")); - assertEquals("Effect StartTime", 9000, effectColor9.getStartTime()); - assertEquals("Effect EndTime", 1000, effectColor9.getDuration()); - assertEquals("Effect Type", EffectColor.TYPE_NEGATIVE, - effectColor9.getType()); - assertEquals("Effect Color", -1, effectColor9.getColor()); - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", - 9000, 1000, EffectColor.TYPE_COLOR - 1, 0); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect type Invalid", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect9", - 9000, 1000, EffectColor.TYPE_FIFTIES + 1, 0); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect type Invalid", flagForException); - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect10", - 10000, 1000, EffectColor.TYPE_FIFTIES + - EffectColor.TYPE_GRADIENT, 0); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect type Invalid", flagForException); - } - - /** - * To test Effect Color : Set duration and Get Duration - */ - @LargeTest - public void testEffectSetgetDuration() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem( - mediaVideoItem1, "effect1", 1000, 2000, - EffectColor.TYPE_COLOR, EffectColor.PINK); - mediaVideoItem1.addEffect(effectColor1); - - effectColor1.setDuration(5000); - assertEquals("Updated Effect Duration", 5000, - effectColor1.getDuration()); - try { - effectColor1.setDuration(mediaVideoItem1.getDuration() + 1000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect Color duration > mediaVideoItemDuration", - flagForException); - assertEquals("Effect Duration", 5000, effectColor1.getDuration()); - flagForException = false; - try { - effectColor1.setDuration(-1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect Color duration = -1", flagForException); - } - - /** - * To test Effect Color : UNDEFINED color param value - */ - @LargeTest - public void testEffectUndefinedColorParam() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - try{ - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", 1000, - 2000, EffectColor.TYPE_COLOR, 0xabcdabcd); - }catch (IllegalArgumentException e){ - flagForException = true; - } - assertTrue("Invalid Effect added",flagForException); - } - - /** - * To test Effect Color : with Invalid StartTime and Duration - */ - @LargeTest - public void testEffectInvalidStartTimeAndDuration() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp"; - final int videoItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName, videoItemRenderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", - 400000000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect with invalid StartTime", flagForException); - - flagForException = false; - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", -1, - 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect with invalid StartTime", flagForException); - - flagForException = false; - try { - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effect1", - 2000, -1, EffectColor.TYPE_COLOR, EffectColor.GREEN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect with invalid Duration", flagForException); - } - - - /** Test cases 29, 30, 31, 32 and 33 are removed */ - - - /** - * To test Effect : with NULL Media Item - */ - @LargeTest - public void testEffectNullMediaItem() throws Exception { - boolean flagForException = false; - try { - mVideoEditorHelper.createEffectItem(null, "effect1", 1000, 4000, - EffectColor.TYPE_COLOR, EffectColor.GREEN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Effect with null MediaItem", flagForException); - } - - /** - * To test Effect : KenBurn Effect - */ - @LargeTest - public void testEffectKenBurn() throws Exception { - // Test ken burn effect using a JPEG file. - testEffectKenBurn(INPUT_FILE_PATH + "IMG_640x480.jpg", - "mediaImageItem1"); - - // Test ken burn effect using a PNG file - testEffectKenBurn(INPUT_FILE_PATH + "IMG_640x480.png", - "mediaImageItem2"); - } - - private void testEffectKenBurn(final String imageItemFileName, - final String MediaId) throws Exception { - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaImageItem mediaImageItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, MediaId, - 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: " + imageItemFileName, - kbEffectOnMediaItem); - - mediaImageItem.addEffect(kbEffectOnMediaItem); - assertEquals("KenBurn Start Rect: " + imageItemFileName, startRect, - kbEffectOnMediaItem.getStartRect()); - - assertEquals("KenBurn End Rect: " + imageItemFileName, endRect, - kbEffectOnMediaItem.getEndRect()); - } - - /** - * To test KenBurnEffect : Set StartRect and EndRect - */ - - @LargeTest - public void testEffectKenBurnSet() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final int imageItemRenderingMode =MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - 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()); - - EffectKenBurns kbEffectOnMediaItem=null; - 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()); - - final Rect startRect1 = new Rect((mediaImageItem.getHeight() / 5), - (mediaImageItem.getWidth() / 5), (mediaImageItem.getHeight() / 4), - (mediaImageItem.getWidth() / 4)); - final Rect endRect1 = new Rect(10, 10, mediaImageItem.getWidth() / 4, - mediaImageItem.getHeight() / 4); - - /* Added newly to take care of removal set APIs */ - kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_changed", - startRect1, endRect1, 500, 3000); - - assertEquals("KenBurn Start Rect", startRect1, - kbEffectOnMediaItem.getStartRect()); - assertEquals("KenBurn End Rect", endRect1, - kbEffectOnMediaItem.getEndRect()); - - final Rect zeroRect = new Rect(0, 0, 0, 0); - try { - kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroStart", - zeroRect, endRect, 500, 3000); - - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid Start Rect", flagForException); - - flagForException = false; - try { - kbEffectOnMediaItem = new EffectKenBurns(mediaImageItem, "KBOnM2_zeroEnd", - startRect, zeroRect, 500, 3000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid End Rect", flagForException); - } - - /** - * To test Transition : Fade To Black with all behavior - * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST - */ - - @LargeTest - public void testTransitionFadeBlack() throws Exception { - - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String videoItemFilename2 = INPUT_FILE_PATH + - "H263_profile0_176x144_15fps_128kbps_1_35.3gp"; - final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final String videoItemFilename3 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final String videoItemFilename4 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFilename5 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_96kbps_0_25.3gp"; - boolean flagForException = false; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionFadeBlack transition1And2 = mVideoEditorHelper - .createTFadeBlack("transition1And2", mediaVideoItem1, - mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP); - mVideoEditor.addTransition(transition1And2); - - assertTrue("Transition ID", - transition1And2.getId().equals("transition1And2")); - assertEquals("Transtion After Media item", - mediaVideoItem1, transition1And2.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem2, - transition1And2.getBeforeMediaItem()); - assertEquals("Transtion Duration", 3000, transition1And2.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, - transition1And2.getBehavior()); - - final MediaImageItem mediaImageItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem3); - - final TransitionFadeBlack transition2And3 = - mVideoEditorHelper.createTFadeBlack("transition2And3", mediaVideoItem2, - mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN); - mVideoEditor.addTransition(transition2And3); - - assertTrue("Transition ID", - transition2And3.getId().equals("transition2And3")); - assertEquals("Transtion After Media item", mediaVideoItem2, - transition2And3.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaImageItem3, - transition2And3.getBeforeMediaItem()); - assertEquals("Transtion Duration", 1000, transition2And3.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, - transition2And3.getBehavior()); - - final MediaVideoItem mediaVideoItem4 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem4.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem4); - - final TransitionFadeBlack transition3And4 = - mVideoEditorHelper.createTFadeBlack("transition3And4", mediaImageItem3, - mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR); - mVideoEditor.addTransition(transition3And4); - - assertTrue("Transition ID", - transition3And4.getId().equals("transition3And4")); - assertEquals("Transtion After Media item", mediaImageItem3, - transition3And4.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem4, - transition3And4.getBeforeMediaItem()); - assertEquals("Transtion Duration", 5000, transition3And4.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, - transition3And4.getBehavior()); - - final MediaVideoItem mediaVideoItem5 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem5); - - final TransitionFadeBlack transition4And5 = - mVideoEditorHelper.createTFadeBlack("transition4And5", mediaVideoItem4, - mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition4And5); - - assertTrue("Transition ID", - transition4And5.getId().equals("transition4And5")); - assertEquals("Transtion After Media item", mediaVideoItem4, - transition4And5.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem5, - transition4And5.getBeforeMediaItem()); - assertEquals("Transtion Duration", 8000, transition4And5.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, - transition4And5.getBehavior()); - - final MediaVideoItem mediaVideoItem6 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", - videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem6.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem6); - - final TransitionFadeBlack transition5And6 = - mVideoEditorHelper.createTFadeBlack("transition5And6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW); - mVideoEditor.addTransition(transition5And6); - - assertTrue("Transition ID", - transition5And6.getId().equals("transition5And6")); - assertEquals("Transtion After Media item", mediaVideoItem5, - transition5And6.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem6, - transition5And6.getBeforeMediaItem()); - assertEquals("Transtion Duration", 2000, transition5And6.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, - transition5And6.getBehavior()); - flagForException = false; - try { - mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTFadeBlack("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - } - - /** - * To test Transition : CrossFade with all behavior - * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST - */ - - @LargeTest - public void testTransitionCrossFade() throws Exception { - - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String videoItemFilename2 = INPUT_FILE_PATH + - "H263_profile0_176x144_15fps_128kbps_1_35.3gp"; - final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final String videoItemFilename3 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final String videoItemFilename4 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFilename5 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_96kbps_0_25.3gp"; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionCrossfade transition1And2 = - mVideoEditorHelper.createTCrossFade("transition1And2", mediaVideoItem1, - mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP); - mVideoEditor.addTransition(transition1And2); - - assertTrue("Transition ID", - transition1And2.getId().equals("transition1And2")); - assertEquals("Transtion After Media item", mediaVideoItem1, - transition1And2.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem2, - transition1And2.getBeforeMediaItem()); - assertEquals("Transtion Duration", 3000, transition1And2.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, - transition1And2.getBehavior()); - - final MediaImageItem mediaImageItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem3); - - final TransitionCrossfade transition2And3 = - mVideoEditorHelper.createTCrossFade("transition2And3", mediaVideoItem2, - mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN); - mVideoEditor.addTransition(transition2And3); - - assertTrue("Transition ID", - transition2And3.getId().equals("transition2And3")); - assertEquals("Transtion After Media item", mediaVideoItem2, - transition2And3.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaImageItem3, - transition2And3.getBeforeMediaItem()); - assertEquals("Transtion Duration", 1000, transition2And3.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, - transition2And3.getBehavior()); - - final MediaVideoItem mediaVideoItem4 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem4.setExtractBoundaries(0, 18000); - mVideoEditor.addMediaItem(mediaVideoItem4); - - final TransitionCrossfade transition3And4 = - mVideoEditorHelper.createTCrossFade("transition3And4", mediaImageItem3, - mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR); - mVideoEditor.addTransition(transition3And4); - - assertTrue("Transition ID", - transition3And4.getId().equals("transition3And4")); - assertEquals("Transtion After Media item", mediaImageItem3, - transition3And4.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem4, - transition3And4.getBeforeMediaItem()); - assertEquals("Transtion Duration", 5000, transition3And4.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, - transition3And4.getBehavior()); - - final MediaVideoItem mediaVideoItem5 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem5); - - final TransitionCrossfade transition4And5 = - mVideoEditorHelper.createTCrossFade("transition4And5", mediaVideoItem4, - mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition4And5); - - assertTrue("Transition ID", - transition4And5.getId().equals("transition4And5")); - assertEquals("Transtion After Media item", mediaVideoItem4, - transition4And5.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem5, - transition4And5.getBeforeMediaItem()); - assertEquals("Transtion Duration", 8000, transition4And5.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, - transition4And5.getBehavior()); - - final MediaVideoItem mediaVideoItem6 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", - videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem6.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem6); - - final TransitionCrossfade transition5And6 = - mVideoEditorHelper.createTCrossFade("transition5And6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW); - mVideoEditor.addTransition(transition5And6); - - assertTrue("Transition ID", - transition5And6.getId().equals("transition5And6")); - assertEquals("Transtion After Media item", mediaVideoItem5, - transition5And6.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem6, - transition5And6.getBeforeMediaItem()); - assertEquals("Transtion Duration", 2000, transition5And6.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, - transition5And6.getBehavior()); - - flagForException = false; - try { - mVideoEditorHelper.createTCrossFade("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTCrossFade("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - } - - /** - * To test Transition : Sliding with all behavior - * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST and Direction = - * DIRECTION_RIGHT_OUT_LEFT_IN - * ,DIRECTION_LEFT_OUT_RIGHT_IN,DIRECTION_TOP_OUT_BOTTOM_IN - * ,DIRECTION_BOTTOM_OUT_TOP_IN - */ - - @LargeTest - public void testTransitionSliding() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String videoItemFilename2 = INPUT_FILE_PATH + - "H263_profile0_176x144_15fps_128kbps_1_35.3gp"; - final String imageItemFilename1 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String videoItemFilename3 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final String videoItemFilename4 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFilename5 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_96kbps_0_25.3gp"; - boolean flagForException = false; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionSliding transition1And2 = - mVideoEditorHelper.createTSliding("transition1And2", mediaVideoItem1, - mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); - mVideoEditor.addTransition(transition1And2); - - assertTrue("Transition ID", - transition1And2.getId().equals("transition1And2")); - assertEquals("Transtion After Media item", mediaVideoItem1, - transition1And2.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem2, - transition1And2.getBeforeMediaItem()); - assertEquals("Transtion Duration", 3000, transition1And2.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, - transition1And2.getBehavior()); - assertEquals("Transition Sliding", - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, - transition1And2.getDirection()); - - final MediaImageItem mediaImageItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem3); - - final TransitionSliding transition2And3 = - mVideoEditorHelper.createTSliding("transition2And3", - mediaVideoItem2, mediaImageItem3, 1000, - Transition.BEHAVIOR_SPEED_DOWN, - TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN); - mVideoEditor.addTransition(transition2And3); - - assertTrue("Transition ID", - transition2And3.getId().equals("transition2And3")); - assertEquals("Transtion After Media item", mediaVideoItem2, - transition2And3.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaImageItem3, - transition2And3.getBeforeMediaItem()); - assertEquals("Transtion Duration", 1000, transition2And3.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, - transition2And3.getBehavior()); - assertEquals("Transition Sliding", - TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN, - transition2And3.getDirection()); - - final MediaVideoItem mediaVideoItem4 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem4.setExtractBoundaries(0, 18000); - mVideoEditor.addMediaItem(mediaVideoItem4); - - final TransitionSliding transition3And4 = - mVideoEditorHelper.createTSliding("transition3And4", mediaImageItem3, - mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, - TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN); - mVideoEditor.addTransition(transition3And4); - - assertTrue("Transition ID", - transition3And4.getId().equals("transition3And4")); - assertEquals("Transtion After Media item", mediaImageItem3, - transition3And4.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem4, - transition3And4.getBeforeMediaItem()); - assertEquals("Transtion Duration", 5000, transition3And4.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, - transition3And4.getBehavior()); - assertEquals("Transition Sliding", - TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN, - transition3And4.getDirection()); - - final MediaVideoItem mediaVideoItem5 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem5); - - final TransitionSliding transition4And5 = - mVideoEditorHelper.createTSliding("transition4And5", mediaVideoItem4, - mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, - TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN); - mVideoEditor.addTransition(transition4And5); - - assertTrue("Transition ID", - transition4And5.getId().equals("transition4And5")); - assertEquals("Transtion After Media item", mediaVideoItem4, - transition4And5.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem5, - transition4And5.getBeforeMediaItem()); - assertEquals("Transtion Duration", 8000, transition4And5.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, - transition4And5.getBehavior()); - assertEquals("Transition Sliding", - TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN, - transition4And5.getDirection()); - - final MediaVideoItem mediaVideoItem6 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", - videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem6.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem6); - - final TransitionSliding transition5And6 = - mVideoEditorHelper.createTSliding("transition5And6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); - mVideoEditor.addTransition(transition5And6); - - assertTrue("Transition ID", - transition5And6.getId().equals("transition5And6")); - assertEquals("Transtion After Media item", mediaVideoItem5, - transition5And6.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem6, - transition5And6.getBeforeMediaItem()); - assertEquals("Transtion Duration", 2000, transition5And6.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_SLOW, - transition5And6.getBehavior()); - assertEquals("Transition Sliding", - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN, - transition5And6.getDirection()); - - flagForException = false; - try { - mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN - 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition Sliding with Invalid Direction", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, - TransitionSliding.DIRECTION_BOTTOM_OUT_TOP_IN + 1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition Sliding with Invalid behavior", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_SPEED_UP - 1, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition Sliding with Invalid behavior", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTSliding("transitiond6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition Sliding with Invalid behavior", flagForException); - } - - /** - * To test Transition : Alpha with all behavior - * SPEED_UP/SPEED_DOWN/LINEAR/MIDDLE_SLOW/MIDDLE_FAST - */ - - @LargeTest - public void testTransitionAlpha() throws Exception { - - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String videoItemFilename2 = INPUT_FILE_PATH + - "H263_profile0_176x144_15fps_128kbps_1_35.3gp"; - final String imageItemFilename1 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String videoItemFilename3 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final String videoItemFilename4 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFilename5 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_96kbps_0_25.3gp"; - final String maskFilename = INPUT_FILE_PATH + - "TransitionSpiral_QVGA.jpg"; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionAlpha transition1And2 = - mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, - mediaVideoItem2, 3000, Transition.BEHAVIOR_SPEED_UP, maskFilename, - 10, false); - mVideoEditor.addTransition(transition1And2); - - assertTrue("Transition ID", - transition1And2.getId().equals("transition1And2")); - assertEquals("Transtion After Media item", mediaVideoItem1, - transition1And2.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem2, - transition1And2.getBeforeMediaItem()); - assertEquals("Transtion Duration", 3000, transition1And2.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_UP, - transition1And2.getBehavior()); - assertTrue("Transition maskFile", - transition1And2.getMaskFilename().equals(maskFilename)); - assertEquals("Transition BlendingPercent", 10, - transition1And2.getBlendingPercent()); - assertFalse("Transition Invert", transition1And2.isInvert()); - - final MediaImageItem mediaImageItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem3); - - final TransitionAlpha transition2And3 = - mVideoEditorHelper.createTAlpha("transition2And3", mediaVideoItem2, - mediaImageItem3, 1000, Transition.BEHAVIOR_SPEED_DOWN, - maskFilename, 30, false); - mVideoEditor.addTransition(transition2And3); - - assertTrue("Transition ID", - transition2And3.getId().equals("transition2And3")); - assertEquals("Transtion After Media item", mediaVideoItem2, - transition2And3.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaImageItem3, - transition2And3.getBeforeMediaItem()); - assertEquals("Transtion Duration", 1000, transition2And3.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_SPEED_DOWN, - transition2And3.getBehavior()); - assertTrue("Transition maskFile", - transition2And3.getMaskFilename().equals(maskFilename)); - assertEquals("Transition BlendingPercent", 30, - transition2And3.getBlendingPercent()); - assertFalse("Transition Invert", transition2And3.isInvert()); - - final MediaVideoItem mediaVideoItem4 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem4.setExtractBoundaries(0, 18000); - mVideoEditor.addMediaItem(mediaVideoItem4); - - final TransitionAlpha transition3And4 = - mVideoEditorHelper.createTAlpha("transition3And4", mediaImageItem3, - mediaVideoItem4, 5000, Transition.BEHAVIOR_LINEAR, maskFilename, - 50, false); - mVideoEditor.addTransition(transition3And4); - - assertTrue("Transition ID", - transition3And4.getId().equals("transition3And4")); - assertEquals("Transtion After Media item", mediaImageItem3, - transition3And4.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem4, - transition3And4.getBeforeMediaItem()); - assertEquals("Transtion Duration", 5000, transition3And4.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_LINEAR, - transition3And4.getBehavior()); - assertTrue("Transition maskFile", - transition3And4.getMaskFilename().equals(maskFilename)); - assertEquals("Transition BlendingPercent", 50, - transition3And4.getBlendingPercent()); - assertFalse("Transition Invert", transition3And4.isInvert()); - - final MediaVideoItem mediaVideoItem5 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - videoItemFilename4, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem5); - - final TransitionAlpha transition4And5 = - mVideoEditorHelper.createTAlpha("transition4And5", mediaVideoItem4, - mediaVideoItem5, 8000, Transition.BEHAVIOR_MIDDLE_FAST, - maskFilename, 70, true); - mVideoEditor.addTransition(transition4And5); - - assertTrue("Transition ID", - transition4And5.getId().equals("transition4And5")); - assertEquals("Transtion After Media item", mediaVideoItem4, - transition4And5.getAfterMediaItem()); - assertEquals("Transtion Before Media item", mediaVideoItem5, - transition4And5.getBeforeMediaItem()); - assertEquals("Transtion Duration", 8000, transition4And5.getDuration()); - assertEquals("Transtion Behavior", Transition.BEHAVIOR_MIDDLE_FAST, - transition4And5.getBehavior()); - assertTrue("Transition maskFile", - transition4And5.getMaskFilename().equals(maskFilename)); - assertEquals("Transition BlendingPercent", 70, - transition4And5.getBlendingPercent()); - assertTrue("Transition Invert", transition4And5.isInvert()); - - final MediaVideoItem mediaVideoItem6 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m6", - videoItemFilename5, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem6.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem6); - - try { - mVideoEditorHelper.createTAlpha("transition5And6", mediaVideoItem5, - mediaVideoItem6, 2000, Transition.BEHAVIOR_MIDDLE_SLOW, - INPUT_FILE_PATH + "imDummyFile.jpg", 70, - true); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("MaskFile is not exsisting", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTAlpha("transition5And6", null, null, 2000, - Transition.BEHAVIOR_MIDDLE_SLOW, maskFilename, 101, true); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Invalid Blending Percent", flagForException); - - flagForException = false; - try { - mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, - mediaVideoItem5, 2000, Transition.BEHAVIOR_SPEED_UP - 1, - maskFilename, 30, false); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - flagForException = false; - try { - mVideoEditorHelper.createTAlpha("transitiond6", mediaVideoItem4, - mediaVideoItem5, 2000, Transition.BEHAVIOR_MIDDLE_FAST + 1, - maskFilename, 30, false); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition FadeBlack with Invalid behavior", flagForException); - } - - /** - * To test Frame Overlay for Media Video Item - */ - - @LargeTest - public void testFrameOverlayVideoItem() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_256kbps_0_25.3gp"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_176x144_Overlay1.png"; - final String overlayFile2 = INPUT_FILE_PATH + "IMG_176x144_Overlay2.png"; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFile1, - 176, 144); - final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( - mediaVideoItem1, "overlayId1", mBitmap1, 5000, 5000); - mediaVideoItem1.addOverlay(overlayFrame1); - - assertEquals("Overlay : Media Item", mediaVideoItem1, - overlayFrame1.getMediaItem()); - assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1")); - assertEquals("Overlay Bitmap", mBitmap1, overlayFrame1.getBitmap()); - assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime()); - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - - Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 176, 144); - overlayFrame1.setBitmap(upddateBmp); - assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap()); - upddateBmp.recycle(); - } - - /** - * To test Frame Overlay for Media Video Item : Set duration and Get - * Duration - */ - - @LargeTest - public void testFrameOverlaySetAndGet() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_30fps_512Kbps_0_27.mp4"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( - mediaVideoItem1, "overlayId1", mBitmap, 5000, 5000); - mediaVideoItem1.addOverlay(overlayFrame1); - overlayFrame1.setDuration(5000); - - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - try { - overlayFrame1.setDuration(mediaVideoItem1.getDuration() + 10000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay Duration > MediaVideo Item Duration", - flagForException); - - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - flagForException = false; - - try { - overlayFrame1.setDuration(-1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay Duration = -1", flagForException); - } - - /** - * To test Frame Overlay for Media Video Item : Set duration and Get - * Duration - */ - - @LargeTest - public void testFrameOverlayInvalidTime() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId1", - mBitmap, 400000000, 2000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - - flagForException = false; - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId2", - mBitmap, -1, 2000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - - flagForException = false; - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaVideoItem1, "overlayId3", - mBitmap, 2000, -1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - } - - /** - * To test Frame Overlay for Media Image Item - */ - @LargeTest - public void testFrameOverlayImageItem() throws Exception { - final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - final String overlayFile2 = INPUT_FILE_PATH + "IMG_640x480_Overlay2.png"; - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - imageItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, - 480); - final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( - mediaImageItem1, "overlayId1", mBitmap, 5000, 5000); - mediaImageItem1.addOverlay(overlayFrame1); - - assertEquals("Overlay : Media Item", mediaImageItem1, - overlayFrame1.getMediaItem()); - assertTrue("Overlay Id", overlayFrame1.getId().equals("overlayId1")); - assertEquals("Overlay Bitmap",mBitmap ,overlayFrame1.getBitmap()); - assertEquals("Overlay Start Time", 5000, overlayFrame1.getStartTime()); - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - Bitmap upddateBmp = mVideoEditorHelper.getBitmap(overlayFile2, 640, 480); - - overlayFrame1.setBitmap(upddateBmp); - assertEquals("Overlay Update Bitmap", upddateBmp, overlayFrame1.getBitmap()); - upddateBmp.recycle(); - } - - /** - * To test Frame Overlay for Media Image Item : Set duration and Get - * Duration - */ - - @LargeTest - public void testFrameOverlaySetAndGetImage() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - final OverlayFrame overlayFrame1 = mVideoEditorHelper.createOverlay( - mediaImageItem1, "overlayId1", mBitmap, 5000, 5000); - mediaImageItem1.addOverlay(overlayFrame1); - - overlayFrame1.setDuration(5000); - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - - try { - overlayFrame1.setDuration(mediaImageItem1.getDuration() + 10000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay Duration > Media Item Duration", flagForException); - assertEquals("Overlay Duration", 5000, overlayFrame1.getDuration()); - - flagForException = false; - try { - overlayFrame1.setDuration(-1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay Duration = -1", flagForException); - } - - /** - * To test Frame Overlay for Media Image Item :Invalid StartTime and - * Duration - */ - - @LargeTest - public void testFrameOverlayInvalidTimeImage() throws Exception { - final String videoItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", - mBitmap, 400000000, 2000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - - flagForException = false; - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId2", - mBitmap, -1, 2000); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - - flagForException = false; - try { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, - 640, 480); - mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId3", - mBitmap, 2000, -1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Overlay With Invalid Start Time", flagForException); - } - - /** - * To Test Frame Overlay Media Image Item :JPG File - */ - - @LargeTest - public void testFrameOverlayJPGImage() throws Exception { - - final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String overlayFile1 = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - imageItemFilename, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile1, 640, - 480); - mVideoEditorHelper.createOverlay(mediaImageItem1, "overlayId1", - mBitmap, 5000, 5000); - } - - /** - * To test Video Editor API - * - * @throws Exception - */ - @LargeTest - public void testVideoEditorAPI() throws Exception { - - final String videoItemFileName1 = INPUT_FILE_PATH - + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String videoItemFileName3 = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg"; - final String audioFilename1 = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - final String audioFilename2 = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - TransitionCrossfade transition2And4; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName1, renderingMode); - mediaVideoItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFileName2, renderingMode); - mediaVideoItem2.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, - mediaVideoItem2.getDuration() / 2); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final MediaVideoItem mediaVideoItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - videoItemFileName3, renderingMode); - mediaVideoItem3.setExtractBoundaries(mediaVideoItem3.getDuration() / 2, - mediaVideoItem3.getDuration()); - mVideoEditor.addMediaItem(mediaVideoItem3); - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - imageItemFileName1, 5000, renderingMode); - - final MediaImageItem mediaImageItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - imageItemFileName2, 5000, renderingMode); - - List<MediaItem> mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 3, mediaList.size()); - - mVideoEditor.insertMediaItem(mediaImageItem1, mediaVideoItem2.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 4, mediaList.size()); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); - assertEquals("Media item 4", mediaImageItem1, mediaList.get(2)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3)); - - mVideoEditor.insertMediaItem(mediaImageItem2, mediaImageItem1.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 5, mediaList.size()); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); - assertEquals("Media item 4", mediaImageItem1, mediaList.get(2)); - assertEquals("Media item 5", mediaImageItem2, mediaList.get(3)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); - - mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), mediaImageItem2.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 5, mediaList.size()); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0)); - assertEquals("Media item 4", mediaImageItem1, mediaList.get(1)); - assertEquals("Media item 5", mediaImageItem2, mediaList.get(2)); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); - - assertEquals("Media Item 1", mediaVideoItem1, - mVideoEditor.getMediaItem(mediaVideoItem1.getId())); - - flagForException = false; - transition2And4 = null; - try{ - transition2And4 = mVideoEditorHelper.createTCrossFade( - "transition2And4", mediaVideoItem2, mediaImageItem1, 2000, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition2And4); - } - catch (IllegalArgumentException e) { - flagForException = true; - } - assertFalse("Transition2and4 cannot be created", flagForException); - - - TransitionCrossfade transition1And3 = null; - flagForException = false; - try{ - transition1And3 = mVideoEditorHelper.createTCrossFade( - "transition1And3", mediaVideoItem1, mediaVideoItem2, 5000, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition1And3); - }catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Transition1and3 cannot be created", flagForException); - - List<Transition> transitionList = mVideoEditor.getAllTransitions(); - assertEquals("Transition List", 1, transitionList.size()); - - assertEquals("Transition 2", transition2And4, - mVideoEditor.getTransition(transition2And4.getId())); - - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFilename1); - mVideoEditor.addAudioTrack(audioTrack); - - List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks(); - assertEquals("Audio List", 1, audioList.size()); - - final AudioTrack audioTrack1 = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack1", audioFilename2); - flagForException = false; - try { - mVideoEditor.addAudioTrack(audioTrack1); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Audio Track support is 1 ", flagForException); - - flagForException = false; - try { - mVideoEditor.insertAudioTrack(audioTrack1,"audioTrack"); - } catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Audio Track supports is 1 ", flagForException); - - assertEquals("Removing AudioTrack", audioTrack, - mVideoEditor.removeAudioTrack(audioTrack.getId())); - - assertEquals("Removing transition", transition2And4, - mVideoEditor.removeTransition(transition2And4.getId())); - - assertEquals("Removing Media Item", mediaVideoItem2, - mVideoEditor.removeMediaItem(mediaVideoItem2.getId())); - - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_16_9); - assertEquals("Check Aspect Ratio", MediaProperties.ASPECT_RATIO_16_9, - mVideoEditor.getAspectRatio()); - - long storyBoardDuration = mediaVideoItem1.getTimelineDuration() - + mediaVideoItem3.getTimelineDuration() - + mediaImageItem1.getDuration() - + mediaImageItem2.getDuration(); - assertEquals("Story Board Duration", storyBoardDuration, - mVideoEditor.getDuration()); - } - - /** - * To add Audio Track Greater than MediaItem Duration - * - * @throws Exception - */ - @LargeTest - public void testVideoLessThanAudio() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH - + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; - final String audioTrackFilename = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrackId", audioTrackFilename); - mVideoEditor.addAudioTrack(audioTrack); - assertEquals("Storyboard = mediaItem Duration", - mediaVideoItem1.getDuration(), mVideoEditor.getDuration()); - assertTrue("Audio Duration > mediaItem Duration", - (audioTrack.getDuration() > mediaVideoItem1.getDuration() ? - true : false)); - } - - /** - * To test Video Editor API with 1080 P - * - * @throws Exception - */ - @LargeTest - public void testVideoContentHD() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH - + "H264_BP_1920x1080_30fps_1200Kbps_1_10.mp4"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final MediaVideoItem mediaVideoItem1; - // 1080p resolution is supported on some devices - // but not on other devices. - // So this test case is not generic and - // hence we always assert true - boolean flagForException = true; - try { - mediaVideoItem1 = mVideoEditorHelper.createMediaItem(mVideoEditor, - "m1", videoItemFileName1, renderingMode); - } catch (IllegalArgumentException e) { - } - assertTrue("VideoContent 1920x1080", flagForException); - } - - - /** - * To test: Remove audio track - * - * @throws Exception - */ - @LargeTest - public void testRemoveAudioTrack() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack1", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - assertEquals("Audio Track Item Duration", audioTrack.getDuration(), - audioTrack.getTimelineDuration()); - assertTrue("Audio Track ID", audioTrack.getId().equals("audioTrack1")); - assertNotNull("Remove Audio Track", - mVideoEditor.removeAudioTrack("audioTrack1")); - try{ - mVideoEditor.removeAudioTrack("audioTrack1"); - }catch (IllegalArgumentException e){ - flagForException = true; - } - assertTrue("Remove Audio Track not possible", flagForException); - } - - /** - * To test: Disable ducking - * - * @throws Exception - */ - @LargeTest - public void testAudioDuckingDisable() throws Exception { - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - audioTrack.disableDucking(); - assertFalse("Audio Track Ducking is Disabled", - audioTrack.isDuckingEnabled()); - } - - - - /** - * To test: Need a basic test case for the get value for TransitionAlpha - * ( ie. getBlendingPercent, getMaskFilename, isInvert) - * - * @throws Exception - */ - @LargeTest - public void testTransitionAlphaBasic() throws Exception { - - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String maskFilename = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - boolean flagForException = false; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 15000); - - final MediaImageItem mediaImageItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, - 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaImageItem.setDuration(15000); - - mVideoEditor.addMediaItem(mediaVideoItem1); - mVideoEditor.addMediaItem(mediaImageItem); - final TransitionAlpha transition1And2 = - mVideoEditorHelper.createTAlpha("transition1And2", mediaVideoItem1, - mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, - maskFilename, 10, false); - mVideoEditor.addTransition(transition1And2); - assertTrue("Transition maskFile", - transition1And2.getMaskFilename().equals(maskFilename)); - assertEquals("Transition BlendingPercent", 10, - transition1And2.getBlendingPercent()); - assertFalse("Transition Invert", transition1And2.isInvert()); - } - - /** - * To test: NULL arguments to the Video Editor APIs - * - * @throws Exception - */ - @LargeTest - public void testNullAPIs() throws Exception { - - final String videoItemFilename1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String maskFilename = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final String audioFileName = INPUT_FILE_PATH + - "AACLC_48KHz_256Kbps_s_1_17.3gp"; - boolean flagForException = false; - - try { - mVideoEditor.addAudioTrack(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Video Editor with null Audio Track", flagForException); - flagForException = false; - try { - mVideoEditor.addMediaItem(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Video Editor with NULL Image Item ", flagForException); - flagForException = false; - try { - mVideoEditor.addMediaItem(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Video Editor with NULL Video Item ", flagForException); - - MediaVideoItem mediaVideoItem1 = null; - try { - mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - } catch (IllegalArgumentException e) { - assertTrue("Cannot Create Video Item", false); - } - mediaVideoItem1.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem1); - flagForException = false; - try { - mediaVideoItem1.addEffect(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Video with null effect ", flagForException); - flagForException = false; - try { - mediaVideoItem1.addOverlay(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Video with null overlay ", flagForException); - - final MediaImageItem mediaImageItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", maskFilename, - 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaImageItem.setDuration(15000); - mVideoEditor.addMediaItem(mediaImageItem); - flagForException = false; - try { - mediaImageItem.addEffect(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Image with null effect ", flagForException); - flagForException = false; - try { - mediaImageItem.addOverlay(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Image with null overlay ", flagForException); - - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioFileName); - mVideoEditor.addAudioTrack(audioTrack); - - flagForException = false; - try { - mVideoEditor.addTransition(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Added null transition ", flagForException); - - flagForException = false; - try { - mVideoEditor.addTransition(null); - } catch(IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Added null transition ", flagForException); - - } -} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java deleted file mode 100644 index 69ecf0d..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorExportTest.java +++ /dev/null @@ -1,812 +0,0 @@ -/* - * 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.videoeditor; - -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 android.test.suitebuilder.annotation.Suppress; -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 - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - *To Test export : With Effect and Overlays on Different Media Items - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - * To test export : with Image with KenBurnEffect - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - * To Test Export : With Video and Image and An Audio BackGround Track - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - *To Test export : With Transition on Different Media Items - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - * To Test Export : Without any Media Items in the story Board - * - * @throws Exception - */ - @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 - */ - @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 - */ - @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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } - - /** - * To Test Export :Media Item having duration of 1 Hour - * - * @throws Exception - */ - @Suppress - @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_H264, 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_H264, MediaProperties.ACODEC_AAC_LC); - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - } -} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java deleted file mode 100644 index 7965b0a..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/videoeditor/VideoEditorPreviewTest.java +++ /dev/null @@ -1,1156 +0,0 @@ -/* - * 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.videoeditor; - -import java.io.File; -import java.io.IOException; -import java.util.List; -import java.util.concurrent.Semaphore; - -import android.graphics.Bitmap; -import android.graphics.Rect; -import android.media.videoeditor.AudioTrack; -import android.media.videoeditor.Effect; -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.Overlay; -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.media.videoeditor.VideoEditor.PreviewProgressListener; -import android.media.videoeditor.VideoEditor.OverlayData; -import android.os.Environment; -import android.test.ActivityInstrumentationTestCase; -import android.view.SurfaceHolder; - - -import com.android.mediaframeworktest.MediaFrameworkTest; -import android.test.suitebuilder.annotation.LargeTest; -import com.android.mediaframeworktest.VideoEditorHelper; - -import android.os.Handler; -import android.os.Looper; -import android.os.Message; - -import java.util.concurrent.TimeUnit; - -import android.util.Log; - -public class VideoEditorPreviewTest extends - ActivityInstrumentationTestCase<MediaFrameworkTest> { - private final String TAG = "VideoEditorTest"; - - private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; - - private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; - - private final String PROJECT_CLASS_NAME = - "android.media.videoeditor.VideoEditorImpl"; - - private VideoEditor mVideoEditor; - - private VideoEditorHelper mVideoEditorHelper; - - private class EventHandler extends Handler { - public EventHandler( Looper lp) - { - super(lp); - } - public void handleMessage(Message msg) - { - switch (msg.what) - { - default: - MediaFrameworkTest.testInvalidateOverlay(); - } - } - } - private EventHandler mEventHandler; - - private boolean previewStart; - private boolean previewStop; - private boolean previewError; - - /* Minimum waiting time for Semaphore to wait for release */ - private final long minWaitingTime = 3000; - - // Declares the annotation for Preview Test Cases - public @interface Preview { - } - - public VideoEditorPreviewTest() { - super("com.android.mediaframeworktest", MediaFrameworkTest.class); - - Looper looper; - if ((looper = Looper.myLooper()) != null) { - mEventHandler = new EventHandler(looper); - - } else { - //Handle error when looper can not be created. - ; - } - } - - @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 setPreviewStart() { - previewStart = true; - } - protected void setPreviewStop() { - previewStop = true; - } - protected void setPreviewError() { - previewError = true; - } - protected void validatePreviewProgress(int startMs, int endMs, - boolean loop, long duration) throws Exception { - - final int[] progressUpdate = new int[100]; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - previewError = false; - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - int i = 0; - public void onProgress(Object item, int action, int progress) { - progressUpdate[i++] = progress; - } - }); - mVideoEditorHelper.checkProgressCBValues(progressUpdate); - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - - long waitingTime = minWaitingTime; - if (endMs == -1) { - waitingTime += duration; - } - else { - waitingTime += (endMs - startMs); - } - blockTillPreviewCompletes.acquire(); - try { - mVideoEditor.startPreview(surfaceHolder, startMs, endMs, loop, 1, - new PreviewProgressListener() { - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - - if ( overlayData != null) { - if(overlayData.needsRendering()) { - overlayData.renderOverlay(MediaFrameworkTest.mDestBitmap); - mEventHandler.sendMessage(mEventHandler.obtainMessage(1, 2, 3)); - } - } - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - blockTillPreviewCompletes.release(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - blockTillPreviewCompletes.release(); - } - }); - } catch (Exception e) { - blockTillPreviewCompletes.release(); - } - blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS); - - mVideoEditor.stopPreview(); - assertTrue("Preview Failed to start", previewStart); - assertTrue("Preview Failed to stop", previewStop); - assertFalse("Preview Error occurred", previewError); - - blockTillPreviewCompletes.release(); - } - - // ----------------------------------------------------------------- - // Preview - // ----------------------------------------------------------------- - - /** - *To test Preview : FULL Preview of current work (beginning till end) - */ - @LargeTest - public void testPreviewTheStoryBoard() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH - + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFileName3 = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp"; - previewStart = false; - previewStop = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem2", - videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem2); - mediaVideoItem2.setExtractBoundaries(0, 10000); - - final MediaVideoItem mediaVideoItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem3", - videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem3.setExtractBoundaries(0, 10000); - - mVideoEditor.insertMediaItem(mediaVideoItem3, mediaVideoItem1.getId()); - List<MediaItem> mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media Item 3", mediaVideoItem3, mediaList.get(1)); - assertEquals("Media Item 2", mediaVideoItem2, mediaList.get(2)); - - mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER); - assertEquals("Media Item 1 Rendering Mode", - MediaItem.RENDERING_MODE_BLACK_BORDER, - mediaVideoItem1.getRenderingMode()); - - mediaVideoItem2.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER); - assertEquals("Media Item 2 Rendering Mode", - MediaItem.RENDERING_MODE_BLACK_BORDER, - mediaVideoItem2.getRenderingMode()); - - mediaVideoItem3.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); - assertEquals("Media Item 3 Rendering Mode", - MediaItem.RENDERING_MODE_STRETCH, - mediaVideoItem3.getRenderingMode()); - - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_5_3); - assertEquals("Aspect Ratio", MediaProperties.ASPECT_RATIO_5_3, - mVideoEditor.getAspectRatio()); - - validatePreviewProgress(0, -1, false, mVideoEditor.getDuration()); - } - - /** - * To test Preview : Preview of start + 10 sec till end of story board - */ - @LargeTest - public void testPreviewTheStoryBoardFromDuration() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH - + "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_256kbps_0_30.mp4"; - final String videoItemFileName3 = INPUT_FILE_PATH - + "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp"; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem2", - videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final MediaVideoItem mediaVideoItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem3", - videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem3.setExtractBoundaries(0, 10000); - - mVideoEditor.insertMediaItem(mediaVideoItem3, mediaVideoItem1.getId()); - - List<MediaItem> mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media Item 3", mediaVideoItem3, mediaList.get(1)); - assertEquals("Media Item 2", mediaVideoItem2, mediaList.get(2)); - mediaVideoItem1.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER); - - assertEquals("Media Item 1 Rendering Mode", - MediaItem.RENDERING_MODE_BLACK_BORDER, - mediaVideoItem1.getRenderingMode()); - mediaVideoItem2.setRenderingMode(MediaItem.RENDERING_MODE_BLACK_BORDER); - - assertEquals("Media Item 2 Rendering Mode", - MediaItem.RENDERING_MODE_BLACK_BORDER, - mediaVideoItem2.getRenderingMode()); - mediaVideoItem3.setRenderingMode(MediaItem.RENDERING_MODE_STRETCH); - - assertEquals("Media Item 3 Rendering Mode", - MediaItem.RENDERING_MODE_STRETCH, - mediaVideoItem3.getRenderingMode()); - - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_5_3); - assertEquals("Aspect Ratio", MediaProperties.ASPECT_RATIO_5_3, - mVideoEditor.getAspectRatio()); - - validatePreviewProgress(10000, -1, false, mVideoEditor.getDuration()); - } - - /** - * To test Preview : Preview of current Effects applied - */ - @LargeTest - public void testPreviewOfEffects() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaVideoItem1", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final EffectColor effectNegative = - mVideoEditorHelper.createEffectItem(mediaVideoItem1, - "effectNegative", 0, 2000, EffectColor.TYPE_NEGATIVE, 0); - mediaVideoItem1.addEffect(effectNegative); - - final EffectColor effectGreen = - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectGreen", - 2000, 3000, EffectColor.TYPE_COLOR, EffectColor.GREEN); - mediaVideoItem1.addEffect(effectGreen); - - final EffectColor effectFifties = - mVideoEditorHelper.createEffectItem(mediaVideoItem1, - "effectFifties", 5000, 4000, EffectColor.TYPE_FIFTIES, 0); - mediaVideoItem1.addEffect(effectFifties); - - List<Effect> effectList = mediaVideoItem1.getAllEffects(); - assertEquals("Effect List Size", 3, effectList.size()); - assertEquals("Effect negative", effectNegative, effectList.get(0)); - assertEquals("Effect Green", effectGreen, effectList.get(1)); - assertEquals("Effect Fifties", effectFifties, effectList.get(2)); - - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_4_3); - assertEquals("Aspect Ratio", MediaProperties.ASPECT_RATIO_4_3, - mVideoEditor.getAspectRatio()); - - final long storyboardDuration = mVideoEditor.getDuration() ; - validatePreviewProgress(0, (int)(storyboardDuration/2), false, (storyboardDuration/2)); - - assertEquals("Removing Effect : Negative", effectNegative, - mediaVideoItem1.removeEffect(effectNegative.getId())); - - effectList = mediaVideoItem1.getAllEffects(); - - assertEquals("Effect List Size", 2, effectList.size()); - assertEquals("Effect Green", effectGreen, effectList.get(0)); - assertEquals("Effect Fifties", effectFifties, effectList.get(1)); - - validatePreviewProgress(0, -1, false, mVideoEditor.getDuration()); - } - - /** - *To test Preview : Preview of current Transitions applied (with multiple - * generatePreview) - */ - @LargeTest - public void testPreviewWithTransition() throws Exception { - - final String videoItemFileName1 = INPUT_FILE_PATH + - "H263_profile0_176x144_10fps_96kbps_0_25.3gp"; - final String imageItemFileName1 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4"; - final String maskFilename = INPUT_FILE_PATH + - "TransitionSpiral_QVGA.jpg"; - previewStart = false; - previewStop = false; - previewError = false; - - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - imageItemFileName1, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem2.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionCrossfade transition1And2CrossFade = - mVideoEditorHelper.createTCrossFade("transition_1_2_CF", - mediaVideoItem1, mediaImageItem1, 2000, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition1And2CrossFade); - - final TransitionAlpha transition2And3Alpha = - mVideoEditorHelper.createTAlpha("transition_2_3", mediaImageItem1, - mediaVideoItem2, 4000, Transition.BEHAVIOR_SPEED_UP, - maskFilename, 50, true); - mVideoEditor.addTransition(transition2And3Alpha); - - final TransitionFadeBlack transition1FadeBlack = - mVideoEditorHelper.createTFadeBlack("transition_1FB", null, - mediaVideoItem1, 2000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition1FadeBlack); - - List<Transition> transitionList = mVideoEditor.getAllTransitions(); - assertEquals("Transition List Size", 3, transitionList.size()); - assertEquals("Transition 1", transition1And2CrossFade, - transitionList.get(0)); - assertEquals("Transition 2", transition2And3Alpha, transitionList.get(1)); - assertEquals("Transition 3", transition1FadeBlack, transitionList.get(2)); - - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_3_2); - - final int[] progressValues = new int[300]; - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - int i = 0; - - public void onProgress(Object item, int action, int progress) { - if (item instanceof TransitionCrossfade) { - progressValues[i] = progress; - assertEquals("Object", item, transition1And2CrossFade); - assertEquals("Action", action, - MediaProcessingProgressListener.ACTION_ENCODE); - } else if (item instanceof TransitionAlpha) { - progressValues[i] = progress; - assertEquals("Object", item, transition2And3Alpha); - assertEquals("Action", action, - MediaProcessingProgressListener.ACTION_ENCODE); - } else if (item instanceof TransitionFadeBlack) { - progressValues[i] = progress; - assertEquals("Object", item, transition1FadeBlack); - assertEquals("Action", action, - MediaProcessingProgressListener.ACTION_ENCODE); - } - i++; - } - }); - - mVideoEditorHelper.checkProgressCBValues(progressValues); - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - /* As transition takes more time buffer of 10 sec is added */ - long waitingTime = minWaitingTime + 10000 + 10000; - - blockTillPreviewCompletes.acquire(); - try { - mVideoEditor.startPreview(surfaceHolder, 0, 10000, false, 1, - new PreviewProgressListener() { - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - blockTillPreviewCompletes.release(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - blockTillPreviewCompletes.release(); - } - }); - } catch (Exception e) { - blockTillPreviewCompletes.release(); - } - blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS); - mVideoEditor.stopPreview(); - blockTillPreviewCompletes.release(); - assertTrue("Preview Failed to start", previewStart); - assertTrue("Preview Failed to stop", previewStop); - assertFalse("Preview Error occurred", previewError); - - assertEquals("Removing Transition " + transition1And2CrossFade.getId(), - transition1And2CrossFade, - mVideoEditor.removeTransition(transition1And2CrossFade.getId())); - transitionList = mVideoEditor.getAllTransitions(); - assertEquals("Transition List Size", 2, transitionList.size()); - assertEquals("Transition 1", transition2And3Alpha, transitionList.get(0)); - assertEquals("Transition 2", transition1FadeBlack, transitionList.get(1)); - - validatePreviewProgress(0, -1, false, mVideoEditor.getDuration()); - - - final TransitionSliding transition1And2Sliding = - mVideoEditorHelper.createTSliding("transition_1_2Sliding", - mediaVideoItem1, mediaImageItem1, 4000, - Transition.BEHAVIOR_MIDDLE_FAST, - TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN); - mVideoEditor.addTransition(transition1And2Sliding); - - transitionList = mVideoEditor.getAllTransitions(); - assertEquals("Transition List Size", 3, transitionList.size()); - assertEquals("Transition 1", transition2And3Alpha, transitionList.get(0)); - assertEquals("Transition 2", transition1FadeBlack, transitionList.get(1)); - assertEquals("Transition 3", transition1And2Sliding, - transitionList.get(2)); - - validatePreviewProgress(5000, -1, false, (mVideoEditor.getDuration())); - - } - - /** - * To test Preview : Preview of current Overlay applied - */ - @LargeTest - public void testPreviewWithOverlay() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String overlayFilename1 = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final String overlayFilename2 = INPUT_FILE_PATH + - "IMG_640x480_Overlay2.png"; - final int previewFrom = 5000; - final int previewTo = 10000; - final boolean previewLoop = false; - final int previewCallbackFrameCount = 1; - final int setAspectRatio = MediaProperties.ASPECT_RATIO_4_3; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - boolean flagForException = false; - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem); - mediaVideoItem.setExtractBoundaries(0, 10000); - - final Bitmap mBitmap1 = mVideoEditorHelper.getBitmap(overlayFilename1, - 640, 480); - final OverlayFrame overlayOnMvi1 = - mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi1", - mBitmap1, 0, 5000); - mediaVideoItem.addOverlay(overlayOnMvi1); - - final Bitmap mBitmap2 = mVideoEditorHelper.getBitmap(overlayFilename2, - 640, 480); - final OverlayFrame overlayOnMvi2 = - mVideoEditorHelper.createOverlay(mediaVideoItem, "OverlayOnMvi2", - mBitmap2, 5000, 9000); - mediaVideoItem.addOverlay(overlayOnMvi2); - - List<Overlay> overlayList = mediaVideoItem.getAllOverlays(); - assertEquals("Overlay Size", 2, overlayList.size()); - assertEquals("Overlay 1", overlayOnMvi1, overlayList.get(0)); - assertEquals("Overlay 2", overlayOnMvi2, overlayList.get(1)); - - mVideoEditor.setAspectRatio(setAspectRatio); - - validatePreviewProgress(0 /* previewFrom */, -1, previewLoop, - mVideoEditor.getDuration()); - } - - /** - * To test Preview : Preview of current Trim applied (with default aspect - * ratio) - */ - @LargeTest - public void testPreviewWithTrim() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName, MediaItem.RENDERING_MODE_CROPPING); - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - boolean flagForException = false; - previewStart = false; - previewStop = false; - mediaVideoItem.setExtractBoundaries(mediaVideoItem.getDuration() / 2, - mediaVideoItem.getDuration()); - mVideoEditor.addMediaItem(mediaVideoItem); - - validatePreviewProgress(1000, -1, false, mVideoEditor.getDuration()); - } - - /** - * To test Preview : Preview of current work having Overlay and Effect - * applied - */ - - @LargeTest - public void testPreviewWithOverlayEffectKenBurn() throws Exception { - - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String videoItemFileName1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final String overlayFilename = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaImageItem mediaImageItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - imageItemFileName, 10000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem2); - - final MediaVideoItem mediaVideoItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem3); - - final EffectColor effectColor = - mVideoEditorHelper.createEffectItem(mediaVideoItem1, "Effect1", - 1000, 3000, EffectColor.TYPE_COLOR, EffectColor.GREEN); - mediaVideoItem1.addEffect(effectColor); - - final Rect startRect = new Rect((mediaImageItem2.getHeight() / 3), - (mediaImageItem2.getWidth() / 3), (mediaImageItem2.getHeight() / 2), - (mediaImageItem2.getWidth() / 2)); - final Rect endRect = new Rect(0, 0, mediaImageItem2.getWidth(), - mediaImageItem2.getHeight()); - - final EffectKenBurns kbeffectOnMI2 = new EffectKenBurns(mediaImageItem2, - "KBOnM2", startRect, endRect, 0, 10000); - assertNotNull("EffectKenBurns", kbeffectOnMI2); - mediaImageItem2.addEffect(kbeffectOnMI2); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFilename, - 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaVideoItem3, "OverlayID", - mBitmap, (mediaImageItem2.getDuration() / 4), - (mediaVideoItem3.getDuration() / 3)); - mediaVideoItem3.addOverlay(overlayFrame); - - validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration()); - } - - /** - *To test Preview : Export during preview - */ - @LargeTest - public void testPreviewDuringExport() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - previewStart = false; - previewStop = false; - previewError = false; - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - - long waitingTime = minWaitingTime + mVideoEditor.getDuration(); - - - blockTillPreviewCompletes.acquire(); - final String fileName = mVideoEditor.getPath() + "/test.3gp"; - final int height = MediaProperties.HEIGHT_480; - final int bitrate = MediaProperties.BITRATE_512K; - - try { - mVideoEditor.export(fileName, height, bitrate, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, - String outFileName,int progress) { - - } - }); - } catch (IOException e) { - assertTrue("UnExpected Error in Export" + - e.toString(), false); - } - - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - try { - - mVideoEditor.startPreview(surfaceHolder, 5000, -1, false, 1, - new PreviewProgressListener() { - - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - blockTillPreviewCompletes.release(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - blockTillPreviewCompletes.release(); - } - }); - - } catch (Exception e) { - blockTillPreviewCompletes.release(); - } - blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS); - mVideoEditor.stopPreview(); - assertTrue("Preview Failed to start", previewStart); - assertTrue("Preview Failed to stop", previewStop); - assertFalse("Preview Error occurred", previewError); - - blockTillPreviewCompletes.release(); - } - - /** - * To test Preview : Preview of current Effects applied (with from time > - * total duration) - */ - @LargeTest - public void testPreviewWithDurationGreaterThanMediaDuration() - throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_192kbps_1_5.mp4"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - boolean flagForException = false; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName, renderingMode); - try { - mediaVideoItem1.setExtractBoundaries(0, 20000); - } catch (Exception e) { - assertTrue("Exception during setExtract Boundaries", false); - } - mVideoEditor.addMediaItem(mediaVideoItem1); - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - long waitingTime = minWaitingTime + (mVideoEditor.getDuration() - 30000); - if(waitingTime < 0) - { - waitingTime = minWaitingTime; - } - - blockTillPreviewCompletes.acquire(); - try { - mVideoEditor.startPreview(surfaceHolder, 30000, -1, true, 1, - new PreviewProgressListener() { - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - blockTillPreviewCompletes.release(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - blockTillPreviewCompletes.release(); - } - }); - - } catch (IllegalArgumentException e) { - blockTillPreviewCompletes.release(); - flagForException = true; - } - blockTillPreviewCompletes.tryAcquire(waitingTime, TimeUnit.MILLISECONDS); - assertTrue("Expected Error in Preview", flagForException); - mVideoEditor.stopPreview(); - blockTillPreviewCompletes.release(); - } - - /** - * To test Preview : Preview of current Effects applied (with Render Preview - * Frame) - */ - @LargeTest - public void testPreviewWithRenderPreviewFrame() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final Semaphore blockTillPreviewCompletes = new Semaphore(1); - boolean flagForException = false; - OverlayData overlayData1 = new OverlayData(); - previewStart = false; - previewStop = false; - - final String overlayFilename1 = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, - "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem); - - final EffectColor effectPink = - mVideoEditorHelper.createEffectItem(mediaVideoItem, - "effectNegativeOnMvi", 1000, 3000, EffectColor.TYPE_COLOR, - EffectColor.PINK); - mediaVideoItem.addEffect(effectPink); - - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - - assertEquals("Render preview Frame at 5 Sec", 5000, - mVideoEditor.renderPreviewFrame(surfaceHolder, 5000, - overlayData1)); - - assertEquals("Render preview Frame at 7 Sec", 7000, - mVideoEditor.renderPreviewFrame(surfaceHolder, 7000, - overlayData1)); - - validatePreviewProgress(5000, -1, false, mVideoEditor.getDuration()); - } - - /** - * To test Preview : Preview of current work from selected jump location - * till end with Audio Track - */ - @LargeTest - public void testPreviewWithEndAudioTrack() throws Exception { - final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final String audioFilename = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - - boolean flagForException = false; - previewStart = false; - previewStop = false; - final MediaImageItem mediaImageItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - imageItemFilename1, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem1); - - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem.setExtractBoundaries(1000, 8000); - mVideoEditor.addMediaItem(mediaVideoItem); - - final MediaImageItem mediaImageItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem2); - - final AudioTrack audioTrack = - mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename); - mVideoEditor.addAudioTrack(audioTrack); - - List<AudioTrack> audioList = mVideoEditor.getAllAudioTracks(); - assertEquals("Audio Track List size", 1, audioList.size()); - assertEquals("Audio Track", audioTrack, audioList.get(0)); - mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_4_3); - - validatePreviewProgress(10000, -1, false, mVideoEditor.getDuration()); - } - - /** - * To test render Preview Frame - */ - @LargeTest - public void testRenderPreviewFrame() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH - + "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH - + "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4"; - final String videoItemFileName3 = INPUT_FILE_PATH - + "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String imageItemFilename1 = INPUT_FILE_PATH - + "IMG_1600x1200.jpg"; - final String imageItemFilename2 = INPUT_FILE_PATH - + "IMG_176x144.jpg"; - final String audioFilename = INPUT_FILE_PATH - + "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - OverlayData overlayData1 = new OverlayData(); - previewStart = false; - previewStop = false; - final MediaVideoItem mediaVideoItem1 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - videoItemFileName2, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 4, - mediaVideoItem2.getDuration() / 2); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final MediaVideoItem mediaVideoItem3 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m3", - videoItemFileName3, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem1.setExtractBoundaries(mediaVideoItem2.getDuration() / 2, - mediaVideoItem2.getDuration()); - mVideoEditor.addMediaItem(mediaVideoItem3); - - final MediaImageItem mediaImageItem4 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m4", - imageItemFilename1, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER); - - final MediaImageItem mediaImageItem5 = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m5", - imageItemFilename2, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER); - - List<MediaItem> mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 3, mediaList.size()); - - mVideoEditor.insertMediaItem(mediaImageItem4, mediaVideoItem2.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 4, mediaList.size()); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); - assertEquals("Media item 4", mediaImageItem4, mediaList.get(2)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(3)); - - mVideoEditor.insertMediaItem(mediaImageItem5, mediaImageItem4.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 5, mediaList.size()); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(0)); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(1)); - assertEquals("Media item 4", mediaImageItem4, mediaList.get(2)); - assertEquals("Media item 5", mediaImageItem5, mediaList.get(3)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); - - mVideoEditor.moveMediaItem(mediaVideoItem1.getId(), - mediaImageItem5.getId()); - mediaList = mVideoEditor.getAllMediaItems(); - assertEquals("Media Item List Size", 5, mediaList.size()); - assertEquals("Media item 2", mediaVideoItem2, mediaList.get(0)); - assertEquals("Media item 4", mediaImageItem4, mediaList.get(1)); - assertEquals("Media item 5", mediaImageItem5, mediaList.get(2)); - assertEquals("Media item 1", mediaVideoItem1, mediaList.get(3)); - assertEquals("Media item 3", mediaVideoItem3, mediaList.get(4)); - - final TransitionCrossfade transition2And4CrossFade = - mVideoEditorHelper.createTCrossFade("transition2And4CrossFade", - mediaVideoItem2, mediaImageItem4, 2000, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition2And4CrossFade); - - final TransitionCrossfade transition1And3CrossFade = - mVideoEditorHelper.createTCrossFade("transition1And3CrossFade", - mediaVideoItem1, mediaVideoItem3, 5000, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(transition1And3CrossFade); - - final AudioTrack audioTrack = - mVideoEditorHelper.createAudio(mVideoEditor, "a1", audioFilename); - audioTrack.setExtractBoundaries(0, 2000); - mVideoEditor.addAudioTrack(audioTrack); - - audioTrack.enableLoop(); - - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - - mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration()/4, overlayData1); - Thread.sleep(1000); - mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration()/2, overlayData1); - Thread.sleep(1000); - mVideoEditor.renderPreviewFrame(surfaceHolder, mVideoEditor.getDuration(), overlayData1); - - } - - /** - * To Test Preview : Without any Media Items in the story Board - */ - @LargeTest - public void testStartPreviewWithoutMediaItems() throws Exception { - boolean flagForException = false; - - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - try{ - mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, - new PreviewProgressListener() { - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - } - }); - }catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Preview without Media Items", flagForException); - } - - /** - * To Test Preview : Add Media and Remove Media Item (Without any Media - * Items in the story Board) - */ - @LargeTest - public void testStartPreviewAddRemoveMediaItems() 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 alphaFilename = INPUT_FILE_PATH + - "TransitionSpiral_QVGA.jpg"; - boolean flagForException = false; - - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", - videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER); - mediaVideoItem.setExtractBoundaries(0, 15000); - mVideoEditor.addMediaItem(mediaVideoItem); - - final MediaImageItem mediaImageItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, "m2", - imageItemFilename1, 15000, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaImageItem); - - final TransitionAlpha transition1And2 = - mVideoEditorHelper.createTAlpha("transition", mediaVideoItem, - mediaImageItem, 3000, Transition.BEHAVIOR_SPEED_UP, - alphaFilename, 10, false); - mVideoEditor.addTransition(transition1And2); - - final EffectColor effectColor = - mVideoEditorHelper.createEffectItem(mediaImageItem, "effect", 5000, - 3000, EffectColor.TYPE_COLOR, EffectColor.PINK); - mediaImageItem.addEffect(effectColor); - - assertEquals("removing Media item 1", mediaVideoItem, - mVideoEditor.removeMediaItem(mediaVideoItem.getId())); - assertEquals("removing Media item 2", mediaImageItem, - mVideoEditor.removeMediaItem(mediaImageItem.getId())); - - try{ - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1, - new PreviewProgressListener() { - public void onProgress(VideoEditor videoEditor, long timeMs, - OverlayData overlayData) { - } - public void onStart(VideoEditor videoEditor) { - setPreviewStart(); - } - public void onStop(VideoEditor videoEditor) { - setPreviewStop(); - } - public void onError(VideoEditor videoEditor, int error) { - setPreviewError(); - } - }); - }catch (IllegalArgumentException e) { - flagForException = true; - } - assertTrue("Preview with removed Media Items", flagForException); - - } - - /** - * To test Preview : Preview of current Effects applied (with Render Preview - * Frame) - */ - @LargeTest - public void testPreviewWithRenderPreviewFrameWithoutGenerate() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - boolean flagForException = false; - long duration = 0; - OverlayData overlayData1 = new OverlayData(); - - final MediaVideoItem mediaVideoItem = - mVideoEditorHelper.createMediaItem(mVideoEditor, - "m1", videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER); - mVideoEditor.addMediaItem(mediaVideoItem); - - final SurfaceHolder surfaceHolder = - MediaFrameworkTest.mSurfaceView.getHolder(); - duration = mVideoEditor.getDuration(); - /* RenderPreviewFrame returns -1 to indicate last frame */ - try { - mVideoEditor.renderPreviewFrame(surfaceHolder, duration, - overlayData1); - } catch ( IllegalStateException e) { - flagForException = true; - } - assertTrue (" Render Preview Frame without generate", flagForException); - duration = mVideoEditor.getDuration() + 1000; - try { - mVideoEditor.renderPreviewFrame(surfaceHolder, duration, - overlayData1); - } catch ( IllegalArgumentException e) { - flagForException = true; - } - assertTrue (" Preview time greater than duration", flagForException); - } -} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java deleted file mode 100644 index d15a535..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/performance/VideoEditorPerformance.java +++ /dev/null @@ -1,1073 +0,0 @@ -/* - * 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.performance; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.Writer; - -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.TransitionCrossfade; -import android.media.videoeditor.TransitionAlpha; -import android.media.videoeditor.TransitionFadeBlack; -import android.media.videoeditor.TransitionSliding; -import android.media.videoeditor.VideoEditor; -import android.os.Environment; -import android.test.ActivityInstrumentationTestCase; -import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener; -import android.os.Environment; -import android.os.SystemClock; -import android.test.ActivityInstrumentationTestCase; -import android.media.videoeditor.VideoEditor.ExportProgressListener; - -import android.util.Log; - -import com.android.mediaframeworktest.MediaFrameworkTest; -import android.test.suitebuilder.annotation.LargeTest; -import com.android.mediaframeworktest.VideoEditorHelper; - -/** - * Junit / Instrumentation - performance measurement for media player and - * recorder - */ -public class VideoEditorPerformance extends - ActivityInstrumentationTestCase<MediaFrameworkTest> { - - private final String TAG = "VideoEditorPerformance"; - - private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; - - private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; - - private final String VIDEOEDITOR_OUTPUT = PROJECT_LOCATION + - "VideoEditorPerformance.txt"; - - public VideoEditorPerformance() { - super("com.android.mediaframeworktest", MediaFrameworkTest.class); - } - - private final String PROJECT_CLASS_NAME = - "android.media.videoeditor.VideoEditorImpl"; - private VideoEditor mVideoEditor; - private VideoEditorHelper mVideoEditorHelper; - - @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(); - } - - private void writeTimingInfo(String testCaseName, String[] information) - throws Exception { - File outFile = new File(VIDEOEDITOR_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(outFile, true)); - output.write(testCaseName + "\n\t"); - for (int i = 0; i < information.length; i++) { - output.write(information[i]); - } - output.write("\n\n"); - output.close(); - } - - private final int NUM_OF_ITERATIONS=20; - - private int calculateTimeTaken(long beginTime, int numIterations) - throws Exception { - final long duration2 = SystemClock.uptimeMillis(); - final long durationToCreateMediaItem = (duration2 - beginTime); - final int timeTaken1 = (int)(durationToCreateMediaItem / numIterations); - return (timeTaken1); - } - - private void createVideoItems(MediaVideoItem[] mediaVideoItem, - String videoItemFileName, int renderingMode, int startTime, int endTime) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i, - videoItemFileName, renderingMode); - mediaVideoItem[i].setExtractBoundaries(startTime, endTime); - } catch (Exception e1) { - assertTrue( - "Can not create an object of Video Item with file name = " - + videoItemFileName + "------ID:m" + i + " Issue = " - + e1.toString(), false); - } - } - } - - private void addVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mVideoEditor.addMediaItem(mediaVideoItem[i]); - } catch (Exception e1) { - assertTrue( - "Can not add an object of Video Item with ID:m" + i + - " Issue = " + e1.toString(), false); - } - } - } - - private void removeVideoItems(MediaVideoItem[] mediaVideoItem) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mVideoEditor.removeMediaItem(mediaVideoItem[i].getId()); - } catch (Exception e1) { - assertTrue( - "Can not Remove an object of Video Item with ID:m" + i + - " Issue = " + e1.toString(), false); - } - } - } - - private void createImageItems(MediaImageItem[] mIi, - String imageItemFileName, int renderingMode, int duration) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mIi[i] = new MediaImageItem(mVideoEditor, "m" + i, - imageItemFileName, duration, renderingMode); - } catch (Exception e1) { - assertTrue( " Cannot create Image Item", false); - } - } - } - - private void addImageItems(MediaImageItem[] mIi) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mVideoEditor.addMediaItem(mIi[i]); - } catch (Exception e1) { - assertTrue("Cannot add Image item", false); - } - } - } - - private void removeImageItems(MediaImageItem[] mIi) throws Exception { - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - try { - mVideoEditor.removeMediaItem(mIi[i].getId()); - } catch (Exception e1) { - assertTrue("Cannot remove image item", false); - } - } - } - /** - * To test the performance of adding and removing the video media item - * - * @throws Exception - */ - @LargeTest - public void testPerformanceAddRemoveVideoItem() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final int videoItemStartTime = 0; - final int videoItemEndTime = 5000; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[3]; - final MediaVideoItem[] mediaVideoItem = - new MediaVideoItem[NUM_OF_ITERATIONS]; - int timeTaken = 0; - long startTime = 0; - - /** Time Take for creation of Media Video Item */ - startTime = SystemClock.uptimeMillis(); - createVideoItems(mediaVideoItem, videoItemFileName, renderingMode, - videoItemStartTime, videoItemEndTime); - - timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS); - loggingInfo[0] = "Time taken to Create Media Video Item :" + - timeTaken; - - /** Time Take for Addition of Media Video Item */ - startTime = SystemClock.uptimeMillis(); - addVideoItems(mediaVideoItem); - timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS); - loggingInfo[1] = "\n\tTime taken to Add Media Video Item :" - + timeTaken; - - /** Time Take for Removal of Media Video Item */ - startTime = SystemClock.uptimeMillis(); - removeVideoItems(mediaVideoItem); - timeTaken = calculateTimeTaken (startTime, NUM_OF_ITERATIONS); - loggingInfo[2] = "\n\tTime taken to remove Media Video Item :" - + timeTaken; - - writeTimingInfo("testPerformanceAddRemoveVideoItem (in mSec)", loggingInfo); - } - - /** - * To test the performance of adding and removing the image media item - * - * @throws Exception - */ - @LargeTest - public void testPerformanceAddRemoveImageItem() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final int imageItemDuration = 0; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[3]; - final MediaImageItem[] mediaImageItem = - new MediaImageItem[NUM_OF_ITERATIONS]; - int timeTaken = 0; - - long beginTime = SystemClock.uptimeMillis(); - createImageItems(mediaImageItem, imageItemFileName, renderingMode, - imageItemDuration); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[0] = "Time taken to Create Media Image Item :" + - timeTaken; - - beginTime = SystemClock.uptimeMillis(); - addImageItems(mediaImageItem); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[1] = "\n\tTime taken to add Media Image Item :" + - timeTaken; - - beginTime = SystemClock.uptimeMillis(); - removeImageItems(mediaImageItem); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[2] = "\n\tTime taken to remove Media Image Item :" - + timeTaken; - - writeTimingInfo("testPerformanceAddRemoveImageItem (in mSec)", - loggingInfo); - } - - /** - * To test the performance of adding and removing the transition - * - * @throws Exception - */ - @LargeTest - public void testPerformanceAddRemoveTransition() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final int videoItemStartTime1 = 0; - final int videoItemEndTime1 = 20000; - final String videoItemFileName2 = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final int videoItemStartTime2 = 0; - final int videoItemEndTime2 = 20000; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int transitionDuration = 5000; - final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST; - final String[] loggingInfo = new String[3]; - int timeTaken = 0; - - final MediaVideoItem[] mediaVideoItem = - new MediaVideoItem[(NUM_OF_ITERATIONS *10) + 1]; - - for (int i = 0; i < (NUM_OF_ITERATIONS *10); i+=2) { - try { - mediaVideoItem[i] = new MediaVideoItem(mVideoEditor, "m" + i, - videoItemFileName1, renderingMode); - mediaVideoItem[i+1] = new MediaVideoItem(mVideoEditor, - "m" + (i+1), videoItemFileName2, renderingMode); - mediaVideoItem[i].setExtractBoundaries(videoItemStartTime1, - videoItemEndTime1); - mediaVideoItem[i+1].setExtractBoundaries(videoItemStartTime2, - videoItemEndTime2); - } catch (Exception e1) { - assertTrue("Can not create Video Object Item with file name = " - + e1.toString(), false); - } - mVideoEditor.addMediaItem(mediaVideoItem[i]); - mVideoEditor.addMediaItem(mediaVideoItem[i+1]); - } - mediaVideoItem[(NUM_OF_ITERATIONS *10)] = new MediaVideoItem(mVideoEditor, - "m" + (NUM_OF_ITERATIONS *10), videoItemFileName1, renderingMode); - mediaVideoItem[(NUM_OF_ITERATIONS *10)].setExtractBoundaries( - videoItemStartTime1, videoItemEndTime1); - mVideoEditor.addMediaItem(mediaVideoItem[(NUM_OF_ITERATIONS *10)]); - final TransitionCrossfade tranCrossfade[] = - new TransitionCrossfade[(NUM_OF_ITERATIONS *10)]; - - long beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) { - tranCrossfade[i] = new TransitionCrossfade("transition" + i, - mediaVideoItem[i], mediaVideoItem[i+1], transitionDuration, - transitionBehavior); - } - timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10)); - loggingInfo[0] = "Time taken to Create CrossFade Transition :" + - timeTaken; - - beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) { - mVideoEditor.addTransition(tranCrossfade[i]); - } - timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10)); - loggingInfo[1] = "\n\tTime taken to add CrossFade Transition :" + - timeTaken; - - beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < (NUM_OF_ITERATIONS *10); i++) { - assertEquals("Removing Transitions", tranCrossfade[i], mVideoEditor - .removeTransition(tranCrossfade[i].getId())); - } - timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS * 10)); - loggingInfo[2] = "\n\tTime taken to remove CrossFade Transition :" + - timeTaken; - - writeTimingInfo("testPerformanceAddRemoveTransition (in mSec)", loggingInfo); - } - - /** - * To test performance of Export - * - * @throws Exception - */ - @LargeTest - public void testPerformanceExport() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int outHeight = MediaProperties.HEIGHT_480; - final int outBitrate = MediaProperties.BITRATE_256K; - final int outVcodec = MediaProperties.VCODEC_H264; - final String[] loggingInfo = new String[1]; - final String outFilename = mVideoEditorHelper - .createRandomFile(mVideoEditor.getPath() + "/") + ".3gp"; - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4"; - final String imageItemFileName1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_32kbps_m_1_17.3gp"; - final String imageItemFileName2 = INPUT_FILE_PATH + "IMG_176x144.jpg"; - final String videoItemFileName3 = INPUT_FILE_PATH + - "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4"; - final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png"; - final String audioTrackFilename = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - final String maskFilename = INPUT_FILE_PATH + - "TransitionSpiral_QVGA.jpg"; - - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", videoItemFileName1, renderingMode); - mediaItem1.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaItem1); - - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2", imageItemFileName1, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3", videoItemFileName2, renderingMode); - mediaItem3.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaItem3); - - final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, - "m4", imageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem4); - - final MediaVideoItem mediaItem5 = new MediaVideoItem(mVideoEditor, - "m5", videoItemFileName3, renderingMode); - mediaItem5.setExtractBoundaries(0, 20000); - mVideoEditor.addMediaItem(mediaItem5); - /** - * 7.Add TransitionAlpha, Apply this Transition as Begin for Media Item 1 - * with duration = 2 sec behavior = BEHAVIOR_LINEAR, mask file name = - * TransitionSpiral_QVGA.jpg , blending percent = 50%, invert = true; - * */ - final TransitionAlpha transition1 = - mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1, - 2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true); - mVideoEditor.addTransition(transition1); - - /** - * 8.Add Transition Sliding between MediaItem 2 and 3 , - * Sliding Direction = DIRECTION_RIGHT_OUT_LEFT_IN, - * behavior = BEHAVIOR_MIDDLE_FAST and duration = 4sec - * */ - final TransitionSliding transition2And3 = - mVideoEditorHelper.createTSliding("transition2", mediaItem2, - mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST, - TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN); - mVideoEditor.addTransition(transition2And3); - - /** - * 9.Add Transition Crossfade between Media Item 3 and 4, - * behavior = BEHAVIOR_MIDDLE_SLOW, duration = 3.5 sec - * */ - final TransitionCrossfade transition3And4 = - mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, - mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW); - mVideoEditor.addTransition(transition3And4); - - /** - * 10.Add Transition Fadeblack between Media Item 4 and 5, - * behavior = BEHAVIOR_SPEED_DOWN, duration = 3.5 sec - * */ - final TransitionFadeBlack transition4And5 = - mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4, - mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN); - mVideoEditor.addTransition(transition4And5); - - /** - * 11.Add Effect 1 type="TYPE_SEPIA" to the MediaItem 1, - * start time=1sec and duration =4secs - * */ - final EffectColor effectColor1 = mVideoEditorHelper.createEffectItem( - mediaItem1, "effect1", 1000, 4000, EffectColor.TYPE_SEPIA, 0); - mediaItem1.addEffect(effectColor1); - - /** - * 12.Add Overlay 1 to the MediaItem 3: Frame Overlay with start time = 1 sec - * duration = 4 sec with item = IMG_640x480_Overlay1.png - * */ - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile, 640, - 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem3, "overlay", - mBitmap, 1000, 4000); - mediaItem3.addOverlay(overlayFrame); - /** - * 13.Add Effect 2 type="TYPE_NEGATIVE" to the MediaItem 2, - * start time=8sec and duration =2secs - * */ - final EffectColor effectColor2 = mVideoEditorHelper.createEffectItem( - mediaItem2, "effect2", 8000, 2000, EffectColor.TYPE_NEGATIVE, 0); - mediaItem2.addEffect(effectColor2); - /** - * 14.Add Effect 3 type="TYPE_COLOR" to the MediaItem 3, color param = "PINK", - * start time=5 sec and duration =3secs - * */ - final EffectColor effectColor3 = mVideoEditorHelper.createEffectItem( - mediaItem3, "effect3", 5000, 3000, EffectColor.TYPE_COLOR, - EffectColor.PINK); - mediaItem3.addEffect(effectColor3); - /** - * 15.Add Effect 4 type="TYPE_FIFTIES" to the MediaItem 4, - * start time=2 sec and duration =1secs - * */ - final EffectColor effectColor4 = mVideoEditorHelper.createEffectItem( - mediaItem4, "effect4", 2000, 1000, EffectColor.TYPE_FIFTIES, 0); - mediaItem4.addEffect(effectColor4); - /** - * 16.Add KenBurnsEffect for MediaItem 4 with - * duration = 3 sec and startTime = 4 sec - * StartRect - * left = org_height/3 ; top = org_width/3 - * bottom = org_width/2 ; right = org_height/2 - * EndRect - * left = 0 ; top = 0 - * bottom = org_height; right = org_width - * */ - - final Rect startRect = new Rect((mediaItem4.getHeight() / 3), - (mediaItem4.getWidth() / 3), (mediaItem4.getHeight() / 2), - (mediaItem4.getWidth() / 2)); - final Rect endRect = new Rect(0, 0, mediaItem4.getWidth(), - mediaItem4.getHeight()); - final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns( - mediaItem4, "KBOnM2", startRect, endRect,4000 , 3000); - mediaItem4.addEffect(kbEffectOnMediaItem); - - /** 17.Add Audio Track,Set extract boundaries o to 10 sec. - * */ - final AudioTrack audioTrack = mVideoEditorHelper.createAudio( - mVideoEditor, "audioTrack", audioTrackFilename); - mVideoEditor.addAudioTrack(audioTrack); - /** 18.Enable Looping for Audio Track. - * */ - audioTrack.enableLoop(); - int timeTaken = 0; - final long beginTime = SystemClock.uptimeMillis(); - try { - mVideoEditor.export(outFilename, outHeight, outBitrate, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, - String outFileName, int progress) { - } - }); - } catch (Exception e) { - assertTrue("Error in Export" + e.toString(), false); - } - mVideoEditorHelper.checkDeleteExistingFile(outFilename); - - timeTaken = calculateTimeTaken(beginTime, 1); - loggingInfo[0] = "Time taken to do ONE export of storyboard duration " - + mVideoEditor.getDuration() + " is :" + timeTaken; - - writeTimingInfo("testPerformanceExport (in mSec)", loggingInfo); - mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath())); - } - - - /** - * To test the performance of thumbnail extraction - * - * @throws Exception - */ - @LargeTest - public void testPerformanceThumbnailVideoItem() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final int videoItemStartTime = 0; - final int videoItemEndTime = 20000; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[1]; - - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "m1", videoItemFileName, renderingMode); - mediaVideoItem.setExtractBoundaries(videoItemStartTime, - videoItemEndTime); - - int timeTaken = 0; - long beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - mediaVideoItem.getThumbnail(mediaVideoItem.getWidth() / 2, - mediaVideoItem.getHeight() / 2, i); - } - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[0] = "Duration taken to get Video Thumbnails :" + - timeTaken; - - writeTimingInfo("testPerformanceThumbnailVideoItem (in mSec)", loggingInfo); - } - - /** - * To test the performance of adding and removing the overlay to media item - * - * @throws Exception - */ - @LargeTest - public void testPerformanceOverlayVideoItem() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final int videoItemStartTime1 = 0; - final int videoItemEndTime1 = 10000; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String overlayFilename = INPUT_FILE_PATH - + "IMG_640x480_Overlay1.png"; - final int overlayStartTime = 1000; - final int overlayDuration = 5000; - - final String[] loggingInfo = new String[2]; - MediaVideoItem mediaVideoItem = null; - - try { - mediaVideoItem = new MediaVideoItem(mVideoEditor, "m0", - videoItemFileName1, renderingMode); - mediaVideoItem.setExtractBoundaries(videoItemStartTime1, - videoItemEndTime1); - } catch (Exception e1) { - assertTrue("Can not create Video Item with file name = " - + e1.toString(), false); - } - final OverlayFrame overlayFrame[] = new OverlayFrame[NUM_OF_ITERATIONS]; - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFilename, - 640, 480); - int timeTaken = 0; - long beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - overlayFrame[i] = new OverlayFrame(mediaVideoItem, "overlay" + i, - mBitmap, overlayStartTime, overlayDuration); - mediaVideoItem.addOverlay(overlayFrame[i]); - } - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[0] = "Time taken to add & create Overlay :" + timeTaken; - - beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - assertEquals("Removing Overlays", overlayFrame[i], - mediaVideoItem.removeOverlay((overlayFrame[i].getId()))); - } - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[1] = "\n\tTime taken to remove Overlay :" + - timeTaken; - - writeTimingInfo("testPerformanceOverlayVideoItem (in mSec)", loggingInfo); - } - - /** - * To test the performance of get properties of a Video media item - * - * @throws Exception - */ - @LargeTest - public void testPerformanceVideoItemProperties() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final int videoItemStartTime1 = 0; - final int videoItemEndTime1 = 10100; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; - final int fileType = MediaProperties.FILE_MP4; - final int videoCodecType = MediaProperties.VCODEC_H264; - final int duration = 77366; - final int videoBitrate = 3169971; - final int fps = 30; - final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - final int width = 1080; - final int height = MediaProperties.HEIGHT_720; - int timeTaken = 0; - final String[] loggingInfo = new String[1]; - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "m0", videoItemFileName1, renderingMode); - mediaVideoItem.setExtractBoundaries(videoItemStartTime1, - videoItemEndTime1); - long beginTime = SystemClock.uptimeMillis(); - for (int i = 0; i < (NUM_OF_ITERATIONS*10); i++) { - try { - assertEquals("Aspect Ratio Mismatch", - aspectRatio, mediaVideoItem.getAspectRatio()); - assertEquals("File Type Mismatch", - fileType, mediaVideoItem.getFileType()); - assertEquals("VideoCodec Mismatch", - videoCodecType, mediaVideoItem.getVideoType()); - assertEquals("duration Mismatch", - duration, mediaVideoItem.getDuration()); - assertEquals("Video Profile ", - videoProfile, mediaVideoItem.getVideoProfile()); - assertEquals("Video Level ", - videoLevel, mediaVideoItem.getVideoLevel()); - assertEquals("Video height ", - height, mediaVideoItem.getHeight()); - assertEquals("Video width ", - width, mediaVideoItem.getWidth()); - } catch (Exception e1) { - assertTrue("Can not create Video Item with file name = " - + e1.toString(), false); - } - } - timeTaken = calculateTimeTaken(beginTime, (NUM_OF_ITERATIONS*10)); - loggingInfo[0] = "Time taken to get Media Properties :" - + timeTaken; - writeTimingInfo("testPerformanceVideoItemProperties:", loggingInfo); - } - - /** - * To test the performance of generatePreview : with Transitions - * - * @throws Exception - */ - @LargeTest - public void testPerformanceGeneratePreviewWithTransitions() - throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String imageItemFileName = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST; - long averageTime = 0; - final String[] loggingInfo = new String[1]; - - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName, renderingMode); - mediaVideoItem.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem); - - final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor, - "mediaItem2", imageItemFileName, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaImageItem); - - final TransitionCrossfade transitionCrossFade = new TransitionCrossfade( - "transitionCrossFade", mediaVideoItem, mediaImageItem, - 5000, transitionBehavior); - mVideoEditor.addTransition(transitionCrossFade); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final long duration2 = SystemClock.uptimeMillis(); - mVideoEditor.removeTransition(transitionCrossFade.getId()); - mVideoEditor.addTransition(transitionCrossFade); - averageTime += (duration2 - duration1); - } - final long durationToAddObjects = averageTime; - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = "Time taken to Generate Preview with transition :" - + timeTaken; - writeTimingInfo("testPerformanceGeneratePreviewWithTransitions:", - loggingInfo); - } - - /** - * To test the performance of generatePreview : with KenBurn - * - * @throws Exception - */ - @LargeTest - public void testPerformanceWithKenBurn() throws Exception { - final String videoItemFileName = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String imageItemFileName = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - long averageTime = 0; - final String[] loggingInfo = new String[1]; - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName, renderingMode); - mediaVideoItem.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaVideoItem); - - final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor, - "mediaItem2", imageItemFileName, 10000, renderingMode); - 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); - mediaImageItem.addEffect(kbEffectOnMediaItem); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final long duration2 = SystemClock.uptimeMillis(); - mediaImageItem.removeEffect(kbEffectOnMediaItem.getId()); - mediaImageItem.addEffect(kbEffectOnMediaItem); - averageTime += duration2 - duration1; - } - - final long durationToAddObjects = (averageTime); - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = "Time taken to Generate KenBurn Effect :" - + timeTaken; - writeTimingInfo("testPerformanceWithKenBurn", loggingInfo); - } - - /** - * To test the performance of generatePreview : with Transitions and - * Effect,Overlapping scenario - * - * @throws Exception - */ - @LargeTest - public void testPerformanceEffectOverlappingTransition() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final int videoStartTime1 = 0; - final int videoEndTime1 = 10000; - final int videoStartTime2 = 0; - final int videoEndTime2 = 10000; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int transitionDuration = 5000; - final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST; - final int effectItemStartTime = 5000; - final int effectItemDurationTime = 5000; - final int effectType = EffectColor.TYPE_COLOR; - final int effectColorType = EffectColor.GREEN; - long averageDuration = 0; - - final String[] loggingInfo = new String[1]; - final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName1, renderingMode); - mediaVideoItem1.setExtractBoundaries(videoStartTime1, videoEndTime1); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor, - "mediaItem2", videoItemFileName2, renderingMode); - mediaVideoItem2.setExtractBoundaries(videoStartTime2, videoEndTime2); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionCrossfade transitionCrossFade = new TransitionCrossfade( - "transitionCrossFade", mediaVideoItem1, mediaVideoItem2, - transitionDuration, transitionBehavior); - mVideoEditor.addTransition(transitionCrossFade); - - final EffectColor effectColor = new EffectColor(mediaVideoItem1, - "effect", effectItemStartTime, effectItemDurationTime, effectType, - effectColorType); - mediaVideoItem1.addEffect(effectColor); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final long duration2 = SystemClock.uptimeMillis(); - mVideoEditor.removeTransition(transitionCrossFade.getId()); - mVideoEditor.addTransition(transitionCrossFade); - averageDuration += (duration2 - duration1); - } - SystemClock.uptimeMillis(); - final long durationToAddObjects = (averageDuration); - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = - "Time taken to testPerformanceEffectOverlappingTransition :" - + timeTaken; - writeTimingInfo("testPerformanceEffectOverlappingTransition:", - loggingInfo); - } - - /** - * To test creation of story board with Transition and Two Effects, Effect - * overlapping transitions - * - * @throws Exception - */ - @LargeTest - public void testPerformanceTransitionWithEffectOverlapping() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH - + "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int transitionDuration = 5000; - final int transitionBehavior = Transition.BEHAVIOR_MIDDLE_FAST; - final int effectItemStartTime1 = 5000; - final int effectItemDurationTime1 = 5000; - final int effectType1 = EffectColor.TYPE_COLOR; - final int effectColorType1 = EffectColor.GREEN; - final int effectItemStartTime2 = 5000; - final int effectItemDurationTime2 = 5000; - final int effectType2 = EffectColor.TYPE_COLOR; - final int effectColorType2 = EffectColor.GREEN; - int averageTime = 0; - final String[] loggingInfo = new String[1]; - - final MediaVideoItem mediaVideoItem1 = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem1); - - final MediaVideoItem mediaVideoItem2 = new MediaVideoItem(mVideoEditor, - "mediaItem2", videoItemFileName2, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem2); - - final TransitionCrossfade transitionCrossFade = new TransitionCrossfade( - "transitionCrossFade", mediaVideoItem1, mediaVideoItem2, - transitionDuration, transitionBehavior); - mVideoEditor.addTransition(transitionCrossFade); - - final EffectColor effectColor1 = new EffectColor(mediaVideoItem1, - "effect1", effectItemStartTime1, effectItemDurationTime1, - effectType1, effectColorType1); - mediaVideoItem1.addEffect(effectColor1); - - final EffectColor effectColor2 = new EffectColor(mediaVideoItem2, - "effect2", effectItemStartTime2, effectItemDurationTime2, - effectType2, effectColorType2); - mediaVideoItem2.addEffect(effectColor2); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - final long duration2 = SystemClock.uptimeMillis(); - mVideoEditor.removeTransition(transitionCrossFade.getId()); - mVideoEditor.addTransition(transitionCrossFade); - averageTime += duration2 - duration1; - } - final long durationToAddObjects = (averageTime); - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = "Time taken to TransitionWithEffectOverlapping :" - + timeTaken; - writeTimingInfo("testPerformanceTransitionWithEffectOverlapping", - loggingInfo); - } - - /** - *To test ThumbnailList for H264 - */ - @LargeTest - public void testThumbnailH264NonIFrame() throws Exception { - final String videoItemFilename = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final int outWidth = 1080; - final int outHeight = 720; - final int atTime = 2400; - long durationToAddObjects = 0; - int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[1]; - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "m1", videoItemFilename, renderingMode); - assertNotNull("MediaVideoItem", mediaVideoItem); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i); - final long duration2 = SystemClock.uptimeMillis(); - durationToAddObjects += (duration2 - duration1); - } - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = "Time taken for Thumbnail generation :" - + timeTaken; - writeTimingInfo("testThumbnailH264NonIFrame", loggingInfo); - } - - /** - *To test ThumbnailList for H264 - */ - @LargeTest - public void testThumbnailH264AnIFrame() throws Exception { - final String videoItemFilename = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final int outWidth = 1080; - final int outHeight = 720; - final int atTime = 3000; - int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[1]; - long durationToAddObjects = 0; - - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "m1", videoItemFilename, renderingMode); - assertNotNull("MediaVideoItem", mediaVideoItem); - - for (int i = 0; i < NUM_OF_ITERATIONS; i++) { - final long duration1 = SystemClock.uptimeMillis(); - mediaVideoItem.getThumbnail(outWidth, outHeight, atTime + i); - final long duration2 = SystemClock.uptimeMillis(); - durationToAddObjects += (duration2 - duration1); - } - final float timeTaken = (float)durationToAddObjects * - 1.0f/(float)NUM_OF_ITERATIONS; - loggingInfo[0] = "Time taken Thumbnail generation :" - + timeTaken; - writeTimingInfo("testThumbnailH264AnIFrame", loggingInfo); - } - - /** - * To test the performance : With an audio track - * - * @throws Exception - */ - @LargeTest - public void testPerformanceWithAudioTrack() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String audioFilename1 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - final String audioFilename2 = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int audioVolume = 50; - final String[] loggingInfo = new String[2]; - int timeTaken = 0; - - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem); - - final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, - "Audio Track1", audioFilename1); - audioTrack1.disableDucking(); - audioTrack1.setVolume(audioVolume); - mVideoEditor.addAudioTrack(audioTrack1); - - long beginTime = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - timeTaken = calculateTimeTaken(beginTime, 1); - loggingInfo[0] = "Time taken for 1st Audio Track (AACLC) :" - + timeTaken; - - final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor, - "Audio Track2", audioFilename2); - audioTrack2.enableLoop(); - - beginTime = SystemClock.uptimeMillis(); - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - timeTaken = calculateTimeTaken(beginTime, 1); - loggingInfo[1] = "\n\tTime taken for 2nd Audio Track(AMRNB) :" - + timeTaken; - - writeTimingInfo("testPerformanceWithAudioTrack", loggingInfo); - } - - /** - * To test the performance of adding and removing the - * image media item with 640 x 480 - * - * @throws Exception - */ - @LargeTest - public void testPerformanceAddRemoveImageItem640x480() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final int imageItemDuration = 0; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[3]; - - int timeTaken = 0; - - final MediaImageItem[] mediaImageItem = - new MediaImageItem[NUM_OF_ITERATIONS]; - long beginTime = SystemClock.uptimeMillis(); - createImageItems(mediaImageItem, imageItemFileName, renderingMode, - imageItemDuration); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[0] = "Time taken to Create Media Image Item (640x480) :" - + timeTaken; - - beginTime = SystemClock.uptimeMillis(); - addImageItems(mediaImageItem); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[1] = "\n\tTime taken to add Media Image Item (640x480) :" - + timeTaken; - - beginTime = SystemClock.uptimeMillis(); - removeImageItems(mediaImageItem); - timeTaken = calculateTimeTaken(beginTime, NUM_OF_ITERATIONS); - loggingInfo[2] = "\n\tTime taken to remove Media Image Item (640x480) :" - + timeTaken; - writeTimingInfo("testPerformanceAddRemoveImageItem640x480 (in mSec)", loggingInfo); - } - - -} diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java deleted file mode 100644 index 7784c7b..0000000 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/stress/VideoEditorStressTest.java +++ /dev/null @@ -1,1309 +0,0 @@ -/* - * 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.stress; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.Writer; -import java.util.List; - -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.TransitionCrossfade; -import android.media.videoeditor.TransitionAlpha; -import android.media.videoeditor.TransitionFadeBlack; -import android.media.videoeditor.TransitionSliding; -import android.media.videoeditor.VideoEditor; -import android.os.Environment; -import android.test.ActivityInstrumentationTestCase; -import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener; -import android.os.Environment; -import android.os.SystemClock; -import android.test.ActivityInstrumentationTestCase; -import android.media.videoeditor.VideoEditor.ExportProgressListener; -import android.media.videoeditor.VideoEditorFactory; -import android.media.videoeditor.ExtractAudioWaveformProgressListener; - -import android.os.Debug; -import android.util.Log; -import com.android.mediaframeworktest.MediaFrameworkPerfTestRunner; -import com.android.mediaframeworktest.MediaFrameworkTest; -import android.test.suitebuilder.annotation.LargeTest; -import com.android.mediaframeworktest.VideoEditorHelper; -import com.android.mediaframeworktest.MediaTestUtil; - -/** - * Junit / Instrumentation - performance measurement for media player and - * recorder - */ -public class VideoEditorStressTest - extends ActivityInstrumentationTestCase<MediaFrameworkTest> { - - private final String TAG = "VideoEditorStressTest"; - - private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON; - - private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON; - - private final String VIDEOEDITOR_OUTPUT = PROJECT_LOCATION + - "VideoEditorStressMemOutput.txt"; - - private long BeginJavaMemory; - private long AfterJavaMemory; - - private long BeginNativeMemory; - private long AfterNativeMemory; - - public VideoEditorStressTest() { - super("com.android.mediaframeworktest", MediaFrameworkTest.class); - new File(VIDEOEDITOR_OUTPUT).delete(); - } - - private final String PROJECT_CLASS_NAME = - "android.media.videoeditor.VideoEditorImpl"; - private VideoEditor mVideoEditor; - private MediaTestUtil mMediaTestUtil; - private VideoEditorHelper mVideoEditorHelper; - - @Override - protected void setUp() throws Exception { - // setup for each test case. - super.setUp(); - getActivity(); - mMediaTestUtil = new MediaTestUtil( - "/sdcard/VideoEditorMediaServerMemoryLog.txt", - this.getName(), "mediaserver"); - 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 { - final String[] loggingInfo = new String[1]; - mMediaTestUtil.getMemorySummary(); - loggingInfo[0] = "\n" +this.getName(); - writeTimingInfo(loggingInfo); - loggingInfo[0] = " diff : " + (AfterNativeMemory - BeginNativeMemory); - writeTimingInfo(loggingInfo); - mVideoEditorHelper.destroyVideoEditor(mVideoEditor); - // Clean the directory created as project path - mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath())); - System.gc(); - super.tearDown(); - } - - private void writeTimingInfo(String[] information) - throws Exception { - File outFile = new File(VIDEOEDITOR_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(outFile, true)); - for (int i = 0; i < information.length; i++) { - output.write(information[i]); - } - output.close(); - } - - private void writeTestCaseHeader(String testCaseName) - throws Exception { - File outFile = new File(VIDEOEDITOR_OUTPUT); - Writer output = new BufferedWriter(new FileWriter(outFile, true)); - output.write("\n\n" + testCaseName + "\n"); - output.close(); - } - - private void getBeginMemory() throws Exception { - System.gc(); - Thread.sleep(2500); - BeginNativeMemory = Debug.getNativeHeapAllocatedSize(); - mMediaTestUtil.getStartMemoryLog(); - } - private void getAfterMemory_updateLog(String[] loggingInfo, boolean when, - int iteration) - throws Exception { - System.gc(); - Thread.sleep(2500); - AfterNativeMemory = Debug.getNativeHeapAllocatedSize(); - if(when == false){ - loggingInfo[0] = "\n Before Remove: iteration No.= " + iteration + - "\t " + (AfterNativeMemory - BeginNativeMemory); - } else { - loggingInfo[0] = "\n After Remove: iteration No.= " + iteration + - "\t " + (AfterNativeMemory - BeginNativeMemory); - } - writeTimingInfo(loggingInfo); - mMediaTestUtil.getMemoryLog(); - } - - /** - * To stress test MediaItem(Video Item) adding functionality - * - * @throws Exception - */ - @LargeTest - public void testStressAddRemoveVideoItem() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_176x144_15fps_144kbps_AMRNB_8kHz_12.2kbps_m_1_17.3gp"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4"; - final String videoItemFileName3 = INPUT_FILE_PATH + - "H263_profile0_176x144_15fps_128kbps_1_35.3gp"; - final String videoItemFileName4 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String[] loggingInfo = new String[1]; - writeTestCaseHeader("testStressAddRemoveVideoItem"); - int i = 0; - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1" + i, videoItemFileName1, renderingMode); - mediaItem1.setExtractBoundaries(0, 5000); - mVideoEditor.addMediaItem(mediaItem1); - } - if (i % 4 == 1) { - final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, - "m2" + i, videoItemFileName2, renderingMode); - mediaItem2.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaItem2); - } - if (i % 4 == 2) { - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3" + i, videoItemFileName3, renderingMode); - mediaItem3.setExtractBoundaries(30000, 45000); - mVideoEditor.addMediaItem(mediaItem3); - } - if (i % 4 == 3) { - final MediaVideoItem mediaItem4 = new MediaVideoItem(mVideoEditor, - "m4" + i, videoItemFileName4, renderingMode); - mediaItem4.setExtractBoundaries(10000, 30000); - mVideoEditor.addMediaItem(mediaItem4); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - mVideoEditor.removeMediaItem("m1" + i); - } - if (i % 4 == 1) { - mVideoEditor.removeMediaItem("m2" + i); - } - if (i % 4 == 2) { - mVideoEditor.removeMediaItem("m3" + i); - } - if (i % 4 == 3) { - mVideoEditor.removeMediaItem("m4" + i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, true, i); - } - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test MediaItem(Image Item) adding functionality - * - * @throws Exception - */ - @LargeTest - public void testStressAddRemoveImageItem() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String ImageItemFileName1 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String ImageItemFileName3 = INPUT_FILE_PATH + - "IMG_320x240.jpg"; - final String ImageItemFileName4 = INPUT_FILE_PATH + - "IMG_176x144.jpg"; - final String[] loggingInfo = new String[1]; - int i = 0; - writeTestCaseHeader("testStressAddRemoveImageItem"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - final MediaImageItem mediaItem1 = new MediaImageItem(mVideoEditor, - "m1"+ i, ImageItemFileName1, 5000, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - } - if (i % 4 == 1) { - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2"+ i, ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - } - if (i % 4 == 2) { - final MediaImageItem mediaItem3 = new MediaImageItem(mVideoEditor, - "m3"+ i, ImageItemFileName3, 15000, renderingMode); - mVideoEditor.addMediaItem(mediaItem3); - } - if (i % 4 == 3) { - final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, - "m4"+ i, ImageItemFileName4, 20000, renderingMode); - mVideoEditor.addMediaItem(mediaItem4); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - mVideoEditor.removeMediaItem("m1"+i); - } - if (i % 4 == 1) { - mVideoEditor.removeMediaItem("m2"+i); - } - if (i % 4 == 2) { - mVideoEditor.removeMediaItem("m3"+i); - } - if (i % 4 == 3) { - mVideoEditor.removeMediaItem("m4"+i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, true, i); - } - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test transition - * - * @throws Exception - */ - @LargeTest - public void testStressAddRemoveTransition() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_800x480_15fps_512kbps_1_17.mp4"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String VideoItemFileName3 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final String maskFilename = INPUT_FILE_PATH + - "TransitionSpiral_QVGA.jpg"; - final String[] loggingInfo = new String[1]; - int i = 0; - writeTestCaseHeader("testStressAddRemoveTransition"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1"+i, VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - final TransitionCrossfade tranCrossfade = - new TransitionCrossfade("transCF" + i, null, - mediaItem1, 5000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(tranCrossfade); - } - if (i % 4 == 1) { - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1"+i, VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2" +i, ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - - final TransitionAlpha transitionAlpha = - mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem1, - mediaItem2, 5000, Transition.BEHAVIOR_SPEED_UP, - maskFilename, 10, false); - transitionAlpha.setDuration(4000); - mVideoEditor.addTransition(transitionAlpha); - } - if (i % 4 == 2) { - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2" + i, ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3" + i, VideoItemFileName3, renderingMode); - mVideoEditor.addMediaItem(mediaItem3); - - mediaItem3.setExtractBoundaries(0, 10000); - final TransitionAlpha transitionAlpha = - mVideoEditorHelper.createTAlpha("transAlpha" + i, mediaItem2, - mediaItem3, 5000, Transition.BEHAVIOR_SPEED_UP, - maskFilename, 10, false); - transitionAlpha.setDuration(4000); - mVideoEditor.addTransition(transitionAlpha); - - mediaItem3.setExtractBoundaries(0, 6000); - - final TransitionSliding transition2And3 = - mVideoEditorHelper.createTSliding("transSlide" +i, mediaItem2, - mediaItem3, 3000, Transition.BEHAVIOR_MIDDLE_FAST, - TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN); - mVideoEditor.addTransition(transition2And3); - } - if (i % 4 == 3) { - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3" + i, VideoItemFileName3, renderingMode); - mVideoEditor.addMediaItem(mediaItem3); - mediaItem3.setExtractBoundaries(0, 5000); - - final TransitionFadeBlack transition3 = - mVideoEditorHelper.createTFadeBlack("transFB" +i, mediaItem3, - null, 2500, Transition.BEHAVIOR_SPEED_UP); - transition3.setDuration(500); - mVideoEditor.addTransition(transition3); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - mVideoEditor.removeTransition("transCF" + i); - mVideoEditor.removeMediaItem("m1" + i); - } - if (i % 4 == 1) { - mVideoEditor.removeTransition("transAlpha" + i); - mVideoEditor.removeMediaItem("m1" + i); - mVideoEditor.removeMediaItem("m2" + i); - } - if (i % 4 == 2) { - mVideoEditor.removeTransition("transSlide" +i); - mVideoEditor.removeMediaItem("m2" + i); - mVideoEditor.removeMediaItem("m3" + i); - } - if (i % 4 == 3) { - mVideoEditor.removeMediaItem("m3" + i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, true, i); - } - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test overlay - * - * @throws Exception - */ - @LargeTest - public void testStressAddRemoveOverlay() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String OverlayFile3 = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final String OverlayFile4 = INPUT_FILE_PATH + - "IMG_640x480_Overlay2.png"; - final String[] loggingInfo = new String[1]; - int i = 0; - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2", ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - writeTestCaseHeader("testStressAddRemoveOverlay"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 3 == 0) { - mediaItem1.setExtractBoundaries(0, 10000); - final Bitmap mBitmap = mVideoEditorHelper.getBitmap( - OverlayFile3, 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, - mBitmap, 1000, 5000); - mediaItem1.addOverlay(overlayFrame); - mediaItem1.removeOverlay("overlay"+i); - } - if (i % 3 == 1) { - final Bitmap mBitmap = mVideoEditorHelper.getBitmap( - OverlayFile4, 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem2, "overlay" + i, - mBitmap, 1000, 5000); - mediaItem2.addOverlay(overlayFrame); - mediaItem2.removeOverlay("overlay"+i); - } - if (i % 3 == 2) { - mediaItem1.setExtractBoundaries(0, 10000); - final Bitmap mBitmap = mVideoEditorHelper.getBitmap( - OverlayFile4, 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, - mBitmap, 0, mediaItem1.getDuration()); - mediaItem1.addOverlay(overlayFrame); - mediaItem1.removeOverlay("overlay"+i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - } - - /** - * To stress test Effects - * - * @throws Exception - */ - @LargeTest - public void testStressAddRemoveEffects() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String[] loggingInfo = new String[1]; - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2", ImageItemFileName2, 10000, renderingMode); - int i = 0; - mVideoEditor.addMediaItem(mediaItem2); - writeTestCaseHeader("testStressAddRemoveEffects"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 5 == 0) { - mediaItem1.setExtractBoundaries(10000, 30000); - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem1, "effect1"+i, - 10000, (mediaItem1.getTimelineDuration()-1000), - EffectColor.TYPE_COLOR, EffectColor.GREEN); - mediaItem1.addEffect(effectColor1); - } - if (i % 5 == 1) { - mediaItem2.setDuration(20000); - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem2, "effect1"+i, - 0, 4000, EffectColor.TYPE_GRADIENT, EffectColor.GRAY); - mediaItem2.addEffect(effectColor1); - } - if (i % 5 == 2) { - mediaItem1.setExtractBoundaries(10000, 30000); - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem1, "effect1"+i, - (mediaItem1.getTimelineDuration() - 4000), 4000, - EffectColor.TYPE_SEPIA, 0); - mediaItem1.addEffect(effectColor1); - } - if (i % 5 == 3) { - mediaItem2.setDuration(20000); - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem2, "effect1"+i, - 10000, 4000, EffectColor.TYPE_NEGATIVE, 0); - mediaItem2.addEffect(effectColor1); - } - if (i % 5 == 4) { - mediaItem2.setDuration(20000); - final Rect startRect = new Rect((mediaItem2.getHeight() / 3), - (mediaItem2.getWidth() / 3), (mediaItem2.getHeight() / 2), - (mediaItem2.getWidth() / 2)); - final Rect endRect = new Rect(0, 0, mediaItem2.getWidth(), - mediaItem2.getHeight()); - final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns( - mediaItem2, "KBOnM2" + i, startRect, endRect, 500, - (mediaItem2.getDuration() - 500)); - mediaItem2.addEffect(kbEffectOnMediaItem); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 50; i++) { - if (i % 5 == 0) { - mediaItem1.removeEffect("effect1"+i); - } - if (i % 5 == 1) { - mediaItem1.removeEffect("effect1"+i); - } - if (i % 5 == 2) { - mediaItem1.removeEffect("effect1"+i); - } - if (i % 5 == 3) { - mediaItem1.removeEffect("effect1"+i); - } - if (i % 5 == 4) { - mediaItem1.removeEffect("KBOnM2"+i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, true, i); - } - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * This method will test thumbnail list extraction in a loop = 200 for Video - * Item - * - * @throws Exception - */ - @LargeTest - public void testStressThumbnailVideoItem() 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 String[] loggingInfo = new String[1]; - int i = 0; - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "m1", videoItemFileName, renderingMode); - writeTestCaseHeader("testStressThumbnailVideoItem"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - final Bitmap[] thumbNails = - mediaVideoItem.getThumbnailList(mediaVideoItem.getWidth()*3, - mediaVideoItem.getHeight()/2, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 1) { - final Bitmap[] thumbNails = - mediaVideoItem.getThumbnailList(mediaVideoItem.getWidth()/2, - mediaVideoItem.getHeight() * 3, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 2) { - final Bitmap[] thumbNails = - mediaVideoItem.getThumbnailList(mediaVideoItem.getWidth()*2, - mediaVideoItem.getHeight() / 3, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 3) { - final Bitmap[] thumbNails = - mediaVideoItem.getThumbnailList(mediaVideoItem.getWidth(), - mediaVideoItem.getHeight(), i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - } - - /** - * To stress test media properties - * - * @throws Exception - */ - @LargeTest - public void testStressMediaProperties() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String AudioItemFileName3 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - final String[] loggingInfo = new String[1]; - int i = 0; - final int videoAspectRatio = MediaProperties.ASPECT_RATIO_3_2; - final int videoFileType = MediaProperties.FILE_MP4; - final int videoCodecType = MediaProperties.VCODEC_H264; - final int videoDuration = 77366; - final int videoProfile = MediaProperties.H264Profile.H264ProfileBaseline; - final int videoLevel = MediaProperties.H264Level.H264Level13; - final int videoHeight = MediaProperties.HEIGHT_720; - final int videoWidth = 1080; - - final int imageAspectRatio = MediaProperties.ASPECT_RATIO_4_3; - final int imageFileType = MediaProperties.FILE_JPEG; - final int imageWidth = 640; - final int imageHeight = MediaProperties.HEIGHT_480; - - final int audioDuration = 77554; - final int audioCodecType = MediaProperties.ACODEC_AAC_LC; - final int audioSamplingFrequency = 44100; - final int audioChannel = 2; - writeTestCaseHeader("testStressMediaProperties"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 3 == 0) { - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1" + i, VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 20000); - assertEquals("Aspect Ratio Mismatch", - videoAspectRatio, mediaItem1.getAspectRatio()); - assertEquals("File Type Mismatch", - videoFileType, mediaItem1.getFileType()); - assertEquals("VideoCodec Mismatch", - videoCodecType, mediaItem1.getVideoType()); - assertEquals("duration Mismatch", - videoDuration, mediaItem1.getDuration()); - assertEquals("Video Profile ", - videoProfile, mediaItem1.getVideoProfile()); - assertEquals("Video Level ", - videoLevel, mediaItem1.getVideoLevel()); - assertEquals("Video height ", - videoHeight, mediaItem1.getHeight()); - assertEquals("Video width ", - videoWidth, mediaItem1.getWidth()); - mVideoEditor.removeMediaItem("m1" + i); - } - if (i % 3 == 1) { - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2" + i, ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - assertEquals("Aspect Ratio Mismatch", - imageAspectRatio, mediaItem2.getAspectRatio()); - assertEquals("File Type Mismatch", - imageFileType, mediaItem2.getFileType()); - assertEquals("Image height", - imageHeight, mediaItem2.getHeight()); - assertEquals("Image width", - imageWidth, mediaItem2.getWidth()); - mVideoEditor.removeMediaItem("m2" + i); - } - if (i % 3 == 2) { - final AudioTrack mediaItem3 = new AudioTrack(mVideoEditor, - "m3" + i, AudioItemFileName3); - mVideoEditor.addAudioTrack(mediaItem3); - assertEquals("AudioType Mismatch", audioCodecType, - mediaItem3.getAudioType()); - assertEquals("Audio Sampling", audioSamplingFrequency, - mediaItem3.getAudioSamplingFrequency()); - assertEquals("Audio Channels", - audioChannel, mediaItem3.getAudioChannels()); - assertEquals("duration Mismatch", audioDuration, - mediaItem3.getDuration()); - mVideoEditor.removeAudioTrack("m3" + i); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - } - - /** - * To stress test insert and move of mediaitems - * - * @throws Exception - */ - @LargeTest - public void testStressInsertMovieItems() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String VideoItemFileName2 = INPUT_FILE_PATH + - "H264_BP_800x480_15fps_512kbps_1_17.mp4"; - final String VideoItemFileName3 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String[] loggingInfo = new String[1]; - int i = 0; - writeTestCaseHeader("testStressInsertMovieItems"); - - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - - final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, - "m2", VideoItemFileName2, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - mediaItem2.setExtractBoundaries(0, 15000); - - getBeginMemory(); - for ( i = 0; i < 50; i++) { - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3" + i, VideoItemFileName3, renderingMode); - mediaItem3.setExtractBoundaries(0, 15000); - mVideoEditor.insertMediaItem(mediaItem3, "m1"); - mVideoEditor.moveMediaItem("m2", "m3" + i); - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 50; i++) { - mVideoEditor.removeMediaItem("m3" + i); - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, true, i); - } - } - mVideoEditor.removeMediaItem("m2"); - mVideoEditor.removeMediaItem("m1"); - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test : load and save - * - * @throws Exception - */ - @LargeTest - public void testStressLoadAndSave() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String VideoItemFileName2 = INPUT_FILE_PATH + - "H264_BP_800x480_15fps_512kbps_1_17.mp4"; - final String VideoItemFileName3 = INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_1200kbps_AACLC_48khz_64kbps_m_1_17.3gp"; - final String ImageItemFileName4 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String ImageItemFileName5 = INPUT_FILE_PATH + - "IMG_176x144.jpg"; - final String OverlayFile6 = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final String[] loggingInfo = new String[1]; - int i = 0; - final String[] projectPath = new String[10]; - writeTestCaseHeader("testStressLoadAndSave"); - getBeginMemory(); - for( i=0; i < 10; i++){ - - projectPath[i] = - mVideoEditorHelper.createRandomFile(PROJECT_LOCATION); - final VideoEditor mVideoEditor1 = - mVideoEditorHelper.createVideoEditor(projectPath[i]); - - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor1, - "m1", VideoItemFileName1, renderingMode); - mVideoEditor1.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - - final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor1, - "m2", VideoItemFileName2, renderingMode); - mVideoEditor1.addMediaItem(mediaItem2); - mediaItem2.setExtractBoundaries(mediaItem2.getDuration()/4, - mediaItem2.getDuration()/2); - - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor1, - "m3", VideoItemFileName3, renderingMode); - mVideoEditor1.addMediaItem(mediaItem3); - mediaItem3.setExtractBoundaries(mediaItem3.getDuration()/2, - mediaItem3.getDuration()); - - final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor1, - "m4", ImageItemFileName4, 5000, renderingMode); - mVideoEditor1.addMediaItem(mediaItem4); - - final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor1, - "m5", ImageItemFileName5, 5000, renderingMode); - mVideoEditor1.addMediaItem(mediaItem5); - - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem3, "effect1", - 10000, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN); - mediaItem3.addEffect(effectColor1); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile6, - 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem4, "overlay", - mBitmap, 4000, 1000); - mediaItem4.addOverlay(overlayFrame); - - final TransitionCrossfade tranCrossfade = - new TransitionCrossfade("transCF", mediaItem1, - mediaItem2, 5000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor1.addTransition(tranCrossfade); - - final EffectColor effectColor2 = - mVideoEditorHelper.createEffectItem(mediaItem4, "effect2", 0, - mediaItem4.getDuration(), EffectColor.TYPE_COLOR, - EffectColor.PINK); - mediaItem4.addEffect(effectColor2); - - mVideoEditor1.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - - mVideoEditor1.save(); - mVideoEditor1.release(); - - getAfterMemory_updateLog(loggingInfo, false, i); - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for( i=0; i<10; i++){ - final VideoEditor mVideoEditor1b = - VideoEditorFactory.load(projectPath[i], true); - List<MediaItem> mediaList = mVideoEditor1b.getAllMediaItems(); - assertEquals("Media Item List Size", 5, mediaList.size()); - - mediaList.get(3).removeEffect("effect1"); - mediaList.get(3).removeEffect("effect2"); - mediaList.get(2).removeOverlay("overlay"); - mVideoEditor1b.removeTransition("transCF"); - mVideoEditor1b.removeMediaItem("m5"); - mVideoEditor1b.removeMediaItem("m4"); - mVideoEditor1b.removeMediaItem("m3"); - mVideoEditor1b.removeMediaItem("m2"); - mVideoEditor1b.removeMediaItem("m1"); - mVideoEditor1b.release(); - getAfterMemory_updateLog(loggingInfo, true, i); - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test : Multiple Export - * - * @throws Exception - */ - @LargeTest - public void testStressMultipleExport() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String VideoItemFileName2 = INPUT_FILE_PATH + - "H264_BP_800x480_15fps_512kbps_1_17.mp4"; - final String[] loggingInfo = new String[1]; - final String outFilename = mVideoEditorHelper.createRandomFile( - mVideoEditor.getPath() + "/") + ".3gp"; - int i = 0; - writeTestCaseHeader("testStressMultipleExport"); - getBeginMemory(); - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - - final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, - "m2", VideoItemFileName2, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - mediaItem2.setExtractBoundaries(0, 15000); - - for ( i = 0; i < 50; i++) { - if(i%4 ==0){ - final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9; - mVideoEditor.setAspectRatio(aspectRatio); - mVideoEditor.export(outFilename, MediaProperties.HEIGHT_288, - MediaProperties.BITRATE_256K,MediaProperties.ACODEC_AAC_LC, - MediaProperties.VCODEC_H263, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, String outFileName, - int progress) { - } - }); - } - if(i%4 ==1){ - final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3; - mVideoEditor.setAspectRatio(aspectRatio); - mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, - MediaProperties.BITRATE_384K,MediaProperties.ACODEC_AAC_LC, - MediaProperties.VCODEC_MPEG4, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, String outFileName, - int progress) { - } - }); - } - if(i%4 ==2){ - final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9; - mVideoEditor.setAspectRatio(aspectRatio); - mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144, - MediaProperties.BITRATE_512K,MediaProperties.ACODEC_AAC_LC, - MediaProperties.VCODEC_H264, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, String outFileName, - int progress) { - } - }); - } - if(i%4 ==3){ - final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2; - mVideoEditor.setAspectRatio(aspectRatio); - mVideoEditor.export(outFilename, MediaProperties.HEIGHT_480, - MediaProperties.BITRATE_800K,MediaProperties.ACODEC_AAC_LC, - MediaProperties.VCODEC_H264, - new ExportProgressListener() { - public void onProgress(VideoEditor ve, String outFileName, - int progress) { - } - }); - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - mVideoEditor.removeMediaItem("m2"); - mVideoEditor.removeMediaItem("m1"); - - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To stress test Media Item,Overlays,Transitions and Ken Burn - * - * @throws Exception - */ - @LargeTest - public void testStressOverlayTransKenBurn() throws Exception { - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String VideoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_640x480_30fps_256kbps_1_17.mp4"; - final String ImageItemFileName2 = INPUT_FILE_PATH + - "IMG_640x480.jpg"; - final String OverlayFile3 = INPUT_FILE_PATH + - "IMG_640x480_Overlay1.png"; - final String audioFilename4 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - int i = 0; - final String[] loggingInfo = new String[1]; - writeTestCaseHeader("testStressOverlayTransKenBurn"); - getBeginMemory(); - for ( i = 0; i < 10; i++) { - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1" + i, VideoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaItem1); - mediaItem1.setExtractBoundaries(0, 10000); - - final MediaImageItem mediaItem2 = new MediaImageItem(mVideoEditor, - "m2" + i, ImageItemFileName2, 10000, renderingMode); - mVideoEditor.addMediaItem(mediaItem2); - - final EffectColor effectColor1 = - mVideoEditorHelper.createEffectItem(mediaItem1, "effect1"+i, - (mediaItem1.getDuration() - 4000), 4000, - EffectColor.TYPE_SEPIA, 0); - mediaItem1.addEffect(effectColor1); - - final TransitionCrossfade tranCrossfade = - new TransitionCrossfade("transCF" + i, mediaItem1, - mediaItem2, 4000, Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(tranCrossfade); - - final Bitmap mBitmap = mVideoEditorHelper.getBitmap(OverlayFile3, - 640, 480); - final OverlayFrame overlayFrame = - mVideoEditorHelper.createOverlay(mediaItem1, "overlay" + i, - mBitmap, 1000, 5000); - mediaItem1.addOverlay(overlayFrame); - - final Rect startRect = new Rect((mediaItem2.getHeight() / 3), - (mediaItem2.getWidth() / 3), (mediaItem2.getHeight() / 2), - (mediaItem2.getWidth() / 2)); - final Rect endRect = new Rect(0, 0, mediaItem2.getWidth(), - mediaItem2.getHeight()); - - final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns( - mediaItem2, "KBOnM2" + i, startRect, endRect, 500, - (mediaItem2.getDuration()-500)); - mediaItem2.addEffect(kbEffectOnMediaItem); - - if(i == 5) { - final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, - "Audio Track1", audioFilename4); - mVideoEditor.addAudioTrack(audioTrack1); - } - getAfterMemory_updateLog(loggingInfo, false, i); - } - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - for ( i = 0; i < 10; i++) { - MediaImageItem m2 = (MediaImageItem)mVideoEditor.getMediaItem("m2"+i); - MediaVideoItem m1 = (MediaVideoItem)mVideoEditor.getMediaItem("m1"+i); - m2.removeEffect("KBOnM2" + i); - m1.removeOverlay("overlay" + i); - mVideoEditor.removeTransition("transCF" + i); - m1.removeEffect("effect1" + i); - mVideoEditor.removeMediaItem("m2" + i); - mVideoEditor.removeMediaItem("m1" + i); - if(i == 5) { - mVideoEditor.removeAudioTrack("Audio Track1"); - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To test the performance : With an audio track with Video - * - * @throws Exception - */ - @LargeTest - public void testStressAudioTrackVideo() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "H264_BP_1080x720_30fps_800kbps_1_17.mp4"; - final String audioFilename1 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - final String audioFilename2 = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int audioVolume = 50; - final String[] loggingInfo = new String[1]; - int i = 1; - writeTestCaseHeader("testStressAudioTrackVideo"); - getBeginMemory(); - final MediaVideoItem mediaVideoItem = new MediaVideoItem(mVideoEditor, - "mediaItem1", videoItemFileName1, renderingMode); - mVideoEditor.addMediaItem(mediaVideoItem); - - final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, - "Audio Track1", audioFilename1); - audioTrack1.disableDucking(); - audioTrack1.setVolume(audioVolume); - mVideoEditor.addAudioTrack(audioTrack1); - - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - - mVideoEditor.removeAudioTrack("Audio Track1"); - - final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor, - "Audio Track2", audioFilename2); - audioTrack2.enableLoop(); - - mVideoEditor.generatePreview(new MediaProcessingProgressListener() { - public void onProgress(Object item, int action, int progress) { - } - }); - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - mVideoEditor.removeMediaItem("mediaItem1"); - - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To Test Stress : Story Board creation with out preview or export - * - * @throws Exception - */ - @LargeTest - public void testStressStoryBoard() throws Exception { - final String videoItemFileName1 = INPUT_FILE_PATH + - "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4"; - final String videoItemFileName2 = INPUT_FILE_PATH + - "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4"; - final String videoItemFileName3= INPUT_FILE_PATH + - "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4"; - final String imageItemFileName4 = INPUT_FILE_PATH + - "IMG_1600x1200.jpg"; - final String imageItemFileName5 = INPUT_FILE_PATH + - "IMG_176x144.jpg"; - final String audioFilename6 = INPUT_FILE_PATH + - "AMRNB_8KHz_12.2Kbps_m_1_17.3gp"; - final String audioFilename7 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final int audioVolume = 50; - final String[] loggingInfo = new String[1]; - int i = 1; - - writeTestCaseHeader("testStressStoryBoard"); - getBeginMemory(); - final MediaVideoItem mediaItem1 = new MediaVideoItem(mVideoEditor, - "m1", videoItemFileName1, renderingMode); - mediaItem1.setExtractBoundaries(0, 10000); - mVideoEditor.addMediaItem(mediaItem1); - - final MediaVideoItem mediaItem2 = new MediaVideoItem(mVideoEditor, - "m2", videoItemFileName2, renderingMode); - mediaItem2.setExtractBoundaries(mediaItem2.getDuration()/4, - mediaItem2.getDuration()/2); - mVideoEditor.addMediaItem(mediaItem2); - - final MediaVideoItem mediaItem3 = new MediaVideoItem(mVideoEditor, - "m3", videoItemFileName3, renderingMode); - mediaItem3.setExtractBoundaries(mediaItem3.getDuration()/2, - mediaItem3.getDuration()); - mVideoEditor.addMediaItem(mediaItem3); - - final MediaImageItem mediaItem4 = new MediaImageItem(mVideoEditor, - "m4", imageItemFileName4, 5000, renderingMode); - mVideoEditor.addMediaItem(mediaItem4); - - final MediaImageItem mediaItem5 = new MediaImageItem(mVideoEditor, - "m5", imageItemFileName5, 5000, renderingMode); - mVideoEditor.addMediaItem(mediaItem5); - - final TransitionCrossfade tranCrossfade = - new TransitionCrossfade("transCF", mediaItem2, mediaItem3, 2500, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(tranCrossfade); - - final TransitionCrossfade tranCrossfade1 = - new TransitionCrossfade("transCF1", mediaItem3, mediaItem4, 2500, - Transition.BEHAVIOR_MIDDLE_FAST); - mVideoEditor.addTransition(tranCrossfade1); - - final AudioTrack audioTrack1 = new AudioTrack(mVideoEditor, - "Audio Track1", audioFilename6); - mVideoEditor.addAudioTrack(audioTrack1); - - mVideoEditor.removeAudioTrack("Audio Track1"); - final AudioTrack audioTrack2 = new AudioTrack(mVideoEditor, - "Audio Track2", audioFilename7); - mVideoEditor.addAudioTrack(audioTrack2); - audioTrack2.enableLoop(); - getAfterMemory_updateLog(loggingInfo, false, i); - - /** Remove items and check for memory leak if any */ - getBeginMemory(); - mVideoEditor.removeAudioTrack("Audio Track2"); - mVideoEditor.removeTransition("transCF"); - mVideoEditor.removeTransition("transCF1"); - mVideoEditor.removeMediaItem("m5"); - mVideoEditor.removeMediaItem("m4"); - mVideoEditor.removeMediaItem("m3"); - mVideoEditor.removeMediaItem("m2"); - mVideoEditor.removeMediaItem("m1"); - - getAfterMemory_updateLog(loggingInfo, true, i); - } - - /** - * To test the performance : With an audio track Only - * - * @throws Exception - */ - @LargeTest - public void testStressAudioTrackOnly() throws Exception { - - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String AudioItemFileName1 = INPUT_FILE_PATH + - "AACLC_44.1kHz_256kbps_s_1_17.mp4"; - final String[] loggingInfo = new String[1]; - int i = 0; - writeTestCaseHeader("testStressAudioTrackOnly"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - final AudioTrack mediaItem1 = new AudioTrack(mVideoEditor, - "m1" + i, AudioItemFileName1); - mVideoEditor.addAudioTrack(mediaItem1); - mediaItem1.enableLoop(); - mVideoEditor.removeAudioTrack("m1" + i); - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - } - - /** - * This method will test thumbnail list extraction in a loop = 200 for Image - * Item - * - * @throws Exception - */ - @LargeTest - public void testStressThumbnailImageItem() throws Exception { - final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg"; - final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER; - final String[] loggingInfo = new String[1]; - int i = 0; - final MediaImageItem mediaImageItem = new MediaImageItem(mVideoEditor, - "m1", imageItemFileName, 5000, renderingMode); - writeTestCaseHeader("testStressThumbnailImageItem"); - getBeginMemory(); - for ( i = 0; i < 50; i++) { - if (i % 4 == 0) { - final Bitmap[] thumbNails = mediaImageItem.getThumbnailList( - mediaImageItem.getWidth() / 2 , - mediaImageItem.getHeight() / 2, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 1) { - final Bitmap[] thumbNails = mediaImageItem.getThumbnailList( - mediaImageItem.getWidth() / 2, - mediaImageItem.getHeight() * 3, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 2) { - final Bitmap[] thumbNails = mediaImageItem.getThumbnailList( - mediaImageItem.getWidth() * 2, - mediaImageItem.getHeight() / 3, i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 4 == 3) { - final Bitmap[] thumbNails = mediaImageItem.getThumbnailList( - mediaImageItem.getWidth(), - mediaImageItem.getHeight(), i, 5000, 2); - // Recycle this Bitmap array - for (int i1 = 0; i1 < thumbNails.length; i1++) { - thumbNails[i1].recycle(); - } - } - if (i % 10 == 0) { - getAfterMemory_updateLog(loggingInfo, false, i); - } - } - getAfterMemory_updateLog(loggingInfo, false, i); - } -} |