amstream: Implement IDirectDrawStreamSample::GetSampleTimes.
Signed-off-by: Anton Baskanov <baskanov@gmail.com> Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
29a4921278
commit
e58b42d48d
|
@ -70,6 +70,8 @@ struct ddraw_sample
|
|||
struct ddraw_stream *parent;
|
||||
IDirectDrawSurface *surface;
|
||||
RECT rect;
|
||||
STREAM_TIME start_time;
|
||||
STREAM_TIME end_time;
|
||||
CONDITION_VARIABLE update_cv;
|
||||
|
||||
struct list entry;
|
||||
|
@ -96,7 +98,8 @@ static void flush_update_queue(struct ddraw_stream *stream, HRESULT update_hr)
|
|||
}
|
||||
}
|
||||
|
||||
static HRESULT process_update(struct ddraw_sample *sample, int stride, BYTE *pointer)
|
||||
static HRESULT process_update(struct ddraw_sample *sample, int stride, BYTE *pointer,
|
||||
STREAM_TIME start_time, STREAM_TIME end_time)
|
||||
{
|
||||
DDSURFACEDESC desc;
|
||||
DWORD row_size;
|
||||
|
@ -124,6 +127,9 @@ static HRESULT process_update(struct ddraw_sample *sample, int stride, BYTE *poi
|
|||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
sample->start_time = start_time;
|
||||
sample->end_time = end_time;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
@ -1259,6 +1265,8 @@ static HRESULT WINAPI ddraw_meminput_Receive(IMemInputPin *iface, IMediaSample *
|
|||
{
|
||||
struct ddraw_stream *stream = impl_from_IMemInputPin(iface);
|
||||
BITMAPINFOHEADER *bitmap_info;
|
||||
REFERENCE_TIME start_time = 0;
|
||||
REFERENCE_TIME end_time = 0;
|
||||
BYTE *top_down_pointer;
|
||||
int top_down_stride;
|
||||
BYTE *pointer;
|
||||
|
@ -1272,6 +1280,8 @@ static HRESULT WINAPI ddraw_meminput_Receive(IMemInputPin *iface, IMediaSample *
|
|||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
IMediaSample_GetTime(sample, &start_time, &end_time);
|
||||
|
||||
EnterCriticalSection(&stream->cs);
|
||||
|
||||
bitmap_info = &((VIDEOINFOHEADER *)stream->mt.pbFormat)->bmiHeader;
|
||||
|
@ -1293,7 +1303,7 @@ static HRESULT WINAPI ddraw_meminput_Receive(IMemInputPin *iface, IMediaSample *
|
|||
{
|
||||
struct ddraw_sample *sample = LIST_ENTRY(list_head(&stream->update_queue), struct ddraw_sample, entry);
|
||||
|
||||
sample->update_hr = process_update(sample, top_down_stride, top_down_pointer);
|
||||
sample->update_hr = process_update(sample, top_down_stride, top_down_pointer, start_time, end_time);
|
||||
|
||||
remove_queued_update(sample);
|
||||
LeaveCriticalSection(&stream->cs);
|
||||
|
@ -1439,9 +1449,19 @@ static HRESULT WINAPI ddraw_sample_GetMediaStream(IDirectDrawStreamSample *iface
|
|||
static HRESULT WINAPI ddraw_sample_GetSampleTimes(IDirectDrawStreamSample *iface, STREAM_TIME *start_time,
|
||||
STREAM_TIME *end_time, STREAM_TIME *current_time)
|
||||
{
|
||||
FIXME("(%p)->(%p,%p,%p): stub\n", iface, start_time, end_time, current_time);
|
||||
struct ddraw_sample *sample = impl_from_IDirectDrawStreamSample(iface);
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("sample %p, start_time %p, end_time %p, current_time %p.\n", sample, start_time, end_time, current_time);
|
||||
|
||||
if (current_time)
|
||||
IMediaStreamFilter_GetCurrentStreamTime(sample->parent->filter, current_time);
|
||||
|
||||
if (start_time)
|
||||
*start_time = sample->start_time;
|
||||
if (end_time)
|
||||
*end_time = sample->end_time;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ddraw_sample_SetSampleTimes(IDirectDrawStreamSample *iface, const STREAM_TIME *start_time,
|
||||
|
|
|
@ -2986,8 +2986,8 @@ static HRESULT WINAPI testclock_GetTime(IReferenceClock *iface, REFERENCE_TIME *
|
|||
|
||||
static HRESULT WINAPI testclock_AdviseTime(IReferenceClock *iface, REFERENCE_TIME base, REFERENCE_TIME offset, HEVENT event, DWORD_PTR *cookie)
|
||||
{
|
||||
ok(0, "Unexpected call.\n");
|
||||
return E_NOTIMPL;
|
||||
SetEvent((HANDLE)event);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI testclock_AdvisePeriodic(IReferenceClock *iface, REFERENCE_TIME start, REFERENCE_TIME period, HSEMAPHORE semaphore, DWORD_PTR *cookie)
|
||||
|
@ -7512,6 +7512,156 @@ static void test_ddrawstreamsample_completion_status(void)
|
|||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
}
|
||||
|
||||
static void test_ddrawstreamsample_get_sample_times(void)
|
||||
{
|
||||
static const BYTE test_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
|
||||
IAMMultiMediaStream *mmstream = create_ammultimediastream();
|
||||
IDirectDrawStreamSample *stream_sample;
|
||||
IMediaFilter *graph_media_filter;
|
||||
IDirectDrawMediaStream *ddraw_stream;
|
||||
STREAM_TIME filter_start_time;
|
||||
IMemInputPin *mem_input_pin;
|
||||
IMediaStreamFilter *filter;
|
||||
IMediaSample *media_sample;
|
||||
struct testfilter source;
|
||||
STREAM_TIME current_time;
|
||||
struct testclock clock;
|
||||
STREAM_TIME start_time;
|
||||
STREAM_TIME end_time;
|
||||
IGraphBuilder *graph;
|
||||
IMediaStream *stream;
|
||||
VIDEOINFO video_info;
|
||||
AM_MEDIA_TYPE mt;
|
||||
HRESULT hr;
|
||||
ULONG ref;
|
||||
IPin *pin;
|
||||
|
||||
hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IAMMultiMediaStream_GetFilter(mmstream, &filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(!!filter, "Expected non-null filter.\n");
|
||||
hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMediaStream_QueryInterface(stream, &IID_IDirectDrawMediaStream, (void **)&ddraw_stream);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMediaStream_QueryInterface(stream, &IID_IMemInputPin, (void **)&mem_input_pin);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IAMMultiMediaStream_GetFilterGraph(mmstream, &graph);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(graph != NULL, "Expected non-NULL graph.\n");
|
||||
hr = IGraphBuilder_QueryInterface(graph, &IID_IMediaFilter, (void **)&graph_media_filter);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
testfilter_init(&source);
|
||||
hr = IGraphBuilder_AddFilter(graph, &source.filter.IBaseFilter_iface, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
testclock_init(&clock);
|
||||
|
||||
video_info = rgb32_video_info;
|
||||
video_info.bmiHeader.biWidth = 3;
|
||||
video_info.bmiHeader.biHeight = 1;
|
||||
mt = rgb32_mt;
|
||||
mt.pbFormat = (BYTE *)&video_info;
|
||||
hr = IGraphBuilder_ConnectDirect(graph, &source.source.pin.IPin_iface, pin, &mt);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IDirectDrawMediaStream_CreateSample(ddraw_stream, NULL, NULL, 0, &stream_sample);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
clock.time = 12345678;
|
||||
|
||||
current_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, NULL, NULL, ¤t_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(current_time == 0, "Got current time %s.\n", wine_dbgstr_longlong(current_time));
|
||||
|
||||
IMediaFilter_SetSyncSource(graph_media_filter, &clock.IReferenceClock_iface);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
current_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, NULL, NULL, ¤t_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(current_time == 0, "Got current time %s.\n", wine_dbgstr_longlong(current_time));
|
||||
|
||||
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_RUN);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
hr = IMediaStreamFilter_GetCurrentStreamTime(filter, &filter_start_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
|
||||
clock.get_time_hr = E_FAIL;
|
||||
|
||||
current_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, NULL, NULL, ¤t_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(current_time == 0xdeadbeefddf15da1 + filter_start_time, "Expected current time %s, got %s.\n",
|
||||
wine_dbgstr_longlong(0xdeadbeefddf15da1 + filter_start_time), wine_dbgstr_longlong(current_time));
|
||||
|
||||
clock.get_time_hr = S_OK;
|
||||
|
||||
current_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, NULL, NULL, ¤t_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(current_time == filter_start_time, "Expected current time %s, got %s.\n",
|
||||
wine_dbgstr_longlong(filter_start_time), wine_dbgstr_longlong(current_time));
|
||||
|
||||
clock.time = 23456789;
|
||||
|
||||
current_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, NULL, NULL, ¤t_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(current_time == filter_start_time + 11111111, "Expected current time %s, got %s.\n",
|
||||
wine_dbgstr_longlong(filter_start_time + 11111111), wine_dbgstr_longlong(current_time));
|
||||
|
||||
start_time = 0xdeadbeefdeadbeef;
|
||||
end_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, &start_time, &end_time, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(start_time == 0, "Got start time %s.\n", wine_dbgstr_longlong(start_time));
|
||||
ok(end_time == 0, "Got end time %s.\n", wine_dbgstr_longlong(end_time));
|
||||
|
||||
hr = IDirectDrawStreamSample_Update(stream_sample, SSUPDATE_ASYNC, NULL, NULL, 0);
|
||||
ok(hr == MS_S_PENDING, "Got hr %#x.\n", hr);
|
||||
|
||||
media_sample = ammediastream_allocate_sample(&source, test_data, sizeof(test_data));
|
||||
start_time = 12345678;
|
||||
end_time = 23456789;
|
||||
hr = IMediaSample_SetTime(media_sample, &start_time, &end_time);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
hr = IMemInputPin_Receive(mem_input_pin, media_sample);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
IMediaSample_Release(media_sample);
|
||||
|
||||
start_time = 0xdeadbeefdeadbeef;
|
||||
end_time = 0xdeadbeefdeadbeef;
|
||||
hr = IDirectDrawStreamSample_GetSampleTimes(stream_sample, &start_time, &end_time, NULL);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
ok(start_time == 12345678, "Got start time %s.\n", wine_dbgstr_longlong(start_time));
|
||||
ok(end_time == 23456789, "Got end time %s.\n", wine_dbgstr_longlong(end_time));
|
||||
|
||||
hr = IAMMultiMediaStream_SetState(mmstream, STREAMSTATE_STOP);
|
||||
ok(hr == S_OK, "Got hr %#x.\n", hr);
|
||||
IGraphBuilder_Disconnect(graph, pin);
|
||||
IGraphBuilder_Disconnect(graph, &source.source.pin.IPin_iface);
|
||||
|
||||
ref = IDirectDrawStreamSample_Release(stream_sample);
|
||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
ref = IAMMultiMediaStream_Release(mmstream);
|
||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
IMediaFilter_Release(graph_media_filter);
|
||||
ref = IGraphBuilder_Release(graph);
|
||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
ref = IMediaStreamFilter_Release(filter);
|
||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
IPin_Release(pin);
|
||||
IMemInputPin_Release(mem_input_pin);
|
||||
IDirectDrawMediaStream_Release(ddraw_stream);
|
||||
ref = IMediaStream_Release(stream);
|
||||
ok(!ref, "Got outstanding refcount %d.\n", ref);
|
||||
}
|
||||
|
||||
START_TEST(amstream)
|
||||
{
|
||||
const WCHAR *test_avi_path;
|
||||
|
@ -7568,6 +7718,7 @@ START_TEST(amstream)
|
|||
test_ddrawstreamsample_get_media_stream();
|
||||
test_ddrawstreamsample_update();
|
||||
test_ddrawstreamsample_completion_status();
|
||||
test_ddrawstreamsample_get_sample_times();
|
||||
|
||||
test_ammediastream_join_am_multi_media_stream();
|
||||
test_ammediastream_join_filter();
|
||||
|
|
Loading…
Reference in New Issue