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"
28 #include "wine/heap.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(mfplat
);
34 IMFSinkWriter IMFSinkWriter_iface
;
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
))
51 IMFSinkWriter_AddRef(iface
);
55 WARN("Unsupported %s.\n", debugstr_guid(riid
));
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
);
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
);
85 static HRESULT WINAPI
sink_writer_AddStream(IMFSinkWriter
*iface
, IMFMediaType
*type
, DWORD
*index
)
87 FIXME("%p, %p, %p.\n", iface
, type
, index
);
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
);
100 static HRESULT WINAPI
sink_writer_BeginWriting(IMFSinkWriter
*iface
)
102 FIXME("%p.\n", iface
);
107 static HRESULT WINAPI
sink_writer_WriteSample(IMFSinkWriter
*iface
, DWORD index
, IMFSample
*sample
)
109 FIXME("%p, %u, %p.\n", iface
, index
, sample
);
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
));
121 static HRESULT WINAPI
sink_writer_PlaceMarker(IMFSinkWriter
*iface
, DWORD index
, void *context
)
123 FIXME("%p, %u, %p.\n", iface
, index
, context
);
128 static HRESULT WINAPI
sink_writer_NotifyEndOfSegment(IMFSinkWriter
*iface
, DWORD index
)
130 FIXME("%p, %u.\n", iface
, index
);
135 static HRESULT WINAPI
sink_writer_Flush(IMFSinkWriter
*iface
, DWORD index
)
137 FIXME("%p, %u.\n", iface
, index
);
142 static HRESULT WINAPI
sink_writer_Finalize(IMFSinkWriter
*iface
)
144 FIXME("%p.\n", iface
);
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
);
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
);
164 static const IMFSinkWriterVtbl sink_writer_vtbl
=
166 sink_writer_QueryInterface
,
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
,
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
;
188 object
= heap_alloc(sizeof(*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
);
200 HRESULT
create_sink_writer_from_stream(IMFByteStream
*stream
, IMFAttributes
*attributes
,
201 REFIID riid
, void **out
)
203 struct sink_writer
*object
;
206 object
= heap_alloc(sizeof(*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
);
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
);