diff options
author | Mike Lockwood <lockwood@android.com> | 2010-08-10 07:37:50 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-08-10 09:00:30 -0400 |
commit | 4b322ce4fb86b5a7a6e50633a3a9f498ca8d4706 (patch) | |
tree | d55c197b7c89017cc73d37c100ac0c3578b2a709 /media/jni/android_media_MtpDatabase.cpp | |
parent | fb824581d7c8b4683e26a9c2e34d9023cdbc177d (diff) | |
download | frameworks_base-4b322ce4fb86b5a7a6e50633a3a9f498ca8d4706.zip frameworks_base-4b322ce4fb86b5a7a6e50633a3a9f498ca8d4706.tar.gz frameworks_base-4b322ce4fb86b5a7a6e50633a3a9f498ca8d4706.tar.bz2 |
MTP: Push queries for supported formats and properties up to Java.
Change-Id: I4f117090340e3916afda3d194521a6092a672ddc
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/jni/android_media_MtpDatabase.cpp')
-rw-r--r-- | media/jni/android_media_MtpDatabase.cpp | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/media/jni/android_media_MtpDatabase.cpp b/media/jni/android_media_MtpDatabase.cpp index bfdc872..abbea30 100644 --- a/media/jni/android_media_MtpDatabase.cpp +++ b/media/jni/android_media_MtpDatabase.cpp @@ -40,6 +40,10 @@ static jmethodID method_beginSendObject; static jmethodID method_endSendObject; static jmethodID method_getObjectList; static jmethodID method_getNumObjects; +static jmethodID method_getSupportedPlaybackFormats; +static jmethodID method_getSupportedCaptureFormats; +static jmethodID method_getSupportedObjectProperties; +static jmethodID method_getSupportedDeviceProperties; static jmethodID method_getObjectProperty; static jmethodID method_getObjectInfo; static jmethodID method_getObjectFilePath; @@ -87,6 +91,13 @@ public: MtpObjectFormat format, MtpObjectHandle parent); + // callee should delete[] the results from these + // results can be NULL + virtual MtpObjectFormatList* getSupportedPlaybackFormats(); + virtual MtpObjectFormatList* getSupportedCaptureFormats(); + virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format); + virtual MtpDevicePropertyList* getSupportedDeviceProperties(); + virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle, MtpObjectProperty property, MtpDataPacket& packet); @@ -190,6 +201,66 @@ int MyMtpDatabase::getNumObjects(MtpStorageID storageID, (jint)storageID, (jint)format, (jint)parent); } +MtpObjectFormatList* MyMtpDatabase::getSupportedPlaybackFormats() { + JNIEnv* env = AndroidRuntime::getJNIEnv(); + jintArray array = (jintArray)env->CallObjectMethod(mDatabase, + method_getSupportedPlaybackFormats); + if (!array) + return NULL; + MtpObjectFormatList* list = new MtpObjectFormatList(); + jint* formats = env->GetIntArrayElements(array, 0); + jsize length = env->GetArrayLength(array); + for (int i = 0; i < length; i++) + list->push(formats[i]); + env->ReleaseIntArrayElements(array, formats, 0); + return list; +} + +MtpObjectFormatList* MyMtpDatabase::getSupportedCaptureFormats() { + JNIEnv* env = AndroidRuntime::getJNIEnv(); + jintArray array = (jintArray)env->CallObjectMethod(mDatabase, + method_getSupportedCaptureFormats); + if (!array) + return NULL; + MtpObjectFormatList* list = new MtpObjectFormatList(); + jint* formats = env->GetIntArrayElements(array, 0); + jsize length = env->GetArrayLength(array); + for (int i = 0; i < length; i++) + list->push(formats[i]); + env->ReleaseIntArrayElements(array, formats, 0); + return list; +} + +MtpObjectPropertyList* MyMtpDatabase::getSupportedObjectProperties(MtpObjectFormat format) { + JNIEnv* env = AndroidRuntime::getJNIEnv(); + jintArray array = (jintArray)env->CallObjectMethod(mDatabase, + method_getSupportedObjectProperties, (jint)format); + if (!array) + return NULL; + MtpObjectPropertyList* list = new MtpObjectPropertyList(); + jint* properties = env->GetIntArrayElements(array, 0); + jsize length = env->GetArrayLength(array); + for (int i = 0; i < length; i++) + list->push(properties[i]); + env->ReleaseIntArrayElements(array, properties, 0); + return list; +} + +MtpDevicePropertyList* MyMtpDatabase::getSupportedDeviceProperties() { + JNIEnv* env = AndroidRuntime::getJNIEnv(); + jintArray array = (jintArray)env->CallObjectMethod(mDatabase, + method_getSupportedDeviceProperties); + if (!array) + return NULL; + MtpDevicePropertyList* list = new MtpDevicePropertyList(); + jint* properties = env->GetIntArrayElements(array, 0); + jsize length = env->GetArrayLength(array); + for (int i = 0; i < length; i++) + list->push(properties[i]); + env->ReleaseIntArrayElements(array, properties, 0); + return list; +} + MtpResponseCode MyMtpDatabase::getObjectProperty(MtpObjectHandle handle, MtpObjectProperty property, MtpDataPacket& packet) { @@ -460,6 +531,26 @@ int register_android_media_MtpDatabase(JNIEnv *env) LOGE("Can't find getNumObjects"); return -1; } + method_getSupportedPlaybackFormats = env->GetMethodID(clazz, "getSupportedPlaybackFormats", "()[I"); + if (method_getSupportedPlaybackFormats == NULL) { + LOGE("Can't find getSupportedPlaybackFormats"); + return -1; + } + method_getSupportedCaptureFormats = env->GetMethodID(clazz, "getSupportedCaptureFormats", "()[I"); + if (method_getSupportedCaptureFormats == NULL) { + LOGE("Can't find getSupportedCaptureFormats"); + return -1; + } + method_getSupportedObjectProperties = env->GetMethodID(clazz, "getSupportedObjectProperties", "(I)[I"); + if (method_getSupportedObjectProperties == NULL) { + LOGE("Can't find getSupportedObjectProperties"); + return -1; + } + method_getSupportedDeviceProperties = env->GetMethodID(clazz, "getSupportedDeviceProperties", "()[I"); + if (method_getSupportedDeviceProperties == NULL) { + LOGE("Can't find getSupportedDeviceProperties"); + return -1; + } method_getObjectProperty = env->GetMethodID(clazz, "getObjectProperty", "(II[J[C)I"); if (method_getObjectProperty == NULL) { LOGE("Can't find getObjectProperty"); |