2 * Copyright 2019 Nikolay Sivov for CodeWeavers
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 "wine/debug.h"
28 #include "wine/heap.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(mfplat
);
34 IMFPMediaPlayer IMFPMediaPlayer_iface
;
36 IMFPMediaPlayerCallback
*callback
;
39 static struct media_player
*impl_from_IMFPMediaPlayer(IMFPMediaPlayer
*iface
)
41 return CONTAINING_RECORD(iface
, struct media_player
, IMFPMediaPlayer_iface
);
44 static HRESULT WINAPI
media_player_QueryInterface(IMFPMediaPlayer
*iface
, REFIID riid
, void **obj
)
46 TRACE("%p, %s, %p.\n", iface
, debugstr_guid(riid
), obj
);
48 if (IsEqualIID(riid
, &IID_IMFPMediaPlayer
) ||
49 IsEqualIID(riid
, &IID_IUnknown
))
52 IMFPMediaPlayer_AddRef(iface
);
56 WARN("Unsupported interface %s.\n", debugstr_guid(riid
));
62 static ULONG WINAPI
media_player_AddRef(IMFPMediaPlayer
*iface
)
64 struct media_player
*player
= impl_from_IMFPMediaPlayer(iface
);
65 ULONG refcount
= InterlockedIncrement(&player
->refcount
);
67 TRACE("%p, refcount %u.\n", iface
, refcount
);
72 static ULONG WINAPI
media_player_Release(IMFPMediaPlayer
*iface
)
74 struct media_player
*player
= impl_from_IMFPMediaPlayer(iface
);
75 ULONG refcount
= InterlockedDecrement(&player
->refcount
);
77 TRACE("%p, refcount %u.\n", iface
, refcount
);
82 IMFPMediaPlayerCallback_Release(player
->callback
);
89 static HRESULT WINAPI
media_player_Play(IMFPMediaPlayer
*iface
)
91 FIXME("%p.\n", iface
);
96 static HRESULT WINAPI
media_player_Pause(IMFPMediaPlayer
*iface
)
98 FIXME("%p.\n", iface
);
103 static HRESULT WINAPI
media_player_Stop(IMFPMediaPlayer
*iface
)
105 FIXME("%p.\n", iface
);
110 static HRESULT WINAPI
media_player_FrameStep(IMFPMediaPlayer
*iface
)
112 FIXME("%p.\n", iface
);
117 static HRESULT WINAPI
media_player_SetPosition(IMFPMediaPlayer
*iface
, REFGUID postype
, const PROPVARIANT
*position
)
119 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(postype
), position
);
124 static HRESULT WINAPI
media_player_GetPosition(IMFPMediaPlayer
*iface
, REFGUID postype
, PROPVARIANT
*position
)
126 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(postype
), position
);
131 static HRESULT WINAPI
media_player_GetDuration(IMFPMediaPlayer
*iface
, REFGUID postype
, PROPVARIANT
*position
)
133 FIXME("%p, %s, %p.\n", iface
, debugstr_guid(postype
), position
);
138 static HRESULT WINAPI
media_player_SetRate(IMFPMediaPlayer
*iface
, float rate
)
140 FIXME("%p, %f.\n", iface
, rate
);
145 static HRESULT WINAPI
media_player_GetRate(IMFPMediaPlayer
*iface
, float *rate
)
147 FIXME("%p, %p.\n", iface
, rate
);
152 static HRESULT WINAPI
media_player_GetSupportedRates(IMFPMediaPlayer
*iface
, BOOL forward
, float *slowest_rate
, float *fastest_rate
)
154 FIXME("%p, %d, %p, %p.\n", iface
, forward
, slowest_rate
, fastest_rate
);
159 static HRESULT WINAPI
media_player_GetState(IMFPMediaPlayer
*iface
, MFP_MEDIAPLAYER_STATE
*state
)
161 FIXME("%p, %p.\n", iface
, state
);
166 static HRESULT WINAPI
media_player_CreateMediaItemFromURL(IMFPMediaPlayer
*iface
,
167 const WCHAR
*url
, BOOL sync
, DWORD_PTR user_data
, IMFPMediaItem
**item
)
169 FIXME("%p, %s, %d, %lx, %p.\n", iface
, debugstr_w(url
), sync
, user_data
, item
);
174 static HRESULT WINAPI
media_player_CreateMediaItemFromObject(IMFPMediaPlayer
*iface
,
175 IUnknown
*object
, BOOL sync
, DWORD_PTR user_data
, IMFPMediaItem
**item
)
177 FIXME("%p, %p, %d, %lx, %p.\n", iface
, object
, sync
, user_data
, item
);
182 static HRESULT WINAPI
media_player_SetMediaItem(IMFPMediaPlayer
*iface
, IMFPMediaItem
*item
)
184 FIXME("%p, %p.\n", iface
, item
);
189 static HRESULT WINAPI
media_player_ClearMediaItem(IMFPMediaPlayer
*iface
)
191 FIXME("%p.\n", iface
);
196 static HRESULT WINAPI
media_player_GetMediaItem(IMFPMediaPlayer
*iface
, IMFPMediaItem
**item
)
198 FIXME("%p, %p.\n", iface
, item
);
203 static HRESULT WINAPI
media_player_GetVolume(IMFPMediaPlayer
*iface
, float *volume
)
205 FIXME("%p, %p.\n", iface
, volume
);
210 static HRESULT WINAPI
media_player_SetVolume(IMFPMediaPlayer
*iface
, float volume
)
212 FIXME("%p, %.8e.\n", iface
, volume
);
217 static HRESULT WINAPI
media_player_GetBalance(IMFPMediaPlayer
*iface
, float *balance
)
219 FIXME("%p, %p.\n", iface
, balance
);
224 static HRESULT WINAPI
media_player_SetBalance(IMFPMediaPlayer
*iface
, float balance
)
226 FIXME("%p, %.8e.\n", iface
, balance
);
231 static HRESULT WINAPI
media_player_GetMute(IMFPMediaPlayer
*iface
, BOOL
*mute
)
233 FIXME("%p, %p.\n", iface
, mute
);
238 static HRESULT WINAPI
media_player_SetMute(IMFPMediaPlayer
*iface
, BOOL mute
)
240 FIXME("%p, %d.\n", iface
, mute
);
245 static HRESULT WINAPI
media_player_GetNativeVideoSize(IMFPMediaPlayer
*iface
,
246 SIZE
*video
, SIZE
*arvideo
)
248 FIXME("%p, %p, %p.\n", iface
, video
, arvideo
);
253 static HRESULT WINAPI
media_player_GetIdealVideoSize(IMFPMediaPlayer
*iface
,
254 SIZE
*min_size
, SIZE
*max_size
)
256 FIXME("%p, %p, %p.\n", iface
, min_size
, max_size
);
261 static HRESULT WINAPI
media_player_SetVideoSourceRect(IMFPMediaPlayer
*iface
,
262 MFVideoNormalizedRect
const *rect
)
264 FIXME("%p, %p.\n", iface
, rect
);
269 static HRESULT WINAPI
media_player_GetVideoSourceRect(IMFPMediaPlayer
*iface
,
270 MFVideoNormalizedRect
*rect
)
272 FIXME("%p, %p.\n", iface
, rect
);
277 static HRESULT WINAPI
media_player_SetAspectRatioMode(IMFPMediaPlayer
*iface
, DWORD mode
)
279 FIXME("%p, %u.\n", iface
, mode
);
284 static HRESULT WINAPI
media_player_GetAspectRatioMode(IMFPMediaPlayer
*iface
,
287 FIXME("%p, %p.\n", iface
, mode
);
292 static HRESULT WINAPI
media_player_GetVideoWindow(IMFPMediaPlayer
*iface
, HWND
*hwnd
)
294 FIXME("%p, %p.\n", iface
, hwnd
);
299 static HRESULT WINAPI
media_player_UpdateVideo(IMFPMediaPlayer
*iface
)
301 FIXME("%p.\n", iface
);
306 static HRESULT WINAPI
media_player_SetBorderColor(IMFPMediaPlayer
*iface
, COLORREF color
)
308 FIXME("%p, %#x.\n", iface
, color
);
313 static HRESULT WINAPI
media_player_GetBorderColor(IMFPMediaPlayer
*iface
, COLORREF
*color
)
315 FIXME("%p, %p.\n", iface
, color
);
320 static HRESULT WINAPI
media_player_InsertEffect(IMFPMediaPlayer
*iface
, IUnknown
*effect
,
323 FIXME("%p, %p, %d.\n", iface
, effect
, optional
);
328 static HRESULT WINAPI
media_player_RemoveEffect(IMFPMediaPlayer
*iface
, IUnknown
*effect
)
330 FIXME("%p, %p.\n", iface
, effect
);
335 static HRESULT WINAPI
media_player_RemoveAllEffects(IMFPMediaPlayer
*iface
)
337 FIXME("%p.\n", iface
);
342 static HRESULT WINAPI
media_player_Shutdown(IMFPMediaPlayer
*iface
)
344 FIXME("%p.\n", iface
);
349 static const IMFPMediaPlayerVtbl media_player_vtbl
=
351 media_player_QueryInterface
,
353 media_player_Release
,
357 media_player_FrameStep
,
358 media_player_SetPosition
,
359 media_player_GetPosition
,
360 media_player_GetDuration
,
361 media_player_SetRate
,
362 media_player_GetRate
,
363 media_player_GetSupportedRates
,
364 media_player_GetState
,
365 media_player_CreateMediaItemFromURL
,
366 media_player_CreateMediaItemFromObject
,
367 media_player_SetMediaItem
,
368 media_player_ClearMediaItem
,
369 media_player_GetMediaItem
,
370 media_player_GetVolume
,
371 media_player_SetVolume
,
372 media_player_GetBalance
,
373 media_player_SetBalance
,
374 media_player_GetMute
,
375 media_player_SetMute
,
376 media_player_GetNativeVideoSize
,
377 media_player_GetIdealVideoSize
,
378 media_player_SetVideoSourceRect
,
379 media_player_GetVideoSourceRect
,
380 media_player_SetAspectRatioMode
,
381 media_player_GetAspectRatioMode
,
382 media_player_GetVideoWindow
,
383 media_player_UpdateVideo
,
384 media_player_SetBorderColor
,
385 media_player_GetBorderColor
,
386 media_player_InsertEffect
,
387 media_player_RemoveEffect
,
388 media_player_RemoveAllEffects
,
389 media_player_Shutdown
,
392 HRESULT WINAPI
MFPCreateMediaPlayer(const WCHAR
*url
, BOOL start_playback
, MFP_CREATION_OPTIONS options
,
393 IMFPMediaPlayerCallback
*callback
, HWND hwnd
, IMFPMediaPlayer
**player
)
395 struct media_player
*object
;
397 TRACE("%s, %d, %#x, %p, %p, %p.\n", debugstr_w(url
), start_playback
, options
, callback
, hwnd
, player
);
399 if (!(object
= heap_alloc_zero(sizeof(*object
))))
400 return E_OUTOFMEMORY
;
402 object
->IMFPMediaPlayer_iface
.lpVtbl
= &media_player_vtbl
;
403 object
->refcount
= 1;
404 object
->callback
= callback
;
405 if (object
->callback
)
406 IMFPMediaPlayerCallback_AddRef(object
->callback
);
408 *player
= &object
->IMFPMediaPlayer_iface
;