• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /**
19  *  @file pv_player_node_registry.h
20  *  @brief PVPlayerNodeRegistry maintains a list of nodes available which is queryable. The utility
21  *   also allows the node specified by PVUuid to be created and returned
22  *
23  */
24 
25 
26 #ifndef PV_PLAYER_NODE_REGISTRY_H_INCLUDED
27 #define PV_PLAYER_NODE_REGISTRY_H_INCLUDED
28 
29 #ifndef OSCL_VECTOR_H_INCLUDED
30 #include "oscl_vector.h"
31 #endif
32 
33 #ifndef OSCL_VECTOR_H_INCLUDED
34 #include "oscl_mem.h"
35 #endif
36 
37 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
38 #include "oscl_scheduler_ao.h"
39 #endif
40 
41 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
42 #include "pvmf_format_type.h"
43 #endif
44 
45 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
46 #include "pvmf_node_interface.h"
47 #endif
48 
49 #ifndef PV_UUID_H_INCLUDED
50 #include "pv_uuid.h"
51 #endif
52 
53 #ifndef PVMF_RECOGNIZER_TYPES_H_INCLUDED
54 #include "pvmf_recognizer_types.h"
55 #endif
56 
57 #ifndef PV_PLAYER_NODE_REGISTRY_INTERFACE_H_INCLUDED
58 #include "pv_player_node_registry_interface.h"
59 #endif
60 
61 #ifndef PVMF_RECOGNIZER_REGISTRY_H_INCLUDED
62 #include "pvmf_recognizer_registry.h"
63 #endif
64 
65 #ifndef PV_PLAYER_CONFIG_H_INCLUDED
66 #include "pv_player_config.h"
67 #endif
68 
69 #ifndef PV_LOGGER_H_INCLUDED
70 #include "pvlogger.h"
71 #endif
72 
73 #ifndef USE_CML2_CONFIG
74 #ifndef PV_PLAYER_ENGINE_TUNABLES_H_INCLUDED
75 #include "pv_player_engine_tunables.h"
76 #endif
77 #endif
78 
79 class OsclSharedLibrary;
80 class NodeRegistryPopulatorInterface;
81 class RecognizerPopulatorInterface;
82 
83 
84 // CLASS DECLARATION
85 /**
86  * PVPlayerNodeRegistry maintains a list of nodes available which is queryable.
87  * The utility also allows the node specified by PVUuid to be created and returned
88  **/
89 class PVPlayerNodeRegistry : public PVPlayerNodeRegistryInterface
90 {
91     public:
92         /**
93          * Object Constructor function
94          **/
95         PVPlayerNodeRegistry();
96 
97         void AddLoadableModules(const OSCL_String&);
98         void RemoveLoadableModules();
99 
100         /**
101          * The QueryRegistry for PVPlayerNodeRegistry. Used mainly for Seaching of the UUID
102          * whether it is available or not & returns Success if it is found else failure.
103          *
104          * @param aInputType Input Format Type
105          *
106          * @param aOutputType Output Format Type
107          *
108          * @param aUuids Reference to the UUID registered
109          *
110          * @returns Success or Failure
111          **/
112         virtual PVMFStatus QueryRegistry(PVMFFormatType& aInputType, PVMFFormatType& aOutputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids);
113 
114         /**
115          * The CreateNode for PVPlayerNodeRegistry. Used mainly for creating a node.
116          *
117          * @param aUuid UUID returned by the QueryRegistry
118          *
119          * @returns a pointer to node
120          **/
121         virtual PVMFNodeInterface* CreateNode(PVUuid& aUuid);
122 
123         /**
124          * The ReleaseNode for PVPlayerNodeRegistry. Used for releasing a node.
125          *
126          * @param aUuid UUID recorded at the time of creation of the node.
127          *
128          * @param Pointer to the node to be released
129          *
130          * @returns True or False
131          **/
132         virtual bool ReleaseNode(PVUuid& aUuid, PVMFNodeInterface *aNode);
133 
134         /**
135          * The RegisterNode for PVPlayerNodeRegistry. Used for registering nodes through the NodeInfo object.
136          *
137          * @param aNodeInfo NodeInfo object passed to the regisry class. This contains all nodes that need to be registered.
138          *
139          **/
RegisterNode(const PVPlayerNodeInfo & aNodeInfo)140         virtual void RegisterNode(const PVPlayerNodeInfo& aNodeInfo)
141         {
142             iType.push_back(aNodeInfo);
143         };
144 
145         /**
146          * UnregisterNode for PVPlayerNodeRegistry. Used to remove nodes from dynamic registry.
147          *
148          * @param aNodeInfo NodeInfo object passed to the regisry class. This contains all nodes that need to be unregistered.
149           *
150          **/
UnregisterNode(const PVPlayerNodeInfo & aNodeInfo)151         virtual void UnregisterNode(const PVPlayerNodeInfo& aNodeInfo)
152         {
153             OSCL_UNUSED_ARG(aNodeInfo);
154             // do nothing
155         };
156 
157         /**
158          * Object destructor function
159          **/
160         virtual ~PVPlayerNodeRegistry();
161 
162 
163     private:
164         /*
165         ** The node list.
166         */
167         Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> iType;
168 
169         OsclAny* iStaticPopulatorContext;
170         friend class PVPlayerRegistryPopulator;
171 
172         /*
173         ** Bookkeeping data for dynamically loaded nodes.
174         */
175         struct PVPlayerEngineNodeSharedLibInfo
176         {
177             OsclSharedLibrary* iLib;
178             NodeRegistryPopulatorInterface* iNodeLibIfacePtr;
179             OsclAny* iContext;
180         };
181         Oscl_Vector<struct PVPlayerEngineNodeSharedLibInfo*, OsclMemAllocator> iNodeLibInfoList;
182         PVLogger* iLogger;
183 };
184 
185 
186 class PVMFRecognizerPluginFactory;
187 class PVMFCPMPluginAccessInterfaceFactory;
188 
189 class PVPlayerRecognizerRegistryObserver
190 {
191     public:
192         virtual void RecognizeCompleted(PVMFFormatType aSourceFormatType, OsclAny* aContext) = 0;
~PVPlayerRecognizerRegistryObserver()193         virtual ~PVPlayerRecognizerRegistryObserver() {}
194 };
195 
196 /**
197  * PVPlayerRecognizerRegistry maintains sets up the recognizer registry so the player engine
198  * can determine the file type
199  **/
200 class PVPlayerRecognizerRegistry : public OsclTimerObject,
201         public PVMFRecognizerCommmandHandler
202         , public PVPlayerRecognizerRegistryInterface
203 {
204     public:
205         PVPlayerRecognizerRegistry();
206         virtual ~PVPlayerRecognizerRegistry();
207 
208         void AddLoadableModules(const OSCL_String&);
209         void RemoveLoadableModules();
210 
211         /**
212          * Determines the format type of the specified source file using the PVMF recognizer
213          *
214          * @param aSourceURL The source file to determine the format
215          * @param aObserver The callback handler to call when recognize operation completes
216          * @param aContext Optional opaque data that would be returned in callback
217          *
218          * @returns Status of query
219          **/
220         PVMFStatus QueryFormatType(OSCL_wString& aSourceURL, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aContext = NULL);
221 
222         /**
223          * Determines the format type of the specified source file using the PVMF recognizer
224          *
225          * @param aDataStreamFactory The factory to create source data stream to determine the format
226          * @param aObserver The callback handler to call when recognize operation completes
227          * @param aContext Optional opaque data that would be returned in callback
228          *
229          * @returns Status of query
230          **/
231         PVMFStatus QueryFormatType(PVMFCPMPluginAccessInterfaceFactory* aDataStreamFactory, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aContext = NULL);
232 
233         /**
234          * Cancels any pending format type query
235          *
236          * @param aContext Optional opaque data that would be returned in callback
237          *
238          * @returns None
239          **/
240         void CancelQuery(OsclAny* aContext = NULL);
241 
242         /**
243          * The RegisterRecognizer for PVPlayerRecognizerRegistryInterface. Used for registering file format recognizer factory plugins.
244          *
245          * @param aRecognizerPluginFactory PVMFRecognizerPluginFactory object pointer passed to the regisry class.
246          *
247          **/
RegisterRecognizer(PVMFRecognizerPluginFactory * aRecognizerPluginFactory)248         void RegisterRecognizer(PVMFRecognizerPluginFactory* aRecognizerPluginFactory)
249         {
250             if (PVMFRecognizerRegistry::RegisterPlugin(*aRecognizerPluginFactory) == PVMFSuccess)
251             {
252                 iRecognizerList.push_back(aRecognizerPluginFactory);
253             }
254         }
255 
256         /**
257          * The UnregisterRecognizer for PVPlayerRecognizerRegistryInterface. Used for removing file format recognizer factory plugins.
258          *
259          * @param aRecognizerPluginFactory PVMFRecognizerPluginFactory object pointer passed to the regisry class.
260          *
261          **/
UnregisterRecognizer(PVMFRecognizerPluginFactory * aRecognizerPluginFactory)262         void UnregisterRecognizer(PVMFRecognizerPluginFactory* aRecognizerPluginFactory)
263         {
264             for (uint i = 0; i < iRecognizerList.size(); i++)
265             {
266                 if (iRecognizerList[i] == aRecognizerPluginFactory)
267                 {
268                     iRecognizerList.erase(iRecognizerList.begin() + i);
269                     PVMFRecognizerRegistry::RemovePlugin(*aRecognizerPluginFactory);
270                 }
271             }
272         }
273 
274     private:
275         // From OsclTimerObject
276         void Run();
277 
278         // From PVMFRecognizerCommmandHandler
279         void RecognizerCommandCompleted(const PVMFCmdResp& aResponse);
280 
281         /*
282         ** The Recognizer list
283         */
284         Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator> iRecognizerList;
285 
286         PVMFSessionId iRecSessionId;
287         Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator> iRecognizerResult;
288         PVMFCPMPluginAccessInterfaceFactory* iFileDataStreamFactory;
289         PVMFCPMPluginAccessInterfaceFactory* iDataStreamFactory;
290 
291         PVMFFormatType iSourceFormatType;
292         PVPlayerRecognizerRegistryObserver* iObserver;
293         OsclAny* iCmdContext;
294         PVMFCommandId iRecognizeCmdId;
295         bool iCancelQuery;
296         OsclAny* iCancelCmdContext;
297 
298         OsclAny* iStaticPopulatorContext;
299         friend class PVPlayerRegistryPopulator;
300 
301         /*
302         ** Bookkeeping data for dynamically loaded recognizers.
303         */
304         struct PVPlayerEngineRecognizerSharedLibInfo
305         {
306             OsclSharedLibrary* iLib;
307             RecognizerPopulatorInterface* iRecognizerLibIfacePtr;
308             OsclAny* iContext;
309         };
310         Oscl_Vector<struct PVPlayerEngineRecognizerSharedLibInfo*, OsclMemAllocator> iRecognizerLibInfoList;
311         PVLogger* iLogger;
312 };
313 
314 /*
315 ** PVPlayerRegistryPopulator is used by Player engine to populate & de-populate
316 ** the registries.
317 */
318 class PVPlayerRegistryPopulator: public NodeRegistryPopulatorInterface
319         , public RecognizerPopulatorInterface
320 {
321     public:
322         /*
323         ** Populate both registries from static and loadable modules
324         */
325         static void Populate(PVPlayerNodeRegistry&, PVPlayerRecognizerRegistry&);
326 
327         /*
328         ** Depopulate both registries.
329         */
330         static void Depopulate(PVPlayerNodeRegistry&, PVPlayerRecognizerRegistry&);
331 
332     private:
333         /*
334         ** These routines are implemented in the project-specific player config.
335         ** They would normally populate using statically linked modules.
336         */
337 
338         //from NodeRegistryPopulatorInterface
339         void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext) ;
340         void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext) ;
341 
342         //from RecognizerPopulatorInterface
343         void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext) ;
344         void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext) ;
345 };
346 
347 
348 #endif // PV_PLAYER_NODE_REGISTRY_H_INCLUDED
349 
350 
351