From 4440ef8efc77d1bd7838885e83d41e54deb5a3b8 Mon Sep 17 00:00:00 2001 From: Surajit Podder Date: Thu, 23 Jan 2014 13:24:34 +0530 Subject: DataSource: Remove global variables in DataSource related to sniff Remove global variables related to sniff, and added Sniffer class to implement the sniff functionality with non-static members. Change-Id: I6fbd0ba5b686e09fda11d78cdd687a69c81a6bdf CRs-Fixed: 567753 --- include/media/stagefright/DataSource.h | 38 +++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/media/stagefright/DataSource.h b/include/media/stagefright/DataSource.h index 0c31e72..de31ff0 100644 --- a/include/media/stagefright/DataSource.h +++ b/include/media/stagefright/DataSource.h @@ -36,6 +36,37 @@ class IDataSource; struct IMediaHTTPService; class String8; struct HTTPBase; +class DataSource; + +class Sniffer : public RefBase { +public: + Sniffer(); + + //////////////////////////////////////////////////////////////////////////// + + bool sniff(DataSource *source, String8 *mimeType, float *confidence, sp *meta); + + // The sniffer can optionally fill in "meta" with an AMessage containing + // a dictionary of values that helps the corresponding extractor initialize + // its state without duplicating effort already exerted by the sniffer. + typedef bool (*SnifferFunc)( + const sp &source, String8 *mimeType, + float *confidence, sp *meta); + + //if isExtendedExtractor = true, store the location of the sniffer to register + void registerSniffer_l(SnifferFunc func); + void registerDefaultSniffers(); + + virtual ~Sniffer() {} + +private: + Mutex mSnifferMutex; + List mSniffers; + List::iterator extendedSnifferPosition; + + Sniffer(const Sniffer &); + Sniffer &operator=(const Sniffer &); +}; class DataSource : public RefBase { public: @@ -57,7 +88,7 @@ public: static sp CreateMediaHTTP(const sp &httpService); static sp CreateFromIDataSource(const sp &source); - DataSource() {} + DataSource() : mSniffer(new Sniffer()) {} virtual status_t initCheck() const = 0; @@ -111,10 +142,7 @@ public: protected: virtual ~DataSource() {} -private: - static Mutex gSnifferMutex; - static List gSniffers; - static bool gSniffersRegistered; + sp mSniffer; static void RegisterSniffer_l(SnifferFunc func); -- cgit v1.1