Commit c55dbcdb authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Add a helper to get associated topology node object.

parent 20beb7ab
...@@ -561,9 +561,9 @@ static const IMFTransformVtbl sample_copier_transform_vtbl = ...@@ -561,9 +561,9 @@ static const IMFTransformVtbl sample_copier_transform_vtbl =
sample_copier_transform_ProcessOutput, sample_copier_transform_ProcessOutput,
}; };
BOOL mf_is_sample_copier_transform(IUnknown *transform) BOOL mf_is_sample_copier_transform(IMFTransform *transform)
{ {
return transform->lpVtbl == (IUnknownVtbl *)&sample_copier_transform_vtbl; return transform->lpVtbl == &sample_copier_transform_vtbl;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -80,4 +80,5 @@ static inline const char *debugstr_time(LONGLONG time) ...@@ -80,4 +80,5 @@ static inline const char *debugstr_time(LONGLONG time)
return wine_dbg_sprintf("%s", rev); return wine_dbg_sprintf("%s", rev);
} }
extern BOOL mf_is_sample_copier_transform(IUnknown *transform) DECLSPEC_HIDDEN; extern BOOL mf_is_sample_copier_transform(IMFTransform *transform) DECLSPEC_HIDDEN;
extern HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj) DECLSPEC_HIDDEN;
...@@ -792,7 +792,6 @@ static void session_shutdown_current_topology(struct media_session *session) ...@@ -792,7 +792,6 @@ static void session_shutdown_current_topology(struct media_session *session)
IMFTopologyNode *node; IMFTopologyNode *node;
IMFActivate *activate; IMFActivate *activate;
IMFMediaSink *sink; IMFMediaSink *sink;
IUnknown *object;
WORD idx = 0; WORD idx = 0;
HRESULT hr; HRESULT hr;
...@@ -818,20 +817,15 @@ static void session_shutdown_current_topology(struct media_session *session) ...@@ -818,20 +817,15 @@ static void session_shutdown_current_topology(struct media_session *session)
WARN("Failed to shut down activation object for the sink, hr %#x.\n", hr); WARN("Failed to shut down activation object for the sink, hr %#x.\n", hr);
IMFActivate_Release(activate); IMFActivate_Release(activate);
} }
else if (SUCCEEDED(IMFTopologyNode_GetObject(node, &object))) else if (SUCCEEDED(topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
{ {
if (SUCCEEDED(IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&stream_sink))) if (SUCCEEDED(IMFStreamSink_GetMediaSink(stream_sink, &sink)))
{ {
if (SUCCEEDED(IMFStreamSink_GetMediaSink(stream_sink, &sink))) IMFMediaSink_Shutdown(sink);
{ IMFMediaSink_Release(sink);
IMFMediaSink_Shutdown(sink);
IMFMediaSink_Release(sink);
}
IMFStreamSink_Release(stream_sink);
} }
IUnknown_Release(object); IMFStreamSink_Release(stream_sink);
} }
} }
} }
...@@ -1358,7 +1352,6 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod ...@@ -1358,7 +1352,6 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod
IMFMediaType *media_type; IMFMediaType *media_type;
IMFStreamDescriptor *sd; IMFStreamDescriptor *sd;
HRESULT hr = S_OK; HRESULT hr = S_OK;
IUnknown *object;
if (!(topo_node = heap_alloc_zero(sizeof(*topo_node)))) if (!(topo_node = heap_alloc_zero(sizeof(*topo_node))))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -1374,15 +1367,11 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod ...@@ -1374,15 +1367,11 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod
case MF_TOPOLOGY_OUTPUT_NODE: case MF_TOPOLOGY_OUTPUT_NODE:
topo_node->u.sink.notify_cb.lpVtbl = &node_sample_allocator_cb_vtbl; topo_node->u.sink.notify_cb.lpVtbl = &node_sample_allocator_cb_vtbl;
if (FAILED(hr = IMFTopologyNode_GetObject(node, &object))) if (FAILED(hr = topology_node_get_object(node, &IID_IMFStreamSink, (void **)&topo_node->object.object)))
{ {
WARN("Node %s does not have associated object.\n", wine_dbgstr_longlong(topo_node->node_id)); WARN("Failed to get stream sink interface, hr %#x.\n", hr);
break; break;
} }
hr = IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&topo_node->object.object);
IUnknown_Release(object);
if (FAILED(hr))
break;
if (FAILED(hr = IMFStreamSink_GetMediaSink(topo_node->object.sink_stream, &media_sink))) if (FAILED(hr = IMFStreamSink_GetMediaSink(topo_node->object.sink_stream, &media_sink)))
break; break;
...@@ -1433,14 +1422,11 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod ...@@ -1433,14 +1422,11 @@ static HRESULT session_append_node(struct media_session *session, IMFTopologyNod
break; break;
case MF_TOPOLOGY_TRANSFORM_NODE: case MF_TOPOLOGY_TRANSFORM_NODE:
if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &object)))
{
hr = IUnknown_QueryInterface(object, &IID_IMFTransform, (void **)&topo_node->object.transform);
IUnknown_Release(object);
}
if (SUCCEEDED(hr)) if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFTransform, (void **)&topo_node->object.transform)))
{
hr = session_set_transform_stream_info(topo_node); hr = session_set_transform_stream_info(topo_node);
}
else else
WARN("Failed to get IMFTransform for MFT node, hr %#x.\n", hr); WARN("Failed to get IMFTransform for MFT node, hr %#x.\n", hr);
...@@ -2017,10 +2003,10 @@ static HRESULT WINAPI session_get_service_GetService(IMFGetService *iface, REFGU ...@@ -2017,10 +2003,10 @@ static HRESULT WINAPI session_get_service_GetService(IMFGetService *iface, REFGU
{ {
IMFStreamSink *stream_sink; IMFStreamSink *stream_sink;
IMFTopologyNode *node; IMFTopologyNode *node;
IUnknown *vr, *object;
IMFCollection *nodes; IMFCollection *nodes;
IMFMediaSink *sink; IMFMediaSink *sink;
unsigned int i = 0; unsigned int i = 0;
IUnknown *vr;
HRESULT hr; HRESULT hr;
EnterCriticalSection(&session->cs); EnterCriticalSection(&session->cs);
...@@ -2033,23 +2019,18 @@ static HRESULT WINAPI session_get_service_GetService(IMFGetService *iface, REFGU ...@@ -2033,23 +2019,18 @@ static HRESULT WINAPI session_get_service_GetService(IMFGetService *iface, REFGU
{ {
while (IMFCollection_GetElement(nodes, i++, (IUnknown **)&node) == S_OK) while (IMFCollection_GetElement(nodes, i++, (IUnknown **)&node) == S_OK)
{ {
if (SUCCEEDED(IMFTopologyNode_GetObject(node, &object))) if (SUCCEEDED(topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
{ {
if (SUCCEEDED(IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&stream_sink))) if (SUCCEEDED(IMFStreamSink_GetMediaSink(stream_sink, &sink)))
{ {
if (SUCCEEDED(IMFStreamSink_GetMediaSink(stream_sink, &sink))) if (SUCCEEDED(IMFMediaSink_QueryInterface(sink, &IID_IMFVideoRenderer, (void **)&vr)))
{ {
if (SUCCEEDED(IMFMediaSink_QueryInterface(sink, &IID_IMFVideoRenderer, (void **)&vr))) if (FAILED(hr = MFGetService(vr, service, riid, obj)))
{ WARN("Failed to get service from video renderer %#x.\n", hr);
if (FAILED(hr = MFGetService(vr, service, riid, obj))) IUnknown_Release(vr);
WARN("Failed to get service from video renderer %#x.\n", hr);
IUnknown_Release(vr);
}
} }
IMFStreamSink_Release(stream_sink);
} }
IMFStreamSink_Release(stream_sink);
IUnknown_Release(object);
} }
IMFTopologyNode_Release(node); IMFTopologyNode_Release(node);
......
...@@ -1786,6 +1786,22 @@ static HRESULT create_topology_node(MF_TOPOLOGY_TYPE node_type, struct topology_ ...@@ -1786,6 +1786,22 @@ static HRESULT create_topology_node(MF_TOPOLOGY_TYPE node_type, struct topology_
return S_OK; return S_OK;
} }
HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj)
{
IUnknown *unk;
HRESULT hr;
*obj = NULL;
if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, &unk)))
{
hr = IUnknown_QueryInterface(unk, riid, obj);
IUnknown_Release(unk);
}
return hr;
}
/*********************************************************************** /***********************************************************************
* MFCreateTopologyNode (mf.@) * MFCreateTopologyNode (mf.@)
*/ */
...@@ -1817,7 +1833,6 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO ...@@ -1817,7 +1833,6 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO
IMFStreamDescriptor *sd; IMFStreamDescriptor *sd;
IMFTransform *transform; IMFTransform *transform;
UINT32 primary_output; UINT32 primary_output;
IUnknown *object;
HRESULT hr; HRESULT hr;
TRACE("%p, %u, %d, %p.\n", node, stream, output, type); TRACE("%p, %u, %d, %p.\n", node, stream, output, type);
...@@ -1828,12 +1843,7 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO ...@@ -1828,12 +1843,7 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO
switch (node_type) switch (node_type)
{ {
case MF_TOPOLOGY_OUTPUT_NODE: case MF_TOPOLOGY_OUTPUT_NODE:
if (FAILED(hr = IMFTopologyNode_GetObject(node, &object))) if (SUCCEEDED(topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
return hr;
hr = IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&stream_sink);
IUnknown_Release(object);
if (SUCCEEDED(hr))
{ {
hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &type_handler); hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, &type_handler);
IMFStreamSink_Release(stream_sink); IMFStreamSink_Release(stream_sink);
...@@ -1861,12 +1871,7 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO ...@@ -1861,12 +1871,7 @@ HRESULT WINAPI MFGetTopoNodeCurrentType(IMFTopologyNode *node, DWORD stream, BOO
} }
break; break;
case MF_TOPOLOGY_TRANSFORM_NODE: case MF_TOPOLOGY_TRANSFORM_NODE:
if (FAILED(hr = IMFTopologyNode_GetObject(node, &object))) if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFTransform, (void **)&transform)))
return hr;
hr = IUnknown_QueryInterface(object, &IID_IMFTransform, (void **)&transform);
IUnknown_Release(object);
if (SUCCEEDED(hr))
{ {
if (output) if (output)
hr = IMFTransform_GetOutputCurrentType(transform, stream, type); hr = IMFTransform_GetOutputCurrentType(transform, stream, type);
...@@ -2163,7 +2168,6 @@ static HRESULT topology_loader_get_node_type_handler(IMFTopologyNode *node, IMFM ...@@ -2163,7 +2168,6 @@ static HRESULT topology_loader_get_node_type_handler(IMFTopologyNode *node, IMFM
MF_TOPOLOGY_TYPE node_type; MF_TOPOLOGY_TYPE node_type;
IMFStreamSink *stream_sink; IMFStreamSink *stream_sink;
IMFStreamDescriptor *sd; IMFStreamDescriptor *sd;
IUnknown *object;
HRESULT hr; HRESULT hr;
if (FAILED(hr = IMFTopologyNode_GetNodeType(node, &node_type))) if (FAILED(hr = IMFTopologyNode_GetNodeType(node, &node_type)))
...@@ -2172,14 +2176,10 @@ static HRESULT topology_loader_get_node_type_handler(IMFTopologyNode *node, IMFM ...@@ -2172,14 +2176,10 @@ static HRESULT topology_loader_get_node_type_handler(IMFTopologyNode *node, IMFM
switch (node_type) switch (node_type)
{ {
case MF_TOPOLOGY_OUTPUT_NODE: case MF_TOPOLOGY_OUTPUT_NODE:
if (SUCCEEDED(hr = IMFTopologyNode_GetObject(node, (IUnknown **)&object))) if (SUCCEEDED(hr = topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink)))
{ {
if (SUCCEEDED(hr = IUnknown_QueryInterface(object, &IID_IMFStreamSink, (void **)&stream_sink))) hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, handler);
{ IMFStreamSink_Release(stream_sink);
hr = IMFStreamSink_GetMediaTypeHandler(stream_sink, handler);
IMFStreamSink_Release(stream_sink);
}
IUnknown_Release(object);
} }
break; break;
case MF_TOPOLOGY_SOURCESTREAM_NODE: case MF_TOPOLOGY_SOURCESTREAM_NODE:
...@@ -2368,22 +2368,20 @@ static BOOL topology_loader_is_node_d3d_aware(IMFTopologyNode *node) ...@@ -2368,22 +2368,20 @@ static BOOL topology_loader_is_node_d3d_aware(IMFTopologyNode *node)
{ {
IMFAttributes *attributes; IMFAttributes *attributes;
unsigned int d3d_aware = 0; unsigned int d3d_aware = 0;
IUnknown *object = NULL; IMFTransform *transform;
if (FAILED(IMFTopologyNode_GetObject(node, &object))) if (FAILED(topology_node_get_object(node, &IID_IMFAttributes, (void **)&attributes)))
return FALSE; return FALSE;
if (SUCCEEDED(IUnknown_QueryInterface(object, &IID_IMFAttributes, (void **)&attributes))) IMFAttributes_GetUINT32(attributes, &MF_SA_D3D_AWARE, &d3d_aware);
IMFAttributes_Release(attributes);
if (!d3d_aware && SUCCEEDED(topology_node_get_object(node, &IID_IMFTransform, (void **)&transform)))
{ {
IMFAttributes_GetUINT32(attributes, &MF_SA_D3D_AWARE, &d3d_aware); d3d_aware = mf_is_sample_copier_transform(transform);
IMFAttributes_Release(attributes); IMFTransform_Release(transform);
} }
if (!d3d_aware)
d3d_aware = mf_is_sample_copier_transform(object);
IUnknown_Release(object);
return !!d3d_aware; return !!d3d_aware;
} }
...@@ -2454,7 +2452,7 @@ static HRESULT topology_loader_connect_d3d_aware_input(struct topoloader_context ...@@ -2454,7 +2452,7 @@ static HRESULT topology_loader_connect_d3d_aware_input(struct topoloader_context
IMFTransform *copier = NULL; IMFTransform *copier = NULL;
HRESULT hr = S_OK; HRESULT hr = S_OK;
IMFTopologyNode_GetObject(node, (IUnknown **)&stream_sink); topology_node_get_object(node, &IID_IMFStreamSink, (void **)&stream_sink);
if (topology_loader_is_node_d3d_aware(node)) if (topology_loader_is_node_d3d_aware(node))
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment