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 Base Functions (QUARTZ.DLL)
00002  *
00003  * Copyright 2002 Lionel Ulmer
00004  *
00005  * This file contains the (internal) driver registration functions,
00006  * driver enumeration APIs and DirectDraw creation functions.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00021  */
00022 
00023 #include "config.h"
00024 #include "wine/debug.h"
00025 
00026 #include "quartz_private.h"
00027 #include "wine/unicode.h"
00028 
00029 WINE_DEFAULT_DEBUG_CHANNEL(quartz);
00030 
00031 extern HRESULT WINAPI QUARTZ_DllGetClassObject(REFCLSID, REFIID, LPVOID *) DECLSPEC_HIDDEN;
00032 extern HRESULT WINAPI QUARTZ_DllCanUnloadNow(void) DECLSPEC_HIDDEN;
00033 extern BOOL WINAPI QUARTZ_DllMain(HINSTANCE, DWORD, LPVOID) DECLSPEC_HIDDEN;
00034 
00035 static DWORD dll_ref = 0;
00036 
00037 /* For the moment, do nothing here. */
00038 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
00039 {
00040     return QUARTZ_DllMain( hInstDLL, fdwReason, lpv );
00041 }
00042 
00043 /******************************************************************************
00044  * DirectShow ClassFactory
00045  */
00046 typedef struct {
00047     IClassFactory ITF_IClassFactory;
00048 
00049     LONG ref;
00050     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00051 } IClassFactoryImpl;
00052 
00053 struct object_creation_info
00054 {
00055     const CLSID *clsid;
00056     HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
00057 };
00058 
00059 static const struct object_creation_info object_creation[] =
00060 {
00061     { &CLSID_SeekingPassThru, SeekingPassThru_create },
00062     { &CLSID_FilterGraph, FilterGraph_create },
00063     { &CLSID_FilterGraphNoThread, FilterGraphNoThread_create },
00064     { &CLSID_FilterMapper, FilterMapper_create },
00065     { &CLSID_FilterMapper2, FilterMapper2_create },
00066     { &CLSID_AsyncReader, AsyncReader_create },
00067     { &CLSID_MemoryAllocator, StdMemAllocator_create },
00068     { &CLSID_AviSplitter, AVISplitter_create },
00069     { &CLSID_MPEG1Splitter, MPEGSplitter_create },
00070     { &CLSID_VideoRenderer, VideoRenderer_create },
00071     { &CLSID_NullRenderer, NullRenderer_create },
00072     { &CLSID_VideoRendererDefault, VideoRendererDefault_create },
00073     { &CLSID_DSoundRender, DSoundRender_create },
00074     { &CLSID_AudioRender, DSoundRender_create },
00075     { &CLSID_AVIDec, AVIDec_create },
00076     { &CLSID_SystemClock, QUARTZ_CreateSystemClock },
00077     { &CLSID_ACMWrapper, ACMWrapper_create },
00078     { &CLSID_WAVEParser, WAVEParser_create }
00079 };
00080 
00081 static HRESULT WINAPI
00082 DSCF_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     *ppobj = NULL;
00095     WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
00096     return E_NOINTERFACE;
00097 }
00098 
00099 static ULONG WINAPI DSCF_AddRef(LPCLASSFACTORY iface)
00100 {
00101     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00102     return InterlockedIncrement(&This->ref);
00103 }
00104 
00105 static ULONG WINAPI DSCF_Release(LPCLASSFACTORY iface)
00106 {
00107     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00108 
00109     ULONG ref = InterlockedDecrement(&This->ref);
00110 
00111     if (ref == 0)
00112     CoTaskMemFree(This);
00113 
00114     return ref;
00115 }
00116 
00117 
00118 static HRESULT WINAPI DSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
00119                       REFIID riid, LPVOID *ppobj)
00120 {
00121     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00122     HRESULT hres;
00123     LPUNKNOWN punk;
00124     
00125     TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
00126 
00127     *ppobj = NULL;
00128     hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
00129     if (SUCCEEDED(hres)) {
00130         hres = IUnknown_QueryInterface(punk, riid, ppobj);
00131         IUnknown_Release(punk);
00132     }
00133     return hres;
00134 }
00135 
00136 static HRESULT WINAPI DSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
00137 {
00138     IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
00139     FIXME("(%p)->(%d),stub!\n",This,dolock);
00140     return S_OK;
00141 }
00142 
00143 static const IClassFactoryVtbl DSCF_Vtbl =
00144 {
00145     DSCF_QueryInterface,
00146     DSCF_AddRef,
00147     DSCF_Release,
00148     DSCF_CreateInstance,
00149     DSCF_LockServer
00150 };
00151 
00152 /*******************************************************************************
00153  * DllGetClassObject [QUARTZ.@]
00154  * Retrieves class object from a DLL object
00155  *
00156  * NOTES
00157  *    Docs say returns STDAPI
00158  *
00159  * PARAMS
00160  *    rclsid [I] CLSID for the class object
00161  *    riid   [I] Reference to identifier of interface for class object
00162  *    ppv    [O] Address of variable to receive interface pointer for riid
00163  *
00164  * RETURNS
00165  *    Success: S_OK
00166  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
00167  *             E_UNEXPECTED
00168  */
00169 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
00170 {
00171     unsigned int i;
00172 
00173     TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
00174 
00175     if (IsEqualGUID( &IID_IClassFactory, riid ) || IsEqualGUID( &IID_IUnknown, riid))
00176     {
00177         for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
00178         {
00179             if (IsEqualGUID(object_creation[i].clsid, rclsid))
00180             {
00181                 IClassFactoryImpl *factory = CoTaskMemAlloc(sizeof(*factory));
00182                 if (factory == NULL) return E_OUTOFMEMORY;
00183 
00184                 factory->ITF_IClassFactory.lpVtbl = &DSCF_Vtbl;
00185                 factory->ref = 1;
00186 
00187                 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
00188 
00189                 *ppv = &factory->ITF_IClassFactory;
00190                 return S_OK;
00191             }
00192         }
00193     }
00194     return QUARTZ_DllGetClassObject( rclsid, riid, ppv );
00195 }
00196 
00197 /***********************************************************************
00198  *              DllCanUnloadNow (QUARTZ.@)
00199  */
00200 HRESULT WINAPI DllCanUnloadNow(void)
00201 {
00202     if (dll_ref) return S_FALSE;
00203     return QUARTZ_DllCanUnloadNow();
00204 }
00205 
00206 
00207 #define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
00208     { { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } } , #name },
00209 
00210 static const struct {
00211     const GUID  riid;
00212     const char  *name;
00213 } InterfaceDesc[] =
00214 {
00215 #include "uuids.h"
00216     { { 0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0} }, NULL }
00217 };
00218 
00219 /***********************************************************************
00220  *              proxies
00221  */
00222 HRESULT CALLBACK ICaptureGraphBuilder_FindInterface_Proxy( ICaptureGraphBuilder *This,
00223                                                            const GUID *pCategory,
00224                                                            IBaseFilter *pf,
00225                                                            REFIID riid,
00226                                                            void **ppint )
00227 {
00228     return ICaptureGraphBuilder_RemoteFindInterface_Proxy( This, pCategory, pf,
00229                                                            riid, (IUnknown **)ppint );
00230 }
00231 
00232 HRESULT __RPC_STUB ICaptureGraphBuilder_FindInterface_Stub( ICaptureGraphBuilder *This,
00233                                                             const GUID *pCategory,
00234                                                             IBaseFilter *pf,
00235                                                             REFIID riid,
00236                                                             IUnknown **ppint )
00237 {
00238     return ICaptureGraphBuilder_FindInterface( This, pCategory, pf, riid, (void **)ppint );
00239 }
00240 
00241 HRESULT CALLBACK ICaptureGraphBuilder2_FindInterface_Proxy( ICaptureGraphBuilder2 *This,
00242                                                             const GUID *pCategory,
00243                                                             const GUID *pType,
00244                                                             IBaseFilter *pf,
00245                                                             REFIID riid,
00246                                                             void **ppint )
00247 {
00248     return ICaptureGraphBuilder2_RemoteFindInterface_Proxy( This, pCategory, pType,
00249                                                             pf, riid, (IUnknown **)ppint );
00250 }
00251 
00252 HRESULT __RPC_STUB ICaptureGraphBuilder2_FindInterface_Stub( ICaptureGraphBuilder2 *This,
00253                                                              const GUID *pCategory,
00254                                                              const GUID *pType,
00255                                                              IBaseFilter *pf,
00256                                                              REFIID riid,
00257                                                              IUnknown **ppint )
00258 {
00259     return ICaptureGraphBuilder2_FindInterface( This, pCategory, pType, pf, riid, (void **)ppint );
00260 }
00261 
00262 /***********************************************************************
00263  *              qzdebugstr_guid (internal)
00264  *
00265  * Gives a text version of DirectShow GUIDs
00266  */
00267 const char * qzdebugstr_guid( const GUID * id )
00268 {
00269     int i;
00270     char * name = NULL;
00271 
00272     for (i=0;InterfaceDesc[i].name && !name;i++) {
00273         if (IsEqualGUID(&InterfaceDesc[i].riid, id)) return InterfaceDesc[i].name;
00274     }
00275     return debugstr_guid(id);
00276 }
00277 
00278 LONG WINAPI AmpFactorToDB(LONG ampfactor)
00279 {
00280     FIXME("(%d) Stub!\n", ampfactor);
00281     return 0;
00282 }
00283 
00284 LONG WINAPI DBToAmpFactor(LONG db)
00285 {
00286     FIXME("(%d) Stub!\n", db);
00287     /* Avoid divide by zero (probably during range computation) in Windows Media Player 6.4 */
00288     if (db < -1000)
00289     return 0;
00290     return 100;
00291 }
00292 
00293 /***********************************************************************
00294  *              AMGetErrorTextA (QUARTZ.@)
00295  */
00296 DWORD WINAPI AMGetErrorTextA(HRESULT hr, LPSTR buffer, DWORD maxlen)
00297 {
00298     unsigned int len;
00299     static const char format[] = "Error: 0x%x";
00300     char error[MAX_ERROR_TEXT_LEN];
00301 
00302     FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
00303 
00304     if (!buffer) return 0;
00305     wsprintfA(error, format, hr);
00306     if ((len = strlen(error)) >= maxlen) return 0;
00307     lstrcpyA(buffer, error);
00308     return len;
00309 }
00310 
00311 /***********************************************************************
00312  *              AMGetErrorTextW (QUARTZ.@)
00313  */
00314 DWORD WINAPI AMGetErrorTextW(HRESULT hr, LPWSTR buffer, DWORD maxlen)
00315 {
00316     unsigned int len;
00317     static const WCHAR format[] = {'E','r','r','o','r',':',' ','0','x','%','l','x',0};
00318     WCHAR error[MAX_ERROR_TEXT_LEN];
00319 
00320     FIXME("(%x,%p,%d) stub\n", hr, buffer, maxlen);
00321 
00322     if (!buffer) return 0;
00323     wsprintfW(error, format, hr);
00324     if ((len = strlenW(error)) >= maxlen) return 0;
00325     lstrcpyW(buffer, error);
00326     return len;
00327 }

Generated on Fri May 25 2012 04:15:02 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.