ws2_32/tests: Add some tests for opening the Afd device.
[wine.git] / dlls / mfreadwrite / writer.c
blob6807ee26fbec2b71ba6afa6dbad50edfe28c97f1
1 /*
2 * Copyright 2020 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define COBJMACROS
20 #define NONAMELESSUNION
22 #include "mfapi.h"
23 #include "mfidl.h"
24 #include "mfreadwrite.h"
25 #include "mf_private.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
31 struct sink_writer
33 IMFSinkWriter IMFSinkWriter_iface;
34 LONG refcount;
37 static struct sink_writer *impl_from_IMFSinkWriter(IMFSinkWriter *iface)
39 return CONTAINING_RECORD(iface, struct sink_writer, IMFSinkWriter_iface);
42 static HRESULT WINAPI sink_writer_QueryInterface(IMFSinkWriter *iface, REFIID riid, void **out)
44 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
46 if (IsEqualIID(riid, &IID_IMFSinkWriter) ||
47 IsEqualIID(riid, &IID_IUnknown))
49 *out = iface;
50 IMFSinkWriter_AddRef(iface);
51 return S_OK;
54 WARN("Unsupported %s.\n", debugstr_guid(riid));
55 *out = NULL;
56 return E_NOINTERFACE;
59 static ULONG WINAPI sink_writer_AddRef(IMFSinkWriter *iface)
61 struct sink_writer *writer = impl_from_IMFSinkWriter(iface);
62 ULONG refcount = InterlockedIncrement(&writer->refcount);
64 TRACE("%p, %u.\n", iface, refcount);
66 return refcount;
69 static ULONG WINAPI sink_writer_Release(IMFSinkWriter *iface)
71 struct sink_writer *writer = impl_from_IMFSinkWriter(iface);
72 ULONG refcount = InterlockedDecrement(&writer->refcount);
74 TRACE("%p, %u.\n", iface, refcount);
76 if (!refcount)
78 free(writer);
81 return refcount;
84 static HRESULT WINAPI sink_writer_AddStream(IMFSinkWriter *iface, IMFMediaType *type, DWORD *index)
86 FIXME("%p, %p, %p.\n", iface, type, index);
88 return E_NOTIMPL;
91 static HRESULT WINAPI sink_writer_SetInputMediaType(IMFSinkWriter *iface, DWORD index, IMFMediaType *type,
92 IMFAttributes *parameters)
94 FIXME("%p, %u, %p, %p.\n", iface, index, type, parameters);
96 return E_NOTIMPL;
99 static HRESULT WINAPI sink_writer_BeginWriting(IMFSinkWriter *iface)
101 FIXME("%p.\n", iface);
103 return E_NOTIMPL;
106 static HRESULT WINAPI sink_writer_WriteSample(IMFSinkWriter *iface, DWORD index, IMFSample *sample)
108 FIXME("%p, %u, %p.\n", iface, index, sample);
110 return E_NOTIMPL;
113 static HRESULT WINAPI sink_writer_SendStreamTick(IMFSinkWriter *iface, DWORD index, LONGLONG timestamp)
115 FIXME("%p, %u, %s.\n", iface, index, wine_dbgstr_longlong(timestamp));
117 return E_NOTIMPL;
120 static HRESULT WINAPI sink_writer_PlaceMarker(IMFSinkWriter *iface, DWORD index, void *context)
122 FIXME("%p, %u, %p.\n", iface, index, context);
124 return E_NOTIMPL;
127 static HRESULT WINAPI sink_writer_NotifyEndOfSegment(IMFSinkWriter *iface, DWORD index)
129 FIXME("%p, %u.\n", iface, index);
131 return E_NOTIMPL;
134 static HRESULT WINAPI sink_writer_Flush(IMFSinkWriter *iface, DWORD index)
136 FIXME("%p, %u.\n", iface, index);
138 return E_NOTIMPL;
141 static HRESULT WINAPI sink_writer_Finalize(IMFSinkWriter *iface)
143 FIXME("%p.\n", iface);
145 return E_NOTIMPL;
148 static HRESULT WINAPI sink_writer_GetServiceForStream(IMFSinkWriter *iface, DWORD index, REFGUID service,
149 REFIID riid, void **object)
151 FIXME("%p, %u, %s, %s, %p.\n", iface, index, debugstr_guid(service), debugstr_guid(riid), object);
153 return E_NOTIMPL;
156 static HRESULT WINAPI sink_writer_GetStatistics(IMFSinkWriter *iface, DWORD index, MF_SINK_WRITER_STATISTICS *stats)
158 FIXME("%p, %u, %p.\n", iface, index, stats);
160 return E_NOTIMPL;
163 static const IMFSinkWriterVtbl sink_writer_vtbl =
165 sink_writer_QueryInterface,
166 sink_writer_AddRef,
167 sink_writer_Release,
168 sink_writer_AddStream,
169 sink_writer_SetInputMediaType,
170 sink_writer_BeginWriting,
171 sink_writer_WriteSample,
172 sink_writer_SendStreamTick,
173 sink_writer_PlaceMarker,
174 sink_writer_NotifyEndOfSegment,
175 sink_writer_Flush,
176 sink_writer_Finalize,
177 sink_writer_GetServiceForStream,
178 sink_writer_GetStatistics,
181 HRESULT create_sink_writer_from_sink(IMFMediaSink *sink, IMFAttributes *attributes,
182 REFIID riid, void **out)
184 struct sink_writer *object;
185 HRESULT hr;
187 object = malloc(sizeof(*object));
188 if (!object)
189 return E_OUTOFMEMORY;
191 object->IMFSinkWriter_iface.lpVtbl = &sink_writer_vtbl;
192 object->refcount = 1;
194 hr = IMFSinkWriter_QueryInterface(&object->IMFSinkWriter_iface, riid, out);
195 IMFSinkWriter_Release(&object->IMFSinkWriter_iface);
196 return hr;
199 HRESULT create_sink_writer_from_stream(IMFByteStream *stream, IMFAttributes *attributes,
200 REFIID riid, void **out)
202 struct sink_writer *object;
203 HRESULT hr;
205 object = malloc(sizeof(*object));
206 if (!object)
207 return E_OUTOFMEMORY;
209 object->IMFSinkWriter_iface.lpVtbl = &sink_writer_vtbl;
210 object->refcount = 1;
212 hr = IMFSinkWriter_QueryInterface(&object->IMFSinkWriter_iface, riid, out);
213 IMFSinkWriter_Release(&object->IMFSinkWriter_iface);
214 return hr;
217 /***********************************************************************
218 * MFCreateSinkWriterFromMediaSink (mfreadwrite.@)
220 HRESULT WINAPI MFCreateSinkWriterFromMediaSink(IMFMediaSink *sink, IMFAttributes *attributes, IMFSinkWriter **writer)
222 TRACE("%p, %p, %p.\n", sink, attributes, writer);
224 return create_sink_writer_from_sink(sink, attributes, &IID_IMFSinkWriter, (void **)writer);
227 /***********************************************************************
228 * MFCreateSinkWriterFromURL (mfreadwrite.@)
230 HRESULT WINAPI MFCreateSinkWriterFromURL(const WCHAR *url, IMFByteStream *bytestream, IMFAttributes *attributes,
231 IMFSinkWriter **writer)
233 FIXME("%s, %p, %p, %p.\n", debugstr_w(url), bytestream, attributes, writer);
235 return E_NOTIMPL;