am e556248: Merge change 1017 into donut

Merge commit 'e556248e859e7197d5f97c6c0724806d5913da24'

* commit 'e556248e859e7197d5f97c6c0724806d5913da24':
  Changes in mediaframework test for the OpenCore 2.0 integration. Changes included:
This commit is contained in:
Android (Google) Code Review
2009-05-06 01:31:31 -07:00
committed by The Android Open Source Project
4 changed files with 109 additions and 42 deletions

View File

@@ -380,35 +380,35 @@ public class MediaNames {
public static final String META_DATA_MP3 [][] = {
{"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1_ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
"ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues",
"ID3V2.3 Title", "1234", "321", "1"},
"ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/ID3V2.mp3", "1/10", "ID3V2.3 Album", "ID3V2.3 Artist",
"ID3V2.3 Lyricist", "ID3V2.3 Composer", null, "Blues",
"ID3V2.3 Title", "1234", "313", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1.mp3", null, "test ID3V1 Album", "test ID3V1 Artist",
null, null, null, null, "test ID3V1 Title", "1234", "231332", "1"},
"ID3V2.3 Title", "1234", "287", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/ID3V1.mp3", "1", "test ID3V1 Album", "test ID3V1 Artist",
null, null, null, "255", "test ID3V1 Title", "1234", "231332", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V1.mp3" , null, null, null,
null, null, null, null, null, null, "231330", "1"},
//The corrupted TALB field in id3v2 would not switch to id3v1 tag automatically
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TALB.mp3", "01", null, "ID3V2.3 Artist",
"ID3V2.3 Lyricist", "ID3V2.3 Composer", null,
"Blues", "ID3V2.3 Title", "1234", "321", "1"},
"Blues", "ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM.mp3", "01", "ID3V2.3 Album",
"ID3V2.3 Artist", "ID3V2.3 Lyricist", null, null,
"Blues", "ID3V2.3 Title", "1234", "321", "1"},
"Blues", "ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TCOM_2.mp3", "01", "ID3V2.3 Album",
"ID3V2.3 Artist", null, null, null, "Blues", "ID3V2.3 Title", "1234", "321", "1"},
"ID3V2.3 Artist", null, null, null, "Blues", "ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK.mp3", "dd", "ID3V2.3 Album",
"ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null,
"Blues", "ID3V2.3 Title", "1234", "321", "1"},
"Blues", "ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TRCK_2.mp3", "01", "ID3V2.3 Album",
"ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", null, "321", "1"},
"ID3V2.3 Artist", null, null, null, "255", "ID3V2.3 Title", "1234", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER.mp3", "01", "ID3V2.3 Album",
"ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", "9999", "321", "1"},
"ID3V2.3 Artist", null, null, null, null, "ID3V2.3 Title", "9999", "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TYER_2.mp3", "01", "ID3V2.3 Album",
"ID3V2.3 Artist", "ID3V2.3 Lyricist", "ID3V2.3 Composer", null,
"Blues", "ID3V2.3 Title", null, "321", "1"},
"Blues", "ID3V2.3 Title", null, "295", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP3/Corrupted_ID3V2_TIT.mp3", null, null, null,
null, null, null, null, null, null, "577", "1"}
null, null, null, null, null, null, "295", "1"}
};
public static final String META_DATA_OTHERS [][] = {
@@ -432,7 +432,7 @@ public class MediaNames {
null, null, "2005", "231180", "1"},
{"/sdcard/media_api/metaDataTestMedias/MP4/kung_fu_panda_h264.mp4", null, "mp4 album Kung Fu Panda",
"mp4 artist Kung Fu Panda", null, null, "20080517T091451.000Z",
"Kung Fu Panda", "Kung Fu Panda", "2008", "5667840", "2"},
"41", "Kung Fu Panda", "2008", "5667840", "2"},
{"/sdcard/media_api/metaDataTestMedias/OGG/Ring_Classic_02.ogg", null, "Suspended Animation",
"John Petrucci", null, null, "20070510T125223.000Z",
null, null, "2005", "231180", "1"},

View File

@@ -43,11 +43,13 @@ public class CodecTest {
private static MediaPlayer mMediaPlayer;
private MediaPlayer.OnPreparedListener mOnPreparedListener;
private static int WAIT_FOR_COMMAND_TO_COMPLETE = 10000; //10 seconds max.
private static int WAIT_FOR_COMMAND_TO_COMPLETE = 60000; //1 min max.
private static boolean mInitialized = false;
private static boolean mPrepareReset = false;
private static Looper mLooper = null;
private static final Object lock = new Object();
private static final Object prepareDone = new Object();
private static final Object videoSizeChanged = new Object();
private static boolean onPrepareSuccess = false;
@@ -227,28 +229,84 @@ public class CodecTest {
mp.pause();
mp.release();
}
static MediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener =
new MediaPlayer.OnVideoSizeChangedListener() {
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
synchronized (videoSizeChanged) {
Log.v(TAG, "sizechanged notification received ...");
videoSizeChanged.notify();
}
}
};
//Register the videoSizeChanged listener
public static int videoHeight(String filePath) throws Exception {
Log.v(TAG, "videoHeight - " + filePath);
int videoHeight = 0;
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(filePath);
mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
mp.prepare();
videoHeight = mp.getVideoHeight();
mp.release();
int videoHeight = 0;
synchronized (lock) {
initializeMessageLooper();
try {
lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch(Exception e) {
Log.v(TAG, "looper was interrupted.");
return 0;
}
}
try {
mMediaPlayer.setDataSource(filePath);
mMediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
mMediaPlayer.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
synchronized (videoSizeChanged) {
try {
mMediaPlayer.prepare();
mMediaPlayer.start();
videoSizeChanged.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch (Exception e) {
Log.v(TAG, "wait was interrupted");
}
}
videoHeight = mMediaPlayer.getVideoHeight();
terminateMessageLooper();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
return videoHeight;
}
//Register the videoSizeChanged listener
public static int videoWidth(String filePath) throws Exception {
Log.v(TAG, "videoWidth - " + filePath);
int videoWidth = 0;
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(filePath);
mp.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
mp.prepare();
videoWidth = mp.getVideoWidth();
mp.release();
synchronized (lock) {
initializeMessageLooper();
try {
lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch(Exception e) {
Log.v(TAG, "looper was interrupted.");
return 0;
}
}
try {
mMediaPlayer.setDataSource(filePath);
mMediaPlayer.setDisplay(MediaFrameworkTest.mSurfaceView.getHolder());
mMediaPlayer.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
synchronized (videoSizeChanged) {
try {
mMediaPlayer.prepare();
mMediaPlayer.start();
videoSizeChanged.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch (Exception e) {
Log.v(TAG, "wait was interrupted");
}
}
videoWidth = mMediaPlayer.getVideoWidth();
terminateMessageLooper();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
return videoWidth;
}
@@ -622,6 +680,10 @@ public class CodecTest {
static MediaPlayer.OnPreparedListener mPreparedListener = new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
synchronized (prepareDone) {
if(mPrepareReset){
Log.v(TAG, "call Reset");
mMediaPlayer.reset();
}
Log.v(TAG, "notify the prepare callback");
prepareDone.notify();
onPrepareSuccess = true;
@@ -629,13 +691,15 @@ public class CodecTest {
}
};
public static boolean prepareAsyncCallback(String filePath) throws Exception {
int videoWidth = 0;
int videoHeight = 0;
boolean checkVideoDimension = false;
public static boolean prepareAsyncCallback(String filePath, boolean reset) throws Exception {
//Added the PrepareReset flag which allow us to switch to different
//test case.
if (reset){
mPrepareReset = true;
}
initializeMessageLooper();
synchronized (lock) {
initializeMessageLooper();
try {
lock.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
} catch(Exception e) {
@@ -651,14 +715,10 @@ public class CodecTest {
synchronized (prepareDone) {
try {
prepareDone.wait(WAIT_FOR_COMMAND_TO_COMPLETE);
Log.v(TAG, "setPreview done");
} catch (Exception e) {
Log.v(TAG, "wait was interrupted.");
}
}
videoWidth = mMediaPlayer.getVideoWidth();
videoHeight = mMediaPlayer.getVideoHeight();
}
terminateMessageLooper();
}catch (Exception e){
Log.v(TAG,e.getMessage());
@@ -666,7 +726,7 @@ public class CodecTest {
return onPrepareSuccess;
}
}

View File

@@ -432,14 +432,21 @@ public class MediaPlayerApiTest extends ActivityInstrumentationTestCase<MediaFra
@LargeTest
public void testLocalMp3PrepareAsyncCallback() throws Exception {
boolean onPrepareSuccess =
CodecTest.prepareAsyncCallback(MediaNames.VIDEO_H263_AMR);
CodecTest.prepareAsyncCallback(MediaNames.VIDEO_H263_AMR, false);
assertTrue("LocalMp3prepareAsyncCallback", onPrepareSuccess);
}
@LargeTest
public void testStreamPrepareAsyncCallback() throws Exception {
boolean onPrepareSuccess =
CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k);
CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k, false);
assertTrue("StreamH264PrepareAsyncCallback", onPrepareSuccess);
}
@LargeTest
public void testStreamPrepareAsyncCallbackReset() throws Exception {
boolean onPrepareSuccess =
CodecTest.prepareAsyncCallback(MediaNames.STREAM_H264_480_360_1411k, true);
assertTrue("StreamH264PrepareAsyncCallback", onPrepareSuccess);
}
}

View File

@@ -148,8 +148,8 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase<MediaFram
Log.v(TAG, "before getduration");
mOutputDuration = mediaPlayer.getDuration();
Log.v(TAG, "get video dimension");
mOutputVideoHeight = mediaPlayer.getVideoHeight();
mOutputVideoWidth = mediaPlayer.getVideoWidth();
mOutputVideoHeight = CodecTest.videoHeight(outputFilePath);
mOutputVideoWidth = CodecTest.videoWidth(outputFilePath);
mediaPlayer.release();
} catch (Exception e) {
Log.v(TAG, e.toString());