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
20 #define NONAMELESSUNION
24 #include "mfreadwrite.h"
25 #include "mf_private.h"
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(mfplat
);
33 IMFSinkWriter IMFSinkWriter_iface
;
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
))
50 IMFSinkWriter_AddRef(iface
);
54 WARN("Unsupported %s.\n", debugstr_guid(riid
));
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
);
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
);
84 static HRESULT WINAPI
sink_writer_AddStream(IMFSinkWriter
*iface
, IMFMediaType
*type
, DWORD
*index
)
86 FIXME("%p, %p, %p.\n", iface
, type
, index
);
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
);
99 static HRESULT WINAPI
sink_writer_BeginWriting(IMFSinkWriter
*iface
)
101 FIXME("%p.\n", iface
);
106 static HRESULT WINAPI
sink_writer_WriteSample(IMFSinkWriter
*iface
, DWORD index
, IMFSample
*sample
)
108 FIXME("%p, %u, %p.\n", iface
, index
, sample
);
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
));
120 static HRESULT WINAPI
sink_writer_PlaceMarker(IMFSinkWriter
*iface
, DWORD index
, void *context
)
122 FIXME("%p, %u, %p.\n", iface
, index
, context
);
127 static HRESULT WINAPI
sink_writer_NotifyEndOfSegment(IMFSinkWriter
*iface
, DWORD index
)
129 FIXME("%p, %u.\n", iface
, index
);
134 static HRESULT WINAPI
sink_writer_Flush(IMFSinkWriter
*iface
, DWORD index
)
136 FIXME("%p, %u.\n", iface
, index
);
141 static HRESULT WINAPI
sink_writer_Finalize(IMFSinkWriter
*iface
)
143 FIXME("%p.\n", iface
);
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
);
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
);
163 static const IMFSinkWriterVtbl sink_writer_vtbl
=
165 sink_writer_QueryInterface
,
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
,
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
;
187 object
= malloc(sizeof(*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
);
199 HRESULT
create_sink_writer_from_stream(IMFByteStream
*stream
, IMFAttributes
*attributes
,
200 REFIID riid
, void **out
)
202 struct sink_writer
*object
;
205 object
= malloc(sizeof(*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
);
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
);