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