ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

main.c
Go to the documentation of this file.
00001 /*
00002  *     MultiMedia Streams Base Functions (AMSTREAM.DLL)
00003  *
00004  * Copyright 2004 Christian Costa
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #include <stdarg.h>
00022 #include <string.h>
00023 
00024 #define COBJMACROS
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "winuser.h"
00029 #include "winerror.h"
00030 
00031 #include "ole2.h"
00032 #include "rpcproxy.h"
00033 
00034 #include "amstream_private.h"
00035 #include "amstream.h"
00036 
00037 #include "wine/debug.h"
00038 
00039 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
00040 
00041 static HINSTANCE instance;
00042 static DWORD dll_ref = 0;
00043 
00044 /* For the moment, do nothing here. */
00045 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
00046 {
00047     switch(fdwReason) {
00048         case DLL_PROCESS_ATTACH:
00049             instance = hInstDLL;
00050             DisableThreadLibraryCalls(hInstDLL);
00051         break;
00052     case DLL_PROCESS_DETACH:
00053         break;
00054     }
00055     return TRUE;
00056 }
00057 
00058 /******************************************************************************
00059  * Multimedia Streams ClassFactory
00060  */
00061 typedef struct {
00062     IClassFactory ITF_IClassFactory;
00063 
00064     LONG ref;
00065     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00066 } IClassFactoryImpl;
00067 
00068 struct object_creation_info
00069 {
00070     const CLSID *clsid;
00071     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00072 };
00073 
00074 static const struct object_creation_info object_creation[] =
00075 {
00076     { &CLSID_AMMultiMediaStream, AM_create },
00077     { &CLSID_AMDirectDrawStream, AM_create },
00078     { &CLSID_MediaStreamFilter, MediaStreamFilter_create }
00079 };
00080 
00081 static HRESULT WINAPI
00082 AMCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
00083 {
00084     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00085 
00086     if (IsEqualGUID(riid, &IID_IUnknown)
00087     || IsEqualGUID(riid, &IID_IClassFactory))
00088     {
00089     IClassFactory_AddRef(iface);
00090     *ppobj = This;
00091     return S_OK;
00092     }
00093 
00094     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
00095     return E_NOINTERFACE;
00096 }
00097 
00098 static ULONG WINAPI AMCF_AddRef(LPCLASSFACTORY iface)
00099 {
00100     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00101     return InterlockedIncrement(&This->ref);
00102 }
00103 
00104 static ULONG WINAPI AMCF_Release(LPCLASSFACTORY iface)
00105 {
00106     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00107 
00108     ULONG ref = InterlockedDecrement(&This->ref);
00109 
00110     if (ref == 0)
00111     HeapFree(GetProcessHeap(), 0, This);
00112 
00113     return ref;
00114 }
00115 
00116 
00117 static HRESULT WINAPI AMCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
00118                       REFIID riid, LPVOID *ppobj)
00119 {
00120     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00121     HRESULT hres;
00122     LPUNKNOWN punk;
00123     
00124     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
00125 
00126     *ppobj = NULL;
00127     hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
00128     if (SUCCEEDED(hres)) {
00129         hres = IUnknown_QueryInterface(punk, riid, ppobj);
00130         IUnknown_Release(punk);
00131     }
00132     return hres;
00133 }
00134 
00135 static HRESULT WINAPI AMCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
00136 {
00137     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00138     FIXME("(%p)->(%d),stub!\n",This,dolock);
00139     return S_OK;
00140 }
00141 
00142 static const IClassFactoryVtbl DSCF_Vtbl =
00143 {
00144     AMCF_QueryInterface,
00145     AMCF_AddRef,
00146     AMCF_Release,
00147     AMCF_CreateInstance,
00148     AMCF_LockServer
00149 };
00150 
00151 /*******************************************************************************
00152  * DllGetClassObject [AMSTREAM.@]
00153  * Retrieves class object from a DLL object
00154  *
00155  * NOTES
00156  *    Docs say returns STDAPI
00157  *
00158  * PARAMS
00159  *    rclsid [I] CLSID for the class object
00160  *    riid   [I] Reference to identifier of interface for class object
00161  *    ppv    [O] Address of variable to receive interface pointer for riid
00162  *
00163  * RETURNS
00164  *    Success: S_OK
00165  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
00166  *             E_UNEXPECTED
00167  */
00168 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
00169 {
00170     unsigned int i;
00171     IClassFactoryImpl *factory;
00172     
00173     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
00174     
00175     if ( !IsEqualGUID( &IID_IClassFactory, riid )
00176      && ! IsEqualGUID( &IID_IUnknown, riid) )
00177     return E_NOINTERFACE;
00178 
00179     for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
00180     {
00181     if (IsEqualGUID(object_creation[i].clsid, rclsid))
00182         break;
00183     }
00184 
00185     if (i == sizeof(object_creation)/sizeof(object_creation[0]))
00186     {
00187     FIXME("%s: no class found.\n", debugstr_guid(rclsid));
00188     return CLASS_E_CLASSNOTAVAILABLE;
00189     }
00190 
00191     factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
00192     if (factory == NULL) return E_OUTOFMEMORY;
00193 
00194     factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
00195     factory->ref = 1;
00196 
00197     factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
00198 
00199     *ppv = &(factory->ITF_IClassFactory);
00200     return S_OK;
00201 }
00202 
00203 /***********************************************************************
00204  *              DllCanUnloadNow (AMSTREAM.@)
00205  */
00206 HRESULT WINAPI DllCanUnloadNow(void)
00207 {
00208     return dll_ref != 0 ? S_FALSE : S_OK;
00209 }
00210 
00211 /***********************************************************************
00212  *      DllRegisterServer (AMSTREAM.@)
00213  */
00214 HRESULT WINAPI DllRegisterServer(void)
00215 {
00216     return __wine_register_resources( instance );
00217 }
00218 
00219 /***********************************************************************
00220  *      DllUnregisterServer (AMSTREAM.@)
00221  */
00222 HRESULT WINAPI DllUnregisterServer(void)
00223 {
00224     return __wine_unregister_resources( instance );
00225 }

Generated on Sun May 27 2012 04:16:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.