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/mtp | |
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/mtp')
-rw-r--r-- | media/mtp/MtpDataPacket.cpp | 7 | ||||
-rw-r--r-- | media/mtp/MtpDataPacket.h | 1 | ||||
-rw-r--r-- | media/mtp/MtpDatabase.h | 7 | ||||
-rw-r--r-- | media/mtp/MtpServer.cpp | 60 | ||||
-rw-r--r-- | media/mtp/MtpTypes.h | 1 |
5 files changed, 30 insertions, 46 deletions
diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp index c159e20..9bfd00f 100644 --- a/media/mtp/MtpDataPacket.cpp +++ b/media/mtp/MtpDataPacket.cpp @@ -266,6 +266,13 @@ void MtpDataPacket::putAUInt16(const uint16_t* values, int count) { putUInt16(*values++); } +void MtpDataPacket::putAUInt16(const UInt16List* values) { + size_t count = (values ? values->size() : 0); + putUInt32(count); + for (size_t i = 0; i < count; i++) + putUInt16((*values)[i]); +} + void MtpDataPacket::putAInt32(const int32_t* values, int count) { putUInt32(count); for (int i = 0; i < count; i++) diff --git a/media/mtp/MtpDataPacket.h b/media/mtp/MtpDataPacket.h index e8314d7..b458286 100644 --- a/media/mtp/MtpDataPacket.h +++ b/media/mtp/MtpDataPacket.h @@ -74,6 +74,7 @@ public: void putAUInt8(const uint8_t* values, int count); void putAInt16(const int16_t* values, int count); void putAUInt16(const uint16_t* values, int count); + void putAUInt16(const UInt16List* values); void putAInt32(const int32_t* values, int count); void putAUInt32(const uint32_t* values, int count); void putAUInt32(const UInt32List* list); diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h index 02bb0d9..17823df 100644 --- a/media/mtp/MtpDatabase.h +++ b/media/mtp/MtpDatabase.h @@ -51,6 +51,13 @@ public: MtpObjectFormat format, MtpObjectHandle parent) = 0; + // callee should delete[] the results from these + // results can be NULL + virtual MtpObjectFormatList* getSupportedPlaybackFormats() = 0; + virtual MtpObjectFormatList* getSupportedCaptureFormats() = 0; + virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format) = 0; + virtual MtpDevicePropertyList* getSupportedDeviceProperties() = 0; + virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle, MtpObjectProperty property, MtpDataPacket& packet) = 0; diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index 082d924..6d2eec3 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -78,46 +78,6 @@ static const MtpEventCode kSupportedEventCodes[] = { MTP_EVENT_OBJECT_REMOVED, }; -static const MtpObjectProperty kSupportedObjectProperties[] = { - MTP_PROPERTY_STORAGE_ID, - MTP_PROPERTY_OBJECT_FORMAT, - MTP_PROPERTY_OBJECT_SIZE, - MTP_PROPERTY_OBJECT_FILE_NAME, - MTP_PROPERTY_PARENT_OBJECT, -}; - -static const MtpObjectFormat kSupportedPlaybackFormats[] = { - // MTP_FORMAT_UNDEFINED, - MTP_FORMAT_ASSOCIATION, - // MTP_FORMAT_TEXT, - // MTP_FORMAT_HTML, - MTP_FORMAT_MP3, - //MTP_FORMAT_AVI, - MTP_FORMAT_MPEG, - // MTP_FORMAT_ASF, - MTP_FORMAT_EXIF_JPEG, - MTP_FORMAT_TIFF_EP, - // MTP_FORMAT_BMP, - MTP_FORMAT_GIF, - MTP_FORMAT_JFIF, - MTP_FORMAT_PNG, - MTP_FORMAT_TIFF, - MTP_FORMAT_WMA, - MTP_FORMAT_OGG, - MTP_FORMAT_AAC, - // MTP_FORMAT_FLAC, - // MTP_FORMAT_WMV, - MTP_FORMAT_MP4_CONTAINER, - MTP_FORMAT_MP2, - MTP_FORMAT_3GP_CONTAINER, - // MTP_FORMAT_ABSTRACT_AUDIO_ALBUM, - MTP_FORMAT_ABSTRACT_AV_PLAYLIST, - MTP_FORMAT_WPL_PLAYLIST, - MTP_FORMAT_M3U_PLAYLIST, - // MTP_FORMAT_MPL_PLAYLIST, - MTP_FORMAT_PLS_PLAYLIST, -}; - MtpServer::MtpServer(int fd, MtpDatabase* database, int fileGroup, int filePerm, int directoryPerm) : mFD(fd), @@ -354,6 +314,10 @@ MtpResponseCode MtpServer::doGetDeviceInfo() { MtpStringBuffer string; char prop_value[PROPERTY_VALUE_MAX]; + MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats(); + MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats(); + MtpDevicePropertyList* deviceProperties = mDatabase->getSupportedDeviceProperties(); + // fill in device info mData.putUInt16(MTP_STANDARD_VERSION); mData.putUInt32(6); // MTP Vendor Extension ID @@ -365,10 +329,9 @@ MtpResponseCode MtpServer::doGetDeviceInfo() { sizeof(kSupportedOperationCodes) / sizeof(uint16_t)); // Operations Supported mData.putAUInt16(kSupportedEventCodes, sizeof(kSupportedEventCodes) / sizeof(uint16_t)); // Events Supported - mData.putEmptyArray(); // Device Properties Supported - mData.putEmptyArray(); // Capture Formats - mData.putAUInt16(kSupportedPlaybackFormats, - sizeof(kSupportedPlaybackFormats) / sizeof(uint16_t)); // Playback Formats + mData.putAUInt16(deviceProperties); // Device Properties Supported + mData.putAUInt16(captureFormats); // Capture Formats + mData.putAUInt16(playbackFormats); // Playback Formats // FIXME string.set("Google, Inc."); mData.putString(string); // Manufacturer @@ -383,6 +346,10 @@ MtpResponseCode MtpServer::doGetDeviceInfo() { string.set(prop_value); mData.putString(string); // Serial Number + delete playbackFormats; + delete captureFormats; + delete deviceProperties; + return MTP_RESPONSE_OK; } @@ -443,8 +410,9 @@ MtpResponseCode MtpServer::doGetObjectPropsSupported() { if (!mSessionOpen) return MTP_RESPONSE_SESSION_NOT_OPEN; MtpObjectFormat format = mRequest.getParameter(1); - mData.putAUInt16(kSupportedObjectProperties, - sizeof(kSupportedObjectProperties) / sizeof(uint16_t)); + MtpDevicePropertyList* properties = mDatabase->getSupportedObjectProperties(format); + mData.putAUInt16(properties); + delete[] properties; return MTP_RESPONSE_OK; } diff --git a/media/mtp/MtpTypes.h b/media/mtp/MtpTypes.h index 2a895a7..7e3c009 100644 --- a/media/mtp/MtpTypes.h +++ b/media/mtp/MtpTypes.h @@ -78,6 +78,7 @@ typedef Vector<int16_t> Int16List; typedef Vector<int32_t> Int32List; typedef Vector<int64_t> Int64List; +typedef UInt16List MtpObjectPropertyList; typedef UInt16List MtpDevicePropertyList; typedef UInt16List MtpObjectFormatList; typedef UInt32List MtpObjectHandleList; |