mf: Implement presentation clock methods for sample grabber.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
9157129fc8
commit
2407a0f53b
|
@ -50,6 +50,7 @@ struct sample_grabber
|
|||
BOOL is_shut_down;
|
||||
IMFStreamSink *stream;
|
||||
IMFMediaEventQueue *event_queue;
|
||||
IMFPresentationClock *clock;
|
||||
CRITICAL_SECTION cs;
|
||||
};
|
||||
|
||||
|
@ -430,6 +431,8 @@ static ULONG WINAPI sample_grabber_sink_Release(IMFMediaSink *iface)
|
|||
IMFMediaEventQueue_Shutdown(grabber->event_queue);
|
||||
IMFMediaEventQueue_Release(grabber->event_queue);
|
||||
}
|
||||
if (grabber->clock)
|
||||
IMFPresentationClock_Release(grabber->clock);
|
||||
DeleteCriticalSection(&grabber->cs);
|
||||
heap_free(grabber);
|
||||
}
|
||||
|
@ -539,16 +542,56 @@ static HRESULT WINAPI sample_grabber_sink_GetStreamSinkById(IMFMediaSink *iface,
|
|||
|
||||
static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *iface, IMFPresentationClock *clock)
|
||||
{
|
||||
FIXME("%p, %p.\n", iface, clock);
|
||||
struct sample_grabber *grabber = impl_from_IMFMediaSink(iface);
|
||||
HRESULT hr;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %p.\n", iface, clock);
|
||||
|
||||
EnterCriticalSection(&grabber->cs);
|
||||
|
||||
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnSetPresentationClock(grabber->callback, clock)))
|
||||
{
|
||||
if (grabber->clock)
|
||||
{
|
||||
IMFPresentationClock_RemoveClockStateSink(grabber->clock, &grabber->IMFClockStateSink_iface);
|
||||
IMFPresentationClock_Release(grabber->clock);
|
||||
}
|
||||
grabber->clock = clock;
|
||||
if (grabber->clock)
|
||||
{
|
||||
IMFPresentationClock_AddRef(grabber->clock);
|
||||
IMFPresentationClock_AddClockStateSink(grabber->clock, &grabber->IMFClockStateSink_iface);
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&grabber->cs);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_sink_GetPresentationClock(IMFMediaSink *iface, IMFPresentationClock **clock)
|
||||
{
|
||||
FIXME("%p, %p.\n", iface, clock);
|
||||
struct sample_grabber *grabber = impl_from_IMFMediaSink(iface);
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("%p, %p.\n", iface, clock);
|
||||
|
||||
if (!clock)
|
||||
return E_POINTER;
|
||||
|
||||
EnterCriticalSection(&grabber->cs);
|
||||
|
||||
if (grabber->clock)
|
||||
{
|
||||
*clock = grabber->clock;
|
||||
IMFPresentationClock_AddRef(*clock);
|
||||
}
|
||||
else
|
||||
hr = MF_E_NO_CLOCK;
|
||||
|
||||
LeaveCriticalSection(&grabber->cs);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface)
|
||||
|
|
|
@ -1605,7 +1605,7 @@ static HRESULT WINAPI grabber_callback_OnClockSetRate(IMFSampleGrabberSinkCallba
|
|||
static HRESULT WINAPI grabber_callback_OnSetPresentationClock(IMFSampleGrabberSinkCallback *iface,
|
||||
IMFPresentationClock *clock)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI grabber_callback_OnProcessSample(IMFSampleGrabberSinkCallback *iface, REFGUID major_type,
|
||||
|
@ -1641,9 +1641,9 @@ static void test_sample_grabber(void)
|
|||
IMFMediaType *media_type, *media_type2, *media_type3;
|
||||
IMFMediaTypeHandler *handler, *handler2;
|
||||
IMFPresentationTimeSource *time_source;
|
||||
IMFPresentationClock *clock, *clock2;
|
||||
IMFStreamSink *stream, *stream2;
|
||||
IMFClockStateSink *clocksink;
|
||||
IMFPresentationClock *clock;
|
||||
IMFMediaEventGenerator *eg;
|
||||
IMFMediaSink *sink, *sink2;
|
||||
DWORD flags, count, id;
|
||||
|
@ -1742,8 +1742,17 @@ static void test_sample_grabber(void)
|
|||
hr = MFCreatePresentationClock(&clock);
|
||||
ok(hr == S_OK, "Failed to create clock object, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaSink_GetPresentationClock(sink, NULL);
|
||||
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaSink_GetPresentationClock(sink, &clock2);
|
||||
ok(hr == MF_E_NO_CLOCK, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaSink_SetPresentationClock(sink, NULL);
|
||||
ok(hr == S_OK, "Failed to set presentation clock, hr %#x.\n", hr);
|
||||
|
||||
hr = IMFMediaSink_SetPresentationClock(sink, clock);
|
||||
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
||||
ok(hr == S_OK, "Failed to set presentation clock, hr %#x.\n", hr);
|
||||
|
||||
hr = MFCreateSystemTimeSource(&time_source);
|
||||
ok(hr == S_OK, "Failed to create time source, hr %#x.\n", hr);
|
||||
|
@ -1752,9 +1761,6 @@ static void test_sample_grabber(void)
|
|||
ok(hr == S_OK, "Failed to set time source, hr %#x.\n", hr);
|
||||
IMFPresentationTimeSource_Release(time_source);
|
||||
|
||||
hr = IMFMediaSink_SetPresentationClock(sink, clock);
|
||||
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
|
||||
|
||||
IMFPresentationClock_Release(clock);
|
||||
|
||||
hr = IMFActivate_ShutdownObject(activate);
|
||||
|
|
Loading…
Reference in New Issue