OSCL_EXPORT_REF PV2WayLipSyncSourceAndSinks::PV2WayLipSyncSourceAndSinks(PV2Way324InitInfo& aSdkInitInfo):
        PV2WayDummySourceAndSinks(aSdkInitInfo)
{
    if (iDummyMioAudioInputFactory)
    {
        OSCL_DELETE(iDummyMioAudioInputFactory);
    }
    if (iDummyMioAudioOutputFactory)
    {
        OSCL_DELETE(iDummyMioAudioOutputFactory);
    }
    if (iDummyMioVideoInputFactory)
    {
        OSCL_DELETE(iDummyMioVideoInputFactory);
    }
    if (iDummyMioVideoOutputFactory)
    {
        OSCL_DELETE(iDummyMioVideoOutputFactory);
    }
    iDummyMioAudioInputFactory = OSCL_NEW(PV2WayLipSyncInputMIONodeFactory, ());
    iDummyMioVideoInputFactory = OSCL_NEW(PV2WayLipSyncInputMIONodeFactory, ());

    iDummyMioAudioOutputFactory = OSCL_NEW(PV2WayLipSyncOutputMIONodeFactory, ());
    iDummyMioVideoOutputFactory = OSCL_NEW(PV2WayLipSyncOutputMIONodeFactory, ());
}
OsclAsyncFile::~OsclAsyncFile()
{
    //Stop the tread, cancel any requests for Run()
    //and remove AO from the scheduler

    StopAsyncReadThread();

    Cancel();
    RemoveFromScheduler();

    if (iNativeFileDuplicate)
    {
        iNativeFileDuplicate->Close();
        OSCL_DELETE(iNativeFileDuplicate);
    }

    for (uint32 i = 0; i < iDataBufferArray.size(); i++)
        OSCL_DELETE(iDataBufferArray[i]);

    iDataBufferArray.clear();
    iSortedDataBufferArray.clear();
    iLinkedDataBufferArray.clear();
    OSCL_DELETE(iDataBuffer);

}
void PVMFJitterBufferMisc::ResetParams(bool aReleaseMemory)
{
    if (ipFireWallPacketExchangerImpl && aReleaseMemory)
    {
        OSCL_DELETE(ipFireWallPacketExchangerImpl);
    }

    ipFireWallPacketExchangerImpl = NULL;

    iSessionDuration = 0;
    iStreamingSessionExpired = false;
    iPlayDurationAvailable = false;
    iBroadcastSession = false;

    iPlayStartTimeInMS = 0;
    iPlayStopTimeInMS = 0;
    iPlayStopTimeAvailable = false;


    iFireWallPacketsExchangeEnabled = true;
    iEstimatedServerClockUpdateCallbackId = 0;
    iEstimatedServerClockUpdateCallbackPending = false;


}
bool ProtocolEngineNodeProgressiveDownloadContainerLoader::DeleteProgressiveDownloadContainer(ProtocolContainer* aContainer)
{
    if (NULL == aContainer) return false;

    // Retrieve shared library pointer
    OsclSharedLibrary* aSharedLibrary = aContainer->GetSharedLibraryPtr();

    bool bStatus = false;
    if (NULL != aSharedLibrary)
    {
        // Query for release function
        OsclAny* interfacePtr = NULL;
        aSharedLibrary->QueryInterface(PENODE_SHARED_LIBRARY_INTERFACE, (OsclAny*&)interfacePtr);

        ProtocolEngineNodeSharedLibraryInterface* libIntPtr = OSCL_DYNAMIC_CAST(ProtocolEngineNodeSharedLibraryInterface*, interfacePtr);

        OsclAny* releaseFuncTemp = libIntPtr->QueryLibInterface(PENODE_RELEASE_LIB_INTERFACE);
        if (!releaseFuncTemp) return false;

        LPFN_LIB_RELEASE_FUNC libReleaseFunc = OSCL_DYNAMIC_CAST(bool (*)(ProtocolContainer*), releaseFuncTemp);

        if (NULL != libReleaseFunc)
        {
            bStatus = (*(libReleaseFunc))(aContainer);
        }

        aSharedLibrary->RemoveRef();

        if (OsclLibSuccess == aSharedLibrary->Close())
        {
            // Close will unload the library if refcount is 0
            OSCL_DELETE(aSharedLibrary);
        }
    }
OSCL_EXPORT_REF void PVPLSFFRecognizerFactory::DestroyRecognizerPlugin(PVMFRecognizerPluginInterface* aPlugin)
{
    if (aPlugin)
    {
        OSCL_DELETE(((PVPLSFFRecognizerPlugin*)aPlugin));
    }
}
// Destructor
PVA_FF_MediaDataAtom::~PVA_FF_MediaDataAtom()
{
    if (_pofstream._filePtr != NULL && true == _oIsFileOpen)
    {
        PVA_FF_AtomUtils::closeFile(&_pofstream);
        _pofstream._filePtr = NULL;
    }

    // PVA_FF_TrackAtom *_ptrackReferencePtr - is taken care of by the movie atom
    // Delete vector<PVA_FF_Renderable*> *_prenderables
    if (_prenderables != NULL)
    {
        for (uint32 i = 0; i < _prenderables->size(); i++)
        {
            if ((*_prenderables)[i] != NULL)
            {
                OSCL_DELETE((*_prenderables)[i]);
                //PV_MP4_FF_DELETE(NULL,PVA_FF_Renderable,(*_prenderables)[i]);
                (*_prenderables)[i] = NULL;
            }
        }
        PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_RenderableVecType, Oscl_Vector, _prenderables);
        _prenderables = NULL;
    }

    //Contents of this array are deleted in movie atom
    //OSCL_DELETE(_ptrackReferencePtrVec);

    PV_MP4_FF_TEMPLATED_DELETE(NULL, PVA_FF_TrackAtomVecType, Oscl_Vector, _ptrackReferencePtrVec);

    Oscl_FileServer fileServ;
    fileServ.Connect();
    fileServ.Oscl_DeleteFile(_tempFilename.get_cstr());
    fileServ.Close();
}
PvmfMediaInputNodeOutPort::~PvmfMediaInputNodeOutPort()
{
    PvmfPortBaseImpl::ClearMsgQueues();


    if (iMediaDataAlloc != NULL)
    {
        OSCL_DELETE(iMediaDataAlloc);
    }

    if (iMediaDataAllocMemPool)
    {
        iMediaDataAllocMemPool->removeRef();
    }

    if (iMediaDataMemPool)
    {
        iMediaDataMemPool->removeRef();
    }
    iDataPathLogger = NULL;

    // we need to clear the activity handler, since otherwise the PvmfPortBaseImpl destructor
    // ends up calling back onto our HandlePortActivity method, which no longer exists because
    // this objects's destructor has already been called.
    SetActivityHandler(NULL);
}
/* ======================================================================== */
OSCL_EXPORT_REF void PV_Wav_Parser::CleanupWAVFile(void)
{
    if (ipWAVFile != NULL)
        ipWAVFile->Close();
    OSCL_DELETE(ipWAVFile);
    ipWAVFile = NULL;

    AudioFormat = 0;
    NumChannels = 0;
    SampleRate = 0;
    ByteRate = 0;
    BlockAlign = 0;
    BitsPerSample = 0;
    BytesPerSample = 0;
    PCMBytesRead = 0;
    PCMBytesPresent = 0;
    iHeaderSize = 0;
    isLittleEndian = 1; // little endian by default
    xLawTable = NULL;
    if(iGsmHandle) 
    {
        gsm_destroy((gsm)iGsmHandle);
        iGsmHandle = 0;
    }
    iPrevData = 0;
}
bool ShoutcastContainer::createProtocolObjects()
{
    if (!ProgressiveStreamingContainer::createProtocolObjects()) return false;

    // re-create iProtocol
    if (iProtocol) OSCL_DELETE(iProtocol);
    iProtocol = OSCL_NEW(ShoutcastStreaming, ());
    if (iProtocol == NULL) return false;

    // re-create iDownloadControl
    if (iDownloadControl) OSCL_DELETE(iDownloadControl);
    iDownloadControl = OSCL_NEW(ShoutcastControl, ());
    if (iDownloadControl == NULL) return false;

    DownloadContainer::setEventReporterSupportObjects();
    return true;
}
OsclComponentRegistryElement::~OsclComponentRegistryElement()
{
    if (iId)
    {
        OSCL_HeapString<OsclMemAllocator>* id = (OSCL_HeapString<OsclMemAllocator>*)iId;
        OSCL_DELETE(id);
    }
}
/* ///////////////////////////////////////////////////////////////////////// */
OSCL_EXPORT_REF CPVM4VEncoder* CPVM4VEncoder::New(int32 aThreadId)
{
    CPVM4VEncoder* self = new CPVM4VEncoder;
    if (self && self->Construct(aThreadId))
        return self;
    if (self)
        OSCL_DELETE(self);
    return NULL;
}
void CDecoderVideo::Release(JNIEnv*  env)
{
	env->ReleaseByteArrayElements(m_byDecoded, m_pbyDecoded, 0);
	env->ReleaseByteArrayElements(m_byRGB, m_pbyRGB, 0);
	env->ReleaseIntArrayElements(m_iRGB, m_piRGB, 0);
	OSCL_DELETE(((ColorConvert32*)_pCC));
	
	PVCleanUpVideoDecoder(_iVideoCtrls);
	//oscl_free(_H263Header);
	if (_pvDec){
		_pvDec->CleanUpVideoDecoder();
		delete _pvDec;
		_pvDec=NULL;
	}
	OSCL_DELETE((VideoDecControls *)_iVideoCtrls);
    _iVideoCtrls = NULL;
	__android_log_write(ANDROID_LOG_DEBUG, "CDecoderVideo", "Released");
}
PVMp4FFComposerPort::~PVMp4FFComposerPort()
{
    if (memfrag_sps)
    {
        for (uint32 i = 0; i < iNode->memvector_sps.size(); i++)
        {
            OSCL_FREE(iNode->memvector_sps[i]->ptr);
        }

        while (!iNode->memvector_sps.empty())
        {
            if (iNode->memvector_sps.front())
            {
                OSCL_FREE(iNode->memvector_sps.front());
            }
            iNode->memvector_sps.erase(&iNode->memvector_sps.front());
        }
    }

    if (memfrag_pps)
    {
        for (uint32 i = 0; i < iNode->memvector_pps.size(); i++)
        {
            OSCL_FREE(iNode->memvector_pps[i]->ptr);
        }

        while (!iNode->memvector_pps.empty())
        {
            if (iNode->memvector_pps.front())
            {
                OSCL_FREE(iNode->memvector_pps.front());
            }
            iNode->memvector_pps.erase(&iNode->memvector_pps.front());
        }
    }

    if (iNode->textdecodervector.size() > 0)
    {

        while (!iNode->textdecodervector.empty())
        {
            if (iNode->textdecodervector.front())
            {
                OSCL_DELETE(iNode->textdecodervector.front());
            }

            iNode->textdecodervector.erase(&iNode->textdecodervector.front());
        }
    }
    Disconnect();
    ClearMsgQueues();

    // we need to clear the activity handler, since otherwise the PvmfPortBaseImpl destructor
    // ends up calling back onto our HandlePortActivity method, which no longer exists because
    // this objects's destructor has already been called.
    SetActivityHandler(NULL);
}
/* ///////////////////////////////////////////////////////////////////////// */
OSCL_EXPORT_REF CPVM4VEncoder::~CPVM4VEncoder()
{
#if defined(RGB24_INPUT) || defined (RGB12_INPUT) || defined(YUV420SEMIPLANAR_INPUT)
    OSCL_DELETE(ccRGBtoYUV);
#endif

    Cancel(); /* CTimer function */
    Terminate();
}
OSCL_EXPORT_REF bool PVMFRrtspEngineNodeFactory::DeletePVMFRtspEngineNode(PVMFNodeInterface* aNode)
{
    if (aNode)
    {
        OSCL_DELETE(((PVRTSPEngineNode*)aNode));
        return true;
    }

    return false;
}
OSCL_EXPORT_REF bool PVAVCDecoderFactory::DeletePVAVCDecoder(PVAVCDecoderInterface* aVideoDec)
{
    if (aVideoDec)
    {
        OSCL_DELETE(aVideoDec);
        return true;
    }

    return false;
}
OSCL_EXPORT_REF
bool PVMFMP3FFParserNodeFactory::DeletePVMFMP3FFParserNode(PVMFNodeInterface* aNode)
{
    if (aNode)
    {
        OSCL_DELETE(aNode);
        return true;
    }
    return false;
}
OSCL_EXPORT_REF void OsclMemPoolResizableAllocator::removeRef()
{
    // Decrement the ref count
    --iRefCount;

    // If ref count reaches 0 then destroy this object automatically
    if (iRefCount <= 0)
    {
        OSCL_DELETE(this);
    }
}
OSCL_EXPORT_REF PVMFJitterBufferMisc::~PVMFJitterBufferMisc()
{
    ResetParams(true);
    if (ipRTCPProtoImplementator)
    {
        ipRTCPProtoImplementator->RemoveAllRTCPChannelControllers();
        OSCL_DELETE(ipRTCPProtoImplementator);
    }

    if (ipEventNotifier)
    {
        OSCL_DELETE(ipEventNotifier);
    }

    if (ipSessionDurationTimer)
    {
        OSCL_DELETE(ipSessionDurationTimer);
    }

    if (ipEstimatedServerClock)
    {
        OSCL_DELETE(ipEstimatedServerClock);
    }

    if (ipWallClock)
    {
        OSCL_DELETE(ipWallClock);
    }

    if (ipNonDecreasingClock)
    {
        OSCL_DELETE(ipNonDecreasingClock);
    }
}
OsclComponentRegistryElement& OsclComponentRegistryElement::operator=(const OsclComponentRegistryElement & src)
{
    if (iId)
    {
        OSCL_HeapString<OsclMemAllocator>* id = (OSCL_HeapString<OsclMemAllocator>*)iId;
        OSCL_DELETE(id);
        iId = NULL;
    }
    iId = OSCL_NEW(OSCL_HeapString<OsclMemAllocator>, (*src.iId));
    iFactory = src.iFactory;
    iComponentId = src.iComponentId;
    return *this;
}
TPVStatusCode H223LowerLayer::Close()
{
    PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, iLogger, PVLOGMSG_STACK_TRACE, (0, "H223LowerLayer::Close\n"));

    OSCL_DEFAULT_FREE(iIdleSyncCheckBuffer);
    iIdleSyncCheckBuffer = NULL;

    OSCL_DEFAULT_FREE(iDemuxBuffer);
    iDemuxBuffer = iDemuxBufferPos = NULL;

    iDispatchPacketAlloc->removeRef();
    iDispatchPacketAlloc = NULL;

    OSCL_DELETE(iMediaMsgPoolAlloc);
    iMediaMsgPoolAlloc = NULL;

    OSCL_DELETE(iMediaDataImplMemAlloc);
    iMediaDataImplMemAlloc = NULL;

    iMemFragmentAlloc->clear();
    OSCL_DELETE(iMemFragmentAlloc);
    return EPVT_Success;
}
OSCL_EXPORT_REF GAU::~GAU()
{
    for (int32 ii = 0; ii < buf.num_fragments; ii++)
    {
        if (buf.buf_states[ii] != NULL)
        {
            buf.buf_states[ii]->decrement_refcnt();
            if (free_buffer_states_when_done && buf.buf_states[ii]->get_refcount() == 0)
            {
                OSCL_DELETE(buf.buf_states[ii]);
                buf.buf_states[ii] = NULL;
            }
        }
    }
}
// Factory functions
PVMFNodeInterface* Mp4NodesCoreLibraryLoader::CreateMp4ParserNode(int32 aPriority)
{
    OsclSharedLibrary* mp4SharedLibrary = NULL;
    OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(MP4_LIB_NAME);

    // Need to load the library for the node
    mp4SharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
    OsclLibStatus result = mp4SharedLibrary->LoadLib();
    if (OsclLibSuccess != result)
    {
        return NULL;
    }

    mp4SharedLibrary->AddRef();

    // Query for create function
    OsclAny* interfacePtr = NULL;

    mp4SharedLibrary->QueryInterface(PV_NODE_INTERFACE, (OsclAny*&)interfacePtr);

    NodeSharedLibraryInterface* nodeIntPtr = OSCL_DYNAMIC_CAST(NodeSharedLibraryInterface*, interfacePtr);

    OsclAny* createFuncTemp = nodeIntPtr->QueryNodeInterface(KPVMFMP4FFParserNodeUuid, PV_CREATE_NODE_INTERFACE);

    LPFN_NODE_CREATE_FUNC nodeCreateFunc = OSCL_DYNAMIC_CAST(PVMFNodeInterface * (*)(int32), createFuncTemp);

    if (NULL != nodeCreateFunc)
    {
        PVMFNodeInterface* node = NULL;
        // call the real node factory function
        node = (*(nodeCreateFunc))(aPriority);
        if (NULL == node)
        {
            mp4SharedLibrary->RemoveRef();

            if (OsclLibSuccess == mp4SharedLibrary->Close())
            {
                // Close will unload the library if refcount is 0
                OSCL_DELETE(mp4SharedLibrary);
            }

            return NULL;
        }
        node->SetSharedLibraryPtr(mp4SharedLibrary);
        return node;
    }
    return NULL;
}
//data is available on one of the thread-safe queues.
void pv_metadata_engine_test::ThreadSafeQueueDataAvailable(ThreadSafeQueue* aQueue)
{
    if (aQueue == &iThreadSafeCommandQueue)
    {
        for (uint32 ndata = 1; ndata;)
        {
            ThreadSafeQueueId id;
            OsclAny* data;
            ndata = iThreadSafeCommandQueue.DeQueue(id, data);
            if (ndata)
            {
                PVCmdResponse* cmd = (PVCmdResponse*)data;
                CommandCompleted(*cmd);
                OSCL_DELETE(cmd);
            }
        }
    }
    if (aQueue == &iThreadSafeErrorQueue)
    {
        for (uint32 ndata = 1; ndata;)
        {
            ThreadSafeQueueId id;
            OsclAny* data;
            ndata = iThreadSafeErrorQueue.DeQueue(id, data);
            if (ndata)
            {
                int32 eventType = (PVMFEventType)data;
                PVAsyncErrorEvent event(eventType);
                HandleErrorEvent(event);
            }
        }
    }
    if (aQueue == &iThreadSafeInfoQueue)
    {
        for (uint32 ndata = 1; ndata;)
        {
            ThreadSafeQueueId id;
            OsclAny* data;
            ndata = iThreadSafeInfoQueue.DeQueue(id, data);
            if (ndata)
            {
                int32 eventType = (PVMFEventType)data;
                PVAsyncInformationalEvent event(eventType);
                HandleInformationalEvent(event);
            }
        }
    }
}
void PVMFProtocolEngineNodeRegistry::AddLoadableModules()
{
    LOGINFO((0, "PVMFProtocolEngineNodeRegistry::AddLoadableModules() IN"));

#if USE_LOADABLE_MODULES

    OsclConfigFileList aCfgList;
    // collects all config files from the project specified directory
    if (NULL != PV_DYNAMIC_LOADING_CONFIG_FILE_PATH)
    {
        OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
        aCfgList.Populate(configFilePath);
    }
    // populate libraries from all config files
    for (uint k = 0; k < aCfgList.Size(); k++)
    {
        OsclLibraryList libList;
        libList.Populate(PVMF_PROTOCOL_ENGINE_NODE_REGISTRY_POPULATOR_INTERFACE, aCfgList.GetConfigfileAt(k));

        for (uint32 i = 0; i < libList.Size(); i++)
        {
            OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
            if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess)
            {
                OsclAny* interfacePtr = NULL;
                OsclLibStatus result = lib->QueryInterface(PVMF_PROTOCOL_ENGINE_NODE_REGISTRY_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
                if (result == OsclLibSuccess && interfacePtr != NULL)
                {
                    struct PVProtocolEngineNodeSharedLibInfo *libInfo =
                        (struct PVProtocolEngineNodeSharedLibInfo *)oscl_malloc(sizeof(struct PVProtocolEngineNodeSharedLibInfo));
                    if (NULL != libInfo)
                    {
                        libInfo->iLib = lib;

                        PVMFProtocolEngineNodeRegistryPopulatorInterface* nodeLibIntPtr = OSCL_DYNAMIC_CAST(PVMFProtocolEngineNodeRegistryPopulatorInterface*, interfacePtr);
                        libInfo->iNodeLibIfacePtr = nodeLibIntPtr;
                        nodeLibIntPtr->Register(this);

                        // save for depopulation later
                        iNodeLibInfoList.push_front(libInfo);
                        continue;
                    }
                }
            }
            lib->Close();
            OSCL_DELETE(lib);
        }
        // From NodeRegistrySharedLibraryInterface
        void UnregisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny* aContext)
        {
            if (NULL != aContext)
            {
                Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = (Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator> *)aContext;

                while (!nodeList->empty())
                {
                    PVPlayerNodeInfo tmpnode = nodeList->front();
                    OSCL_DELETE(tmpnode.iSharedLibrary);
                    aRegistry->UnregisterNode(tmpnode);
                    nodeList->erase(nodeList->begin());
                }

                delete nodeList;
            }
        };
OSCL_EXPORT_REF PVMFBufferDataSource::~PVMFBufferDataSource()
{
    Stop();
    if (iMediaDataAlloc)
    {
        OSCL_DELETE(iMediaDataAlloc);
        iMediaDataAlloc = NULL;
    }
    if (iFsi)
    {
        OSCL_DEFAULT_FREE(iFsi);
        iFsi = NULL;
    }

    // we need to clear the activity handler, since otherwise the PvmfPortBaseImpl destructor
    // ends up calling back onto our HandlePortActivity method, which no longer exists because
    // this objects's destructor has already been called.
    SetActivityHandler(NULL);
}
PVMFRecognizerRegistryImpl::~PVMFRecognizerRegistryImpl()
{
    iDataStreamFactory = NULL;

    while (iRecognizerPluginFactoryList.empty() == false)
    {
        // The plug-in factories were not removed before shutting down the
        // registry. This could lead to memory leaks since the registry
        // cannot call the destructor for the derived factory class. So assert.
        OSCL_ASSERT(false);

        // Destroy factory using the base class
        PVMFRecognizerPluginFactory* pluginfactory = iRecognizerPluginFactoryList[0];
        iRecognizerPluginFactoryList.erase(iRecognizerPluginFactoryList.begin());
        OSCL_DELETE(pluginfactory);
    }

    iLogger = NULL;
}
// Factory functions
ProtocolContainer* ProtocolEngineNodeProgressiveDownloadContainerLoader::CreateProgressiveDownloadContainer(PVMFProtocolEngineNode* aNode)
{
    OsclSharedLibrary* aSharedLibrary = NULL;
    OSCL_StackString<LIB_NAME_MAX_LENGTH> libname(PDL_PLUGIN_LIB_NAME);

    // Need to load the library for the node
    aSharedLibrary = OSCL_NEW(OsclSharedLibrary, ());

    OsclLibStatus result = aSharedLibrary->LoadLib(libname);
    if (OsclLibSuccess != result) return NULL;
    aSharedLibrary->AddRef();

    // Query for create function
    OsclAny* interfacePtr = NULL;
    aSharedLibrary->QueryInterface(PENODE_SHARED_LIBRARY_INTERFACE, (OsclAny*&)interfacePtr);
    if (NULL == interfacePtr) return NULL;

    ProtocolEngineNodeSharedLibraryInterface* libIntPtr = OSCL_DYNAMIC_CAST(ProtocolEngineNodeSharedLibraryInterface*, interfacePtr);

    OsclAny* createFuncTemp = libIntPtr->QueryLibInterface(PENODE_CREATE_LIB_INTERFACE);
    if (!createFuncTemp) return NULL;

    LPFN_LIB_CREATE_FUNC libCreateFunc = OSCL_DYNAMIC_CAST(ProtocolContainer * (*)(PVMFProtocolEngineNode *), createFuncTemp);

    if (NULL != libCreateFunc)
    {
        // call the real node factory function
        ProtocolContainer *aProtocolContainer = (*(libCreateFunc))(aNode);
        if (NULL != aProtocolContainer)
        {
            aProtocolContainer->SetSharedLibraryPtr(aSharedLibrary);
            return aProtocolContainer;
        }
    }

    aSharedLibrary->RemoveRef();
    if (OsclLibSuccess == aSharedLibrary->Close())
    {
        // Close will unload the library if refcount is 0
        OSCL_DELETE(aSharedLibrary);
    }
    return NULL;
}
        void UnregisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny* aContext)
        {
            if (NULL != aContext)
            {
                Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>* pluginList = (Oscl_Vector<PVMFRecognizerPluginFactory*, OsclMemAllocator>*)aContext;

                while (!pluginList->empty())
                {
                    PVMFRecognizerPluginFactory* tmpfac = pluginList->front();

                    aRegistry->UnregisterRecognizer(tmpfac);

                    pluginList->erase(pluginList->begin());

                    OSCL_DELETE(tmpfac);
                }

                delete pluginList;
            }
        };