winewayland.drv: Update desktop window size on display changes.
[wine.git] / dlls / mf / topology.c
blobb684b17ff720d0c40dc75dbff4bf03a2d4964eee
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;
717 if (!outputs->streams[j].connection)
718 continue;
720 id = outputs->streams[j].connection->id;
722 /* Skip node lookup in destination topology, assuming same node order. */
723 if (SUCCEEDED(hr = topology_get_node_by_id(topology, id, &node)))
724 topology_node_connect_output(topology->nodes.nodes[i], j, node, input_index);
728 /* Copy attributes and id. */
729 hr = IMFTopology_CopyAllItems(src, (IMFAttributes *)&topology->IMFTopology_iface);
730 if (SUCCEEDED(hr))
731 topology->id = src_topology->id;
733 return S_OK;
736 static HRESULT WINAPI topology_GetNodeByID(IMFTopology *iface, TOPOID id, IMFTopologyNode **ret)
738 struct topology *topology = impl_from_IMFTopology(iface);
739 struct topology_node *node;
740 HRESULT hr;
742 TRACE("%p, %p.\n", iface, ret);
744 if (SUCCEEDED(hr = topology_get_node_by_id(topology, id, &node)))
746 *ret = &node->IMFTopologyNode_iface;
747 IMFTopologyNode_AddRef(*ret);
749 else
750 *ret = NULL;
752 return hr;
755 static HRESULT topology_get_node_collection(const struct topology *topology, MF_TOPOLOGY_TYPE node_type,
756 IMFCollection **collection)
758 HRESULT hr;
759 size_t i;
761 if (!collection)
762 return E_POINTER;
764 if (FAILED(hr = MFCreateCollection(collection)))
765 return hr;
767 for (i = 0; i < topology->nodes.count; ++i)
769 if (topology->nodes.nodes[i]->node_type == node_type)
771 if (FAILED(hr = IMFCollection_AddElement(*collection,
772 (IUnknown *)&topology->nodes.nodes[i]->IMFTopologyNode_iface)))
774 IMFCollection_Release(*collection);
775 *collection = NULL;
776 break;
781 return hr;
784 static HRESULT WINAPI topology_GetSourceNodeCollection(IMFTopology *iface, IMFCollection **collection)
786 struct topology *topology = impl_from_IMFTopology(iface);
788 TRACE("%p, %p.\n", iface, collection);
790 return topology_get_node_collection(topology, MF_TOPOLOGY_SOURCESTREAM_NODE, collection);
793 static HRESULT WINAPI topology_GetOutputNodeCollection(IMFTopology *iface, IMFCollection **collection)
795 struct topology *topology = impl_from_IMFTopology(iface);
797 TRACE("%p, %p.\n", iface, collection);
799 return topology_get_node_collection(topology, MF_TOPOLOGY_OUTPUT_NODE, collection);
802 static const IMFTopologyVtbl topologyvtbl =
804 topology_QueryInterface,
805 topology_AddRef,
806 topology_Release,
807 topology_GetItem,
808 topology_GetItemType,
809 topology_CompareItem,
810 topology_Compare,
811 topology_GetUINT32,
812 topology_GetUINT64,
813 topology_GetDouble,
814 topology_GetGUID,
815 topology_GetStringLength,
816 topology_GetString,
817 topology_GetAllocatedString,
818 topology_GetBlobSize,
819 topology_GetBlob,
820 topology_GetAllocatedBlob,
821 topology_GetUnknown,
822 topology_SetItem,
823 topology_DeleteItem,
824 topology_DeleteAllItems,
825 topology_SetUINT32,
826 topology_SetUINT64,
827 topology_SetDouble,
828 topology_SetGUID,
829 topology_SetString,
830 topology_SetBlob,
831 topology_SetUnknown,
832 topology_LockStore,
833 topology_UnlockStore,
834 topology_GetCount,
835 topology_GetItemByIndex,
836 topology_CopyAllItems,
837 topology_GetTopologyID,
838 topology_AddNode,
839 topology_RemoveNode,
840 topology_GetNodeCount,
841 topology_GetNode,
842 topology_Clear,
843 topology_CloneFrom,
844 topology_GetNodeByID,
845 topology_GetSourceNodeCollection,
846 topology_GetOutputNodeCollection,
849 static struct topology *unsafe_impl_from_IMFTopology(IMFTopology *iface)
851 if (!iface || iface->lpVtbl != &topologyvtbl)
852 return NULL;
853 return impl_from_IMFTopology(iface);
856 static TOPOID topology_generate_id(void)
858 TOPOID old;
862 old = next_topology_id;
864 while (InterlockedCompareExchange64((LONG64 *)&next_topology_id, old + 1, old) != old);
866 return next_topology_id;
869 /***********************************************************************
870 * MFCreateTopology (mf.@)
872 HRESULT WINAPI MFCreateTopology(IMFTopology **topology)
874 struct topology *object;
875 HRESULT hr;
877 TRACE("%p.\n", topology);
879 if (!topology)
880 return E_POINTER;
882 if (!(object = calloc(1, sizeof(*object))))
883 return E_OUTOFMEMORY;
885 object->IMFTopology_iface.lpVtbl = &topologyvtbl;
886 object->refcount = 1;
888 hr = MFCreateAttributes(&object->attributes, 0);
889 if (FAILED(hr))
891 IMFTopology_Release(&object->IMFTopology_iface);
892 return hr;
895 object->id = topology_generate_id();
897 *topology = &object->IMFTopology_iface;
899 return S_OK;
902 static HRESULT WINAPI topology_node_QueryInterface(IMFTopologyNode *iface, REFIID riid, void **out)
904 struct topology_node *node = impl_from_IMFTopologyNode(iface);
906 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
908 if (IsEqualIID(riid, &IID_IMFTopologyNode) ||
909 IsEqualIID(riid, &IID_IMFAttributes) ||
910 IsEqualIID(riid, &IID_IUnknown))
912 *out = &node->IMFTopologyNode_iface;
913 IMFTopologyNode_AddRef(iface);
914 return S_OK;
917 WARN("Unsupported interface %s.\n", debugstr_guid(riid));
918 *out = NULL;
920 return E_NOINTERFACE;
923 static ULONG WINAPI topology_node_AddRef(IMFTopologyNode *iface)
925 struct topology_node *node = impl_from_IMFTopologyNode(iface);
926 ULONG refcount = InterlockedIncrement(&node->refcount);
928 TRACE("%p, refcount %lu.\n", iface, refcount);
930 return refcount;
933 static ULONG WINAPI topology_node_Release(IMFTopologyNode *iface)
935 struct topology_node *node = impl_from_IMFTopologyNode(iface);
936 ULONG refcount = InterlockedDecrement(&node->refcount);
937 unsigned int i;
939 TRACE("%p, refcount %lu.\n", iface, refcount);
941 if (!refcount)
943 if (node->object)
944 IUnknown_Release(node->object);
945 if (node->input_type)
946 IMFMediaType_Release(node->input_type);
947 for (i = 0; i < node->inputs.count; ++i)
949 if (node->inputs.streams[i].preferred_type)
950 IMFMediaType_Release(node->inputs.streams[i].preferred_type);
952 for (i = 0; i < node->outputs.count; ++i)
954 if (node->outputs.streams[i].preferred_type)
955 IMFMediaType_Release(node->outputs.streams[i].preferred_type);
957 free(node->inputs.streams);
958 free(node->outputs.streams);
959 IMFAttributes_Release(node->attributes);
960 DeleteCriticalSection(&node->cs);
961 free(node);
964 return refcount;
967 static HRESULT WINAPI topology_node_GetItem(IMFTopologyNode *iface, REFGUID key, PROPVARIANT *value)
969 struct topology_node *node = impl_from_IMFTopologyNode(iface);
971 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
973 return IMFAttributes_GetItem(node->attributes, key, value);
976 static HRESULT WINAPI topology_node_GetItemType(IMFTopologyNode *iface, REFGUID key, MF_ATTRIBUTE_TYPE *type)
978 struct topology_node *node = impl_from_IMFTopologyNode(iface);
980 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), type);
982 return IMFAttributes_GetItemType(node->attributes, key, type);
985 static HRESULT WINAPI topology_node_CompareItem(IMFTopologyNode *iface, REFGUID key, REFPROPVARIANT value, BOOL *result)
987 struct topology_node *node = impl_from_IMFTopologyNode(iface);
989 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, result);
991 return IMFAttributes_CompareItem(node->attributes, key, value, result);
994 static HRESULT WINAPI topology_node_Compare(IMFTopologyNode *iface, IMFAttributes *theirs,
995 MF_ATTRIBUTES_MATCH_TYPE type, BOOL *result)
997 struct topology_node *node = impl_from_IMFTopologyNode(iface);
999 TRACE("%p, %p, %d, %p.\n", iface, theirs, type, result);
1001 return IMFAttributes_Compare(node->attributes, theirs, type, result);
1004 static HRESULT WINAPI topology_node_GetUINT32(IMFTopologyNode *iface, REFGUID key, UINT32 *value)
1006 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1008 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1010 return IMFAttributes_GetUINT32(node->attributes, key, value);
1013 static HRESULT WINAPI topology_node_GetUINT64(IMFTopologyNode *iface, REFGUID key, UINT64 *value)
1015 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1017 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1019 return IMFAttributes_GetUINT64(node->attributes, key, value);
1022 static HRESULT WINAPI topology_node_GetDouble(IMFTopologyNode *iface, REFGUID key, double *value)
1024 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1026 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1028 return IMFAttributes_GetDouble(node->attributes, key, value);
1031 static HRESULT WINAPI topology_node_GetGUID(IMFTopologyNode *iface, REFGUID key, GUID *value)
1033 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1035 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1037 return IMFAttributes_GetGUID(node->attributes, key, value);
1040 static HRESULT WINAPI topology_node_GetStringLength(IMFTopologyNode *iface, REFGUID key, UINT32 *length)
1042 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1044 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), length);
1046 return IMFAttributes_GetStringLength(node->attributes, key, length);
1049 static HRESULT WINAPI topology_node_GetString(IMFTopologyNode *iface, REFGUID key, WCHAR *value,
1050 UINT32 size, UINT32 *length)
1052 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1054 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), value, size, length);
1056 return IMFAttributes_GetString(node->attributes, key, value, size, length);
1059 static HRESULT WINAPI topology_node_GetAllocatedString(IMFTopologyNode *iface, REFGUID key,
1060 WCHAR **value, UINT32 *length)
1062 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1064 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), value, length);
1066 return IMFAttributes_GetAllocatedString(node->attributes, key, value, length);
1069 static HRESULT WINAPI topology_node_GetBlobSize(IMFTopologyNode *iface, REFGUID key, UINT32 *size)
1071 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1073 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), size);
1075 return IMFAttributes_GetBlobSize(node->attributes, key, size);
1078 static HRESULT WINAPI topology_node_GetBlob(IMFTopologyNode *iface, REFGUID key, UINT8 *buf,
1079 UINT32 bufsize, UINT32 *blobsize)
1081 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1083 TRACE("%p, %s, %p, %d, %p.\n", iface, debugstr_guid(key), buf, bufsize, blobsize);
1085 return IMFAttributes_GetBlob(node->attributes, key, buf, bufsize, blobsize);
1088 static HRESULT WINAPI topology_node_GetAllocatedBlob(IMFTopologyNode *iface, REFGUID key, UINT8 **buf, UINT32 *size)
1090 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1092 TRACE("%p, %s, %p, %p.\n", iface, debugstr_guid(key), buf, size);
1094 return IMFAttributes_GetAllocatedBlob(node->attributes, key, buf, size);
1097 static HRESULT WINAPI topology_node_GetUnknown(IMFTopologyNode *iface, REFGUID key, REFIID riid, void **ppv)
1099 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1101 TRACE("%p, %s, %s, %p.\n", iface, debugstr_guid(key), debugstr_guid(riid), ppv);
1103 return IMFAttributes_GetUnknown(node->attributes, key, riid, ppv);
1106 static HRESULT WINAPI topology_node_SetItem(IMFTopologyNode *iface, REFGUID key, REFPROPVARIANT value)
1108 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1110 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), value);
1112 return IMFAttributes_SetItem(node->attributes, key, value);
1115 static HRESULT WINAPI topology_node_DeleteItem(IMFTopologyNode *iface, REFGUID key)
1117 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1119 TRACE("%p, %s.\n", iface, debugstr_guid(key));
1121 return IMFAttributes_DeleteItem(node->attributes, key);
1124 static HRESULT WINAPI topology_node_DeleteAllItems(IMFTopologyNode *iface)
1126 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1128 TRACE("%p.\n", iface);
1130 return IMFAttributes_DeleteAllItems(node->attributes);
1133 static HRESULT WINAPI topology_node_SetUINT32(IMFTopologyNode *iface, REFGUID key, UINT32 value)
1135 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1137 TRACE("%p, %s, %d.\n", iface, debugstr_guid(key), value);
1139 return IMFAttributes_SetUINT32(node->attributes, key, value);
1142 static HRESULT WINAPI topology_node_SetUINT64(IMFTopologyNode *iface, REFGUID key, UINT64 value)
1144 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1146 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), wine_dbgstr_longlong(value));
1148 return IMFAttributes_SetUINT64(node->attributes, key, value);
1151 static HRESULT WINAPI topology_node_SetDouble(IMFTopologyNode *iface, REFGUID key, double value)
1153 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1155 TRACE("%p, %s, %f.\n", iface, debugstr_guid(key), value);
1157 return IMFAttributes_SetDouble(node->attributes, key, value);
1160 static HRESULT WINAPI topology_node_SetGUID(IMFTopologyNode *iface, REFGUID key, REFGUID value)
1162 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1164 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_guid(value));
1166 return IMFAttributes_SetGUID(node->attributes, key, value);
1169 static HRESULT WINAPI topology_node_SetString(IMFTopologyNode *iface, REFGUID key, const WCHAR *value)
1171 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1173 TRACE("%p, %s, %s.\n", iface, debugstr_guid(key), debugstr_w(value));
1175 return IMFAttributes_SetString(node->attributes, key, value);
1178 static HRESULT WINAPI topology_node_SetBlob(IMFTopologyNode *iface, REFGUID key, const UINT8 *buf, UINT32 size)
1180 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1182 TRACE("%p, %s, %p, %d.\n", iface, debugstr_guid(key), buf, size);
1184 return IMFAttributes_SetBlob(node->attributes, key, buf, size);
1187 static HRESULT WINAPI topology_node_SetUnknown(IMFTopologyNode *iface, REFGUID key, IUnknown *unknown)
1189 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1191 TRACE("%p, %s, %p.\n", iface, debugstr_guid(key), unknown);
1193 return IMFAttributes_SetUnknown(node->attributes, key, unknown);
1196 static HRESULT WINAPI topology_node_LockStore(IMFTopologyNode *iface)
1198 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1200 TRACE("%p.\n", iface);
1202 return IMFAttributes_LockStore(node->attributes);
1205 static HRESULT WINAPI topology_node_UnlockStore(IMFTopologyNode *iface)
1207 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1209 TRACE("%p.\n", iface);
1211 return IMFAttributes_UnlockStore(node->attributes);
1214 static HRESULT WINAPI topology_node_GetCount(IMFTopologyNode *iface, UINT32 *count)
1216 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1218 TRACE("%p, %p.\n", iface, count);
1220 return IMFAttributes_GetCount(node->attributes, count);
1223 static HRESULT WINAPI topology_node_GetItemByIndex(IMFTopologyNode *iface, UINT32 index, GUID *key, PROPVARIANT *value)
1225 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1227 TRACE("%p, %u, %p, %p.\n", iface, index, key, value);
1229 return IMFAttributes_GetItemByIndex(node->attributes, index, key, value);
1232 static HRESULT WINAPI topology_node_CopyAllItems(IMFTopologyNode *iface, IMFAttributes *dest)
1234 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1236 TRACE("%p, %p.\n", iface, dest);
1238 return IMFAttributes_CopyAllItems(node->attributes, dest);
1241 static HRESULT topology_node_set_object(struct topology_node *node, IUnknown *object)
1243 static const GUID *iids[3] = { &IID_IPersist, &IID_IPersistStorage, &IID_IPersistPropertyBag };
1244 IPersist *persist = NULL;
1245 BOOL has_object_id;
1246 GUID object_id;
1247 unsigned int i;
1248 HRESULT hr;
1250 has_object_id = IMFAttributes_GetGUID(node->attributes, &MF_TOPONODE_TRANSFORM_OBJECTID, &object_id) == S_OK;
1252 if (object && !has_object_id)
1254 for (i = 0; i < ARRAY_SIZE(iids); ++i)
1256 persist = NULL;
1257 if (SUCCEEDED(hr = IUnknown_QueryInterface(object, iids[i], (void **)&persist)))
1258 break;
1261 if (persist)
1263 if (FAILED(hr = IPersist_GetClassID(persist, &object_id)))
1265 IPersist_Release(persist);
1266 persist = NULL;
1271 EnterCriticalSection(&node->cs);
1273 if (node->object)
1274 IUnknown_Release(node->object);
1275 node->object = object;
1276 if (node->object)
1277 IUnknown_AddRef(node->object);
1279 if (persist)
1280 IMFAttributes_SetGUID(node->attributes, &MF_TOPONODE_TRANSFORM_OBJECTID, &object_id);
1282 LeaveCriticalSection(&node->cs);
1284 if (persist)
1285 IPersist_Release(persist);
1287 return S_OK;
1290 static HRESULT WINAPI topology_node_SetObject(IMFTopologyNode *iface, IUnknown *object)
1292 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1294 TRACE("%p, %p.\n", iface, object);
1296 return topology_node_set_object(node, object);
1299 static HRESULT WINAPI topology_node_GetObject(IMFTopologyNode *iface, IUnknown **object)
1301 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1303 TRACE("%p, %p.\n", iface, object);
1305 if (!object)
1306 return E_POINTER;
1308 EnterCriticalSection(&node->cs);
1310 *object = node->object;
1311 if (*object)
1312 IUnknown_AddRef(*object);
1314 LeaveCriticalSection(&node->cs);
1316 return *object ? S_OK : E_FAIL;
1319 static HRESULT WINAPI topology_node_GetNodeType(IMFTopologyNode *iface, MF_TOPOLOGY_TYPE *node_type)
1321 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1323 TRACE("%p, %p.\n", iface, node_type);
1325 *node_type = node->node_type;
1327 return S_OK;
1330 static HRESULT WINAPI topology_node_GetTopoNodeID(IMFTopologyNode *iface, TOPOID *id)
1332 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1334 TRACE("%p, %p.\n", iface, id);
1336 *id = node->id;
1338 return S_OK;
1341 static HRESULT WINAPI topology_node_SetTopoNodeID(IMFTopologyNode *iface, TOPOID id)
1343 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1345 TRACE("%p, %s.\n", iface, wine_dbgstr_longlong(id));
1347 node->id = id;
1349 return S_OK;
1352 static HRESULT WINAPI topology_node_GetInputCount(IMFTopologyNode *iface, DWORD *count)
1354 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1356 TRACE("%p, %p.\n", iface, count);
1358 *count = node->inputs.count;
1360 return S_OK;
1363 static HRESULT WINAPI topology_node_GetOutputCount(IMFTopologyNode *iface, DWORD *count)
1365 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1367 TRACE("%p, %p.\n", iface, count);
1369 *count = node->outputs.count;
1371 return S_OK;
1374 static void topology_node_set_stream_type(struct node_stream *stream, IMFMediaType *mediatype)
1376 if (stream->preferred_type)
1377 IMFMediaType_Release(stream->preferred_type);
1378 stream->preferred_type = mediatype;
1379 if (stream->preferred_type)
1380 IMFMediaType_AddRef(stream->preferred_type);
1383 static HRESULT topology_node_connect_output(struct topology_node *node, DWORD output_index,
1384 struct topology_node *connection, DWORD input_index)
1386 struct node_stream *stream;
1387 HRESULT hr;
1389 if (node->node_type == MF_TOPOLOGY_OUTPUT_NODE || connection->node_type == MF_TOPOLOGY_SOURCESTREAM_NODE)
1390 return E_FAIL;
1392 EnterCriticalSection(&node->cs);
1393 EnterCriticalSection(&connection->cs);
1395 topology_node_disconnect_output(node, output_index);
1396 if (input_index < connection->inputs.count)
1398 stream = &connection->inputs.streams[input_index];
1399 if (stream->connection)
1400 topology_node_disconnect_output(stream->connection, stream->connection_stream);
1403 hr = topology_node_reserve_streams(&node->outputs, output_index);
1404 if (SUCCEEDED(hr))
1406 size_t old_count = connection->inputs.count;
1407 hr = topology_node_reserve_streams(&connection->inputs, input_index);
1408 if (SUCCEEDED(hr) && !old_count && connection->input_type)
1410 topology_node_set_stream_type(connection->inputs.streams, connection->input_type);
1411 IMFMediaType_Release(connection->input_type);
1412 connection->input_type = NULL;
1416 if (SUCCEEDED(hr))
1418 node->outputs.streams[output_index].connection = connection;
1419 IMFTopologyNode_AddRef(&node->outputs.streams[output_index].connection->IMFTopologyNode_iface);
1420 node->outputs.streams[output_index].connection_stream = input_index;
1421 connection->inputs.streams[input_index].connection = node;
1422 IMFTopologyNode_AddRef(&connection->inputs.streams[input_index].connection->IMFTopologyNode_iface);
1423 connection->inputs.streams[input_index].connection_stream = output_index;
1426 LeaveCriticalSection(&connection->cs);
1427 LeaveCriticalSection(&node->cs);
1429 return hr;
1432 static HRESULT WINAPI topology_node_ConnectOutput(IMFTopologyNode *iface, DWORD output_index,
1433 IMFTopologyNode *peer, DWORD input_index)
1435 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1436 struct topology_node *connection = unsafe_impl_from_IMFTopologyNode(peer);
1438 TRACE("%p, %lu, %p, %lu.\n", iface, output_index, peer, input_index);
1440 if (!connection)
1442 WARN("External node implementations are not supported.\n");
1443 return E_UNEXPECTED;
1446 return topology_node_connect_output(node, output_index, connection, input_index);
1449 static HRESULT WINAPI topology_node_DisconnectOutput(IMFTopologyNode *iface, DWORD output_index)
1451 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1453 TRACE("%p, %lu.\n", iface, output_index);
1455 return topology_node_disconnect_output(node, output_index);
1458 static HRESULT WINAPI topology_node_GetInput(IMFTopologyNode *iface, DWORD input_index, IMFTopologyNode **ret,
1459 DWORD *output_index)
1461 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1462 HRESULT hr = S_OK;
1464 TRACE("%p, %lu, %p, %p.\n", iface, input_index, ret, output_index);
1466 EnterCriticalSection(&node->cs);
1468 if (input_index < node->inputs.count)
1470 const struct node_stream *stream = &node->inputs.streams[input_index];
1472 if (stream->connection)
1474 *ret = &stream->connection->IMFTopologyNode_iface;
1475 IMFTopologyNode_AddRef(*ret);
1476 *output_index = stream->connection_stream;
1478 else
1479 hr = MF_E_NOT_FOUND;
1481 else
1482 hr = E_INVALIDARG;
1484 LeaveCriticalSection(&node->cs);
1486 return hr;
1489 static HRESULT WINAPI topology_node_GetOutput(IMFTopologyNode *iface, DWORD output_index, IMFTopologyNode **ret,
1490 DWORD *input_index)
1492 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1493 HRESULT hr = S_OK;
1495 TRACE("%p, %lu, %p, %p.\n", iface, output_index, ret, input_index);
1497 EnterCriticalSection(&node->cs);
1499 if (output_index < node->outputs.count)
1501 const struct node_stream *stream = &node->outputs.streams[output_index];
1503 if (stream->connection)
1505 *ret = &stream->connection->IMFTopologyNode_iface;
1506 IMFTopologyNode_AddRef(*ret);
1507 *input_index = stream->connection_stream;
1509 else
1510 hr = MF_E_NOT_FOUND;
1512 else
1513 hr = E_INVALIDARG;
1515 LeaveCriticalSection(&node->cs);
1517 return hr;
1520 static HRESULT WINAPI topology_node_SetOutputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType *mediatype)
1522 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1523 HRESULT hr = S_OK;
1525 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1527 EnterCriticalSection(&node->cs);
1529 if (node->node_type != MF_TOPOLOGY_OUTPUT_NODE)
1531 if (SUCCEEDED(hr = topology_node_reserve_streams(&node->outputs, index)))
1532 topology_node_set_stream_type(&node->outputs.streams[index], mediatype);
1534 else
1535 hr = E_NOTIMPL;
1537 LeaveCriticalSection(&node->cs);
1539 return hr;
1542 static HRESULT topology_node_get_pref_type(struct node_streams *streams, unsigned int index, IMFMediaType **mediatype)
1544 *mediatype = streams->streams[index].preferred_type;
1545 if (*mediatype)
1547 IMFMediaType_AddRef(*mediatype);
1548 return S_OK;
1551 return E_FAIL;
1554 static HRESULT WINAPI topology_node_GetOutputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType **mediatype)
1556 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1557 HRESULT hr = S_OK;
1559 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1561 EnterCriticalSection(&node->cs);
1563 if (index < node->outputs.count)
1564 hr = topology_node_get_pref_type(&node->outputs, index, mediatype);
1565 else
1566 hr = E_INVALIDARG;
1568 LeaveCriticalSection(&node->cs);
1570 return hr;
1573 static HRESULT WINAPI topology_node_SetInputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType *mediatype)
1575 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1576 HRESULT hr = S_OK;
1578 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1580 EnterCriticalSection(&node->cs);
1582 switch (node->node_type)
1584 case MF_TOPOLOGY_TEE_NODE:
1585 if (index)
1587 hr = MF_E_INVALIDTYPE;
1588 break;
1590 if (node->inputs.count)
1591 topology_node_set_stream_type(&node->inputs.streams[index], mediatype);
1592 else
1594 if (node->input_type)
1595 IMFMediaType_Release(node->input_type);
1596 node->input_type = mediatype;
1597 if (node->input_type)
1598 IMFMediaType_AddRef(node->input_type);
1600 break;
1601 case MF_TOPOLOGY_SOURCESTREAM_NODE:
1602 hr = E_NOTIMPL;
1603 break;
1604 default:
1605 if (SUCCEEDED(hr = topology_node_reserve_streams(&node->inputs, index)))
1606 topology_node_set_stream_type(&node->inputs.streams[index], mediatype);
1609 LeaveCriticalSection(&node->cs);
1611 return hr;
1614 static HRESULT WINAPI topology_node_GetInputPrefType(IMFTopologyNode *iface, DWORD index, IMFMediaType **mediatype)
1616 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1617 HRESULT hr = S_OK;
1619 TRACE("%p, %lu, %p.\n", iface, index, mediatype);
1621 EnterCriticalSection(&node->cs);
1623 if (index < node->inputs.count)
1625 hr = topology_node_get_pref_type(&node->inputs, index, mediatype);
1627 else if (node->node_type == MF_TOPOLOGY_TEE_NODE && node->input_type)
1629 *mediatype = node->input_type;
1630 IMFMediaType_AddRef(*mediatype);
1632 else
1633 hr = E_INVALIDARG;
1635 LeaveCriticalSection(&node->cs);
1637 return hr;
1640 static HRESULT WINAPI topology_node_CloneFrom(IMFTopologyNode *iface, IMFTopologyNode *src_node)
1642 struct topology_node *node = impl_from_IMFTopologyNode(iface);
1643 MF_TOPOLOGY_TYPE node_type;
1644 IMFMediaType *mediatype;
1645 IUnknown *object;
1646 DWORD count, i;
1647 TOPOID topoid;
1648 HRESULT hr;
1650 TRACE("%p, %p.\n", iface, src_node);
1652 if (FAILED(hr = IMFTopologyNode_GetNodeType(src_node, &node_type)))
1653 return hr;
1655 if (node->node_type != node_type)
1656 return MF_E_INVALIDREQUEST;
1658 if (FAILED(hr = IMFTopologyNode_GetTopoNodeID(src_node, &topoid)))
1659 return hr;
1661 object = NULL;
1662 IMFTopologyNode_GetObject(src_node, &object);
1664 EnterCriticalSection(&node->cs);
1666 hr = IMFTopologyNode_CopyAllItems(src_node, node->attributes);
1668 if (SUCCEEDED(hr))
1669 hr = topology_node_set_object(node, object);
1671 if (SUCCEEDED(hr))
1672 node->id = topoid;
1674 if (SUCCEEDED(IMFTopologyNode_GetInputCount(src_node, &count)))
1676 for (i = 0; i < count; ++i)
1678 if (SUCCEEDED(IMFTopologyNode_GetInputPrefType(src_node, i, &mediatype)))
1680 IMFTopologyNode_SetInputPrefType(iface, i, mediatype);
1681 IMFMediaType_Release(mediatype);
1686 if (SUCCEEDED(IMFTopologyNode_GetOutputCount(src_node, &count)))
1688 for (i = 0; i < count; ++i)
1690 if (SUCCEEDED(IMFTopologyNode_GetOutputPrefType(src_node, i, &mediatype)))
1692 IMFTopologyNode_SetOutputPrefType(iface, i, mediatype);
1693 IMFMediaType_Release(mediatype);
1698 LeaveCriticalSection(&node->cs);
1700 if (object)
1701 IUnknown_Release(object);
1703 return hr;
1706 static const IMFTopologyNodeVtbl topologynodevtbl =
1708 topology_node_QueryInterface,
1709 topology_node_AddRef,
1710 topology_node_Release,
1711 topology_node_GetItem,
1712 topology_node_GetItemType,
1713 topology_node_CompareItem,
1714 topology_node_Compare,
1715 topology_node_GetUINT32,
1716 topology_node_GetUINT64,
1717 topology_node_GetDouble,
1718 topology_node_GetGUID,
1719 topology_node_GetStringLength,
1720 topology_node_GetString,
1721 topology_node_GetAllocatedString,
1722 topology_node_GetBlobSize,
1723 topology_node_GetBlob,
1724 topology_node_GetAllocatedBlob,
1725 topology_node_GetUnknown,
1726 topology_node_SetItem,
1727 topology_node_DeleteItem,
1728 topology_node_DeleteAllItems,
1729 topology_node_SetUINT32,
1730 topology_node_SetUINT64,
1731 topology_node_SetDouble,
1732 topology_node_SetGUID,
1733 topology_node_SetString,
1734 topology_node_SetBlob,
1735 topology_node_SetUnknown,
1736 topology_node_LockStore,
1737 topology_node_UnlockStore,
1738 topology_node_GetCount,
1739 topology_node_GetItemByIndex,
1740 topology_node_CopyAllItems,
1741 topology_node_SetObject,
1742 topology_node_GetObject,
1743 topology_node_GetNodeType,
1744 topology_node_GetTopoNodeID,
1745 topology_node_SetTopoNodeID,
1746 topology_node_GetInputCount,
1747 topology_node_GetOutputCount,
1748 topology_node_ConnectOutput,
1749 topology_node_DisconnectOutput,
1750 topology_node_GetInput,
1751 topology_node_GetOutput,
1752 topology_node_SetOutputPrefType,
1753 topology_node_GetOutputPrefType,
1754 topology_node_SetInputPrefType,
1755 topology_node_GetInputPrefType,
1756 topology_node_CloneFrom,
1759 static HRESULT create_topology_node(MF_TOPOLOGY_TYPE node_type, struct topology_node **node)
1761 HRESULT hr;
1763 if (!(*node = calloc(1, sizeof(**node))))
1764 return E_OUTOFMEMORY;
1766 (*node)->IMFTopologyNode_iface.lpVtbl = &topologynodevtbl;
1767 (*node)->refcount = 1;
1768 (*node)->node_type = node_type;
1769 hr = MFCreateAttributes(&(*node)->attributes, 0);
1770 if (FAILED(hr))
1772 free(*node);
1773 return hr;
1775 (*node)->id = ((TOPOID)GetCurrentProcessId() << 32) | InterlockedIncrement(&next_node_id);
1776 InitializeCriticalSection(&(*node)->cs);
1778 return S_OK;
1781 HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj)
1783 IUnknown *unk;
1784 HRESULT hr;
1786 *obj = NULL;
1788 if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &unk)))
1790 hr = IUnknown_QueryInterface(unk, riid, obj);
1791 IUnknown_Release(unk);
1794 return hr;
1797 /***********************************************************************
1798 * MFCreateTopologyNode (mf.@)
1800 HRESULT WINAPI MFCreateTopologyNode(MF_TOPOLOGY_TYPE node_type, IMFTopologyNode **node)
1802 struct topology_node *object;
1803 HRESULT hr;
1805 TRACE("%d, %p.\n", node_type, node);
1807 if (!node)
1808 return E_POINTER;
1810 hr = create_topology_node(node_type, &object);
1811 if (SUCCEEDED(hr))
1812 *node = &object->IMFTopologyNode_iface;
1814 return hr;
1817 /* private helper for node types without an actual IMFMediaTypeHandler */
1818 struct type_handler
1820 IMFMediaTypeHandler IMFMediaTypeHandler_iface;
1821 LONG refcount;
1823 IMFTopologyNode *node;
1824 DWORD stream;
1825 BOOL output;
1827 IMFTransform *transform;
1830 static struct type_handler *impl_from_IMFMediaTypeHandler(IMFMediaTypeHandler *iface)
1832 return CONTAINING_RECORD(iface, struct type_handler, IMFMediaTypeHandler_iface);
1835 static HRESULT WINAPI type_handler_QueryInterface(IMFMediaTypeHandler *iface, REFIID riid, void **obj)
1837 if (IsEqualIID(riid, &IID_IMFMediaTypeHandler)
1838 || IsEqualIID(riid, &IID_IUnknown))
1840 IMFMediaTypeHandler_AddRef((*obj = iface));
1841 return S_OK;
1844 *obj = NULL;
1845 return E_NOINTERFACE;
1848 static ULONG WINAPI type_handler_AddRef(IMFMediaTypeHandler *iface)
1850 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1851 ULONG refcount = InterlockedIncrement(&handler->refcount);
1852 return refcount;
1855 static ULONG WINAPI type_handler_Release(IMFMediaTypeHandler *iface)
1857 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1858 ULONG refcount = InterlockedDecrement(&handler->refcount);
1860 if (!refcount)
1862 if (handler->transform)
1863 IMFTransform_Release(handler->transform);
1864 IMFTopologyNode_Release(handler->node);
1865 free(handler);
1868 return refcount;
1871 static HRESULT WINAPI type_handler_IsMediaTypeSupported(IMFMediaTypeHandler *iface, IMFMediaType *in_type,
1872 IMFMediaType **out_type)
1874 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1875 IMFMediaType *type;
1876 DWORD flags;
1877 HRESULT hr;
1879 if (out_type)
1880 *out_type = NULL;
1882 if (handler->transform)
1884 if (handler->output)
1885 return IMFTransform_SetOutputType(handler->transform, handler->stream, in_type, MFT_SET_TYPE_TEST_ONLY);
1886 else
1887 return IMFTransform_SetInputType(handler->transform, handler->stream, in_type, MFT_SET_TYPE_TEST_ONLY);
1890 if (FAILED(hr = IMFMediaTypeHandler_GetCurrentMediaType(iface, &type)))
1891 return hr;
1893 hr = IMFMediaType_IsEqual(type, in_type, &flags);
1894 IMFMediaType_Release(type);
1895 return hr;
1898 static HRESULT WINAPI type_handler_GetMediaTypeCount(IMFMediaTypeHandler *iface, DWORD *count)
1900 return E_NOTIMPL;
1903 static HRESULT WINAPI type_handler_GetMediaTypeByIndex(IMFMediaTypeHandler *iface, DWORD index,
1904 IMFMediaType **type)
1906 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1908 if (handler->transform)
1910 if (handler->output)
1911 return IMFTransform_GetOutputAvailableType(handler->transform, handler->stream, index, type);
1912 else
1913 return IMFTransform_GetInputAvailableType(handler->transform, handler->stream, index, type);
1916 if (index)
1917 return MF_E_NO_MORE_TYPES;
1919 return IMFMediaTypeHandler_GetCurrentMediaType(iface, type);
1922 static HRESULT WINAPI type_handler_SetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType *type)
1924 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1926 if (handler->transform)
1928 if (handler->output)
1929 return IMFTransform_SetOutputType(handler->transform, handler->stream, type, 0);
1930 else
1931 return IMFTransform_SetInputType(handler->transform, handler->stream, type, 0);
1934 return IMFTopologyNode_SetInputPrefType(handler->node, handler->stream, type);
1937 static HRESULT WINAPI type_handler_GetCurrentMediaType(IMFMediaTypeHandler *iface, IMFMediaType **type)
1939 struct type_handler *handler = impl_from_IMFMediaTypeHandler(iface);
1940 UINT32 output;
1942 if (handler->transform)
1944 if (handler->output)
1945 return IMFTransform_GetOutputCurrentType(handler->transform, handler->stream, type);
1946 else
1947 return IMFTransform_GetInputCurrentType(handler->transform, handler->stream, type);
1950 if (SUCCEEDED(IMFTopologyNode_GetInputPrefType(handler->node, 0, type)))
1951 return S_OK;
1953 if (FAILED(IMFTopologyNode_GetUINT32(handler->node, &MF_TOPONODE_PRIMARYOUTPUT, &output)))
1954 output = 0;
1956 return IMFTopologyNode_GetOutputPrefType(handler->node, output, type);
1959 static HRESULT WINAPI type_handler_GetMajorType(IMFMediaTypeHandler *iface, GUID *type)
1961 IMFMediaType *media_type;
1962 HRESULT hr;
1964 if (FAILED(hr = IMFMediaTypeHandler_GetCurrentMediaType(iface, &media_type)))
1965 return hr;
1967 hr = IMFMediaType_GetMajorType(media_type, type);
1968 IMFMediaType_Release(media_type);
1969 return hr;
1972 static const IMFMediaTypeHandlerVtbl type_handler_vtbl =
1974 type_handler_QueryInterface,
1975 type_handler_AddRef,
1976 type_handler_Release,
1977 type_handler_IsMediaTypeSupported,
1978 type_handler_GetMediaTypeCount,
1979 type_handler_GetMediaTypeByIndex,
1980 type_handler_SetCurrentMediaType,
1981 type_handler_GetCurrentMediaType,
1982 type_handler_GetMajorType,
1985 static HRESULT type_handler_create(IMFTopologyNode *node, DWORD stream, BOOL output, IMFTransform *transform, IMFMediaTypeHandler **out)
1987 struct type_handler *handler;
1989 if (!(handler = calloc(1, sizeof(*handler)))) return E_OUTOFMEMORY;
1990 handler->IMFMediaTypeHandler_iface.lpVtbl = &type_handler_vtbl;
1991 handler->refcount = 1;
1992 handler->stream = stream;
1993 handler->output = output;
1994 IMFTopologyNode_AddRef((handler->node = node));
1995 if (transform)
1996 IMFTransform_AddRef((handler->transform = transform));
1998 *out = &handler->IMFMediaTypeHandler_iface;
1999 return S_OK;
2002 HRESULT topology_node_get_type_handler(IMFTopologyNode *node, DWORD stream,
2003 BOOL output, IMFMediaTypeHandler **handler)
2005 MF_TOPOLOGY_TYPE node_type;
2006 IMFStreamSink *stream_sink;
2007 IMFStreamDescriptor *sd;
2008 IMFTransform *transform;
2009 HRESULT hr;
2011 if (FAILED(hr = IMFTopologyNode_GetNodeType(node, &node_type)))
2012 return hr;
2014 switch (node_type)
2016 case MF_TOPOLOGY_OUTPUT_NODE:
2017 if (output || stream)
2018 return MF_E_INVALIDSTREAMNUMBER;
2020 if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
2022 hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, handler);
2023 IMFStreamSink_Release(stream_sink);
2025 break;
2026 case MF_TOPOLOGY_SOURCESTREAM_NODE:
2027 if (!output || stream)
2028 return MF_E_INVALIDSTREAMNUMBER;
2030 if (SUCCEEDED(hr = IMFTopologyNode_GetUnknown(node, &MF_TOPONODE_STREAM_DESCRIPTOR,
2031 &IID_IMFStreamDescriptor, (void **)&sd)))
2033 hr = IMFStreamDescriptor_GetMediaTypeHandler(sd, handler);
2034 IMFStreamDescriptor_Release(sd);
2036 break;
2037 case MF_TOPOLOGY_TRANSFORM_NODE:
2038 if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFTransform, (void **)&transform)))
2040 hr = type_handler_create(node, stream, output, transform, handler);
2041 IMFTransform_Release(transform);
2043 break;
2044 case MF_TOPOLOGY_TEE_NODE:
2045 hr = type_handler_create(node, stream, output, NULL, handler);
2046 break;
2047 default:
2048 WARN("Unexpected node type %u.\n", node_type);
2049 return MF_E_UNEXPECTED;
2052 return hr;
2055 /***********************************************************************
2056 * MFGetTopoNodeCurrentType (mf.@)
2058 HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOOL output, IMFMediaType **type)
2060 IMFMediaTypeHandler *handler;
2061 HRESULT hr;
2063 TRACE("%p, %lu, %d, %p.\n", node, stream, output, type);
2065 if (FAILED(hr = topology_node_get_type_handler(node, stream, output, &handler)))
2066 return hr;
2068 hr = IMFMediaTypeHandler_GetCurrentMediaType(handler, type);
2069 IMFMediaTypeHandler_Release(handler);
2070 return hr;
2073 static HRESULT WINAPI seq_source_QueryInterface(IMFSequencerSource *iface, REFIID riid, void **out)
2075 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2077 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), out);
2079 *out = NULL;
2081 if (IsEqualIID(riid, &IID_IMFSequencerSource) ||
2082 IsEqualIID(riid, &IID_IUnknown))
2084 *out = &seq_source->IMFSequencerSource_iface;
2086 else if (IsEqualIID(riid, &IID_IMFMediaSourceTopologyProvider))
2088 *out = &seq_source->IMFMediaSourceTopologyProvider_iface;
2090 else
2092 WARN("Unimplemented %s.\n", debugstr_guid(riid));
2093 return E_NOINTERFACE;
2096 if (*out)
2097 IUnknown_AddRef((IUnknown *)*out);
2099 return S_OK;
2102 static ULONG WINAPI seq_source_AddRef(IMFSequencerSource *iface)
2104 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2105 ULONG refcount = InterlockedIncrement(&seq_source->refcount);
2107 TRACE("%p, refcount %lu.\n", iface, refcount);
2109 return refcount;
2112 static ULONG WINAPI seq_source_Release(IMFSequencerSource *iface)
2114 struct seq_source *seq_source = impl_from_IMFSequencerSource(iface);
2115 ULONG refcount = InterlockedDecrement(&seq_source->refcount);
2117 TRACE("%p, refcount %lu.\n", iface, refcount);
2119 if (!refcount)
2120 free(seq_source);
2122 return refcount;
2125 static HRESULT WINAPI seq_source_AppendTopology(IMFSequencerSource *iface, IMFTopology *topology,
2126 DWORD flags, MFSequencerElementId *id)
2128 FIXME("%p, %p, %lx, %p.\n", iface, topology, flags, id);
2130 return E_NOTIMPL;
2133 static HRESULT WINAPI seq_source_DeleteTopology(IMFSequencerSource *iface, MFSequencerElementId id)
2135 FIXME("%p, %#lx.\n", iface, id);
2137 return E_NOTIMPL;
2140 static HRESULT WINAPI seq_source_GetPresentationContext(IMFSequencerSource *iface,
2141 IMFPresentationDescriptor *descriptor, MFSequencerElementId *id, IMFTopology **topology)
2143 FIXME("%p, %p, %p, %p.\n", iface, descriptor, id, topology);
2145 return E_NOTIMPL;
2148 static HRESULT WINAPI seq_source_UpdateTopology(IMFSequencerSource *iface, MFSequencerElementId id,
2149 IMFTopology *topology)
2151 FIXME("%p, %#lx, %p.\n", iface, id, topology);
2153 return E_NOTIMPL;
2156 static HRESULT WINAPI seq_source_UpdateTopologyFlags(IMFSequencerSource *iface, MFSequencerElementId id, DWORD flags)
2158 FIXME("%p, %#lx, %#lx.\n", iface, id, flags);
2160 return E_NOTIMPL;
2163 static HRESULT WINAPI seq_source_topology_provider_QueryInterface(IMFMediaSourceTopologyProvider *iface, REFIID riid,
2164 void **obj)
2166 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2167 return IMFSequencerSource_QueryInterface(&seq_source->IMFSequencerSource_iface, riid, obj);
2170 static ULONG WINAPI seq_source_topology_provider_AddRef(IMFMediaSourceTopologyProvider *iface)
2172 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2173 return IMFSequencerSource_AddRef(&seq_source->IMFSequencerSource_iface);
2176 static ULONG WINAPI seq_source_topology_provider_Release(IMFMediaSourceTopologyProvider *iface)
2178 struct seq_source *seq_source = impl_from_IMFMediaSourceTopologyProvider(iface);
2179 return IMFSequencerSource_Release(&seq_source->IMFSequencerSource_iface);
2182 static HRESULT WINAPI seq_source_topology_provider_GetMediaSourceTopology(IMFMediaSourceTopologyProvider *iface,
2183 IMFPresentationDescriptor *pd, IMFTopology **topology)
2185 FIXME("%p, %p, %p.\n", iface, pd, topology);
2187 return E_NOTIMPL;
2190 static const IMFMediaSourceTopologyProviderVtbl seq_source_topology_provider_vtbl =
2192 seq_source_topology_provider_QueryInterface,
2193 seq_source_topology_provider_AddRef,
2194 seq_source_topology_provider_Release,
2195 seq_source_topology_provider_GetMediaSourceTopology,
2198 static const IMFSequencerSourceVtbl seqsourcevtbl =
2200 seq_source_QueryInterface,
2201 seq_source_AddRef,
2202 seq_source_Release,
2203 seq_source_AppendTopology,
2204 seq_source_DeleteTopology,
2205 seq_source_GetPresentationContext,
2206 seq_source_UpdateTopology,
2207 seq_source_UpdateTopologyFlags,
2210 /***********************************************************************
2211 * MFCreateSequencerSource (mf.@)
2213 HRESULT WINAPI MFCreateSequencerSource(IUnknown *reserved, IMFSequencerSource **seq_source)
2215 struct seq_source *object;
2217 TRACE("%p, %p.\n", reserved, seq_source);
2219 if (!seq_source)
2220 return E_POINTER;
2222 if (!(object = calloc(1, sizeof(*object))))
2223 return E_OUTOFMEMORY;
2225 object->IMFSequencerSource_iface.lpVtbl = &seqsourcevtbl;
2226 object->IMFMediaSourceTopologyProvider_iface.lpVtbl = &seq_source_topology_provider_vtbl;
2227 object->refcount = 1;
2229 *seq_source = &object->IMFSequencerSource_iface;
2231 return S_OK;