am 3b728ca7: Merge "Revert "Fixes Issue ID: 3396697"" into honeycomb
* commit '3b728ca70a4fe6760b682589505d76848c47d765': Revert "Fixes Issue ID: 3396697"
This commit is contained in:
committed by
Android Git Automerger
commit
141a2adb25
@@ -1,51 +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 com.android.mediaframeworktest.stress.MediaPlayerStressTest;
|
||||
import com.android.mediaframeworktest.stress.VideoEditorStressTest;
|
||||
import junit.framework.TestSuite;
|
||||
import android.test.InstrumentationTestRunner;
|
||||
import android.test.InstrumentationTestSuite;
|
||||
|
||||
/**
|
||||
* Instrumentation Test Runner for all MediaPlayer tests.
|
||||
*
|
||||
* Running all tests:
|
||||
*
|
||||
* adb shell am instrument \
|
||||
* -w com.android.smstests.MediaPlayerInstrumentationTestRunner
|
||||
*/
|
||||
|
||||
public class MediaFrameworkStressTestRunner extends InstrumentationTestRunner {
|
||||
|
||||
|
||||
@Override
|
||||
public TestSuite getAllTests() {
|
||||
TestSuite suite = new InstrumentationTestSuite(this);
|
||||
suite.addTestSuite(MediaPlayerStressTest.class);
|
||||
/** Video Editor Stress Test cases*/
|
||||
suite.addTestSuite(VideoEditorStressTest.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassLoader getLoader() {
|
||||
return MediaFrameworkTestRunner.class.getClassLoader();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,954 +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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.videoeditor.MediaImageItem;
|
||||
import android.media.videoeditor.MediaItem;
|
||||
import android.media.videoeditor.MediaVideoItem;
|
||||
import android.media.videoeditor.VideoEditor;
|
||||
import android.os.Environment;
|
||||
import android.test.ActivityInstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import com.android.mediaframeworktest.MediaFrameworkTest;
|
||||
import com.android.mediaframeworktest.VideoEditorHelper;
|
||||
|
||||
public class MediaItemThumbnailTest extends
|
||||
ActivityInstrumentationTestCase<MediaFrameworkTest> {
|
||||
private final String TAG = "MediaItemThumbailTest";
|
||||
|
||||
private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
|
||||
|
||||
private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
|
||||
|
||||
private VideoEditor mVideoEditor;
|
||||
|
||||
private VideoEditorHelper mVideoEditorHelper;
|
||||
|
||||
public MediaItemThumbnailTest() {
|
||||
super("com.android.mediaframeworktest", MediaFrameworkTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// setup for each test case.
|
||||
super.setUp();
|
||||
mVideoEditorHelper = new VideoEditorHelper();
|
||||
// Create a random String which will be used as project path, where all
|
||||
// project related files will be stored.
|
||||
final String projectPath = mVideoEditorHelper.
|
||||
createRandomFile(PROJECT_LOCATION);
|
||||
mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
|
||||
// Clean the directory created as project path
|
||||
mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
|
||||
System.gc();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void validateThumbnail(Bitmap thumbNailBmp, int outWidth,
|
||||
int outHeight) throws Exception {
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Height", outHeight, thumbNailBmp.getHeight());
|
||||
assertEquals("Thumbnail Width", outWidth, thumbNailBmp.getWidth());
|
||||
thumbNailBmp.recycle();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// THUMBNAIL
|
||||
// -----------------------------------------------------------------
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H.263 QCIF.
|
||||
*/
|
||||
// TODO : TC_TN_001
|
||||
@LargeTest
|
||||
public void testThumbnailForH263QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on MPEG4 VGA .
|
||||
*/
|
||||
// TODO : TC_TN_002
|
||||
@LargeTest
|
||||
public void testThumbnailForMPEG4VGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"MPEG4_SP_640x480_30fps_512Kbps_0_23.3gp";
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on MPEG4 NTSC.
|
||||
*/
|
||||
// TODO : TC_TN_003
|
||||
@LargeTest
|
||||
public void testThumbnailForMPEG4NTSC() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on MPEG4 WVGA.
|
||||
*/
|
||||
// TODO : TC_TN_004
|
||||
@LargeTest
|
||||
public void testThumbnailForMPEG4WVGA() throws Exception {
|
||||
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth() * 2;
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on MPEG4 QCIF.
|
||||
*/
|
||||
// TODO : TC_TN_005
|
||||
@LargeTest
|
||||
public void testThumbnailForMPEG4QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_44.1kHz_96kbps_s_1_17.3gp";
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth();
|
||||
final int outHeight = mediaVideoItem.getHeight() * 2;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 QCIF.
|
||||
*/
|
||||
// TODO : TC_TN_006
|
||||
@LargeTest
|
||||
public void testThumbnailForH264QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_176x144_15fps_144kbps_AMRNB_8kHz_12.2kbps_m_1_17.3gp";
|
||||
|
||||
final int atTime = 0;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth() * 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() * 2;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 VGA.
|
||||
*/
|
||||
// TODO : TC_TN_007
|
||||
@LargeTest
|
||||
public void testThumbnailForH264VGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_30fps_192kbps_1_5.mp4";
|
||||
final int outWidth = 32;
|
||||
final int outHeight = 32;
|
||||
final int atTime = 0;
|
||||
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 WVGA.
|
||||
*/
|
||||
// TODO : TC_TN_008
|
||||
@LargeTest
|
||||
public void testThumbnailForH264WVGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int outWidth = 64;
|
||||
final int outHeight = 64;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final long atTime = mediaVideoItem.getDuration() / 2;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 854x480.
|
||||
*/
|
||||
// TODO : TC_TN_009
|
||||
@LargeTest
|
||||
public void testThumbnailForH264854_480() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
|
||||
final int outWidth = 128;
|
||||
final int outHeight = 128;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
MediaVideoItem mediaVideoItem = null;
|
||||
mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final long atTime = mediaVideoItem.getDuration() - 1000;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 960x720.
|
||||
*/
|
||||
// TODO : TC_TN_010
|
||||
@LargeTest
|
||||
public void testThumbnailForH264HD960() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
|
||||
final int outWidth = 75;
|
||||
final int outHeight = 75;
|
||||
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final long atTime = mediaVideoItem.getDuration() - 1000;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on H264 1080x720 .
|
||||
*/
|
||||
// TODO : TC_TN_011
|
||||
@LargeTest
|
||||
public void testThumbnailForH264HD1080() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_1080x720_30fps_800kbps_1_17.mp4";
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final long atTime = mediaVideoItem.getDuration() / 4;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail / frame extraction precision at 0,100 and 200 ms
|
||||
*/
|
||||
// TODO : TC_TN_012
|
||||
@LargeTest
|
||||
public void testThumbnailForH264VGADifferentDuration() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_30fps_256kbps_1_17.mp4";
|
||||
final int atTime = 0;
|
||||
final int atTime1 = 100;
|
||||
final int atTime2 = 200;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth();
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
|
||||
// get Thumbnail @ 100ms
|
||||
final Bitmap thumbNailBmpAt100 =
|
||||
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime1);
|
||||
validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
|
||||
|
||||
// get Thumbnail @ 200ms
|
||||
final Bitmap thumbNailBmpAt200 = mediaVideoItem.getThumbnail(
|
||||
outWidth, outHeight, atTime2);
|
||||
validateThumbnail(thumbNailBmpAt200, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
*Check the thumbnail / frame extraction precision at
|
||||
* FileDuration,FileDuration/2 + 100 andFileDuration/2 + 200 ms
|
||||
*/
|
||||
// TODO : TC_TN_013
|
||||
@LargeTest
|
||||
public void testThumbnailForMP4VGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"MPEG4_SP_640x480_15fps_256kbps_0_30.mp4";
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
|
||||
final int outWidth = mediaVideoItem.getWidth();
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
final long atTime = mediaVideoItem.getDuration() / 2;
|
||||
final long atTime1 = atTime + 100;
|
||||
final long atTime2 = atTime + 200;
|
||||
|
||||
// get Thumbnail @ duration/2
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
|
||||
// get Thumbnail @ duration/2 + 100ms
|
||||
final Bitmap thumbNailBmpAt100 = mediaVideoItem.getThumbnail(
|
||||
outWidth, outHeight, atTime1);
|
||||
validateThumbnail(thumbNailBmpAt100, outWidth, outHeight);
|
||||
|
||||
// get Thumbnail @ duration/2 + 200ms
|
||||
final Bitmap thumbNailBmpAt200 = mediaVideoItem.getThumbnail(
|
||||
outWidth, outHeight, atTime2);
|
||||
validateThumbnail(thumbNailBmpAt200, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail / frame extraction on JPEG file
|
||||
*/
|
||||
// TODO : TC_TN_014
|
||||
@LargeTest
|
||||
public void testThumbnailForImage() throws Exception {
|
||||
final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final int mediaDuration = 1000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
int outWidth = 0;
|
||||
int outHeight = 0;
|
||||
|
||||
final MediaImageItem mii = mVideoEditorHelper.createMediaItem(
|
||||
mVideoEditor, "m1", imageItemFilename, mediaDuration, renderingMode);
|
||||
assertNotNull("Media Image Item is Null", mii);
|
||||
outWidth = mii.getWidth() / 2;
|
||||
outHeight = mii.getHeight() / 2;
|
||||
|
||||
final Bitmap thumbNailBmp = mii.getThumbnail(outWidth,
|
||||
outHeight, mediaDuration);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
/**
|
||||
*To test ThumbnailList for H263 QCIF
|
||||
*/
|
||||
// TODO : TC_TN_015
|
||||
@LargeTest
|
||||
public void testThumbnailListH263QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
|
||||
final int startTime = 0;
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = mediaVideoItem.getWidth() / 4;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 4;
|
||||
final long endTime = mediaVideoItem.getDuration() / 2;
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
|
||||
outWidth, outHeight, startTime, endTime, tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for MPEG4 QCIF
|
||||
*/
|
||||
// TODO : TC_TN_016
|
||||
@LargeTest
|
||||
public void testThumbnailListMPEG4QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final long startTime = mediaVideoItem.getDuration() / 2;
|
||||
final long endTime = mediaVideoItem.getDuration();
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
|
||||
outWidth, outHeight, startTime, endTime, tnCount);
|
||||
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 VGA
|
||||
*/
|
||||
// TODO : TC_TN_017
|
||||
@LargeTest
|
||||
public void testThumbnailListH264VGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_30fps_256kbps_1_17.mp4";
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final long startTime = mediaVideoItem.getDuration() / 3;
|
||||
final long endTime = mediaVideoItem.getDuration() / 2;
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
|
||||
outWidth, outHeight, startTime, endTime, tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 WVGA
|
||||
*/
|
||||
// TODO : TC_TN_018
|
||||
@LargeTest
|
||||
public void testThumbnailListH264WVGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final long startTime = mediaVideoItem.getDuration() / 3;
|
||||
final long endTime = mediaVideoItem.getDuration() / 2;
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(
|
||||
outWidth, outHeight, startTime, endTime, tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 VGA ,Time exceeding file duration
|
||||
*/
|
||||
// TODO : TC_TN_019
|
||||
@LargeTest
|
||||
public void testThumbnailH264VGAExceedingFileDuration() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_30fps_256kbps_1_17.mp4";
|
||||
boolean flagForException = false;
|
||||
int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth() / 2;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
final long atTime = mediaVideoItem.getDuration() + 2000;
|
||||
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Exception in Extracting thumbanil with Invalid Time",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for VGA Image
|
||||
*/
|
||||
// TODO : TC_TN_020
|
||||
@LargeTest
|
||||
public void testThumbnailListVGAImage() throws Exception {
|
||||
final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final int imageItemDuration = 10000;
|
||||
final int startTime = 0;
|
||||
final int endTime = 0;
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaImageItem mediaImageItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
imageItemFilename, imageItemDuration, renderingMode);
|
||||
final int outWidth = mediaImageItem.getWidth() / 2;
|
||||
final int outHeight = mediaImageItem.getHeight() / 2;
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaImageItem.getThumbnailList
|
||||
(outWidth, outHeight, startTime, endTime, tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for Invalid file path
|
||||
*/
|
||||
// TODO : TC_TN_021
|
||||
@LargeTest
|
||||
public void testThumbnailForInvalidFilePath() throws Exception {
|
||||
final String imageItemFileName = INPUT_FILE_PATH + "/sdcard/abc.jpg";
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try{
|
||||
final MediaImageItem mii = new MediaImageItem(mVideoEditor, "m1",
|
||||
imageItemFileName, 3000, renderingMode);
|
||||
}catch (IllegalArgumentException e){
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue(" Invalid File Path", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction with setBoundaries
|
||||
*/
|
||||
// TODO : TC_TN_022
|
||||
@LargeTest
|
||||
public void testThumbnailForMPEG4WVGAWithSetBoundaries() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
|
||||
final int atTime = 10000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
mediaVideoItem.setExtractBoundaries(1000,
|
||||
(mediaVideoItem.getDuration() - 21000));
|
||||
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail(outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 WVGA with setExtractboundaries
|
||||
*/
|
||||
// TODO : TC_TN_023
|
||||
@LargeTest
|
||||
public void testThumbnailListForH264WVGAWithSetBoundaries() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_1_17.mp4";
|
||||
final int thumbNailStartTime = 10000;
|
||||
final int thumbNailEndTime = 12000;
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
|
||||
mediaVideoItem.setExtractBoundaries(10000, 12000);
|
||||
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList
|
||||
(outWidth, outHeight, thumbNailStartTime, thumbNailEndTime,
|
||||
tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertTrue("Thumbnail Size", (thumbNailBmp.length > 0) ? true : false);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 WVGA with count > frame available
|
||||
*/
|
||||
// TODO : TC_TN_024
|
||||
@LargeTest
|
||||
public void testThumbnailListForH264WVGAWithCount() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int tnCount = 100;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
|
||||
final long thumbNailEndTime = thumbNailStartTime + 4000;
|
||||
Bitmap thumbNailBmp[] = null;
|
||||
boolean flagForException = false;
|
||||
try{
|
||||
thumbNailBmp = mediaVideoItem.getThumbnailList(outWidth, outHeight,
|
||||
thumbNailStartTime, thumbNailEndTime, tnCount);
|
||||
}catch (Exception e){
|
||||
assertTrue("Unable to get Thumbnail list", flagForException);
|
||||
}
|
||||
if (thumbNailBmp.length <= tnCount) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail count more than asked", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList for H264 WVGA with startTime > End Time
|
||||
*/
|
||||
// TODO : TC_TN_025
|
||||
@LargeTest
|
||||
public void testThumbnailListH264WVGAWithStartGreaterEnd() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final int tnCount = 10;
|
||||
boolean flagForException = false;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
|
||||
final long thumbNailEndTime = thumbNailStartTime - 1000;
|
||||
try{
|
||||
mediaVideoItem.getThumbnailList(outWidth, outHeight,
|
||||
thumbNailStartTime, thumbNailEndTime, tnCount);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail Extraction where start time > end time",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList TC_TN_026 for H264 WVGA with startTime = End Time
|
||||
*/
|
||||
// TODO : TC_TN_026
|
||||
@LargeTest
|
||||
public void testThumbnailListH264WVGAWithStartEqualEnd() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int tnCount = 1;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
final long thumbNailStartTime = mediaVideoItem.getDuration() / 2;
|
||||
final long thumbNailEndTime = thumbNailStartTime;
|
||||
final Bitmap thumbNailBmp[] = mediaVideoItem.getThumbnailList(outWidth,
|
||||
outHeight, thumbNailStartTime, thumbNailEndTime, tnCount);
|
||||
assertNotNull("Thumbnail Retrived is Null", thumbNailBmp);
|
||||
assertEquals("Thumbnail Count", tnCount, thumbNailBmp.length);
|
||||
for (int i = 0; i < thumbNailBmp.length; i++) {
|
||||
validateThumbnail(thumbNailBmp[i], outWidth, outHeight);
|
||||
thumbNailBmp[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList TC_TN_027 for file where video duration is less
|
||||
* than file duration.
|
||||
*/
|
||||
// TODO : TC_TN_027
|
||||
@LargeTest
|
||||
public void testThumbnailForVideoDurationLessFileDuration() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = (mediaVideoItem.getHeight() / 2);
|
||||
final long atTime = mediaVideoItem.getDuration() - 2000;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*To test ThumbnailList TC_TN_028 for file which has video part corrupted
|
||||
*/
|
||||
// TODO : TC_TN_028
|
||||
@LargeTest
|
||||
public void testThumbnailWithCorruptedVideoPart() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"corrupted_H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = mediaVideoItem.getWidth();
|
||||
final int outHeight = mediaVideoItem.getHeight() * 2;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail
|
||||
(outWidth, outHeight, mediaVideoItem.getDuration()/2);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Corrupted File cannot be read", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail / frame list extraction for Height as Negative Value
|
||||
*/
|
||||
// TODO : TC_TN_029
|
||||
@LargeTest
|
||||
public void testThumbnailWithNegativeHeight() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = -1;
|
||||
final long thumbNailStartTime =
|
||||
mediaVideoItem.getBoundaryBeginTime()/2;
|
||||
final long thumbNailEndTime = mediaVideoItem.getBoundaryEndTime();
|
||||
mediaVideoItem.getThumbnailList(outWidth, outHeight,
|
||||
thumbNailStartTime, thumbNailEndTime, tnCount);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail List with negative Height", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail for Height as Zero
|
||||
*/
|
||||
// TODO : TC_TN_030
|
||||
@LargeTest
|
||||
public void testThumbnailWithHeightAsZero() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int atTime = 100;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = -1;
|
||||
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail List with Zero Height", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail for Height = 10
|
||||
*/
|
||||
// TODO : TC_TN_031
|
||||
@LargeTest
|
||||
public void testThumbnailWithHeight() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int atTime = 1000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = (mediaVideoItem.getWidth() / 2);
|
||||
final int outHeight = 10;
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail / frame list extraction for Width as Negative Value
|
||||
*/
|
||||
// TODO : TC_TN_032
|
||||
@LargeTest
|
||||
public void testThumbnailWithNegativeWidth() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int tnCount = 10;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = -1;
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
final long thumbNailStartTime =
|
||||
mediaVideoItem.getBoundaryBeginTime()/2;
|
||||
final long thumbNailEndTime = mediaVideoItem.getBoundaryEndTime();
|
||||
mediaVideoItem.getThumbnailList(outWidth, outHeight, thumbNailStartTime,
|
||||
thumbNailEndTime, tnCount);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail List with negative Height", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail / frame list extraction for Width zero
|
||||
*/
|
||||
// TODO : TC_TN_033
|
||||
@LargeTest
|
||||
public void testThumbnailWithWidthAsZero() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int atTime = 1000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = 0;
|
||||
final int outHeight = mediaVideoItem.getHeight() / 2;
|
||||
mediaVideoItem.getThumbnail(outWidth, outHeight, atTime);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Thumbnail List with Zero Width", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the thumbnail for Width = 10
|
||||
*/
|
||||
// TODO : TC_TN_034
|
||||
@LargeTest
|
||||
public void testThumbnailWithWidth() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_s_1_17.3gp";
|
||||
final int atTime = 1000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename, renderingMode);
|
||||
final int outWidth = 10;
|
||||
final int outHeight = mediaVideoItem.getHeight();
|
||||
final Bitmap thumbNailBmp = mediaVideoItem.getThumbnail (outWidth,
|
||||
outHeight, atTime);
|
||||
validateThumbnail(thumbNailBmp, outWidth, outHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test thumbnail / frame extraction on MPEG4 (time beyond file duration).
|
||||
*/
|
||||
// TODO : TC_TN_035
|
||||
@LargeTest
|
||||
public void testThumbnailMPEG4withMorethanFileDuration() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_30fps_256kbps_AACLC_96kbps_44kHz_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);
|
||||
}
|
||||
}
|
||||
@@ -1,753 +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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import android.media.videoeditor.AudioTrack;
|
||||
import android.media.videoeditor.MediaImageItem;
|
||||
import android.media.videoeditor.MediaItem;
|
||||
import android.media.videoeditor.MediaProperties;
|
||||
import android.media.videoeditor.MediaVideoItem;
|
||||
import android.media.videoeditor.VideoEditor;
|
||||
import android.os.Environment;
|
||||
import android.test.ActivityInstrumentationTestCase;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import com.android.mediaframeworktest.MediaFrameworkTest;
|
||||
import com.android.mediaframeworktest.VideoEditorHelper;
|
||||
|
||||
public class MediaPropertiesTest extends
|
||||
ActivityInstrumentationTestCase<MediaFrameworkTest> {
|
||||
private final String TAG = "MediaPropertiesTest";
|
||||
|
||||
private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
|
||||
|
||||
private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
|
||||
|
||||
private VideoEditor mVideoEditor;
|
||||
|
||||
private VideoEditorHelper mVideoEditorHelper;
|
||||
|
||||
public MediaPropertiesTest() {
|
||||
super("com.android.mediaframeworktest", MediaFrameworkTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// setup for each test case.
|
||||
super.setUp();
|
||||
mVideoEditorHelper = new VideoEditorHelper();
|
||||
// Create a random String which will be used as project path,
|
||||
// where all project related files will be stored.
|
||||
final String projectPath = mVideoEditorHelper.
|
||||
createRandomFile(PROJECT_LOCATION);
|
||||
mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
|
||||
// Clean the directory created as project path
|
||||
mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
|
||||
System.gc();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void validateVideoProperties(int aspectRatio, int fileType,
|
||||
int videoCodecType, int duration, int videoBitrate, int fps,
|
||||
int videoProfile, int width, int height, int audioCodecType,
|
||||
int audioSamplingFrequency, int audioChannel, int audioBitrate,
|
||||
MediaVideoItem mvi) throws Exception {
|
||||
assertEquals("Aspect Ratio Mismatch", aspectRatio, mvi.getAspectRatio());
|
||||
assertEquals("File Type Mismatch", fileType, mvi.getFileType());
|
||||
assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
|
||||
|
||||
assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
|
||||
duration, mvi.getDuration(), 10));
|
||||
assertEquals("Video Profile " + mvi.getVideoProfile(), videoProfile,
|
||||
mvi.getVideoProfile());
|
||||
assertEquals("Video height " + mvi.getHeight(), height, mvi.getHeight());
|
||||
assertEquals("Video width " + mvi.getWidth(), width, mvi.getWidth());
|
||||
/** Check FPS with 10% range */
|
||||
assertTrue("fps Mismatch" + mvi.getFps(),
|
||||
mVideoEditorHelper.checkRange(fps, mvi.getFps(), 10));
|
||||
|
||||
assertEquals("AudioType Mismatch ", audioCodecType, mvi.getAudioType());
|
||||
assertEquals("Audio Sampling " + mvi.getAudioSamplingFrequency(),
|
||||
audioSamplingFrequency, mvi.getAudioSamplingFrequency());
|
||||
assertEquals("Audio Channels " + mvi.getAudioChannels(), audioChannel,
|
||||
mvi.getAudioChannels());
|
||||
|
||||
/**
|
||||
if (videoBitrate != 0) {
|
||||
assertTrue("VideoBitrate Mismatch <expected> " + videoBitrate +
|
||||
"\t<actual> " + mvi.getVideoBitrate(),
|
||||
mVideoEditorHelper.checkRange(videoBitrate, mvi.getVideoBitrate(), 10));
|
||||
}
|
||||
if (audioBitrate != 0) {
|
||||
assertTrue("AudioBitrate Mismatch <expected> " + audioBitrate +
|
||||
"\t<actual> " + mvi.getAudioBitrate(),
|
||||
mVideoEditorHelper.checkRange(audioBitrate, mvi.getAudioBitrate(), 10));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
protected void validateAudioProperties(int audioCodecType, int duration,
|
||||
int audioSamplingFrequency, int audioChannel, int audioBitrate,
|
||||
AudioTrack aT) throws Exception {
|
||||
assertEquals("AudioType Mismatch ", audioCodecType, aT.getAudioType());
|
||||
assertTrue("Video duration Mismatch", mVideoEditorHelper.checkRange (
|
||||
duration, aT.getDuration(), 10));
|
||||
assertEquals("Audio Sampling " + aT.getAudioSamplingFrequency(),
|
||||
audioSamplingFrequency, aT.getAudioSamplingFrequency());
|
||||
assertEquals("Audio Channels " + aT.getAudioChannels(), audioChannel,
|
||||
aT.getAudioChannels());
|
||||
/**
|
||||
if (audioBitrate != 0) {
|
||||
assertTrue("AudioBitrate Mismatch <expected> " + audioBitrate +
|
||||
"\t<actual> " + aT.getAudioBitrate(),
|
||||
mVideoEditorHelper.checkRange(audioBitrate, aT.getAudioBitrate(), 10));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected void validateImageProperties(int aspectRatio, int fileType,
|
||||
int width, int height, MediaImageItem mii)
|
||||
throws Exception {
|
||||
assertEquals("Aspect Ratio Mismatch", aspectRatio, mii.getAspectRatio());
|
||||
assertEquals("File Type Mismatch", fileType, mii.getFileType());
|
||||
assertEquals("Image height " + mii.getHeight(), height, mii.getHeight());
|
||||
assertEquals("Image width " + mii.getWidth(), width, mii.getWidth());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*To test Media Properties for file MPEG4 854 x 480
|
||||
*/
|
||||
// TODO : Remove TC_MP_001
|
||||
@LargeTest
|
||||
public void testPropertiesMPEG4854_480() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_854x480_15fps_256kbps_AACLC_16khz_48kbps_s_0_26.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_MPEG4;
|
||||
final int duration = 26933;
|
||||
final int videoBitrate = 319000;
|
||||
final int audioBitrate = 48000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 16000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 854;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*To test Media Properties for file MPEG4 WVGA
|
||||
*/
|
||||
// TODO : Remove TC_MP_002
|
||||
@LargeTest
|
||||
public void testPropertiesMPEGWVGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_800x480_515kbps_15fps_AMR_NB_8KHz_12.2kbps_m_0_26.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
|
||||
final int fileType = MediaProperties.FILE_3GP;
|
||||
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 = 0;
|
||||
final int width = 800;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for MPEG4 720x480 (NTSC) + AAC file.
|
||||
*/
|
||||
// TODO : Remove TC_MP_003
|
||||
@LargeTest
|
||||
public void testPropertiesMPEGNTSC() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_161kbps_s_0_26.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_MPEG4;
|
||||
final int duration = 26866;
|
||||
final int videoBitrate = 403000;
|
||||
final int audioBitrate = 160000;
|
||||
final int fps = 30;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 48000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 720;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file MPEG4 VGA
|
||||
*/
|
||||
// TODO : Remove TC_MP_004
|
||||
@LargeTest
|
||||
public void testPropertiesMPEGVGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_640x480_15fps_512kbps_AACLC_48khz_132kbps_s_0_26.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_MPEG4;
|
||||
final int duration = 26933;
|
||||
final int videoBitrate = 533000;
|
||||
final int audioBitrate = 128000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 48000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 640;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file MPEG4 QCIF
|
||||
*/
|
||||
// TODO : Remove TC_MP_005
|
||||
@LargeTest
|
||||
public void testPropertiesMPEGQCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_176x144_12fps_92kbps_AMRNB_8KHz_12.2kbps_m_0_27.3gp";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
|
||||
final int fileType = MediaProperties.FILE_3GP;
|
||||
final int videoCodecType = MediaProperties.VCODEC_MPEG4;
|
||||
final int duration = 27000;
|
||||
final int videoBitrate = 384000;
|
||||
final int audioBitrate = 12200;
|
||||
final int fps = 12;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AMRNB;
|
||||
final int audioSamplingFrequency = 8000;
|
||||
final int audioChannel = 1;
|
||||
final int videoProfile = 0;
|
||||
final int width = 176;
|
||||
final int height = MediaProperties.HEIGHT_144;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To To test media properties for H263 176x144 (QCIF) + AAC (mono) file.
|
||||
*/
|
||||
// TODO : Remove TC_MP_006
|
||||
@LargeTest
|
||||
public void testPropertiesH263QCIF() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_16kHz_32kbps_m_0_26.3gp";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_11_9;
|
||||
final int fileType = MediaProperties.FILE_3GP;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H263;
|
||||
final int duration = 26933;
|
||||
final int videoBitrate = 384000;
|
||||
final int audioBitrate = 64000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 16000;
|
||||
final int audioChannel = 1;
|
||||
final int videoProfile = 0;
|
||||
final int width = 176;
|
||||
final int height = MediaProperties.HEIGHT_144;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file H264 VGA
|
||||
*/
|
||||
// TODO : Remove TC_MP_007
|
||||
@LargeTest
|
||||
public void testPropertiesH264VGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
|
||||
final int fileType = MediaProperties.FILE_3GP;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 77600;
|
||||
final int videoBitrate = 745000;
|
||||
final int audioBitrate = 64000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 48000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 640;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file H264 NTSC
|
||||
*/
|
||||
// TODO : Remove TC_MP_008
|
||||
@LargeTest
|
||||
public void testPropertiesH264NTSC() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_720x480_25fps_256kbps_AMRNB_8khz_12.2kbps_m_0_26.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 26880;
|
||||
final int videoBitrate = 244000;
|
||||
final int audioBitrate = 12200;
|
||||
final int fps = 25;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AMRNB;
|
||||
final int audioSamplingFrequency = 8000;
|
||||
final int audioChannel = 1;
|
||||
final int videoProfile = 0;
|
||||
final int width = 720;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for H264 800x480 (WVGA) + AAC file.
|
||||
*/
|
||||
// TODO : Remove TC_MP_009
|
||||
@LargeTest
|
||||
public void testPropertiesH264WVGA() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_800x480_15fps_512kbps_AACLC_24KHz_38Kbps_s_1_17.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_5_3;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 77466;
|
||||
final int videoBitrate = 528000;
|
||||
final int audioBitrate = 38000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 24000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 800;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file H264 HD1280
|
||||
*/
|
||||
// TODO : Remove TC_MP_010
|
||||
@LargeTest
|
||||
public void testPropertiesH264HD1280() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_1280x720_15fps_512kbps_AACLC_16khz_48kbps_s_1_17.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_16_9;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 77600;
|
||||
final int videoBitrate = 606000;
|
||||
final int audioBitrate = 48000;
|
||||
final int fps = 15;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 16000;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 1280;
|
||||
final int height = MediaProperties.HEIGHT_720;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for H264 1080x720 + AAC file
|
||||
*/
|
||||
// TODO : Remove TC_MP_011
|
||||
@LargeTest
|
||||
public void testPropertiesH264HD1080WithAudio() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_BP_1080x720_30fps_12Mbps_AACLC_44.1khz_64kbps_s_1_17.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 77500;
|
||||
final int videoBitrate = 1190000;
|
||||
final int audioBitrate = 64000;
|
||||
final int fps = 10;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 44100;
|
||||
final int audioChannel = 2;
|
||||
final int videoProfile = 0;
|
||||
final int width = 1080;
|
||||
final int height = MediaProperties.HEIGHT_720;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file WMV - Unsupported type
|
||||
*/
|
||||
// TODO : Remove TC_MP_012
|
||||
@LargeTest
|
||||
public void testPropertiesWMVFile() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"WMV_V7_640x480_15fps_512Kbps_wma_V9_44khz_48Kbps_s_1_30.wmv";
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Media Properties for a WMV File -- Unsupported file type",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for H.264 Main/Advanced profile. (unsupported profile input)
|
||||
*/
|
||||
// TODO : Remove TC_MP_013
|
||||
@LargeTest
|
||||
public void testPropertiesH264MainLineProfile() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH
|
||||
+ "H264_MP_960x720_25fps_800kbps_AACLC_48Khz_192Kbps_s_1_17.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
|
||||
//final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264MP;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
|
||||
try {
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
assertEquals("VideoCodec Mismatch", videoCodecType, mvi.getVideoType());
|
||||
}catch (IllegalArgumentException e){
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Unsupported Main Profile", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for non existing file.
|
||||
*/
|
||||
// TODO : Remove TC_MP_014
|
||||
@LargeTest
|
||||
public void testPropertiesForNonExsitingFile() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH + "abc.3gp";
|
||||
boolean flagForException = false;
|
||||
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Media Properties for non exsisting file", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file H264 HD1080
|
||||
*/
|
||||
// TODO : Remove TC_MP_015
|
||||
@LargeTest
|
||||
public void testPropertiesH264HD1080WithoutAudio() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"H264_BP_1080x720_30fps_800kbps_1_17.mp4";
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_3_2;
|
||||
final int fileType = MediaProperties.FILE_MP4;
|
||||
final int videoCodecType = MediaProperties.VCODEC_H264BP;
|
||||
final int duration = 77366;
|
||||
final int videoBitrate = 859000;
|
||||
final int audioBitrate = 0;
|
||||
final int fps = 30;
|
||||
final int audioCodecType = -1;
|
||||
final int audioSamplingFrequency = 0;
|
||||
final int audioChannel = 0;
|
||||
final int videoProfile = 0;
|
||||
final int width = 1080;
|
||||
final int height = MediaProperties.HEIGHT_720;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaVideoItem mvi = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", videoItemFilename, renderingMode);
|
||||
|
||||
validateVideoProperties(aspectRatio, fileType, videoCodecType, duration,
|
||||
videoBitrate, fps, videoProfile, width, height, audioCodecType,
|
||||
audioSamplingFrequency, audioChannel, audioBitrate, mvi);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for Image file of JPEG Type
|
||||
*/
|
||||
// TODO : Remove TC_MP_016
|
||||
@LargeTest
|
||||
public void testPropertiesVGAImage() throws Exception {
|
||||
final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final int imageItemDuration = 10000;
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
|
||||
final int fileType = MediaProperties.FILE_JPEG;
|
||||
final int width = 640;
|
||||
final int height = MediaProperties.HEIGHT_480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
|
||||
final MediaImageItem mii = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", imageItemFilename, imageItemDuration,
|
||||
renderingMode);
|
||||
validateImageProperties(aspectRatio, fileType, width, height, mii);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for Image file of PNG Type
|
||||
*/
|
||||
// TODO : Remove TC_MP_017
|
||||
@LargeTest
|
||||
public void testPropertiesPNG() throws Exception {
|
||||
final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.png";
|
||||
final int imageItemDuration = 10000;
|
||||
final int aspectRatio = MediaProperties.ASPECT_RATIO_4_3;
|
||||
final int fileType = MediaProperties.FILE_PNG;
|
||||
final int width = 640;
|
||||
final int height = 480;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final MediaImageItem mii = mVideoEditorHelper.createMediaItem
|
||||
(mVideoEditor, "m1", imageItemFilename, imageItemDuration,
|
||||
renderingMode);
|
||||
validateImageProperties(aspectRatio, fileType, width, height, mii);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file GIF - Unsupported type
|
||||
*/
|
||||
// TODO : Remove TC_MP_018
|
||||
@LargeTest
|
||||
public void testPropertiesGIFFile() throws Exception {
|
||||
|
||||
final String imageItemFilename = INPUT_FILE_PATH + "IMG_640x480.gif";
|
||||
final int imageItemDuration = 10000;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
new MediaImageItem(mVideoEditor, "m1", imageItemFilename,
|
||||
imageItemDuration, renderingMode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Media Properties for a GIF File -- Unsupported file type",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file Text file named as 3GP
|
||||
*/
|
||||
// TODO : Remove TC_MP_019
|
||||
@LargeTest
|
||||
public void testPropertiesofDirtyFile() throws Exception {
|
||||
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"Text_FileRenamedTo3gp.3gp";
|
||||
boolean flagForException = false;
|
||||
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file name as NULL
|
||||
*/
|
||||
// TODO : Remove TC_MP_020
|
||||
@LargeTest
|
||||
public void testPropertieNULLFile() throws Exception {
|
||||
final String videoItemFilename = null;
|
||||
boolean flagForException = false;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
|
||||
renderingMode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Media Properties for NULL File ",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties for file which is of type MPEG2
|
||||
*/
|
||||
// TODO : Remove TC_MP_021
|
||||
@LargeTest
|
||||
public void testPropertiesMPEG2File() throws Exception {
|
||||
final String videoItemFilename = INPUT_FILE_PATH +
|
||||
"MPEG2_640x480_30fps_192kbps_1_5.mp4";
|
||||
boolean flagForException = false;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", videoItemFilename,
|
||||
renderingMode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Media Properties for a MPEG2 File --Unsupported file type",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Media Properties TC_MP_023 for file without Video only Audio
|
||||
*/
|
||||
// TODO : Remove TC_MP_023
|
||||
@LargeTest
|
||||
public void testProperties3GPWithoutVideoMediaItem() throws Exception {
|
||||
final String audioFilename = INPUT_FILE_PATH +
|
||||
"AACLC_48KHz_256Kbps_s_1_17.3gp";
|
||||
boolean flagForException = false;
|
||||
final int renderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
try {
|
||||
new MediaVideoItem(mVideoEditor, "m1", audioFilename,
|
||||
renderingMode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Exception in Creaing Media Video item object without video",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for Audio Track file. (No Video, AAC Audio)
|
||||
*/
|
||||
// TODO : Remove TC_MP_024
|
||||
@LargeTest
|
||||
public void testProperties3GPWithoutVideoAudioTrack() throws Exception {
|
||||
|
||||
final String audioFilename = INPUT_FILE_PATH +
|
||||
"AACLC_44.1kHz_256kbps_s_1_17.mp4";
|
||||
final int duration = 77554;
|
||||
final int audioBitrate = 384000;
|
||||
final int audioCodecType = MediaProperties.ACODEC_AAC_LC;
|
||||
final int audioSamplingFrequency = 44100;
|
||||
final int audioChannel = 2;
|
||||
|
||||
final AudioTrack audioTrack = mVideoEditorHelper.createAudio
|
||||
(mVideoEditor, "a1", audioFilename);
|
||||
|
||||
validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
|
||||
audioChannel, audioBitrate, audioTrack);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test media properties for Audio Track file. MP3 file
|
||||
*/
|
||||
// TODO : Remove TC_MP_025
|
||||
@LargeTest
|
||||
public void testPropertiesMP3AudioTrack() throws Exception {
|
||||
|
||||
final String audioFilename = INPUT_FILE_PATH +
|
||||
"MP3_48KHz_128kbps_s_1_17.mp3";
|
||||
final int duration = 77640;
|
||||
final int audioBitrate = 128000;
|
||||
final int audioCodecType = MediaProperties.ACODEC_MP3;
|
||||
final int audioSamplingFrequency = 48000;
|
||||
final int audioChannel = 2;
|
||||
|
||||
final AudioTrack audioTrack = mVideoEditorHelper.createAudio
|
||||
(mVideoEditor, "a1", audioFilename);
|
||||
|
||||
validateAudioProperties(audioCodecType, duration, audioSamplingFrequency,
|
||||
audioChannel, audioBitrate, audioTrack);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,819 +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;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
import android.media.videoeditor.AudioTrack;
|
||||
import android.media.videoeditor.EffectColor;
|
||||
import android.media.videoeditor.EffectKenBurns;
|
||||
import android.media.videoeditor.MediaImageItem;
|
||||
import android.media.videoeditor.MediaItem;
|
||||
import android.media.videoeditor.MediaProperties;
|
||||
import android.media.videoeditor.MediaVideoItem;
|
||||
import android.media.videoeditor.OverlayFrame;
|
||||
import android.media.videoeditor.Transition;
|
||||
import android.media.videoeditor.TransitionAlpha;
|
||||
import android.media.videoeditor.TransitionCrossfade;
|
||||
import android.media.videoeditor.TransitionFadeBlack;
|
||||
import android.media.videoeditor.TransitionSliding;
|
||||
import android.media.videoeditor.VideoEditor;
|
||||
import android.media.videoeditor.VideoEditor.ExportProgressListener;
|
||||
import android.media.videoeditor.VideoEditor.MediaProcessingProgressListener;
|
||||
import android.os.Environment;
|
||||
import android.test.ActivityInstrumentationTestCase;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.mediaframeworktest.MediaFrameworkTest;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import com.android.mediaframeworktest.VideoEditorHelper;
|
||||
|
||||
public class VideoEditorExportTest extends
|
||||
ActivityInstrumentationTestCase<MediaFrameworkTest> {
|
||||
private final String TAG = "TransitionTest";
|
||||
|
||||
private final String PROJECT_LOCATION = VideoEditorHelper.PROJECT_LOCATION_COMMON;
|
||||
|
||||
private final String INPUT_FILE_PATH = VideoEditorHelper.INPUT_FILE_PATH_COMMON;
|
||||
|
||||
private VideoEditor mVideoEditor;
|
||||
|
||||
private VideoEditorHelper mVideoEditorHelper;
|
||||
|
||||
// Declares the annotation for Preview Test Cases
|
||||
public @interface TransitionTests {
|
||||
}
|
||||
|
||||
public VideoEditorExportTest() {
|
||||
super("com.android.mediaframeworktest", MediaFrameworkTest.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
// setup for each test case.
|
||||
super.setUp();
|
||||
mVideoEditorHelper = new VideoEditorHelper();
|
||||
// Create a random String which will be used as project path, where all
|
||||
// project related files will be stored.
|
||||
final String projectPath =
|
||||
mVideoEditorHelper.createRandomFile(PROJECT_LOCATION);
|
||||
mVideoEditor = mVideoEditorHelper.createVideoEditor(projectPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
mVideoEditorHelper.destroyVideoEditor(mVideoEditor);
|
||||
// Clean the directory created as project path
|
||||
mVideoEditorHelper.deleteProject(new File(mVideoEditor.getPath()));
|
||||
System.gc();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test export : Merge and Trim different types of Video and Image files
|
||||
*/
|
||||
// TODO :remove TC_EXP_001
|
||||
@LargeTest
|
||||
public void testExportMergeTrim() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
|
||||
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
|
||||
final String videoItemFilename2 = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final String videoItemFilename3 = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
|
||||
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
|
||||
final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/")
|
||||
+ ".3gp";
|
||||
|
||||
final MediaVideoItem mediaVideoItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem1.setExtractBoundaries(2000, 7000);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem1);
|
||||
|
||||
final MediaImageItem mediaImageItem2 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem2);
|
||||
|
||||
final MediaVideoItem mediaVideoItem3 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
|
||||
videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem3.setExtractBoundaries(0, 2000);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem3);
|
||||
|
||||
final MediaVideoItem mediaVideoItem4 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
|
||||
videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration()-5000,
|
||||
mediaVideoItem4.getDuration());
|
||||
mVideoEditor.addMediaItem(mediaVideoItem4);
|
||||
|
||||
final MediaImageItem mediaImageItem5 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
|
||||
imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem5);
|
||||
|
||||
final MediaImageItem mediaImageItem6 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
|
||||
imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem6);
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
final long storyBoardDuration = mediaVideoItem1.getTimelineDuration()
|
||||
+ mediaImageItem2.getDuration() + mediaVideoItem3.getTimelineDuration()
|
||||
+ mediaVideoItem4.getTimelineDuration() + mediaImageItem5.getDuration()
|
||||
+ mediaImageItem6.getDuration();
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
*To Test export : With Effect and Overlays on Different Media Items
|
||||
*/
|
||||
// TODO :remove TC_EXP_002
|
||||
@LargeTest
|
||||
public void testExportEffectOverlay() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
|
||||
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
|
||||
final String videoItemFilename2 = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_15fps_1200Kbps_AACLC_48KHz_64kps_m_0_27.3gp";
|
||||
final String videoItemFilename3 = INPUT_FILE_PATH
|
||||
+ "MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
|
||||
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
|
||||
final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
|
||||
final String overlayFile = INPUT_FILE_PATH + "IMG_640x480_Overlay1.png";
|
||||
|
||||
final MediaVideoItem mediaVideoItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem1.setExtractBoundaries(2000, 7000);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem1);
|
||||
|
||||
final EffectColor effectPink =
|
||||
mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectPink",
|
||||
0, 2000, EffectColor.TYPE_COLOR, EffectColor.PINK);
|
||||
mediaVideoItem1.addEffect(effectPink);
|
||||
|
||||
final EffectColor effectNegative =
|
||||
mVideoEditorHelper.createEffectItem(mediaVideoItem1, "effectNegative",
|
||||
3000, 4000, EffectColor.TYPE_NEGATIVE, 0);
|
||||
mediaVideoItem1.addEffect(effectNegative);
|
||||
|
||||
final MediaImageItem mediaImageItem2 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFilename1, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem2);
|
||||
|
||||
final EffectColor effectFifties =
|
||||
mVideoEditorHelper.createEffectItem(mediaImageItem2, "effectFifties",
|
||||
0, 3000, EffectColor.TYPE_FIFTIES, 0);
|
||||
mediaImageItem2.addEffect(effectFifties);
|
||||
|
||||
final MediaVideoItem mediaVideoItem3 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
|
||||
videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem3);
|
||||
mediaVideoItem3.setExtractBoundaries(0, 8000);
|
||||
|
||||
final Bitmap mBitmap = mVideoEditorHelper.getBitmap(overlayFile,
|
||||
640, 480);
|
||||
final OverlayFrame overlayFrame =
|
||||
mVideoEditorHelper.createOverlay(mediaVideoItem3, "overlay",
|
||||
mBitmap, 2000, 5000);
|
||||
mediaVideoItem3.addOverlay(overlayFrame);
|
||||
|
||||
final EffectColor effectGreen =
|
||||
mVideoEditorHelper.createEffectItem(mediaVideoItem3, "effectGreen",
|
||||
0, 2000, EffectColor.TYPE_COLOR, EffectColor.GREEN);
|
||||
mediaVideoItem3.addEffect(effectGreen);
|
||||
|
||||
final MediaVideoItem mediaVideoItem4 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
|
||||
videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem4.setExtractBoundaries(mediaVideoItem4.getDuration()-5000,
|
||||
mediaVideoItem4.getDuration());
|
||||
mVideoEditor.addMediaItem(mediaVideoItem4);
|
||||
|
||||
final EffectColor effectSepia =
|
||||
mVideoEditorHelper.createEffectItem(mediaVideoItem4, "effectSepia",
|
||||
0, 2000, EffectColor.TYPE_SEPIA, 0);
|
||||
mediaVideoItem4.addEffect(effectSepia);
|
||||
|
||||
final MediaImageItem mediaImageItem5 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
|
||||
imageItemFilename2, 4000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem5);
|
||||
|
||||
final EffectColor effectGray =
|
||||
mVideoEditorHelper.createEffectItem(mediaImageItem5, "effectGray",
|
||||
0, 2000, EffectColor.TYPE_COLOR, EffectColor.GRAY);
|
||||
mediaImageItem5.addEffect(effectGray);
|
||||
|
||||
final MediaImageItem mediaImageItem6 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
|
||||
imageItemFilename3, 2000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem6);
|
||||
|
||||
final EffectColor effectGradient =
|
||||
mVideoEditorHelper.createEffectItem(mediaImageItem6,
|
||||
"effectGradient", 0, 2000, EffectColor.TYPE_GRADIENT,
|
||||
EffectColor.PINK);
|
||||
mediaImageItem6.addEffect(effectGradient);
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
final long storyBoardDuration = mediaVideoItem1.getTimelineDuration()
|
||||
+ mediaImageItem2.getDuration()
|
||||
+ mediaVideoItem3.getTimelineDuration()
|
||||
+ mediaVideoItem4.getTimelineDuration()
|
||||
+ mediaImageItem5.getDuration()
|
||||
+ mediaImageItem6.getDuration();
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test export : with Image with KenBurnEffect
|
||||
*/
|
||||
// TODO : remove TC_EXP_003
|
||||
@LargeTest
|
||||
public void testExportEffectKenBurn() throws Exception {
|
||||
final String imageItemFileName = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final int imageItemRenderingMode = MediaItem.RENDERING_MODE_BLACK_BORDER;
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
|
||||
final MediaImageItem mediaImageItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "mediaImageItem1",
|
||||
imageItemFileName, 5000, imageItemRenderingMode);
|
||||
mVideoEditor.addMediaItem(mediaImageItem);
|
||||
|
||||
final Rect startRect = new Rect((mediaImageItem.getHeight() / 3),
|
||||
(mediaImageItem.getWidth() / 3), (mediaImageItem.getHeight() / 2),
|
||||
(mediaImageItem.getWidth() / 2));
|
||||
|
||||
final Rect endRect = new Rect(0, 0, mediaImageItem.getWidth(),
|
||||
mediaImageItem.getHeight());
|
||||
|
||||
final EffectKenBurns kbEffectOnMediaItem = new EffectKenBurns(
|
||||
mediaImageItem, "KBOnM2", startRect, endRect, 500, 3000);
|
||||
assertNotNull("EffectKenBurns", kbEffectOnMediaItem);
|
||||
mediaImageItem.addEffect(kbEffectOnMediaItem);
|
||||
|
||||
assertEquals("KenBurn Start Rect", startRect,
|
||||
kbEffectOnMediaItem.getStartRect());
|
||||
assertEquals("KenBurn End Rect", endRect,
|
||||
kbEffectOnMediaItem.getEndRect());
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, mediaImageItem.getDuration(),
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export : With Video and Image and An Audio BackGround Track
|
||||
*/
|
||||
// TODO : remove TC_EXP_004
|
||||
@LargeTest
|
||||
public void testExportAudio() throws Exception {
|
||||
final String videoItemFileName = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
|
||||
final String imageItemFileName = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
final String audioTrackFilename = INPUT_FILE_PATH +
|
||||
"AMRNB_8KHz_12.2Kbps_m_1_17.3gp";
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaVideoItem.setExtractBoundaries(0, 10000);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem);
|
||||
|
||||
final MediaImageItem mediaImageItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFileName, 5000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaImageItem);
|
||||
|
||||
final AudioTrack audioTrack = mVideoEditorHelper.createAudio(
|
||||
mVideoEditor, "a1", audioTrackFilename);
|
||||
audioTrack.setExtractBoundaries(2000, 5000);
|
||||
mVideoEditor.addAudioTrack(audioTrack);
|
||||
|
||||
audioTrack.disableDucking();
|
||||
audioTrack.enableLoop();
|
||||
audioTrack.setVolume(75);
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, (mediaVideoItem.getTimelineDuration() +
|
||||
mediaImageItem.getDuration()),
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
*To Test export : With Transition on Different Media Items
|
||||
*/
|
||||
// TODO :remove TC_EXP_005
|
||||
@LargeTest
|
||||
public void testExportTransition() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_0_26.3gp";
|
||||
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
|
||||
final String videoItemFilename2 = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final String videoItemFilename3 = INPUT_FILE_PATH +
|
||||
"MPEG4_SP_720x480_30fps_280kbps_AACLC_48kHz_96kbps_s_0_21.mp4";
|
||||
|
||||
final String imageItemFilename2 = INPUT_FILE_PATH + "IMG_176x144.jpg";
|
||||
final String imageItemFilename3 = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
final String maskFilename = INPUT_FILE_PATH +
|
||||
"TransitionSpiral_QVGA.jpg";
|
||||
|
||||
final MediaVideoItem mediaItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaItem1.setExtractBoundaries(2000, 7000);
|
||||
mVideoEditor.addMediaItem(mediaItem1);
|
||||
|
||||
final TransitionAlpha transition1 =
|
||||
mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
|
||||
2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
|
||||
mVideoEditor.addTransition(transition1);
|
||||
|
||||
final MediaImageItem mediaItem2 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem2);
|
||||
|
||||
final MediaVideoItem mediaItem3 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
|
||||
videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaItem3.setExtractBoundaries(0, 8000);
|
||||
mVideoEditor.addMediaItem(mediaItem3);
|
||||
|
||||
final TransitionSliding transition2And3 =
|
||||
mVideoEditorHelper.createTSliding("transition2", mediaItem2,
|
||||
mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
|
||||
TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
|
||||
mVideoEditor.addTransition(transition2And3);
|
||||
|
||||
final MediaVideoItem mediaItem4 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m4",
|
||||
videoItemFilename3, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem4);
|
||||
mediaItem4.setExtractBoundaries(0, 8000);
|
||||
|
||||
final TransitionCrossfade transition3And4 =
|
||||
mVideoEditorHelper.createTCrossFade("transition3", mediaItem3,
|
||||
mediaItem4, 3500, Transition.BEHAVIOR_MIDDLE_SLOW);
|
||||
mVideoEditor.addTransition(transition3And4);
|
||||
|
||||
final MediaImageItem mediaItem5 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m5",
|
||||
imageItemFilename2, 7000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem5);
|
||||
|
||||
final TransitionFadeBlack transition4And5 =
|
||||
mVideoEditorHelper.createTFadeBlack("transition4", mediaItem4,
|
||||
mediaItem5, 3500, Transition.BEHAVIOR_SPEED_DOWN);
|
||||
mVideoEditor.addTransition(transition4And5);
|
||||
|
||||
final MediaImageItem mediaItem6 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m6",
|
||||
imageItemFilename3, 3000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem6);
|
||||
|
||||
final TransitionSliding transition5And6 =
|
||||
mVideoEditorHelper.createTSliding("transition5", mediaItem5,
|
||||
mediaItem6, 1000/*4000*/, Transition.BEHAVIOR_SPEED_UP,
|
||||
TransitionSliding.DIRECTION_LEFT_OUT_RIGHT_IN);
|
||||
mVideoEditor.addTransition(transition5And6);
|
||||
|
||||
final TransitionSliding transition6 =
|
||||
mVideoEditorHelper.createTSliding("transition6", mediaItem6, null,
|
||||
1000 /*4000*/, Transition.BEHAVIOR_SPEED_UP,
|
||||
TransitionSliding.DIRECTION_TOP_OUT_BOTTOM_IN);
|
||||
mVideoEditor.addTransition(transition6);
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
final long storyBoardDuration = mediaItem1.getTimelineDuration()
|
||||
+ mediaItem2.getTimelineDuration()
|
||||
+ mediaItem3.getTimelineDuration() - transition2And3.getDuration()
|
||||
+ mediaItem4.getTimelineDuration() - transition3And4.getDuration()
|
||||
+ mediaItem5.getTimelineDuration() - transition4And5.getDuration()
|
||||
+ mediaItem6.getTimelineDuration() - transition5And6.getDuration();
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, storyBoardDuration,
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export : Without any Media Items in the story Board
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
// TODO :remove TC_EXP_006
|
||||
@LargeTest
|
||||
public void testExportWithoutMediaItems() throws Exception {
|
||||
boolean flagForException = false;
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (IllegalStateException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Export without any MediaItems", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export : With Media Items add and removed in the story Board
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
// TODO :remove TC_EXP_007
|
||||
@LargeTest
|
||||
public void testExportWithoutMediaItemsAddRemove() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH +
|
||||
"H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
|
||||
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_640x480.jpg";
|
||||
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
|
||||
boolean flagForException = false;
|
||||
|
||||
final MediaVideoItem mediaItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaItem1.setExtractBoundaries(0, 15000);
|
||||
mVideoEditor.addMediaItem(mediaItem1);
|
||||
|
||||
final MediaImageItem mediaItem2 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFilename1, 15000,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem2);
|
||||
|
||||
final TransitionAlpha transition1 =
|
||||
mVideoEditorHelper.createTAlpha("transition1", mediaItem1, mediaItem2,
|
||||
3000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, false);
|
||||
mVideoEditor.addTransition(transition1);
|
||||
|
||||
final EffectColor effectColor =
|
||||
mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 12000,
|
||||
3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
|
||||
mediaItem2.addEffect(effectColor);
|
||||
|
||||
mVideoEditor.removeMediaItem(mediaItem1.getId());
|
||||
mVideoEditor.removeMediaItem(mediaItem2.getId());
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export("/sdcard/Test.3gp", MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (IllegalStateException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Export with MediaItem added and removed", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export : With Video and Image : MMS use case
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
// TODO :remove TC_EXP_008
|
||||
@LargeTest
|
||||
public void testExportMMS() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
|
||||
final String imageItemFilename1 = INPUT_FILE_PATH + "IMG_1600x1200.jpg";
|
||||
final String videoItemFilename2 = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final String maskFilename = INPUT_FILE_PATH + "TransitionSpiral_QVGA.jpg";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
|
||||
final MediaVideoItem mediaItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaItem1.setExtractBoundaries(2000, 7000);
|
||||
mVideoEditor.addMediaItem(mediaItem1);
|
||||
|
||||
final TransitionAlpha transition1 =
|
||||
mVideoEditorHelper.createTAlpha("transition1", null, mediaItem1,
|
||||
2000, Transition.BEHAVIOR_LINEAR, maskFilename, 50, true);
|
||||
mVideoEditor.addTransition(transition1);
|
||||
|
||||
final MediaImageItem mediaItem2 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
imageItemFilename1, 8000, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem2);
|
||||
|
||||
final MediaVideoItem mediaItem3 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m3",
|
||||
videoItemFilename2, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mediaItem3.setExtractBoundaries(0, 8000);
|
||||
mVideoEditor.addMediaItem(mediaItem3);
|
||||
|
||||
final TransitionSliding transition2And3 =
|
||||
mVideoEditorHelper.createTSliding("transition2", mediaItem2,
|
||||
mediaItem3, 4000, Transition.BEHAVIOR_MIDDLE_FAST,
|
||||
TransitionSliding.DIRECTION_RIGHT_OUT_LEFT_IN);
|
||||
mVideoEditor.addTransition(transition2And3);
|
||||
|
||||
final TransitionCrossfade transition3 =
|
||||
mVideoEditorHelper.createTCrossFade("transition3", mediaItem3, null,
|
||||
3500, Transition.BEHAVIOR_MIDDLE_SLOW);
|
||||
mVideoEditor.addTransition(transition3);
|
||||
|
||||
final EffectColor effectColor =
|
||||
mVideoEditorHelper.createEffectItem(mediaItem2, "effect", 0,
|
||||
3000, EffectColor.TYPE_COLOR, EffectColor.PINK);
|
||||
mediaItem2.addEffect(effectColor);
|
||||
|
||||
mVideoEditor.setAspectRatio(MediaProperties.ASPECT_RATIO_11_9);
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
final long storyBoardDuration = mediaItem1.getTimelineDuration()
|
||||
- transition1.getDuration() + mediaItem2.getTimelineDuration()
|
||||
+ mediaItem3.getTimelineDuration() - transition2And3.getDuration()
|
||||
- transition3.getDuration();
|
||||
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_144, 0, storyBoardDuration,
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export :Media Item having duration of 1 Hour
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@LargeTest
|
||||
public void testExportDuration1Hour() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_15fps_384kbps_60_0.mp4";
|
||||
final String outFilename = mVideoEditorHelper.createRandomFile(
|
||||
mVideoEditor.getPath() + "/") + ".3gp";
|
||||
|
||||
final MediaVideoItem mediaItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFilename1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaItem1);
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
}catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0, mediaItem1.getDuration(),
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export : Storage location having very less space (Less than 100
|
||||
* KB)
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@LargeTest
|
||||
public void testExportWithStorageFull() throws Exception {
|
||||
final String videoItemFilename1 = INPUT_FILE_PATH
|
||||
+ "H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
boolean flagForException = false;
|
||||
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1", videoItemFilename1,
|
||||
MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_144,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Error in exporting file due to lack of storage space",
|
||||
flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Export :Two Media Items added
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@LargeTest
|
||||
public void testExportTwoVideos() throws Exception {
|
||||
final String videoItemFileName = INPUT_FILE_PATH
|
||||
+ "H263_profile0_176x144_15fps_256kbps_AACLC_32kHz_128kbps_s_1_17.3gp";
|
||||
final String videoItemFileName1 = INPUT_FILE_PATH +
|
||||
"H264_BP_640x480_12.5fps_256kbps_AACLC_16khz_24kbps_s_0_26.mp4";
|
||||
final String outFilename = mVideoEditorHelper
|
||||
.createRandomFile(mVideoEditor.getPath() + "/") + ".3gp";
|
||||
|
||||
final MediaVideoItem mediaVideoItem =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m1",
|
||||
videoItemFileName, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem);
|
||||
|
||||
final MediaVideoItem mediaVideoItem1 =
|
||||
mVideoEditorHelper.createMediaItem(mVideoEditor, "m2",
|
||||
videoItemFileName1, MediaItem.RENDERING_MODE_BLACK_BORDER);
|
||||
mVideoEditor.addMediaItem(mediaVideoItem1);
|
||||
|
||||
mVideoEditor.generatePreview(new MediaProcessingProgressListener() {
|
||||
public void onProgress(Object item, int action, int progress) {
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
final int[] progressUpdate = new int[100];
|
||||
mVideoEditor.export(outFilename, MediaProperties.HEIGHT_720,
|
||||
MediaProperties.BITRATE_800K, new ExportProgressListener() {
|
||||
int i = 0;
|
||||
public void onProgress(VideoEditor ve, String outFileName,
|
||||
int progress) {
|
||||
progressUpdate[i++] = progress;
|
||||
}
|
||||
});
|
||||
mVideoEditorHelper.checkProgressCBValues(progressUpdate);
|
||||
} catch (Exception e) {
|
||||
assertTrue("Error in Export" + e.toString(), false);
|
||||
}
|
||||
mVideoEditorHelper.validateExport(mVideoEditor, outFilename,
|
||||
MediaProperties.HEIGHT_720, 0,
|
||||
(mediaVideoItem.getDuration()+ mediaVideoItem1.getDuration()),
|
||||
MediaProperties.VCODEC_H264BP, MediaProperties.ACODEC_AAC_LC);
|
||||
mVideoEditorHelper.checkDeleteExistingFile(outFilename);
|
||||
}
|
||||
}
|
||||
@@ -1,990 +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;
|
||||
|
||||
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.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.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;
|
||||
|
||||
// Declares the annotation for Preview Test Cases
|
||||
public @interface Preview {
|
||||
}
|
||||
|
||||
public VideoEditorPreviewTest() {
|
||||
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 validatePreviewProgress(int startMs, int endMs, boolean loop, long duration) throws Exception {
|
||||
|
||||
final int[] progressUpdate = new int[100];
|
||||
final Semaphore blockTillPreviewCompletes = new Semaphore(1);
|
||||
final long mDuration = duration;
|
||||
|
||||
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();
|
||||
|
||||
blockTillPreviewCompletes.acquire();
|
||||
try {
|
||||
mVideoEditor.startPreview(surfaceHolder, startMs, endMs, loop, 1,
|
||||
new PreviewProgressListener() {
|
||||
public void onProgress(VideoEditor videoEditor, long timeMs,
|
||||
boolean end) {
|
||||
if ((mDuration != 0) && (timeMs >= mDuration)) {
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
else if (end == true) {
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e("VideoEditorPreviewTest","Exception thrown during preview");
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
blockTillPreviewCompletes.acquire();
|
||||
mVideoEditor.stopPreview();
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Preview
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*To test Preview : FULL Preview of current work (beginning till end)
|
||||
*/
|
||||
// TODO : remove TC_PRV_001
|
||||
@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";
|
||||
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of start + 10 sec till end of story board
|
||||
*/
|
||||
// TODO : remove TC_PRV_002
|
||||
@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);
|
||||
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Effects applied
|
||||
*/
|
||||
// TODO : remove TC_PRV_003
|
||||
@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);
|
||||
|
||||
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() / 2;
|
||||
validatePreviewProgress(0, -1, false, storyboardDuration);
|
||||
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Preview : Preview of current Transitions applied (with multiple
|
||||
* generatePreview)
|
||||
*/
|
||||
// TODO : remove TC_PRV_004
|
||||
@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";
|
||||
|
||||
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[305];
|
||||
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();
|
||||
blockTillPreviewCompletes.acquire();
|
||||
mVideoEditor.startPreview(surfaceHolder, 0, -1, false, 1,
|
||||
new PreviewProgressListener() {
|
||||
public void onProgress(VideoEditor videoEditor, long timeMs,
|
||||
boolean end) {
|
||||
if (timeMs >= 10000) {
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
blockTillPreviewCompletes.acquire();
|
||||
mVideoEditor.stopPreview();
|
||||
blockTillPreviewCompletes.release();
|
||||
|
||||
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, 25000);
|
||||
|
||||
mVideoEditorHelper.checkProgressCBValues(progressValues);
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Overlay applied
|
||||
*/
|
||||
// TODO : remove TC_PRV_005
|
||||
@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);
|
||||
|
||||
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 */, previewTo, previewLoop, previewTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Trim applied (with default aspect
|
||||
* ratio)
|
||||
*/
|
||||
// TODO : remove TC_PRV_006
|
||||
@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;
|
||||
mediaVideoItem.setExtractBoundaries(mediaVideoItem.getDuration() / 2,
|
||||
mediaVideoItem.getDuration());
|
||||
mVideoEditor.addMediaItem(mediaVideoItem);
|
||||
|
||||
validatePreviewProgress(1000, -1, false, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current work having Overlay and Effect
|
||||
* applied
|
||||
*/
|
||||
|
||||
// TODO : remove TC_PRV_007
|
||||
@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);
|
||||
|
||||
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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
*To test Preview : Export during preview
|
||||
*/
|
||||
// TODO : remove TC_PRV_008
|
||||
@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);
|
||||
|
||||
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) {
|
||||
}
|
||||
});
|
||||
blockTillPreviewCompletes.acquire();
|
||||
|
||||
final SurfaceHolder surfaceHolder =
|
||||
MediaFrameworkTest.mSurfaceView.getHolder();
|
||||
try {
|
||||
mVideoEditor.startPreview(surfaceHolder, 5000, -1, false, 1,
|
||||
new PreviewProgressListener() {
|
||||
final String fileName = mVideoEditor.getPath() + "\test.3gp";
|
||||
final int height = MediaProperties.HEIGHT_360;
|
||||
final int bitrate = MediaProperties.BITRATE_512K;
|
||||
public void onProgress(VideoEditor videoEditor, long timeMs,
|
||||
boolean end) {
|
||||
if (timeMs >= 10000)
|
||||
try {
|
||||
videoEditor.export(fileName, height, bitrate,
|
||||
new ExportProgressListener() {
|
||||
public void onProgress(VideoEditor ve,
|
||||
String outFileName,int progress) {
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
assertTrue("UnExpected Error in Export" +
|
||||
e.toString(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
assertTrue("Expected Error in Preview" + e.toString(), true);
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
blockTillPreviewCompletes.acquire();
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Effects applied (with from time >
|
||||
* total duration)
|
||||
*/
|
||||
// TODO : remove TC_PRV_009
|
||||
@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;
|
||||
final Semaphore blockTillPreviewCompletes = new Semaphore(1);
|
||||
|
||||
boolean flagForException = false;
|
||||
|
||||
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);
|
||||
|
||||
try {
|
||||
validatePreviewProgress(30000, -1, true, 0);
|
||||
} catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Expected Error in Preview", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Effects applied (with Render Preview
|
||||
* Frame)
|
||||
*/
|
||||
// TODO : remove TC_PRV_010
|
||||
@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;
|
||||
|
||||
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));
|
||||
|
||||
assertEquals("Render preview Frame at 7 Sec", 7000,
|
||||
mVideoEditor.renderPreviewFrame(surfaceHolder, 7000));
|
||||
|
||||
blockTillPreviewCompletes.acquire();
|
||||
|
||||
mVideoEditor.startPreview(surfaceHolder, 5000, -1, false, 1,
|
||||
new PreviewProgressListener() {
|
||||
public void onProgress(VideoEditor videoEditor, long timeMs,
|
||||
boolean end) {
|
||||
if (end) {
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
}
|
||||
});
|
||||
blockTillPreviewCompletes.acquire();
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current work from selected jump location
|
||||
* till end with Audio Track
|
||||
*/
|
||||
// TODO : remove TC_PRV_011
|
||||
@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";
|
||||
final Semaphore blockTillPreviewCompletes = new Semaphore(1);
|
||||
boolean flagForException = 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, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test render Preview Frame
|
||||
*/
|
||||
// TODO : remove TC_PRV_012
|
||||
@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";
|
||||
|
||||
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();
|
||||
final SurfaceHolder surfaceHolder =
|
||||
MediaFrameworkTest.mSurfaceView.getHolder();
|
||||
|
||||
for (int i = 0; i < mVideoEditor.getDuration(); i += 500) {
|
||||
assertEquals("Render PreviewFram", -1,
|
||||
mVideoEditor.renderPreviewFrame(surfaceHolder, i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To Test Preview : Without any Media Items in the story Board
|
||||
*/
|
||||
// TODO : remove TC_PRV_013
|
||||
@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,
|
||||
boolean end) {
|
||||
}
|
||||
});
|
||||
}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)
|
||||
*/
|
||||
// TODO : remove TC_PRV_014
|
||||
@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,
|
||||
boolean end) {
|
||||
}
|
||||
});
|
||||
}catch (IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue("Preview with removed Media Items", flagForException);
|
||||
}
|
||||
|
||||
/**
|
||||
* To test Preview : Preview of current Effects applied (with Render Preview
|
||||
* Frame)
|
||||
*/
|
||||
// TODO : remove TC_PRV_015
|
||||
@LargeTest
|
||||
public void testPreviewWithRenderPreviewFrameWithoutGenerate() 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;
|
||||
long duration = 0;
|
||||
|
||||
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();
|
||||
|
||||
try {
|
||||
assertEquals("Render preview Frame at item duration", duration,
|
||||
mVideoEditor.renderPreviewFrame(surfaceHolder, duration));
|
||||
} catch ( Exception e) {
|
||||
assertTrue (" Render Preview Frame without generate", false);
|
||||
}
|
||||
|
||||
duration = mVideoEditor.getDuration() + 1000;
|
||||
try {
|
||||
mVideoEditor.renderPreviewFrame(surfaceHolder, duration);
|
||||
} catch ( IllegalArgumentException e) {
|
||||
flagForException = true;
|
||||
}
|
||||
assertTrue (" Preview time greater than duration", flagForException);
|
||||
blockTillPreviewCompletes.acquire();
|
||||
blockTillPreviewCompletes.release();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user