diff options
author | niko <niko@google.com> | 2009-07-16 16:39:53 -0700 |
---|---|---|
committer | niko <niko@google.com> | 2009-07-17 11:31:11 -0700 |
commit | d608a813a9d2cbc6e2a5ea81d78d4a9044090c4c (patch) | |
tree | c6661ade3ceeacfd804236265d2bdc6a9f65cff7 /media | |
parent | 919f7387f2eafc36223a5cd599fb46871f801b10 (diff) | |
download | frameworks_av-d608a813a9d2cbc6e2a5ea81d78d4a9044090c4c.zip frameworks_av-d608a813a9d2cbc6e2a5ea81d78d4a9044090c4c.tar.gz frameworks_av-d608a813a9d2cbc6e2a5ea81d78d4a9044090c4c.tar.bz2 |
Added method to get metadata out of the player.
The method passes a list of metadata ids to be retrieved and
a parcel where the metadata records should be appended.
If the list of ids is empty, all the metadata should be returned.
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/MediaPlayerService.cpp | 37 | ||||
-rw-r--r-- | media/libmediaplayerservice/MidiFile.h | 8 | ||||
-rw-r--r-- | media/libmediaplayerservice/TestPlayerStub.h | 4 | ||||
-rw-r--r-- | media/libmediaplayerservice/VorbisPlayer.h | 4 |
4 files changed, 46 insertions, 7 deletions
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 02327d8..5e62f9d 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -99,6 +99,8 @@ const int kMaxFilterSize = 64; // I pulled that out of thin air. // Keep in sync with ANY in Metadata.java const int32_t kAny = 0; +const int32_t kMetaMarker = 0x4d455441; // 'M' 'E' 'T' 'A' + // Unmarshall a filter from a Parcel. // Filter format in a parcel: @@ -870,10 +872,14 @@ status_t MediaPlayerService::Client::setMetadataFilter(const Parcel& filter) status_t MediaPlayerService::Client::getMetadata( bool update_only, bool apply_filter, Parcel *reply) { + sp<MediaPlayerBase> p = getPlayer(); + if (p == 0) return UNKNOWN_ERROR; + status_t status; - reply->writeInt32(-1); // Placeholder for the return code + // Placeholder for the return code, updated by the caller. + reply->writeInt32(-1); - SortedVector<MetadataType> updates; + SortedVector<MetadataType> ids; // We don't block notifications while we fetch the data. We clear // mMetadataUpdated first so we don't lose notifications happening @@ -881,15 +887,34 @@ status_t MediaPlayerService::Client::getMetadata( { Mutex::Autolock lock(mLock); if (update_only) { - updates = mMetadataUpdated; + ids = mMetadataUpdated; } mMetadataUpdated.clear(); } - // FIXME: Implement, query the native player and do the optional filtering, etc... - status = OK; + const size_t begin = reply->dataPosition(); + reply->writeInt32(-1); // Placeholder for the length of the metadata + reply->writeInt32(kMetaMarker); - return status; + status = p->getMetadata(ids, reply); + + if (status != OK) { + reply->setDataPosition(begin); + LOGE("getMetadata failed %d", status); + return status; + } + + // FIXME: Implement filtering on the result. Not critical since + // filtering takes place on the update notifications already. This + // would be when all the metadata are fetch and a filter is set. + + const size_t end = reply->dataPosition(); + + // Everything is fine, update the metadata length. + reply->setDataPosition(begin); + reply->writeInt32(end - begin); + reply->setDataPosition(end); + return OK; } status_t MediaPlayerService::Client::prepareAsync() diff --git a/media/libmediaplayerservice/MidiFile.h b/media/libmediaplayerservice/MidiFile.h index 83d97fe..30b6a2e 100644 --- a/media/libmediaplayerservice/MidiFile.h +++ b/media/libmediaplayerservice/MidiFile.h @@ -46,7 +46,13 @@ public: virtual status_t reset(); virtual status_t setLooping(int loop); virtual player_type playerType() { return SONIVOX_PLAYER; } - virtual status_t invoke(const Parcel& request, Parcel *reply) {return INVALID_OPERATION;} + virtual status_t invoke(const Parcel& request, Parcel *reply) { + return INVALID_OPERATION; + } + virtual status_t getMetadata(const SortedVector<MetadataType>& ids, + Parcel *records) { + return INVALID_OPERATION; + } private: status_t createOutputTrack(); diff --git a/media/libmediaplayerservice/TestPlayerStub.h b/media/libmediaplayerservice/TestPlayerStub.h index 80d53a8..339b108 100644 --- a/media/libmediaplayerservice/TestPlayerStub.h +++ b/media/libmediaplayerservice/TestPlayerStub.h @@ -94,6 +94,10 @@ class TestPlayerStub : public MediaPlayerInterface { virtual status_t invoke(const android::Parcel& in, android::Parcel *out) { return mPlayer->invoke(in, out); } + virtual status_t getMetadata(const SortedVector<MetadataType>& ids, + Parcel *records) { + return INVALID_OPERATION; + } // @return true if the current build is 'eng' or 'test' and the diff --git a/media/libmediaplayerservice/VorbisPlayer.h b/media/libmediaplayerservice/VorbisPlayer.h index 4024654..040eb36 100644 --- a/media/libmediaplayerservice/VorbisPlayer.h +++ b/media/libmediaplayerservice/VorbisPlayer.h @@ -54,6 +54,10 @@ public: virtual status_t setLooping(int loop); virtual player_type playerType() { return VORBIS_PLAYER; } virtual status_t invoke(const Parcel& request, Parcel *reply) {return INVALID_OPERATION;} + virtual status_t getMetadata(const SortedVector<MetadataType>& ids, + Parcel *records) { + return INVALID_OPERATION; + } private: status_t setdatasource(const char *path, int fd, int64_t offset, int64_t length); |