ReactOS 0.4.17-dev-966-gf06eace
main.c
Go to the documentation of this file.
1/*
2 * MultiMedia Streams Base Functions (AMSTREAM.DLL)
3 *
4 * Copyright 2004 Christian Costa
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22#include <string.h>
23
24#define COBJMACROS
25
26#include "windef.h"
27#include "winbase.h"
28#include "winuser.h"
29#include "winerror.h"
30
31#include "ole2.h"
32#include "rpcproxy.h"
33
34#include "amstream_private.h"
35
36#include "wine/debug.h"
37
39
40/******************************************************************************
41 * Multimedia Streams ClassFactory
42 */
43typedef struct {
45 LONG ref;
46 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
48
50{
51 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
52}
53
55{
56 const CLSID *clsid;
57 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
58};
59
61{
62 { &CLSID_AMMultiMediaStream, multimedia_stream_create },
63 { &CLSID_AMDirectDrawStream, ddraw_stream_create },
64 { &CLSID_AMAudioStream, audio_stream_create },
65 { &CLSID_AMAudioData, AMAudioData_create },
66 { &CLSID_MediaStreamFilter, filter_create }
67};
68
70{
73 {
74 IClassFactory_AddRef(iface);
75 *ppobj = iface;
76 return S_OK;
77 }
78
79 *ppobj = NULL;
80 WARN("(%p)->(%s,%p), not found\n", iface, debugstr_guid(riid), ppobj);
81 return E_NOINTERFACE;
82}
83
85{
87 return InterlockedIncrement(&This->ref);
88}
89
91{
94
95 if (ref == 0)
96 free(This);
97
98 return ref;
99}
100
101
103 REFIID riid, void **ppobj)
104{
107 IUnknown *punk;
108
109 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
110
111 *ppobj = NULL;
112 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
113 if (SUCCEEDED(hres)) {
114 hres = IUnknown_QueryInterface(punk, riid, ppobj);
115 IUnknown_Release(punk);
116 }
117 return hres;
118}
119
121{
123 FIXME("(%p)->(%d),stub!\n",This,dolock);
124 return S_OK;
125}
126
127static const IClassFactoryVtbl DSCF_Vtbl =
128{
134};
135
136/*******************************************************************************
137 * DllGetClassObject [AMSTREAM.@]
138 * Retrieves class object from a DLL object
139 *
140 * NOTES
141 * Docs say returns STDAPI
142 *
143 * PARAMS
144 * rclsid [I] CLSID for the class object
145 * riid [I] Reference to identifier of interface for class object
146 * ppv [O] Address of variable to receive interface pointer for riid
147 *
148 * RETURNS
149 * Success: S_OK
150 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
151 * E_UNEXPECTED
152 */
154{
155 unsigned int i;
157
158 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
159
161 && ! IsEqualGUID( &IID_IUnknown, riid) )
162 return E_NOINTERFACE;
163
164 for (i = 0; i < ARRAY_SIZE(object_creation); i++)
165 {
166 if (IsEqualGUID(object_creation[i].clsid, rclsid))
167 break;
168 }
169
171 {
172 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
174 }
175
176 if (!(factory = calloc(1, sizeof(*factory))))
177 return E_OUTOFMEMORY;
178
180 factory->ref = 1;
181
182 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
183
185 return S_OK;
186}
HRESULT audio_stream_create(IUnknown *outer, void **out)
Definition: audiostream.c:1389
HRESULT multimedia_stream_create(IUnknown *outer, void **out)
Definition: multimedia.c:557
HRESULT filter_create(IUnknown *outer, void **out)
Definition: filter.c:1088
HRESULT ddraw_stream_create(IUnknown *outer, void **out)
Definition: ddrawstream.c:1473
HRESULT AMAudioData_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: audiodata.c:219
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
static HRESULT WINAPI AMCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: main.c:102
static HRESULT WINAPI AMCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: main.c:69
static const struct object_creation_info object_creation[]
Definition: main.c:60
static HRESULT WINAPI AMCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: main.c:120
static ULONG WINAPI AMCF_Release(IClassFactory *iface)
Definition: main.c:90
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: main.c:153
static const IClassFactoryVtbl DSCF_Vtbl
Definition: main.c:127
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: main.c:49
static ULONG WINAPI AMCF_AddRef(IClassFactory *iface)
Definition: main.c:84
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
HRESULT hres
Definition: protocol.c:432
const CLSID * clsid
Definition: msctf.cpp:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
#define calloc
Definition: rosglue.h:14
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: main.c:44
Definition: main.c:439
IClassFactory IClassFactory_iface
Definition: main.c:440
const CLSID * clsid
Definition: main.c:56
HRESULT(* pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: main.c:57
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772