Commit 2d4387c1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mf: Add support for IMFSampleGrabberSinkCallback2.

parent 1cc06fb2
...@@ -66,6 +66,7 @@ struct sample_grabber_stream ...@@ -66,6 +66,7 @@ struct sample_grabber_stream
LONG refcount; LONG refcount;
struct sample_grabber *sink; struct sample_grabber *sink;
IMFMediaEventQueue *event_queue; IMFMediaEventQueue *event_queue;
IMFAttributes *sample_attributes;
enum sink_state state; enum sink_state state;
struct list items; struct list items;
IUnknown *cancel_key; IUnknown *cancel_key;
...@@ -79,6 +80,7 @@ struct sample_grabber ...@@ -79,6 +80,7 @@ struct sample_grabber
IMFMediaEventGenerator IMFMediaEventGenerator_iface; IMFMediaEventGenerator IMFMediaEventGenerator_iface;
LONG refcount; LONG refcount;
IMFSampleGrabberSinkCallback *callback; IMFSampleGrabberSinkCallback *callback;
IMFSampleGrabberSinkCallback2 *callback2;
IMFMediaType *media_type; IMFMediaType *media_type;
BOOL is_shut_down; BOOL is_shut_down;
struct sample_grabber_stream *stream; struct sample_grabber_stream *stream;
...@@ -90,6 +92,11 @@ struct sample_grabber ...@@ -90,6 +92,11 @@ struct sample_grabber
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
}; };
static IMFSampleGrabberSinkCallback *sample_grabber_get_callback(const struct sample_grabber *sink)
{
return sink->callback2 ? (IMFSampleGrabberSinkCallback *)sink->callback2 : sink->callback;
}
struct sample_grabber_activate_context struct sample_grabber_activate_context
{ {
IMFMediaType *media_type; IMFMediaType *media_type;
...@@ -209,6 +216,8 @@ static ULONG WINAPI sample_grabber_stream_Release(IMFStreamSink *iface) ...@@ -209,6 +216,8 @@ static ULONG WINAPI sample_grabber_stream_Release(IMFStreamSink *iface)
IMFMediaEventQueue_Shutdown(stream->event_queue); IMFMediaEventQueue_Shutdown(stream->event_queue);
IMFMediaEventQueue_Release(stream->event_queue); IMFMediaEventQueue_Release(stream->event_queue);
} }
if (stream->sample_attributes)
IMFAttributes_Release(stream->sample_attributes);
LIST_FOR_EACH_ENTRY_SAFE(item, next_item, &stream->items, struct scheduled_item, entry) LIST_FOR_EACH_ENTRY_SAFE(item, next_item, &stream->items, struct scheduled_item, entry)
{ {
stream_release_pending_item(item); stream_release_pending_item(item);
...@@ -333,6 +342,14 @@ static HRESULT sample_grabber_report_sample(struct sample_grabber *grabber, IMFS ...@@ -333,6 +342,14 @@ static HRESULT sample_grabber_report_sample(struct sample_grabber *grabber, IMFS
if (SUCCEEDED(hr = IMFMediaBuffer_Lock(buffer, &data, NULL, &size))) if (SUCCEEDED(hr = IMFMediaBuffer_Lock(buffer, &data, NULL, &size)))
{ {
if (grabber->callback2)
{
hr = IMFSample_CopyAllItems(sample, grabber->stream->sample_attributes);
if (SUCCEEDED(hr))
hr = IMFSampleGrabberSinkCallback2_OnProcessSampleEx(grabber->callback2, &major_type, flags,
sample_time, sample_duration, data, size, grabber->stream->sample_attributes);
}
else
hr = IMFSampleGrabberSinkCallback_OnProcessSample(grabber->callback, &major_type, flags, sample_time, hr = IMFSampleGrabberSinkCallback_OnProcessSample(grabber->callback, &major_type, flags, sample_time,
sample_duration, data, size); sample_duration, data, size);
IMFMediaBuffer_Unlock(buffer); IMFMediaBuffer_Unlock(buffer);
...@@ -814,7 +831,10 @@ static ULONG WINAPI sample_grabber_sink_Release(IMFMediaSink *iface) ...@@ -814,7 +831,10 @@ static ULONG WINAPI sample_grabber_sink_Release(IMFMediaSink *iface)
if (!refcount) if (!refcount)
{ {
if (grabber->callback)
IMFSampleGrabberSinkCallback_Release(grabber->callback); IMFSampleGrabberSinkCallback_Release(grabber->callback);
if (grabber->callback2)
IMFSampleGrabberSinkCallback2_Release(grabber->callback2);
IMFMediaType_Release(grabber->media_type); IMFMediaType_Release(grabber->media_type);
if (grabber->event_queue) if (grabber->event_queue)
{ {
...@@ -941,7 +961,8 @@ static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *ifa ...@@ -941,7 +961,8 @@ static HRESULT WINAPI sample_grabber_sink_SetPresentationClock(IMFMediaSink *ifa
EnterCriticalSection(&grabber->cs); EnterCriticalSection(&grabber->cs);
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnSetPresentationClock(grabber->callback, clock))) if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnSetPresentationClock(sample_grabber_get_callback(grabber),
clock)))
{ {
if (grabber->clock) if (grabber->clock)
{ {
...@@ -1008,7 +1029,7 @@ static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface) ...@@ -1008,7 +1029,7 @@ static HRESULT WINAPI sample_grabber_sink_Shutdown(IMFMediaSink *iface)
EnterCriticalSection(&grabber->cs); EnterCriticalSection(&grabber->cs);
grabber->is_shut_down = TRUE; grabber->is_shut_down = TRUE;
if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnShutdown(grabber->callback))) if (SUCCEEDED(hr = IMFSampleGrabberSinkCallback_OnShutdown(sample_grabber_get_callback(grabber))))
{ {
IMFMediaSink_Release(&grabber->stream->sink->IMFMediaSink_iface); IMFMediaSink_Release(&grabber->stream->sink->IMFMediaSink_iface);
EnterCriticalSection(&grabber->stream->cs); EnterCriticalSection(&grabber->stream->cs);
...@@ -1246,6 +1267,9 @@ static HRESULT sample_grabber_create_stream(struct sample_grabber *sink, struct ...@@ -1246,6 +1267,9 @@ static HRESULT sample_grabber_create_stream(struct sample_grabber *sink, struct
if (FAILED(hr = MFCreateEventQueue(&object->event_queue))) if (FAILED(hr = MFCreateEventQueue(&object->event_queue)))
goto failed; goto failed;
if (FAILED(hr = MFCreateAttributes(&object->sample_attributes, 0)))
goto failed;
*stream = object; *stream = object;
return S_OK; return S_OK;
...@@ -1277,8 +1301,12 @@ static HRESULT sample_grabber_create_object(IMFAttributes *attributes, void *use ...@@ -1277,8 +1301,12 @@ static HRESULT sample_grabber_create_object(IMFAttributes *attributes, void *use
object->IMFClockStateSink_iface.lpVtbl = &sample_grabber_clock_sink_vtbl; object->IMFClockStateSink_iface.lpVtbl = &sample_grabber_clock_sink_vtbl;
object->IMFMediaEventGenerator_iface.lpVtbl = &sample_grabber_sink_events_vtbl; object->IMFMediaEventGenerator_iface.lpVtbl = &sample_grabber_sink_events_vtbl;
object->refcount = 1; object->refcount = 1;
if (FAILED(IMFSampleGrabberSinkCallback_QueryInterface(context->callback, &IID_IMFSampleGrabberSinkCallback2,
(void **)&object->callback2)))
{
object->callback = context->callback; object->callback = context->callback;
IMFSampleGrabberSinkCallback_AddRef(object->callback); IMFSampleGrabberSinkCallback_AddRef(object->callback);
}
object->media_type = context->media_type; object->media_type = context->media_type;
IMFMediaType_AddRef(object->media_type); IMFMediaType_AddRef(object->media_type);
IMFAttributes_GetUINT32(attributes, &MF_SAMPLEGRABBERSINK_IGNORE_CLOCK, &object->ignore_clock); IMFAttributes_GetUINT32(attributes, &MF_SAMPLEGRABBERSINK_IGNORE_CLOCK, &object->ignore_clock);
......
...@@ -549,6 +549,23 @@ interface IMFSampleGrabberSinkCallback : IMFClockStateSink ...@@ -549,6 +549,23 @@ interface IMFSampleGrabberSinkCallback : IMFClockStateSink
HRESULT OnShutdown(); HRESULT OnShutdown();
} }
[
object,
uuid(ca86aa50-c46e-429e-ab27-16d6ac6844cb),
local
]
interface IMFSampleGrabberSinkCallback2 : IMFSampleGrabberSinkCallback
{
HRESULT OnProcessSampleEx(
[in] REFGUID major_type,
[in] DWORD sample_flags,
[in] LONGLONG sample_time,
[in] LONGLONG sample_duration,
[in] const BYTE *buffer,
[in] DWORD sample_size,
[in] IMFAttributes *attributes);
}
cpp_quote("HRESULT WINAPI MFCreateMediaSession(IMFAttributes *config, IMFMediaSession **session);") cpp_quote("HRESULT WINAPI MFCreateMediaSession(IMFAttributes *config, IMFMediaSession **session);")
cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream);" ) cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStream(IStream *stream, IMFByteStream **bytestream);" )
cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStreamEx(IUnknown *stream, IMFByteStream **bytestream);") cpp_quote("HRESULT WINAPI MFCreateMFByteStreamOnStreamEx(IUnknown *stream, IMFByteStream **bytestream);")
......
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