summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-08-03 15:30:09 -0400
committerMike Lockwood <lockwood@android.com>2010-08-03 15:36:22 -0400
commit438344fba74ddd6b931ac733fa48643f27b63de3 (patch)
tree3dd0ed5763a0c332506d9f6684a2f0eefe38cc08
parentfd150a8e03cdd8462eafd68f4a4231aa52f0e5a1 (diff)
downloadframeworks_av-438344fba74ddd6b931ac733fa48643f27b63de3.zip
frameworks_av-438344fba74ddd6b931ac733fa48643f27b63de3.tar.gz
frameworks_av-438344fba74ddd6b931ac733fa48643f27b63de3.tar.bz2
MTP: Add support for syncing MTP playlists
MTP playlists now correspond to playlists in the media provider (like those created by the Music app). Change-Id: I085cb3cff003037ad62f0e297fb0cfd3047cb3a2 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--media/mtp/MtpDatabase.h7
-rw-r--r--media/mtp/MtpServer.cpp45
-rw-r--r--media/mtp/MtpServer.h2
3 files changed, 47 insertions, 7 deletions
diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h
index bbbbc38..02bb0d9 100644
--- a/media/mtp/MtpDatabase.h
+++ b/media/mtp/MtpDatabase.h
@@ -61,7 +61,14 @@ public:
virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle,
MtpString& filePath,
int64_t& fileLength) = 0;
+
virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0;
+
+ virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0;
+
+ virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle,
+ MtpObjectHandleList* references) = 0;
+
};
}; // namespace android
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 50a839e..5f5cadf 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -68,8 +68,8 @@ static const MtpOperationCode kSupportedOperationCodes[] = {
// MTP_OPERATION_GET_OBJECT_PROP_DESC,
MTP_OPERATION_GET_OBJECT_PROP_VALUE,
// MTP_OPERATION_SET_OBJECT_PROP_VALUE,
-// MTP_OPERATION_GET_OBJECT_REFERENCES,
-// MTP_OPERATION_SET_OBJECT_REFERENCES,
+ MTP_OPERATION_GET_OBJECT_REFERENCES,
+ MTP_OPERATION_SET_OBJECT_REFERENCES,
// MTP_OPERATION_SKIP,
};
@@ -111,11 +111,11 @@ static const MtpObjectFormat kSupportedPlaybackFormats[] = {
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_ABSTRACT_AV_PLAYLIST,
+ MTP_FORMAT_WPL_PLAYLIST,
+ MTP_FORMAT_M3U_PLAYLIST,
// MTP_FORMAT_MPL_PLAYLIST,
- // MTP_FORMAT_PLS_PLAYLIST,
+ MTP_FORMAT_PLS_PLAYLIST,
};
MtpServer::MtpServer(int fd, MtpDatabase* database,
@@ -175,7 +175,8 @@ void MtpServer::run() {
mRequest.dump();
// FIXME need to generalize this
- bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO);
+ bool dataIn = (operation == MTP_OPERATION_SEND_OBJECT_INFO
+ || operation == MTP_OPERATION_SET_OBJECT_REFERENCES);
if (dataIn) {
int ret = mData.read(fd);
if (ret < 0) {
@@ -311,6 +312,12 @@ bool MtpServer::handleRequest() {
case MTP_OPERATION_GET_NUM_OBJECTS:
response = doGetNumObjects();
break;
+ case MTP_OPERATION_GET_OBJECT_REFERENCES:
+ response = doGetObjectReferences();
+ break;
+ case MTP_OPERATION_SET_OBJECT_REFERENCES:
+ response = doSetObjectReferences();
+ break;
case MTP_OPERATION_GET_OBJECT_PROP_VALUE:
response = doGetObjectPropValue();
break;
@@ -477,6 +484,30 @@ MtpResponseCode MtpServer::doGetNumObjects() {
}
}
+MtpResponseCode MtpServer::doGetObjectReferences() {
+ if (!mSessionOpen)
+ return MTP_RESPONSE_SESSION_NOT_OPEN;
+ MtpStorageID handle = mRequest.getParameter(1);
+ MtpObjectHandleList* handles = mDatabase->getObjectReferences(handle);
+ if (!handles) {
+ mData.putEmptyArray();
+ return MTP_RESPONSE_INVALID_OBJECT_HANDLE;
+ }
+ mData.putAUInt32(handles);
+ delete handles;
+ return MTP_RESPONSE_OK;
+}
+
+MtpResponseCode MtpServer::doSetObjectReferences() {
+ if (!mSessionOpen)
+ return MTP_RESPONSE_SESSION_NOT_OPEN;
+ MtpStorageID handle = mRequest.getParameter(1);
+ MtpObjectHandleList* references = mData.getAUInt32();
+ MtpResponseCode result = mDatabase->setObjectReferences(handle, references);
+ delete references;
+ return result;
+}
+
MtpResponseCode MtpServer::doGetObjectPropValue() {
MtpObjectHandle handle = mRequest.getParameter(1);
MtpObjectProperty property = mRequest.getParameter(2);
diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h
index 9ed1c84..19ccf24 100644
--- a/media/mtp/MtpServer.h
+++ b/media/mtp/MtpServer.h
@@ -95,6 +95,8 @@ private:
MtpResponseCode doGetObjectPropsSupported();
MtpResponseCode doGetObjectHandles();
MtpResponseCode doGetNumObjects();
+ MtpResponseCode doGetObjectReferences();
+ MtpResponseCode doSetObjectReferences();
MtpResponseCode doGetObjectPropValue();
MtpResponseCode doGetObjectInfo();
MtpResponseCode doGetObject();