diff options
Diffstat (limited to 'media')
3 files changed, 22 insertions, 11 deletions
diff --git a/media/java/android/media/MediaMetadataRetriever.java b/media/java/android/media/MediaMetadataRetriever.java index a3c3f09..6209dc0 100644 --- a/media/java/android/media/MediaMetadataRetriever.java +++ b/media/java/android/media/MediaMetadataRetriever.java @@ -42,6 +42,8 @@ public class MediaMetadataRetriever @SuppressWarnings("unused") private int mNativeContext; + private static final int EMBEDDED_PICTURE_TYPE_ANY = 0xFFFF; + public MediaMetadataRetriever() { native_setup(); } @@ -272,7 +274,11 @@ public class MediaMetadataRetriever * * @return null if no such graphic is found. */ - public native byte[] extractAlbumArt(); + public byte[] getEmbeddedPicture() { + return getEmbeddedPicture(EMBEDDED_PICTURE_TYPE_ANY); + } + + private native byte[] getEmbeddedPicture(int pictureType); /** * Call it when one is done with the object. This method releases the memory diff --git a/media/jni/android_media_MediaMetadataRetriever.cpp b/media/jni/android_media_MediaMetadataRetriever.cpp index 4ccdd9a..05623ec 100644 --- a/media/jni/android_media_MediaMetadataRetriever.cpp +++ b/media/jni/android_media_MediaMetadataRetriever.cpp @@ -289,21 +289,26 @@ static jobject android_media_MediaMetadataRetriever_getFrameAtTime(JNIEnv *env, return jBitmap; } -static jbyteArray android_media_MediaMetadataRetriever_extractAlbumArt(JNIEnv *env, jobject thiz) +static jbyteArray android_media_MediaMetadataRetriever_getEmbeddedPicture( + JNIEnv *env, jobject thiz, jint pictureType) { - LOGV("extractAlbumArt"); + LOGV("getEmbeddedPicture: %d", pictureType); MediaMetadataRetriever* retriever = getRetriever(env, thiz); if (retriever == 0) { jniThrowException(env, "java/lang/IllegalStateException", "No retriever available"); return NULL; } MediaAlbumArt* mediaAlbumArt = NULL; + + // FIXME: + // Use pictureType to retrieve the intended embedded picture and also change + // the method name to getEmbeddedPicture(). sp<IMemory> albumArtMemory = retriever->extractAlbumArt(); if (albumArtMemory != 0) { // cast the shared structure to a MediaAlbumArt object mediaAlbumArt = static_cast<MediaAlbumArt *>(albumArtMemory->pointer()); } if (mediaAlbumArt == NULL) { - LOGE("extractAlbumArt: Call to extractAlbumArt failed."); + LOGE("getEmbeddedPicture: Call to getEmbeddedPicture failed."); return NULL; } @@ -311,7 +316,7 @@ static jbyteArray android_media_MediaMetadataRetriever_extractAlbumArt(JNIEnv *e char* data = (char*) mediaAlbumArt + sizeof(MediaAlbumArt); jbyteArray array = env->NewByteArray(len); if (!array) { // OutOfMemoryError exception has already been thrown. - LOGE("extractAlbumArt: OutOfMemoryError is thrown."); + LOGE("getEmbeddedPicture: OutOfMemoryError is thrown."); } else { jbyte* bytes = env->GetByteArrayElements(array, NULL); if (bytes != NULL) { @@ -445,7 +450,7 @@ static JNINativeMethod nativeMethods[] = { {"setMode", "(I)V", (void *)android_media_MediaMetadataRetriever_setMode}, {"_getFrameAtTime", "(JI)Landroid/graphics/Bitmap;", (void *)android_media_MediaMetadataRetriever_getFrameAtTime}, {"extractMetadata", "(I)Ljava/lang/String;", (void *)android_media_MediaMetadataRetriever_extractMetadata}, - {"extractAlbumArt", "()[B", (void *)android_media_MediaMetadataRetriever_extractAlbumArt}, + {"getEmbeddedPicture", "(I)[B", (void *)android_media_MediaMetadataRetriever_getEmbeddedPicture}, {"release", "()V", (void *)android_media_MediaMetadataRetriever_release}, {"native_finalize", "()V", (void *)android_media_MediaMetadataRetriever_native_finalize}, {"native_setup", "()V", (void *)android_media_MediaMetadataRetriever_native_setup}, diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaMetadataRetrieverTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaMetadataRetrieverTest.java index a0c72e6..0870522 100644 --- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaMetadataRetrieverTest.java +++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/MediaMetadataRetrieverTest.java @@ -31,8 +31,8 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase { // Test album art extraction. @MediumTest - public static void testAlbumArt() throws Exception { - Log.v(TAG, "testAlbumArt starts."); + public static void testGetEmbeddedPicture() throws Exception { + Log.v(TAG, "testGetEmbeddedPicture starts."); MediaMetadataRetriever retriever = new MediaMetadataRetriever(); boolean supportWMA = MediaProfileReader.getWMAEnable(); boolean hasFailed = false; @@ -48,13 +48,13 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase { continue; } retriever.setDataSource(MediaNames.ALBUMART_TEST_FILES[i]); - byte[] albumArt = retriever.extractAlbumArt(); + byte[] albumArt = retriever.getEmbeddedPicture(); // TODO: // A better test would be to compare the retrieved album art with the // known result. if (albumArt == null) { // Do we have expect in JUnit? - Log.e(TAG, "Fails to extract album art for " + MediaNames.ALBUMART_TEST_FILES[i]); + Log.e(TAG, "Fails to get embedded picture for " + MediaNames.ALBUMART_TEST_FILES[i]); hasFailed = true; } } catch(Exception e) { @@ -64,7 +64,7 @@ public class MediaMetadataRetrieverTest extends AndroidTestCase { Thread.yield(); // Don't be evil } retriever.release(); - Log.v(TAG, "testAlbumArt completes."); + Log.v(TAG, "testGetEmbeddedPicture completes."); assertTrue(!hasFailed); } |