int main(int argc, char* argv[]) { if (argc != 3) { fprintf(stderr, "Usage : %s <sdp version> <sdp file>\n", argv[0]); } else { IUnknown* pContext = new CHXMiniCCF(); if (pContext) { pContext->AddRef(); IHXCommonClassFactory* pCCF = 0; if (HXR_OK == pContext->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF)) { IHXBuffer* pSDP = ReadSDPFile(pCCF, argv[2]); if (pSDP) { if (HXR_OK != Parse(pContext, strtoul(argv[1], 0, 10), pSDP)) { fprintf(stderr, "Failed to parse SDP\n", argv[1]); } pSDP->Release(); pSDP = 0; } else { fprintf(stderr, "Failed to read SDP file '%s'\n", argv[2]); } pCCF->Release(); pCCF = 0; } pContext->Release(); pContext = 0; } } return 0; }
STDMETHODIMP HXCommonClassFactory::CreateInstance ( REFCLSID /*IN*/ rclsid, void** /*OUT*/ ppUnknown ) { if (IsEqualCLSID(rclsid, CLSID_IHXBuffer)) { *ppUnknown = (IUnknown*)(IHXBuffer*)(new ServerBuffer(TRUE)); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXPacket)) { if (!g_bFastMallocAll && !g_bFastMalloc) *ppUnknown = (IUnknown*)(IHXPacket*)(new ServerPacket(TRUE)); else *ppUnknown = (IUnknown*)(IHXPacket*)(new(m_pMemCache) ServerPacket(TRUE)); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXRTPPacket)) { if (!g_bFastMallocAll && !g_bFastMalloc) *ppUnknown = (IUnknown*)(IHXRTPPacket*)(new ServerRTPPacket(TRUE)); else *ppUnknown = (IUnknown*)(IHXRTPPacket*)(new(m_pMemCache) ServerRTPPacket(TRUE)); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXValues)) { *ppUnknown = (IUnknown*)(IHXValues*)(new CHXHeader()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXValues2)) { *ppUnknown = (IUnknown*)(IHXValues2*)(new CHXHeader()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXFileSystemManager)) { *ppUnknown = (IUnknown*)(IHXFileSystemManager*)(new FSManager(m_proc)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if(IsEqualCLSID(rclsid, CLSID_IHXPluginGroupEnumerator)) { *ppUnknown = (IUnknown*)(IHXPluginGroupEnumerator*) (new CHXPluginGroupEnumerator(m_proc->pc->plugin_handler)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXFragmentedBuffer)) { *ppUnknown = (IUnknown*)(IHXFragmentedBuffer*)(new CHXFragmentedBuffer((IUnknown*)(IHXCommonClassFactory*)this)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXKeyValueList)) { *ppUnknown = (IUnknown*)(IHXKeyValueList*)(new CKeyValueList()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualIID(rclsid, CLSID_IHXSourceFinderObject)) { *ppUnknown = (IUnknown*)(IHXSourceFinderObject*)(new CServerSourceFinder(m_proc)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXHTTPPostObject)) { CHXHTTPPostObject* pObject = CHXHTTPPostObject::CreateObject(); *ppUnknown = (IUnknown*) (IHXHTTPPostObject*) pObject; ((IUnknown*)*ppUnknown)->AddRef(); pObject->InitObject(m_proc->pc->server_context); return HXR_OK; } else if(IsEqualCLSID(rclsid, CLSID_IHXRequest)) { *ppUnknown = (IUnknown*)(IHXRequest*)(new CHXRequest()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXMutex)) { *ppUnknown = (IUnknown*)(IHXMutex*)(new Mutex()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXFastFileFactory)) { *ppUnknown = (IUnknown*)(IHXFastFileFactory*) (new FastFileFactory(m_proc->pc->server_context)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXFastFileFactory2)) { *ppUnknown = (IUnknown*)(IHXFastFileFactory2*) (new FastFileFactory(m_proc->pc->server_context)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXQoSSignal)) { *ppUnknown = (IUnknown*)(IHXQoSSignal*)(new QoSSignal()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if (IsEqualCLSID(rclsid, CLSID_IHXList)) { IHXFastAlloc* pAlloc = NULL; m_proc->pc->server_context->QueryInterface(IID_IHXFastAlloc, (void**)&pAlloc); *ppUnknown = (IUnknown*)(IHXList*)(new CHXList(pAlloc)); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else if(IsEqualCLSID(rclsid, IID_IHXPacketOrderer)) { *ppUnknown = (IUnknown*)(IHXPacketOrderer*)(new CPacketOrderShim()); ((IUnknown*)*ppUnknown)->AddRef(); return HXR_OK; } else { // Try the factory plugins PluginHandler* pPluginHandler = m_proc->pc->plugin_handler; *ppUnknown = NULL; if(pPluginHandler) { PluginHandler::Factory* pFactories; PluginHandler::Plugin* pPlugin; CHXSimpleList::Iterator i; pFactories = pPluginHandler->m_factory_handler; for(i = pFactories->m_pPlugins->Begin(); i != pFactories->m_pPlugins->End(); ++i) { IUnknown* pInstance = 0; pPlugin = (PluginHandler::Plugin*)(*i); pPlugin->GetInstance(&pInstance); if(pInstance) { HX_RESULT res; IHXPlugin* pFPlugin = 0; res = pInstance->QueryInterface(IID_IHXPlugin, (void**)&pFPlugin); if(res == HXR_OK) { IHXCommonClassFactory* pClassFactory; IUnknown* pContext; m_proc->pc->server_context->QueryInterface( IID_IUnknown, (void**)&pContext); pFPlugin->InitPlugin(pContext); pFPlugin->Release(); pContext->Release(); res = pInstance->QueryInterface( IID_IHXCommonClassFactory, (void**)&pClassFactory); if(HXR_OK == res) { res = pClassFactory->CreateInstance(rclsid, ppUnknown); if(HXR_OK != res) *ppUnknown = NULL; pClassFactory->Release(); } } pInstance->Release(); pPlugin->ReleaseInstance(); if(*ppUnknown) { return HXR_OK; } } } } } *ppUnknown = NULL; return HXR_NOINTERFACE; }