From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- .../private.h | 1 + .../classes.idl | 1 + .../windows.media.playback.mediaplayer/main.c | 59 +++++++++++++++++++ .../private.h | 38 ++++++++++++ .../tests/mediaplayer.c | 6 ++ 5 files changed, 105 insertions(+)
diff --git a/dlls/windows.media.playback.backgroundmediaplayer/private.h b/dlls/windows.media.playback.backgroundmediaplayer/private.h index 345937f80ee..24ee9d147f7 100644 --- a/dlls/windows.media.playback.backgroundmediaplayer/private.h +++ b/dlls/windows.media.playback.backgroundmediaplayer/private.h @@ -33,6 +33,7 @@ #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"
diff --git a/dlls/windows.media.playback.mediaplayer/classes.idl b/dlls/windows.media.playback.mediaplayer/classes.idl index 5ed8c1304bd..aa6a0895277 100644 --- a/dlls/windows.media.playback.mediaplayer/classes.idl +++ b/dlls/windows.media.playback.mediaplayer/classes.idl @@ -29,6 +29,7 @@ import "asyncinfo.idl"; import "eventtoken.idl"; import "windowscontracts.idl"; import "windows.foundation.idl"; +import "windows.media.idl";
#define DO_NO_IMPORTS #define _WINDOWS_MEDIA_PLAYBACK_MEDIAPLAYER diff --git a/dlls/windows.media.playback.mediaplayer/main.c b/dlls/windows.media.playback.mediaplayer/main.c index 695b45000ce..2e82b7dfc0a 100644 --- a/dlls/windows.media.playback.mediaplayer/main.c +++ b/dlls/windows.media.playback.mediaplayer/main.c @@ -27,6 +27,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mediaplayer); struct media_player { IMediaPlayer IMediaPlayer_iface; + IMediaPlayer2 IMediaPlayer2_iface; LONG ref; };
@@ -51,6 +52,13 @@ static HRESULT WINAPI media_player_QueryInterface( IMediaPlayer *iface, REFIID i return S_OK; }
+ if (IsEqualGUID( iid, &IID_IMediaPlayer2 )) + { + *out = &impl->IMediaPlayer2_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); *out = NULL; return E_NOINTERFACE; @@ -405,6 +413,56 @@ static const struct IMediaPlayerVtbl media_player_vtbl = media_player_SetUriSource, };
+DEFINE_IINSPECTABLE( media_player2, IMediaPlayer2, struct media_player, IMediaPlayer_iface ) + +static HRESULT WINAPI media_player2_get_SystemMediaTransportControls( IMediaPlayer2 *iface, ISystemMediaTransportControls **value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player2_get_AudioCategory( IMediaPlayer2 *iface, MediaPlayerAudioCategory *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player2_put_AudioCategory( IMediaPlayer2 *iface, MediaPlayerAudioCategory value ) +{ + FIXME( "iface %p, value %#x stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player2_get_AudioDeviceType( IMediaPlayer2 *iface, MediaPlayerAudioDeviceType *value ) +{ + FIXME( "iface %p, value %p stub!\n", iface, value ); + return E_NOTIMPL; +} + +static HRESULT WINAPI media_player2_put_AudioDeviceType( IMediaPlayer2 *iface, MediaPlayerAudioDeviceType value ) +{ + FIXME( "iface %p, value %#x stub!\n", iface, value ); + return E_NOTIMPL; +} + +static const struct IMediaPlayer2Vtbl media_player2_vtbl = +{ + /* IUnknown methods */ + media_player2_QueryInterface, + media_player2_AddRef, + media_player2_Release, + /* IInspectable methods */ + media_player2_GetIids, + media_player2_GetRuntimeClassName, + media_player2_GetTrustLevel, + /* IMediaPlayer2 methods */ + media_player2_get_SystemMediaTransportControls, + media_player2_get_AudioCategory, + media_player2_put_AudioCategory, + media_player2_get_AudioDeviceType, + media_player2_put_AudioDeviceType, +}; + struct media_player_statics { IActivationFactory IActivationFactory_iface; @@ -483,6 +541,7 @@ static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInsp }
impl->IMediaPlayer_iface.lpVtbl = &media_player_vtbl; + impl->IMediaPlayer2_iface.lpVtbl = &media_player2_vtbl; impl->ref = 1;
*instance = (IInspectable *)&impl->IMediaPlayer_iface; diff --git a/dlls/windows.media.playback.mediaplayer/private.h b/dlls/windows.media.playback.mediaplayer/private.h index e356abcff28..d5bbba3206a 100644 --- a/dlls/windows.media.playback.mediaplayer/private.h +++ b/dlls/windows.media.playback.mediaplayer/private.h @@ -36,4 +36,42 @@ #define WIDL_using_Windows_Media_Playback #include "windows.media.playback.h"
+#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) + #endif diff --git a/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c b/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c index 6570d979756..91f22bb68cf 100644 --- a/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c +++ b/dlls/windows.media.playback.mediaplayer/tests/mediaplayer.c @@ -49,6 +49,7 @@ static void test_MediaPlayer_Statics(void) { static const WCHAR *media_player_name = L"Windows.Media.Playback.MediaPlayer"; IActivationFactory *factory = (void *)0xdeadbeef; + IMediaPlayer2 *media_player2 = (void *)0xdeadbeef; IMediaPlayer *media_player = (void *)0xdeadbeef; IInspectable *inspectable = (void *)0xdeadbeef; HSTRING str; @@ -81,6 +82,11 @@ static void test_MediaPlayer_Statics(void)
check_interface( media_player, &IID_IAgileObject, TRUE );
+ hr = IMediaPlayer_QueryInterface( media_player, &IID_IMediaPlayer2, (void **)&media_player2 ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + ref = IMediaPlayer2_Release( media_player2 ); + ok( ref == 2, "got ref %ld.\n", ref ); ref = IMediaPlayer_Release( media_player ); ok( ref == 1, "got ref %ld.\n", ref ); ref = IActivationFactory_Release( factory );