diff options
author | Nicolas Catania <niko@google.com> | 2009-07-09 09:21:33 -0700 |
---|---|---|
committer | Nicolas Catania <niko@google.com> | 2009-07-10 11:00:42 -0700 |
commit | 5d55c7119820ee9bb06fc072e416fe98ba77cd28 (patch) | |
tree | 4f461a51f26fc221f4e9c7c660c6b6680ff072d7 /media/jni | |
parent | 2eedb2515b733aaba0a92944def8156ef379e0da (diff) | |
download | frameworks_base-5d55c7119820ee9bb06fc072e416fe98ba77cd28.zip frameworks_base-5d55c7119820ee9bb06fc072e416fe98ba77cd28.tar.gz frameworks_base-5d55c7119820ee9bb06fc072e416fe98ba77cd28.tar.bz2 |
Basic plumbing to retrieve metadata from the native player.
IMediaPlayer.h
Added a getMetadata method that mirrors the on in MediaPlayer.java.
MediaPlayer.java
Added a native method to get the metadata from the native player.
Parse the parcel into a Metadata object.
Metadata.java
Added a stub to parse the Parcel returned by the native player into
a set of metadata.
android_media_MediaPlayer.cpp
JNI call to forward the getMetadata call.
MediaPlayerService.cpp
MediaPlayerService::Client implements the new getMetadata method added in IMediaPlayer.h
Diffstat (limited to 'media/jni')
-rw-r--r-- | media/jni/android_media_MediaPlayer.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaPlayer.cpp b/media/jni/android_media_MediaPlayer.cpp index 19a2a41..b173129 100644 --- a/media/jni/android_media_MediaPlayer.cpp +++ b/media/jni/android_media_MediaPlayer.cpp @@ -479,9 +479,39 @@ android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject r Parcel *filter = parcelForJavaObject(env, request); + if (filter == NULL ) { + jniThrowException(env, "java/lang/RuntimeException", "Filter is null"); + return UNKNOWN_ERROR; + } + return media_player->setMetadataFilter(*filter); } +static jboolean +android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only, + jboolean apply_filter, jobject reply) +{ + sp<MediaPlayer> media_player = getMediaPlayer(env, thiz); + if (media_player == NULL ) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return false; + } + + Parcel *metadata = parcelForJavaObject(env, reply); + + if (metadata == NULL ) { + jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null"); + return false; + } + + metadata->freeData(); + // On return metadata is positioned at the beginning of the + // metadata. Note however that the parcel actually starts with the + // return code so you should not rewind the parcel using + // setDataPosition(0). + return media_player->getMetadata(update_only, apply_filter, metadata) == OK; +} + static void android_media_MediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this) @@ -546,6 +576,7 @@ static JNINativeMethod gMethods[] = { {"getFrameAt", "(I)Landroid/graphics/Bitmap;", (void *)android_media_MediaPlayer_getFrameAt}, {"native_invoke", "(Landroid/os/Parcel;Landroid/os/Parcel;)I",(void *)android_media_MediaPlayer_invoke}, {"native_setMetadataFilter", "(Landroid/os/Parcel;)I", (void *)android_media_MediaPlayer_setMetadataFilter}, + {"native_getMetadata", "(ZZLandroid/os/Parcel;)Z", (void *)android_media_MediaPlayer_getMetadata}, {"native_setup", "(Ljava/lang/Object;)V", (void *)android_media_MediaPlayer_native_setup}, {"native_finalize", "()V", (void *)android_media_MediaPlayer_native_finalize}, }; |