d3d8: Backport texture tests.
[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 "config.h"
25 #include "wine/debug.h"
26
27 #define COBJMACROS
28
29 #include "winbase.h"
30 #include "wingdi.h"
31
32 #include "amstream_private.h"
33 #include "amstream.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(amstream);
36
37 typedef struct {
38     IMediaStream lpVtbl;
39     LONG ref;
40     IMultiMediaStream* Parent;
41     MSPID PurposeId;
42     STREAM_TYPE StreamType;
43 } IMediaStreamImpl;
44
45 static struct IMediaStreamVtbl MediaStream_Vtbl;
46
47 HRESULT MediaStream_create(IMultiMediaStream* Parent, const MSPID* pPurposeId, STREAM_TYPE StreamType, IMediaStream** ppMediaStream)
48 {
49     IMediaStreamImpl* object; 
50
51     TRACE("(%p,%p,%p)\n", Parent, pPurposeId, ppMediaStream);
52
53     object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMediaStreamImpl));
54     
55     object->lpVtbl.lpVtbl = &MediaStream_Vtbl;
56     object->ref = 1;
57
58     object->Parent = Parent;
59     object->PurposeId = *pPurposeId;
60     object->StreamType = StreamType;
61
62     *ppMediaStream = (IMediaStream*)object;
63     
64     return S_OK;
65 }
66
67 /*** IUnknown methods ***/
68 static HRESULT WINAPI IMediaStreamImpl_QueryInterface(IMediaStream* iface, REFIID riid, void** ppvObject)
69 {
70     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
71
72     TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
73
74     if (IsEqualGUID(riid, &IID_IUnknown) ||
75         IsEqualGUID(riid, &IID_IAMMultiMediaStream))
76     {
77       IClassFactory_AddRef(iface);
78       *ppvObject = This;
79       return S_OK;
80     }
81
82     ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
83     return E_NOINTERFACE;
84 }
85
86 static ULONG WINAPI IMediaStreamImpl_AddRef(IMediaStream* iface)
87 {
88     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
89
90     TRACE("(%p/%p)\n", iface, This);
91
92     return InterlockedIncrement(&This->ref);
93 }
94
95 static ULONG WINAPI IMediaStreamImpl_Release(IMediaStream* iface)
96 {
97     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
98     ULONG ref = InterlockedDecrement(&This->ref);
99
100     TRACE("(%p/%p)\n", iface, This);
101
102     if (!ref)
103       HeapFree(GetProcessHeap(), 0, This);
104
105     return ref;
106 }
107
108 /*** IMediaStream methods ***/
109 static HRESULT WINAPI IMediaStreamImpl_GetMultiMediaStream(IMediaStream* iface, IMultiMediaStream** ppMultiMediaStream)
110 {
111     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
112
113     FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppMultiMediaStream); 
114
115     return S_FALSE;
116 }
117
118
119 static HRESULT WINAPI IMediaStreamImpl_GetInformation(IMediaStream* iface, MSPID* pPurposeId, STREAM_TYPE* pType)
120 {
121     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
122
123     TRACE("(%p/%p)->(%p,%p)\n", This, iface, pPurposeId, pType);
124
125     if (pPurposeId)
126         *pPurposeId = This->PurposeId;
127     if (pType)
128         *pType = This->StreamType;
129
130     return S_OK;
131 }
132
133 static HRESULT WINAPI IMediaStreamImpl_SetSameFormat(IMediaStream* iface, IMediaStream* pStreamThatHasDesiredFormat, DWORD dwFlags)
134 {
135     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
136
137     FIXME("(%p/%p)->(%p,%x) stub!\n", This, iface, pStreamThatHasDesiredFormat, dwFlags);
138
139     return S_FALSE;
140 }
141
142 static HRESULT WINAPI IMediaStreamImpl_AllocateSample(IMediaStream* iface, DWORD dwFlags, IStreamSample** ppSample)
143 {
144     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
145
146     FIXME("(%p/%p)->(%x,%p) stub!\n", This, iface, dwFlags, ppSample);
147
148     return S_FALSE;
149 }
150
151 static HRESULT WINAPI IMediaStreamImpl_CreateSharedSample(IMediaStream* iface, IStreamSample* pExistingSample, DWORD dwFlags, IStreamSample** ppSample)
152 {
153     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
154
155     FIXME("(%p/%p)->(%p,%x,%p) stub!\n", This, iface, pExistingSample, dwFlags, ppSample);
156
157     return S_FALSE;
158 }
159
160 static HRESULT WINAPI IMediaStreamImpl_SendEndOfStream(IMediaStream* iface, DWORD dwFlags)
161 {
162     IMediaStreamImpl *This = (IMediaStreamImpl *)iface;
163
164     FIXME("(%p/%p)->(%x) stub!\n", This, iface, dwFlags);
165
166     return S_FALSE;
167 }
168
169 static IMediaStreamVtbl MediaStream_Vtbl =
170 {
171     IMediaStreamImpl_QueryInterface,
172     IMediaStreamImpl_AddRef,
173     IMediaStreamImpl_Release,
174     IMediaStreamImpl_GetMultiMediaStream,
175     IMediaStreamImpl_GetInformation,
176     IMediaStreamImpl_SetSameFormat,
177     IMediaStreamImpl_AllocateSample,
178     IMediaStreamImpl_CreateSharedSample,
179     IMediaStreamImpl_SendEndOfStream
180 };