2 * Copyright 2020 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
27 #include "evr_classes.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(evr
);
37 #define MAX_MIXER_INPUT_STREAMS 16
42 IMFAttributes
*attributes
;
43 IMFMediaType
*media_type
;
44 MFVideoNormalizedRect rect
;
47 unsigned int sample_requested
: 1;
54 IMFMediaType
*media_type
;
59 IMFMediaType
*media_type
;
60 struct rt_format
*rt_formats
;
61 unsigned int rt_formats_count
;
66 IMFTransform IMFTransform_iface
;
67 IMFVideoDeviceID IMFVideoDeviceID_iface
;
68 IMFTopologyServiceLookupClient IMFTopologyServiceLookupClient_iface
;
69 IMFVideoMixerControl2 IMFVideoMixerControl2_iface
;
70 IMFGetService IMFGetService_iface
;
71 IMFVideoMixerBitmap IMFVideoMixerBitmap_iface
;
72 IMFVideoPositionMapper IMFVideoPositionMapper_iface
;
73 IMFVideoProcessor IMFVideoProcessor_iface
;
74 IMFAttributes IMFAttributes_iface
;
75 IMFQualityAdvise IMFQualityAdvise_iface
;
76 IMFClockStateSink IMFClockStateSink_iface
;
77 IUnknown IUnknown_inner
;
81 struct input_stream inputs
[MAX_MIXER_INPUT_STREAMS
];
82 unsigned int input_ids
[MAX_MIXER_INPUT_STREAMS
];
83 unsigned int input_count
;
84 struct output_stream output
;
86 IDirect3DDeviceManager9
*device_manager
;
87 IDirectXVideoProcessor
*processor
;
90 IMediaEventSink
*event_sink
;
91 IMFAttributes
*attributes
;
92 IMFAttributes
*internal_attributes
;
93 unsigned int mixing_flags
;
94 unsigned int is_streaming
;
101 static struct video_mixer
*impl_from_IUnknown(IUnknown
*iface
)
103 return CONTAINING_RECORD(iface
, struct video_mixer
, IUnknown_inner
);
106 static struct video_mixer
*impl_from_IMFTransform(IMFTransform
*iface
)
108 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFTransform_iface
);
111 static struct video_mixer
*impl_from_IMFVideoDeviceID(IMFVideoDeviceID
*iface
)
113 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoDeviceID_iface
);
116 static struct video_mixer
*impl_from_IMFTopologyServiceLookupClient(IMFTopologyServiceLookupClient
*iface
)
118 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFTopologyServiceLookupClient_iface
);
121 static struct video_mixer
*impl_from_IMFVideoMixerControl2(IMFVideoMixerControl2
*iface
)
123 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoMixerControl2_iface
);
126 static struct video_mixer
*impl_from_IMFGetService(IMFGetService
*iface
)
128 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFGetService_iface
);
131 static struct video_mixer
*impl_from_IMFVideoMixerBitmap(IMFVideoMixerBitmap
*iface
)
133 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoMixerBitmap_iface
);
136 static struct video_mixer
*impl_from_IMFVideoPositionMapper(IMFVideoPositionMapper
*iface
)
138 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoPositionMapper_iface
);
141 static struct video_mixer
*impl_from_IMFVideoProcessor(IMFVideoProcessor
*iface
)
143 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFVideoProcessor_iface
);
146 static struct video_mixer
*impl_from_IMFAttributes(IMFAttributes
*iface
)
148 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFAttributes_iface
);
151 static struct video_mixer
*impl_from_IMFQualityAdvise(IMFQualityAdvise
*iface
)
153 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFQualityAdvise_iface
);
156 static struct video_mixer
*impl_from_IMFClockStateSink(IMFClockStateSink
*iface
)
158 return CONTAINING_RECORD(iface
, struct video_mixer
, IMFClockStateSink_iface
);
161 static int __cdecl
video_mixer_compare_input_id(const void *a
, const void *b
)
163 const unsigned int *key
= a
;
164 const struct input_stream
*input
= b
;
166 if (*key
> input
->id
) return 1;
167 if (*key
< input
->id
) return -1;
171 static HRESULT
video_mixer_get_input(const struct video_mixer
*mixer
, unsigned int id
, struct input_stream
**stream
)
173 *stream
= bsearch(&id
, mixer
->inputs
, mixer
->input_count
, sizeof(*mixer
->inputs
), video_mixer_compare_input_id
);
174 return *stream
? S_OK
: MF_E_INVALIDSTREAMNUMBER
;
177 static void video_mixer_init_input(struct input_stream
*stream
)
179 if (SUCCEEDED(MFCreateAttributes(&stream
->attributes
, 1)))
180 IMFAttributes_SetUINT32(stream
->attributes
, &MF_SA_REQUIRED_SAMPLE_COUNT
, 1);
181 stream
->rect
.left
= stream
->rect
.top
= 0.0f
;
182 stream
->rect
.right
= stream
->rect
.bottom
= 1.0f
;
185 static void video_mixer_clear_types(struct video_mixer
*mixer
)
189 for (i
= 0; i
< mixer
->input_count
; ++i
)
191 if (mixer
->inputs
[i
].media_type
)
192 IMFMediaType_Release(mixer
->inputs
[i
].media_type
);
193 mixer
->inputs
[i
].media_type
= NULL
;
194 if (mixer
->inputs
[i
].sample
)
195 IMFSample_Release(mixer
->inputs
[i
].sample
);
196 mixer
->inputs
[i
].sample
= NULL
;
198 for (i
= 0; i
< mixer
->output
.rt_formats_count
; ++i
)
200 IMFMediaType_Release(mixer
->output
.rt_formats
[i
].media_type
);
202 free(mixer
->output
.rt_formats
);
203 if (mixer
->output
.media_type
)
204 IMFMediaType_Release(mixer
->output
.media_type
);
205 mixer
->output
.media_type
= NULL
;
208 static HRESULT WINAPI
video_mixer_inner_QueryInterface(IUnknown
*iface
, REFIID riid
, void **obj
)
210 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
212 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
214 if (IsEqualIID(riid
, &IID_IUnknown
))
218 else if (IsEqualIID(riid
, &IID_IMFTransform
))
220 *obj
= &mixer
->IMFTransform_iface
;
222 else if (IsEqualIID(riid
, &IID_IMFVideoDeviceID
))
224 *obj
= &mixer
->IMFVideoDeviceID_iface
;
226 else if (IsEqualIID(riid
, &IID_IMFTopologyServiceLookupClient
))
228 *obj
= &mixer
->IMFTopologyServiceLookupClient_iface
;
230 else if (IsEqualIID(riid
, &IID_IMFVideoMixerControl2
) ||
231 IsEqualIID(riid
, &IID_IMFVideoMixerControl
))
233 *obj
= &mixer
->IMFVideoMixerControl2_iface
;
235 else if (IsEqualIID(riid
, &IID_IMFGetService
))
237 *obj
= &mixer
->IMFGetService_iface
;
239 else if (IsEqualIID(riid
, &IID_IMFVideoMixerBitmap
))
241 *obj
= &mixer
->IMFVideoMixerBitmap_iface
;
243 else if (IsEqualIID(riid
, &IID_IMFVideoPositionMapper
))
245 *obj
= &mixer
->IMFVideoPositionMapper_iface
;
247 else if (IsEqualIID(riid
, &IID_IMFVideoProcessor
))
249 *obj
= &mixer
->IMFVideoProcessor_iface
;
251 else if (IsEqualIID(riid
, &IID_IMFAttributes
))
253 *obj
= &mixer
->IMFAttributes_iface
;
255 else if (IsEqualIID(riid
, &IID_IMFQualityAdvise
))
257 *obj
= &mixer
->IMFQualityAdvise_iface
;
259 else if (IsEqualIID(riid
, &IID_IMFClockStateSink
))
261 *obj
= &mixer
->IMFClockStateSink_iface
;
265 WARN("Unsupported interface %s.\n", debugstr_guid(riid
));
267 return E_NOINTERFACE
;
270 IUnknown_AddRef((IUnknown
*)*obj
);
274 static ULONG WINAPI
video_mixer_inner_AddRef(IUnknown
*iface
)
276 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
277 ULONG refcount
= InterlockedIncrement(&mixer
->refcount
);
279 TRACE("%p, refcount %u.\n", iface
, refcount
);
284 static void video_mixer_release_device_manager(struct video_mixer
*mixer
)
286 if (mixer
->processor
)
287 IDirectXVideoProcessor_Release(mixer
->processor
);
288 if (mixer
->device_manager
)
290 IDirect3DDeviceManager9_CloseDeviceHandle(mixer
->device_manager
, mixer
->device_handle
);
291 IDirect3DDeviceManager9_Release(mixer
->device_manager
);
293 mixer
->device_handle
= NULL
;
294 mixer
->device_manager
= NULL
;
295 mixer
->processor
= NULL
;
298 static ULONG WINAPI
video_mixer_inner_Release(IUnknown
*iface
)
300 struct video_mixer
*mixer
= impl_from_IUnknown(iface
);
301 ULONG refcount
= InterlockedDecrement(&mixer
->refcount
);
304 TRACE("%p, refcount %u.\n", iface
, refcount
);
308 for (i
= 0; i
< mixer
->input_count
; ++i
)
310 if (mixer
->inputs
[i
].attributes
)
311 IMFAttributes_Release(mixer
->inputs
[i
].attributes
);
313 video_mixer_clear_types(mixer
);
314 video_mixer_release_device_manager(mixer
);
315 if (mixer
->attributes
)
316 IMFAttributes_Release(mixer
->attributes
);
317 if (mixer
->internal_attributes
)
318 IMFAttributes_Release(mixer
->internal_attributes
);
319 DeleteCriticalSection(&mixer
->cs
);
326 static const IUnknownVtbl video_mixer_inner_vtbl
=
328 video_mixer_inner_QueryInterface
,
329 video_mixer_inner_AddRef
,
330 video_mixer_inner_Release
,
333 static HRESULT WINAPI
video_mixer_transform_QueryInterface(IMFTransform
*iface
, REFIID riid
, void **obj
)
335 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
336 return IUnknown_QueryInterface(mixer
->outer_unk
, riid
, obj
);
339 static ULONG WINAPI
video_mixer_transform_AddRef(IMFTransform
*iface
)
341 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
342 return IUnknown_AddRef(mixer
->outer_unk
);
345 static ULONG WINAPI
video_mixer_transform_Release(IMFTransform
*iface
)
347 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
348 return IUnknown_Release(mixer
->outer_unk
);
351 static HRESULT WINAPI
video_mixer_transform_GetStreamLimits(IMFTransform
*iface
, DWORD
*input_minimum
,
352 DWORD
*input_maximum
, DWORD
*output_minimum
, DWORD
*output_maximum
)
354 TRACE("%p, %p, %p, %p, %p.\n", iface
, input_minimum
, input_maximum
, output_minimum
, output_maximum
);
357 *input_maximum
= MAX_MIXER_INPUT_STREAMS
;
364 static HRESULT WINAPI
video_mixer_transform_GetStreamCount(IMFTransform
*iface
, DWORD
*inputs
, DWORD
*outputs
)
366 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
368 TRACE("%p, %p, %p.\n", iface
, inputs
, outputs
);
370 EnterCriticalSection(&mixer
->cs
);
371 if (inputs
) *inputs
= mixer
->input_count
;
372 if (outputs
) *outputs
= 1;
373 LeaveCriticalSection(&mixer
->cs
);
378 static HRESULT WINAPI
video_mixer_transform_GetStreamIDs(IMFTransform
*iface
, DWORD input_size
, DWORD
*inputs
,
379 DWORD output_size
, DWORD
*outputs
)
381 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
384 TRACE("%p, %u, %p, %u, %p.\n", iface
, input_size
, inputs
, output_size
, outputs
);
386 EnterCriticalSection(&mixer
->cs
);
387 if (mixer
->input_count
> input_size
|| !output_size
)
388 hr
= MF_E_BUFFERTOOSMALL
;
390 memcpy(inputs
, mixer
->input_ids
, mixer
->input_count
* sizeof(*inputs
));
391 if (outputs
) *outputs
= 0;
392 LeaveCriticalSection(&mixer
->cs
);
397 static HRESULT WINAPI
video_mixer_transform_GetInputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_INPUT_STREAM_INFO
*info
)
399 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
400 struct input_stream
*input
;
403 TRACE("%p, %u, %p.\n", iface
, id
, info
);
405 EnterCriticalSection(&mixer
->cs
);
407 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
409 memset(info
, 0, sizeof(*info
));
411 info
->dwFlags
|= MFT_INPUT_STREAM_REMOVABLE
| MFT_INPUT_STREAM_OPTIONAL
;
414 LeaveCriticalSection(&mixer
->cs
);
419 static HRESULT WINAPI
video_mixer_transform_GetOutputStreamInfo(IMFTransform
*iface
, DWORD id
, MFT_OUTPUT_STREAM_INFO
*info
)
421 TRACE("%p, %u, %p.\n", iface
, id
, info
);
424 return MF_E_INVALIDSTREAMNUMBER
;
426 memset(info
, 0, sizeof(*info
));
431 static HRESULT WINAPI
video_mixer_transform_GetAttributes(IMFTransform
*iface
, IMFAttributes
**attributes
)
433 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
435 TRACE("%p, %p.\n", iface
, attributes
);
440 *attributes
= mixer
->attributes
;
441 IMFAttributes_AddRef(*attributes
);
446 static HRESULT WINAPI
video_mixer_transform_GetInputStreamAttributes(IMFTransform
*iface
, DWORD id
,
447 IMFAttributes
**attributes
)
449 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
450 struct input_stream
*input
;
453 TRACE("%p, %u, %p.\n", iface
, id
, attributes
);
455 EnterCriticalSection(&mixer
->cs
);
457 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
459 *attributes
= input
->attributes
;
461 IMFAttributes_AddRef(*attributes
);
464 LeaveCriticalSection(&mixer
->cs
);
469 static HRESULT WINAPI
video_mixer_transform_GetOutputStreamAttributes(IMFTransform
*iface
, DWORD id
,
470 IMFAttributes
**attributes
)
472 TRACE("%p, %u, %p.\n", iface
, id
, attributes
);
477 static HRESULT WINAPI
video_mixer_transform_DeleteInputStream(IMFTransform
*iface
, DWORD id
)
479 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
480 struct input_stream
*input
;
484 TRACE("%p, %u.\n", iface
, id
);
487 return MF_E_INVALIDSTREAMNUMBER
;
489 EnterCriticalSection(&mixer
->cs
);
491 /* Can't delete reference stream. */
492 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
494 mixer
->input_count
--;
495 idx
= input
- mixer
->inputs
;
496 if (idx
< mixer
->input_count
)
498 if (mixer
->inputs
[idx
].attributes
)
499 IMFAttributes_Release(mixer
->inputs
[idx
].attributes
);
500 memmove(&mixer
->inputs
[idx
], &mixer
->inputs
[idx
+ 1], (mixer
->input_count
- idx
) * sizeof(*mixer
->inputs
));
501 memmove(&mixer
->input_ids
[idx
], &mixer
->input_ids
[idx
+ 1], (mixer
->input_count
- idx
) *
502 sizeof(*mixer
->input_ids
));
506 LeaveCriticalSection(&mixer
->cs
);
511 static int __cdecl
video_mixer_add_input_sort_compare(const void *a
, const void *b
)
513 const struct input_stream
*left
= a
, *right
= b
;
514 return left
->id
!= right
->id
? (left
->id
< right
->id
? -1 : 1) : 0;
517 static HRESULT WINAPI
video_mixer_transform_AddInputStreams(IMFTransform
*iface
, DWORD count
, DWORD
*ids
)
519 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
520 struct input_stream inputs
[MAX_MIXER_INPUT_STREAMS
] = { {0} };
521 struct input_stream
*input
;
525 TRACE("%p, %u, %p.\n", iface
, count
, ids
);
530 EnterCriticalSection(&mixer
->cs
);
531 if (count
> ARRAY_SIZE(mixer
->inputs
) - mixer
->input_count
)
535 /* Test for collisions. */
536 memcpy(inputs
, mixer
->inputs
, mixer
->input_count
* sizeof(*inputs
));
537 for (i
= 0; i
< count
; ++i
)
538 inputs
[i
+ mixer
->input_count
].id
= ids
[i
];
540 len
= mixer
->input_count
+ count
;
542 qsort(inputs
, len
, sizeof(*inputs
), video_mixer_add_input_sort_compare
);
544 for (i
= 1; i
< len
; ++i
)
546 if (inputs
[i
- 1].id
== inputs
[i
].id
)
555 unsigned int zorder
= mixer
->input_count
;
557 for (i
= 0; i
< count
; ++i
)
559 if ((input
= bsearch(&ids
[i
], inputs
, len
, sizeof(*inputs
), video_mixer_compare_input_id
)))
560 video_mixer_init_input(input
);
562 memcpy(&mixer
->input_ids
[mixer
->input_count
], ids
, count
* sizeof(*ids
));
563 memcpy(mixer
->inputs
, inputs
, len
* sizeof(*inputs
));
564 mixer
->input_count
+= count
;
566 for (i
= 0; i
< count
; ++i
)
568 if (SUCCEEDED(video_mixer_get_input(mixer
, ids
[i
], &input
)))
569 input
->zorder
= zorder
;
574 LeaveCriticalSection(&mixer
->cs
);
579 static HRESULT WINAPI
video_mixer_transform_GetInputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
582 TRACE("%p, %u, %u, %p.\n", iface
, id
, index
, type
);
587 static HRESULT WINAPI
video_mixer_transform_GetOutputAvailableType(IMFTransform
*iface
, DWORD id
, DWORD index
,
590 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
593 TRACE("%p, %u, %u, %p.\n", iface
, id
, index
, type
);
596 return MF_E_INVALIDSTREAMNUMBER
;
598 EnterCriticalSection(&mixer
->cs
);
600 if (!mixer
->inputs
[0].media_type
)
601 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
602 else if (index
>= mixer
->output
.rt_formats_count
)
603 hr
= MF_E_NO_MORE_TYPES
;
606 *type
= mixer
->output
.rt_formats
[index
].media_type
;
607 IMFMediaType_AddRef(*type
);
610 LeaveCriticalSection(&mixer
->cs
);
615 static HRESULT
video_mixer_init_dxva_videodesc(IMFMediaType
*media_type
, DXVA2_VideoDesc
*video_desc
)
617 const MFVIDEOFORMAT
*video_format
;
618 IMFVideoMediaType
*video_type
;
619 BOOL is_compressed
= TRUE
;
622 if (FAILED(IMFMediaType_QueryInterface(media_type
, &IID_IMFVideoMediaType
, (void **)&video_type
)))
623 return MF_E_INVALIDMEDIATYPE
;
625 video_format
= IMFVideoMediaType_GetVideoFormat(video_type
);
626 IMFVideoMediaType_IsCompressedFormat(video_type
, &is_compressed
);
628 if (!video_format
|| !video_format
->videoInfo
.dwWidth
|| !video_format
->videoInfo
.dwHeight
|| is_compressed
)
630 hr
= MF_E_INVALIDMEDIATYPE
;
634 memset(video_desc
, 0, sizeof(*video_desc
));
635 video_desc
->SampleWidth
= video_format
->videoInfo
.dwWidth
;
636 video_desc
->SampleHeight
= video_format
->videoInfo
.dwHeight
;
637 video_desc
->Format
= video_format
->surfaceInfo
.Format
;
640 IMFVideoMediaType_Release(video_type
);
645 static int __cdecl
rt_formats_sort_compare(const void *left
, const void *right
)
647 const struct rt_format
*format1
= left
, *format2
= right
;
649 if (format1
->format
< format2
->format
) return -1;
650 if (format1
->format
> format2
->format
) return 1;
654 static HRESULT
video_mixer_collect_output_types(struct video_mixer
*mixer
, const DXVA2_VideoDesc
*video_desc
,
655 IMFMediaType
*media_type
, IDirectXVideoProcessorService
*service
, unsigned int device_count
,
656 const GUID
*devices
, unsigned int flags
)
658 unsigned int i
, j
, format_count
, count
;
659 struct rt_format
*rt_formats
= NULL
, *ptr
;
660 HRESULT hr
= MF_E_INVALIDMEDIATYPE
;
665 for (i
= 0; i
< device_count
; ++i
)
667 if (SUCCEEDED(IDirectXVideoProcessorService_GetVideoProcessorRenderTargets(service
, &devices
[i
], video_desc
,
668 &format_count
, &formats
)))
670 if (!(ptr
= realloc(rt_formats
, (count
+ format_count
) * sizeof(*rt_formats
))))
674 CoTaskMemFree(formats
);
679 for (j
= 0; j
< format_count
; ++j
)
681 rt_formats
[count
+ j
].format
= formats
[j
];
682 rt_formats
[count
+ j
].device
= devices
[i
];
684 count
+= format_count
;
686 CoTaskMemFree(formats
);
690 if (count
&& !(flags
& MFT_SET_TYPE_TEST_ONLY
))
692 qsort(rt_formats
, count
, sizeof(*rt_formats
), rt_formats_sort_compare
);
695 for (i
= j
+ 1; i
< count
; ++i
)
697 if (rt_formats
[i
].format
!= rt_formats
[j
].format
)
699 rt_formats
[++j
] = rt_formats
[i
];
704 memcpy(&subtype
, &MFVideoFormat_Base
, sizeof(subtype
));
705 if ((mixer
->output
.rt_formats
= calloc(count
, sizeof(*mixer
->output
.rt_formats
))))
707 for (i
= 0; i
< count
; ++i
)
709 IMFMediaType
*rt_media_type
;
711 subtype
.Data1
= rt_formats
[i
].format
;
712 mixer
->output
.rt_formats
[i
] = rt_formats
[i
];
714 MFCreateMediaType(&rt_media_type
);
715 IMFMediaType_CopyAllItems(media_type
, (IMFAttributes
*)rt_media_type
);
716 IMFMediaType_SetGUID(rt_media_type
, &MF_MT_SUBTYPE
, &subtype
);
718 mixer
->output
.rt_formats
[i
].media_type
= rt_media_type
;
720 mixer
->output
.rt_formats_count
= count
;
731 return count
? S_OK
: hr
;
734 static HRESULT
video_mixer_open_device_handle(struct video_mixer
*mixer
)
736 IDirect3DDeviceManager9_CloseDeviceHandle(mixer
->device_manager
, mixer
->device_handle
);
737 mixer
->device_handle
= NULL
;
738 return IDirect3DDeviceManager9_OpenDeviceHandle(mixer
->device_manager
, &mixer
->device_handle
);
741 static HRESULT
video_mixer_get_processor_service(struct video_mixer
*mixer
, IDirectXVideoProcessorService
**service
)
745 if (!mixer
->device_handle
)
747 if (FAILED(hr
= IDirect3DDeviceManager9_OpenDeviceHandle(mixer
->device_manager
, &mixer
->device_handle
)))
753 hr
= IDirect3DDeviceManager9_GetVideoService(mixer
->device_manager
, mixer
->device_handle
,
754 &IID_IDirectXVideoProcessorService
, (void **)service
);
755 if (hr
== DXVA2_E_NEW_VIDEO_DEVICE
)
757 if (SUCCEEDED(hr
= video_mixer_open_device_handle(mixer
)))
766 static HRESULT WINAPI
video_mixer_transform_SetInputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*media_type
, DWORD flags
)
768 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
769 IDirectXVideoProcessorService
*service
;
770 DXVA2_VideoDesc video_desc
;
771 HRESULT hr
= E_NOTIMPL
;
775 TRACE("%p, %u, %p, %#x.\n", iface
, id
, media_type
, flags
);
777 EnterCriticalSection(&mixer
->cs
);
779 if (!(flags
& MFT_SET_TYPE_TEST_ONLY
))
780 video_mixer_clear_types(mixer
);
782 if (!mixer
->device_manager
)
783 hr
= MF_E_NOT_INITIALIZED
;
786 if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
788 if (SUCCEEDED(hr
= video_mixer_init_dxva_videodesc(media_type
, &video_desc
)))
792 if (SUCCEEDED(hr
= IDirectXVideoProcessorService_GetVideoProcessorDeviceGuids(service
, &video_desc
,
795 if (SUCCEEDED(hr
= video_mixer_collect_output_types(mixer
, &video_desc
, media_type
,
796 service
, count
, guids
, flags
)) && !(flags
& MFT_SET_TYPE_TEST_ONLY
))
798 if (mixer
->inputs
[0].media_type
)
799 IMFMediaType_Release(mixer
->inputs
[0].media_type
);
800 mixer
->inputs
[0].media_type
= media_type
;
801 IMFMediaType_AddRef(mixer
->inputs
[0].media_type
);
803 CoTaskMemFree(guids
);
808 FIXME("Unimplemented for substreams.\n");
812 IDirectXVideoProcessorService_Release(service
);
816 LeaveCriticalSection(&mixer
->cs
);
821 static HRESULT WINAPI
video_mixer_transform_SetOutputType(IMFTransform
*iface
, DWORD id
, IMFMediaType
*type
, DWORD flags
)
823 const unsigned int equality_flags
= MF_MEDIATYPE_EQUAL_MAJOR_TYPES
|
824 MF_MEDIATYPE_EQUAL_FORMAT_TYPES
| MF_MEDIATYPE_EQUAL_FORMAT_DATA
;
825 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
826 HRESULT hr
= MF_E_INVALIDMEDIATYPE
;
827 unsigned int i
, compare_flags
;
829 TRACE("%p, %u, %p, %#x.\n", iface
, id
, type
, flags
);
832 return MF_E_INVALIDSTREAMNUMBER
;
834 EnterCriticalSection(&mixer
->cs
);
836 for (i
= 0; i
< mixer
->output
.rt_formats_count
; ++i
)
839 if (FAILED(IMFMediaType_IsEqual(type
, mixer
->output
.rt_formats
[i
].media_type
, &compare_flags
)))
842 if ((compare_flags
& equality_flags
) == equality_flags
)
849 if (SUCCEEDED(hr
) && !(flags
& MFT_SET_TYPE_TEST_ONLY
))
851 IDirectXVideoProcessorService
*service
;
853 if (SUCCEEDED(hr
= video_mixer_get_processor_service(mixer
, &service
)))
855 DXVA2_VideoDesc video_desc
;
856 GUID subtype
= { 0 };
859 if (mixer
->processor
)
860 IDirectXVideoProcessor_Release(mixer
->processor
);
861 mixer
->processor
= NULL
;
863 video_mixer_init_dxva_videodesc(mixer
->inputs
[0].media_type
, &video_desc
);
864 IMFMediaType_GetGUID(type
, &MF_MT_SUBTYPE
, &subtype
);
865 rt_format
= subtype
.Data1
;
867 if (SUCCEEDED(hr
= IDirectXVideoProcessorService_CreateVideoProcessor(service
, &mixer
->output
.rt_formats
[i
].device
,
868 &video_desc
, rt_format
, MAX_MIXER_INPUT_STREAMS
, &mixer
->processor
)))
870 if (mixer
->output
.media_type
)
871 IMFMediaType_Release(mixer
->output
.media_type
);
872 mixer
->output
.media_type
= type
;
873 IMFMediaType_AddRef(mixer
->output
.media_type
);
876 IDirectXVideoProcessorService_Release(service
);
880 LeaveCriticalSection(&mixer
->cs
);
885 static HRESULT WINAPI
video_mixer_transform_GetInputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
887 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
888 struct input_stream
*stream
;
891 TRACE("%p, %u, %p.\n", iface
, id
, type
);
893 EnterCriticalSection(&mixer
->cs
);
895 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
897 if (!stream
->media_type
)
898 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
901 *type
= stream
->media_type
;
902 IMFMediaType_AddRef(*type
);
906 LeaveCriticalSection(&mixer
->cs
);
911 static HRESULT WINAPI
video_mixer_transform_GetOutputCurrentType(IMFTransform
*iface
, DWORD id
, IMFMediaType
**type
)
913 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
916 TRACE("%p, %u, %p.\n", iface
, id
, type
);
919 return MF_E_INVALIDSTREAMNUMBER
;
921 EnterCriticalSection(&mixer
->cs
);
923 if (!mixer
->output
.media_type
)
924 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
927 *type
= mixer
->output
.media_type
;
928 IMFMediaType_AddRef(*type
);
931 LeaveCriticalSection(&mixer
->cs
);
936 static HRESULT WINAPI
video_mixer_transform_GetInputStatus(IMFTransform
*iface
, DWORD id
, DWORD
*status
)
938 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
939 struct input_stream
*stream
;
942 TRACE("%p, %u, %p.\n", iface
, id
, status
);
947 EnterCriticalSection(&mixer
->cs
);
949 if (!mixer
->output
.media_type
)
950 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
951 else if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
953 *status
= stream
->sample
? 0 : MFT_INPUT_STATUS_ACCEPT_DATA
;
956 LeaveCriticalSection(&mixer
->cs
);
961 static HRESULT WINAPI
video_mixer_transform_GetOutputStatus(IMFTransform
*iface
, DWORD
*status
)
963 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
967 TRACE("%p, %p.\n", iface
, status
);
972 EnterCriticalSection(&mixer
->cs
);
974 if (!mixer
->output
.media_type
)
975 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
978 *status
= MFT_OUTPUT_STATUS_SAMPLE_READY
;
979 for (i
= 0; i
< mixer
->input_count
; ++i
)
981 if (!mixer
->inputs
[i
].sample
)
989 LeaveCriticalSection(&mixer
->cs
);
994 static HRESULT WINAPI
video_mixer_transform_SetOutputBounds(IMFTransform
*iface
, LONGLONG lower
, LONGLONG upper
)
996 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
998 TRACE("%p, %s, %s.\n", iface
, wine_dbgstr_longlong(lower
), wine_dbgstr_longlong(upper
));
1000 EnterCriticalSection(&mixer
->cs
);
1002 mixer
->lower_bound
= lower
;
1003 mixer
->upper_bound
= upper
;
1005 LeaveCriticalSection(&mixer
->cs
);
1010 static HRESULT WINAPI
video_mixer_transform_ProcessEvent(IMFTransform
*iface
, DWORD id
, IMFMediaEvent
*event
)
1012 FIXME("%p, %u, %p.\n", iface
, id
, event
);
1017 static void video_mixer_request_sample(struct video_mixer
*mixer
, unsigned int idx
)
1019 if (!mixer
->event_sink
|| mixer
->inputs
[idx
].sample_requested
)
1022 IMediaEventSink_Notify(mixer
->event_sink
, EC_SAMPLE_NEEDED
, idx
, 0);
1023 mixer
->inputs
[idx
].sample_requested
= 1;
1026 static HRESULT WINAPI
video_mixer_transform_ProcessMessage(IMFTransform
*iface
, MFT_MESSAGE_TYPE message
, ULONG_PTR param
)
1028 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1032 TRACE("%p, %u, %#lx.\n", iface
, message
, param
);
1036 case MFT_MESSAGE_SET_D3D_MANAGER
:
1038 EnterCriticalSection(&mixer
->cs
);
1040 video_mixer_release_device_manager(mixer
);
1042 hr
= IUnknown_QueryInterface((IUnknown
*)param
, &IID_IDirect3DDeviceManager9
, (void **)&mixer
->device_manager
);
1044 LeaveCriticalSection(&mixer
->cs
);
1048 case MFT_MESSAGE_COMMAND_FLUSH
:
1050 EnterCriticalSection(&mixer
->cs
);
1052 for (i
= 0; i
< mixer
->input_count
; ++i
)
1054 if (mixer
->inputs
[i
].sample
)
1056 IMFSample_Release(mixer
->inputs
[i
].sample
);
1057 mixer
->inputs
[i
].sample
= NULL
;
1058 mixer
->inputs
[i
].sample_requested
= 0;
1062 LeaveCriticalSection(&mixer
->cs
);
1066 case MFT_MESSAGE_NOTIFY_BEGIN_STREAMING
:
1067 case MFT_MESSAGE_NOTIFY_END_STREAMING
:
1069 EnterCriticalSection(&mixer
->cs
);
1071 if (!mixer
->is_streaming
)
1073 for (i
= 0; i
< mixer
->input_count
; ++i
)
1074 video_mixer_request_sample(mixer
, i
);
1077 mixer
->is_streaming
= message
== MFT_MESSAGE_NOTIFY_BEGIN_STREAMING
;
1079 LeaveCriticalSection(&mixer
->cs
);
1083 case MFT_MESSAGE_COMMAND_DRAIN
:
1087 WARN("Message not handled %d.\n", message
);
1094 static HRESULT WINAPI
video_mixer_transform_ProcessInput(IMFTransform
*iface
, DWORD id
, IMFSample
*sample
, DWORD flags
)
1096 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1097 struct input_stream
*input
;
1100 TRACE("%p, %u, %p, %#x.\n", iface
, id
, sample
, flags
);
1105 EnterCriticalSection(&mixer
->cs
);
1107 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &input
)))
1109 if (!input
->media_type
|| !mixer
->output
.media_type
)
1110 hr
= MF_E_TRANSFORM_TYPE_NOT_SET
;
1111 else if (input
->sample
)
1112 hr
= MF_E_NOTACCEPTING
;
1115 mixer
->is_streaming
= 1;
1116 input
->sample_requested
= 0;
1117 input
->sample
= sample
;
1118 IMFSample_AddRef(input
->sample
);
1122 LeaveCriticalSection(&mixer
->cs
);
1127 static HRESULT
video_mixer_get_sample_surface(IMFSample
*sample
, IDirect3DSurface9
**surface
)
1129 IMFMediaBuffer
*buffer
;
1133 if (FAILED(hr
= IMFSample_GetBufferByIndex(sample
, 0, &buffer
)))
1136 hr
= IMFMediaBuffer_QueryInterface(buffer
, &IID_IMFGetService
, (void **)&gs
);
1137 IMFMediaBuffer_Release(buffer
);
1141 hr
= IMFGetService_GetService(gs
, &MR_BUFFER_SERVICE
, &IID_IDirect3DSurface9
, (void **)surface
);
1142 IMFGetService_Release(gs
);
1146 static HRESULT
video_mixer_get_d3d_device(struct video_mixer
*mixer
, IDirect3DDevice9
**device
)
1152 hr
= IDirect3DDeviceManager9_LockDevice(mixer
->device_manager
, mixer
->device_handle
,
1154 if (hr
== DXVA2_E_NEW_VIDEO_DEVICE
)
1156 if (SUCCEEDED(hr
= video_mixer_open_device_handle(mixer
)))
1165 static void video_mixer_scale_rect(RECT
*rect
, unsigned int width
, unsigned int height
,
1166 const MFVideoNormalizedRect
*scale
)
1168 if (rect
->left
== 0.0f
&& rect
->top
== 0.0f
&& rect
->right
== 1.0f
&& rect
->bottom
== 1.0f
)
1170 SetRect(rect
, 0, 0, width
, height
);
1174 rect
->left
= width
* scale
->left
;
1175 rect
->right
= width
* scale
->right
;
1176 rect
->top
= height
* scale
->top
;
1177 rect
->bottom
= height
* scale
->bottom
;
1181 static void video_mixer_render(struct video_mixer
*mixer
, IDirect3DSurface9
*rt
)
1183 DXVA2_VideoSample samples
[1] = {{ 0 }};
1184 DXVA2_VideoProcessBltParams params
= { 0 };
1185 MFVideoNormalizedRect zoom_rect
;
1186 struct input_stream
*stream
;
1187 IDirect3DSurface9
*surface
;
1188 D3DSURFACE_DESC desc
;
1191 IDirect3DSurface9_GetDesc(rt
, &desc
);
1193 if (FAILED(IMFAttributes_GetBlob(mixer
->attributes
, &VIDEO_ZOOM_RECT
, (UINT8
*)&zoom_rect
,
1194 sizeof(zoom_rect
), NULL
)))
1196 zoom_rect
.left
= zoom_rect
.top
= 0.0f
;
1197 zoom_rect
.right
= zoom_rect
.bottom
= 1.0f
;
1200 video_mixer_scale_rect(¶ms
.TargetRect
, desc
.Width
, desc
.Height
, &zoom_rect
);
1202 /* FIXME: for now only handle reference stream. */
1204 video_mixer_get_input(mixer
, 0, &stream
);
1206 if (FAILED(hr
= video_mixer_get_sample_surface(stream
->sample
, &surface
)))
1208 WARN("Failed to get source surface, hr %#x.\n", hr
);
1212 IDirect3DSurface9_GetDesc(surface
, &desc
);
1214 samples
[0].SrcSurface
= surface
;
1215 SetRect(&samples
[0].SrcRect
, 0, 0, desc
.Width
, desc
.Height
);
1216 video_mixer_scale_rect(&samples
[0].DstRect
, desc
.Width
, desc
.Height
, &stream
->rect
);
1218 if (FAILED(hr
= IDirectXVideoProcessor_VideoProcessBlt(mixer
->processor
, rt
, ¶ms
, samples
, 1, NULL
)))
1219 WARN("Failed to process samples, hr %#x.\n", hr
);
1221 IDirect3DSurface9_Release(surface
);
1224 static HRESULT
video_mixer_get_sample_desired_time(IMFSample
*sample
, LONGLONG
*timestamp
, LONGLONG
*duration
)
1226 IMFDesiredSample
*desired
;
1229 if (SUCCEEDED(hr
= IMFSample_QueryInterface(sample
, &IID_IMFDesiredSample
, (void **)&desired
)))
1231 hr
= IMFDesiredSample_GetDesiredSampleTimeAndDuration(desired
, timestamp
, duration
);
1232 IMFDesiredSample_Release(desired
);
1238 static HRESULT WINAPI
video_mixer_transform_ProcessOutput(IMFTransform
*iface
, DWORD flags
, DWORD count
,
1239 MFT_OUTPUT_DATA_BUFFER
*buffers
, DWORD
*status
)
1241 struct video_mixer
*mixer
= impl_from_IMFTransform(iface
);
1242 LONGLONG timestamp
, duration
;
1243 IDirect3DSurface9
*surface
;
1244 IDirect3DDevice9
*device
;
1248 TRACE("%p, %#x, %u, %p, %p.\n", iface
, flags
, count
, buffers
, status
);
1250 if (!buffers
|| !count
|| count
> 1 || !buffers
->pSample
)
1251 return E_INVALIDARG
;
1253 if (buffers
->dwStreamID
)
1254 return MF_E_INVALIDSTREAMNUMBER
;
1258 EnterCriticalSection(&mixer
->cs
);
1260 if (SUCCEEDED(hr
= video_mixer_get_sample_surface(buffers
->pSample
, &surface
)))
1262 if (mixer
->is_streaming
)
1264 for (i
= 0; i
< mixer
->input_count
; ++i
)
1266 if (!mixer
->inputs
[i
].sample
)
1268 hr
= MF_E_TRANSFORM_NEED_MORE_INPUT
;
1275 video_mixer_render(mixer
, surface
);
1277 timestamp
= duration
= 0;
1278 if (SUCCEEDED(IMFSample_GetSampleTime(mixer
->inputs
[0].sample
, ×tamp
)))
1280 IMFSample_SetSampleTime(buffers
->pSample
, timestamp
);
1282 IMFSample_GetSampleDuration(mixer
->inputs
[0].sample
, &duration
);
1283 IMFSample_SetSampleDuration(buffers
->pSample
, duration
);
1289 for (i
= 0; i
< mixer
->input_count
; ++i
)
1291 if (mixer
->inputs
[i
].sample
)
1292 IMFSample_Release(mixer
->inputs
[i
].sample
);
1293 mixer
->inputs
[i
].sample
= NULL
;
1294 video_mixer_request_sample(mixer
, i
);
1300 if (SUCCEEDED(video_mixer_get_sample_desired_time(buffers
->pSample
, ×tamp
, &duration
)))
1302 if (SUCCEEDED(hr
= video_mixer_get_d3d_device(mixer
, &device
)))
1304 IDirect3DDevice9_ColorFill(device
, surface
, NULL
, 0);
1305 IDirect3DDeviceManager9_UnlockDevice(mixer
->device_manager
, mixer
->device_handle
, FALSE
);
1306 IDirect3DDevice9_Release(device
);
1310 hr
= MF_E_TRANSFORM_NEED_MORE_INPUT
;
1312 IDirect3DSurface9_Release(surface
);
1315 LeaveCriticalSection(&mixer
->cs
);
1320 static const IMFTransformVtbl video_mixer_transform_vtbl
=
1322 video_mixer_transform_QueryInterface
,
1323 video_mixer_transform_AddRef
,
1324 video_mixer_transform_Release
,
1325 video_mixer_transform_GetStreamLimits
,
1326 video_mixer_transform_GetStreamCount
,
1327 video_mixer_transform_GetStreamIDs
,
1328 video_mixer_transform_GetInputStreamInfo
,
1329 video_mixer_transform_GetOutputStreamInfo
,
1330 video_mixer_transform_GetAttributes
,
1331 video_mixer_transform_GetInputStreamAttributes
,
1332 video_mixer_transform_GetOutputStreamAttributes
,
1333 video_mixer_transform_DeleteInputStream
,
1334 video_mixer_transform_AddInputStreams
,
1335 video_mixer_transform_GetInputAvailableType
,
1336 video_mixer_transform_GetOutputAvailableType
,
1337 video_mixer_transform_SetInputType
,
1338 video_mixer_transform_SetOutputType
,
1339 video_mixer_transform_GetInputCurrentType
,
1340 video_mixer_transform_GetOutputCurrentType
,
1341 video_mixer_transform_GetInputStatus
,
1342 video_mixer_transform_GetOutputStatus
,
1343 video_mixer_transform_SetOutputBounds
,
1344 video_mixer_transform_ProcessEvent
,
1345 video_mixer_transform_ProcessMessage
,
1346 video_mixer_transform_ProcessInput
,
1347 video_mixer_transform_ProcessOutput
,
1350 static HRESULT WINAPI
video_mixer_device_id_QueryInterface(IMFVideoDeviceID
*iface
, REFIID riid
, void **obj
)
1352 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1353 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1356 static ULONG WINAPI
video_mixer_device_id_AddRef(IMFVideoDeviceID
*iface
)
1358 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1359 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1362 static ULONG WINAPI
video_mixer_device_id_Release(IMFVideoDeviceID
*iface
)
1364 struct video_mixer
*mixer
= impl_from_IMFVideoDeviceID(iface
);
1365 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1368 static HRESULT WINAPI
video_mixer_device_id_GetDeviceID(IMFVideoDeviceID
*iface
, IID
*device_id
)
1370 TRACE("%p, %p.\n", iface
, device_id
);
1375 memcpy(device_id
, &IID_IDirect3DDevice9
, sizeof(*device_id
));
1380 static const IMFVideoDeviceIDVtbl video_mixer_device_id_vtbl
=
1382 video_mixer_device_id_QueryInterface
,
1383 video_mixer_device_id_AddRef
,
1384 video_mixer_device_id_Release
,
1385 video_mixer_device_id_GetDeviceID
,
1388 static HRESULT WINAPI
video_mixer_service_client_QueryInterface(IMFTopologyServiceLookupClient
*iface
,
1389 REFIID riid
, void **obj
)
1391 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1392 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1395 static ULONG WINAPI
video_mixer_service_client_AddRef(IMFTopologyServiceLookupClient
*iface
)
1397 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1398 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1401 static ULONG WINAPI
video_mixer_service_client_Release(IMFTopologyServiceLookupClient
*iface
)
1403 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1404 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1407 static HRESULT WINAPI
video_mixer_service_client_InitServicePointers(IMFTopologyServiceLookupClient
*iface
,
1408 IMFTopologyServiceLookup
*service_lookup
)
1410 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1414 TRACE("%p, %p.\n", iface
, service_lookup
);
1416 if (!service_lookup
)
1419 EnterCriticalSection(&mixer
->cs
);
1422 if (FAILED(hr
= IMFTopologyServiceLookup_LookupService(service_lookup
, MF_SERVICE_LOOKUP_GLOBAL
, 0,
1423 &MR_VIDEO_RENDER_SERVICE
, &IID_IMediaEventSink
, (void **)&mixer
->event_sink
, &count
)))
1425 WARN("Failed to get renderer event sink, hr %#x.\n", hr
);
1428 LeaveCriticalSection(&mixer
->cs
);
1433 static HRESULT WINAPI
video_mixer_service_client_ReleaseServicePointers(IMFTopologyServiceLookupClient
*iface
)
1435 struct video_mixer
*mixer
= impl_from_IMFTopologyServiceLookupClient(iface
);
1437 TRACE("%p.\n", iface
);
1439 EnterCriticalSection(&mixer
->cs
);
1441 if (mixer
->event_sink
)
1442 IMediaEventSink_Release(mixer
->event_sink
);
1443 mixer
->event_sink
= NULL
;
1445 LeaveCriticalSection(&mixer
->cs
);
1450 static const IMFTopologyServiceLookupClientVtbl video_mixer_service_client_vtbl
=
1452 video_mixer_service_client_QueryInterface
,
1453 video_mixer_service_client_AddRef
,
1454 video_mixer_service_client_Release
,
1455 video_mixer_service_client_InitServicePointers
,
1456 video_mixer_service_client_ReleaseServicePointers
,
1459 static HRESULT WINAPI
video_mixer_control_QueryInterface(IMFVideoMixerControl2
*iface
, REFIID riid
, void **obj
)
1461 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1462 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1465 static ULONG WINAPI
video_mixer_control_AddRef(IMFVideoMixerControl2
*iface
)
1467 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1468 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1471 static ULONG WINAPI
video_mixer_control_Release(IMFVideoMixerControl2
*iface
)
1473 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1474 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1477 static HRESULT WINAPI
video_mixer_control_SetStreamZOrder(IMFVideoMixerControl2
*iface
, DWORD id
, DWORD zorder
)
1479 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1480 struct input_stream
*stream
;
1483 TRACE("%p, %u, %u.\n", iface
, id
, zorder
);
1485 /* Can't change reference stream. */
1487 return E_INVALIDARG
;
1489 EnterCriticalSection(&mixer
->cs
);
1491 if (zorder
>= mixer
->input_count
)
1493 else if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1495 /* Lowest zorder only applies to reference stream. */
1497 hr
= MF_E_INVALIDREQUEST
;
1499 stream
->zorder
= zorder
;
1502 LeaveCriticalSection(&mixer
->cs
);
1507 static HRESULT WINAPI
video_mixer_control_GetStreamZOrder(IMFVideoMixerControl2
*iface
, DWORD id
, DWORD
*zorder
)
1509 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1510 struct input_stream
*stream
;
1513 TRACE("%p, %u, %p.\n", iface
, id
, zorder
);
1518 EnterCriticalSection(&mixer
->cs
);
1520 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1521 *zorder
= stream
->zorder
;
1523 LeaveCriticalSection(&mixer
->cs
);
1528 static HRESULT WINAPI
video_mixer_control_SetStreamOutputRect(IMFVideoMixerControl2
*iface
, DWORD id
,
1529 const MFVideoNormalizedRect
*rect
)
1531 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1532 struct input_stream
*stream
;
1535 TRACE("%p, %u, %p.\n", iface
, id
, rect
);
1540 if (rect
->left
> rect
->right
|| rect
->top
> rect
->bottom
||
1541 rect
->left
< 0.0f
|| rect
->top
< 0.0f
|| rect
->right
> 1.0f
|| rect
->bottom
> 1.0f
)
1543 return E_INVALIDARG
;
1546 EnterCriticalSection(&mixer
->cs
);
1548 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1549 stream
->rect
= *rect
;
1551 LeaveCriticalSection(&mixer
->cs
);
1556 static HRESULT WINAPI
video_mixer_control_GetStreamOutputRect(IMFVideoMixerControl2
*iface
, DWORD id
,
1557 MFVideoNormalizedRect
*rect
)
1559 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1560 struct input_stream
*stream
;
1563 TRACE("%p, %u, %p.\n", iface
, id
, rect
);
1568 EnterCriticalSection(&mixer
->cs
);
1570 if (SUCCEEDED(hr
= video_mixer_get_input(mixer
, id
, &stream
)))
1571 *rect
= stream
->rect
;
1573 LeaveCriticalSection(&mixer
->cs
);
1578 static HRESULT WINAPI
video_mixer_control_SetMixingPrefs(IMFVideoMixerControl2
*iface
, DWORD flags
)
1580 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1582 TRACE("%p, %#x.\n", iface
, flags
);
1584 EnterCriticalSection(&mixer
->cs
);
1585 mixer
->mixing_flags
= flags
;
1586 LeaveCriticalSection(&mixer
->cs
);
1591 static HRESULT WINAPI
video_mixer_control_GetMixingPrefs(IMFVideoMixerControl2
*iface
, DWORD
*flags
)
1593 struct video_mixer
*mixer
= impl_from_IMFVideoMixerControl2(iface
);
1595 TRACE("%p, %p.\n", iface
, flags
);
1600 EnterCriticalSection(&mixer
->cs
);
1601 *flags
= mixer
->mixing_flags
;
1602 LeaveCriticalSection(&mixer
->cs
);
1607 static const IMFVideoMixerControl2Vtbl video_mixer_control_vtbl
=
1609 video_mixer_control_QueryInterface
,
1610 video_mixer_control_AddRef
,
1611 video_mixer_control_Release
,
1612 video_mixer_control_SetStreamZOrder
,
1613 video_mixer_control_GetStreamZOrder
,
1614 video_mixer_control_SetStreamOutputRect
,
1615 video_mixer_control_GetStreamOutputRect
,
1616 video_mixer_control_SetMixingPrefs
,
1617 video_mixer_control_GetMixingPrefs
,
1620 static HRESULT WINAPI
video_mixer_getservice_QueryInterface(IMFGetService
*iface
, REFIID riid
, void **obj
)
1622 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1623 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1626 static ULONG WINAPI
video_mixer_getservice_AddRef(IMFGetService
*iface
)
1628 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1629 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1632 static ULONG WINAPI
video_mixer_getservice_Release(IMFGetService
*iface
)
1634 struct video_mixer
*mixer
= impl_from_IMFGetService(iface
);
1635 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1638 static HRESULT WINAPI
video_mixer_getservice_GetService(IMFGetService
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1640 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(service
), debugstr_guid(riid
), obj
);
1642 if (IsEqualGUID(service
, &MR_VIDEO_MIXER_SERVICE
))
1644 if (IsEqualIID(riid
, &IID_IMFVideoMixerBitmap
) ||
1645 IsEqualIID(riid
, &IID_IMFVideoProcessor
) ||
1646 IsEqualIID(riid
, &IID_IMFVideoPositionMapper
) ||
1647 IsEqualIID(riid
, &IID_IMFVideoMixerControl
) ||
1648 IsEqualIID(riid
, &IID_IMFVideoMixerControl2
))
1650 return IMFGetService_QueryInterface(iface
, riid
, obj
);
1653 return E_NOINTERFACE
;
1656 FIXME("Unsupported service %s, riid %s.\n", debugstr_guid(service
), debugstr_guid(riid
));
1658 return MF_E_UNSUPPORTED_SERVICE
;
1661 static const IMFGetServiceVtbl video_mixer_getservice_vtbl
=
1663 video_mixer_getservice_QueryInterface
,
1664 video_mixer_getservice_AddRef
,
1665 video_mixer_getservice_Release
,
1666 video_mixer_getservice_GetService
,
1669 static HRESULT WINAPI
video_mixer_bitmap_QueryInterface(IMFVideoMixerBitmap
*iface
, REFIID riid
, void **obj
)
1671 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1672 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1675 static ULONG WINAPI
video_mixer_bitmap_AddRef(IMFVideoMixerBitmap
*iface
)
1677 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1678 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1681 static ULONG WINAPI
video_mixer_bitmap_Release(IMFVideoMixerBitmap
*iface
)
1683 struct video_mixer
*mixer
= impl_from_IMFVideoMixerBitmap(iface
);
1684 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1687 static HRESULT WINAPI
video_mixer_bitmap_SetAlphaBitmap(IMFVideoMixerBitmap
*iface
, const MFVideoAlphaBitmap
*bitmap
)
1689 FIXME("%p, %p.\n", iface
, bitmap
);
1694 static HRESULT WINAPI
video_mixer_bitmap_ClearAlphaBitmap(IMFVideoMixerBitmap
*iface
)
1696 FIXME("%p.\n", iface
);
1701 static HRESULT WINAPI
video_mixer_bitmap_UpdateAlphaBitmapParameters(IMFVideoMixerBitmap
*iface
,
1702 const MFVideoAlphaBitmapParams
*params
)
1704 FIXME("%p, %p.\n", iface
, params
);
1709 static HRESULT WINAPI
video_mixer_bitmap_GetAlphaBitmapParameters(IMFVideoMixerBitmap
*iface
, MFVideoAlphaBitmapParams
*params
)
1711 FIXME("%p, %p.\n", iface
, params
);
1716 static const IMFVideoMixerBitmapVtbl video_mixer_bitmap_vtbl
=
1718 video_mixer_bitmap_QueryInterface
,
1719 video_mixer_bitmap_AddRef
,
1720 video_mixer_bitmap_Release
,
1721 video_mixer_bitmap_SetAlphaBitmap
,
1722 video_mixer_bitmap_ClearAlphaBitmap
,
1723 video_mixer_bitmap_UpdateAlphaBitmapParameters
,
1724 video_mixer_bitmap_GetAlphaBitmapParameters
,
1727 static HRESULT WINAPI
video_mixer_position_mapper_QueryInterface(IMFVideoPositionMapper
*iface
, REFIID riid
, void **obj
)
1729 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1730 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1733 static ULONG WINAPI
video_mixer_position_mapper_AddRef(IMFVideoPositionMapper
*iface
)
1735 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1736 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1739 static ULONG WINAPI
video_mixer_position_mapper_Release(IMFVideoPositionMapper
*iface
)
1741 struct video_mixer
*mixer
= impl_from_IMFVideoPositionMapper(iface
);
1742 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1745 static HRESULT WINAPI
video_mixer_position_mapper_MapOutputCoordinateToInputStream(IMFVideoPositionMapper
*iface
,
1746 float x_out
, float y_out
, DWORD output_stream
, DWORD input_stream
, float *x_in
, float *y_in
)
1748 FIXME("%p, %f, %f, %u, %u, %p, %p.\n", iface
, x_out
, y_out
, output_stream
, input_stream
, x_in
, y_in
);
1753 static const IMFVideoPositionMapperVtbl video_mixer_position_mapper_vtbl
=
1755 video_mixer_position_mapper_QueryInterface
,
1756 video_mixer_position_mapper_AddRef
,
1757 video_mixer_position_mapper_Release
,
1758 video_mixer_position_mapper_MapOutputCoordinateToInputStream
,
1761 static HRESULT WINAPI
video_mixer_processor_QueryInterface(IMFVideoProcessor
*iface
, REFIID riid
, void **obj
)
1763 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1764 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, obj
);
1767 static ULONG WINAPI
video_mixer_processor_AddRef(IMFVideoProcessor
*iface
)
1769 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1770 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1773 static ULONG WINAPI
video_mixer_processor_Release(IMFVideoProcessor
*iface
)
1775 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1776 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1779 static HRESULT WINAPI
video_mixer_processor_GetAvailableVideoProcessorModes(IMFVideoProcessor
*iface
, UINT
*count
,
1782 FIXME("%p, %p, %p.\n", iface
, count
, modes
);
1787 static HRESULT WINAPI
video_mixer_processor_GetVideoProcessorCaps(IMFVideoProcessor
*iface
, GUID
*mode
,
1788 DXVA2_VideoProcessorCaps
*caps
)
1790 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(mode
), caps
);
1795 static HRESULT WINAPI
video_mixer_processor_GetVideoProcessorMode(IMFVideoProcessor
*iface
, GUID
*mode
)
1797 FIXME("%p, %p.\n", iface
, mode
);
1802 static HRESULT WINAPI
video_mixer_processor_SetVideoProcessorMode(IMFVideoProcessor
*iface
, GUID
*mode
)
1804 FIXME("%p, %s.\n", iface
, debugstr_guid(mode
));
1809 static HRESULT WINAPI
video_mixer_processor_GetProcAmpRange(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_ValueRange
*range
)
1811 FIXME("%p, %#x, %p.\n", iface
, prop
, range
);
1816 static HRESULT WINAPI
video_mixer_processor_GetProcAmpValues(IMFVideoProcessor
*iface
, DWORD flags
, DXVA2_ProcAmpValues
*values
)
1818 FIXME("%p, %#x, %p.\n", iface
, flags
, values
);
1823 static HRESULT WINAPI
video_mixer_processor_SetProcAmpValues(IMFVideoProcessor
*iface
, DWORD flags
, DXVA2_ProcAmpValues
*values
)
1825 FIXME("%p, %#x, %p.\n", iface
, flags
, values
);
1830 static HRESULT WINAPI
video_mixer_processor_GetFilteringRange(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_ValueRange
*range
)
1832 FIXME("%p, %#x, %p.\n", iface
, prop
, range
);
1837 static HRESULT WINAPI
video_mixer_processor_GetFilteringValue(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_Fixed32
*value
)
1839 FIXME("%p, %#x, %p.\n", iface
, prop
, value
);
1844 static HRESULT WINAPI
video_mixer_processor_SetFilteringValue(IMFVideoProcessor
*iface
, DWORD prop
, DXVA2_Fixed32
*value
)
1846 FIXME("%p, %#x, %p.\n", iface
, prop
, value
);
1851 static HRESULT WINAPI
video_mixer_processor_GetBackgroundColor(IMFVideoProcessor
*iface
, COLORREF
*color
)
1853 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1855 TRACE("%p, %p.\n", iface
, color
);
1860 EnterCriticalSection(&mixer
->cs
);
1861 *color
= mixer
->bkgnd_color
;
1862 LeaveCriticalSection(&mixer
->cs
);
1867 static HRESULT WINAPI
video_mixer_processor_SetBackgroundColor(IMFVideoProcessor
*iface
, COLORREF color
)
1869 struct video_mixer
*mixer
= impl_from_IMFVideoProcessor(iface
);
1871 TRACE("%p, %#x.\n", iface
, color
);
1873 EnterCriticalSection(&mixer
->cs
);
1874 mixer
->bkgnd_color
= color
;
1875 LeaveCriticalSection(&mixer
->cs
);
1880 static const IMFVideoProcessorVtbl video_mixer_processor_vtbl
=
1882 video_mixer_processor_QueryInterface
,
1883 video_mixer_processor_AddRef
,
1884 video_mixer_processor_Release
,
1885 video_mixer_processor_GetAvailableVideoProcessorModes
,
1886 video_mixer_processor_GetVideoProcessorCaps
,
1887 video_mixer_processor_GetVideoProcessorMode
,
1888 video_mixer_processor_SetVideoProcessorMode
,
1889 video_mixer_processor_GetProcAmpRange
,
1890 video_mixer_processor_GetProcAmpValues
,
1891 video_mixer_processor_SetProcAmpValues
,
1892 video_mixer_processor_GetFilteringRange
,
1893 video_mixer_processor_GetFilteringValue
,
1894 video_mixer_processor_SetFilteringValue
,
1895 video_mixer_processor_GetBackgroundColor
,
1896 video_mixer_processor_SetBackgroundColor
,
1899 static HRESULT WINAPI
video_mixer_attributes_QueryInterface(IMFAttributes
*iface
, REFIID riid
, void **out
)
1901 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1902 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
1905 static ULONG WINAPI
video_mixer_attributes_AddRef(IMFAttributes
*iface
)
1907 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1908 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
1911 static ULONG WINAPI
video_mixer_attributes_Release(IMFAttributes
*iface
)
1913 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1914 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
1917 static HRESULT WINAPI
video_mixer_attributes_GetItem(IMFAttributes
*iface
, REFGUID key
, PROPVARIANT
*value
)
1919 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1921 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1923 return IMFAttributes_GetItem(mixer
->internal_attributes
, key
, value
);
1926 static HRESULT WINAPI
video_mixer_attributes_GetItemType(IMFAttributes
*iface
, REFGUID key
, MF_ATTRIBUTE_TYPE
*type
)
1928 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1930 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), type
);
1932 return IMFAttributes_GetItemType(mixer
->internal_attributes
, key
, type
);
1935 static HRESULT WINAPI
video_mixer_attributes_CompareItem(IMFAttributes
*iface
, REFGUID key
,
1936 REFPROPVARIANT value
, BOOL
*result
)
1938 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1940 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, result
);
1942 return IMFAttributes_CompareItem(mixer
->internal_attributes
, key
, value
, result
);
1945 static HRESULT WINAPI
video_mixer_attributes_Compare(IMFAttributes
*iface
, IMFAttributes
*theirs
,
1946 MF_ATTRIBUTES_MATCH_TYPE match_type
, BOOL
*ret
)
1948 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1950 TRACE("%p, %p, %d, %p.\n", iface
, theirs
, match_type
, ret
);
1952 return IMFAttributes_Compare(mixer
->internal_attributes
, theirs
, match_type
, ret
);
1955 static HRESULT WINAPI
video_mixer_attributes_GetUINT32(IMFAttributes
*iface
, REFGUID key
, UINT32
*value
)
1957 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1959 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1961 return IMFAttributes_GetUINT32(mixer
->internal_attributes
, key
, value
);
1964 static HRESULT WINAPI
video_mixer_attributes_GetUINT64(IMFAttributes
*iface
, REFGUID key
, UINT64
*value
)
1966 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1968 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1970 return IMFAttributes_GetUINT64(mixer
->internal_attributes
, key
, value
);
1973 static HRESULT WINAPI
video_mixer_attributes_GetDouble(IMFAttributes
*iface
, REFGUID key
, double *value
)
1975 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1977 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1979 return IMFAttributes_GetDouble(mixer
->internal_attributes
, key
, value
);
1982 static HRESULT WINAPI
video_mixer_attributes_GetGUID(IMFAttributes
*iface
, REFGUID key
, GUID
*value
)
1984 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1986 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
1988 return IMFAttributes_GetGUID(mixer
->internal_attributes
, key
, value
);
1991 static HRESULT WINAPI
video_mixer_attributes_GetStringLength(IMFAttributes
*iface
, REFGUID key
, UINT32
*length
)
1993 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
1995 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), length
);
1997 return IMFAttributes_GetStringLength(mixer
->internal_attributes
, key
, length
);
2000 static HRESULT WINAPI
video_mixer_attributes_GetString(IMFAttributes
*iface
, REFGUID key
, WCHAR
*value
,
2001 UINT32 size
, UINT32
*length
)
2003 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2005 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), value
, size
, length
);
2007 return IMFAttributes_GetString(mixer
->internal_attributes
, key
, value
, size
, length
);
2010 static HRESULT WINAPI
video_mixer_attributes_GetAllocatedString(IMFAttributes
*iface
, REFGUID key
,
2011 WCHAR
**value
, UINT32
*length
)
2013 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2015 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), value
, length
);
2017 return IMFAttributes_GetAllocatedString(mixer
->internal_attributes
, key
, value
, length
);
2020 static HRESULT WINAPI
video_mixer_attributes_GetBlobSize(IMFAttributes
*iface
, REFGUID key
, UINT32
*size
)
2022 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2024 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), size
);
2026 return IMFAttributes_GetBlobSize(mixer
->internal_attributes
, key
, size
);
2029 static HRESULT WINAPI
video_mixer_attributes_GetBlob(IMFAttributes
*iface
, REFGUID key
, UINT8
*buf
,
2030 UINT32 bufsize
, UINT32
*blobsize
)
2032 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2034 TRACE("%p, %s, %p, %d, %p.\n", iface
, debugstr_guid(key
), buf
, bufsize
, blobsize
);
2036 return IMFAttributes_GetBlob(mixer
->internal_attributes
, key
, buf
, bufsize
, blobsize
);
2039 static HRESULT WINAPI
video_mixer_attributes_GetAllocatedBlob(IMFAttributes
*iface
, REFGUID key
, UINT8
**buf
, UINT32
*size
)
2041 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2043 TRACE("%p, %s, %p, %p.\n", iface
, debugstr_guid(key
), buf
, size
);
2045 return IMFAttributes_GetAllocatedBlob(mixer
->internal_attributes
, key
, buf
, size
);
2048 static HRESULT WINAPI
video_mixer_attributes_GetUnknown(IMFAttributes
*iface
, REFGUID key
, REFIID riid
, void **out
)
2050 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2052 TRACE("%p, %s, %s, %p.\n", iface
, debugstr_guid(key
), debugstr_guid(riid
), out
);
2054 return IMFAttributes_GetUnknown(mixer
->internal_attributes
, key
, riid
, out
);
2057 static HRESULT WINAPI
video_mixer_attributes_SetItem(IMFAttributes
*iface
, REFGUID key
, REFPROPVARIANT value
)
2059 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2061 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), value
);
2063 return IMFAttributes_SetItem(mixer
->internal_attributes
, key
, value
);
2066 static HRESULT WINAPI
video_mixer_attributes_DeleteItem(IMFAttributes
*iface
, REFGUID key
)
2068 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2070 TRACE("%p, %s.\n", iface
, debugstr_guid(key
));
2072 return IMFAttributes_DeleteItem(mixer
->internal_attributes
, key
);
2075 static HRESULT WINAPI
video_mixer_attributes_DeleteAllItems(IMFAttributes
*iface
)
2077 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2079 TRACE("%p.\n", iface
);
2081 return IMFAttributes_DeleteAllItems(mixer
->internal_attributes
);
2084 static HRESULT WINAPI
video_mixer_attributes_SetUINT32(IMFAttributes
*iface
, REFGUID key
, UINT32 value
)
2086 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2088 TRACE("%p, %s, %u.\n", iface
, debugstr_guid(key
), value
);
2090 return IMFAttributes_SetUINT32(mixer
->internal_attributes
, key
, value
);
2093 static HRESULT WINAPI
video_mixer_attributes_SetUINT64(IMFAttributes
*iface
, REFGUID key
, UINT64 value
)
2095 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2097 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), wine_dbgstr_longlong(value
));
2099 return IMFAttributes_SetUINT64(mixer
->internal_attributes
, key
, value
);
2102 static HRESULT WINAPI
video_mixer_attributes_SetDouble(IMFAttributes
*iface
, REFGUID key
, double value
)
2104 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2106 TRACE("%p, %s, %f.\n", iface
, debugstr_guid(key
), value
);
2108 return IMFAttributes_SetDouble(mixer
->internal_attributes
, key
, value
);
2111 static HRESULT WINAPI
video_mixer_attributes_SetGUID(IMFAttributes
*iface
, REFGUID key
, REFGUID value
)
2113 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2115 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_guid(value
));
2117 return IMFAttributes_SetGUID(mixer
->internal_attributes
, key
, value
);
2120 static HRESULT WINAPI
video_mixer_attributes_SetString(IMFAttributes
*iface
, REFGUID key
, const WCHAR
*value
)
2122 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2124 TRACE("%p, %s, %s.\n", iface
, debugstr_guid(key
), debugstr_w(value
));
2126 return IMFAttributes_SetString(mixer
->internal_attributes
, key
, value
);
2129 static HRESULT WINAPI
video_mixer_attributes_SetBlob(IMFAttributes
*iface
, REFGUID key
, const UINT8
*buf
, UINT32 size
)
2131 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2133 TRACE("%p, %s, %p, %u.\n", iface
, debugstr_guid(key
), buf
, size
);
2135 return IMFAttributes_SetBlob(mixer
->internal_attributes
, key
, buf
, size
);
2138 static HRESULT WINAPI
video_mixer_attributes_SetUnknown(IMFAttributes
*iface
, REFGUID key
, IUnknown
*unknown
)
2140 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2142 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(key
), unknown
);
2144 return IMFAttributes_SetUnknown(mixer
->internal_attributes
, key
, unknown
);
2147 static HRESULT WINAPI
video_mixer_attributes_LockStore(IMFAttributes
*iface
)
2149 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2151 TRACE("%p.\n", iface
);
2153 return IMFAttributes_LockStore(mixer
->internal_attributes
);
2156 static HRESULT WINAPI
video_mixer_attributes_UnlockStore(IMFAttributes
*iface
)
2158 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2160 TRACE("%p.\n", iface
);
2162 return IMFAttributes_UnlockStore(mixer
->internal_attributes
);
2165 static HRESULT WINAPI
video_mixer_attributes_GetCount(IMFAttributes
*iface
, UINT32
*count
)
2167 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2169 TRACE("%p, %p.\n", iface
, count
);
2171 return IMFAttributes_GetCount(mixer
->internal_attributes
, count
);
2174 static HRESULT WINAPI
video_mixer_attributes_GetItemByIndex(IMFAttributes
*iface
, UINT32 index
,
2175 GUID
*key
, PROPVARIANT
*value
)
2177 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2179 TRACE("%p, %u, %p, %p.\n", iface
, index
, key
, value
);
2181 return IMFAttributes_GetItemByIndex(mixer
->internal_attributes
, index
, key
, value
);
2184 static HRESULT WINAPI
video_mixer_attributes_CopyAllItems(IMFAttributes
*iface
, IMFAttributes
*dest
)
2186 struct video_mixer
*mixer
= impl_from_IMFAttributes(iface
);
2188 TRACE("%p, %p.\n", iface
, dest
);
2190 return IMFAttributes_CopyAllItems(mixer
->internal_attributes
, dest
);
2193 static const IMFAttributesVtbl video_mixer_attributes_vtbl
=
2195 video_mixer_attributes_QueryInterface
,
2196 video_mixer_attributes_AddRef
,
2197 video_mixer_attributes_Release
,
2198 video_mixer_attributes_GetItem
,
2199 video_mixer_attributes_GetItemType
,
2200 video_mixer_attributes_CompareItem
,
2201 video_mixer_attributes_Compare
,
2202 video_mixer_attributes_GetUINT32
,
2203 video_mixer_attributes_GetUINT64
,
2204 video_mixer_attributes_GetDouble
,
2205 video_mixer_attributes_GetGUID
,
2206 video_mixer_attributes_GetStringLength
,
2207 video_mixer_attributes_GetString
,
2208 video_mixer_attributes_GetAllocatedString
,
2209 video_mixer_attributes_GetBlobSize
,
2210 video_mixer_attributes_GetBlob
,
2211 video_mixer_attributes_GetAllocatedBlob
,
2212 video_mixer_attributes_GetUnknown
,
2213 video_mixer_attributes_SetItem
,
2214 video_mixer_attributes_DeleteItem
,
2215 video_mixer_attributes_DeleteAllItems
,
2216 video_mixer_attributes_SetUINT32
,
2217 video_mixer_attributes_SetUINT64
,
2218 video_mixer_attributes_SetDouble
,
2219 video_mixer_attributes_SetGUID
,
2220 video_mixer_attributes_SetString
,
2221 video_mixer_attributes_SetBlob
,
2222 video_mixer_attributes_SetUnknown
,
2223 video_mixer_attributes_LockStore
,
2224 video_mixer_attributes_UnlockStore
,
2225 video_mixer_attributes_GetCount
,
2226 video_mixer_attributes_GetItemByIndex
,
2227 video_mixer_attributes_CopyAllItems
2230 static HRESULT WINAPI
video_mixer_quality_advise_QueryInterface(IMFQualityAdvise
*iface
, REFIID riid
, void **out
)
2232 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2233 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
2236 static ULONG WINAPI
video_mixer_quality_advise_AddRef(IMFQualityAdvise
*iface
)
2238 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2239 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
2242 static ULONG WINAPI
video_mixer_quality_advise_Release(IMFQualityAdvise
*iface
)
2244 struct video_mixer
*mixer
= impl_from_IMFQualityAdvise(iface
);
2245 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
2248 static HRESULT WINAPI
video_mixer_quality_advise_SetDropMode(IMFQualityAdvise
*iface
, MF_QUALITY_DROP_MODE mode
)
2250 FIXME("%p, %u.\n", iface
, mode
);
2255 static HRESULT WINAPI
video_mixer_quality_advise_SetQualityLevel(IMFQualityAdvise
*iface
, MF_QUALITY_LEVEL level
)
2257 FIXME("%p, %u.\n", iface
, level
);
2262 static HRESULT WINAPI
video_mixer_quality_advise_GetDropMode(IMFQualityAdvise
*iface
, MF_QUALITY_DROP_MODE
*mode
)
2264 FIXME("%p, %p.\n", iface
, mode
);
2269 static HRESULT WINAPI
video_mixer_quality_advise_GetQualityLevel(IMFQualityAdvise
*iface
, MF_QUALITY_LEVEL
*level
)
2271 FIXME("%p, %p.\n", iface
, level
);
2276 static HRESULT WINAPI
video_mixer_quality_advise_DropTime(IMFQualityAdvise
*iface
, LONGLONG interval
)
2278 FIXME("%p, %s.\n", iface
, wine_dbgstr_longlong(interval
));
2283 static const IMFQualityAdviseVtbl video_mixer_quality_advise_vtbl
=
2285 video_mixer_quality_advise_QueryInterface
,
2286 video_mixer_quality_advise_AddRef
,
2287 video_mixer_quality_advise_Release
,
2288 video_mixer_quality_advise_SetDropMode
,
2289 video_mixer_quality_advise_SetQualityLevel
,
2290 video_mixer_quality_advise_GetDropMode
,
2291 video_mixer_quality_advise_GetQualityLevel
,
2292 video_mixer_quality_advise_DropTime
,
2295 static HRESULT WINAPI
video_mixer_clock_state_sink_QueryInterface(IMFClockStateSink
*iface
,
2296 REFIID riid
, void **out
)
2298 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2299 return IMFTransform_QueryInterface(&mixer
->IMFTransform_iface
, riid
, out
);
2302 static ULONG WINAPI
video_mixer_clock_state_sink_AddRef(IMFClockStateSink
*iface
)
2304 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2305 return IMFTransform_AddRef(&mixer
->IMFTransform_iface
);
2308 static ULONG WINAPI
video_mixer_clock_state_sink_Release(IMFClockStateSink
*iface
)
2310 struct video_mixer
*mixer
= impl_from_IMFClockStateSink(iface
);
2311 return IMFTransform_Release(&mixer
->IMFTransform_iface
);
2314 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockStart(IMFClockStateSink
*iface
,
2315 MFTIME systime
, LONGLONG offset
)
2317 FIXME("%p.\n", iface
);
2322 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockStop(IMFClockStateSink
*iface
,
2325 FIXME("%p.\n", iface
);
2330 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockPause(IMFClockStateSink
*iface
,
2333 FIXME("%p.\n", iface
);
2338 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockRestart(IMFClockStateSink
*iface
,
2341 FIXME("%p.\n", iface
);
2346 static HRESULT WINAPI
video_mixer_clock_state_sink_OnClockSetRate(IMFClockStateSink
*iface
,
2347 MFTIME systime
, float rate
)
2349 FIXME("%p, %f.\n", iface
, rate
);
2354 static const IMFClockStateSinkVtbl video_mixer_clock_state_sink_vtbl
=
2356 video_mixer_clock_state_sink_QueryInterface
,
2357 video_mixer_clock_state_sink_AddRef
,
2358 video_mixer_clock_state_sink_Release
,
2359 video_mixer_clock_state_sink_OnClockStart
,
2360 video_mixer_clock_state_sink_OnClockStop
,
2361 video_mixer_clock_state_sink_OnClockPause
,
2362 video_mixer_clock_state_sink_OnClockRestart
,
2363 video_mixer_clock_state_sink_OnClockSetRate
,
2366 HRESULT WINAPI
MFCreateVideoMixer(IUnknown
*owner
, REFIID riid_device
, REFIID riid
, void **obj
)
2368 TRACE("%p, %s, %s, %p.\n", owner
, debugstr_guid(riid_device
), debugstr_guid(riid
), obj
);
2372 if (!IsEqualIID(riid_device
, &IID_IDirect3DDevice9
))
2373 return E_INVALIDARG
;
2375 return CoCreateInstance(&CLSID_MFVideoMixer9
, owner
, CLSCTX_INPROC_SERVER
, riid
, obj
);
2378 HRESULT
evr_mixer_create(IUnknown
*outer
, void **out
)
2380 struct video_mixer
*object
;
2381 MFVideoNormalizedRect rect
;
2384 if (!(object
= calloc(1, sizeof(*object
))))
2385 return E_OUTOFMEMORY
;
2387 object
->IMFTransform_iface
.lpVtbl
= &video_mixer_transform_vtbl
;
2388 object
->IMFVideoDeviceID_iface
.lpVtbl
= &video_mixer_device_id_vtbl
;
2389 object
->IMFTopologyServiceLookupClient_iface
.lpVtbl
= &video_mixer_service_client_vtbl
;
2390 object
->IMFVideoMixerControl2_iface
.lpVtbl
= &video_mixer_control_vtbl
;
2391 object
->IMFGetService_iface
.lpVtbl
= &video_mixer_getservice_vtbl
;
2392 object
->IMFVideoMixerBitmap_iface
.lpVtbl
= &video_mixer_bitmap_vtbl
;
2393 object
->IMFVideoPositionMapper_iface
.lpVtbl
= &video_mixer_position_mapper_vtbl
;
2394 object
->IMFVideoProcessor_iface
.lpVtbl
= &video_mixer_processor_vtbl
;
2395 object
->IMFAttributes_iface
.lpVtbl
= &video_mixer_attributes_vtbl
;
2396 object
->IMFQualityAdvise_iface
.lpVtbl
= &video_mixer_quality_advise_vtbl
;
2397 object
->IMFClockStateSink_iface
.lpVtbl
= &video_mixer_clock_state_sink_vtbl
;
2398 object
->IUnknown_inner
.lpVtbl
= &video_mixer_inner_vtbl
;
2399 object
->outer_unk
= outer
? outer
: &object
->IUnknown_inner
;
2400 object
->refcount
= 1;
2401 object
->input_count
= 1;
2402 object
->lower_bound
= MFT_OUTPUT_BOUND_LOWER_UNBOUNDED
;
2403 object
->upper_bound
= MFT_OUTPUT_BOUND_UPPER_UNBOUNDED
;
2404 video_mixer_init_input(&object
->inputs
[0]);
2405 InitializeCriticalSection(&object
->cs
);
2406 if (FAILED(hr
= MFCreateAttributes(&object
->attributes
, 0)))
2408 IUnknown_Release(&object
->IUnknown_inner
);
2411 if (FAILED(hr
= MFCreateAttributes(&object
->internal_attributes
, 0)))
2413 IUnknown_Release(&object
->IUnknown_inner
);
2417 /* Default attributes configuration. */
2419 rect
.left
= rect
.top
= 0.0f
;
2420 rect
.right
= rect
.bottom
= 1.0f
;
2421 IMFAttributes_SetBlob(object
->attributes
, &VIDEO_ZOOM_RECT
, (const UINT8
*)&rect
, sizeof(rect
));
2423 IMFAttributes_SetUINT32(object
->internal_attributes
, &MF_SA_D3D_AWARE
, 1);
2425 *out
= &object
->IUnknown_inner
;