vidplin.cpp
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:8k
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: RCSL 1.0/RPSL 1.0
- *
- * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
- *
- * The contents of this file, and the files included with this file, are
- * subject to the current version of the RealNetworks Public Source License
- * Version 1.0 (the "RPSL") available at
- * http://www.helixcommunity.org/content/rpsl unless you have licensed
- * the file under the RealNetworks Community Source License Version 1.0
- * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
- * in which case the RCSL will apply. You may also obtain the license terms
- * directly from RealNetworks. You may not use this file except in
- * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
- * applicable to this file, the RCSL. Please see the applicable RPSL or
- * RCSL for the rights, obligations and limitations governing use of the
- * contents of the file.
- *
- * This file is part of the Helix DNA Technology. RealNetworks is the
- * developer of the Original Code and owns the copyrights in the portions
- * it created.
- *
- * This file, and the files included with this file, is distributed and made
- * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
- * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- *
- * Technology Compatibility Kit Test Suite(s) Location:
- * http://www.helixcommunity.org/content/tck
- *
- * Contributor(s):
- *
- * ***** END LICENSE BLOCK ***** */
- #if defined _UNIX
- int some_friggin_ctor_dtor_ism_vidplin_cpp_smp_aak_pm_don_pg_jp = 0;
- #endif
- #include "hxtypes.h"
- #include "hxcom.h"
- #ifdef HELIX_FEATURE_VIDEO_REAL
- #include "rvxvideo.h"
- #endif // HELIX_FEATURE_VIDEO_REAL
- #ifdef HELIX_FEATURE_VIDEO_MPEG4
- #include "mp4video.h"
- #endif // HELIX_FEATURE_VIDEO_MPEG4
- #ifdef HELIX_FEATURE_VIDEO_H263
- #include "h263video.h"
- #endif // HELIX_FEATURE_VIDEO_H263
- #include "vidplin.h"
- HX_RESULT (STDAPICALLTYPE* const VideoPluginFactory::m_fpEntryArray[])(IUnknown**)={
- #ifdef HELIX_FEATURE_VIDEO_REAL
- CRVXVideoRenderer::HXCreateInstance,
- #endif // HELIX_FEATURE_VIDEO_REAL
- #ifdef HELIX_FEATURE_VIDEO_MPEG4
- CMP4VideoRenderer::HXCreateInstance,
- #endif // HELIX_FEATURE_VIDEO_MPEG4
- #ifdef HELIX_FEATURE_VIDEO_H263
- CH263VideoRenderer::HXCreateInstance,
- #endif // HELIX_FEATURE_VIDEO_H263
- 0};
- HX_RESULT (STDAPICALLTYPE* const VideoPluginFactory::m_fpExitArray[])()={0};
- HX_RESULT (STDAPICALLTYPE* const VideoPluginFactory::m_fpUnloadArray[])()={
- #ifdef HELIX_FEATURE_VIDEO_REAL
- CRVXVideoRenderer::CanUnload,
- #endif // HELIX_FEATURE_VIDEO_REAL
- #ifdef HELIX_FEATURE_VIDEO_MPEG4
- CMP4VideoRenderer::CanUnload,
- #endif // HELIX_FEATURE_VIDEO_MPEG4
- #ifdef HELIX_FEATURE_VIDEO_H263
- CH263VideoRenderer::CanUnload,
- #endif // HELIX_FEATURE_VIDEO_H263
- 0};
- HX_RESULT (STDAPICALLTYPE* const VideoPluginFactory::m_fpUnloadArray2[])()={
- #ifdef HELIX_FEATURE_VIDEO_REAL
- CRVXVideoRenderer::CanUnload2,
- #endif // HELIX_FEATURE_VIDEO_REAL
- #ifdef HELIX_FEATURE_VIDEO_MPEG4
- CMP4VideoRenderer::CanUnload2,
- #endif // HELIX_FEATURE_VIDEO_MPEG4
- #ifdef HELIX_FEATURE_VIDEO_H263
- CH263VideoRenderer::CanUnload2,
- #endif // HELIX_FEATURE_VIDEO_H263
- 0};
- /****************************************************************************
- *
- * Function:
- *
- * HXCreateInstance()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's to create an instance of
- * any of the objects supported by the DLL. This method is similar to
- * Window's CoCreateInstance() in its purpose, except that it only
- * creates objects from this plugin DLL.
- *
- * NOTE: Aggregation is never used. Therefore and outer unknown is
- * not passed to this function, and you do not need to code for this
- * situation.
- *
- */
- STDAPI HXCreateInstance
- (
- IUnknown** /*OUT*/ ppIUnknown
- )
- {
- *ppIUnknown = (IUnknown*)(IHXPlugin*)new VideoPluginFactory();
- if (*ppIUnknown)
- {
- (*ppIUnknown)->AddRef();
- return HXR_OK;
- }
- return HXR_OUTOFMEMORY;
- }
- /****************************************************************************
- *
- * Function:
- *
- * HXShutdown()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's to free any *global*
- * resources. This method is called just before the DLL is unloaded.
- *
- */
- STDAPI HXShutdown()
- {
- HX_RESULT (STDAPICALLTYPE * const *itterator)(void) = &(VideoPluginFactory::m_fpExitArray[0]);
- while(*itterator)
- {
- (*itterator++)();
- }
- return HXR_OK;
- }
- /****************************************************************************
- *
- * Function:
- *
- * CanUnload()
- *
- * Purpose:
- *
- * Function implemented by all plugin DLL's if it returns HXR_OK
- * then the pluginhandler can unload the DLL
- *
- */
- STDAPI ENTRYPOINT(CanUnload2)(void)
- {
- for( int i=0; VideoPluginFactory::m_fpUnloadArray2[i]; i++ )
- {
- if( (VideoPluginFactory::m_fpUnloadArray2[i])() != HXR_OK )
- {
- return HXR_FAIL;
- }
- }
- return HXR_OK;
- }
- STDAPI ENTRYPOINT(CanUnload)(void)
- {
- return ENTRYPOINT(CanUnload2)();
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // VideoPluginFactory
- // Purpose:
- // Constructor. Counts the number of functions within the
- // Entry Array. Would have liked to use:
- // return (sizeof(m_fpEntryArray)/sizeof(m_fpEntryArray[0]))-1;
- // But for some strange reason the complier spits at it...
- //
- VideoPluginFactory::VideoPluginFactory()
- {
- m_lRefCount = 0;
- for(m_usNumOfPlugins = 0;
- m_fpEntryArray[m_usNumOfPlugins];
- m_usNumOfPlugins++) {};
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // IUnknown::QueryInterface
- // Purpose:
- // Implement this to export the interfaces supported by your
- // object.
- //
- STDMETHODIMP VideoPluginFactory::QueryInterface(REFIID riid, void** ppvObj)
- {
- if (IsEqualIID(riid, IID_IUnknown))
- {
- AddRef();
- *ppvObj = (IUnknown *)this;
- return HXR_OK;
- }
- else if (IsEqualIID(riid, IID_IHXPluginFactory))
- {
- AddRef();
- *ppvObj = (IHXPluginFactory *)this;
- return HXR_OK;
- }
- *ppvObj = NULL;
- return HXR_NOINTERFACE;
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // VideoPluginFactory::AddRef
- // Purpose:
- // Everyone usually implements this the same... feel free to use
- // this implementation.
- //
- STDMETHODIMP_(ULONG32) VideoPluginFactory::AddRef()
- {
- return InterlockedIncrement(&m_lRefCount);
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // VideoPluginFactory::Release
- // Purpose:
- // Everyone usually implements this the same... feel free to use
- // this implementation.
- //
- STDMETHODIMP_(ULONG32) VideoPluginFactory::Release()
- {
- if (InterlockedDecrement(&m_lRefCount) > 0)
- {
- return m_lRefCount;
- }
- delete this;
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // VideoPluginFactory::GetNumPlugins
- // Purpose:
- // Returns an int, the number of plugins in this DLL.
- //
- //
- STDMETHODIMP_(UINT16) VideoPluginFactory::GetNumPlugins()
- {
- return m_usNumOfPlugins;
- }
- /////////////////////////////////////////////////////////////////////////
- // Method:
- // VideoPluginFactory::GetPlugin
- // Purpose:
- // Returns an IUnknown Reference to the specified Interface
- //
- //
- STDMETHODIMP VideoPluginFactory::GetPlugin(UINT16 uindex, IUnknown** pPlugin)
- {
- if (uindex < m_usNumOfPlugins)
- {
- return m_fpEntryArray[uindex](pPlugin);
- }
- *pPlugin=0;
- return HXR_NOINTERFACE;
- }