use of android.media.MediaMetadataRetriever in project android_frameworks_base by crdroidandroid.
the class MediaDecoder method retrieveDefaultRotation.
@TargetApi(17)
private void retrieveDefaultRotation() {
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
metadataRetriever.setDataSource(mContext, mUri);
String rotationString = metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
mDefaultRotation = rotationString == null ? 0 : Integer.parseInt(rotationString);
}
use of android.media.MediaMetadataRetriever in project android_frameworks_base by crdroidandroid.
the class MediaRecorderTest method validateMetadata.
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;
}
use of android.media.MediaMetadataRetriever in project android_frameworks_base by AOSPA.
the class MediaMetadataRetrieverTest method testGetEmbeddedPicture.
// Test album art extraction.
@MediumTest
public static void testGetEmbeddedPicture() throws Exception {
Log.v(TAG, "testGetEmbeddedPicture starts.");
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
boolean supportWMA = MediaProfileReader.getWMAEnable();
boolean hasFailed = false;
boolean supportWMV = MediaProfileReader.getWMVEnable();
for (int i = 0, n = MediaNames.ALBUMART_TEST_FILES.length; i < n; ++i) {
try {
Log.v(TAG, "File " + i + ": " + MediaNames.ALBUMART_TEST_FILES[i]);
if ((MediaNames.ALBUMART_TEST_FILES[i].endsWith(".wma") && !supportWMA) || (MediaNames.ALBUMART_TEST_FILES[i].endsWith(".wmv") && !supportWMV)) {
Log.v(TAG, "windows media is not supported and thus we will skip the test for this file");
continue;
}
retriever.setDataSource(MediaNames.ALBUMART_TEST_FILES[i]);
byte[] albumArt = retriever.getEmbeddedPicture();
// known result.
if (albumArt == null) {
// Do we have expect in JUnit?
Log.e(TAG, "Fails to get embedded picture for " + MediaNames.ALBUMART_TEST_FILES[i]);
hasFailed = true;
}
} catch (Exception e) {
Log.e(TAG, "Fails to setDataSource for " + MediaNames.ALBUMART_TEST_FILES[i]);
hasFailed = true;
}
// Don't be evil
Thread.yield();
}
retriever.release();
Log.v(TAG, "testGetEmbeddedPicture completes.");
assertTrue(!hasFailed);
}
use of android.media.MediaMetadataRetriever in project android_frameworks_base by AOSPA.
the class MediaMetadataRetrieverTest method testMetadataRetrieval.
@LargeTest
public static void testMetadataRetrieval() throws Exception {
boolean supportWMA = MediaProfileReader.getWMAEnable();
boolean supportWMV = MediaProfileReader.getWMVEnable();
boolean hasFailed = false;
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
for (int i = 0, n = MediaNames.THUMBNAIL_METADATA_TEST_FILES.length; i < n; ++i) {
try {
Log.v(TAG, "File " + i + ": " + MediaNames.THUMBNAIL_METADATA_TEST_FILES[i]);
if ((MediaNames.THUMBNAIL_METADATA_TEST_FILES[i].endsWith(".wma") && !supportWMA) || (MediaNames.THUMBNAIL_METADATA_TEST_FILES[i].endsWith(".wmv") && !supportWMV)) {
Log.v(TAG, "windows media is not supported and thus we will skip the test for this file");
continue;
}
retriever.setDataSource(MediaNames.THUMBNAIL_METADATA_TEST_FILES[i]);
extractAllSupportedMetadataValues(retriever);
} catch (Exception e) {
Log.e(TAG, "Fails to setDataSource for file " + MediaNames.THUMBNAIL_METADATA_TEST_FILES[i]);
hasFailed = true;
}
// Don't be evil
Thread.yield();
}
retriever.release();
assertTrue(!hasFailed);
}
use of android.media.MediaMetadataRetriever in project android_frameworks_base by AOSPA.
the class MediaMetadataRetrieverTest method testBasicNormalMethodCallSequence.
// If the specified call order and valid media file is used, no exception
// should be thrown.
@MediumTest
public static void testBasicNormalMethodCallSequence() throws Exception {
boolean hasFailed = false;
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
try {
retriever.setDataSource(MediaNames.TEST_PATH_1);
Bitmap bitmap = retriever.getFrameAtTime(-1);
assertTrue(bitmap != null);
try {
java.io.OutputStream stream = new FileOutputStream("/sdcard/thumbnailout.jpg");
bitmap.compress(Bitmap.CompressFormat.JPEG, 75, stream);
stream.close();
} catch (Exception e) {
throw new Exception("Fails to convert the bitmap to a JPEG file for " + MediaNames.TEST_PATH_1, e);
}
extractAllSupportedMetadataValues(retriever);
} catch (Exception e) {
Log.e(TAG, "Fails to setDataSource for " + MediaNames.TEST_PATH_1, e);
hasFailed = true;
}
retriever.release();
assertTrue(!hasFailed);
}
Aggregations