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 /*              DirectShow Editing Services (qedit.dll)
00002  *
00003  * Copyright 2008 Google (Lei Zhang)
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include "qedit_private.h"
00021 #include "wine/debug.h"
00022 
00023 WINE_DEFAULT_DEBUG_CHANNEL(qedit);
00024 
00025 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
00026 {
00027     switch(fdwReason) {
00028         case DLL_PROCESS_ATTACH:
00029             DisableThreadLibraryCalls(hInstDLL);
00030             break;
00031         case DLL_PROCESS_DETACH:
00032             break;
00033     }
00034     return TRUE;
00035 }
00036 
00037 /******************************************************************************
00038  * DirectShow ClassFactory
00039  */
00040 typedef struct {
00041     IClassFactory ITF_IClassFactory;
00042 
00043     LONG ref;
00044     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00045 } IClassFactoryImpl;
00046 
00047 struct object_creation_info
00048 {
00049     const CLSID *clsid;
00050     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00051 };
00052 
00053 static const struct object_creation_info object_creation[] =
00054 {
00055     { &CLSID_MediaDet, MediaDet_create },
00056     { &CLSID_SampleGrabber, SampleGrabber_create },
00057 };
00058 
00059 static HRESULT WINAPI
00060 DSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
00061 {
00062     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00063 
00064     if (IsEqualGUID(riid, &IID_IUnknown)
00065         || IsEqualGUID(riid, &IID_IClassFactory))
00066     {
00067         IClassFactory_AddRef(iface);
00068         *ppobj = This;
00069         return S_OK;
00070     }
00071 
00072     *ppobj = NULL;
00073     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
00074     return E_NOINTERFACE;
00075 }
00076 
00077 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
00078 {
00079     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00080     return InterlockedIncrement(&This->ref);
00081 }
00082 
00083 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
00084 {
00085     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00086 
00087     ULONG ref = InterlockedDecrement(&This->ref);
00088 
00089     if (ref == 0)
00090         CoTaskMemFree(This);
00091 
00092     return ref;
00093 }
00094 
00095 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
00096 {
00097     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00098     HRESULT hres;
00099     LPUNKNOWN punk;
00100 
00101     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
00102 
00103     *ppobj = NULL;
00104     hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
00105     if (SUCCEEDED(hres)) {
00106         hres = IUnknown_QueryInterface(punk, riid, ppobj);
00107         IUnknown_Release(punk);
00108     }
00109     return hres;
00110 }
00111 
00112 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
00113 {
00114     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00115     FIXME("(%p)->(%d),stub!\n",This,dolock);
00116     return S_OK;
00117 }
00118 
00119 static const IClassFactoryVtbl DSCF_Vtbl =
00120 {
00121     DSCF_QueryInterface,
00122     DSCF_AddRef,
00123     DSCF_Release,
00124     DSCF_CreateInstance,
00125     DSCF_LockServer
00126 };
00127 
00128 
00129 /***********************************************************************
00130  *              DllCanUnloadNow (QEDIT.@)
00131  */
00132 HRESULT WINAPI DllCanUnloadNow(void)
00133 {
00134     return S_OK;
00135 }
00136 
00137 /*******************************************************************************
00138  * DllGetClassObject [QEDIT.@]
00139  * Retrieves class object from a DLL object
00140  *
00141  * PARAMS
00142  *    rclsid [I] CLSID for the class object
00143  *    riid   [I] Reference to identifier of interface for class object
00144  *    ppv    [O] Address of variable to receive interface pointer for riid
00145  *
00146  * RETURNS
00147  *    Success: S_OK
00148  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
00149  *             E_UNEXPECTED, E_NOINTERFACE
00150  */
00151 
00152 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
00153 {
00154     unsigned int i;
00155     IClassFactoryImpl *factory;
00156 
00157     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
00158 
00159     if ( !IsEqualGUID( &IID_IClassFactory, riid )
00160          && ! IsEqualGUID( &IID_IUnknown, riid) )
00161         return E_NOINTERFACE;
00162 
00163     for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
00164     {
00165         if (IsEqualGUID(object_creation[i].clsid, rclsid))
00166             break;
00167     }
00168 
00169     if (i == sizeof(object_creation)/sizeof(object_creation[0]))
00170     {
00171         FIXME("%s: no class found.\n", debugstr_guid(rclsid));
00172         return CLASS_E_CLASSNOTAVAILABLE;
00173     }
00174 
00175     factory = CoTaskMemAlloc(sizeof(*factory));
00176     if (factory == NULL) return E_OUTOFMEMORY;
00177 
00178     factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
00179     factory->ref = 1;
00180 
00181     factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
00182 
00183     *ppv = &(factory->ITF_IClassFactory);
00184     return S_OK;
00185 }

Generated on Sat May 26 2012 04:15:41 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.