winegstreamer: Set sample timestamps in MPEG audio decoder.

Signed-off-by: Anton Baskanov <baskanov@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Anton Baskanov 2022-04-12 14:38:55 +07:00 committed by Alexandre Julliard
parent 5db4b0cff9
commit 2567ff497d
2 changed files with 31 additions and 3 deletions

View File

@ -888,11 +888,11 @@ static HRESULT WINAPI testsink_Receive(struct strmbase_sink *iface, IMediaSample
start = 0xdeadbeef;
stop = 0xdeadbeef;
hr = IMediaSample_GetTime(sample, &start, &stop);
todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
ok(hr == S_OK, "Got hr %#lx.\n", hr);
if (filter->got_sample == 1)
{
todo_wine ok(start == filter->expected_start_time, "Got start time %s.\n", wine_dbgstr_longlong(start));
todo_wine ok(stop == filter->expected_stop_time, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
ok(start == filter->expected_start_time, "Got start time %s.\n", wine_dbgstr_longlong(start));
ok(stop == filter->expected_stop_time, "Got stop time %s.\n", wine_dbgstr_longlong(stop));
}
return S_OK;

View File

@ -281,6 +281,8 @@ static HRESULT WINAPI transform_sink_receive(struct strmbase_sink *pin, IMediaSa
{
struct transform *filter = impl_from_strmbase_filter(pin->pin.filter);
struct wg_sample input_wg_sample = {0};
REFERENCE_TIME start_time;
REFERENCE_TIME end_time;
HRESULT hr;
/* We do not expect pin connection state to change while the filter is
@ -306,6 +308,18 @@ static HRESULT WINAPI transform_sink_receive(struct strmbase_sink *pin, IMediaSa
if (FAILED(hr))
return hr;
hr = IMediaSample_GetTime(sample, &start_time, &end_time);
if (SUCCEEDED(hr))
{
input_wg_sample.pts = start_time;
input_wg_sample.flags |= WG_SAMPLE_FLAG_HAS_PTS;
}
if (hr == S_OK)
{
input_wg_sample.duration = end_time - start_time;
input_wg_sample.flags |= WG_SAMPLE_FLAG_HAS_DURATION;
}
hr = wg_transform_push_data(filter->transform, &input_wg_sample);
if (FAILED(hr))
return hr;
@ -347,6 +361,20 @@ static HRESULT WINAPI transform_sink_receive(struct strmbase_sink *pin, IMediaSa
return hr;
}
if (output_wg_sample.flags & WG_SAMPLE_FLAG_HAS_PTS)
{
start_time = output_wg_sample.pts;
if (output_wg_sample.flags & WG_SAMPLE_FLAG_HAS_DURATION)
{
end_time = start_time + output_wg_sample.duration;
IMediaSample_SetTime(output_sample, &start_time, &end_time);
}
else
{
IMediaSample_SetTime(output_sample, &start_time, NULL);
}
}
hr = IMemInputPin_Receive(filter->source.pMemInputPin, output_sample);
if (FAILED(hr))
{