include: Move ddk/imm.h to immdev.h.
[wine.git] / dlls / mf / topology.c
blob25a007081000a3d07a49c6b984aa74d7a913a2e5
1 /*
2 * Copyright 2017 Nikolay Sivov
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 #include <stdarg.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
27 #undef INITGUID
28 #include <guiddef.h>
29 #include "mfidl.h"
31 #include "wine/debug.h"
33 #include "mf_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mfplat);
37 static LONG next_node_id;
38 static TOPOID next_topology_id;
40 struct node_stream
42 IMFMediaType *preferred_type;
43 struct topology_node *connection;
44 DWORD connection_stream;
47 struct node_streams
49 struct node_stream *streams;
50 size_t size;
51 size_t count;
54 struct topology_node
56 IMFTopologyNode IMFTopologyNode_iface;
57 LONG refcount;
58 IMFAttributes *attributes;
59 MF_TOPOLOGY_TYPE node_type;
60 TOPOID id;
61 IUnknown *object;
62 IMFMediaType *input_type; /* Only for tee nodes. */
63 struct node_streams inputs;
64 struct node_streams outputs;
65 CRITICAL_SECTION cs;
68 struct topology
70 IMFTopology IMFTopology_iface;
71 LONG refcount;
72 IMFAttributes *attributes;
73 struct
75 struct topology_node **nodes;
76 size_t size;
77 size_t count;
78 } nodes;
79 TOPOID id;
82 struct seq_source
84 IMFSequencerSource IMFSequencerSource_iface;
85 IMFMediaSourceTopologyProvider IMFMediaSourceTopologyProvider_iface;
86 LONG refcount;
89 static inline struct topology *impl_from_IMFTopology(IMFTopology *iface)
91 return CONTAINING_RECORD(iface, struct topology, IMFTopology_iface);
94 static struct topology_node *impl_from_IMFTopologyNode(IMFTopologyNode *iface)
96 return CONTAINING_RECORD(iface, struct topology_node, IMFTopologyNode_iface);
99 static const IMFTopologyNodeVtbl topologynodevtbl;
101 static struct topology_node *unsafe_impl_from_IMFTopologyNode(IMFTopologyNode *iface)
103 if (!iface || iface->lpVtbl != &topologynodevtbl)
104 return NULL;
105 return impl_from_IMFTopologyNode(iface);
108 static HRESULT create_topology_node(MF_TOPOLOGY_TYPE node_type, struct topology_node **node);
109 static HRESULT topology_node_connect_output(struct topology_node *node, DWORD output_index,
110 struct topology_node *connection, DWORD input_index);
112 static struct topology *unsafe_impl_from_IMFTopology(IMFTopology *iface);
114 static struct seq_source *impl_from_IMFSequencerSource(IMFSequencerSource *iface)
116 return CONTAINING_RECORD(iface, struct seq_source, IMFSequencerSource_iface);
119 static struct seq_source *impl_from_IMFMediaSourceTopologyProvider(IMFMediaSourceTopologyProvider *iface)
121 return CONTAINING_RECORD(iface, struct seq_source, IMFMediaSourceTopologyProvider_iface);
124 static HRESULT topology_node_reserve_streams(struct node_streams *streams, DWORD index)
126 if (!mf_array_reserve((void **)&streams->streams, &streams->size, index + 1, sizeof(*streams->streams)))
127 return E_OUTOFMEMORY;
129 if (index >= streams->count)
131 memset(&streams->streams[streams->count], 0, (index - streams->count + 1) * sizeof(*streams->streams));
132 streams->count = index + 1;
135 return S_OK;
138 static HRESULT WINAPI topology_QueryInterface(IMFTopology *iface, REFIID riid, void **out)
140 struct topology *topology = impl_from_IMFTopology(iface);
142 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
144 if (IsEqualIID(riid, &IID_IMFTopology) ||
145 IsEqualIID(riid, &IID_IMFAttributes) ||
146 IsEqualIID(riid, &IID_IUnknown))
148 *out = &topology->IMFTopology_iface;
150 else
152 FIXME("(%s, %p)\n", debugstr_guid(riid), out);
153 *out = NULL;
154 return E_NOINTERFACE;
157 IUnknown_AddRef((IUnknown*)*out);
158 return S_OK;
161 static ULONG WINAPI topology_AddRef(IMFTopology *iface)
163 struct topology *topology = impl_from_IMFTopology(iface);
164 ULONG refcount = InterlockedIncrement(&topology->refcount);
166 TRACE("%p, refcount %lu.\n", iface, refcount);
168 return refcount;
171 static HRESULT topology_node_disconnect_output(struct topology_node *node, DWORD output_index)
173 struct topology_node *connection = NULL;
174 struct node_stream *stream;
175 DWORD connection_stream;
176 HRESULT hr = S_OK;
178 EnterCriticalSection(&node->cs);
180 if (output_index < node->outputs.count)
182 stream = &node->outputs.streams[output_index];
184 if (stream->connection)
186 connection = stream->connection;
187 connection_stream = stream->connection_stream;
188 stream->connection = NULL;
189 stream->connection_stream = 0;
191 else
192 hr = MF_E_NOT_FOUND;
194 else
195 hr = E_INVALIDARG;
197 LeaveCriticalSection(&node->cs);
199 if (connection)
201 EnterCriticalSection(&connection->cs);
203 if (connection_stream < connection->inputs.count)
205 stream = &connection->inputs.streams[connection_stream];
207 if (stream->connection)
209 stream->connection = NULL;
210 stream->connection_stream = 0;
214 LeaveCriticalSection(&connection->cs);
216 IMFTopologyNode_Release(&connection->IMFTopologyNode_iface);
217 IMFTopologyNode_Release(&node->IMFTopologyNode_iface);
220 return hr;
223 static void topology_node_disconnect(struct topology_node *node)
225 struct node_stream *stream;
226 size_t i;
228 for (i = 0; i < node->outputs.count; ++i)
229 topology_node_disconnect_output(node, i);
231 for (i = 0; i < node->inputs.count; ++i)
233 stream = &node->inputs.streams[i];
234 if (stream->connection)
235 topology_node_disconnect_output(stream->connection, stream->connection_stream);
239 static void topology_clear(struct topology *topology)
241 size_t i;
243 for (i = 0; i < topology->nodes.count; ++i)
245 topology_node_disconnect(topology->nodes.nodes[i]);
246 IMFTopologyNode_Release(&topology->nodes.nodes[i]->IMFTopologyNode_iface);
248 free(topology->nodes.nodes);
249 topology->nodes.nodes = NULL;
250 topology->nodes.count = 0;
251 topology->nodes.size = 0;
254 static ULONG WINAPI topology_Release(IMFTopology *iface)
256 struct topology *topology = impl_from_IMFTopology(iface);
257 ULONG refcount = InterlockedDecrement(&topology->refcount);
259 TRACE("%p, refcount %lu.\n", iface, refcount);
261 if (!refcount)
263 if (topology->attributes)
264 IMFAttributes_Release(topology->attributes);
265 topology_clear(topology);
266 free(topology);
269 return refcount;
272 static HRESULT WINAPI topology_GetItem(IMFTopology *iface, REFGUID key, PROPVARIANT *value)
274 struct topology *topology = impl_from_IMFTopology(iface);
276 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
278 return IMFAttributes_GetItem(topology->attributes, key, value);
281 static HRESULT WINAPI topology_GetItemType(IMFTopology *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
283 struct topology *topology = impl_from_IMFTopology(iface);
285 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), type);
287 return IMFAttributes_GetItemType(topology->attributes, key, type);
290 static HRESULT WINAPI topology_CompareItem(IMFTopology *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
292 struct topology *topology = impl_from_IMFTopology(iface);
294 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, result);
296 return IMFAttributes_CompareItem(topology->attributes, key, value, result);
299 static HRESULT WINAPI topology_Compare(IMFTopology *iface, IMFAttributes *theirs, MF_ATTRIBUTES_MATCH_TYPE type,
300 BOOL *result)
302 struct topology *topology = impl_from_IMFTopology(iface);
304 TRACE("%p, %p, %d, %p.\n", iface, theirs, type, result);
306 return IMFAttributes_Compare(topology->attributes, theirs, type, result);
309 static HRESULT WINAPI topology_GetUINT32(IMFTopology *iface, REFGUID key, UINT32 *value)
311 struct topology *topology = impl_from_IMFTopology(iface);
313 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
315 return IMFAttributes_GetUINT32(topology->attributes, key, value);
318 static HRESULT WINAPI topology_GetUINT64(IMFTopology *iface, REFGUID key, UINT64 *value)
320 struct topology *topology = impl_from_IMFTopology(iface);
322 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
324 return IMFAttributes_GetUINT64(topology->attributes, key, value);
327 static HRESULT WINAPI topology_GetDouble(IMFTopology *iface, REFGUID key, double *value)
329 struct topology *topology = impl_from_IMFTopology(iface);
331 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
333 return IMFAttributes_GetDouble(topology->attributes, key, value);
336 static HRESULT WINAPI topology_GetGUID(IMFTopology *iface, REFGUID key, GUID *value)
338 struct topology *topology = impl_from_IMFTopology(iface);
340 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
342 return IMFAttributes_GetGUID(topology->attributes, key, value);
345 static HRESULT WINAPI topology_GetStringLength(IMFTopology *iface, REFGUID key, UINT32 *length)
347 struct topology *topology = impl_from_IMFTopology(iface);
349 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), length);
351 return IMFAttributes_GetStringLength(topology->attributes, key, length);
354 static HRESULT WINAPI topology_GetString(IMFTopology *iface, REFGUID key, WCHAR *value,
355 UINT32 size, UINT32 *length)
357 struct topology *topology = impl_from_IMFTopology(iface);
359 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), value, size, length);
361 return IMFAttributes_GetString(topology->attributes, key, value, size, length);
364 static HRESULT WINAPI topology_GetAllocatedString(IMFTopology *iface, REFGUID key,
365 WCHAR **value, UINT32 *length)
367 struct topology *topology = impl_from_IMFTopology(iface);
369 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, length);
371 return IMFAttributes_GetAllocatedString(topology->attributes, key, value, length);
374 static HRESULT WINAPI topology_GetBlobSize(IMFTopology *iface, REFGUID key, UINT32 *size)
376 struct topology *topology = impl_from_IMFTopology(iface);
378 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), size);
380 return IMFAttributes_GetBlobSize(topology->attributes, key, size);
383 static HRESULT WINAPI topology_GetBlob(IMFTopology *iface, REFGUID key, UINT8 *buf,
384 UINT32 bufsize, UINT32 *blobsize)
386 struct topology *topology = impl_from_IMFTopology(iface);
388 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), buf, bufsize, blobsize);
390 return IMFAttributes_GetBlob(topology->attributes, key, buf, bufsize, blobsize);
393 static HRESULT WINAPI topology_GetAllocatedBlob(IMFTopology *iface, REFGUID key, UINT8 **buf, UINT32 *size)
395 struct topology *topology = impl_from_IMFTopology(iface);
397 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), buf, size);
399 return IMFAttributes_GetAllocatedBlob(topology->attributes, key, buf, size);
402 static HRESULT WINAPI topology_GetUnknown(IMFTopology *iface, REFGUID key, REFIID riid, void **ppv)
404 struct topology *topology = impl_from_IMFTopology(iface);
406 TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(key), debugstr_guid(riid), ppv);
408 return IMFAttributes_GetUnknown(topology->attributes, key, riid, ppv);
411 static HRESULT WINAPI topology_SetItem(IMFTopology *iface, REFGUID key, REFPROPVARIANT value)
413 struct topology *topology = impl_from_IMFTopology(iface);
415 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
417 return IMFAttributes_SetItem(topology->attributes, key, value);
420 static HRESULT WINAPI topology_DeleteItem(IMFTopology *iface, REFGUID key)
422 struct topology *topology = impl_from_IMFTopology(iface);
424 TRACE("%p, %s.\n", topology, debugstr_guid(key));
426 return IMFAttributes_DeleteItem(topology->attributes, key);
429 static HRESULT WINAPI topology_DeleteAllItems(IMFTopology *iface)
431 struct topology *topology = impl_from_IMFTopology(iface);
433 TRACE("%p.\n", iface);
435 return IMFAttributes_DeleteAllItems(topology->attributes);
438 static HRESULT WINAPI topology_SetUINT32(IMFTopology *iface, REFGUID key, UINT32 value)
440 struct topology *topology = impl_from_IMFTopology(iface);
442 TRACE("%p, %s, %d.\n", iface, debugstr_guid(key), value);
444 return IMFAttributes_SetUINT32(topology->attributes, key, value);
447 static HRESULT WINAPI topology_SetUINT64(IMFTopology *iface, REFGUID key, UINT64 value)
449 struct topology *topology = impl_from_IMFTopology(iface);
451 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), wine_dbgstr_longlong(value));
453 return IMFAttributes_SetUINT64(topology->attributes, key, value);
456 static HRESULT WINAPI topology_SetDouble(IMFTopology *iface, REFGUID key, double value)
458 struct topology *topology = impl_from_IMFTopology(iface);
460 TRACE("%p, %s, %f.\n", iface, debugstr_guid(key), value);
462 return IMFAttributes_SetDouble(topology->attributes, key, value);
465 static HRESULT WINAPI topology_SetGUID(IMFTopology *iface, REFGUID key, REFGUID value)
467 struct topology *topology = impl_from_IMFTopology(iface);
469 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_guid(value));
471 return IMFAttributes_SetGUID(topology->attributes, key, value);
474 static HRESULT WINAPI topology_SetString(IMFTopology *iface, REFGUID key, const WCHAR *value)
476 struct topology *topology = impl_from_IMFTopology(iface);
478 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_w(value));
480 return IMFAttributes_SetString(topology->attributes, key, value);
483 static HRESULT WINAPI topology_SetBlob(IMFTopology *iface, REFGUID key, const UINT8 *buf, UINT32 size)
485 struct topology *topology = impl_from_IMFTopology(iface);
487 TRACE("%p, %s, %p, %d.\n", iface, debugstr_guid(key), buf, size);
489 return IMFAttributes_SetBlob(topology->attributes, key, buf, size);
492 static HRESULT WINAPI topology_SetUnknown(IMFTopology *iface, REFGUID key, IUnknown *unknown)
494 struct topology *topology = impl_from_IMFTopology(iface);
496 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), unknown);
498 return IMFAttributes_SetUnknown(topology->attributes, key, unknown);
501 static HRESULT WINAPI topology_LockStore(IMFTopology *iface)
503 struct topology *topology = impl_from_IMFTopology(iface);
505 TRACE("%p.\n", iface);
507 return IMFAttributes_LockStore(topology->attributes);
510 static HRESULT WINAPI topology_UnlockStore(IMFTopology *iface)
512 struct topology *topology = impl_from_IMFTopology(iface);
514 TRACE("%p.\n", iface);
516 return IMFAttributes_UnlockStore(topology->attributes);
519 static HRESULT WINAPI topology_GetCount(IMFTopology *iface, UINT32 *count)
521 struct topology *topology = impl_from_IMFTopology(iface);
523 TRACE("%p, %p.\n", iface, count);
525 return IMFAttributes_GetCount(topology->attributes, count);
528 static HRESULT WINAPI topology_GetItemByIndex(IMFTopology *iface, UINT32 index, GUID *key, PROPVARIANT *value)
530 struct topology *topology = impl_from_IMFTopology(iface);
532 TRACE("%p, %u, %p, %p.\n", iface, index, key, value);
534 return IMFAttributes_GetItemByIndex(topology->attributes, index, key, value);
537 static HRESULT WINAPI topology_CopyAllItems(IMFTopology *iface, IMFAttributes *dest)
539 struct topology *topology = impl_from_IMFTopology(iface);
541 TRACE("%p, %p.\n", iface, dest);
543 return IMFAttributes_CopyAllItems(topology->attributes, dest);
546 static HRESULT WINAPI topology_GetTopologyID(IMFTopology *iface, TOPOID *id)
548 struct topology *topology = impl_from_IMFTopology(iface);
550 TRACE("%p, %p.\n", iface, id);
552 if (!id)
553 return E_POINTER;
555 *id = topology->id;
557 return S_OK;
560 static HRESULT topology_get_node_by_id(const struct topology *topology, TOPOID id, struct topology_node **node)
562 size_t i = 0;
564 for (i = 0; i < topology->nodes.count; ++i)
566 if (topology->nodes.nodes[i]->id == id)
568 *node = topology->nodes.nodes[i];
569 return S_OK;
573 return MF_E_NOT_FOUND;
576 static HRESULT topology_add_node(struct topology *topology, struct topology_node *node)
578 struct topology_node *match;
580 if (!node)
581 return E_POINTER;
583 if (SUCCEEDED(topology_get_node_by_id(topology, node->id, &match)))
584 return E_INVALIDARG;
586 if (!mf_array_reserve((void **)&topology->nodes.nodes, &topology->nodes.size, topology->nodes.count + 1,
587 sizeof(*topology->nodes.nodes)))
589 return E_OUTOFMEMORY;
592 topology->nodes.nodes[topology->nodes.count++] = node;
593 IMFTopologyNode_AddRef(&node->IMFTopologyNode_iface);
595 return S_OK;
598 static HRESULT WINAPI topology_AddNode(IMFTopology *iface, IMFTopologyNode *node_iface)
600 struct topology *topology = impl_from_IMFTopology(iface);
601 struct topology_node *node = unsafe_impl_from_IMFTopologyNode(node_iface);
603 TRACE("%p, %p.\n", iface, node_iface);
605 return topology_add_node(topology, node);
608 static HRESULT WINAPI topology_RemoveNode(IMFTopology *iface, IMFTopologyNode *node)
610 struct topology *topology = impl_from_IMFTopology(iface);
611 size_t i, count;
613 TRACE("%p, %p.\n", iface, node);
615 for (i = 0; i < topology->nodes.count; ++i)
617 if (&topology->nodes.nodes[i]->IMFTopologyNode_iface == node)
619 topology_node_disconnect(topology->nodes.nodes[i]);
620 IMFTopologyNode_Release(&topology->nodes.nodes[i]->IMFTopologyNode_iface);
621 count = topology->nodes.count - i - 1;
622 if (count)
624 memmove(&topology->nodes.nodes[i], &topology->nodes.nodes[i + 1],
625 count * sizeof(*topology->nodes.nodes));
627 topology->nodes.count--;
628 return S_OK;
632 return E_INVALIDARG;
635 static HRESULT WINAPI topology_GetNodeCount(IMFTopology *iface, WORD *count)
637 struct topology *topology = impl_from_IMFTopology(iface);
639 TRACE("%p, %p.\n", iface, count);
641 if (!count)
642 return E_POINTER;
644 *count = topology->nodes.count;
646 return S_OK;
649 static HRESULT WINAPI topology_GetNode(IMFTopology *iface, WORD index, IMFTopologyNode **node)
651 struct topology *topology = impl_from_IMFTopology(iface);
653 TRACE("%p, %u, %p.\n", iface, index, node);
655 if (!node)
656 return E_POINTER;
658 if (index >= topology->nodes.count)
659 return MF_E_INVALIDINDEX;
661 *node = &topology->nodes.nodes[index]->IMFTopologyNode_iface;
662 IMFTopologyNode_AddRef(*node);
664 return S_OK;
667 static HRESULT WINAPI topology_Clear(IMFTopology *iface)
669 struct topology *topology = impl_from_IMFTopology(iface);
671 TRACE("%p.\n", iface);
673 topology_clear(topology);
674 return S_OK;
677 static HRESULT WINAPI topology_CloneFrom(IMFTopology *iface, IMFTopology *src)
679 struct topology *topology = impl_from_IMFTopology(iface);
680 struct topology *src_topology = unsafe_impl_from_IMFTopology(src);
681 struct topology_node *node;
682 size_t i, j;
683 HRESULT hr;
685 TRACE("%p, %p.\n", iface, src);
687 topology_clear(topology);
689 /* Clone nodes. */
690 for (i = 0; i < src_topology->nodes.count; ++i)
692 if (FAILED(hr = create_topology_node(src_topology->nodes.nodes[i]->node_type, &node)))
694 WARN("Failed to create a node, hr %#lx.\n", hr);
695 break;
698 if (SUCCEEDED(hr = IMFTopologyNode_CloneFrom(&node->IMFTopologyNode_iface,
699 &src_topology->nodes.nodes[i]->IMFTopologyNode_iface)))
701 topology_add_node(topology, node);
704 IMFTopologyNode_Release(&node->IMFTopologyNode_iface);
707 /* Clone connections. */
708 for (i = 0; i < src_topology->nodes.count; ++i)
710 const struct node_streams *outputs = &src_topology->nodes.nodes[i]->outputs;
712 for (j = 0; j < outputs->count; ++j)
714 DWORD input_index = outputs->streams[j].connection_stream;
715 TOPOID id = outputs->streams[j].connection->id;
717 /* Skip node lookup in destination topology, assuming same node order. */
718 if (SUCCEEDED(hr = topology_get_node_by_id(topology, id, &node)))
719 topology_node_connect_output(topology->nodes.nodes[i], j, node, input_index);
723 /* Copy attributes and id. */
724 hr = IMFTopology_CopyAllItems(src, (IMFAttributes *)&topology->IMFTopology_iface);
725 if (SUCCEEDED(hr))
726 topology->id = src_topology->id;
728 return S_OK;
731 static HRESULT WINAPI topology_GetNodeByID(IMFTopology *iface, TOPOID id, IMFTopologyNode **ret)
733 struct topology *topology = impl_from_IMFTopology(iface);
734 struct topology_node *node;
735 HRESULT hr;
737 TRACE("%p, %p.\n", iface, ret);
739 if (SUCCEEDED(hr = topology_get_node_by_id(topology, id, &node)))
741 *ret = &node->IMFTopologyNode_iface;
742 IMFTopologyNode_AddRef(*ret);
744 else
745 *ret = NULL;
747 return hr;
750 static HRESULT topology_get_node_collection(const struct topology *topology, MF_TOPOLOGY_TYPE node_type,
751 IMFCollection **collection)
753 HRESULT hr;
754 size_t i;
756 if (!collection)
757 return E_POINTER;
759 if (FAILED(hr = MFCreateCollection(collection)))
760 return hr;
762 for (i = 0; i < topology->nodes.count; ++i)
764 if (topology->nodes.nodes[i]->node_type == node_type)
766 if (FAILED(hr = IMFCollection_AddElement(*collection,
767 (IUnknown *)&topology->nodes.nodes[i]->IMFTopologyNode_iface)))
769 IMFCollection_Release(*collection);
770 *collection = NULL;
771 break;
776 return hr;
779 static HRESULT WINAPI topology_GetSourceNodeCollection(IMFTopology *iface, IMFCollection **collection)
781 struct topology *topology = impl_from_IMFTopology(iface);
783 TRACE("%p, %p.\n", iface, collection);
785 return topology_get_node_collection(topology, MF_TOPOLOGY_SOURCESTREAM_NODE, collection);
788 static HRESULT WINAPI topology_GetOutputNodeCollection(IMFTopology *iface, IMFCollection **collection)
790 struct topology *topology = impl_from_IMFTopology(iface);
792 TRACE("%p, %p.\n", iface, collection);
794 return topology_get_node_collection(topology, MF_TOPOLOGY_OUTPUT_NODE, collection);
797 static const IMFTopologyVtbl topologyvtbl =
799 topology_QueryInterface,
800 topology_AddRef,
801 topology_Release,
802 topology_GetItem,
803 topology_GetItemType,
804 topology_CompareItem,
805 topology_Compare,
806 topology_GetUINT32,
807 topology_GetUINT64,
808 topology_GetDouble,
809 topology_GetGUID,
810 topology_GetStringLength,
811 topology_GetString,
812 topology_GetAllocatedString,
813 topology_GetBlobSize,
814 topology_GetBlob,
815 topology_GetAllocatedBlob,
816 topology_GetUnknown,
817 topology_SetItem,
818 topology_DeleteItem,
819 topology_DeleteAllItems,
820 topology_SetUINT32,
821 topology_SetUINT64,
822 topology_SetDouble,
823 topology_SetGUID,
824 topology_SetString,
825 topology_SetBlob,
826 topology_SetUnknown,
827 topology_LockStore,
828 topology_UnlockStore,
829 topology_GetCount,
830 topology_GetItemByIndex,
831 topology_CopyAllItems,
832 topology_GetTopologyID,
833 topology_AddNode,
834 topology_RemoveNode,
835 topology_GetNodeCount,
836 topology_GetNode,
837 topology_Clear,
838 topology_CloneFrom,
839 topology_GetNodeByID,
840 topology_GetSourceNodeCollection,
841 topology_GetOutputNodeCollection,
844 static struct topology *unsafe_impl_from_IMFTopology(IMFTopology *iface)
846 if (!iface || iface->lpVtbl != &topologyvtbl)
847 return NULL;
848 return impl_from_IMFTopology(iface);
851 static TOPOID topology_generate_id(void)
853 TOPOID old;
857 old = next_topology_id;
859 while (InterlockedCompareExchange64((LONG64 *)&next_topology_id, old + 1, old) != old);
861 return next_topology_id;
864 /***********************************************************************
865 * MFCreateTopology (mf.@)
867 HRESULT WINAPI MFCreateTopology(IMFTopology **topology)
869 struct topology *object;
870 HRESULT hr;
872 TRACE("%p.\n", topology);
874 if (!topology)
875 return E_POINTER;
877 if (!(object = calloc(1, sizeof(*object))))
878 return E_OUTOFMEMORY;
880 object->IMFTopology_iface.lpVtbl = &topologyvtbl;
881 object->refcount = 1;
883 hr = MFCreateAttributes(&object->attributes, 0);
884 if (FAILED(hr))
886 IMFTopology_Release(&object->IMFTopology_iface);
887 return hr;
890 object->id = topology_generate_id();
892 *topology = &object->IMFTopology_iface;
894 return S_OK;
897 static HRESULT WINAPI topology_node_QueryInterface(IMFTopologyNode *iface, REFIID riid, void **out)
899 struct topology_node *node = impl_from_IMFTopologyNode(iface);
901 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
903 if (IsEqualIID(riid, &IID_IMFTopologyNode) ||
904 IsEqualIID(riid, &IID_IMFAttributes) ||
905 IsEqualIID(riid, &IID_IUnknown))
907 *out = &node->IMFTopologyNode_iface;
908 IMFTopologyNode_AddRef(iface);
909 return S_OK;
912 WARN("Unsupported interface %s.\n", debugstr_guid(riid));
913 *out = NULL;
915 return E_NOINTERFACE;
918 static ULONG WINAPI topology_node_AddRef(IMFTopologyNode *iface)
920 struct topology_node *node = impl_from_IMFTopologyNode(iface);
921 ULONG refcount = InterlockedIncrement(&node->refcount);
923 TRACE("%p, refcount %lu.\n", iface, refcount);
925 return refcount;
928 static ULONG WINAPI topology_node_Release(IMFTopologyNode *iface)
930 struct topology_node *node = impl_from_IMFTopologyNode(iface);
931 ULONG refcount = InterlockedDecrement(&node->refcount);
932 unsigned int i;
934 TRACE("%p, refcount %lu.\n", iface, refcount);
936 if (!refcount)
938 if (node->object)
939 IUnknown_Release(node->object);
940 if (node->input_type)
941 IMFMediaType_Release(node->input_type);
942 for (i = 0; i < node->inputs.count; ++i)
944 if (node->inputs.streams[i].preferred_type)
945 IMFMediaType_Release(node->inputs.streams[i].preferred_type);
947 for (i = 0; i < node->outputs.count; ++i)
949 if (node->outputs.streams[i].preferred_type)
950 IMFMediaType_Release(node->outputs.streams[i].preferred_type);
952 free(node->inputs.streams);
953 free(node->outputs.streams);
954 IMFAttributes_Release(node->attributes);
955 DeleteCriticalSection(&node->cs);
956 free(node);
959 return refcount;
962 static HRESULT WINAPI topology_node_GetItem(IMFTopologyNode *iface, REFGUID key, PROPVARIANT *value)
964 struct topology_node *node = impl_from_IMFTopologyNode(iface);
966 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
968 return IMFAttributes_GetItem(node->attributes, key, value);
971 static HRESULT WINAPI topology_node_GetItemType(IMFTopologyNode *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
973 struct topology_node *node = impl_from_IMFTopologyNode(iface);
975 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), type);
977 return IMFAttributes_GetItemType(node->attributes, key, type);
980 static HRESULT WINAPI topology_node_CompareItem(IMFTopologyNode *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
982 struct topology_node *node = impl_from_IMFTopologyNode(iface);
984 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, result);
986 return IMFAttributes_CompareItem(node->attributes, key, value, result);
989 static HRESULT WINAPI topology_node_Compare(IMFTopologyNode *iface, IMFAttributes *theirs,
990 MF_ATTRIBUTES_MATCH_TYPE type, BOOL *result)
992 struct topology_node *node = impl_from_IMFTopologyNode(iface);
994 TRACE("%p, %p, %d, %p.\n", iface, theirs, type, result);
996 return IMFAttributes_Compare(node->attributes, theirs, type, result);
999 static HRESULT WINAPI topology_node_GetUINT32(IMFTopologyNode *iface, REFGUID key, UINT32 *value)
1001 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1003 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1005 return IMFAttributes_GetUINT32(node->attributes, key, value);
1008 static HRESULT WINAPI topology_node_GetUINT64(IMFTopologyNode *iface, REFGUID key, UINT64 *value)
1010 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1012 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1014 return IMFAttributes_GetUINT64(node->attributes, key, value);
1017 static HRESULT WINAPI topology_node_GetDouble(IMFTopologyNode *iface, REFGUID key, double *value)
1019 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1021 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1023 return IMFAttributes_GetDouble(node->attributes, key, value);
1026 static HRESULT WINAPI topology_node_GetGUID(IMFTopologyNode *iface, REFGUID key, GUID *value)
1028 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1030 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1032 return IMFAttributes_GetGUID(node->attributes, key, value);
1035 static HRESULT WINAPI topology_node_GetStringLength(IMFTopologyNode *iface, REFGUID key, UINT32 *length)
1037 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1039 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), length);
1041 return IMFAttributes_GetStringLength(node->attributes, key, length);
1044 static HRESULT WINAPI topology_node_GetString(IMFTopologyNode *iface, REFGUID key, WCHAR *value,
1045 UINT32 size, UINT32 *length)
1047 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1049 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), value, size, length);
1051 return IMFAttributes_GetString(node->attributes, key, value, size, length);
1054 static HRESULT WINAPI topology_node_GetAllocatedString(IMFTopologyNode *iface, REFGUID key,
1055 WCHAR **value, UINT32 *length)
1057 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1059 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, length);
1061 return IMFAttributes_GetAllocatedString(node->attributes, key, value, length);
1064 static HRESULT WINAPI topology_node_GetBlobSize(IMFTopologyNode *iface, REFGUID key, UINT32 *size)
1066 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1068 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), size);
1070 return IMFAttributes_GetBlobSize(node->attributes, key, size);
1073 static HRESULT WINAPI topology_node_GetBlob(IMFTopologyNode *iface, REFGUID key, UINT8 *buf,
1074 UINT32 bufsize, UINT32 *blobsize)
1076 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1078 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), buf, bufsize, blobsize);
1080 return IMFAttributes_GetBlob(node->attributes, key, buf, bufsize, blobsize);
1083 static HRESULT WINAPI topology_node_GetAllocatedBlob(IMFTopologyNode *iface, REFGUID key, UINT8 **buf, UINT32 *size)
1085 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1087 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), buf, size);
1089 return IMFAttributes_GetAllocatedBlob(node->attributes, key, buf, size);
1092 static HRESULT WINAPI topology_node_GetUnknown(IMFTopologyNode *iface, REFGUID key, REFIID riid, void **ppv)
1094 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1096 TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(key), debugstr_guid(riid), ppv);
1098 return IMFAttributes_GetUnknown(node->attributes, key, riid, ppv);
1101 static HRESULT WINAPI topology_node_SetItem(IMFTopologyNode *iface, REFGUID key, REFPROPVARIANT value)
1103 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1105 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1107 return IMFAttributes_SetItem(node->attributes, key, value);
1110 static HRESULT WINAPI topology_node_DeleteItem(IMFTopologyNode *iface, REFGUID key)
1112 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1114 TRACE("%p, %s.\n", iface, debugstr_guid(key));
1116 return IMFAttributes_DeleteItem(node->attributes, key);
1119 static HRESULT WINAPI topology_node_DeleteAllItems(IMFTopologyNode *iface)
1121 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1123 TRACE("%p.\n", iface);
1125 return IMFAttributes_DeleteAllItems(node->attributes);
1128 static HRESULT WINAPI topology_node_SetUINT32(IMFTopologyNode *iface, REFGUID key, UINT32 value)
1130 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1132 TRACE("%p, %s, %d.\n", iface, debugstr_guid(key), value);
1134 return IMFAttributes_SetUINT32(node->attributes, key, value);
1137 static HRESULT WINAPI topology_node_SetUINT64(IMFTopologyNode *iface, REFGUID key, UINT64 value)
1139 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1141 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), wine_dbgstr_longlong(value));
1143 return IMFAttributes_SetUINT64(node->attributes, key, value);
1146 static HRESULT WINAPI topology_node_SetDouble(IMFTopologyNode *iface, REFGUID key, double value)
1148 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1150 TRACE("%p, %s, %f.\n", iface, debugstr_guid(key), value);
1152 return IMFAttributes_SetDouble(node->attributes, key, value);
1155 static HRESULT WINAPI topology_node_SetGUID(IMFTopologyNode *iface, REFGUID key, REFGUID value)
1157 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1159 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_guid(value));
1161 return IMFAttributes_SetGUID(node->attributes, key, value);
1164 static HRESULT WINAPI topology_node_SetString(IMFTopologyNode *iface, REFGUID key, const WCHAR *value)
1166 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1168 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_w(value));
1170 return IMFAttributes_SetString(node->attributes, key, value);
1173 static HRESULT WINAPI topology_node_SetBlob(IMFTopologyNode *iface, REFGUID key, const UINT8 *buf, UINT32 size)
1175 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1177 TRACE("%p, %s, %p, %d.\n", iface, debugstr_guid(key), buf, size);
1179 return IMFAttributes_SetBlob(node->attributes, key, buf, size);
1182 static HRESULT WINAPI topology_node_SetUnknown(IMFTopologyNode *iface, REFGUID key, IUnknown *unknown)
1184 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1186 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), unknown);
1188 return IMFAttributes_SetUnknown(node->attributes, key, unknown);
1191 static HRESULT WINAPI topology_node_LockStore(IMFTopologyNode *iface)
1193 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1195 TRACE("%p.\n", iface);
1197 return IMFAttributes_LockStore(node->attributes);
1200 static HRESULT WINAPI topology_node_UnlockStore(IMFTopologyNode *iface)
1202 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1204 TRACE("%p.\n", iface);
1206 return IMFAttributes_UnlockStore(node->attributes);
1209 static HRESULT WINAPI topology_node_GetCount(IMFTopologyNode *iface, UINT32 *count)
1211 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1213 TRACE("%p, %p.\n", iface, count);
1215 return IMFAttributes_GetCount(node->attributes, count);
1218 static HRESULT WINAPI topology_node_GetItemByIndex(IMFTopologyNode *iface, UINT32 index, GUID *key, PROPVARIANT *value)
1220 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1222 TRACE("%p, %u, %p, %p.\n", iface, index, key, value);
1224 return IMFAttributes_GetItemByIndex(node->attributes, index, key, value);
1227 static HRESULT WINAPI topology_node_CopyAllItems(IMFTopologyNode *iface, IMFAttributes *dest)
1229 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1231 TRACE("%p, %p.\n", iface, dest);
1233 return IMFAttributes_CopyAllItems(node->attributes, dest);
1236 static HRESULT topology_node_set_object(struct topology_node *node, IUnknown *object)
1238 static const GUID *iids[3] = { &IID_IPersist, &IID_IPersistStorage, &IID_IPersistPropertyBag };
1239 IPersist *persist = NULL;
1240 BOOL has_object_id;
1241 GUID object_id;
1242 unsigned int i;
1243 HRESULT hr;
1245 has_object_id = IMFAttributes_GetGUID(node->attributes, &MF_TOPONODE_TRANSFORM_OBJECTID, &object_id) == S_OK;
1247 if (object && !has_object_id)
1249 for (i = 0; i < ARRAY_SIZE(iids); ++i)
1251 persist = NULL;
1252 if (SUCCEEDED(hr = IUnknown_QueryInterface(object, iids[i], (void **)&persist)))
1253 break;
1256 if (persist)
1258 if (FAILED(hr = IPersist_GetClassID(persist, &object_id)))
1260 IPersist_Release(persist);
1261 persist = NULL;
1266 EnterCriticalSection(&node->cs);
1268 if (node->object)
1269 IUnknown_Release(node->object);
1270 node->object = object;
1271 if (node->object)
1272 IUnknown_AddRef(node->object);
1274 if (persist)
1275 IMFAttributes_SetGUID(node->attributes, &MF_TOPONODE_TRANSFORM_OBJECTID, &object_id);
1277 LeaveCriticalSection(&node->cs);
1279 if (persist)
1280 IPersist_Release(persist);
1282 return S_OK;
1285 static HRESULT WINAPI topology_node_SetObject(IMFTopologyNode *iface, IUnknown *object)
1287 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1289 TRACE("%p, %p.\n", iface, object);
1291 return topology_node_set_object(node, object);
1294 static HRESULT WINAPI topology_node_GetObject(IMFTopologyNode *iface, IUnknown **object)
1296 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1298 TRACE("%p, %p.\n", iface, object);
1300 if (!object)
1301 return E_POINTER;
1303 EnterCriticalSection(&node->cs);
1305 *object = node->object;
1306 if (*object)
1307 IUnknown_AddRef(*object);
1309 LeaveCriticalSection(&node->cs);
1311 return *object ? S_OK : E_FAIL;
1314 static HRESULT WINAPI topology_node_GetNodeType(IMFTopologyNode *iface, MF_TOPOLOGY_TYPE *node_type)
1316 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1318 TRACE("%p, %p.\n", iface, node_type);
1320 *node_type = node->node_type;
1322 return S_OK;
1325 static HRESULT WINAPI topology_node_GetTopoNodeID(IMFTopologyNode *iface, TOPOID *id)
1327 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1329 TRACE("%p, %p.\n", iface, id);
1331 *id = node->id;
1333 return S_OK;
1336 static HRESULT WINAPI topology_node_SetTopoNodeID(IMFTopologyNode *iface, TOPOID id)
1338 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1340 TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(id));
1342 node->id = id;
1344 return S_OK;
1347 static HRESULT WINAPI topology_node_GetInputCount(IMFTopologyNode *iface, DWORD *count)
1349 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1351 TRACE("%p, %p.\n", iface, count);
1353 *count = node->inputs.count;
1355 return S_OK;
1358 static HRESULT WINAPI topology_node_GetOutputCount(IMFTopologyNode *iface, DWORD *count)
1360 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1362 TRACE("%p, %p.\n", iface, count);
1364 *count = node->outputs.count;
1366 return S_OK;
1369 static void topology_node_set_stream_type(struct node_stream *stream, IMFMediaType *mediatype)
1371 if (stream->preferred_type)
1372 IMFMediaType_Release(stream->preferred_type);
1373 stream->preferred_type = mediatype;
1374 if (stream->preferred_type)
1375 IMFMediaType_AddRef(stream->preferred_type);
1378 static HRESULT topology_node_connect_output(struct topology_node *node, DWORD output_index,
1379 struct topology_node *connection, DWORD input_index)
1381 struct node_stream *stream;
1382 HRESULT hr;
1384 if (node->node_type == MF_TOPOLOGY_OUTPUT_NODE || connection->node_type == MF_TOPOLOGY_SOURCESTREAM_NODE)
1385 return E_FAIL;
1387 EnterCriticalSection(&node->cs);
1388 EnterCriticalSection(&connection->cs);
1390 topology_node_disconnect_output(node, output_index);
1391 if (input_index < connection->inputs.count)
1393 stream = &connection->inputs.streams[input_index];
1394 if (stream->connection)
1395 topology_node_disconnect_output(stream->connection, stream->connection_stream);
1398 hr = topology_node_reserve_streams(&node->outputs, output_index);
1399 if (SUCCEEDED(hr))
1401 size_t old_count = connection->inputs.count;
1402 hr = topology_node_reserve_streams(&connection->inputs, input_index);
1403 if (SUCCEEDED(hr) && !old_count && connection->input_type)
1405 topology_node_set_stream_type(connection->inputs.streams, connection->input_type);
1406 IMFMediaType_Release(connection->input_type);
1407 connection->input_type = NULL;
1411 if (SUCCEEDED(hr))
1413 node->outputs.streams[output_index].connection = connection;
1414 IMFTopologyNode_AddRef(&node->outputs.streams[output_index].connection->IMFTopologyNode_iface);
1415 node->outputs.streams[output_index].connection_stream = input_index;
1416 connection->inputs.streams[input_index].connection = node;
1417 IMFTopologyNode_AddRef(&connection->inputs.streams[input_index].connection->IMFTopologyNode_iface);
1418 connection->inputs.streams[input_index].connection_stream = output_index;
1421 LeaveCriticalSection(&connection->cs);
1422 LeaveCriticalSection(&node->cs);
1424 return hr;
1427 static HRESULT WINAPI topology_node_ConnectOutput(IMFTopologyNode *iface, DWORD output_index,
1428 IMFTopologyNode *peer, DWORD input_index)
1430 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1431 struct topology_node *connection = unsafe_impl_from_IMFTopologyNode(peer);
1433 TRACE("%p, %lu, %p, %lu.\n", iface, output_index, peer, input_index);
1435 if (!connection)
1437 WARN("External node implementations are not supported.\n");
1438 return E_UNEXPECTED;
1441 return topology_node_connect_output(node, output_index, connection, input_index);
1444 static HRESULT WINAPI topology_node_DisconnectOutput(IMFTopologyNode *iface, DWORD output_index)
1446 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1448 TRACE("%p, %lu.\n", iface, output_index);
1450 return topology_node_disconnect_output(node, output_index);
1453 static HRESULT WINAPI topology_node_GetInput(IMFTopologyNode *iface, DWORD input_index, IMFTopologyNode **ret,
1454 DWORD *output_index)
1456 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1457 HRESULT hr = S_OK;
1459 TRACE("%p, %lu, %p, %p.\n", iface, input_index, ret, output_index);
1461 EnterCriticalSection(&node->cs);
1463 if (input_index < node->inputs.count)
1465 const struct node_stream *stream = &node->inputs.streams[input_index];
1467 if (stream->connection)
1469 *ret = &stream->connection->IMFTopologyNode_iface;
1470 IMFTopologyNode_AddRef(*ret);
1471 *output_index = stream->connection_stream;
1473 else
1474 hr = MF_E_NOT_FOUND;
1476 else
1477 hr = E_INVALIDARG;
1479 LeaveCriticalSection(&node->cs);
1481 return hr;
1484 static HRESULT WINAPI topology_node_GetOutput(IMFTopologyNode *iface, DWORD output_index, IMFTopologyNode **ret,
1485 DWORD *input_index)
1487 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1488 HRESULT hr = S_OK;
1490 TRACE("%p, %lu, %p, %p.\n", iface, output_index, ret, input_index);
1492 EnterCriticalSection(&node->cs);
1494 if (output_index < node->outputs.count)
1496 const struct node_stream *stream = &node->outputs.streams[output_index];
1498 if (stream->connection)
1500 *ret = &stream->connection->IMFTopologyNode_iface;
1501 IMFTopologyNode_AddRef(*ret);
1502 *input_index = stream->connection_stream;
1504 else
1505 hr = MF_E_NOT_FOUND;
1507 else
1508 hr = E_INVALIDARG;
1510 LeaveCriticalSection(&node->cs);
1512 return hr;
1515 static HRESULT WINAPI topology_node_SetOutputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType *mediatype)
1517 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1518 HRESULT hr = S_OK;
1520 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1522 EnterCriticalSection(&node->cs);
1524 if (node->node_type != MF_TOPOLOGY_OUTPUT_NODE)
1526 if (SUCCEEDED(hr = topology_node_reserve_streams(&node->outputs, index)))
1527 topology_node_set_stream_type(&node->outputs.streams[index], mediatype);
1529 else
1530 hr = E_NOTIMPL;
1532 LeaveCriticalSection(&node->cs);
1534 return hr;
1537 static HRESULT topology_node_get_pref_type(struct node_streams *streams, unsigned int index, IMFMediaType **mediatype)
1539 *mediatype = streams->streams[index].preferred_type;
1540 if (*mediatype)
1542 IMFMediaType_AddRef(*mediatype);
1543 return S_OK;
1546 return E_FAIL;
1549 static HRESULT WINAPI topology_node_GetOutputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType **mediatype)
1551 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1552 HRESULT hr = S_OK;
1554 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1556 EnterCriticalSection(&node->cs);
1558 if (index < node->outputs.count)
1559 hr = topology_node_get_pref_type(&node->outputs, index, mediatype);
1560 else
1561 hr = E_INVALIDARG;
1563 LeaveCriticalSection(&node->cs);
1565 return hr;
1568 static HRESULT WINAPI topology_node_SetInputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType *mediatype)
1570 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1571 HRESULT hr = S_OK;
1573 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1575 EnterCriticalSection(&node->cs);
1577 switch (node->node_type)
1579 case MF_TOPOLOGY_TEE_NODE:
1580 if (index)
1582 hr = MF_E_INVALIDTYPE;
1583 break;
1585 if (node->inputs.count)
1586 topology_node_set_stream_type(&node->inputs.streams[index], mediatype);
1587 else
1589 if (node->input_type)
1590 IMFMediaType_Release(node->input_type);
1591 node->input_type = mediatype;
1592 if (node->input_type)
1593 IMFMediaType_AddRef(node->input_type);
1595 break;
1596 case MF_TOPOLOGY_SOURCESTREAM_NODE:
1597 hr = E_NOTIMPL;
1598 break;
1599 default:
1600 if (SUCCEEDED(hr = topology_node_reserve_streams(&node->inputs, index)))
1601 topology_node_set_stream_type(&node->inputs.streams[index], mediatype);
1604 LeaveCriticalSection(&node->cs);
1606 return hr;
1609 static HRESULT WINAPI topology_node_GetInputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType **mediatype)
1611 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1612 HRESULT hr = S_OK;
1614 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1616 EnterCriticalSection(&node->cs);
1618 if (index < node->inputs.count)
1620 hr = topology_node_get_pref_type(&node->inputs, index, mediatype);
1622 else if (node->node_type == MF_TOPOLOGY_TEE_NODE && node->input_type)
1624 *mediatype = node->input_type;
1625 IMFMediaType_AddRef(*mediatype);
1627 else
1628 hr = E_INVALIDARG;
1630 LeaveCriticalSection(&node->cs);
1632 return hr;
1635 static HRESULT WINAPI topology_node_CloneFrom(IMFTopologyNode *iface, IMFTopologyNode *src_node)
1637 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1638 MF_TOPOLOGY_TYPE node_type;
1639 IMFMediaType *mediatype;
1640 IUnknown *object;
1641 DWORD count, i;
1642 TOPOID topoid;
1643 HRESULT hr;
1645 TRACE("%p, %p.\n", iface, src_node);
1647 if (FAILED(hr = IMFTopologyNode_GetNodeType(src_node, &node_type)))
1648 return hr;
1650 if (node->node_type != node_type)
1651 return MF_E_INVALIDREQUEST;
1653 if (FAILED(hr = IMFTopologyNode_GetTopoNodeID(src_node, &topoid)))
1654 return hr;
1656 object = NULL;
1657 IMFTopologyNode_GetObject(src_node, &object);
1659 EnterCriticalSection(&node->cs);
1661 hr = IMFTopologyNode_CopyAllItems(src_node, node->attributes);
1663 if (SUCCEEDED(hr))
1664 hr = topology_node_set_object(node, object);
1666 if (SUCCEEDED(hr))
1667 node->id = topoid;
1669 if (SUCCEEDED(IMFTopologyNode_GetInputCount(src_node, &count)))
1671 for (i = 0; i < count; ++i)
1673 if (SUCCEEDED(IMFTopologyNode_GetInputPrefType(src_node, i, &mediatype)))
1675 IMFTopologyNode_SetInputPrefType(iface, i, mediatype);
1676 IMFMediaType_Release(mediatype);
1681 if (SUCCEEDED(IMFTopologyNode_GetOutputCount(src_node, &count)))
1683 for (i = 0; i < count; ++i)
1685 if (SUCCEEDED(IMFTopologyNode_GetOutputPrefType(src_node, i, &mediatype)))
1687 IMFTopologyNode_SetOutputPrefType(iface, i, mediatype);
1688 IMFMediaType_Release(mediatype);
1693 LeaveCriticalSection(&node->cs);
1695 if (object)
1696 IUnknown_Release(object);
1698 return hr;
1701 static const IMFTopologyNodeVtbl topologynodevtbl =
1703 topology_node_QueryInterface,
1704 topology_node_AddRef,
1705 topology_node_Release,
1706 topology_node_GetItem,
1707 topology_node_GetItemType,
1708 topology_node_CompareItem,
1709 topology_node_Compare,
1710 topology_node_GetUINT32,
1711 topology_node_GetUINT64,
1712 topology_node_GetDouble,
1713 topology_node_GetGUID,
1714 topology_node_GetStringLength,
1715 topology_node_GetString,
1716 topology_node_GetAllocatedString,
1717 topology_node_GetBlobSize,
1718 topology_node_GetBlob,
1719 topology_node_GetAllocatedBlob,
1720 topology_node_GetUnknown,
1721 topology_node_SetItem,
1722 topology_node_DeleteItem,
1723 topology_node_DeleteAllItems,
1724 topology_node_SetUINT32,
1725 topology_node_SetUINT64,
1726 topology_node_SetDouble,
1727 topology_node_SetGUID,
1728 topology_node_SetString,
1729 topology_node_SetBlob,
1730 topology_node_SetUnknown,
1731 topology_node_LockStore,
1732 topology_node_UnlockStore,
1733 topology_node_GetCount,
1734 topology_node_GetItemByIndex,
1735 topology_node_CopyAllItems,
1736 topology_node_SetObject,
1737 topology_node_GetObject,
1738 topology_node_GetNodeType,
1739 topology_node_GetTopoNodeID,
1740 topology_node_SetTopoNodeID,
1741 topology_node_GetInputCount,
1742 topology_node_GetOutputCount,
1743 topology_node_ConnectOutput,
1744 topology_node_DisconnectOutput,
1745 topology_node_GetInput,
1746 topology_node_GetOutput,
1747 topology_node_SetOutputPrefType,
1748 topology_node_GetOutputPrefType,
1749 topology_node_SetInputPrefType,
1750 topology_node_GetInputPrefType,
1751 topology_node_CloneFrom,
1754 static HRESULT create_topology_node(MF_TOPOLOGY_TYPE node_type, struct topology_node **node)
1756 HRESULT hr;
1758 if (!(*node = calloc(1, sizeof(**node))))
1759 return E_OUTOFMEMORY;
1761 (*node)->IMFTopologyNode_iface.lpVtbl = &topologynodevtbl;
1762 (*node)->refcount = 1;
1763 (*node)->node_type = node_type;
1764 hr = MFCreateAttributes(&(*node)->attributes, 0);
1765 if (FAILED(hr))
1767 free(*node);
1768 return hr;
1770 (*node)->id = ((TOPOID)GetCurrentProcessId() << 32) | InterlockedIncrement(&next_node_id);
1771 InitializeCriticalSection(&(*node)->cs);
1773 return S_OK;
1776 HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj)
1778 IUnknown *unk;
1779 HRESULT hr;
1781 *obj = NULL;
1783 if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &unk)))
1785 hr = IUnknown_QueryInterface(unk, riid, obj);
1786 IUnknown_Release(unk);
1789 return hr;
1792 /***********************************************************************
1793 * MFCreateTopologyNode (mf.@)
1795 HRESULT WINAPI MFCreateTopologyNode(MF_TOPOLOGY_TYPE node_type, IMFTopologyNode **node)
1797 struct topology_node *object;
1798 HRESULT hr;
1800 TRACE("%d, %p.\n", node_type, node);
1802 if (!node)
1803 return E_POINTER;
1805 hr = create_topology_node(node_type, &object);
1806 if (SUCCEEDED(hr))
1807 *node = &object->IMFTopologyNode_iface;
1809 return hr;
1812 /* private helper for node types without an actual IMFMediaTypeHandler */
1813 struct type_handler
1815 IMFMediaTypeHandler IMFMediaTypeHandler_iface;
1816 LONG refcount;
1818 IMFTopologyNode *node;
1819 DWORD stream;
1820 BOOL output;
1822 IMFTransform *transform;
1825 static struct type_handler *impl_from_IMFMediaTypeHandler(IMFMediaTypeHandler *iface)
1827 return CONTAINING_RECORD(iface, struct type_handler, IMFMediaTypeHandler_iface);
1830 static HRESULT WINAPI type_handler_QueryInterface(IMFMediaTypeHandler *iface, REFIID riid, void **obj)
1832 if (IsEqualIID(riid, &IID_IMFMediaTypeHandler)
1833 || IsEqualIID(riid, &IID_IUnknown))
1835 IMFMediaTypeHandler_AddRef((*obj = iface));
1836 return S_OK;
1839 *obj = NULL;
1840 return E_NOINTERFACE;
1843 static ULONG WINAPI type_handler_AddRef(IMFMediaTypeHandler *iface)
1845 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1846 ULONG refcount = InterlockedIncrement(&handler->refcount);
1847 return refcount;
1850 static ULONG WINAPI type_handler_Release(IMFMediaTypeHandler *iface)
1852 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1853 ULONG refcount = InterlockedDecrement(&handler->refcount);
1855 if (!refcount)
1857 if (handler->transform)
1858 IMFTransform_Release(handler->transform);
1859 IMFTopologyNode_Release(handler->node);
1860 free(handler);
1863 return refcount;
1866 static HRESULT WINAPI type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface, IMFMediaType *in_type,
1867 IMFMediaType **out_type)
1869 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1870 IMFMediaType *type;
1871 DWORD flags;
1872 HRESULT hr;
1874 if (out_type)
1875 *out_type = NULL;
1877 if (handler->transform)
1879 if (handler->output)
1880 return IMFTransform_SetOutputType(handler->transform, handler->stream, in_type, MFT_SET_TYPE_TEST_ONLY);
1881 else
1882 return IMFTransform_SetInputType(handler->transform, handler->stream, in_type, MFT_SET_TYPE_TEST_ONLY);
1885 if (FAILED(hr = IMFMediaTypeHandler_GetCurrentMediaType(iface, &type)))
1886 return hr;
1888 hr = IMFMediaType_IsEqual(type, in_type, &flags);
1889 IMFMediaType_Release(type);
1890 return hr;
1893 static HRESULT WINAPI type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
1895 return E_NOTIMPL;
1898 static HRESULT WINAPI type_handler_GetMediaTypeByIndex(IMFMediaTypeHandler *iface, DWORD index,
1899 IMFMediaType **type)
1901 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1903 if (handler->transform)
1905 if (handler->output)
1906 return IMFTransform_GetOutputAvailableType(handler->transform, handler->stream, index, type);
1907 else
1908 return IMFTransform_GetInputAvailableType(handler->transform, handler->stream, index, type);
1911 if (index)
1912 return MF_E_NO_MORE_TYPES;
1914 return IMFMediaTypeHandler_GetCurrentMediaType(iface, type);
1917 static HRESULT WINAPI type_handler_SetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType *type)
1919 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1921 if (handler->transform)
1923 if (handler->output)
1924 return IMFTransform_SetOutputType(handler->transform, handler->stream, type, 0);
1925 else
1926 return IMFTransform_SetInputType(handler->transform, handler->stream, type, 0);
1929 return IMFTopologyNode_SetInputPrefType(handler->node, handler->stream, type);
1932 static HRESULT WINAPI type_handler_GetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType **type)
1934 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1935 UINT32 output;
1937 if (handler->transform)
1939 if (handler->output)
1940 return IMFTransform_GetOutputCurrentType(handler->transform, handler->stream, type);
1941 else
1942 return IMFTransform_GetInputCurrentType(handler->transform, handler->stream, type);
1945 if (SUCCEEDED(IMFTopologyNode_GetInputPrefType(handler->node, 0, type)))
1946 return S_OK;
1948 if (FAILED(IMFTopologyNode_GetUINT32(handler->node, &MF_TOPONODE_PRIMARYOUTPUT, &output)))
1949 output = 0;
1951 return IMFTopologyNode_GetOutputPrefType(handler->node, output, type);
1954 static HRESULT WINAPI type_handler_GetMajorType(IMFMediaTypeHandler *iface, GUID *type)
1956 IMFMediaType *media_type;
1957 HRESULT hr;
1959 if (FAILED(hr = IMFMediaTypeHandler_GetCurrentMediaType(iface, &media_type)))
1960 return hr;
1962 hr = IMFMediaType_GetMajorType(media_type, type);
1963 IMFMediaType_Release(media_type);
1964 return hr;
1967 static const IMFMediaTypeHandlerVtbl type_handler_vtbl =
1969 type_handler_QueryInterface,
1970 type_handler_AddRef,
1971 type_handler_Release,
1972 type_handler_IsMediaTypeSupported,
1973 type_handler_GetMediaTypeCount,
1974 type_handler_GetMediaTypeByIndex,
1975 type_handler_SetCurrentMediaType,
1976 type_handler_GetCurrentMediaType,
1977 type_handler_GetMajorType,
1980 static HRESULT type_handler_create(IMFTopologyNode *node, DWORD stream, BOOL output, IMFTransform *transform, IMFMediaTypeHandler **out)
1982 struct type_handler *handler;
1984 if (!(handler = calloc(1, sizeof(*handler)))) return E_OUTOFMEMORY;
1985 handler->IMFMediaTypeHandler_iface.lpVtbl = &type_handler_vtbl;
1986 handler->refcount = 1;
1987 handler->stream = stream;
1988 handler->output = output;
1989 IMFTopologyNode_AddRef((handler->node = node));
1990 if (transform)
1991 IMFTransform_AddRef((handler->transform = transform));
1993 *out = &handler->IMFMediaTypeHandler_iface;
1994 return S_OK;
1997 HRESULT topology_node_get_type_handler(IMFTopologyNode *node, DWORD stream,
1998 BOOL output, IMFMediaTypeHandler **handler)
2000 MF_TOPOLOGY_TYPE node_type;
2001 IMFStreamSink *stream_sink;
2002 IMFStreamDescriptor *sd;
2003 IMFTransform *transform;
2004 HRESULT hr;
2006 if (FAILED(hr = IMFTopologyNode_GetNodeType(node, &node_type)))
2007 return hr;
2009 switch (node_type)
2011 case MF_TOPOLOGY_OUTPUT_NODE:
2012 if (output || stream)
2013 return MF_E_INVALIDSTREAMNUMBER;
2015 if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
2017 hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, handler);
2018 IMFStreamSink_Release(stream_sink);
2020 break;
2021 case MF_TOPOLOGY_SOURCESTREAM_NODE:
2022 if (!output || stream)
2023 return MF_E_INVALIDSTREAMNUMBER;
2025 if (SUCCEEDED(hr = IMFTopologyNode_GetUnknown(node, &MF_TOPONODE_STREAM_DESCRIPTOR,
2026 &IID_IMFStreamDescriptor, (void **)&sd)))
2028 hr = IMFStreamDescriptor_GetMediaTypeHandler(sd, handler);
2029 IMFStreamDescriptor_Release(sd);
2031 break;
2032 case MF_TOPOLOGY_TRANSFORM_NODE:
2033 if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFTransform, (void **)&transform)))
2035 hr = type_handler_create(node, stream, output, transform, handler);
2036 IMFTransform_Release(transform);
2038 break;
2039 case MF_TOPOLOGY_TEE_NODE:
2040 hr = type_handler_create(node, stream, output, NULL, handler);
2041 break;
2042 default:
2043 WARN("Unexpected node type %u.\n", node_type);
2044 return MF_E_UNEXPECTED;
2047 return hr;
2050 /***********************************************************************
2051 * MFGetTopoNodeCurrentType (mf.@)
2053 HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOOL output, IMFMediaType **type)
2055 IMFMediaTypeHandler *handler;
2056 HRESULT hr;
2058 TRACE("%p, %lu, %d, %p.\n", node, stream, output, type);
2060 if (FAILED(hr = topology_node_get_type_handler(node, stream, output, &handler)))
2061 return hr;
2063 hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, type);
2064 IMFMediaTypeHandler_Release(handler);
2065 return hr;
2068 static HRESULT WINAPI seq_source_QueryInterface(IMFSequencerSource *iface, REFIID riid, void **out)
2070 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2072 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
2074 *out = NULL;
2076 if (IsEqualIID(riid, &IID_IMFSequencerSource) ||
2077 IsEqualIID(riid, &IID_IUnknown))
2079 *out = &seq_source->IMFSequencerSource_iface;
2081 else if (IsEqualIID(riid, &IID_IMFMediaSourceTopologyProvider))
2083 *out = &seq_source->IMFMediaSourceTopologyProvider_iface;
2085 else
2087 WARN("Unimplemented %s.\n", debugstr_guid(riid));
2088 return E_NOINTERFACE;
2091 if (*out)
2092 IUnknown_AddRef((IUnknown *)*out);
2094 return S_OK;
2097 static ULONG WINAPI seq_source_AddRef(IMFSequencerSource *iface)
2099 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2100 ULONG refcount = InterlockedIncrement(&seq_source->refcount);
2102 TRACE("%p, refcount %lu.\n", iface, refcount);
2104 return refcount;
2107 static ULONG WINAPI seq_source_Release(IMFSequencerSource *iface)
2109 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2110 ULONG refcount = InterlockedDecrement(&seq_source->refcount);
2112 TRACE("%p, refcount %lu.\n", iface, refcount);
2114 if (!refcount)
2115 free(seq_source);
2117 return refcount;
2120 static HRESULT WINAPI seq_source_AppendTopology(IMFSequencerSource *iface, IMFTopology *topology,
2121 DWORD flags, MFSequencerElementId *id)
2123 FIXME("%p, %p, %lx, %p.\n", iface, topology, flags, id);
2125 return E_NOTIMPL;
2128 static HRESULT WINAPI seq_source_DeleteTopology(IMFSequencerSource *iface, MFSequencerElementId id)
2130 FIXME("%p, %#lx.\n", iface, id);
2132 return E_NOTIMPL;
2135 static HRESULT WINAPI seq_source_GetPresentationContext(IMFSequencerSource *iface,
2136 IMFPresentationDescriptor *descriptor, MFSequencerElementId *id, IMFTopology **topology)
2138 FIXME("%p, %p, %p, %p.\n", iface, descriptor, id, topology);
2140 return E_NOTIMPL;
2143 static HRESULT WINAPI seq_source_UpdateTopology(IMFSequencerSource *iface, MFSequencerElementId id,
2144 IMFTopology *topology)
2146 FIXME("%p, %#lx, %p.\n", iface, id, topology);
2148 return E_NOTIMPL;
2151 static HRESULT WINAPI seq_source_UpdateTopologyFlags(IMFSequencerSource *iface, MFSequencerElementId id, DWORD flags)
2153 FIXME("%p, %#lx, %#lx.\n", iface, id, flags);
2155 return E_NOTIMPL;
2158 static HRESULT WINAPI seq_source_topology_provider_QueryInterface(IMFMediaSourceTopologyProvider *iface, REFIID riid,
2159 void **obj)
2161 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2162 return IMFSequencerSource_QueryInterface(&seq_source->IMFSequencerSource_iface, riid, obj);
2165 static ULONG WINAPI seq_source_topology_provider_AddRef(IMFMediaSourceTopologyProvider *iface)
2167 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2168 return IMFSequencerSource_AddRef(&seq_source->IMFSequencerSource_iface);
2171 static ULONG WINAPI seq_source_topology_provider_Release(IMFMediaSourceTopologyProvider *iface)
2173 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2174 return IMFSequencerSource_Release(&seq_source->IMFSequencerSource_iface);
2177 static HRESULT WINAPI seq_source_topology_provider_GetMediaSourceTopology(IMFMediaSourceTopologyProvider *iface,
2178 IMFPresentationDescriptor *pd, IMFTopology **topology)
2180 FIXME("%p, %p, %p.\n", iface, pd, topology);
2182 return E_NOTIMPL;
2185 static const IMFMediaSourceTopologyProviderVtbl seq_source_topology_provider_vtbl =
2187 seq_source_topology_provider_QueryInterface,
2188 seq_source_topology_provider_AddRef,
2189 seq_source_topology_provider_Release,
2190 seq_source_topology_provider_GetMediaSourceTopology,
2193 static const IMFSequencerSourceVtbl seqsourcevtbl =
2195 seq_source_QueryInterface,
2196 seq_source_AddRef,
2197 seq_source_Release,
2198 seq_source_AppendTopology,
2199 seq_source_DeleteTopology,
2200 seq_source_GetPresentationContext,
2201 seq_source_UpdateTopology,
2202 seq_source_UpdateTopologyFlags,
2205 /***********************************************************************
2206 * MFCreateSequencerSource (mf.@)
2208 HRESULT WINAPI MFCreateSequencerSource(IUnknown *reserved, IMFSequencerSource **seq_source)
2210 struct seq_source *object;
2212 TRACE("%p, %p.\n", reserved, seq_source);
2214 if (!seq_source)
2215 return E_POINTER;
2217 if (!(object = calloc(1, sizeof(*object))))
2218 return E_OUTOFMEMORY;
2220 object->IMFSequencerSource_iface.lpVtbl = &seqsourcevtbl;
2221 object->IMFMediaSourceTopologyProvider_iface.lpVtbl = &seq_source_topology_provider_vtbl;
2222 object->refcount = 1;
2224 *seq_source = &object->IMFSequencerSource_iface;
2226 return S_OK;