From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 2 + .../Makefile.in | 6 + .../classes.idl | 35 ++ .../windows.media.playback.mediaplayer/main.c | 533 ++++++++++++++++++ .../private.h | 39 ++ .../tests/Makefile.in | 5 + .../tests/mediaplayer.c | 100 ++++ .../windows.media.playback.mediaplayer.spec | 3 + include/windows.media.playback.idl | 2 + 9 files changed, 725 insertions(+) create mode 100644 dlls/windows.media.playback.mediaplayer/Makefile.in create mode 100644 dlls/windows.media.playback.mediaplayer/classes.idl create mode 100644 dlls/windows.media.playback.mediaplayer/main.c create mode 100644 dlls/windows.media.playback.mediaplayer/private.h create mode 100644 dlls/windows.media.playback.mediaplayer/tests/Makefile.in create mode 100644 dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c create mode 100644 dlls/windows.media.playback.mediaplayer/windows.media.playback.mediaplayer.spec
diff --git a/configure.ac b/configure.ac index a243ffe31a2..0f639b6670d 100644 --- a/configure.ac +++ b/configure.ac @@ -3294,6 +3294,8 @@ WINE_CONFIG_MAKEFILE(dlls/windows.media.mediacontrol) WINE_CONFIG_MAKEFILE(dlls/windows.media.mediacontrol/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media.playback.backgroundmediaplayer) WINE_CONFIG_MAKEFILE(dlls/windows.media.playback.backgroundmediaplayer/tests) +WINE_CONFIG_MAKEFILE(dlls/windows.media.playback.mediaplayer) +WINE_CONFIG_MAKEFILE(dlls/windows.media.playback.mediaplayer/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media.speech) WINE_CONFIG_MAKEFILE(dlls/windows.media.speech/tests) WINE_CONFIG_MAKEFILE(dlls/windows.media) diff --git a/dlls/windows.media.playback.mediaplayer/Makefile.in b/dlls/windows.media.playback.mediaplayer/Makefile.in new file mode 100644 index 00000000000..9fa6895c9ea --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/Makefile.in @@ -0,0 +1,6 @@ +MODULE = windows.media.playback.mediaplayer.dll +IMPORTS = combase + +SOURCES = \ + classes.idl \ + main.c diff --git a/dlls/windows.media.playback.mediaplayer/classes.idl b/dlls/windows.media.playback.mediaplayer/classes.idl new file mode 100644 index 00000000000..5ed8c1304bd --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/classes.idl @@ -0,0 +1,35 @@ +/* + * Runtime Classes for windows.media.playback.mediaplayer.dll + * + * 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 + */ + +#pragma makedep register + +#ifdef __WIDL__ +#pragma winrt ns_prefix +#endif + +import "inspectable.idl"; +import "asyncinfo.idl"; +import "eventtoken.idl"; +import "windowscontracts.idl"; +import "windows.foundation.idl"; + +#define DO_NO_IMPORTS +#define _WINDOWS_MEDIA_PLAYBACK_MEDIAPLAYER +#include "windows.media.playback.idl" diff --git a/dlls/windows.media.playback.mediaplayer/main.c b/dlls/windows.media.playback.mediaplayer/main.c new file mode 100644 index 00000000000..695b45000ce --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/main.c @@ -0,0 +1,533 @@ +/* WinRT Windows.Media.Playback.MediaPlayer 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 "initguid.h" +#include "private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mediaplayer); + +struct media_player +{ + IMediaPlayer IMediaPlayer_iface; + LONG ref; +}; + +static inline struct media_player *impl_from_IMediaPlayer( IMediaPlayer *iface ) +{ + return CONTAINING_RECORD( iface, struct media_player, IMediaPlayer_iface ); +} + +static HRESULT WINAPI media_player_QueryInterface( IMediaPlayer *iface, REFIID iid, void **out ) +{ + struct media_player *impl = impl_from_IMediaPlayer( 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_IMediaPlayer )) + { + *out = &impl->IMediaPlayer_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_player_AddRef( IMediaPlayer *iface ) +{ + struct media_player *impl = impl_from_IMediaPlayer( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p increasing refcount to %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI media_player_Release( IMediaPlayer *iface ) +{ + struct media_player *impl = impl_from_IMediaPlayer( 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_player_GetIids( IMediaPlayer *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_player_GetRuntimeClassName( IMediaPlayer *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_GetTrustLevel( IMediaPlayer *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_AutoPlay( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_AutoPlay( IMediaPlayer *iface, boolean value ) +{ + FIXME( "iface %p, value %d stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_NaturalDuration( IMediaPlayer *iface, TimeSpan *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_Position( IMediaPlayer *iface, TimeSpan *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_Position( IMediaPlayer *iface, TimeSpan value ) +{ + FIXME( "iface %p, value %I64d stub!\n", iface, value.Duration ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_BufferingProgress( IMediaPlayer *iface, DOUBLE *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_CurrentState( IMediaPlayer *iface, MediaPlayerState *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_CanSeek( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_CanPause( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_IsLoopingEnabled( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_IsLoopingEnabled( IMediaPlayer *iface, boolean value ) +{ + FIXME( "iface %p, value %d stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_IsProtected( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_IsMuted( IMediaPlayer *iface, boolean *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_IsMuted( IMediaPlayer *iface, boolean value ) +{ + FIXME( "iface %p, value %d stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_PlaybackRate( IMediaPlayer *iface, DOUBLE *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_PlaybackRate( IMediaPlayer *iface, DOUBLE value ) +{ + FIXME( "iface %p, value %lf stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_Volume( IMediaPlayer *iface, DOUBLE *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_put_Volume( IMediaPlayer *iface, DOUBLE value ) +{ + FIXME( "iface %p, value %lf stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_get_PlaybackMediaMarkers( IMediaPlayer *iface, IPlaybackMediaMarkerSequence **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_MediaOpened( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_MediaOpened( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_MediaEnded( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_MediaEnded( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_MediaFailed( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_MediaPlayerFailedEventArgs *value, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_MediaFailed( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_CurrentStateChanged( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_CurrentStateChanged( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_PlaybackMediaMarkerReached( IMediaPlayer *iface, + ITypedEventHandler_MediaPlayer_PlaybackMediaMarkerReachedEventArgs *value, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_PlaybackMediaMarkerReached( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_MediaPlayerRateChanged( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_MediaPlayerRateChangedEventArgs *value, + EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_MediaPlayerRateChanged( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_VolumeChanged( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_VolumeChanged( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_SeekCompleted( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_SeekCompleted( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_BufferingStarted( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_BufferingStarted( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_add_BufferingEnded( IMediaPlayer *iface, ITypedEventHandler_MediaPlayer_IInspectable *value, EventRegistrationToken *token ) +{ + FIXME( "iface %p, value %p, token %p stub!\n", iface, value, token ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_remove_BufferingEnded( IMediaPlayer *iface, EventRegistrationToken token ) +{ + FIXME( "iface %p, token %#I64x stub!\n", iface, token.value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_Play( IMediaPlayer *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_Pause( IMediaPlayer *iface ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player_SetUriSource( IMediaPlayer *iface, IUriRuntimeClass *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static const struct IMediaPlayerVtbl media_player_vtbl = +{ + /* IUnknown methods */ + media_player_QueryInterface, + media_player_AddRef, + media_player_Release, + /* IInspectable methods */ + media_player_GetIids, + media_player_GetRuntimeClassName, + media_player_GetTrustLevel, + /* IMediaPlayer methods */ + media_player_get_AutoPlay, + media_player_put_AutoPlay, + media_player_get_NaturalDuration, + media_player_get_Position, + media_player_put_Position, + media_player_get_BufferingProgress, + media_player_get_CurrentState, + media_player_get_CanSeek, + media_player_get_CanPause, + media_player_get_IsLoopingEnabled, + media_player_put_IsLoopingEnabled, + media_player_get_IsProtected, + media_player_get_IsMuted, + media_player_put_IsMuted, + media_player_get_PlaybackRate, + media_player_put_PlaybackRate, + media_player_get_Volume, + media_player_put_Volume, + media_player_get_PlaybackMediaMarkers, + media_player_add_MediaOpened, + media_player_remove_MediaOpened, + media_player_add_MediaEnded, + media_player_remove_MediaEnded, + media_player_add_MediaFailed, + media_player_remove_MediaFailed, + media_player_add_CurrentStateChanged, + media_player_remove_CurrentStateChanged, + media_player_add_PlaybackMediaMarkerReached, + media_player_remove_PlaybackMediaMarkerReached, + media_player_add_MediaPlayerRateChanged, + media_player_remove_MediaPlayerRateChanged, + media_player_add_VolumeChanged, + media_player_remove_VolumeChanged, + media_player_add_SeekCompleted, + media_player_remove_SeekCompleted, + media_player_add_BufferingStarted, + media_player_remove_BufferingStarted, + media_player_add_BufferingEnded, + media_player_remove_BufferingEnded, + media_player_Play, + media_player_Pause, + media_player_SetUriSource, +}; + +struct media_player_statics +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct media_player_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct media_player_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct media_player_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_player_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_player_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_player *impl; + + TRACE( "iface %p, instance %p.\n", iface, instance ); + + if (!(impl = calloc( 1, sizeof( *impl ) ))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IMediaPlayer_iface.lpVtbl = &media_player_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IMediaPlayer_iface; + return S_OK; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + /* IUnknown methods */ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +static struct media_player_statics media_player_statics = +{ + {&factory_vtbl}, + 1, +}; + +static IActivationFactory *media_player_factory = &media_player_statics.IActivationFactory_iface; + +HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID riid, void **out ) +{ + FIXME( "clsid %s, riid %s, out %p stub!\n", debugstr_guid( clsid ), debugstr_guid( riid ), out ); + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **factory ) +{ + const WCHAR *buffer = WindowsGetStringRawBuffer( classid, NULL ); + + TRACE( "class %s, factory %p.\n", debugstr_hstring( classid ), factory ); + + *factory = NULL; + + if (!wcscmp( buffer, RuntimeClass_Windows_Media_Playback_MediaPlayer )) + IActivationFactory_QueryInterface( media_player_factory, &IID_IActivationFactory, (void **)factory ); + + if (*factory) return S_OK; + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/windows.media.playback.mediaplayer/private.h b/dlls/windows.media.playback.mediaplayer/private.h new file mode 100644 index 00000000000..e356abcff28 --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/private.h @@ -0,0 +1,39 @@ +/* WinRT Windows.Media.Playback.MediaPlayer 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 + */ + +#ifndef __WINE_WINDOWS_MEDIA_PLAYBACK_MEDIAPLAYER_PRIVATE_H +#define __WINE_WINDOWS_MEDIA_PLAYBACK_MEDIAPLAYER_PRIVATE_H + +#include <stdarg.h> + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "activation.h" + +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#include "windows.foundation.h" +#define WIDL_using_Windows_Media +#define WIDL_using_Windows_Media_Playback +#include "windows.media.playback.h" + +#endif diff --git a/dlls/windows.media.playback.mediaplayer/tests/Makefile.in b/dlls/windows.media.playback.mediaplayer/tests/Makefile.in new file mode 100644 index 00000000000..20894397845 --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = windows.media.playback.mediaplayer.dll +IMPORTS = combase + +SOURCES = \ + mediaplayer.c diff --git a/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c b/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c new file mode 100644 index 00000000000..6570d979756 --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c @@ -0,0 +1,100 @@ +/* + * 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 + */ +#define COBJMACROS +#include "initguid.h" +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "roapi.h" + +#define WIDL_using_Windows_Foundation +#define WIDL_using_Windows_Foundation_Collections +#include "windows.foundation.h" +#define WIDL_using_Windows_Media_Playback +#include "windows.media.playback.h" + +#include "wine/test.h" + +#define check_interface( obj, iid, supported ) check_interface_( __LINE__, obj, iid, supported ) +static void check_interface_( unsigned int line, void *obj, const IID *iid, BOOL supported ) +{ + IUnknown *iface = obj; + IUnknown *unk; + HRESULT hr; + + hr = IUnknown_QueryInterface( iface, iid, (void **)&unk ); + ok_(__FILE__, line)( hr == S_OK || (!supported && hr == E_NOINTERFACE), "got hr %#lx.\n", hr ); + if (SUCCEEDED(hr)) IUnknown_Release( unk ); +} + +static void test_MediaPlayer_Statics(void) +{ + static const WCHAR *media_player_name = L"Windows.Media.Playback.MediaPlayer"; + IActivationFactory *factory = (void *)0xdeadbeef; + IMediaPlayer *media_player = (void *)0xdeadbeef; + IInspectable *inspectable = (void *)0xdeadbeef; + HSTRING str; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( media_player_name, wcslen( media_player_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_player_name ) ); + return; + } + + check_interface( factory, &IID_IUnknown, TRUE ); + check_interface( factory, &IID_IInspectable, TRUE ); + check_interface( factory, &IID_IAgileObject, FALSE ); + check_interface( factory, &IID_IMediaPlayer, FALSE ); + + hr = RoActivateInstance( str, &inspectable ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + hr = IInspectable_QueryInterface( inspectable, &IID_IMediaPlayer, (void **)&media_player ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + check_interface( media_player, &IID_IAgileObject, TRUE ); + + ref = IMediaPlayer_Release( media_player ); + ok( ref == 1, "got ref %ld.\n", ref ); + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + +START_TEST(mediaplayer) +{ + HRESULT hr; + + hr = RoInitialize( RO_INIT_MULTITHREADED ); + ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); + + test_MediaPlayer_Statics(); + + RoUninitialize(); +} diff --git a/dlls/windows.media.playback.mediaplayer/windows.media.playback.mediaplayer.spec b/dlls/windows.media.playback.mediaplayer/windows.media.playback.mediaplayer.spec new file mode 100644 index 00000000000..20a8bfa98ea --- /dev/null +++ b/dlls/windows.media.playback.mediaplayer/windows.media.playback.mediaplayer.spec @@ -0,0 +1,3 @@ +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetActivationFactory(ptr ptr) +@ stdcall -private DllGetClassObject(ptr ptr ptr) diff --git a/include/windows.media.playback.idl b/include/windows.media.playback.idl index 81509b262e1..e38482c46a2 100644 --- a/include/windows.media.playback.idl +++ b/include/windows.media.playback.idl @@ -312,6 +312,7 @@ namespace Windows.Media.Playback { } #endif
+#ifndef _WINDOWS_MEDIA_PLAYBACK_MEDIAPLAYER [ contract(Windows.Foundation.UniversalApiContract, 1.0), marshaling_behavior(agile), @@ -321,6 +322,7 @@ namespace Windows.Media.Playback { runtimeclass BackgroundMediaPlayer { } +#endif
#ifndef _WINDOWS_MEDIA_PLAYBACK_BACKGROUNDMEDIAPLAYER [