ntdll: Implement NtCreateDebugObject().
[wine.git] / dlls / mfreadwrite / writer.c
blob4131862665772d5a5f512418b03c5b3e1d6e9c39
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"
28 #include "wine/heap.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
32 struct sink_writer
34 IMFSinkWriter IMFSinkWriter_iface;
35 LONG refcount;
38 static struct sink_writer *impl_from_IMFSinkWriter(IMFSinkWriter *iface)
40 return CONTAINING_RECORD(iface, struct sink_writer, IMFSinkWriter_iface);
43 static HRESULT WINAPI sink_writer_QueryInterface(IMFSinkWriter *iface, REFIID riid, void **out)
45 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
47 if (IsEqualIID(riid, &IID_IMFSinkWriter) ||
48 IsEqualIID(riid, &IID_IUnknown))
50 *out = iface;
51 IMFSinkWriter_AddRef(iface);
52 return S_OK;
55 WARN("Unsupported %s.\n", debugstr_guid(riid));
56 *out = NULL;
57 return E_NOINTERFACE;
60 static ULONG WINAPI sink_writer_AddRef(IMFSinkWriter *iface)
62 struct sink_writer *writer = impl_from_IMFSinkWriter(iface);
63 ULONG refcount = InterlockedIncrement(&writer->refcount);
65 TRACE("%p, %u.\n", iface, refcount);
67 return refcount;
70 static ULONG WINAPI sink_writer_Release(IMFSinkWriter *iface)
72 struct sink_writer *writer = impl_from_IMFSinkWriter(iface);
73 ULONG refcount = InterlockedDecrement(&writer->refcount);
75 TRACE("%p, %u.\n", iface, refcount);
77 if (!refcount)
79 heap_free(writer);
82 return refcount;
85 static HRESULT WINAPI sink_writer_AddStream(IMFSinkWriter *iface, IMFMediaType *type, DWORD *index)
87 FIXME("%p, %p, %p.\n", iface, type, index);
89 return E_NOTIMPL;
92 static HRESULT WINAPI sink_writer_SetInputMediaType(IMFSinkWriter *iface, DWORD index, IMFMediaType *type,
93 IMFAttributes *parameters)
95 FIXME("%p, %u, %p, %p.\n", iface, index, type, parameters);
97 return E_NOTIMPL;
100 static HRESULT WINAPI sink_writer_BeginWriting(IMFSinkWriter *iface)
102 FIXME("%p.\n", iface);
104 return E_NOTIMPL;
107 static HRESULT WINAPI sink_writer_WriteSample(IMFSinkWriter *iface, DWORD index, IMFSample *sample)
109 FIXME("%p, %u, %p.\n", iface, index, sample);
111 return E_NOTIMPL;
114 static HRESULT WINAPI sink_writer_SendStreamTick(IMFSinkWriter *iface, DWORD index, LONGLONG timestamp)
116 FIXME("%p, %u, %s.\n", iface, index, wine_dbgstr_longlong(timestamp));
118 return E_NOTIMPL;
121 static HRESULT WINAPI sink_writer_PlaceMarker(IMFSinkWriter *iface, DWORD index, void *context)
123 FIXME("%p, %u, %p.\n", iface, index, context);
125 return E_NOTIMPL;
128 static HRESULT WINAPI sink_writer_NotifyEndOfSegment(IMFSinkWriter *iface, DWORD index)
130 FIXME("%p, %u.\n", iface, index);
132 return E_NOTIMPL;
135 static HRESULT WINAPI sink_writer_Flush(IMFSinkWriter *iface, DWORD index)
137 FIXME("%p, %u.\n", iface, index);
139 return E_NOTIMPL;
142 static HRESULT WINAPI sink_writer_Finalize(IMFSinkWriter *iface)
144 FIXME("%p.\n", iface);
146 return E_NOTIMPL;
149 static HRESULT WINAPI sink_writer_GetServiceForStream(IMFSinkWriter *iface, DWORD index, REFGUID service,
150 REFIID riid, void **object)
152 FIXME("%p, %u, %s, %s, %p.\n", iface, index, debugstr_guid(service), debugstr_guid(riid), object);
154 return E_NOTIMPL;
157 static HRESULT WINAPI sink_writer_GetStatistics(IMFSinkWriter *iface, DWORD index, MF_SINK_WRITER_STATISTICS *stats)
159 FIXME("%p, %u, %p.\n", iface, index, stats);
161 return E_NOTIMPL;
164 static const IMFSinkWriterVtbl sink_writer_vtbl =
166 sink_writer_QueryInterface,
167 sink_writer_AddRef,
168 sink_writer_Release,
169 sink_writer_AddStream,
170 sink_writer_SetInputMediaType,
171 sink_writer_BeginWriting,
172 sink_writer_WriteSample,
173 sink_writer_SendStreamTick,
174 sink_writer_PlaceMarker,
175 sink_writer_NotifyEndOfSegment,
176 sink_writer_Flush,
177 sink_writer_Finalize,
178 sink_writer_GetServiceForStream,
179 sink_writer_GetStatistics,
182 HRESULT create_sink_writer_from_sink(IMFMediaSink *sink, IMFAttributes *attributes,
183 REFIID riid, void **out)
185 struct sink_writer *object;
186 HRESULT hr;
188 object = heap_alloc(sizeof(*object));
189 if (!object)
190 return E_OUTOFMEMORY;
192 object->IMFSinkWriter_iface.lpVtbl = &sink_writer_vtbl;
193 object->refcount = 1;
195 hr = IMFSinkWriter_QueryInterface(&object->IMFSinkWriter_iface, riid, out);
196 IMFSinkWriter_Release(&object->IMFSinkWriter_iface);
197 return hr;
200 HRESULT create_sink_writer_from_stream(IMFByteStream *stream, IMFAttributes *attributes,
201 REFIID riid, void **out)
203 struct sink_writer *object;
204 HRESULT hr;
206 object = heap_alloc(sizeof(*object));
207 if (!object)
208 return E_OUTOFMEMORY;
210 object->IMFSinkWriter_iface.lpVtbl = &sink_writer_vtbl;
211 object->refcount = 1;
213 hr = IMFSinkWriter_QueryInterface(&object->IMFSinkWriter_iface, riid, out);
214 IMFSinkWriter_Release(&object->IMFSinkWriter_iface);
215 return hr;
218 /***********************************************************************
219 * MFCreateSinkWriterFromMediaSink (mfreadwrite.@)
221 HRESULT WINAPI MFCreateSinkWriterFromMediaSink(IMFMediaSink *sink, IMFAttributes *attributes, IMFSinkWriter **writer)
223 TRACE("%p, %p, %p.\n", sink, attributes, writer);
225 return create_sink_writer_from_sink(sink, attributes, &IID_IMFSinkWriter, (void **)writer);
228 /***********************************************************************
229 * MFCreateSinkWriterFromURL (mfreadwrite.@)
231 HRESULT WINAPI MFCreateSinkWriterFromURL(const WCHAR *url, IMFByteStream *bytestream, IMFAttributes *attributes,
232 IMFSinkWriter **writer)
234 FIXME("%s, %p, %p, %p.\n", debugstr_w(url), bytestream, attributes, writer);
236 return E_NOTIMPL;