⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hxplugin.cpp

📁 linux下的一款播放器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	if( SUCCEEDED( pUnkPlugin->QueryInterface( IID_IHXComponentPlugin, (void**) &pComponentPlugin ) ) )	{	    // Ask for the correct object by CLSID	    IHXBuffer* pCLSID = NULL;	    if( SUCCEEDED( m_pValues->GetPropertyBuffer( PLUGIN_COMPONENT_CLSID, pCLSID ) ) )	    {		hr = pComponentPlugin->CreateComponentInstance( *(GUID*) pCLSID->GetBuffer(), pUnknown, pIUnkOuter );		HX_RELEASE( pCLSID );	    }	    else	    {		// component plugins must have CLSID                HX_ASSERT(false);	    }	    HX_RELEASE( pComponentPlugin );	    HX_RELEASE( pUnkPlugin );	}	else	{	    if( !pIUnkOuter )	    {		pUnknown = pUnkPlugin;                pUnknown->AddRef();                hr = HXR_OK;	    }            else            {                // we can't aggregate anything because this is not a component plugin                HX_ASSERT(false);            }            HX_RELEASE( pUnkPlugin );	}    }    return hr;}HX_RESULT HXPlugin::GetPluginInfo(IHXValues*& pVals){    if (m_pValues)    {	pVals = m_pValues;        pVals->AddRef();	return HXR_OK;    }    pVals = NULL;    return HXR_FAIL;}HX_RESULTHXPlugin::GetBasicValues(IHXPlugin* pHXPlugin){    DPRINTF(D_INFO, ("HXPlugin()::GetBasicValues(): returning nothing\n"));    return HXR_OK;#if(0)    const char*	pszDescription = NULL;    const char* pszCopyright = NULL;    const char* pszMoreInfoUrl = NULL;    ULONG32	ulVersionNumber = 0;    BOOL	nload_multiple = 0;    if (HXR_OK != pHXPlugin->GetPluginInfo(nload_multiple, pszDescription,				       pszCopyright, pszMoreInfoUrl, ulVersionNumber))    {        return HXR_FAIL;    }    IHXBuffer* pBuffer = NULL;    m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);    if (pszDescription)    {	pBuffer->Set((UCHAR*)pszDescription, strlen(pszDescription)+1);    }    m_pValues->SetPropertyCString(PLUGIN_DESCRIPTION2, pBuffer);    pBuffer->Release();    m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);    if (pszCopyright)    {	pBuffer->Set((UCHAR*)pszCopyright, strlen(pszCopyright)+1);    }    m_pValues->SetPropertyCString(PLUGIN_COPYRIGHT2, pBuffer);    pBuffer->Release();    m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);    if (pszMoreInfoUrl)    {	pBuffer->Set((UCHAR*)pszMoreInfoUrl, strlen(pszMoreInfoUrl)+1);    }    m_pValues->SetPropertyCString(PLUGIN_COPYRIGHT, pBuffer);    pBuffer->Release();    m_pValues->SetPropertyULONG32(PLUGIN_LOADMULTIPLE, nload_multiple);    m_pValues->SetPropertyULONG32(PLUGIN_VERSION, ulVersionNumber);    return HXR_OK;#endif}HX_RESULTHXPlugin::GetExtendedValues(IHXPlugin* pHXPlugin){    IHXFileFormatObject*		pFileFormat	    = NULL;    IHXFileWriter*			pFileWriter	    = NULL;    IHXFileSystemObject*		pFileSystem	    = NULL;    IHXRenderer*			pRenderer	    = NULL;    IHXDataRevert*			pDataRevert	    = NULL;    IHXStreamDescription*		pStreamDescription  = NULL;    IHXCommonClassFactory*		pClassFactory       = NULL;    IHXPluginProperties*		pIHXPluginPropertiesThis = NULL;    UINT32				nCountInterfaces    = 0;    DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues():\n"));    // file system    if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXFileSystemObject, (void**) &pFileSystem))    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): file system object...\n"));	const char* pszShortName;	const char* pszProtocol;	if (HXR_OK != pFileSystem->GetFileSystemInfo(pszShortName, pszProtocol))	{	    HX_RELEASE (pFileSystem);	    return  HXR_FAIL;	}	SetPluginProperty(PLUGIN_FILESYSTEM_TYPE);	IHXBuffer* pBuffer = NULL;	m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);	if (pszShortName)	{	    pBuffer->Set((UCHAR*)pszShortName, strlen(pszShortName)+1);	}	m_pValues->SetPropertyCString(PLUGIN_FILESYSTEMSHORT, pBuffer);	pBuffer->Release();	m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);	if (pszProtocol)	{	    pBuffer->Set((UCHAR*)pszProtocol, strlen(pszProtocol)+1);	}	m_pValues->SetPropertyCString(PLUGIN_FILESYSTEMPROTOCOL, pBuffer);	pBuffer->Release();	pFileSystem->Release();	nCountInterfaces++;        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): fs proto = '%s'\n", pszProtocol));    }    // file format    if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXFileFormatObject, (void**)&pFileFormat) ||	HXR_OK == pHXPlugin->QueryInterface(IID_IHXMetaFileFormatObject, (void**)&pFileFormat) ||	HXR_OK == pHXPlugin->QueryInterface(IID_IHXFileWriter, (void**)&pFileWriter))    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): file format...\n"));	// fine we are in now we will get the correct type.	if (pFileFormat)	{	    pFileFormat->Release();	}	else	{	    pFileWriter->Release();	}	IHXMetaFileFormatObject* pMetaFileFormat;	const char**		ppszMimeTypes = NULL;	const char**		ppszExtensions = NULL;	const char**		ppszOpenNames = NULL;	if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXFileFormatObject, (void**)&pFileFormat))	{	    pFileFormat->GetFileFormatInfo( ppszMimeTypes,					    ppszExtensions,					    ppszOpenNames);	    pFileFormat->Release();	    SetPluginProperty(PLUGIN_FILEFORMAT_TYPE);	}	if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXMetaFileFormatObject, (void**)&pMetaFileFormat))	{	    pMetaFileFormat->GetMetaFileFormatInfo( ppszMimeTypes,						    ppszExtensions,						    ppszOpenNames);	    pMetaFileFormat->Release();	    SetPluginProperty(PLUGIN_METAFILEFORMAT_TYPE);	}	if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXFileWriter, (void**)&pFileWriter))	{	    pFileWriter->GetFileFormatInfo( ppszMimeTypes,					    ppszExtensions,					    ppszOpenNames);	    pFileWriter->Release();	    SetPluginProperty(PLUGIN_FILEWRITER_TYPE);	}	IHXBuffer* pBuffer = NULL;	if (ppszMimeTypes)	{	    CatStrings((char**)ppszMimeTypes, pBuffer);	    //XXXAH this had better be const in reality!	    m_pValues->SetPropertyCString(PLUGIN_FILEMIMETYPES, pBuffer);	    pBuffer->Release();	}	if (ppszExtensions)	{	    CatStrings((char**)ppszExtensions, pBuffer);		//XXXAH this had better be const in reality!	    m_pValues->SetPropertyCString(PLUGIN_FILEEXTENSIONS, pBuffer);	    pBuffer->Release();	}	if (ppszOpenNames)	{	    CatStrings((char**)ppszOpenNames, pBuffer);		//XXXAH this had better be const in reality!	    m_pValues->SetPropertyCString(PLUGIN_FILEOPENNAMES, pBuffer);	    pBuffer->Release();	}	nCountInterfaces++;    }    // renderer    if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXRenderer, (void**)&pRenderer))    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): renderer...\n"));	char**	ppszMimeTypes;        UINT32	initial_granularity = 0;	// get the basic info	if (HXR_OK == pRenderer->GetRendererInfo((const char**&)ppszMimeTypes, initial_granularity))	{	    IHXBuffer* pBuffer;	    if (ppszMimeTypes)	    {		CatStrings(ppszMimeTypes, pBuffer);	    }	    m_pValues->SetPropertyCString(PLUGIN_RENDERER_MIME, pBuffer);	    pBuffer->Release();	    m_pValues->SetPropertyULONG32(PLUGIN_RENDERER_GRANULARITY, initial_granularity);	    SetPluginProperty(PLUGIN_RENDERER_TYPE);	}	HX_RELEASE(pRenderer);	nCountInterfaces++;    }    // stream description    if (HXR_OK == pHXPlugin->QueryInterface(IID_IHXStreamDescription, (void**)&pStreamDescription))    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): stream description...\n"));	const char* pszMimeType;	IHXBuffer* pBuffer;	if (HXR_OK != pStreamDescription->GetStreamDescriptionInfo(pszMimeType))	{	    HX_RELEASE (pStreamDescription);	    return HXR_FAIL;	}	pStreamDescription->Release();	m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pBuffer);	if (pszMimeType)	{	    pBuffer->Set((UCHAR*)pszMimeType, strlen(pszMimeType)+1);	}	m_pValues->SetPropertyCString(PLUGIN_STREAMDESCRIPTION, pBuffer);	pBuffer->Release();	SetPluginProperty(PLUGIN_STREAM_DESC_TYPE);	nCountInterfaces++;    }    // common class factory    if(HXR_OK == pHXPlugin->QueryInterface(IID_IHXCommonClassFactory,					(void**)&pClassFactory))    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): class factory plugin...\n"));	SetPluginProperty(PLUGIN_CLASS_FACTORY_TYPE);	HX_RELEASE (pClassFactory);	nCountInterfaces++;    }    if( SUCCEEDED( pHXPlugin->QueryInterface( IID_IHXPluginProperties, (void**)&pIHXPluginPropertiesThis ) ) )    {        DPRINTF(D_INFO, ("HXPlugin()::GetExtendedValues(): plugin properties interface...\n"));	IHXValues* pIHXValuesProperties = NULL;	pHXPlugin->InitPlugin(m_pContext);	if( SUCCEEDED( pIHXPluginPropertiesThis->GetProperties( pIHXValuesProperties ) ) && pIHXValuesProperties )	{	    CHXHeader::mergeHeaders( m_pValues, pIHXValuesProperties );	}	HX_RELEASE(pIHXValuesProperties);    }    HX_RELEASE(pIHXPluginPropertiesThis);    HX_ASSERT(nCountInterfaces<2);    return HXR_OK;}HX_RESULT HXPlugin::AddComponentInfo( IHXValues* pVal ){    CHXHeader::mergeHeaders(m_pValues, pVal);    return HXR_OK; // no way to know if above succeeded or not}HX_RESULT HXPlugin::CatStrings(char** pInStrings,				    IHXBuffer*& pOutBuffer){    ULONG32 nAllocedSpace   = 100;    char*   ptemp	    = new char[nAllocedSpace];    char*   ptemp2	    = NULL;    ULONG32 nStrLen	    = 0;    ULONG32 nNewStrLen	    = 0;    *ptemp	= 0;    pOutBuffer	= 0;    for(; *pInStrings; pInStrings++)    {	nNewStrLen = strlen(*pInStrings);	if (nNewStrLen+ nStrLen >= nAllocedSpace)	{	    // double if the new string is less than the new space	    // or add double what it required.	    if (nNewStrLen< nAllocedSpace)	    {		nAllocedSpace*=2;	    }	    else	    {		nAllocedSpace+=nNewStrLen*2;	    }	    ptemp2 = new char[nAllocedSpace];	    memcpy(ptemp2, ptemp, nStrLen+1); /* Flawfinder: ignore */	    delete [] ptemp;	    ptemp = ptemp2;	}	// XXXAH I must trim the strings before I add them to this string.	// the find function DEPENDS UPON THIS.	SafeStrCat(ptemp,  *pInStrings, nAllocedSpace);	if (*(pInStrings+1))	{	    SafeStrCat(ptemp,  k_pszValueSeperator, nAllocedSpace);	// XXXAH Perhaps a define?	}	nStrLen+=nNewStrLen+1;    }    m_pClassFactory->CreateInstance(CLSID_IHXBuffer,(void**)&pOutBuffer);    pOutBuffer->Set((UCHAR*)ptemp, strlen(ptemp)+1);    delete[] ptemp;    return HXR_OK;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -