Implemented the metadata changed notification filters.
IMediaPlayer:
new setMetadataFilter method so set a filter (2 lists of allowed and blocked metadata type)
serialized in a Parcel.
MediaPlayer.java/android_media_MediaPlayer.cpp/mediaplayer.cpp
new setMetadataFilter that passes the filter down to the MediaPlayerService's binder interface.
MediaPlayerService.cpp
The Client inner class holds the allowed and blocked metadata types.
These are in 2 vectors that get populated in the setMetadataFilter.
A new shourldDropMetadata method returns true if a type of metadata should be dropped according
to the filters.
The notify method in run the metadata update notifications thru the filter and possibly drop them.
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 12f2231..b915e86 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -23,6 +23,7 @@
#include <utils/List.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
+#include <utils/Vector.h>
#include <ui/SurfaceComposerClient.h>
#include <media/IMediaPlayerService.h>
@@ -143,7 +144,7 @@
sp<MemoryHeapBase> mHeap;
float mMsecsPerFrame;
uint16_t mChannelCount;
- uint16_t mFormat;
+ uint16_t mFormat;
ssize_t mFrameCount;
uint32_t mSampleRate;
uint32_t mSize;
@@ -168,6 +169,7 @@
void removeClient(wp<Client> client);
+
private:
class Client : public BnMediaPlayer {
@@ -188,6 +190,7 @@
virtual status_t setLooping(int loop);
virtual status_t setVolume(float leftVolume, float rightVolume);
virtual status_t invoke(const Parcel& request, Parcel *reply);
+ virtual status_t setMetadataFilter(const Parcel& filter);
sp<MediaPlayerBase> createPlayer(player_type playerType);
status_t setDataSource(const char *url);
@@ -210,6 +213,12 @@
sp<MediaPlayerBase> getPlayer() const { Mutex::Autolock lock(mLock); return mPlayer; }
+
+ /**
+ * @return true if the metadata should be dropped.
+ */
+ bool shouldDropMetadata(int code) const;
+
mutable Mutex mLock;
sp<MediaPlayerBase> mPlayer;
sp<MediaPlayerService> mService;
@@ -219,6 +228,10 @@
status_t mStatus;
bool mLoop;
int32_t mConnId;
+ // FIXME: Replace Vector<> with std::set<> when available. std::set support find.
+ // Metadata filters.
+ Vector<int32_t> mMetadataAllow; // protected by mLock
+ Vector<int32_t> mMetadataDrop; // protected by mLock
#if CALLBACK_ANTAGONIZER
Antagonizer* mAntagonizer;
#endif