mfreadwrite/tests: Add some tests for ReadSample().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2019-04-19 11:06:15 +03:00 committed by Alexandre Julliard
parent fcf8cbfb2a
commit 2ca469f818
2 changed files with 72 additions and 8 deletions

View File

@ -187,11 +187,14 @@ static struct async_callback *create_async_callback(void)
static void test_source_reader(void)
{
IMFMediaType *mediatype, *mediatype2;
DWORD stream_flags, actual_index;
struct async_callback *callback;
IMFAttributes *attributes;
IMFSourceReader *reader;
IMFMediaSource *source;
IMFByteStream *stream;
LONGLONG timestamp;
IMFSample *sample;
BOOL selected;
HRESULT hr;
@ -298,6 +301,62 @@ todo_wine
ok(hr == S_OK, "Failed to get current media type, hr %#x.\n", hr);
IMFMediaType_Release(mediatype);
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, &actual_index, &stream_flags,
&timestamp, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(!stream_flags, "Unexpected stream flags %#x.\n", stream_flags);
IMFSample_Release(sample);
/* There is no video stream. */
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, &actual_index, &stream_flags,
&timestamp, &sample);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);
ok(actual_index == MF_SOURCE_READER_FIRST_VIDEO_STREAM, "Unexpected stream index %u\n", actual_index);
ok(stream_flags == MF_SOURCE_READERF_ERROR, "Unexpected stream flags %#x.\n", stream_flags);
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, &actual_index, &stream_flags,
&timestamp, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
&actual_index, &stream_flags, &timestamp, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
&actual_index, &stream_flags, &timestamp, NULL);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
&actual_index, NULL, &timestamp, &sample);
ok(hr == E_POINTER, "Unexpected hr %#x.\n", hr);
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
NULL, &stream_flags, &timestamp, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
&actual_index, &stream_flags, NULL, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
hr = IMFSourceReader_ReadSample(reader, MF_SOURCE_READER_ANY_STREAM, MF_SOURCE_READER_CONTROLF_DRAIN,
&actual_index, &stream_flags, NULL, &sample);
ok(hr == S_OK, "Failed to get a sample, hr %#x.\n", hr);
ok(actual_index == 0, "Unexpected stream index %u\n", actual_index);
ok(stream_flags == MF_SOURCE_READERF_ENDOFSTREAM, "Unexpected stream flags %#x.\n", stream_flags);
ok(!sample, "Unexpected sample object.\n");
/* Flush. */
hr = IMFSourceReader_Flush(reader, MF_SOURCE_READER_FIRST_VIDEO_STREAM);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#x.\n", hr);

View File

@ -19,6 +19,11 @@
import "mfobjects.idl";
import "mftransform.idl";
typedef [v1_enum] enum MF_SOURCE_READER_CONTROL_FLAG
{
MF_SOURCE_READER_CONTROLF_DRAIN = 0x00000001,
} MF_SOURCE_READER_CONTROL_FLAG;
enum
{
MF_SOURCE_READER_INVALID_STREAM_INDEX = 0xffffffff,
@ -30,15 +35,15 @@ enum
MF_SOURCE_READER_CURRENT_TYPE_INDEX = 0xffffffff
};
typedef enum MF_SOURCE_READER_FLAG
typedef [v1_enum] enum MF_SOURCE_READER_FLAG
{
MF_SOURCE_READERF_ERROR = 0x001,
MF_SOURCE_READERF_ENDOFSTREAM = 0x002,
MF_SOURCE_READERF_NEWSTREAM = 0x004,
MF_SOURCE_READERF_NATIVEMEDIATYPECHANGED = 0x010,
MF_SOURCE_READERF_CURRENTMEDIATYPECHANGED = 0x020,
MF_SOURCE_READERF_STREAMTICK = 0x100,
MF_SOURCE_READERF_ALLEFFECTSREMOVED = 0x200
MF_SOURCE_READERF_ERROR = 0x00000001,
MF_SOURCE_READERF_ENDOFSTREAM = 0x00000002,
MF_SOURCE_READERF_NEWSTREAM = 0x00000004,
MF_SOURCE_READERF_NATIVEMEDIATYPECHANGED = 0x00000010,
MF_SOURCE_READERF_CURRENTMEDIATYPECHANGED = 0x00000020,
MF_SOURCE_READERF_STREAMTICK = 0x00000100,
MF_SOURCE_READERF_ALLEFFECTSREMOVED = 0x00000200,
} MF_SOURCE_READER_FLAG;
typedef struct _MF_SINK_WRITER_STATISTICS