mfmediaengine: Issue MF_MEDIA_ENGINE_EVENT_FIRSTFRAMEREADY on first video sample.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-11-03 15:56:08 +03:00 committed by Alexandre Julliard
parent fa25360235
commit 37ffe44443
1 changed files with 23 additions and 0 deletions

View File

@ -68,6 +68,7 @@ enum media_engine_flags
FLAGS_ENGINE_MUTED = 0x400, FLAGS_ENGINE_MUTED = 0x400,
FLAGS_ENGINE_HAS_AUDIO = 0x800, FLAGS_ENGINE_HAS_AUDIO = 0x800,
FLAGS_ENGINE_HAS_VIDEO = 0x1000, FLAGS_ENGINE_HAS_VIDEO = 0x1000,
FLAGS_ENGINE_FIRST_FRAME = 0x2000,
}; };
struct media_engine struct media_engine
@ -316,6 +317,10 @@ static HRESULT WINAPI media_engine_session_events_Invoke(IMFAsyncCallback *iface
break; break;
case MESessionEnded: case MESessionEnded:
EnterCriticalSection(&engine->cs);
media_engine_set_flag(engine, FLAGS_ENGINE_FIRST_FRAME, FALSE);
LeaveCriticalSection(&engine->cs);
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_ENDED, 0, 0); IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_ENDED, 0, 0);
break; break;
} }
@ -1351,6 +1356,12 @@ static HRESULT WINAPI media_engine_grabber_callback_OnClockStart(IMFSampleGrabbe
static HRESULT WINAPI media_engine_grabber_callback_OnClockStop(IMFSampleGrabberSinkCallback *iface, static HRESULT WINAPI media_engine_grabber_callback_OnClockStop(IMFSampleGrabberSinkCallback *iface,
MFTIME systime) MFTIME systime)
{ {
struct media_engine *engine = impl_from_IMFSampleGrabberSinkCallback(iface);
EnterCriticalSection(&engine->cs);
media_engine_set_flag(engine, FLAGS_ENGINE_FIRST_FRAME, FALSE);
LeaveCriticalSection(&engine->cs);
return S_OK; return S_OK;
} }
@ -1382,6 +1393,18 @@ static HRESULT WINAPI media_engine_grabber_callback_OnProcessSample(IMFSampleGra
REFGUID major_type, DWORD sample_flags, LONGLONG sample_time, LONGLONG sample_duration, REFGUID major_type, DWORD sample_flags, LONGLONG sample_time, LONGLONG sample_duration,
const BYTE *buffer, DWORD sample_size) const BYTE *buffer, DWORD sample_size)
{ {
struct media_engine *engine = impl_from_IMFSampleGrabberSinkCallback(iface);
EnterCriticalSection(&engine->cs);
if (!(engine->flags & FLAGS_ENGINE_FIRST_FRAME))
{
IMFMediaEngineNotify_EventNotify(engine->callback, MF_MEDIA_ENGINE_EVENT_FIRSTFRAMEREADY, 0, 0);
engine->flags |= FLAGS_ENGINE_FIRST_FRAME;
}
LeaveCriticalSection(&engine->cs);
return S_OK; return S_OK;
} }