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 #include "pv_player_node_registry.h"
19
20 #include "pvmi_datastreamsyncinterface_ref_factory.h"
21
22 #ifdef USE_LOADABLE_MODULES
23 #include "oscl_shared_library.h"
24 #include "oscl_library_list.h"
25 #include "oscl_configfile_list.h"
26 #include "osclconfig_lib.h"
27 #include "oscl_shared_lib_interface.h"
28
29 #include "pvmf_node_shared_lib_interface.h"
30
31 #endif //USE_LOADABLE_MODULES
32
33 #include "pvmf_omx_videodec_factory.h"
34
35 #if BUILD_VIDEO_DEC_NODE
36 #include "pvmf_videodec_factory.h"
37 #endif
38
39
Populate(PVPlayerNodeRegistry & aNode,PVPlayerRecognizerRegistry & aRec)40 void PVPlayerRegistryPopulator::Populate(PVPlayerNodeRegistry& aNode, PVPlayerRecognizerRegistry& aRec)
41 {
42
43 #ifdef USE_LOADABLE_MODULES
44 //add loadable modules
45
46 OsclConfigFileList aCfgList;
47 // collects all config files from the project specified directory
48 if (NULL != PV_DYNAMIC_LOADING_CONFIG_FILE_PATH)
49 {
50 OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
51 aCfgList.Populate(configFilePath);
52 }
53 // populate libraries from all config files
54 for (uint k = 0; k < aCfgList.Size(); k++)
55 {
56 aNode.AddLoadableModules(aCfgList.GetConfigfileAt(k));
57 aRec.AddLoadableModules(aCfgList.GetConfigfileAt(k));
58 }
59 #endif
60
61 //add static modules
62 PVPlayerRegistryPopulator pop;
63 pop.RegisterAllNodes(&aNode, aNode.iStaticPopulatorContext);
64 pop.RegisterAllRecognizers(&aRec, aRec.iStaticPopulatorContext);
65
66 }
67
Depopulate(PVPlayerNodeRegistry & aNode,PVPlayerRecognizerRegistry & aRec)68 void PVPlayerRegistryPopulator::Depopulate(PVPlayerNodeRegistry& aNode, PVPlayerRecognizerRegistry& aRec)
69 {
70 aNode.RemoveLoadableModules();
71 aRec.RemoveLoadableModules();
72
73 PVPlayerRegistryPopulator pop;
74 pop.UnregisterAllNodes(&aNode, aNode.iStaticPopulatorContext);
75 pop.UnregisterAllRecognizers(&aRec, aRec.iStaticPopulatorContext);
76 }
77
78
PVPlayerNodeRegistry()79 PVPlayerNodeRegistry::PVPlayerNodeRegistry()
80 {
81 iType.reserve(20);
82 iLogger = PVLogger::GetLoggerObject("pvplayerengine.playernoderegistry");
83 }
84
85
~PVPlayerNodeRegistry()86 PVPlayerNodeRegistry::~PVPlayerNodeRegistry()
87 {
88 iType.clear();
89 iLogger = NULL;
90 }
91
AddLoadableModules(const OSCL_String & aConfigFilePath)92 void PVPlayerNodeRegistry::AddLoadableModules(const OSCL_String& aConfigFilePath)
93 {
94 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::AddLoadableModules() IN"));
95 #ifdef USE_LOADABLE_MODULES
96
97 OsclLibraryList libList;
98 libList.Populate(PV_NODE_REGISTRY_POPULATOR_INTERFACE, aConfigFilePath);
99
100 for (unsigned int i = 0; i < libList.Size(); i++)
101 {
102 OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
103 if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
104 {
105 OsclAny* interfacePtr = NULL;
106 OsclLibStatus result = lib->QueryInterface(PV_NODE_REGISTRY_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
107 if (result == OsclLibSuccess && interfacePtr != NULL)
108 {
109 struct PVPlayerEngineNodeSharedLibInfo *libInfo = (struct PVPlayerEngineNodeSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineNodeSharedLibInfo));
110 if (NULL != libInfo)
111 {
112 libInfo->iLib = lib;
113
114 NodeRegistryPopulatorInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeRegistryPopulatorInterface*, interfacePtr);
115 libInfo->iNodeLibIfacePtr = nodeIntPtr;
116 nodeIntPtr->RegisterAllNodes(this, libInfo->iContext);
117
118 // save for depopulation later
119 iNodeLibInfoList.push_front(libInfo);
120 continue;
121 }
122 }
123 else
124 {
125 PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerNodeRegistry::AddLoadableModules() QueryInterface() of PV_NODE_POPULATOR_INTERFACE for library %s failed.", libList.GetLibraryPathAt(i).get_cstr()));
126
127 }
128 }
129 else
130 {
131 PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVPlayerNodeRegistry::AddLoadableModules() LoadLib() of library %s failed.", libList.GetLibraryPathAt(i).get_cstr()));
132 }
133 lib->Close();
134 OSCL_DELETE(lib);
135 }
136 #else
137 OSCL_UNUSED_ARG(aConfigFilePath);
138 #endif
139 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::AddLoadableModules() OUT"));
140 }
141
RemoveLoadableModules()142 void PVPlayerNodeRegistry::RemoveLoadableModules()
143 {
144 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::RemoveLoadableModules() IN"));
145 #ifdef USE_LOADABLE_MODULES
146 // remove all dynamic nodes now
147 // unregister node one by one
148 while (!iNodeLibInfoList.empty())
149 {
150 struct PVPlayerEngineNodeSharedLibInfo *libInfo = iNodeLibInfoList.front();
151 iNodeLibInfoList.erase(iNodeLibInfoList.begin());
152
153 OsclSharedLibrary* lib = libInfo->iLib;
154 NodeRegistryPopulatorInterface* nodeIntPtr = libInfo->iNodeLibIfacePtr;
155 OsclAny* context = libInfo->iContext;
156 oscl_free(libInfo);
157
158 nodeIntPtr->UnregisterAllNodes(this, context);
159
160 lib->Close();
161 OSCL_DELETE(lib);
162 }
163 #endif
164 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::RemoveLoadableModules() OUT"));
165 }
166
167
QueryRegistry(PVMFFormatType & aInputType,PVMFFormatType & aOutputType,Oscl_Vector<PVUuid,OsclMemAllocator> & aUuids)168 PVMFStatus PVPlayerNodeRegistry::QueryRegistry(PVMFFormatType& aInputType, PVMFFormatType& aOutputType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids)
169 {
170 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::QueryRegistry() IN"));
171 uint32 SearchCount = 0;
172 bool matchfound = false;
173
174 // Find all nodes that support the specified input and ouput format pair
175 while (SearchCount < iType.size())
176 {
177 uint32 inputsearchcount = 0, outputsearchcount = 0;
178 bool iInputFoundFlag = false, iOutputFoundFlag = false;
179
180 while (inputsearchcount < iType[SearchCount].iInputTypes.size())
181 {
182 // Check if the input format matches
183 if (iType[SearchCount].iInputTypes[inputsearchcount] == aInputType)
184 {
185 // Set the the input flag to true since we found the match in the search
186 iInputFoundFlag = true;
187 break;
188 }
189 inputsearchcount++;
190 }
191
192 //Check the flag of input format if it is true check for the output format, if not return failure
193 if (iInputFoundFlag)
194 {
195 while (outputsearchcount < iType[SearchCount].iOutputType.size())
196 {
197 if (iType[SearchCount].iOutputType[outputsearchcount] == aOutputType)
198 {
199 //set the the output flag to true since we found the match in the search
200 iOutputFoundFlag = true;
201 break;
202 }
203
204 outputsearchcount++;
205 }
206
207 if (iOutputFoundFlag)
208 {
209 // There's a match so add this node UUID to the list.
210 aUuids.push_back(iType[SearchCount].iNodeUUID);
211 matchfound = true;
212 }
213 }
214
215 SearchCount++;
216 }
217
218 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::QueryRegistry() OUT"));
219 if (matchfound)
220 {
221 return PVMFSuccess;
222 }
223 else
224 {
225 return PVMFFailure;
226 }
227 }
228
229
CreateNode(PVUuid & aUuid)230 PVMFNodeInterface* PVPlayerNodeRegistry::CreateNode(PVUuid& aUuid)
231 {
232 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() IN"));
233 bool iFoundFlag = false;
234 uint32 NodeSearchCount = 0;
235
236 while (NodeSearchCount < iType.size())
237 {
238 //Search if the UUID's will match
239 if (iType[NodeSearchCount].iNodeUUID == aUuid)
240 {
241 //Since the UUID's match set the flag to true
242 iFoundFlag = true;
243 break;
244 }
245
246 NodeSearchCount++;
247
248 }
249
250 if (iFoundFlag)
251 {
252 OsclActiveObject::OsclActivePriority priority = OsclActiveObject::EPriorityNominal;
253 PVPlayerNodeInfo* nodeInfo = &iType[NodeSearchCount];
254 PVMFNodeInterface* nodeInterface = NULL;
255
256 #if VIDEO_DEC_NODE_LOW_PRIORITY
257 //Call the appropriate Node creation function & return Node pointer
258 if (KPVMFOMXVideoDecNodeUuid == aUuid)
259 {
260 priority = OsclActiveObject::EPriorityLow;
261 }
262 #endif
263 if (NULL != nodeInfo->iNodeCreateFunc)
264 {
265 nodeInterface = (*(iType[NodeSearchCount].iNodeCreateFunc))(priority);
266 }
267 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() OUT"));
268 return nodeInterface;
269 }
270 else
271 {
272 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::CreateNode() OUT"));
273 return NULL;
274 }
275
276
277 }
278
ReleaseNode(PVUuid & aUuid,PVMFNodeInterface * aNode)279 bool PVPlayerNodeRegistry::ReleaseNode(PVUuid& aUuid, PVMFNodeInterface* aNode)
280 {
281 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() IN"));
282 bool iFoundFlag = false;
283 uint32 NodeSearchCount = 0;
284
285 while (NodeSearchCount < iType.size())
286 {
287 //Search if the UUID's will match
288 if (iType[NodeSearchCount].iNodeUUID == aUuid)
289 {
290 //Since the UUID's match set the flag to true
291 iFoundFlag = true;
292 break;
293 }
294
295 NodeSearchCount++;
296
297 }
298
299 if (iFoundFlag)
300 {
301 //Call the appropriate Node release function
302 bool del_stat = (*(iType[NodeSearchCount].iNodeReleaseFunc))(aNode);
303 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() OUT"));
304 return del_stat;
305 }
306
307 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerNodeRegistry::ReleaseNode() OUT"));
308 return false;
309 }
310
311
PVPlayerRecognizerRegistry()312 PVPlayerRecognizerRegistry::PVPlayerRecognizerRegistry()
313 : OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerRecognizerRegistry")
314 {
315 AddToScheduler();
316
317 iRecSessionId = 0;
318 iRecognizerResult.reserve(4);
319 iFileDataStreamFactory = NULL;
320 iDataStreamFactory = NULL;
321 iSourceFormatType = PVMF_MIME_FORMAT_UNKNOWN;
322 iObserver = NULL;
323 iCmdContext = NULL;
324 iCancelQuery = false;
325 iCancelCmdContext = NULL;
326
327 if (PVMFRecognizerRegistry::Init() != PVMFSuccess)
328 {
329 OSCL_ASSERT(false);
330 return;
331 }
332
333 iLogger = PVLogger::GetLoggerObject("pvplayerengine.playerrecognizerregistry");
334 }
335
336
~PVPlayerRecognizerRegistry()337 PVPlayerRecognizerRegistry::~PVPlayerRecognizerRegistry()
338 {
339 if (iFileDataStreamFactory)
340 {
341 OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
342 iFileDataStreamFactory = NULL;
343 }
344
345 PVMFRecognizerRegistry::Cleanup();
346 iLogger = NULL;
347 }
348
AddLoadableModules(const OSCL_String & aConfigFilePath)349 void PVPlayerRecognizerRegistry::AddLoadableModules(const OSCL_String& aConfigFilePath)
350 {
351 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::AddLoadableModules() IN"));
352 #ifdef USE_LOADABLE_MODULES
353 OsclLibraryList libList;
354 libList.Populate(PV_RECOGNIZER_POPULATOR_INTERFACE, aConfigFilePath);
355
356 for (unsigned int i = 0; i < libList.Size(); i++)
357 {
358 OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
359 if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
360 {
361 OsclAny* interfacePtr = NULL;
362 OsclLibStatus result = lib->QueryInterface(PV_RECOGNIZER_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
363 if (result == OsclLibSuccess && interfacePtr != NULL)
364 {
365 struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = (struct PVPlayerEngineRecognizerSharedLibInfo *)oscl_malloc(sizeof(struct PVPlayerEngineRecognizerSharedLibInfo));
366 if (NULL != libInfo)
367 {
368 libInfo->iLib = lib;
369
370 RecognizerPopulatorInterface* recognizerIntPtr = OSCL_DYNAMIC_CAST(RecognizerPopulatorInterface*, interfacePtr);
371
372 libInfo->iRecognizerLibIfacePtr = recognizerIntPtr;
373
374 recognizerIntPtr->RegisterAllRecognizers(this, libInfo->iContext);
375
376 // save for depopulation later
377 iRecognizerLibInfoList.push_front(libInfo);
378 continue;
379 }
380 }
381 }
382 lib->Close();
383 OSCL_DELETE(lib);
384 }
385 #else
386 OSCL_UNUSED_ARG(aConfigFilePath);
387 #endif
388 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::AddLoadableModules() OUT"));
389 }
390
RemoveLoadableModules()391 void PVPlayerRecognizerRegistry::RemoveLoadableModules()
392 {
393 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RemoveLoadableModules() IN"));
394 #ifdef USE_LOADABLE_MODULES
395 // remove all the dynamic plugins now
396 // unregister the plugins one by one
397 while (!iRecognizerLibInfoList.empty())
398 {
399 struct PVPlayerEngineRecognizerSharedLibInfo *libInfo = iRecognizerLibInfoList.front();
400 iRecognizerLibInfoList.erase(iRecognizerLibInfoList.begin());
401
402 OsclSharedLibrary* lib = libInfo->iLib;
403 RecognizerPopulatorInterface* recognizerIntPtr = libInfo->iRecognizerLibIfacePtr;
404 OsclAny* context = libInfo->iContext;
405 oscl_free(libInfo);
406
407 recognizerIntPtr->UnregisterAllRecognizers(this, context);
408
409 lib->Close();
410 OSCL_DELETE(lib);
411 }
412 #endif
413 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RemoveLoadableModules() OUT"));
414 }
415
QueryFormatType(OSCL_wString & aSourceURL,PVPlayerRecognizerRegistryObserver & aObserver,OsclAny * aCmdContext)416 PVMFStatus PVPlayerRecognizerRegistry::QueryFormatType(OSCL_wString& aSourceURL, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aCmdContext)
417 {
418 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() IN"));
419 if (iObserver != NULL)
420 {
421 // Previous query still ongoing
422 return PVMFErrBusy;
423 }
424 iObserver = &aObserver;
425 iCmdContext = aCmdContext;
426
427 // Create a datastream wrapper factory for standard file
428 if (iFileDataStreamFactory)
429 {
430 OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
431 iFileDataStreamFactory = NULL;
432 }
433 int32 leavecode = 0;
434 OSCL_TRY(leavecode, iFileDataStreamFactory = OSCL_STATIC_CAST(PVMFDataStreamFactory*, OSCL_NEW(PVMIDataStreamSyncInterfaceRefFactory, (aSourceURL))));
435 OSCL_FIRST_CATCH_ANY(leavecode,
436 return PVMFErrNoMemory;
437 );
438
439 // Open the session with recognizer
440 PVMFRecognizerRegistry::OpenSession(iRecSessionId, *this);
441
442 // Request file recognition
443 iRecognizerResult.clear();
444 iRecognizeCmdId = PVMFRecognizerRegistry::Recognize(iRecSessionId, *iFileDataStreamFactory, NULL, iRecognizerResult, NULL);
445
446 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() OUT"));
447 return PVMFSuccess;
448 }
449
QueryFormatType(PVMFCPMPluginAccessInterfaceFactory * aDataStreamFactory,PVPlayerRecognizerRegistryObserver & aObserver,OsclAny * aCmdContext)450 PVMFStatus PVPlayerRecognizerRegistry::QueryFormatType(PVMFCPMPluginAccessInterfaceFactory* aDataStreamFactory, PVPlayerRecognizerRegistryObserver& aObserver, OsclAny* aCmdContext)
451 {
452 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() IN"));
453 if (iObserver != NULL)
454 {
455 // Previous query still ongoing
456 return PVMFErrBusy;
457 }
458
459 if (aDataStreamFactory == NULL)
460 {
461 return PVMFErrArgument;
462 }
463
464 iObserver = &aObserver;
465 iCmdContext = aCmdContext;
466
467 // delete the previous DataStreamFactory created by PVPlayerRecognizerRegistry
468 if (iFileDataStreamFactory)
469 {
470 OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
471 iFileDataStreamFactory = NULL;
472 }
473
474 iDataStreamFactory = aDataStreamFactory;
475
476 // Open the session with recognizer
477 PVMFRecognizerRegistry::OpenSession(iRecSessionId, *this);
478
479 // Request file recognition
480 iRecognizerResult.clear();
481 iRecognizeCmdId = PVMFRecognizerRegistry::Recognize(iRecSessionId, *iDataStreamFactory, NULL, iRecognizerResult, NULL);
482
483 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::QueryFormatType() OUT"));
484 return PVMFSuccess;
485 }
486
487
CancelQuery(OsclAny * aContext)488 void PVPlayerRecognizerRegistry::CancelQuery(OsclAny* aContext)
489 {
490 if (iObserver == NULL)
491 {
492 // No pending recognize request
493 OSCL_LEAVE(OsclErrInvalidState);
494 return;
495 }
496
497 iCancelQuery = true;
498 iCancelCmdContext = aContext;
499
500 if (!IsBusy())
501 {
502 // The recognition pending so cancel it
503 PVMFRecognizerRegistry::CancelCommand(iRecSessionId, iRecognizeCmdId);
504 }
505 // Else the recognition already completed so just cancel it in the Run()
506 }
507
508
Run()509 void PVPlayerRecognizerRegistry::Run()
510 {
511 // Close the session with recognizer
512 PVMFRecognizerRegistry::CloseSession(iRecSessionId);
513
514 // Destroy the data stream wrapper factory for standard file
515 if (iFileDataStreamFactory)
516 {
517 OSCL_DELETE(OSCL_STATIC_CAST(PVMIDataStreamSyncInterfaceRefFactory*, iFileDataStreamFactory));
518 iFileDataStreamFactory = NULL;
519 }
520
521 // Tell the engine the result
522 if (iObserver)
523 {
524 iObserver->RecognizeCompleted(iSourceFormatType, iCmdContext);
525
526 if (iCancelQuery)
527 {
528 iObserver->RecognizeCompleted(iSourceFormatType, iCancelCmdContext);
529 iCancelQuery = false;
530 iCancelCmdContext = NULL;
531 }
532 }
533 iObserver = NULL;
534 iCmdContext = NULL;
535 }
536
RecognizerCommandCompleted(const PVMFCmdResp & aResponse)537 void PVPlayerRecognizerRegistry::RecognizerCommandCompleted(const PVMFCmdResp& aResponse)
538 {
539 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() IN"));
540 iSourceFormatType = PVMF_MIME_FORMAT_UNKNOWN;
541
542 if (aResponse.GetCmdId() == iRecognizeCmdId)
543 {
544 // Recognize() command completed
545 if (aResponse.GetCmdStatus() == PVMFSuccess)
546 {
547 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizeCommandCompleted() - Recognize returned Success"));
548 Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>::iterator it;
549 for (it = iRecognizerResult.begin(); it != iRecognizerResult.end(); it++)
550 {
551 if (it->iRecognitionConfidence == PVMFRecognizerConfidenceCertain)
552 { //@TODO: validate whether there are more than one claims Certain.
553 iSourceFormatType = it->iRecognizedFormat.get_str();
554 break;
555 }
556 if (it->iRecognitionConfidence == PVMFRecognizerConfidencePossible)
557 {
558 iSourceFormatType = it->iRecognizedFormat.get_str();
559 }
560 }
561 }
562 else if (aResponse.GetCmdStatus() == PVMFErrCancelled)
563 {
564 // If cancelled, need to wait for the cancel command to complete before
565 // calling Run
566 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() - Recognize returned Cancelled - OUT"));
567 return;
568 }
569 }
570
571 RunIfNotReady();
572 PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "PVPlayerRecognizerRegistry::RecognizerCommandCompleted() OUT"));
573 }
574
575
576
577
578
579