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

mf: Add sample grabber sink stub.

parent e73d8241
......@@ -395,7 +395,7 @@ static HRESULT WINAPI activate_object_ActivateObject(IMFActivate *iface, REFIID
if (FAILED(hr = activate->funcs->create_object((IMFAttributes *)iface, activate->context, &object)))
return hr;
if (!InterlockedCompareExchangePointer((void **)&activate->object, object, NULL))
if (InterlockedCompareExchangePointer((void **)&activate->object, object, NULL))
IUnknown_Release(object);
}
......
......@@ -1230,7 +1230,6 @@ todo_wine
ok(hr == MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED, "Unexpected hr %#x.\n", hr);
hr = IMFActivate_ActivateObject(sink_activate, &IID_IMFMediaSink, (void **)&sink);
todo_wine
ok(hr == S_OK, "Failed to activate, hr %#x.\n", hr);
hr = IMFTopologyNode_SetObject(sink_node, (IUnknown *)sink);
......@@ -1639,9 +1638,16 @@ static IMFSampleGrabberSinkCallback grabber_callback = { &grabber_callback_vtbl
static void test_sample_grabber(void)
{
IMFMediaTypeHandler *handler, *handler2;
IMFStreamSink *stream, *stream2;
IMFClockStateSink *clocksink;
IMFMediaEventGenerator *eg;
IMFMediaSink *sink, *sink2;
IMFMediaType *media_type;
DWORD flags, count, id;
IMFActivate *activate;
ULONG refcount;
IUnknown *unk;
HRESULT hr;
hr = MFCreateMediaType(&media_type);
......@@ -1656,10 +1662,135 @@ static void test_sample_grabber(void)
hr = MFCreateSampleGrabberSinkActivate(media_type, &grabber_callback, &activate);
ok(hr == S_OK, "Failed to create grabber activate, hr %#x.\n", hr);
refcount = IMFMediaType_Release(media_type);
ok(refcount == 1, "Unexpected refcount %u.\n", refcount);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
ok(hr == S_OK, "Failed to set attribute, hr %#x.\n", hr);
hr = IMFActivate_ActivateObject(activate, &IID_IMFMediaSink, (void **)&sink);
ok(hr == S_OK, "Failed to activate object, hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == S_OK, "Failed to get sink flags, hr %#x.\n", hr);
ok(flags & MEDIASINK_FIXED_STREAMS, "Unexpected flags %#x.\n", flags);
hr = IMFMediaSink_GetStreamSinkCount(sink, &count);
ok(hr == S_OK, "Failed to get stream count, hr %#x.\n", hr);
ok(count == 1, "Unexpected stream count %u.\n", count);
EXPECT_REF(sink, 3);
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream);
ok(hr == S_OK, "Failed to get sink stream, hr %#x.\n", hr);
EXPECT_REF(sink, 3);
EXPECT_REF(stream, 2);
hr = IMFStreamSink_GetIdentifier(stream, &id);
ok(hr == S_OK, "Failed to get stream id, hr %#x.\n", hr);
ok(id == 0, "Unexpected id %#x.\n", id);
hr = IMFStreamSink_GetMediaSink(stream, &sink2);
ok(hr == S_OK, "Failed to get media sink, hr %x.\n", hr);
ok(sink2 == sink, "Unexpected sink.\n");
IMFMediaSink_Release(sink2);
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 1, &stream2);
ok(hr == MF_E_INVALIDINDEX, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_GetStreamSinkById(sink, 1, &stream2);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_AddStreamSink(sink, 1, NULL, &stream2);
ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_RemoveStreamSink(sink, 0);
ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#x.\n", hr);
IMFActivate_Release(activate);
hr = IMFMediaSink_RemoveStreamSink(sink, 1);
ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFClockStateSink, (void **)&clocksink);
todo_wine
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
IMFClockStateSink_Release(clocksink);
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFMediaEventGenerator, (void **)&eg);
todo_wine
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
IMFMediaEventGenerator_Release(eg);
hr = IMFMediaSink_QueryInterface(sink, &IID_IMFPresentationTimeSource, (void **)&unk);
ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
hr = IMFStreamSink_QueryInterface(stream, &IID_IMFMediaTypeHandler, (void **)&handler2);
todo_wine
ok(hr == S_OK, "Failed to get handler interface, hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IMFStreamSink_GetMediaTypeHandler(stream, &handler);
ok(hr == S_OK, "Failed to get type handler, hr %#x.\n", hr);
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
ok(hr == S_OK, "Failed to get media type count, hr %#x.\n", hr);
ok(count == 0, "Unexpected count %u.\n", count);
ok(handler == handler2, "Unexpected handler.\n");
IMFMediaTypeHandler_Release(handler);
IMFMediaTypeHandler_Release(handler2);
}
hr = IMFActivate_ShutdownObject(activate);
todo_wine
ok(hr == S_OK, "Failed to shut down, hr %#x.\n", hr);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == E_NOTIMPL, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_AddStreamSink(sink, 1, NULL, &stream2);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_GetStreamSinkCount(sink, &count);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream2);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#x.\n", hr);
hr = IMFStreamSink_GetMediaSink(stream, &sink2);
ok(hr == S_OK, "Failed to get media sink, hr %x.\n", hr);
ok(sink2 == sink, "Unexpected sink.\n");
IMFMediaSink_Release(sink2);
hr = IMFStreamSink_GetIdentifier(stream, &id);
ok(hr == S_OK, "Failed to get stream id, hr %#x.\n", hr);
ok(id == 0, "Unexpected id %#x.\n", id);
hr = IMFStreamSink_GetMediaTypeHandler(stream, &handler);
todo_wine
ok(hr == S_OK, "Failed to get type handler, hr %#x.\n", hr);
if (SUCCEEDED(hr))
{
hr = IMFMediaTypeHandler_GetMediaTypeCount(handler, &count);
ok(hr == S_OK, "Failed to get media type count, hr %#x.\n", hr);
ok(count == 0, "Unexpected count %u.\n", count);
IMFMediaTypeHandler_Release(handler);
}
IMFMediaSink_Release(sink);
IMFStreamSink_Release(stream);
refcount = IMFActivate_Release(activate);
ok(!refcount, "Unexpected refcount %u.\n", refcount);
IMFMediaType_Release(media_type);
}
START_TEST(mf)
......
......@@ -94,6 +94,20 @@
#define MF_E_MEDIA_SOURCE_NO_STREAMS_SELECTED _HRESULT_TYPEDEF_(0xc00d3e9c)
#define MF_E_UNSUPPORTED_CHARACTERISTICS _HRESULT_TYPEDEF_(0xc00d3e9e)
#define MF_E_STREAMSINK_REMOVED _HRESULT_TYPEDEF_(0xc00d4a38)
#define MF_E_STREAMSINKS_OUT_OF_SYNC _HRESULT_TYPEDEF_(0xc00d4a3a)
#define MF_E_STREAMSINKS_FIXED _HRESULT_TYPEDEF_(0xc00d4a3b)
#define MF_E_STREAMSINK_EXISTS _HRESULT_TYPEDEF_(0xc00d4a3c)
#define MF_E_SAMPLEALLOCATOR_CANCELED _HRESULT_TYPEDEF_(0xc00d4a3d)
#define MF_E_SAMPLEALLOCATOR_EMPTY _HRESULT_TYPEDEF_(0xc00d4a3e)
#define MF_E_SINK_ALREADYSTOPPED _HRESULT_TYPEDEF_(0xc00d4a3f)
#define MF_E_ASF_FILESINK_BITRATE_UNKNOWN _HRESULT_TYPEDEF_(0xc00d4a40)
#define MF_E_SINK_NO_STREAMS _HRESULT_TYPEDEF_(0xc00d4a41)
#define MF_S_SINK_NOT_FINALIZED _HRESULT_TYPEDEF_(0x000d4a42)
#define MF_E_METADATA_TOO_LONG _HRESULT_TYPEDEF_(0xc00d4a43)
#define MF_E_SINK_NO_SAMPLES_PROCESSED _HRESULT_TYPEDEF_(0xc00d4a44)
#define MF_E_SINK_HEADERS_NOT_FOUND _HRESULT_TYPEDEF_(0xc00d4a45)
#define MF_E_TOPO_INVALID_OPTIONAL_NODE _HRESULT_TYPEDEF_(0xc00d520e)
#define MF_E_TOPO_CANNOT_FIND_DECRYPTOR _HRESULT_TYPEDEF_(0xc00d5211)
#define MF_E_TOPO_CODEC_NOT_FOUND _HRESULT_TYPEDEF_(0xc00d5212)
......
......@@ -89,6 +89,14 @@ typedef enum _MF_TOPOLOGY_RESOLUTION_STATUS_FLAGS
MF_OPTIONAL_NODE_REJECTED_PROTECTED_PROCESS = 0x00000002,
} MF_TOPOLOGY_RESOLUTION_STATUS_FLAGS;
typedef enum _MFSTREAMSINK_MARKER_TYPE
{
MFSTREAMSINK_MARKER_DEFAULT,
MFSTREAMSINK_MARKER_ENDOFSEGMENT,
MFSTREAMSINK_MARKER_TICK,
MFSTREAMSINK_MARKER_EVENT,
} MFSTREAMSINK_MARKER_TYPE;
[
object,
uuid(2eb1e945-18b8-4139-9b1a-d5d584818530),
......@@ -652,6 +660,13 @@ interface IMFPresentationClock : IMFClock
HRESULT Pause();
}
cpp_quote("#define MEDIASINK_FIXED_STREAMS 0x00000001")
cpp_quote("#define MEDIASINK_CANNOT_MATCH_CLOCK 0x00000002")
cpp_quote("#define MEDIASINK_RATELESS 0x00000004")
cpp_quote("#define MEDIASINK_CLOCK_REQUIRED 0x00000008")
cpp_quote("#define MEDIASINK_CAN_PREROLL 0x00000010")
cpp_quote("#define MEDIASINK_REQUIRE_REFERENCE_MEDIATYPE 0x00000020")
[
object,
uuid(6ef2a660-47c0-4666-b13d-cbb717f2fa2c)
......@@ -672,6 +687,23 @@ interface IMFMediaSink : IUnknown
HRESULT Shutdown();
}
[
object,
uuid(0a97b3cf-8e7c-4a3d-8f8c-0c843dc247fb),
]
interface IMFStreamSink : IMFMediaEventGenerator
{
HRESULT GetMediaSink([out] IMFMediaSink **sink);
HRESULT GetIdentifier([out] DWORD *identifier);
HRESULT GetMediaTypeHandler([out] IMFMediaTypeHandler **handler);
HRESULT ProcessSample([in] IMFSample *sample);
HRESULT PlaceMarker(
[in] MFSTREAMSINK_MARKER_TYPE marker_type,
[in] const PROPVARIANT *marker_value,
[in] const PROPVARIANT *context_value);
HRESULT Flush();
}
typedef enum _MFSHUTDOWN_STATUS
{
MFSHUTDOWN_INITIATED,
......
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