winegstreamer: Move seeking to the Unix library.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-16 19:28:26 -06:00 committed by Alexandre Julliard
parent b90cb3cf95
commit ccc6c98075
3 changed files with 34 additions and 25 deletions

View File

@ -228,6 +228,10 @@ struct unix_funcs
bool (CDECL *wg_parser_stream_get_event)(struct wg_parser_stream *stream, struct wg_parser_event *event);
void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream,
bool underflow, double proportion, int64_t diff, uint64_t timestamp);
/* start_pos and stop_pos are in 100-nanosecond units. */
bool (CDECL *wg_parser_stream_seek)(struct wg_parser_stream *stream, double rate,
uint64_t start_pos, uint64_t stop_pos, DWORD start_flags, DWORD stop_flags);
};
extern const struct unix_funcs *unix_funcs;

View File

@ -848,7 +848,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
{
struct parser *filter = impl_from_strmbase_filter(iface);
struct wg_parser *parser = filter->wg_parser;
GstSeekType stop_type = GST_SEEK_TYPE_NONE;
DWORD stop_flags = AM_SEEKING_NoPositioning;
const SourceSeeking *seeking;
unsigned int i;
@ -861,15 +861,11 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
/* DirectShow retains the old seek positions, but resets to them every time
* it transitions from stopped -> paused. */
parser->next_offset = parser->start_offset;
seeking = &filter->sources[0]->seek;
if (seeking->llStop && seeking->llStop != seeking->llDuration)
stop_type = GST_SEEK_TYPE_SET;
gst_pad_push_event(filter->sources[0]->wg_stream->my_sink, gst_event_new_seek(
seeking->dRate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
GST_SEEK_TYPE_SET, seeking->llCurrent * 100,
stop_type, seeking->llStop * 100));
stop_flags = AM_SEEKING_AbsolutePositioning;
unix_funcs->wg_parser_stream_seek(filter->sources[0]->wg_stream, seeking->dRate,
seeking->llCurrent, seeking->llStop, AM_SEEKING_AbsolutePositioning, stop_flags);
for (i = 0; i < filter->source_count; ++i)
{
@ -1212,11 +1208,8 @@ static ULONG WINAPI GST_Seeking_Release(IMediaSeeking *iface)
static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
LONGLONG *current, DWORD current_flags, LONGLONG *stop, DWORD stop_flags)
{
GstSeekType current_type = GST_SEEK_TYPE_SET, stop_type = GST_SEEK_TYPE_SET;
struct parser_source *pin = impl_from_IMediaSeeking(iface);
struct wg_parser_stream *stream = pin->wg_stream;
struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter);
GstSeekFlags flags = 0;
HRESULT hr = S_OK;
int i;
@ -1256,20 +1249,8 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
SourceSeekingImpl_SetPositions(iface, current, current_flags, stop, stop_flags);
if (current_flags & AM_SEEKING_SeekToKeyFrame)
flags |= GST_SEEK_FLAG_KEY_UNIT;
if (current_flags & AM_SEEKING_Segment)
flags |= GST_SEEK_FLAG_SEGMENT;
if (!(current_flags & AM_SEEKING_NoFlush))
flags |= GST_SEEK_FLAG_FLUSH;
if ((current_flags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
current_type = GST_SEEK_TYPE_NONE;
if ((stop_flags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
stop_type = GST_SEEK_TYPE_NONE;
if (!gst_pad_push_event(stream->my_sink, gst_event_new_seek(pin->seek.dRate, GST_FORMAT_TIME, flags,
current_type, pin->seek.llCurrent * 100, stop_type, pin->seek.llStop * 100)))
if (!unix_funcs->wg_parser_stream_seek(pin->wg_stream, pin->seek.dRate,
pin->seek.llCurrent, pin->seek.llStop, current_flags, stop_flags))
{
ERR("Failed to seek (current %s, stop %s).\n",
debugstr_time(pin->seek.llCurrent), debugstr_time(pin->seek.llStop));

View File

@ -391,6 +391,28 @@ static bool CDECL wg_parser_stream_get_event(struct wg_parser_stream *stream, st
return true;
}
static bool CDECL wg_parser_stream_seek(struct wg_parser_stream *stream, double rate,
uint64_t start_pos, uint64_t stop_pos, DWORD start_flags, DWORD stop_flags)
{
GstSeekType start_type = GST_SEEK_TYPE_SET, stop_type = GST_SEEK_TYPE_SET;
GstSeekFlags flags = 0;
if (start_flags & AM_SEEKING_SeekToKeyFrame)
flags |= GST_SEEK_FLAG_KEY_UNIT;
if (start_flags & AM_SEEKING_Segment)
flags |= GST_SEEK_FLAG_SEGMENT;
if (!(start_flags & AM_SEEKING_NoFlush))
flags |= GST_SEEK_FLAG_FLUSH;
if ((start_flags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
start_type = GST_SEEK_TYPE_NONE;
if ((stop_flags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
stop_type = GST_SEEK_TYPE_NONE;
return gst_pad_push_event(stream->my_sink, gst_event_new_seek(rate,
GST_FORMAT_TIME, flags, start_type, start_pos * 100, stop_type, stop_pos * 100));
}
static void CDECL wg_parser_stream_notify_qos(struct wg_parser_stream *stream,
bool underflow, double proportion, int64_t diff, uint64_t timestamp)
{
@ -1565,6 +1587,8 @@ static const struct unix_funcs funcs =
wg_parser_stream_get_event,
wg_parser_stream_notify_qos,
wg_parser_stream_seek,
};
NTSTATUS CDECL __wine_init_unix_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out)