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