Commit b8ba4909 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Keep media source state based on raised events.

parent 9681e8ca
...@@ -81,10 +81,18 @@ struct media_stream ...@@ -81,10 +81,18 @@ struct media_stream
IMFMediaStream *stream; IMFMediaStream *stream;
}; };
enum source_state
{
SOURCE_STATE_STOPPED = 0,
SOURCE_STATE_STARTED,
SOURCE_STATE_PAUSED,
};
struct media_source struct media_source
{ {
struct list entry; struct list entry;
IMFMediaSource *source; IMFMediaSource *source;
enum source_state state;
struct list streams; struct list streams;
}; };
...@@ -1075,10 +1083,25 @@ static HRESULT session_add_media_stream(struct media_source *source, IMFMediaStr ...@@ -1075,10 +1083,25 @@ static HRESULT session_add_media_stream(struct media_source *source, IMFMediaStr
return S_OK; return S_OK;
} }
static void session_set_source_state(struct media_session *session, IMFMediaSource *source, enum source_state state)
{
struct media_source *cur;
LIST_FOR_EACH_ENTRY(cur, &session->presentation.sources, struct media_source, entry)
{
if (source == cur->source)
{
cur->state = state;
break;
}
}
}
static HRESULT WINAPI session_events_callback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result) static HRESULT WINAPI session_events_callback_Invoke(IMFAsyncCallback *iface, IMFAsyncResult *result)
{ {
struct media_session *session = impl_from_events_callback_IMFAsyncCallback(iface); struct media_session *session = impl_from_events_callback_IMFAsyncCallback(iface);
IMFMediaEventGenerator *event_source; IMFMediaEventGenerator *event_source;
enum source_state source_state;
IMFMediaEvent *event = NULL; IMFMediaEvent *event = NULL;
MediaEventType event_type; MediaEventType event_type;
struct media_source *cur; struct media_source *cur;
...@@ -1111,6 +1134,20 @@ static HRESULT WINAPI session_events_callback_Invoke(IMFAsyncCallback *iface, IM ...@@ -1111,6 +1134,20 @@ static HRESULT WINAPI session_events_callback_Invoke(IMFAsyncCallback *iface, IM
switch (event_type) switch (event_type)
{ {
case MESourceStarted:
case MESourcePaused:
case MESourceStopped:
if (event_type == MESourceStarted)
source_state = SOURCE_STATE_STARTED;
else if (event_type == MESourcePaused)
source_state = SOURCE_STATE_PAUSED;
else
source_state = SOURCE_STATE_STOPPED;
EnterCriticalSection(&session->cs);
session_set_source_state(session, (IMFMediaSource *)event_source, source_state);
LeaveCriticalSection(&session->cs);
break;
case MENewStream: case MENewStream:
stream = (IMFMediaStream *)value.punkVal; stream = (IMFMediaStream *)value.punkVal;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment