blob: 6cb6151426df2a1e27c245284582ceb6c996a560 [file] [log] [blame]
/* ------------------------------------------------------------------
* Copyright (C) 2008 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied.
* See the License for the specific language governing permissions
* and limitations under the License.
* -------------------------------------------------------------------
*/
/* This file defines a PV NodeSharedLibrary interface that populates the
registry with the streaming manager node.
*/
#include "pvmf_node_shared_lib_interface.h"
#include "pvmf_sm_node_factory.h"
#include "pvmf_recognizer_registry.h"
#include "osclconfig.h"
#define NODE_REGISTRY_LIB_NAME_MAX_LENGTH 64
class StreamingNodesRegistryInterface: public OsclSharedLibraryInterface,
public NodeRegistrySharedLibraryInterface,
public RecognizerSharedLibraryInterface
{
public:
// From NodeRegistrySharedLibraryInterface
void RegisterAllNodes(PVPlayerNodeRegistryInterface* aRegistry, OsclAny*& aContext)
{
PVPlayerNodeInfo nodeinfo;
#define RTSP_LIB_NAME "libopencorertsp.so"
OSCL_StackString<NODE_REGISTRY_LIB_NAME_MAX_LENGTH> libname(RTSP_LIB_NAME);
Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>* nodeList = new Oscl_Vector<PVPlayerNodeInfo, OsclMemAllocator>;
//For PVMFStreamingManagerNode
nodeinfo.iInputTypes.clear();
nodeinfo.iInputTypes.push_back(PVMF_DATA_SOURCE_RTSP_URL);
nodeinfo.iInputTypes.push_back(PVMF_DATA_SOURCE_SDP_FILE);
nodeinfo.iNodeUUID = KPVMFStreamingManagerNodeUuid;
nodeinfo.iOutputType.clear();
nodeinfo.iOutputType.push_back(PVMF_FORMAT_UNKNOWN);
nodeinfo.iSharedLibrary = OSCL_NEW(OsclSharedLibrary, (libname));
aRegistry->RegisterNode(nodeinfo);
nodeList->push_back(nodeinfo);
aContext = (OsclAny *)nodeList;
};
// 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;
}
};
// From RecognizerSharedLibraryInterface
void RegisterAllRecognizers(PVPlayerRecognizerRegistryInterface* aRegistry, OsclAny*& aContext)
{
};
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;
}
};
// From OsclSharedLibraryInterface
OsclAny* SharedLibraryLookup(const OsclUuid& aInterfaceId)
{
if (aInterfaceId == PV_NODE_REGISTRY_INTERFACE)
{
return OSCL_STATIC_CAST(NodeRegistrySharedLibraryInterface*, this);
}
return NULL;
};
static StreamingNodesRegistryInterface* Instance()
{
static StreamingNodesRegistryInterface nodeInterface;
return &nodeInterface;
};
private:
StreamingNodesRegistryInterface() {};
};
extern "C"
{
OsclAny *GetInterface(void)
{
return StreamingNodesRegistryInterface::Instance();
}
}