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;