gdiplus: Add some tests for pathiterator, fix leaks.
[wine] / dlls / amstream / mediastream.c
1 /*
2  * Implementation of IMediaStream Interface
3  *
4  * Copyright 2005 Christian Costa
5  *
6  * This file contains the (internal) driver registration functions,
7  * driver enumeration APIs and DirectDraw creation functions.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23
24 #include "wine/debug.h"
25
26 #define COBJMACROS
27
28 #include "winbase.h"
29 #include "wingdi.h"
30
31 #include "amstream_private.h"
32 #include "amstream.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
35
36 typedef struct {
37     IMediaStream lpVtbl;
38     LONG ref;
39     IMultiMediaStream* Parent;
40     MSPID PurposeId;
41     STREAM_TYPE StreamType;
42 } IMediaStreamImpl;
43
44 static const struct IMediaStreamVtbl MediaStream_Vtbl;
45
46 HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
47 {
48     IMediaStreamImpl* object; 
49
50     TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream);
51
52     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
53     
54     object->lpVtbl.lpVtbl = &MediaStream_Vtbl;
55     object->ref = 1;
56
57     object->Parent = Parent;
58     object->PurposeId = *pPurposeId;
59     object->StreamType = StreamType;
60
61     *ppMediaStream = (IMediaStream*)object;
62     
63     return S_OK;
64 }
65
66 /*** IUnknown methods ***/
67 static HRESULT WINAPI IMediaStreamImpl_QueryInterface(IMediaStream* iface, REFIID riid, void** ppvObject)
68 {
69     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
70
71     TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
72
73     if (IsEqualGUID(riid, &IID_IUnknown) ||
74         IsEqualGUID(riid, &IID_IAMMultiMediaStream))
75     {
76       IClassFactory_AddRef(iface);
77       *ppvObject = This;
78       return S_OK;
79     }
80
81     ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
82     return E_NOINTERFACE;
83 }
84
85 static ULONG WINAPI IMediaStreamImpl_AddRef(IMediaStream* iface)
86 {
87     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
88
89     TRACE("(%p/%p)\n", iface, This);
90
91     return InterlockedIncrement(&This->ref);
92 }
93
94 static ULONG WINAPI IMediaStreamImpl_Release(IMediaStream* iface)
95 {
96     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
97     ULONG ref = InterlockedDecrement(&This->ref);
98
99     TRACE("(%p/%p)\n", iface, This);
100
101     if (!ref)
102       HeapFree(GetProcessHeap(), 0, This);
103
104     return ref;
105 }
106
107 /*** IMediaStream methods ***/
108 static HRESULT WINAPI IMediaStreamImpl_GetMultiMediaStream(IMediaStream* iface, IMultiMediaStream** ppMultiMediaStream)
109 {
110     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
111
112     FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream); 
113
114     return S_FALSE;
115 }
116
117
118 static HRESULT WINAPI IMediaStreamImpl_GetInformation(IMediaStream* iface, MSPID* pPurposeId, STREAM_TYPE* pType)
119 {
120     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
121
122     TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
123
124     if (pPurposeId)
125         *pPurposeId = This->PurposeId;
126     if (pType)
127         *pType = This->StreamType;
128
129     return S_OK;
130 }
131
132 static HRESULT WINAPI IMediaStreamImpl_SetSameFormat(IMediaStream* iface, IMediaStream* pStreamThatHasDesiredFormat, DWORD dwFlags)
133 {
134     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
135
136     FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
137
138     return S_FALSE;
139 }
140
141 static HRESULT WINAPI IMediaStreamImpl_AllocateSample(IMediaStream* iface, DWORD dwFlags, IStreamSample** ppSample)
142 {
143     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
144
145     FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
146
147     return S_FALSE;
148 }
149
150 static HRESULT WINAPI IMediaStreamImpl_CreateSharedSample(IMediaStream* iface, IStreamSample* pExistingSample, DWORD dwFlags, IStreamSample** ppSample)
151 {
152     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
153
154     FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
155
156     return S_FALSE;
157 }
158
159 static HRESULT WINAPI IMediaStreamImpl_SendEndOfStream(IMediaStream* iface, DWORD dwFlags)
160 {
161     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
162
163     FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
164
165     return S_FALSE;
166 }
167
168 static const struct IMediaStreamVtbl MediaStream_Vtbl =
169 {
170     IMediaStreamImpl_QueryInterface,
171     IMediaStreamImpl_AddRef,
172     IMediaStreamImpl_Release,
173     IMediaStreamImpl_GetMultiMediaStream,
174     IMediaStreamImpl_GetInformation,
175     IMediaStreamImpl_SetSameFormat,
176     IMediaStreamImpl_AllocateSample,
177     IMediaStreamImpl_CreateSharedSample,
178     IMediaStreamImpl_SendEndOfStream
179 };