Needed by LINE.
The IMediaTranscoder2 definition isn't needed for this, but it's small enough to add in case it's used by mingw.
-- v3: windows.media: Implement IActivationFactory::ActivateInstance() for IMediaTranscoder.
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/windows.media.core.idl | 58 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 include/windows.media.core.idl
diff --git a/include/Makefile.in b/include/Makefile.in index f4c401d1245..45dfcf04cb1 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -896,6 +896,7 @@ SOURCES = \ windows.management.deployment.idl \ windows.media.capture.idl \ windows.media.closedcaptioning.idl \ + windows.media.core.idl \ windows.media.devices.idl \ windows.media.effects.idl \ windows.media.faceanalysis.idl \ diff --git a/include/windows.media.core.idl b/include/windows.media.core.idl new file mode 100644 index 00000000000..9df8656a425 --- /dev/null +++ b/include/windows.media.core.idl @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +/* import "windows.applicationmodel.appservice.idl"; */ +import "windows.graphics.directx.direct3d11.idl"; +import "windows.graphics.imaging.idl"; +import "windows.media.idl"; +import "windows.media.capture.idl"; +/* import "windows.media.capture.frames.idl"; */ +import "windows.media.devices.idl"; +/* import "windows.media.devices.core.idl"; */ +import "windows.media.effects.idl"; +import "windows.media.faceanalysis.idl"; +/* import "windows.media.mediaproperties.idl"; */ +/* import "windows.media.playback.idl"; */ +/* import "windows.media.protection.idl"; */ +/* import "windows.media.streaming.adaptive.idl"; */ +/* import "windows.networking.backgroundtransfer.idl"; */ +import "windows.storage.idl"; +import "windows.storage.fileproperties.idl"; +import "windows.storage.streams.idl"; +import "windows.ui.idl"; + +namespace Windows.Media.Core { + interface IMediaSource; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + uuid(e7bfb599-a09d-4c21-bcdf-20af4f86b3d9) + ] + interface IMediaSource : IInspectable + { + } +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/windows.media.core.idl | 2 +- include/windows.media.mediaproperties.idl | 210 ++++++++++++++++++++++ 3 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 include/windows.media.mediaproperties.idl
diff --git a/include/Makefile.in b/include/Makefile.in index 45dfcf04cb1..dc561fb31d9 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -901,6 +901,7 @@ SOURCES = \ windows.media.effects.idl \ windows.media.faceanalysis.idl \ windows.media.idl \ + windows.media.mediaproperties.idl \ windows.media.render.idl \ windows.media.speechrecognition.idl \ windows.media.speechsynthesis.idl \ diff --git a/include/windows.media.core.idl b/include/windows.media.core.idl index 9df8656a425..7eb30cafb81 100644 --- a/include/windows.media.core.idl +++ b/include/windows.media.core.idl @@ -35,7 +35,7 @@ import "windows.media.devices.idl"; /* import "windows.media.devices.core.idl"; */ import "windows.media.effects.idl"; import "windows.media.faceanalysis.idl"; -/* import "windows.media.mediaproperties.idl"; */ +import "windows.media.mediaproperties.idl"; /* import "windows.media.playback.idl"; */ /* import "windows.media.protection.idl"; */ /* import "windows.media.streaming.adaptive.idl"; */ diff --git a/include/windows.media.mediaproperties.idl b/include/windows.media.mediaproperties.idl new file mode 100644 index 00000000000..904090937eb --- /dev/null +++ b/include/windows.media.mediaproperties.idl @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.media.core.idl"; +import "windows.storage.idl"; +import "windows.storage.streams.idl"; + +namespace Windows.Media.MediaProperties { + interface IAudioEncodingProperties; + interface IAudioEncodingProperties2; + interface IAudioEncodingProperties3; + interface IAudioEncodingPropertiesStatics; + interface IAudioEncodingPropertiesStatics2; + interface IAudioEncodingPropertiesWithFormatUserData; + interface IContainerEncodingProperties; + interface IContainerEncodingProperties2; + interface IMediaEncodingProfile; + interface IMediaEncodingProfile2; + interface IMediaEncodingProfile3; + interface IMediaEncodingProfileStatics; + interface IMediaEncodingProfileStatics2; + interface IMediaEncodingProfileStatics3; + interface IMediaEncodingProperties; + interface IMediaRatio; + interface IVideoEncodingProperties; + interface IVideoEncodingProperties2; + interface IVideoEncodingProperties3; + interface IVideoEncodingProperties4; + interface IVideoEncodingProperties5; + interface IVideoEncodingPropertiesStatics; + interface IVideoEncodingPropertiesStatics2; + + runtimeclass AudioEncodingProperties; + runtimeclass ContainerEncodingProperties; + runtimeclass MediaEncodingProfile; + runtimeclass MediaRatio; + runtimeclass VideoEncodingProperties; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.MediaProperties.AudioEncodingProperties), + uuid(62bc7a16-005c-4b3b-8a0b-0a090e9687f3) + ] + interface IAudioEncodingProperties : IInspectable + requires Windows.Media.MediaProperties.IMediaEncodingProperties + { + [propput] HRESULT Bitrate([in] UINT32 value); + [propget] HRESULT Bitrate([out, retval] UINT32 *value); + [propput] HRESULT ChannelCount([in] UINT32 value); + [propget] HRESULT ChannelCount([out, retval] UINT32 *value); + [propput] HRESULT SampleRate([in] UINT32 value); + [propget] HRESULT SampleRate([out, retval] UINT32 *value); + [propput] HRESULT BitsPerSample([in] UINT32 value); + [propget] HRESULT BitsPerSample([out, retval] UINT32 *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.MediaProperties.ContainerEncodingProperties), + uuid(59ac2a57-b32a-479e-8a61-4b7f2e9e7ea0) + ] + interface IContainerEncodingProperties : IInspectable + requires Windows.Media.MediaProperties.IMediaEncodingProperties + { + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.MediaProperties.MediaEncodingProfile), + uuid(e7dbf5a8-1db9-4783-876b-3dfe12acfdb3) + ] + interface IMediaEncodingProfile : IInspectable + { + [propput] HRESULT Audio([in] Windows.Media.MediaProperties.AudioEncodingProperties *value); + [propget] HRESULT Audio([out, retval] Windows.Media.MediaProperties.AudioEncodingProperties **value); + [propput] HRESULT Video([in] Windows.Media.MediaProperties.VideoEncodingProperties *value); + [propget] HRESULT Video([out, retval] Windows.Media.MediaProperties.VideoEncodingProperties **value); + [propput] HRESULT Container([in] Windows.Media.MediaProperties.ContainerEncodingProperties *value); + [propget] HRESULT Container([out, retval] Windows.Media.MediaProperties.ContainerEncodingProperties **value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.MediaProperties.MediaRatio), + uuid(d2d0fee5-8929-401d-ac78-7d357e378163) + ] + interface IMediaRatio : IInspectable + { + [propput] HRESULT Numerator([in] UINT32 value); + [propget] HRESULT Numerator([out, retval] UINT32 *value); + [propput] HRESULT Denominator([in] UINT32 value); + [propget] HRESULT Denominator([out, retval] UINT32 *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.MediaProperties.VideoEncodingProperties), + uuid(76ee6c9a-37c2-4f2a-880a-1282bbb4373d) + ] + interface IVideoEncodingProperties : IInspectable + requires Windows.Media.MediaProperties.IMediaEncodingProperties + { + [propput] HRESULT Bitrate([in] UINT32 value); + [propget] HRESULT Bitrate([out, retval] UINT32 *value); + [propput] HRESULT Width([in] UINT32 value); + [propget] HRESULT Width([out, retval] UINT32 *value); + [propput] HRESULT Height([in] UINT32 value); + [propget] HRESULT Height([out, retval] UINT32 *value); + [propget] HRESULT FrameRate([out, retval] Windows.Media.MediaProperties.MediaRatio **value); + [propget] HRESULT PixelAspectRatio([out, retval] Windows.Media.MediaProperties.MediaRatio **value); + } + + [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Media.MediaProperties.IAudioEncodingPropertiesStatics, Windows.Foundation.UniversalApiContract, 1.0), + static(Windows.Media.MediaProperties.IAudioEncodingPropertiesStatics2, Windows.Foundation.UniversalApiContract, 4.0), + threading(both) + ] + runtimeclass AudioEncodingProperties + { + [default] interface Windows.Media.MediaProperties.IAudioEncodingProperties; + interface Windows.Media.MediaProperties.IMediaEncodingProperties; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Media.MediaProperties.IAudioEncodingPropertiesWithFormatUserData; + [contract(Windows.Foundation.UniversalApiContract, 4.0)] interface Windows.Media.MediaProperties.IAudioEncodingProperties2; + [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Media.MediaProperties.IAudioEncodingProperties3; + } + + [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass ContainerEncodingProperties + { + [default] interface Windows.Media.MediaProperties.IContainerEncodingProperties; + interface Windows.Media.MediaProperties.IMediaEncodingProperties; + [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Media.MediaProperties.IContainerEncodingProperties2; + } + + [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Media.MediaProperties.IMediaEncodingProfileStatics, Windows.Foundation.UniversalApiContract, 1.0), + static(Windows.Media.MediaProperties.IMediaEncodingProfileStatics2, Windows.Foundation.UniversalApiContract, 1.0), + static(Windows.Media.MediaProperties.IMediaEncodingProfileStatics3, Windows.Foundation.UniversalApiContract, 4.0), + threading(mta) + ] + runtimeclass MediaEncodingProfile + { + [default] interface Windows.Media.MediaProperties.IMediaEncodingProfile; + [contract(Windows.Foundation.UniversalApiContract, 5.0)] interface Windows.Media.MediaProperties.IMediaEncodingProfile2; + [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Media.MediaProperties.IMediaEncodingProfile3; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass MediaRatio + { + [default] interface Windows.Media.MediaProperties.IMediaRatio; + } + + [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + static(Windows.Media.MediaProperties.IVideoEncodingPropertiesStatics, Windows.Foundation.UniversalApiContract, 1.0), + static(Windows.Media.MediaProperties.IVideoEncodingPropertiesStatics2, Windows.Foundation.UniversalApiContract, 4.0), + threading(both) + ] + runtimeclass VideoEncodingProperties + { + [default] interface Windows.Media.MediaProperties.IVideoEncodingProperties; + interface Windows.Media.MediaProperties.IMediaEncodingProperties; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Media.MediaProperties.IVideoEncodingProperties2; + [contract(Windows.Foundation.UniversalApiContract, 3.0)] interface Windows.Media.MediaProperties.IVideoEncodingProperties3; + [contract(Windows.Foundation.UniversalApiContract, 4.0)] interface Windows.Media.MediaProperties.IVideoEncodingProperties4; + [contract(Windows.Foundation.UniversalApiContract, 6.0)] interface Windows.Media.MediaProperties.IVideoEncodingProperties5; + } +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- include/Makefile.in | 1 + include/windows.media.transcoding.idl | 152 ++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 include/windows.media.transcoding.idl
diff --git a/include/Makefile.in b/include/Makefile.in index dc561fb31d9..488d75d7d78 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -905,6 +905,7 @@ SOURCES = \ windows.media.render.idl \ windows.media.speechrecognition.idl \ windows.media.speechsynthesis.idl \ + windows.media.transcoding.idl \ windows.networking.connectivity.idl \ windows.networking.idl \ windows.networking.sockets.idl \ diff --git a/include/windows.media.transcoding.idl b/include/windows.media.transcoding.idl new file mode 100644 index 00000000000..b7b543b17e3 --- /dev/null +++ b/include/windows.media.transcoding.idl @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; +import "windows.media.core.idl"; +import "windows.media.mediaproperties.idl"; +import "windows.storage.idl"; +import "windows.storage.streams.idl"; + +namespace Windows.Media.Transcoding { + typedef enum MediaVideoProcessingAlgorithm MediaVideoProcessingAlgorithm; + typedef enum TranscodeFailureReason TranscodeFailureReason; + + interface IMediaTranscoder; + interface IMediaTranscoder2; + interface IPrepareTranscodeResult; + + runtimeclass MediaTranscoder; + runtimeclass PrepareTranscodeResult; + + declare { + interface Windows.Foundation.IAsyncActionWithProgress<DOUBLE>; + interface Windows.Foundation.AsyncActionProgressHandler<DOUBLE>; + interface Windows.Foundation.AsyncActionWithProgressCompletedHandler<DOUBLE>; + interface Windows.Foundation.IAsyncOperation<Windows.Media.Transcoding.PrepareTranscodeResult *>; + interface Windows.Foundation.IAsyncOperation<Windows.Media.Transcoding.TranscodeFailureReason>; + interface Windows.Foundation.IAsyncOperationWithProgress<Windows.Media.Transcoding.TranscodeFailureReason, DOUBLE>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Media.Transcoding.PrepareTranscodeResult *>; + interface Windows.Foundation.AsyncOperationCompletedHandler<Windows.Media.Transcoding.TranscodeFailureReason>; + interface Windows.Foundation.AsyncOperationWithProgressCompletedHandler<Windows.Media.Transcoding.TranscodeFailureReason, DOUBLE>; + interface Windows.Foundation.AsyncOperationProgressHandler<Windows.Media.Transcoding.TranscodeFailureReason, DOUBLE>; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum MediaVideoProcessingAlgorithm + { + Default = 0, + MrfCrf444 = 1, + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0) + ] + enum TranscodeFailureReason + { + None = 0, + Unknown = 1, + InvalidProfile = 2, + CodecNotFound = 3, + }; + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.Transcoding.MediaTranscoder), + uuid(190c99d2-a0aa-4d34-86bc-eed1b12c2f5b) + ] + interface IMediaTranscoder : IInspectable + { + [propput] HRESULT TrimStartTime([in] Windows.Foundation.TimeSpan value); + [propget] HRESULT TrimStartTime([out, retval] Windows.Foundation.TimeSpan *value); + [propput] HRESULT TrimStopTime([in] Windows.Foundation.TimeSpan value); + [propget] HRESULT TrimStopTime([out, retval] Windows.Foundation.TimeSpan *value); + [propput] HRESULT AlwaysReencode([in] boolean value); + [propget] HRESULT AlwaysReencode([out, retval] boolean *value); + [propput] HRESULT HardwareAccelerationEnabled([in] boolean value); + [propget] HRESULT HardwareAccelerationEnabled([out, retval] boolean *value); + HRESULT AddAudioEffect([in] HSTRING activatable_class_id); + HRESULT AddAudioEffectWithSettings([in] HSTRING activatable_class_id, [in] boolean effect_required, [in] Windows.Foundation.Collections.IPropertySet *configuration); + HRESULT AddVideoEffect([in] HSTRING activatable_class_id); + HRESULT AddVideoEffectWithSettings([in] HSTRING activatable_class_id, [in] boolean effect_required, [in] Windows.Foundation.Collections.IPropertySet *configuration); + HRESULT ClearEffects(); + HRESULT PrepareFileTranscodeAsync([in] Windows.Storage.IStorageFile *source, [in] Windows.Storage.IStorageFile *destination, + [in] Windows.Media.MediaProperties.MediaEncodingProfile *profile, + [out, retval] Windows.Foundation.IAsyncOperation<Windows.Media.Transcoding.PrepareTranscodeResult *> **operation); + HRESULT PrepareStreamTranscodeAsync([in] Windows.Storage.Streams.IRandomAccessStream *source, [in] Windows.Storage.Streams.IRandomAccessStream *destination, + [in] Windows.Media.MediaProperties.MediaEncodingProfile *profile, + [out, retval] Windows.Foundation.IAsyncOperation<Windows.Media.Transcoding.PrepareTranscodeResult *> **operation); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.Transcoding.MediaTranscoder), + uuid(40531d74-35e0-4f04-8574-ca8bc4e5a082) + ] + interface IMediaTranscoder2 : IInspectable + { + HRESULT PrepareMediaStreamSourceTranscodeAsync([in] Windows.Media.Core.IMediaSource *source, [in] Windows.Storage.Streams.IRandomAccessStream *destination, + [in] Windows.Media.MediaProperties.MediaEncodingProfile *profile, + [out, retval] Windows.Foundation.IAsyncOperation<Windows.Media.Transcoding.PrepareTranscodeResult *> **operation); + [propput] HRESULT VideoProcessingAlgorithm([in] Windows.Media.Transcoding.MediaVideoProcessingAlgorithm value); + [propget] HRESULT VideoProcessingAlgorithm([out, retval] Windows.Media.Transcoding.MediaVideoProcessingAlgorithm *value); + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + exclusiveto(Windows.Media.Transcoding.PrepareTranscodeResult), + uuid(05f25dce-994f-4a34-9d68-97ccce1730d6) + ] + interface IPrepareTranscodeResult : IInspectable + { + [propget] HRESULT CanTranscode([out, retval] boolean *value); + [propget] HRESULT FailureReason([out, retval] Windows.Media.Transcoding.TranscodeFailureReason *value); + HRESULT TranscodeAsync([out, retval] Windows.Foundation.IAsyncActionWithProgress<DOUBLE> **operation); + } + + [ + activatable(Windows.Foundation.UniversalApiContract, 1.0), + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass MediaTranscoder + { + [default] interface Windows.Media.Transcoding.IMediaTranscoder; + [contract(Windows.Foundation.UniversalApiContract, 1.0)] interface Windows.Media.Transcoding.IMediaTranscoder2; + } + + [ + contract(Windows.Foundation.UniversalApiContract, 1.0), + marshaling_behavior(agile), + threading(both) + ] + runtimeclass PrepareTranscodeResult + { + [default] interface Windows.Media.Transcoding.IPrepareTranscodeResult; + } +}
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Needed by LINE. --- dlls/windows.media/Makefile.in | 3 +- dlls/windows.media/classes.idl | 1 + dlls/windows.media/main.c | 2 + dlls/windows.media/private.h | 6 + dlls/windows.media/tests/Makefile.in | 2 +- .../tests/{captions.c => media.c} | 49 ++- dlls/windows.media/transcoder.c | 321 ++++++++++++++++++ 7 files changed, 381 insertions(+), 3 deletions(-) rename dlls/windows.media/tests/{captions.c => media.c} (79%) create mode 100644 dlls/windows.media/transcoder.c
diff --git a/dlls/windows.media/Makefile.in b/dlls/windows.media/Makefile.in index 9ab83d7e07f..acc3db1baef 100644 --- a/dlls/windows.media/Makefile.in +++ b/dlls/windows.media/Makefile.in @@ -4,4 +4,5 @@ IMPORTS = combase SOURCES = \ captions.c \ classes.idl \ - main.c + main.c \ + transcoder.c diff --git a/dlls/windows.media/classes.idl b/dlls/windows.media/classes.idl index 12424bbc90a..63db8409f9d 100644 --- a/dlls/windows.media/classes.idl +++ b/dlls/windows.media/classes.idl @@ -21,3 +21,4 @@ #pragma makedep register
#include "windows.media.closedcaptioning.idl" +#include "windows.media.transcoding.idl" diff --git a/dlls/windows.media/main.c b/dlls/windows.media/main.c index 7c0ea0e5b62..8a55c4b78d4 100644 --- a/dlls/windows.media/main.c +++ b/dlls/windows.media/main.c @@ -40,6 +40,8 @@ HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **fac
if (!wcscmp( buffer, RuntimeClass_Windows_Media_ClosedCaptioning_ClosedCaptionProperties )) IActivationFactory_QueryInterface( captions_factory, &IID_IActivationFactory, (void **)factory ); + if (!wcscmp( buffer, RuntimeClass_Windows_Media_Transcoding_MediaTranscoder )) + IActivationFactory_QueryInterface( media_transcoder_factory, &IID_IActivationFactory, (void **)factory );
if (*factory) return S_OK; return CLASS_E_CLASSNOTAVAILABLE; diff --git a/dlls/windows.media/private.h b/dlls/windows.media/private.h index f8756dadd47..ba61c8d9cb7 100644 --- a/dlls/windows.media/private.h +++ b/dlls/windows.media/private.h @@ -36,8 +36,14 @@ #include "windows.ui.h" #define WIDL_using_Windows_Media_ClosedCaptioning #include "windows.media.closedcaptioning.h" +#define WIDL_using_Windows_Storage_Streams +#define WIDL_using_Windows_Storage +#define WIDL_using_Windows_Media_MediaProperties +#define WIDL_using_Windows_Media_Transcoding +#include "windows.media.transcoding.h"
extern IActivationFactory *captions_factory; +extern IActivationFactory *media_transcoder_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ static inline impl_type *impl_from( iface_type *iface ) \ diff --git a/dlls/windows.media/tests/Makefile.in b/dlls/windows.media/tests/Makefile.in index 479d91c9117..79f1aa79103 100644 --- a/dlls/windows.media/tests/Makefile.in +++ b/dlls/windows.media/tests/Makefile.in @@ -2,4 +2,4 @@ TESTDLL = windows.media.dll IMPORTS = combase
SOURCES = \ - captions.c + media.c diff --git a/dlls/windows.media/tests/captions.c b/dlls/windows.media/tests/media.c similarity index 79% rename from dlls/windows.media/tests/captions.c rename to dlls/windows.media/tests/media.c index c496a8503fb..bcd72be19b1 100644 --- a/dlls/windows.media/tests/captions.c +++ b/dlls/windows.media/tests/media.c @@ -32,6 +32,8 @@ #include "windows.ui.h" #define WIDL_using_Windows_Media_ClosedCaptioning #include "windows.media.closedcaptioning.h" +#define WIDL_using_Windows_Media_Transcoding +#include "windows.media.transcoding.h"
#include "wine/test.h"
@@ -151,7 +153,51 @@ static void test_CaptionStatics(void) ok( ref == 1, "got ref %ld.\n", ref ); }
-START_TEST(captions) +static void test_MediaTranscoderStatics(void) +{ + static const WCHAR *media_transcoder_name = L"Windows.Media.Transcoding.MediaTranscoder"; + IMediaTranscoder *media_transcoder = (void *)0xdeadbeef; + IActivationFactory *factory = (void *)0xdeadbeef; + IInspectable *inspectable = (void *)0xdeadbeef; + HSTRING str; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( media_transcoder_name, wcslen( media_transcoder_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + ok( hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "got hr %#lx.\n", hr ); + if (hr == REGDB_E_CLASSNOTREG) + { + WindowsDeleteString( str ); + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( media_transcoder_name )); + return; + } + + check_interface( factory, &IID_IUnknown, TRUE ); + check_interface( factory, &IID_IInspectable, TRUE ); + check_interface( factory, &IID_IAgileObject, FALSE ); + check_interface( factory, &IID_IMediaTranscoder, FALSE ); + + hr = RoActivateInstance( str, &inspectable ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + hr = IInspectable_QueryInterface( inspectable, &IID_IMediaTranscoder, (void **)&media_transcoder ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + check_interface( media_transcoder, &IID_IAgileObject, TRUE ); + + ref = IMediaTranscoder_Release( media_transcoder ); + ok( ref == 1, "got ref %ld.\n", ref ); + ref = IInspectable_Release( inspectable ); + ok( ref == 0, "got ref %ld.\n", ref ); + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + +START_TEST(media) { HRESULT hr;
@@ -159,6 +205,7 @@ START_TEST(captions) ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr );
test_CaptionStatics(); + test_MediaTranscoderStatics();
RoUninitialize(); } diff --git a/dlls/windows.media/transcoder.c b/dlls/windows.media/transcoder.c new file mode 100644 index 00000000000..f934b74f5e5 --- /dev/null +++ b/dlls/windows.media/transcoder.c @@ -0,0 +1,321 @@ +/* WinRT Windows.Media.Transcoding.MediaTranscoder Implementation + * + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "private.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(media); + +struct media_transcoder +{ + IMediaTranscoder IMediaTranscoder_iface; + LONG ref; +}; + +static inline struct media_transcoder *impl_from_IMediaTranscoder( IMediaTranscoder *iface ) +{ + return CONTAINING_RECORD( iface, struct media_transcoder, IMediaTranscoder_iface ); +} + +static HRESULT WINAPI media_transcoder_QueryInterface( IMediaTranscoder *iface, REFIID iid, void **out ) +{ + struct media_transcoder *impl = impl_from_IMediaTranscoder( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IMediaTranscoder )) + { + *out = &impl->IMediaTranscoder_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI media_transcoder_AddRef( IMediaTranscoder *iface ) +{ + struct media_transcoder *impl = impl_from_IMediaTranscoder( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI media_transcoder_Release( IMediaTranscoder *iface ) +{ + struct media_transcoder *impl = impl_from_IMediaTranscoder( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); + + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI media_transcoder_GetIids( IMediaTranscoder *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_GetRuntimeClassName( IMediaTranscoder *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_GetTrustLevel( IMediaTranscoder *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_put_TrimStartTime( IMediaTranscoder *iface, TimeSpan value ) +{ + FIXME( "iface %p, value %I64d stub!\n", iface, value.Duration ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_get_TrimStartTime( IMediaTranscoder *iface, TimeSpan *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_put_TrimStopTime( IMediaTranscoder *iface, TimeSpan value ) +{ + FIXME( "iface %p, value %I64d stub!\n", iface, value.Duration ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_get_TrimStopTime( IMediaTranscoder *iface, TimeSpan *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_put_AlwaysReencode( IMediaTranscoder *iface, boolean value ) +{ + FIXME( "iface %p, value %u stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_get_AlwaysReencode( IMediaTranscoder *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_put_HardwareAccelerationEnabled( IMediaTranscoder *iface, boolean value ) +{ + FIXME( "iface %p, value %u stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_get_HardwareAccelerationEnabled( IMediaTranscoder *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_AddAudioEffect( IMediaTranscoder *iface, HSTRING activatable_class_id ) +{ + FIXME( "iface %p, activatable_class_id %s stub!\n", iface, debugstr_hstring( activatable_class_id ) ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_AddAudioEffectWithSettings( IMediaTranscoder *iface, HSTRING activatable_class_id, + boolean effect_required, IPropertySet *configuration ) +{ + FIXME( "iface %p, activatable_class_id %s, effect_required %u, configuration %p stub!\n", + iface, debugstr_hstring( activatable_class_id ), effect_required, configuration ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_AddVideoEffect( IMediaTranscoder *iface, HSTRING activatable_class_id ) +{ + FIXME( "iface %p, activatable_class_id %s stub!\n", iface, debugstr_hstring( activatable_class_id ) ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_AddVideoEffectWithSettings( IMediaTranscoder *iface, HSTRING activatable_class_id, + boolean effect_required, IPropertySet *configuration ) +{ + FIXME( "iface %p, activatable_class_id %s, effect_required %u, configuration %p stub!\n", + iface, debugstr_hstring( activatable_class_id ), effect_required, configuration ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_ClearEffects( IMediaTranscoder *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_PrepareFileTranscodeAsync( IMediaTranscoder *iface, IStorageFile *source, IStorageFile *destination, + IMediaEncodingProfile *profile, IAsyncOperation_PrepareTranscodeResult **operation ) +{ + FIXME( "iface %p, source %p, destination %p, profile %p, operation %p stub!\n", iface, source, destination, profile, operation ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_transcoder_PrepareStreamTranscodeAsync( IMediaTranscoder *iface, IRandomAccessStream *source, IRandomAccessStream *destination, + IMediaEncodingProfile *profile, IAsyncOperation_PrepareTranscodeResult **operation ) +{ + FIXME( "iface %p, source %p, destination %p, profile %p, operation %p stub!\n", iface, source, destination, profile, operation ); + return E_NOTIMPL; +} + +static const struct IMediaTranscoderVtbl media_transcoder_vtbl = +{ + /* IUnknown methods */ + media_transcoder_QueryInterface, + media_transcoder_AddRef, + media_transcoder_Release, + /* IInspectable methods */ + media_transcoder_GetIids, + media_transcoder_GetRuntimeClassName, + media_transcoder_GetTrustLevel, + /* IMediaTranscoder methods */ + media_transcoder_put_TrimStartTime, + media_transcoder_get_TrimStartTime, + media_transcoder_put_TrimStopTime, + media_transcoder_get_TrimStopTime, + media_transcoder_put_AlwaysReencode, + media_transcoder_get_AlwaysReencode, + media_transcoder_put_HardwareAccelerationEnabled, + media_transcoder_get_HardwareAccelerationEnabled, + media_transcoder_AddAudioEffect, + media_transcoder_AddAudioEffectWithSettings, + media_transcoder_AddVideoEffect, + media_transcoder_AddVideoEffectWithSettings, + media_transcoder_ClearEffects, + media_transcoder_PrepareFileTranscodeAsync, + media_transcoder_PrepareStreamTranscodeAsync, +}; + +struct media_transcoder_statics +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct media_transcoder_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct media_transcoder_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct media_transcoder_statics *impl = impl_from_IActivationFactory( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + *out = &impl->IActivationFactory_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct media_transcoder_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct media_transcoder_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + struct media_transcoder *impl; + + TRACE( "iface %p, instance %p.\n", iface, instance ); + + if (!(impl = calloc( 1, sizeof( *impl ) ))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IMediaTranscoder_iface.lpVtbl = &media_transcoder_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IMediaTranscoder_iface; + return S_OK; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +static struct media_transcoder_statics media_transcoder_statics = +{ + {&factory_vtbl}, + 1, +}; + +IActivationFactory *media_transcoder_factory = &media_transcoder_statics.IActivationFactory_iface;
Rémi Bernon (@rbernon) commented about include/windows.media.transcoding.idl:
uuid(190c99d2-a0aa-4d34-86bc-eed1b12c2f5b)
- ]
- interface IMediaTranscoder : IInspectable
- {
[propput] HRESULT TrimStartTime([in] Windows.Foundation.TimeSpan value);
[propget] HRESULT TrimStartTime([out, retval] Windows.Foundation.TimeSpan *value);
[propput] HRESULT TrimStopTime([in] Windows.Foundation.TimeSpan value);
[propget] HRESULT TrimStopTime([out, retval] Windows.Foundation.TimeSpan *value);
[propput] HRESULT AlwaysReencode([in] boolean value);
[propget] HRESULT AlwaysReencode([out, retval] boolean *value);
[propput] HRESULT HardwareAccelerationEnabled([in] boolean value);
[propget] HRESULT HardwareAccelerationEnabled([out, retval] boolean *value);
HRESULT AddAudioEffect([in] HSTRING activatable_class_id);
HRESULT AddAudioEffectWithSettings([in] HSTRING activatable_class_id, [in] boolean effect_required, [in] Windows.Foundation.Collections.IPropertySet *configuration);
HRESULT AddVideoEffect([in] HSTRING activatable_class_id);
HRESULT AddVideoEffectWithSettings([in] HSTRING activatable_class_id, [in] boolean effect_required, [in] Windows.Foundation.Collections.IPropertySet *configuration);
These four methods should have and `[overload("AddAudioEffect")]` attribute.