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
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
;
42 IMFMediaType
*preferred_type
;
43 struct topology_node
*connection
;
44 DWORD connection_stream
;
49 struct node_stream
*streams
;
56 IMFTopologyNode IMFTopologyNode_iface
;
58 IMFAttributes
*attributes
;
59 MF_TOPOLOGY_TYPE node_type
;
62 IMFMediaType
*input_type
; /* Only for tee nodes. */
63 struct node_streams inputs
;
64 struct node_streams outputs
;
70 IMFTopology IMFTopology_iface
;
72 IMFAttributes
*attributes
;
75 struct topology_node
**nodes
;
82 struct topology_loader
84 IMFTopoLoader IMFTopoLoader_iface
;
90 IMFSequencerSource IMFSequencerSource_iface
;
91 IMFMediaSourceTopologyProvider IMFMediaSourceTopologyProvider_iface
;
95 static inline struct topology
*impl_from_IMFTopology(IMFTopology
*iface
)
97 return CONTAINING_RECORD(iface
, struct topology
, IMFTopology_iface
);
100 static struct topology_node
*impl_from_IMFTopologyNode(IMFTopologyNode
*iface
)
102 return CONTAINING_RECORD(iface
, struct topology_node
, IMFTopologyNode_iface
);
105 static const IMFTopologyNodeVtbl topologynodevtbl
;
107 static struct topology_node
*unsafe_impl_from_IMFTopologyNode(IMFTopologyNode
*iface
)
109 if (!iface
|| iface
->lpVtbl
!= &topologynodevtbl
)
111 return impl_from_IMFTopologyNode(iface
);
114 static HRESULT
create_topology_node(MF_TOPOLOGY_TYPE node_type
, struct topology_node
**node
);
115 static HRESULT
topology_node_connect_output(struct topology_node
*node
, DWORD output_index
,
116 struct topology_node
*connection
, DWORD input_index
);
118 static struct topology
*unsafe_impl_from_IMFTopology(IMFTopology
*iface
);
120 static struct topology_loader
*impl_from_IMFTopoLoader(IMFTopoLoader
*iface
)
122 return CONTAINING_RECORD(iface
, struct topology_loader
, IMFTopoLoader_iface
);
125 static struct seq_source
*impl_from_IMFSequencerSource(IMFSequencerSource
*iface
)
127 return CONTAINING_RECORD(iface
, struct seq_source
, IMFSequencerSource_iface
);
130 static struct seq_source
*impl_from_IMFMediaSourceTopologyProvider(IMFMediaSourceTopologyProvider
*iface
)
132 return CONTAINING_RECORD(iface
, struct seq_source
, IMFMediaSourceTopologyProvider_iface
);
135 static HRESULT
topology_node_reserve_streams(struct node_streams
*streams
, DWORD index
)
137 if (!mf_array_reserve((void **)&streams
->streams
, &streams
->size
, index
+ 1, sizeof(*streams
->streams
)))
138 return E_OUTOFMEMORY
;
140 if (index
>= streams
->count
)
142 memset(&streams
->streams
[streams
->count
], 0, (index
- streams
->count
+ 1) * sizeof(*streams
->streams
));
143 streams
->count
= index
+ 1;
149 static HRESULT WINAPI
topology_QueryInterface(IMFTopology
*iface
, REFIID riid
, void **out
)
151 struct topology
*topology
= impl_from_IMFTopology(iface
);
153 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
155 if (IsEqualIID(riid
, &IID_IMFTopology
) ||
156 IsEqualIID(riid
, &IID_IMFAttributes
) ||
157 IsEqualIID(riid
, &IID_IUnknown
))
159 *out
= &topology
->IMFTopology_iface
;
163 FIXME("(%s, %p)\n", debugstr_guid(riid
), out
);
165 return E_NOINTERFACE
;
168 IUnknown_AddRef((IUnknown
*)*out
);
172 static ULONG WINAPI
topology_AddRef(IMFTopology
*iface
)
174 struct topology
*topology
= impl_from_IMFTopology(iface
);
175 ULONG refcount
= InterlockedIncrement(&topology
->refcount
);
177 TRACE("%p, refcount %u.\n", iface
, refcount
);
182 static HRESULT
topology_node_disconnect_output(struct topology_node
*node
, DWORD output_index
)
184 struct topology_node
*connection
= NULL
;
185 struct node_stream
*stream
;
186 DWORD connection_stream
;
189 EnterCriticalSection(&node
->cs
);
191 if (output_index
< node
->outputs
.count
)
193 stream
= &node
->outputs
.streams
[output_index
];
195 if (stream
->connection
)
197 connection
= stream
->connection
;
198 connection_stream
= stream
->connection_stream
;
199 stream
->connection
= NULL
;
200 stream
->connection_stream
= 0;
208 LeaveCriticalSection(&node
->cs
);
212 EnterCriticalSection(&connection
->cs
);
214 if (connection_stream
< connection
->inputs
.count
)
216 stream
= &connection
->inputs
.streams
[connection_stream
];
218 if (stream
->connection
)
220 stream
->connection
= NULL
;
221 stream
->connection_stream
= 0;
225 LeaveCriticalSection(&connection
->cs
);
227 IMFTopologyNode_Release(&connection
->IMFTopologyNode_iface
);
228 IMFTopologyNode_Release(&node
->IMFTopologyNode_iface
);
234 static void topology_node_disconnect(struct topology_node
*node
)
236 struct node_stream
*stream
;
239 for (i
= 0; i
< node
->outputs
.count
; ++i
)
240 topology_node_disconnect_output(node
, i
);
242 for (i
= 0; i
< node
->inputs
.count
; ++i
)
244 stream
= &node
->inputs
.streams
[i
];
245 if (stream
->connection
)
246 topology_node_disconnect_output(stream
->connection
, stream
->connection_stream
);
250 static void topology_clear(struct topology
*topology
)
254 for (i
= 0; i
< topology
->nodes
.count
; ++i
)
256 topology_node_disconnect(topology
->nodes
.nodes
[i
]);
257 IMFTopologyNode_Release(&topology
->nodes
.nodes
[i
]->IMFTopologyNode_iface
);
259 heap_free(topology
->nodes
.nodes
);
260 topology
->nodes
.nodes
= NULL
;
261 topology
->nodes
.count
= 0;
262 topology
->nodes
.size
= 0;
265 static ULONG WINAPI
topology_Release(IMFTopology
*iface
)
267 struct topology
*topology
= impl_from_IMFTopology(iface
);
268 ULONG refcount
= InterlockedDecrement(&topology
->refcount
);
270 TRACE("%p, refcount %u.\n", iface
, refcount
);
274 if (topology
->attributes
)
275 IMFAttributes_Release(topology
->attributes
);
276 topology_clear(topology
);
283 static HRESULT WINAPI
topology_GetItem(IMFTopology
*iface
, REFGUID key
, PROPVARIANT
*value
)
285 struct topology
*topology
= impl_from_IMFTopology(iface
);
287 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
289 return IMFAttributes_GetItem(topology
->attributes
, key
, value
);
292 static HRESULT WINAPI
topology_GetItemType(IMFTopology
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
294 struct topology
*topology
= impl_from_IMFTopology(iface
);
296 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), type
);
298 return IMFAttributes_GetItemType(topology
->attributes
, key
, type
);
301 static HRESULT WINAPI
topology_CompareItem(IMFTopology
*iface
, REFGUID key
, REFPROPVARIANT value
, BOOL
*result
)
303 struct topology
*topology
= impl_from_IMFTopology(iface
);
305 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, result
);
307 return IMFAttributes_CompareItem(topology
->attributes
, key
, value
, result
);
310 static HRESULT WINAPI
topology_Compare(IMFTopology
*iface
, IMFAttributes
*theirs
, MF_ATTRIBUTES_MATCH_TYPE type
,
313 struct topology
*topology
= impl_from_IMFTopology(iface
);
315 TRACE("%p, %p, %d, %p.\n", iface
, theirs
, type
, result
);
317 return IMFAttributes_Compare(topology
->attributes
, theirs
, type
, result
);
320 static HRESULT WINAPI
topology_GetUINT32(IMFTopology
*iface
, REFGUID key
, UINT32
*value
)
322 struct topology
*topology
= impl_from_IMFTopology(iface
);
324 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
326 return IMFAttributes_GetUINT32(topology
->attributes
, key
, value
);
329 static HRESULT WINAPI
topology_GetUINT64(IMFTopology
*iface
, REFGUID key
, UINT64
*value
)
331 struct topology
*topology
= impl_from_IMFTopology(iface
);
333 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
335 return IMFAttributes_GetUINT64(topology
->attributes
, key
, value
);
338 static HRESULT WINAPI
topology_GetDouble(IMFTopology
*iface
, REFGUID key
, double *value
)
340 struct topology
*topology
= impl_from_IMFTopology(iface
);
342 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
344 return IMFAttributes_GetDouble(topology
->attributes
, key
, value
);
347 static HRESULT WINAPI
topology_GetGUID(IMFTopology
*iface
, REFGUID key
, GUID
*value
)
349 struct topology
*topology
= impl_from_IMFTopology(iface
);
351 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
353 return IMFAttributes_GetGUID(topology
->attributes
, key
, value
);
356 static HRESULT WINAPI
topology_GetStringLength(IMFTopology
*iface
, REFGUID key
, UINT32
*length
)
358 struct topology
*topology
= impl_from_IMFTopology(iface
);
360 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), length
);
362 return IMFAttributes_GetStringLength(topology
->attributes
, key
, length
);
365 static HRESULT WINAPI
topology_GetString(IMFTopology
*iface
, REFGUID key
, WCHAR
*value
,
366 UINT32 size
, UINT32
*length
)
368 struct topology
*topology
= impl_from_IMFTopology(iface
);
370 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), value
, size
, length
);
372 return IMFAttributes_GetString(topology
->attributes
, key
, value
, size
, length
);
375 static HRESULT WINAPI
topology_GetAllocatedString(IMFTopology
*iface
, REFGUID key
,
376 WCHAR
**value
, UINT32
*length
)
378 struct topology
*topology
= impl_from_IMFTopology(iface
);
380 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, length
);
382 return IMFAttributes_GetAllocatedString(topology
->attributes
, key
, value
, length
);
385 static HRESULT WINAPI
topology_GetBlobSize(IMFTopology
*iface
, REFGUID key
, UINT32
*size
)
387 struct topology
*topology
= impl_from_IMFTopology(iface
);
389 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), size
);
391 return IMFAttributes_GetBlobSize(topology
->attributes
, key
, size
);
394 static HRESULT WINAPI
topology_GetBlob(IMFTopology
*iface
, REFGUID key
, UINT8
*buf
,
395 UINT32 bufsize
, UINT32
*blobsize
)
397 struct topology
*topology
= impl_from_IMFTopology(iface
);
399 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), buf
, bufsize
, blobsize
);
401 return IMFAttributes_GetBlob(topology
->attributes
, key
, buf
, bufsize
, blobsize
);
404 static HRESULT WINAPI
topology_GetAllocatedBlob(IMFTopology
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
406 struct topology
*topology
= impl_from_IMFTopology(iface
);
408 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), buf
, size
);
410 return IMFAttributes_GetAllocatedBlob(topology
->attributes
, key
, buf
, size
);
413 static HRESULT WINAPI
topology_GetUnknown(IMFTopology
*iface
, REFGUID key
, REFIID riid
, void **ppv
)
415 struct topology
*topology
= impl_from_IMFTopology(iface
);
417 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(key
), debugstr_guid(riid
), ppv
);
419 return IMFAttributes_GetUnknown(topology
->attributes
, key
, riid
, ppv
);
422 static HRESULT WINAPI
topology_SetItem(IMFTopology
*iface
, REFGUID key
, REFPROPVARIANT value
)
424 struct topology
*topology
= impl_from_IMFTopology(iface
);
426 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
428 return IMFAttributes_SetItem(topology
->attributes
, key
, value
);
431 static HRESULT WINAPI
topology_DeleteItem(IMFTopology
*iface
, REFGUID key
)
433 struct topology
*topology
= impl_from_IMFTopology(iface
);
435 TRACE("%p, %s.\n", topology
, debugstr_guid(key
));
437 return IMFAttributes_DeleteItem(topology
->attributes
, key
);
440 static HRESULT WINAPI
topology_DeleteAllItems(IMFTopology
*iface
)
442 struct topology
*topology
= impl_from_IMFTopology(iface
);
444 TRACE("%p.\n", iface
);
446 return IMFAttributes_DeleteAllItems(topology
->attributes
);
449 static HRESULT WINAPI
topology_SetUINT32(IMFTopology
*iface
, REFGUID key
, UINT32 value
)
451 struct topology
*topology
= impl_from_IMFTopology(iface
);
453 TRACE("%p, %s, %d.\n", iface
, debugstr_guid(key
), value
);
455 return IMFAttributes_SetUINT32(topology
->attributes
, key
, value
);
458 static HRESULT WINAPI
topology_SetUINT64(IMFTopology
*iface
, REFGUID key
, UINT64 value
)
460 struct topology
*topology
= impl_from_IMFTopology(iface
);
462 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), wine_dbgstr_longlong(value
));
464 return IMFAttributes_SetUINT64(topology
->attributes
, key
, value
);
467 static HRESULT WINAPI
topology_SetDouble(IMFTopology
*iface
, REFGUID key
, double value
)
469 struct topology
*topology
= impl_from_IMFTopology(iface
);
471 TRACE("%p, %s, %f.\n", iface
, debugstr_guid(key
), value
);
473 return IMFAttributes_SetDouble(topology
->attributes
, key
, value
);
476 static HRESULT WINAPI
topology_SetGUID(IMFTopology
*iface
, REFGUID key
, REFGUID value
)
478 struct topology
*topology
= impl_from_IMFTopology(iface
);
480 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_guid(value
));
482 return IMFAttributes_SetGUID(topology
->attributes
, key
, value
);
485 static HRESULT WINAPI
topology_SetString(IMFTopology
*iface
, REFGUID key
, const WCHAR
*value
)
487 struct topology
*topology
= impl_from_IMFTopology(iface
);
489 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_w(value
));
491 return IMFAttributes_SetString(topology
->attributes
, key
, value
);
494 static HRESULT WINAPI
topology_SetBlob(IMFTopology
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
496 struct topology
*topology
= impl_from_IMFTopology(iface
);
498 TRACE("%p, %s, %p, %d.\n", iface
, debugstr_guid(key
), buf
, size
);
500 return IMFAttributes_SetBlob(topology
->attributes
, key
, buf
, size
);
503 static HRESULT WINAPI
topology_SetUnknown(IMFTopology
*iface
, REFGUID key
, IUnknown
*unknown
)
505 struct topology
*topology
= impl_from_IMFTopology(iface
);
507 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), unknown
);
509 return IMFAttributes_SetUnknown(topology
->attributes
, key
, unknown
);
512 static HRESULT WINAPI
topology_LockStore(IMFTopology
*iface
)
514 struct topology
*topology
= impl_from_IMFTopology(iface
);
516 TRACE("%p.\n", iface
);
518 return IMFAttributes_LockStore(topology
->attributes
);
521 static HRESULT WINAPI
topology_UnlockStore(IMFTopology
*iface
)
523 struct topology
*topology
= impl_from_IMFTopology(iface
);
525 TRACE("%p.\n", iface
);
527 return IMFAttributes_UnlockStore(topology
->attributes
);
530 static HRESULT WINAPI
topology_GetCount(IMFTopology
*iface
, UINT32
*count
)
532 struct topology
*topology
= impl_from_IMFTopology(iface
);
534 TRACE("%p, %p.\n", iface
, count
);
536 return IMFAttributes_GetCount(topology
->attributes
, count
);
539 static HRESULT WINAPI
topology_GetItemByIndex(IMFTopology
*iface
, UINT32 index
, GUID
*key
, PROPVARIANT
*value
)
541 struct topology
*topology
= impl_from_IMFTopology(iface
);
543 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
545 return IMFAttributes_GetItemByIndex(topology
->attributes
, index
, key
, value
);
548 static HRESULT WINAPI
topology_CopyAllItems(IMFTopology
*iface
, IMFAttributes
*dest
)
550 struct topology
*topology
= impl_from_IMFTopology(iface
);
552 TRACE("%p, %p.\n", iface
, dest
);
554 return IMFAttributes_CopyAllItems(topology
->attributes
, dest
);
557 static HRESULT WINAPI
topology_GetTopologyID(IMFTopology
*iface
, TOPOID
*id
)
559 struct topology
*topology
= impl_from_IMFTopology(iface
);
561 TRACE("%p, %p.\n", iface
, id
);
571 static HRESULT
topology_get_node_by_id(const struct topology
*topology
, TOPOID id
, struct topology_node
**node
)
575 for (i
= 0; i
< topology
->nodes
.count
; ++i
)
577 if (topology
->nodes
.nodes
[i
]->id
== id
)
579 *node
= topology
->nodes
.nodes
[i
];
584 return MF_E_NOT_FOUND
;
587 static HRESULT
topology_add_node(struct topology
*topology
, struct topology_node
*node
)
589 struct topology_node
*match
;
594 if (SUCCEEDED(topology_get_node_by_id(topology
, node
->id
, &match
)))
597 if (!mf_array_reserve((void **)&topology
->nodes
.nodes
, &topology
->nodes
.size
, topology
->nodes
.count
+ 1,
598 sizeof(*topology
->nodes
.nodes
)))
600 return E_OUTOFMEMORY
;
603 topology
->nodes
.nodes
[topology
->nodes
.count
++] = node
;
604 IMFTopologyNode_AddRef(&node
->IMFTopologyNode_iface
);
609 static HRESULT WINAPI
topology_AddNode(IMFTopology
*iface
, IMFTopologyNode
*node_iface
)
611 struct topology
*topology
= impl_from_IMFTopology(iface
);
612 struct topology_node
*node
= unsafe_impl_from_IMFTopologyNode(node_iface
);
614 TRACE("%p, %p.\n", iface
, node_iface
);
616 return topology_add_node(topology
, node
);
619 static HRESULT WINAPI
topology_RemoveNode(IMFTopology
*iface
, IMFTopologyNode
*node
)
621 struct topology
*topology
= impl_from_IMFTopology(iface
);
624 TRACE("%p, %p.\n", iface
, node
);
626 for (i
= 0; i
< topology
->nodes
.count
; ++i
)
628 if (&topology
->nodes
.nodes
[i
]->IMFTopologyNode_iface
== node
)
630 topology_node_disconnect(topology
->nodes
.nodes
[i
]);
631 IMFTopologyNode_Release(&topology
->nodes
.nodes
[i
]->IMFTopologyNode_iface
);
632 count
= topology
->nodes
.count
- i
- 1;
635 memmove(&topology
->nodes
.nodes
[i
], &topology
->nodes
.nodes
[i
+ 1],
636 count
* sizeof(*topology
->nodes
.nodes
));
638 topology
->nodes
.count
--;
646 static HRESULT WINAPI
topology_GetNodeCount(IMFTopology
*iface
, WORD
*count
)
648 struct topology
*topology
= impl_from_IMFTopology(iface
);
650 TRACE("%p, %p.\n", iface
, count
);
655 *count
= topology
->nodes
.count
;
660 static HRESULT WINAPI
topology_GetNode(IMFTopology
*iface
, WORD index
, IMFTopologyNode
**node
)
662 struct topology
*topology
= impl_from_IMFTopology(iface
);
664 TRACE("%p, %u, %p.\n", iface
, index
, node
);
669 if (index
>= topology
->nodes
.count
)
670 return MF_E_INVALIDINDEX
;
672 *node
= &topology
->nodes
.nodes
[index
]->IMFTopologyNode_iface
;
673 IMFTopologyNode_AddRef(*node
);
678 static HRESULT WINAPI
topology_Clear(IMFTopology
*iface
)
680 struct topology
*topology
= impl_from_IMFTopology(iface
);
682 TRACE("%p.\n", iface
);
684 topology_clear(topology
);
688 static HRESULT WINAPI
topology_CloneFrom(IMFTopology
*iface
, IMFTopology
*src
)
690 struct topology
*topology
= impl_from_IMFTopology(iface
);
691 struct topology
*src_topology
= unsafe_impl_from_IMFTopology(src
);
692 struct topology_node
*node
;
696 TRACE("%p, %p.\n", iface
, src
);
698 topology_clear(topology
);
701 for (i
= 0; i
< src_topology
->nodes
.count
; ++i
)
703 if (FAILED(hr
= create_topology_node(src_topology
->nodes
.nodes
[i
]->node_type
, &node
)))
705 WARN("Failed to create a node, hr %#x.\n", hr
);
709 if (SUCCEEDED(hr
= IMFTopologyNode_CloneFrom(&node
->IMFTopologyNode_iface
,
710 &src_topology
->nodes
.nodes
[i
]->IMFTopologyNode_iface
)))
712 topology_add_node(topology
, node
);
715 IMFTopologyNode_Release(&node
->IMFTopologyNode_iface
);
718 /* Clone connections. */
719 for (i
= 0; i
< src_topology
->nodes
.count
; ++i
)
721 const struct node_streams
*outputs
= &src_topology
->nodes
.nodes
[i
]->outputs
;
723 for (j
= 0; j
< outputs
->count
; ++j
)
725 DWORD input_index
= outputs
->streams
[j
].connection_stream
;
726 TOPOID id
= outputs
->streams
[j
].connection
->id
;
728 /* Skip node lookup in destination topology, assuming same node order. */
729 if (SUCCEEDED(hr
= topology_get_node_by_id(topology
, id
, &node
)))
730 topology_node_connect_output(topology
->nodes
.nodes
[i
], j
, node
, input_index
);
734 /* Copy attributes and id. */
735 hr
= IMFTopology_CopyAllItems(src
, (IMFAttributes
*)&topology
->IMFTopology_iface
);
737 topology
->id
= src_topology
->id
;
742 static HRESULT WINAPI
topology_GetNodeByID(IMFTopology
*iface
, TOPOID id
, IMFTopologyNode
**ret
)
744 struct topology
*topology
= impl_from_IMFTopology(iface
);
745 struct topology_node
*node
;
748 TRACE("%p, %p.\n", iface
, ret
);
750 if (SUCCEEDED(hr
= topology_get_node_by_id(topology
, id
, &node
)))
752 *ret
= &node
->IMFTopologyNode_iface
;
753 IMFTopologyNode_AddRef(*ret
);
761 static HRESULT
topology_get_node_collection(const struct topology
*topology
, MF_TOPOLOGY_TYPE node_type
,
762 IMFCollection
**collection
)
770 if (FAILED(hr
= MFCreateCollection(collection
)))
773 for (i
= 0; i
< topology
->nodes
.count
; ++i
)
775 if (topology
->nodes
.nodes
[i
]->node_type
== node_type
)
777 if (FAILED(hr
= IMFCollection_AddElement(*collection
,
778 (IUnknown
*)&topology
->nodes
.nodes
[i
]->IMFTopologyNode_iface
)))
780 IMFCollection_Release(*collection
);
790 static HRESULT WINAPI
topology_GetSourceNodeCollection(IMFTopology
*iface
, IMFCollection
**collection
)
792 struct topology
*topology
= impl_from_IMFTopology(iface
);
794 TRACE("%p, %p.\n", iface
, collection
);
796 return topology_get_node_collection(topology
, MF_TOPOLOGY_SOURCESTREAM_NODE
, collection
);
799 static HRESULT WINAPI
topology_GetOutputNodeCollection(IMFTopology
*iface
, IMFCollection
**collection
)
801 struct topology
*topology
= impl_from_IMFTopology(iface
);
803 TRACE("%p, %p.\n", iface
, collection
);
805 return topology_get_node_collection(topology
, MF_TOPOLOGY_OUTPUT_NODE
, collection
);
808 static const IMFTopologyVtbl topologyvtbl
=
810 topology_QueryInterface
,
814 topology_GetItemType
,
815 topology_CompareItem
,
821 topology_GetStringLength
,
823 topology_GetAllocatedString
,
824 topology_GetBlobSize
,
826 topology_GetAllocatedBlob
,
830 topology_DeleteAllItems
,
839 topology_UnlockStore
,
841 topology_GetItemByIndex
,
842 topology_CopyAllItems
,
843 topology_GetTopologyID
,
846 topology_GetNodeCount
,
850 topology_GetNodeByID
,
851 topology_GetSourceNodeCollection
,
852 topology_GetOutputNodeCollection
,
855 static struct topology
*unsafe_impl_from_IMFTopology(IMFTopology
*iface
)
857 if (!iface
|| iface
->lpVtbl
!= &topologyvtbl
)
859 return impl_from_IMFTopology(iface
);
862 static TOPOID
topology_generate_id(void)
868 old
= next_topology_id
;
870 while (InterlockedCompareExchange64((LONG64
*)&next_topology_id
, old
+ 1, old
) != old
);
872 return next_topology_id
;
875 /***********************************************************************
876 * MFCreateTopology (mf.@)
878 HRESULT WINAPI
MFCreateTopology(IMFTopology
**topology
)
880 struct topology
*object
;
883 TRACE("%p.\n", topology
);
888 object
= heap_alloc_zero(sizeof(*object
));
890 return E_OUTOFMEMORY
;
892 object
->IMFTopology_iface
.lpVtbl
= &topologyvtbl
;
893 object
->refcount
= 1;
895 hr
= MFCreateAttributes(&object
->attributes
, 0);
898 IMFTopology_Release(&object
->IMFTopology_iface
);
902 object
->id
= topology_generate_id();
904 *topology
= &object
->IMFTopology_iface
;
909 static HRESULT WINAPI
topology_node_QueryInterface(IMFTopologyNode
*iface
, REFIID riid
, void **out
)
911 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
913 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
915 if (IsEqualIID(riid
, &IID_IMFTopologyNode
) ||
916 IsEqualIID(riid
, &IID_IMFAttributes
) ||
917 IsEqualIID(riid
, &IID_IUnknown
))
919 *out
= &node
->IMFTopologyNode_iface
;
920 IMFTopologyNode_AddRef(iface
);
924 WARN("Unsupported interface %s.\n", debugstr_guid(riid
));
927 return E_NOINTERFACE
;
930 static ULONG WINAPI
topology_node_AddRef(IMFTopologyNode
*iface
)
932 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
933 ULONG refcount
= InterlockedIncrement(&node
->refcount
);
935 TRACE("%p, refcount %u.\n", iface
, refcount
);
940 static ULONG WINAPI
topology_node_Release(IMFTopologyNode
*iface
)
942 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
943 ULONG refcount
= InterlockedDecrement(&node
->refcount
);
946 TRACE("%p, refcount %u.\n", iface
, refcount
);
951 IUnknown_Release(node
->object
);
952 if (node
->input_type
)
953 IMFMediaType_Release(node
->input_type
);
954 for (i
= 0; i
< node
->inputs
.count
; ++i
)
956 if (node
->inputs
.streams
[i
].preferred_type
)
957 IMFMediaType_Release(node
->inputs
.streams
[i
].preferred_type
);
959 for (i
= 0; i
< node
->outputs
.count
; ++i
)
961 if (node
->outputs
.streams
[i
].preferred_type
)
962 IMFMediaType_Release(node
->outputs
.streams
[i
].preferred_type
);
964 heap_free(node
->inputs
.streams
);
965 heap_free(node
->outputs
.streams
);
966 IMFAttributes_Release(node
->attributes
);
967 DeleteCriticalSection(&node
->cs
);
974 static HRESULT WINAPI
topology_node_GetItem(IMFTopologyNode
*iface
, REFGUID key
, PROPVARIANT
*value
)
976 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
978 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
980 return IMFAttributes_GetItem(node
->attributes
, key
, value
);
983 static HRESULT WINAPI
topology_node_GetItemType(IMFTopologyNode
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
985 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
987 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), type
);
989 return IMFAttributes_GetItemType(node
->attributes
, key
, type
);
992 static HRESULT WINAPI
topology_node_CompareItem(IMFTopologyNode
*iface
, REFGUID key
, REFPROPVARIANT value
, BOOL
*result
)
994 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
996 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, result
);
998 return IMFAttributes_CompareItem(node
->attributes
, key
, value
, result
);
1001 static HRESULT WINAPI
topology_node_Compare(IMFTopologyNode
*iface
, IMFAttributes
*theirs
,
1002 MF_ATTRIBUTES_MATCH_TYPE type
, BOOL
*result
)
1004 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1006 TRACE("%p, %p, %d, %p.\n", iface
, theirs
, type
, result
);
1008 return IMFAttributes_Compare(node
->attributes
, theirs
, type
, result
);
1011 static HRESULT WINAPI
topology_node_GetUINT32(IMFTopologyNode
*iface
, REFGUID key
, UINT32
*value
)
1013 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1015 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1017 return IMFAttributes_GetUINT32(node
->attributes
, key
, value
);
1020 static HRESULT WINAPI
topology_node_GetUINT64(IMFTopologyNode
*iface
, REFGUID key
, UINT64
*value
)
1022 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1024 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1026 return IMFAttributes_GetUINT64(node
->attributes
, key
, value
);
1029 static HRESULT WINAPI
topology_node_GetDouble(IMFTopologyNode
*iface
, REFGUID key
, double *value
)
1031 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1033 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1035 return IMFAttributes_GetDouble(node
->attributes
, key
, value
);
1038 static HRESULT WINAPI
topology_node_GetGUID(IMFTopologyNode
*iface
, REFGUID key
, GUID
*value
)
1040 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1042 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1044 return IMFAttributes_GetGUID(node
->attributes
, key
, value
);
1047 static HRESULT WINAPI
topology_node_GetStringLength(IMFTopologyNode
*iface
, REFGUID key
, UINT32
*length
)
1049 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1051 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), length
);
1053 return IMFAttributes_GetStringLength(node
->attributes
, key
, length
);
1056 static HRESULT WINAPI
topology_node_GetString(IMFTopologyNode
*iface
, REFGUID key
, WCHAR
*value
,
1057 UINT32 size
, UINT32
*length
)
1059 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1061 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), value
, size
, length
);
1063 return IMFAttributes_GetString(node
->attributes
, key
, value
, size
, length
);
1066 static HRESULT WINAPI
topology_node_GetAllocatedString(IMFTopologyNode
*iface
, REFGUID key
,
1067 WCHAR
**value
, UINT32
*length
)
1069 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1071 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, length
);
1073 return IMFAttributes_GetAllocatedString(node
->attributes
, key
, value
, length
);
1076 static HRESULT WINAPI
topology_node_GetBlobSize(IMFTopologyNode
*iface
, REFGUID key
, UINT32
*size
)
1078 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1080 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), size
);
1082 return IMFAttributes_GetBlobSize(node
->attributes
, key
, size
);
1085 static HRESULT WINAPI
topology_node_GetBlob(IMFTopologyNode
*iface
, REFGUID key
, UINT8
*buf
,
1086 UINT32 bufsize
, UINT32
*blobsize
)
1088 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1090 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), buf
, bufsize
, blobsize
);
1092 return IMFAttributes_GetBlob(node
->attributes
, key
, buf
, bufsize
, blobsize
);
1095 static HRESULT WINAPI
topology_node_GetAllocatedBlob(IMFTopologyNode
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
1097 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1099 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), buf
, size
);
1101 return IMFAttributes_GetAllocatedBlob(node
->attributes
, key
, buf
, size
);
1104 static HRESULT WINAPI
topology_node_GetUnknown(IMFTopologyNode
*iface
, REFGUID key
, REFIID riid
, void **ppv
)
1106 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1108 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(key
), debugstr_guid(riid
), ppv
);
1110 return IMFAttributes_GetUnknown(node
->attributes
, key
, riid
, ppv
);
1113 static HRESULT WINAPI
topology_node_SetItem(IMFTopologyNode
*iface
, REFGUID key
, REFPROPVARIANT value
)
1115 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1117 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1119 return IMFAttributes_SetItem(node
->attributes
, key
, value
);
1122 static HRESULT WINAPI
topology_node_DeleteItem(IMFTopologyNode
*iface
, REFGUID key
)
1124 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1126 TRACE("%p, %s.\n", iface
, debugstr_guid(key
));
1128 return IMFAttributes_DeleteItem(node
->attributes
, key
);
1131 static HRESULT WINAPI
topology_node_DeleteAllItems(IMFTopologyNode
*iface
)
1133 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1135 TRACE("%p.\n", iface
);
1137 return IMFAttributes_DeleteAllItems(node
->attributes
);
1140 static HRESULT WINAPI
topology_node_SetUINT32(IMFTopologyNode
*iface
, REFGUID key
, UINT32 value
)
1142 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1144 TRACE("%p, %s, %d.\n", iface
, debugstr_guid(key
), value
);
1146 return IMFAttributes_SetUINT32(node
->attributes
, key
, value
);
1149 static HRESULT WINAPI
topology_node_SetUINT64(IMFTopologyNode
*iface
, REFGUID key
, UINT64 value
)
1151 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1153 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), wine_dbgstr_longlong(value
));
1155 return IMFAttributes_SetUINT64(node
->attributes
, key
, value
);
1158 static HRESULT WINAPI
topology_node_SetDouble(IMFTopologyNode
*iface
, REFGUID key
, double value
)
1160 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1162 TRACE("%p, %s, %f.\n", iface
, debugstr_guid(key
), value
);
1164 return IMFAttributes_SetDouble(node
->attributes
, key
, value
);
1167 static HRESULT WINAPI
topology_node_SetGUID(IMFTopologyNode
*iface
, REFGUID key
, REFGUID value
)
1169 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1171 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_guid(value
));
1173 return IMFAttributes_SetGUID(node
->attributes
, key
, value
);
1176 static HRESULT WINAPI
topology_node_SetString(IMFTopologyNode
*iface
, REFGUID key
, const WCHAR
*value
)
1178 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1180 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_w(value
));
1182 return IMFAttributes_SetString(node
->attributes
, key
, value
);
1185 static HRESULT WINAPI
topology_node_SetBlob(IMFTopologyNode
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
1187 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1189 TRACE("%p, %s, %p, %d.\n", iface
, debugstr_guid(key
), buf
, size
);
1191 return IMFAttributes_SetBlob(node
->attributes
, key
, buf
, size
);
1194 static HRESULT WINAPI
topology_node_SetUnknown(IMFTopologyNode
*iface
, REFGUID key
, IUnknown
*unknown
)
1196 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1198 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), unknown
);
1200 return IMFAttributes_SetUnknown(node
->attributes
, key
, unknown
);
1203 static HRESULT WINAPI
topology_node_LockStore(IMFTopologyNode
*iface
)
1205 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1207 TRACE("%p.\n", iface
);
1209 return IMFAttributes_LockStore(node
->attributes
);
1212 static HRESULT WINAPI
topology_node_UnlockStore(IMFTopologyNode
*iface
)
1214 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1216 TRACE("%p.\n", iface
);
1218 return IMFAttributes_UnlockStore(node
->attributes
);
1221 static HRESULT WINAPI
topology_node_GetCount(IMFTopologyNode
*iface
, UINT32
*count
)
1223 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1225 TRACE("%p, %p.\n", iface
, count
);
1227 return IMFAttributes_GetCount(node
->attributes
, count
);
1230 static HRESULT WINAPI
topology_node_GetItemByIndex(IMFTopologyNode
*iface
, UINT32 index
, GUID
*key
, PROPVARIANT
*value
)
1232 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1234 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
1236 return IMFAttributes_GetItemByIndex(node
->attributes
, index
, key
, value
);
1239 static HRESULT WINAPI
topology_node_CopyAllItems(IMFTopologyNode
*iface
, IMFAttributes
*dest
)
1241 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1243 TRACE("%p, %p.\n", iface
, dest
);
1245 return IMFAttributes_CopyAllItems(node
->attributes
, dest
);
1248 static HRESULT
topology_node_set_object(struct topology_node
*node
, IUnknown
*object
)
1250 static const GUID
*iids
[3] = { &IID_IPersist
, &IID_IPersistStorage
, &IID_IPersistPropertyBag
};
1251 IPersist
*persist
= NULL
;
1257 has_object_id
= IMFAttributes_GetGUID(node
->attributes
, &MF_TOPONODE_TRANSFORM_OBJECTID
, &object_id
) == S_OK
;
1259 if (object
&& !has_object_id
)
1261 for (i
= 0; i
< ARRAY_SIZE(iids
); ++i
)
1264 if (SUCCEEDED(hr
= IUnknown_QueryInterface(object
, iids
[i
], (void **)&persist
)))
1270 if (FAILED(hr
= IPersist_GetClassID(persist
, &object_id
)))
1272 IPersist_Release(persist
);
1278 EnterCriticalSection(&node
->cs
);
1281 IUnknown_Release(node
->object
);
1282 node
->object
= object
;
1284 IUnknown_AddRef(node
->object
);
1287 IMFAttributes_SetGUID(node
->attributes
, &MF_TOPONODE_TRANSFORM_OBJECTID
, &object_id
);
1289 LeaveCriticalSection(&node
->cs
);
1292 IPersist_Release(persist
);
1297 static HRESULT WINAPI
topology_node_SetObject(IMFTopologyNode
*iface
, IUnknown
*object
)
1299 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1301 TRACE("%p, %p.\n", iface
, object
);
1303 return topology_node_set_object(node
, object
);
1306 static HRESULT WINAPI
topology_node_GetObject(IMFTopologyNode
*iface
, IUnknown
**object
)
1308 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1310 TRACE("%p, %p.\n", iface
, object
);
1315 EnterCriticalSection(&node
->cs
);
1317 *object
= node
->object
;
1319 IUnknown_AddRef(*object
);
1321 LeaveCriticalSection(&node
->cs
);
1323 return *object
? S_OK
: E_FAIL
;
1326 static HRESULT WINAPI
topology_node_GetNodeType(IMFTopologyNode
*iface
, MF_TOPOLOGY_TYPE
*node_type
)
1328 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1330 TRACE("%p, %p.\n", iface
, node_type
);
1332 *node_type
= node
->node_type
;
1337 static HRESULT WINAPI
topology_node_GetTopoNodeID(IMFTopologyNode
*iface
, TOPOID
*id
)
1339 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1341 TRACE("%p, %p.\n", iface
, id
);
1348 static HRESULT WINAPI
topology_node_SetTopoNodeID(IMFTopologyNode
*iface
, TOPOID id
)
1350 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1352 TRACE("%p, %s.\n", iface
, wine_dbgstr_longlong(id
));
1359 static HRESULT WINAPI
topology_node_GetInputCount(IMFTopologyNode
*iface
, DWORD
*count
)
1361 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1363 TRACE("%p, %p.\n", iface
, count
);
1365 *count
= node
->inputs
.count
;
1370 static HRESULT WINAPI
topology_node_GetOutputCount(IMFTopologyNode
*iface
, DWORD
*count
)
1372 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1374 TRACE("%p, %p.\n", iface
, count
);
1376 *count
= node
->outputs
.count
;
1381 static void topology_node_set_stream_type(struct node_stream
*stream
, IMFMediaType
*mediatype
)
1383 if (stream
->preferred_type
)
1384 IMFMediaType_Release(stream
->preferred_type
);
1385 stream
->preferred_type
= mediatype
;
1386 if (stream
->preferred_type
)
1387 IMFMediaType_AddRef(stream
->preferred_type
);
1390 static HRESULT
topology_node_connect_output(struct topology_node
*node
, DWORD output_index
,
1391 struct topology_node
*connection
, DWORD input_index
)
1393 struct node_stream
*stream
;
1396 if (node
->node_type
== MF_TOPOLOGY_OUTPUT_NODE
|| connection
->node_type
== MF_TOPOLOGY_SOURCESTREAM_NODE
)
1399 EnterCriticalSection(&node
->cs
);
1400 EnterCriticalSection(&connection
->cs
);
1402 topology_node_disconnect_output(node
, output_index
);
1403 if (input_index
< connection
->inputs
.count
)
1405 stream
= &connection
->inputs
.streams
[input_index
];
1406 if (stream
->connection
)
1407 topology_node_disconnect_output(stream
->connection
, stream
->connection_stream
);
1410 hr
= topology_node_reserve_streams(&node
->outputs
, output_index
);
1413 size_t old_count
= connection
->inputs
.count
;
1414 hr
= topology_node_reserve_streams(&connection
->inputs
, input_index
);
1415 if (SUCCEEDED(hr
) && !old_count
&& connection
->input_type
)
1417 topology_node_set_stream_type(connection
->inputs
.streams
, connection
->input_type
);
1418 IMFMediaType_Release(connection
->input_type
);
1419 connection
->input_type
= NULL
;
1425 node
->outputs
.streams
[output_index
].connection
= connection
;
1426 IMFTopologyNode_AddRef(&node
->outputs
.streams
[output_index
].connection
->IMFTopologyNode_iface
);
1427 node
->outputs
.streams
[output_index
].connection_stream
= input_index
;
1428 connection
->inputs
.streams
[input_index
].connection
= node
;
1429 IMFTopologyNode_AddRef(&connection
->inputs
.streams
[input_index
].connection
->IMFTopologyNode_iface
);
1430 connection
->inputs
.streams
[input_index
].connection_stream
= output_index
;
1433 LeaveCriticalSection(&connection
->cs
);
1434 LeaveCriticalSection(&node
->cs
);
1439 static HRESULT WINAPI
topology_node_ConnectOutput(IMFTopologyNode
*iface
, DWORD output_index
,
1440 IMFTopologyNode
*peer
, DWORD input_index
)
1442 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1443 struct topology_node
*connection
= unsafe_impl_from_IMFTopologyNode(peer
);
1445 TRACE("%p, %u, %p, %u.\n", iface
, output_index
, peer
, input_index
);
1449 WARN("External node implementations are not supported.\n");
1450 return E_UNEXPECTED
;
1453 return topology_node_connect_output(node
, output_index
, connection
, input_index
);
1456 static HRESULT WINAPI
topology_node_DisconnectOutput(IMFTopologyNode
*iface
, DWORD output_index
)
1458 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1460 TRACE("%p, %u.\n", iface
, output_index
);
1462 return topology_node_disconnect_output(node
, output_index
);
1465 static HRESULT WINAPI
topology_node_GetInput(IMFTopologyNode
*iface
, DWORD input_index
, IMFTopologyNode
**ret
,
1466 DWORD
*output_index
)
1468 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1471 TRACE("%p, %u, %p, %p.\n", iface
, input_index
, ret
, output_index
);
1473 EnterCriticalSection(&node
->cs
);
1475 if (input_index
< node
->inputs
.count
)
1477 const struct node_stream
*stream
= &node
->inputs
.streams
[input_index
];
1479 if (stream
->connection
)
1481 *ret
= &stream
->connection
->IMFTopologyNode_iface
;
1482 IMFTopologyNode_AddRef(*ret
);
1483 *output_index
= stream
->connection_stream
;
1486 hr
= MF_E_NOT_FOUND
;
1491 LeaveCriticalSection(&node
->cs
);
1496 static HRESULT WINAPI
topology_node_GetOutput(IMFTopologyNode
*iface
, DWORD output_index
, IMFTopologyNode
**ret
,
1499 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1502 TRACE("%p, %u, %p, %p.\n", iface
, output_index
, ret
, input_index
);
1504 EnterCriticalSection(&node
->cs
);
1506 if (output_index
< node
->outputs
.count
)
1508 const struct node_stream
*stream
= &node
->outputs
.streams
[output_index
];
1510 if (stream
->connection
)
1512 *ret
= &stream
->connection
->IMFTopologyNode_iface
;
1513 IMFTopologyNode_AddRef(*ret
);
1514 *input_index
= stream
->connection_stream
;
1517 hr
= MF_E_NOT_FOUND
;
1522 LeaveCriticalSection(&node
->cs
);
1527 static HRESULT WINAPI
topology_node_SetOutputPrefType(IMFTopologyNode
*iface
, DWORD index
, IMFMediaType
*mediatype
)
1529 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1532 TRACE("%p, %u, %p.\n", iface
, index
, mediatype
);
1534 EnterCriticalSection(&node
->cs
);
1536 if (node
->node_type
!= MF_TOPOLOGY_OUTPUT_NODE
)
1538 if (SUCCEEDED(hr
= topology_node_reserve_streams(&node
->outputs
, index
)))
1539 topology_node_set_stream_type(&node
->outputs
.streams
[index
], mediatype
);
1544 LeaveCriticalSection(&node
->cs
);
1549 static HRESULT
topology_node_get_pref_type(struct node_streams
*streams
, unsigned int index
, IMFMediaType
**mediatype
)
1551 *mediatype
= streams
->streams
[index
].preferred_type
;
1554 IMFMediaType_AddRef(*mediatype
);
1561 static HRESULT WINAPI
topology_node_GetOutputPrefType(IMFTopologyNode
*iface
, DWORD index
, IMFMediaType
**mediatype
)
1563 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1566 TRACE("%p, %u, %p.\n", iface
, index
, mediatype
);
1568 EnterCriticalSection(&node
->cs
);
1570 if (index
< node
->outputs
.count
)
1571 hr
= topology_node_get_pref_type(&node
->outputs
, index
, mediatype
);
1575 LeaveCriticalSection(&node
->cs
);
1580 static HRESULT WINAPI
topology_node_SetInputPrefType(IMFTopologyNode
*iface
, DWORD index
, IMFMediaType
*mediatype
)
1582 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1585 TRACE("%p, %u, %p.\n", iface
, index
, mediatype
);
1587 EnterCriticalSection(&node
->cs
);
1589 switch (node
->node_type
)
1591 case MF_TOPOLOGY_TEE_NODE
:
1594 hr
= MF_E_INVALIDTYPE
;
1597 if (node
->inputs
.count
)
1598 topology_node_set_stream_type(&node
->inputs
.streams
[index
], mediatype
);
1601 if (node
->input_type
)
1602 IMFMediaType_Release(node
->input_type
);
1603 node
->input_type
= mediatype
;
1604 if (node
->input_type
)
1605 IMFMediaType_AddRef(node
->input_type
);
1608 case MF_TOPOLOGY_SOURCESTREAM_NODE
:
1612 if (SUCCEEDED(hr
= topology_node_reserve_streams(&node
->inputs
, index
)))
1613 topology_node_set_stream_type(&node
->inputs
.streams
[index
], mediatype
);
1616 LeaveCriticalSection(&node
->cs
);
1621 static HRESULT WINAPI
topology_node_GetInputPrefType(IMFTopologyNode
*iface
, DWORD index
, IMFMediaType
**mediatype
)
1623 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1626 TRACE("%p, %u, %p.\n", iface
, index
, mediatype
);
1628 EnterCriticalSection(&node
->cs
);
1630 if (index
< node
->inputs
.count
)
1632 hr
= topology_node_get_pref_type(&node
->inputs
, index
, mediatype
);
1634 else if (node
->node_type
== MF_TOPOLOGY_TEE_NODE
&& node
->input_type
)
1636 *mediatype
= node
->input_type
;
1637 IMFMediaType_AddRef(*mediatype
);
1642 LeaveCriticalSection(&node
->cs
);
1647 static HRESULT WINAPI
topology_node_CloneFrom(IMFTopologyNode
*iface
, IMFTopologyNode
*src_node
)
1649 struct topology_node
*node
= impl_from_IMFTopologyNode(iface
);
1650 MF_TOPOLOGY_TYPE node_type
;
1651 IMFMediaType
*mediatype
;
1657 TRACE("%p, %p.\n", iface
, src_node
);
1659 if (FAILED(hr
= IMFTopologyNode_GetNodeType(src_node
, &node_type
)))
1662 if (node
->node_type
!= node_type
)
1663 return MF_E_INVALIDREQUEST
;
1665 if (FAILED(hr
= IMFTopologyNode_GetTopoNodeID(src_node
, &topoid
)))
1669 IMFTopologyNode_GetObject(src_node
, &object
);
1671 EnterCriticalSection(&node
->cs
);
1673 hr
= IMFTopologyNode_CopyAllItems(src_node
, node
->attributes
);
1676 hr
= topology_node_set_object(node
, object
);
1681 if (SUCCEEDED(IMFTopologyNode_GetInputCount(src_node
, &count
)))
1683 for (i
= 0; i
< count
; ++i
)
1685 if (SUCCEEDED(IMFTopologyNode_GetInputPrefType(src_node
, i
, &mediatype
)))
1687 IMFTopologyNode_SetInputPrefType(iface
, i
, mediatype
);
1688 IMFMediaType_Release(mediatype
);
1693 if (SUCCEEDED(IMFTopologyNode_GetOutputCount(src_node
, &count
)))
1695 for (i
= 0; i
< count
; ++i
)
1697 if (SUCCEEDED(IMFTopologyNode_GetOutputPrefType(src_node
, i
, &mediatype
)))
1699 IMFTopologyNode_SetOutputPrefType(iface
, i
, mediatype
);
1700 IMFMediaType_Release(mediatype
);
1705 LeaveCriticalSection(&node
->cs
);
1708 IUnknown_Release(object
);
1713 static const IMFTopologyNodeVtbl topologynodevtbl
=
1715 topology_node_QueryInterface
,
1716 topology_node_AddRef
,
1717 topology_node_Release
,
1718 topology_node_GetItem
,
1719 topology_node_GetItemType
,
1720 topology_node_CompareItem
,
1721 topology_node_Compare
,
1722 topology_node_GetUINT32
,
1723 topology_node_GetUINT64
,
1724 topology_node_GetDouble
,
1725 topology_node_GetGUID
,
1726 topology_node_GetStringLength
,
1727 topology_node_GetString
,
1728 topology_node_GetAllocatedString
,
1729 topology_node_GetBlobSize
,
1730 topology_node_GetBlob
,
1731 topology_node_GetAllocatedBlob
,
1732 topology_node_GetUnknown
,
1733 topology_node_SetItem
,
1734 topology_node_DeleteItem
,
1735 topology_node_DeleteAllItems
,
1736 topology_node_SetUINT32
,
1737 topology_node_SetUINT64
,
1738 topology_node_SetDouble
,
1739 topology_node_SetGUID
,
1740 topology_node_SetString
,
1741 topology_node_SetBlob
,
1742 topology_node_SetUnknown
,
1743 topology_node_LockStore
,
1744 topology_node_UnlockStore
,
1745 topology_node_GetCount
,
1746 topology_node_GetItemByIndex
,
1747 topology_node_CopyAllItems
,
1748 topology_node_SetObject
,
1749 topology_node_GetObject
,
1750 topology_node_GetNodeType
,
1751 topology_node_GetTopoNodeID
,
1752 topology_node_SetTopoNodeID
,
1753 topology_node_GetInputCount
,
1754 topology_node_GetOutputCount
,
1755 topology_node_ConnectOutput
,
1756 topology_node_DisconnectOutput
,
1757 topology_node_GetInput
,
1758 topology_node_GetOutput
,
1759 topology_node_SetOutputPrefType
,
1760 topology_node_GetOutputPrefType
,
1761 topology_node_SetInputPrefType
,
1762 topology_node_GetInputPrefType
,
1763 topology_node_CloneFrom
,
1766 static HRESULT
create_topology_node(MF_TOPOLOGY_TYPE node_type
, struct topology_node
**node
)
1770 *node
= heap_alloc_zero(sizeof(**node
));
1772 return E_OUTOFMEMORY
;
1774 (*node
)->IMFTopologyNode_iface
.lpVtbl
= &topologynodevtbl
;
1775 (*node
)->refcount
= 1;
1776 (*node
)->node_type
= node_type
;
1777 hr
= MFCreateAttributes(&(*node
)->attributes
, 0);
1783 (*node
)->id
= ((TOPOID
)GetCurrentProcessId() << 32) | InterlockedIncrement(&next_node_id
);
1784 InitializeCriticalSection(&(*node
)->cs
);
1789 /***********************************************************************
1790 * MFCreateTopologyNode (mf.@)
1792 HRESULT WINAPI
MFCreateTopologyNode(MF_TOPOLOGY_TYPE node_type
, IMFTopologyNode
**node
)
1794 struct topology_node
*object
;
1797 TRACE("%d, %p.\n", node_type
, node
);
1802 hr
= create_topology_node(node_type
, &object
);
1804 *node
= &object
->IMFTopologyNode_iface
;
1809 /***********************************************************************
1810 * MFGetTopoNodeCurrentType (mf.@)
1812 HRESULT WINAPI
MFGetTopoNodeCurrentType(IMFTopologyNode
*node
, DWORD stream
, BOOL output
, IMFMediaType
**type
)
1814 IMFMediaTypeHandler
*type_handler
;
1815 MF_TOPOLOGY_TYPE node_type
;
1816 IMFStreamSink
*stream_sink
;
1817 IMFStreamDescriptor
*sd
;
1818 IMFTransform
*transform
;
1819 UINT32 primary_output
;
1823 TRACE("%p, %u, %d, %p.\n", node
, stream
, output
, type
);
1825 if (FAILED(hr
= IMFTopologyNode_GetNodeType(node
, &node_type
)))
1830 case MF_TOPOLOGY_OUTPUT_NODE
:
1831 if (FAILED(hr
= IMFTopologyNode_GetObject(node
, &object
)))
1834 hr
= IUnknown_QueryInterface(object
, &IID_IMFStreamSink
, (void **)&stream_sink
);
1835 IUnknown_Release(object
);
1838 hr
= IMFStreamSink_GetMediaTypeHandler(stream_sink
, &type_handler
);
1839 IMFStreamSink_Release(stream_sink
);
1843 hr
= IMFMediaTypeHandler_GetCurrentMediaType(type_handler
, type
);
1844 IMFMediaTypeHandler_Release(type_handler
);
1848 case MF_TOPOLOGY_SOURCESTREAM_NODE
:
1849 if (FAILED(hr
= IMFTopologyNode_GetUnknown(node
, &MF_TOPONODE_STREAM_DESCRIPTOR
, &IID_IMFStreamDescriptor
,
1855 hr
= IMFStreamDescriptor_GetMediaTypeHandler(sd
, &type_handler
);
1856 IMFStreamDescriptor_Release(sd
);
1859 hr
= IMFMediaTypeHandler_GetCurrentMediaType(type_handler
, type
);
1860 IMFMediaTypeHandler_Release(type_handler
);
1863 case MF_TOPOLOGY_TRANSFORM_NODE
:
1864 if (FAILED(hr
= IMFTopologyNode_GetObject(node
, &object
)))
1867 hr
= IUnknown_QueryInterface(object
, &IID_IMFTransform
, (void **)&transform
);
1868 IUnknown_Release(object
);
1872 hr
= IMFTransform_GetOutputCurrentType(transform
, stream
, type
);
1874 hr
= IMFTransform_GetInputCurrentType(transform
, stream
, type
);
1875 IMFTransform_Release(transform
);
1878 case MF_TOPOLOGY_TEE_NODE
:
1879 if (SUCCEEDED(hr
= IMFTopologyNode_GetInputPrefType(node
, 0, type
)))
1882 if (FAILED(IMFTopologyNode_GetUINT32(node
, &MF_TOPONODE_PRIMARYOUTPUT
, &primary_output
)))
1885 hr
= IMFTopologyNode_GetOutputPrefType(node
, primary_output
, type
);
1894 static HRESULT WINAPI
topology_loader_QueryInterface(IMFTopoLoader
*iface
, REFIID riid
, void **out
)
1896 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
1898 if (IsEqualIID(riid
, &IID_IMFTopoLoader
) ||
1899 IsEqualIID(riid
, &IID_IUnknown
))
1902 IMFTopoLoader_AddRef(iface
);
1906 WARN("Unsupported %s.\n", debugstr_guid(riid
));
1908 return E_NOINTERFACE
;
1911 static ULONG WINAPI
topology_loader_AddRef(IMFTopoLoader
*iface
)
1913 struct topology_loader
*loader
= impl_from_IMFTopoLoader(iface
);
1914 ULONG refcount
= InterlockedIncrement(&loader
->refcount
);
1916 TRACE("%p, refcount %u.\n", iface
, refcount
);
1921 static ULONG WINAPI
topology_loader_Release(IMFTopoLoader
*iface
)
1923 struct topology_loader
*loader
= impl_from_IMFTopoLoader(iface
);
1924 ULONG refcount
= InterlockedDecrement(&loader
->refcount
);
1926 TRACE("%p, refcount %u.\n", iface
, refcount
);
1936 struct topoloader_context
1938 IMFTopology
*input_topology
;
1939 IMFTopology
*output_topology
;
1940 unsigned int marker
;
1944 static IMFTopologyNode
*topology_loader_get_node_for_marker(struct topoloader_context
*context
, TOPOID
*id
)
1946 IMFTopologyNode
*node
;
1947 unsigned short i
= 0;
1950 while (SUCCEEDED(IMFTopology_GetNode(context
->output_topology
, i
++, &node
)))
1952 if (SUCCEEDED(IMFTopologyNode_GetUINT32(node
, &context
->key
, &value
)) && value
== context
->marker
)
1954 IMFTopologyNode_GetTopoNodeID(node
, id
);
1957 IMFTopologyNode_Release(node
);
1964 static HRESULT
topology_loader_clone_node(struct topoloader_context
*context
, IMFTopologyNode
*node
,
1965 IMFTopologyNode
**ret
, unsigned int marker
)
1967 IMFTopologyNode
*cloned_node
;
1968 MF_TOPOLOGY_TYPE node_type
;
1971 if (ret
) *ret
= NULL
;
1973 IMFTopologyNode_GetNodeType(node
, &node_type
);
1975 if (FAILED(hr
= MFCreateTopologyNode(node_type
, &cloned_node
)))
1978 if (SUCCEEDED(hr
= IMFTopologyNode_CloneFrom(cloned_node
, node
)))
1979 hr
= IMFTopologyNode_SetUINT32(cloned_node
, &context
->key
, marker
);
1982 hr
= IMFTopology_AddNode(context
->output_topology
, cloned_node
);
1984 if (SUCCEEDED(hr
) && ret
)
1987 IMFTopologyNode_AddRef(*ret
);
1990 IMFTopologyNode_Release(cloned_node
);
1995 typedef HRESULT (*p_topology_loader_connect_func
)(struct topoloader_context
*context
, IMFTopologyNode
*upstream_node
,
1996 unsigned int output_index
, IMFTopologyNode
*downstream_node
, unsigned int input_index
);
1998 static HRESULT
topology_loader_connect_source_node(struct topoloader_context
*context
, IMFTopologyNode
*upstream_node
,
1999 unsigned int output_index
, IMFTopologyNode
*downstream_node
, unsigned int input_index
)
2001 FIXME("Unimplemented.\n");
2006 static HRESULT
topology_loader_resolve_branch(struct topoloader_context
*context
, IMFTopologyNode
*upstream_node
,
2007 unsigned int output_index
, IMFTopologyNode
*downstream_node
, unsigned input_index
)
2009 static const p_topology_loader_connect_func connectors
[MF_TOPOLOGY_TEE_NODE
+1][MF_TOPOLOGY_TEE_NODE
+1] =
2011 /* OUTPUT */ { NULL
},
2012 /* SOURCESTREAM */ { topology_loader_connect_source_node
, NULL
, NULL
, NULL
},
2013 /* TRANSFORM */ { NULL
},
2016 MF_TOPOLOGY_TYPE u_type
, d_type
;
2017 IMFTopologyNode
*node
;
2020 /* Downstream node might have already been cloned. */
2021 IMFTopologyNode_GetTopoNodeID(downstream_node
, &id
);
2022 if (FAILED(IMFTopology_GetNodeByID(context
->output_topology
, id
, &node
)))
2023 topology_loader_clone_node(context
, downstream_node
, &node
, context
->marker
+ 1);
2025 IMFTopologyNode_ConnectOutput(upstream_node
, output_index
, node
, input_index
);
2027 IMFTopologyNode_GetNodeType(upstream_node
, &u_type
);
2028 IMFTopologyNode_GetNodeType(downstream_node
, &d_type
);
2030 if (!connectors
[u_type
][d_type
])
2032 WARN("Unsupported branch kind %d -> %d.\n", u_type
, d_type
);
2036 return connectors
[u_type
][d_type
](context
, upstream_node
, output_index
, downstream_node
, input_index
);
2039 static HRESULT
topology_loader_resolve_nodes(struct topoloader_context
*context
, unsigned int *layer_size
)
2041 IMFTopologyNode
*downstream_node
, *node
, *orig_node
;
2042 unsigned int input_index
, size
= 0;
2043 MF_TOPOLOGY_TYPE node_type
;
2047 while ((node
= topology_loader_get_node_for_marker(context
, &id
)))
2051 IMFTopology_GetNodeByID(context
->input_topology
, id
, &orig_node
);
2053 IMFTopologyNode_GetNodeType(node
, &node_type
);
2056 case MF_TOPOLOGY_SOURCESTREAM_NODE
:
2057 if (FAILED(IMFTopologyNode_GetOutput(orig_node
, 0, &downstream_node
, &input_index
)))
2059 IMFTopology_RemoveNode(context
->output_topology
, node
);
2063 hr
= topology_loader_resolve_branch(context
, node
, 0, downstream_node
, input_index
);
2065 case MF_TOPOLOGY_TRANSFORM_NODE
:
2066 case MF_TOPOLOGY_TEE_NODE
:
2067 FIXME("Unsupported node type %d.\n", node_type
);
2070 WARN("Unexpected node type %d.\n", node_type
);
2073 IMFTopologyNode_DeleteItem(node
, &context
->key
);
2084 static HRESULT WINAPI
topology_loader_Load(IMFTopoLoader
*iface
, IMFTopology
*input_topology
,
2085 IMFTopology
**ret_topology
, IMFTopology
*current_topology
)
2087 struct topoloader_context context
= { 0 };
2088 IMFTopology
*output_topology
;
2089 MF_TOPOLOGY_TYPE node_type
;
2090 unsigned int layer_size
;
2091 IMFTopologyNode
*node
;
2092 unsigned short i
= 0;
2093 IMFStreamSink
*sink
;
2095 HRESULT hr
= E_FAIL
;
2097 FIXME("%p, %p, %p, %p.\n", iface
, input_topology
, ret_topology
, current_topology
);
2099 if (current_topology
)
2100 FIXME("Current topology instance is ignored.\n");
2102 /* Basic sanity checks for input topology:
2104 - source nodes must have stream descriptor set;
2105 - sink nodes must be resolved to stream sink objects;
2107 while (SUCCEEDED(IMFTopology_GetNode(input_topology
, i
++, &node
)))
2109 IMFTopologyNode_GetNodeType(node
, &node_type
);
2113 case MF_TOPOLOGY_OUTPUT_NODE
:
2114 if (SUCCEEDED(hr
= IMFTopologyNode_GetObject(node
, &object
)))
2116 /* Sinks must be bound beforehand. */
2117 if (FAILED(IUnknown_QueryInterface(object
, &IID_IMFStreamSink
, (void **)&sink
)))
2118 hr
= MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED
;
2120 IMFStreamSink_Release(sink
);
2121 IUnknown_Release(object
);
2124 case MF_TOPOLOGY_SOURCESTREAM_NODE
:
2125 hr
= IMFTopologyNode_GetItem(node
, &MF_TOPONODE_STREAM_DESCRIPTOR
, NULL
);
2131 IMFTopologyNode_Release(node
);
2136 if (FAILED(hr
= MFCreateTopology(&output_topology
)))
2139 context
.input_topology
= input_topology
;
2140 context
.output_topology
= output_topology
;
2141 memset(&context
.key
, 0xff, sizeof(context
.key
));
2143 /* Clone source nodes, use initial marker value. */
2145 while (SUCCEEDED(IMFTopology_GetNode(input_topology
, i
++, &node
)))
2147 IMFTopologyNode_GetNodeType(node
, &node_type
);
2149 if (node_type
== MF_TOPOLOGY_SOURCESTREAM_NODE
)
2151 if (FAILED(hr
= topology_loader_clone_node(&context
, node
, NULL
, 0)))
2152 WARN("Failed to clone source node, hr %#x.\n", hr
);
2155 IMFTopologyNode_Release(node
);
2158 for (context
.marker
= 0;; ++context
.marker
)
2160 if (FAILED(hr
= topology_loader_resolve_nodes(&context
, &layer_size
)))
2162 WARN("Failed to resolve for marker %u, hr %#x.\n", context
.marker
, hr
);
2166 /* Reached last marker value. */
2171 /* For now return original topology. */
2173 *ret_topology
= output_topology
;
2175 return IMFTopology_CloneFrom(output_topology
, input_topology
);
2178 static const IMFTopoLoaderVtbl topologyloadervtbl
=
2180 topology_loader_QueryInterface
,
2181 topology_loader_AddRef
,
2182 topology_loader_Release
,
2183 topology_loader_Load
,
2186 /***********************************************************************
2187 * MFCreateTopoLoader (mf.@)
2189 HRESULT WINAPI
MFCreateTopoLoader(IMFTopoLoader
**loader
)
2191 struct topology_loader
*object
;
2193 TRACE("%p.\n", loader
);
2198 object
= heap_alloc(sizeof(*object
));
2200 return E_OUTOFMEMORY
;
2202 object
->IMFTopoLoader_iface
.lpVtbl
= &topologyloadervtbl
;
2203 object
->refcount
= 1;
2205 *loader
= &object
->IMFTopoLoader_iface
;
2210 static HRESULT WINAPI
seq_source_QueryInterface(IMFSequencerSource
*iface
, REFIID riid
, void **out
)
2212 struct seq_source
*seq_source
= impl_from_IMFSequencerSource(iface
);
2214 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), out
);
2218 if (IsEqualIID(riid
, &IID_IMFSequencerSource
) ||
2219 IsEqualIID(riid
, &IID_IUnknown
))
2221 *out
= &seq_source
->IMFSequencerSource_iface
;
2223 else if (IsEqualIID(riid
, &IID_IMFMediaSourceTopologyProvider
))
2225 *out
= &seq_source
->IMFMediaSourceTopologyProvider_iface
;
2229 WARN("Unimplemented %s.\n", debugstr_guid(riid
));
2230 return E_NOINTERFACE
;
2234 IUnknown_AddRef((IUnknown
*)*out
);
2239 static ULONG WINAPI
seq_source_AddRef(IMFSequencerSource
*iface
)
2241 struct seq_source
*seq_source
= impl_from_IMFSequencerSource(iface
);
2242 ULONG refcount
= InterlockedIncrement(&seq_source
->refcount
);
2244 TRACE("%p, refcount %u.\n", iface
, refcount
);
2249 static ULONG WINAPI
seq_source_Release(IMFSequencerSource
*iface
)
2251 struct seq_source
*seq_source
= impl_from_IMFSequencerSource(iface
);
2252 ULONG refcount
= InterlockedDecrement(&seq_source
->refcount
);
2254 TRACE("%p, refcount %u.\n", iface
, refcount
);
2258 heap_free(seq_source
);
2264 static HRESULT WINAPI
seq_source_AppendTopology(IMFSequencerSource
*iface
, IMFTopology
*topology
,
2265 DWORD flags
, MFSequencerElementId
*id
)
2267 FIXME("%p, %p, %x, %p.\n", iface
, topology
, flags
, id
);
2272 static HRESULT WINAPI
seq_source_DeleteTopology(IMFSequencerSource
*iface
, MFSequencerElementId id
)
2274 FIXME("%p, %#x.\n", iface
, id
);
2279 static HRESULT WINAPI
seq_source_GetPresentationContext(IMFSequencerSource
*iface
,
2280 IMFPresentationDescriptor
*descriptor
, MFSequencerElementId
*id
, IMFTopology
**topology
)
2282 FIXME("%p, %p, %p, %p.\n", iface
, descriptor
, id
, topology
);
2287 static HRESULT WINAPI
seq_source_UpdateTopology(IMFSequencerSource
*iface
, MFSequencerElementId id
,
2288 IMFTopology
*topology
)
2290 FIXME("%p, %#x, %p.\n", iface
, id
, topology
);
2295 static HRESULT WINAPI
seq_source_UpdateTopologyFlags(IMFSequencerSource
*iface
, MFSequencerElementId id
, DWORD flags
)
2297 FIXME("%p, %#x, %#x.\n", iface
, id
, flags
);
2302 static HRESULT WINAPI
seq_source_topology_provider_QueryInterface(IMFMediaSourceTopologyProvider
*iface
, REFIID riid
,
2305 struct seq_source
*seq_source
= impl_from_IMFMediaSourceTopologyProvider(iface
);
2306 return IMFSequencerSource_QueryInterface(&seq_source
->IMFSequencerSource_iface
, riid
, obj
);
2309 static ULONG WINAPI
seq_source_topology_provider_AddRef(IMFMediaSourceTopologyProvider
*iface
)
2311 struct seq_source
*seq_source
= impl_from_IMFMediaSourceTopologyProvider(iface
);
2312 return IMFSequencerSource_AddRef(&seq_source
->IMFSequencerSource_iface
);
2315 static ULONG WINAPI
seq_source_topology_provider_Release(IMFMediaSourceTopologyProvider
*iface
)
2317 struct seq_source
*seq_source
= impl_from_IMFMediaSourceTopologyProvider(iface
);
2318 return IMFSequencerSource_Release(&seq_source
->IMFSequencerSource_iface
);
2321 static HRESULT WINAPI
seq_source_topology_provider_GetMediaSourceTopology(IMFMediaSourceTopologyProvider
*iface
,
2322 IMFPresentationDescriptor
*pd
, IMFTopology
**topology
)
2324 FIXME("%p, %p, %p.\n", iface
, pd
, topology
);
2329 static const IMFMediaSourceTopologyProviderVtbl seq_source_topology_provider_vtbl
=
2331 seq_source_topology_provider_QueryInterface
,
2332 seq_source_topology_provider_AddRef
,
2333 seq_source_topology_provider_Release
,
2334 seq_source_topology_provider_GetMediaSourceTopology
,
2337 static const IMFSequencerSourceVtbl seqsourcevtbl
=
2339 seq_source_QueryInterface
,
2342 seq_source_AppendTopology
,
2343 seq_source_DeleteTopology
,
2344 seq_source_GetPresentationContext
,
2345 seq_source_UpdateTopology
,
2346 seq_source_UpdateTopologyFlags
,
2349 /***********************************************************************
2350 * MFCreateSequencerSource (mf.@)
2352 HRESULT WINAPI
MFCreateSequencerSource(IUnknown
*reserved
, IMFSequencerSource
**seq_source
)
2354 struct seq_source
*object
;
2356 TRACE("%p, %p.\n", reserved
, seq_source
);
2361 object
= heap_alloc(sizeof(*object
));
2363 return E_OUTOFMEMORY
;
2365 object
->IMFSequencerSource_iface
.lpVtbl
= &seqsourcevtbl
;
2366 object
->IMFMediaSourceTopologyProvider_iface
.lpVtbl
= &seq_source_topology_provider_vtbl
;
2367 object
->refcount
= 1;
2369 *seq_source
= &object
->IMFSequencerSource_iface
;