| 1 | /*
|
|---|
| 2 | * Copyright 2001 Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #include <string.h>
|
|---|
| 6 | #include <stdio.h>
|
|---|
| 7 | #include <assert.h>
|
|---|
| 8 |
|
|---|
| 9 | #include "winbase.h"
|
|---|
| 10 | #include "winnls.h"
|
|---|
| 11 | #include "mmsystem.h"
|
|---|
| 12 | #include "winerror.h"
|
|---|
| 13 | #include "ole2.h"
|
|---|
| 14 | #include "vfw.h"
|
|---|
| 15 | #include "debugtools.h"
|
|---|
| 16 | #include "avifile_private.h"
|
|---|
| 17 |
|
|---|
| 18 | DEFAULT_DEBUG_CHANNEL(avifile);
|
|---|
| 19 |
|
|---|
| 20 | static HRESULT WINAPI
|
|---|
| 21 | IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj);
|
|---|
| 22 | static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface);
|
|---|
| 23 | static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface);
|
|---|
| 24 | static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj);
|
|---|
| 25 | static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock);
|
|---|
| 26 |
|
|---|
| 27 | static ICOM_VTABLE(IClassFactory) iclassfact =
|
|---|
| 28 | {
|
|---|
| 29 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 30 | IClassFactory_fnQueryInterface,
|
|---|
| 31 | IClassFactory_fnAddRef,
|
|---|
| 32 | IClassFactory_fnRelease,
|
|---|
| 33 | IClassFactory_fnCreateInstance,
|
|---|
| 34 | IClassFactory_fnLockServer
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | typedef struct
|
|---|
| 38 | {
|
|---|
| 39 | /* IUnknown fields */
|
|---|
| 40 | ICOM_VFIELD(IClassFactory);
|
|---|
| 41 | DWORD ref;
|
|---|
| 42 | } IClassFactoryImpl;
|
|---|
| 43 |
|
|---|
| 44 | static IClassFactoryImpl AVIFILE_GlobalCF = {&iclassfact, 0 };
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 | static HRESULT WINAPI
|
|---|
| 49 | IClassFactory_fnQueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
|---|
| 50 | {
|
|---|
| 51 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 52 |
|
|---|
| 53 | TRACE("(%p)->(%p,%p)\n",This,riid,ppobj);
|
|---|
| 54 | if ( ( IsEqualGUID( &IID_IUnknown, riid ) ) ||
|
|---|
| 55 | ( IsEqualGUID( &IID_IClassFactory, riid ) ) )
|
|---|
| 56 | {
|
|---|
| 57 | *ppobj = iface;
|
|---|
| 58 | IClassFactory_AddRef(iface);
|
|---|
| 59 | return S_OK;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | return E_NOINTERFACE;
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | static ULONG WINAPI IClassFactory_fnAddRef(LPCLASSFACTORY iface)
|
|---|
| 66 | {
|
|---|
| 67 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 68 |
|
|---|
| 69 | TRACE("(%p)->()\n",This);
|
|---|
| 70 | if ( (This->ref) == 0 )
|
|---|
| 71 | AVIFILE_data.dwClassObjRef ++;
|
|---|
| 72 |
|
|---|
| 73 | return ++(This->ref);
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | static ULONG WINAPI IClassFactory_fnRelease(LPCLASSFACTORY iface)
|
|---|
| 77 | {
|
|---|
| 78 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 79 |
|
|---|
| 80 | TRACE("(%p)->()\n",This);
|
|---|
| 81 | if ( (--(This->ref)) > 0 )
|
|---|
| 82 | return This->ref;
|
|---|
| 83 |
|
|---|
| 84 | AVIFILE_data.dwClassObjRef --;
|
|---|
| 85 | return 0;
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj)
|
|---|
| 89 | {
|
|---|
| 90 | /*ICOM_THIS(IClassFactoryImpl,iface);*/
|
|---|
| 91 |
|
|---|
| 92 | *ppobj = NULL;
|
|---|
| 93 | if ( pOuter != NULL )
|
|---|
| 94 | return E_FAIL;
|
|---|
| 95 |
|
|---|
| 96 | if ( IsEqualGUID( &IID_IAVIFile, riid ) )
|
|---|
| 97 | return AVIFILE_CreateIAVIFile(ppobj);
|
|---|
| 98 | if ( IsEqualGUID( &IID_IAVIStream, riid ) )
|
|---|
| 99 | return AVIFILE_CreateIAVIStream(ppobj);
|
|---|
| 100 |
|
|---|
| 101 | return E_NOINTERFACE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | static HRESULT WINAPI IClassFactory_fnLockServer(LPCLASSFACTORY iface,BOOL dolock)
|
|---|
| 105 | {
|
|---|
| 106 | ICOM_THIS(IClassFactoryImpl,iface);
|
|---|
| 107 | HRESULT hr;
|
|---|
| 108 |
|
|---|
| 109 | FIXME("(%p)->(%d),stub!\n",This,dolock);
|
|---|
| 110 | if (dolock)
|
|---|
| 111 | hr = IClassFactory_AddRef(iface);
|
|---|
| 112 | else
|
|---|
| 113 | hr = IClassFactory_Release(iface);
|
|---|
| 114 |
|
|---|
| 115 | return hr;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | /***********************************************************************
|
|---|
| 120 | * DllGetClassObject (AVIFIL32.@)
|
|---|
| 121 | */
|
|---|
| 122 | HRESULT WINAPI AVIFILE_DllGetClassObject(const CLSID* pclsid,const IID* piid,void** ppv)
|
|---|
| 123 | {
|
|---|
| 124 | *ppv = NULL;
|
|---|
| 125 | if ( IsEqualCLSID( &IID_IClassFactory, piid ) )
|
|---|
| 126 | {
|
|---|
| 127 | *ppv = (LPVOID)&AVIFILE_GlobalCF;
|
|---|
| 128 | IClassFactory_AddRef((IClassFactory*)*ppv);
|
|---|
| 129 | return S_OK;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | return CLASS_E_CLASSNOTAVAILABLE;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /*****************************************************************************
|
|---|
| 136 | * DllCanUnloadNow (AVIFIL32.@)
|
|---|
| 137 | */
|
|---|
| 138 | DWORD WINAPI AVIFILE_DllCanUnloadNow(void)
|
|---|
| 139 | {
|
|---|
| 140 | return ( AVIFILE_data.dwClassObjRef == 0 ) ? S_OK : S_FALSE;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|