diff options
author | Chong Zhang <chz@google.com> | 2015-04-14 23:54:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-14 23:54:18 +0000 |
commit | b6e809bfab41af69780a9e83e617eee22c018dc3 (patch) | |
tree | 3ecbe0f9935f858693e4c6ea5dd9611bd3712e49 /media/tests | |
parent | d1500d8ff1ba70cd723076d94a994cdfcc1a64fb (diff) | |
parent | 699780f54b7ddd7b00f891218140df663b3ab84e (diff) | |
download | frameworks_base-b6e809bfab41af69780a9e83e617eee22c018dc3.zip frameworks_base-b6e809bfab41af69780a9e83e617eee22c018dc3.tar.gz frameworks_base-b6e809bfab41af69780a9e83e617eee22c018dc3.tar.bz2 |
Merge "MediaRecorderTest: verify capture fps meta key is set"
Diffstat (limited to 'media/tests')
-rw-r--r-- | media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java index d7069cac..e730329 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/mediarecorder/MediaRecorderTest.java @@ -27,6 +27,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.Typeface; import android.hardware.Camera; +import android.media.MediaMetadataRetriever; import android.media.MediaPlayer; import android.media.MediaRecorder; import android.media.EncoderCapabilities; @@ -426,6 +427,29 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFra return validVideo; } + private boolean validateMetadata(String filePath, int captureRate) { + MediaMetadataRetriever retriever = new MediaMetadataRetriever(); + + retriever.setDataSource(filePath); + + // verify capture rate meta key is present and correct + String captureFps = retriever.extractMetadata( + MediaMetadataRetriever.METADATA_KEY_CAPTURE_FRAMERATE); + + if (captureFps == null) { + Log.d(TAG, "METADATA_KEY_CAPTURE_FRAMERATE is missing"); + return false; + } + + if (Math.abs(Float.parseFloat(captureFps) - captureRate) > 0.001) { + Log.d(TAG, "METADATA_KEY_CAPTURE_FRAMERATE is incorrect: " + + captureFps + "vs. " + captureRate); + return false; + } + + // verify other meta keys here if necessary + return true; + } @LargeTest /* * This test case set the camera in portrait mode. @@ -555,13 +579,16 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFra // always set videoOnly=false, MediaRecorder should disable // audio automatically with time lapse/slow motion - success = recordVideoFromSurface(frameRate, - k==0 ? MIN_VIDEO_FPS : HIGH_SPEED_FPS, - 352, 288, codec, + int captureRate = k==0 ? MIN_VIDEO_FPS : HIGH_SPEED_FPS; + success = recordVideoFromSurface( + frameRate, captureRate, 352, 288, codec, MediaRecorder.OutputFormat.THREE_GPP, filename, false /* videoOnly */); if (success) { success = validateVideo(filename, 352, 288); + if (success) { + success = validateMetadata(filename, captureRate); + } } if (!success) { noOfFailure++; @@ -569,6 +596,7 @@ public class MediaRecorderTest extends ActivityInstrumentationTestCase2<MediaFra } } catch (Exception e) { Log.v(TAG, e.toString()); + noOfFailure++; } assertTrue("testSurfaceRecordingTimeLapse", noOfFailure == 0); } |