Signed-off-by: Zebediah Figura <zfigura(a)codeweavers.com>
---
dlls/winegstreamer/gst_private.h | 137 +------------------------
dlls/winegstreamer/unixlib.h | 165 +++++++++++++++++++++++++++++++
dlls/winegstreamer/wg_parser.c | 17 +++-
3 files changed, 179 insertions(+), 140 deletions(-)
create mode 100644 dlls/winegstreamer/unixlib.h
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index 3470f7870fa..91c646571cf 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -36,6 +36,8 @@
#include "wine/debug.h"
#include "wine/strmbase.h"
+#include "unixlib.h"
+
static inline const char *debugstr_time(REFERENCE_TIME time)
{
ULONGLONG abstime = time >= 0 ? time : -time;
@@ -59,141 +61,6 @@ static inline const char *debugstr_time(REFERENCE_TIME time)
#define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
-struct wg_format
-{
- enum wg_major_type
- {
- WG_MAJOR_TYPE_UNKNOWN,
- WG_MAJOR_TYPE_VIDEO,
- WG_MAJOR_TYPE_AUDIO,
- } major_type;
-
- union
- {
- struct
- {
- enum wg_video_format
- {
- WG_VIDEO_FORMAT_UNKNOWN,
-
- WG_VIDEO_FORMAT_BGRA,
- WG_VIDEO_FORMAT_BGRx,
- WG_VIDEO_FORMAT_BGR,
- WG_VIDEO_FORMAT_RGB15,
- WG_VIDEO_FORMAT_RGB16,
-
- WG_VIDEO_FORMAT_AYUV,
- WG_VIDEO_FORMAT_I420,
- WG_VIDEO_FORMAT_NV12,
- WG_VIDEO_FORMAT_UYVY,
- WG_VIDEO_FORMAT_YUY2,
- WG_VIDEO_FORMAT_YV12,
- WG_VIDEO_FORMAT_YVYU,
-
- WG_VIDEO_FORMAT_CINEPAK,
- } format;
- uint32_t width, height;
- uint32_t fps_n, fps_d;
- } video;
- struct
- {
- enum wg_audio_format
- {
- WG_AUDIO_FORMAT_UNKNOWN,
-
- WG_AUDIO_FORMAT_U8,
- WG_AUDIO_FORMAT_S16LE,
- WG_AUDIO_FORMAT_S24LE,
- WG_AUDIO_FORMAT_S32LE,
- WG_AUDIO_FORMAT_F32LE,
- WG_AUDIO_FORMAT_F64LE,
-
- WG_AUDIO_FORMAT_MPEG1_LAYER1,
- WG_AUDIO_FORMAT_MPEG1_LAYER2,
- WG_AUDIO_FORMAT_MPEG1_LAYER3,
- } format;
-
- uint32_t channels;
- uint32_t channel_mask; /* In WinMM format. */
- uint32_t rate;
- } audio;
- } u;
-};
-
-enum wg_parser_event_type
-{
- WG_PARSER_EVENT_NONE = 0,
- WG_PARSER_EVENT_BUFFER,
- WG_PARSER_EVENT_EOS,
- WG_PARSER_EVENT_SEGMENT,
-};
-
-struct wg_parser_event
-{
- enum wg_parser_event_type type;
- union
- {
- struct
- {
- /* pts and duration are in 100-nanosecond units. */
- ULONGLONG pts, duration;
- uint32_t size;
- bool discontinuity, preroll, delta, has_pts, has_duration;
- } buffer;
- struct
- {
- ULONGLONG position, stop;
- DOUBLE rate;
- } segment;
- } u;
-};
-C_ASSERT(sizeof(struct wg_parser_event) == 40);
-
-enum wg_parser_type
-{
- WG_PARSER_DECODEBIN,
- WG_PARSER_AVIDEMUX,
- WG_PARSER_MPEGAUDIOPARSE,
- WG_PARSER_WAVPARSE,
-};
-
-struct unix_funcs
-{
- struct wg_parser *(CDECL *wg_parser_create)(enum wg_parser_type type, bool unlimited_buffering);
- void (CDECL *wg_parser_destroy)(struct wg_parser *parser);
-
- HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size);
- void (CDECL *wg_parser_disconnect)(struct wg_parser *parser);
-
- void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
- void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
-
- bool (CDECL *wg_parser_get_next_read_offset)(struct wg_parser *parser,
- uint64_t *offset, uint32_t *size);
- void (CDECL *wg_parser_push_data)(struct wg_parser *parser,
- const void *data, uint32_t size);
-
- uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser);
- struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
-
- void (CDECL *wg_parser_stream_get_preferred_format)(struct wg_parser_stream *stream, struct wg_format *format);
- void (CDECL *wg_parser_stream_enable)(struct wg_parser_stream *stream, const struct wg_format *format);
- void (CDECL *wg_parser_stream_disable)(struct wg_parser_stream *stream);
-
- bool (CDECL *wg_parser_stream_get_event)(struct wg_parser_stream *stream, struct wg_parser_event *event);
- bool (CDECL *wg_parser_stream_copy_buffer)(struct wg_parser_stream *stream,
- void *data, uint32_t offset, uint32_t size);
- void (CDECL *wg_parser_stream_release_buffer)(struct wg_parser_stream *stream);
- void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream,
- bool underflow, double proportion, int64_t diff, uint64_t timestamp);
-
- /* Returns the duration in 100-nanosecond units. */
- uint64_t (CDECL *wg_parser_stream_get_duration)(struct wg_parser_stream *stream);
- /* 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;
HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h
new file mode 100644
index 00000000000..e917f7b5557
--- /dev/null
+++ b/dlls/winegstreamer/unixlib.h
@@ -0,0 +1,165 @@
+/*
+ * winegstreamer Unix library interface
+ *
+ * Copyright 2020-2021 Zebediah Figura for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_WINEGSTREAMER_UNIXLIB_H
+#define __WINE_WINEGSTREAMER_UNIXLIB_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "windef.h"
+#include "wtypes.h"
+#include "mmreg.h"
+
+struct wg_format
+{
+ enum wg_major_type
+ {
+ WG_MAJOR_TYPE_UNKNOWN,
+ WG_MAJOR_TYPE_VIDEO,
+ WG_MAJOR_TYPE_AUDIO,
+ } major_type;
+
+ union
+ {
+ struct
+ {
+ enum wg_video_format
+ {
+ WG_VIDEO_FORMAT_UNKNOWN,
+
+ WG_VIDEO_FORMAT_BGRA,
+ WG_VIDEO_FORMAT_BGRx,
+ WG_VIDEO_FORMAT_BGR,
+ WG_VIDEO_FORMAT_RGB15,
+ WG_VIDEO_FORMAT_RGB16,
+
+ WG_VIDEO_FORMAT_AYUV,
+ WG_VIDEO_FORMAT_I420,
+ WG_VIDEO_FORMAT_NV12,
+ WG_VIDEO_FORMAT_UYVY,
+ WG_VIDEO_FORMAT_YUY2,
+ WG_VIDEO_FORMAT_YV12,
+ WG_VIDEO_FORMAT_YVYU,
+
+ WG_VIDEO_FORMAT_CINEPAK,
+ } format;
+ uint32_t width, height;
+ uint32_t fps_n, fps_d;
+ } video;
+ struct
+ {
+ enum wg_audio_format
+ {
+ WG_AUDIO_FORMAT_UNKNOWN,
+
+ WG_AUDIO_FORMAT_U8,
+ WG_AUDIO_FORMAT_S16LE,
+ WG_AUDIO_FORMAT_S24LE,
+ WG_AUDIO_FORMAT_S32LE,
+ WG_AUDIO_FORMAT_F32LE,
+ WG_AUDIO_FORMAT_F64LE,
+
+ WG_AUDIO_FORMAT_MPEG1_LAYER1,
+ WG_AUDIO_FORMAT_MPEG1_LAYER2,
+ WG_AUDIO_FORMAT_MPEG1_LAYER3,
+ } format;
+
+ uint32_t channels;
+ uint32_t channel_mask; /* In WinMM format. */
+ uint32_t rate;
+ } audio;
+ } u;
+};
+
+enum wg_parser_event_type
+{
+ WG_PARSER_EVENT_NONE = 0,
+ WG_PARSER_EVENT_BUFFER,
+ WG_PARSER_EVENT_EOS,
+ WG_PARSER_EVENT_SEGMENT,
+};
+
+struct wg_parser_event
+{
+ enum wg_parser_event_type type;
+ union
+ {
+ struct
+ {
+ /* pts and duration are in 100-nanosecond units. */
+ ULONGLONG pts, duration;
+ uint32_t size;
+ bool discontinuity, preroll, delta, has_pts, has_duration;
+ } buffer;
+ struct
+ {
+ ULONGLONG position, stop;
+ DOUBLE rate;
+ } segment;
+ } u;
+};
+C_ASSERT(sizeof(struct wg_parser_event) == 40);
+
+enum wg_parser_type
+{
+ WG_PARSER_DECODEBIN,
+ WG_PARSER_AVIDEMUX,
+ WG_PARSER_MPEGAUDIOPARSE,
+ WG_PARSER_WAVPARSE,
+};
+
+struct unix_funcs
+{
+ struct wg_parser *(CDECL *wg_parser_create)(enum wg_parser_type type, bool unlimited_buffering);
+ void (CDECL *wg_parser_destroy)(struct wg_parser *parser);
+
+ HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size);
+ void (CDECL *wg_parser_disconnect)(struct wg_parser *parser);
+
+ void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
+ void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
+
+ bool (CDECL *wg_parser_get_next_read_offset)(struct wg_parser *parser,
+ uint64_t *offset, uint32_t *size);
+ void (CDECL *wg_parser_push_data)(struct wg_parser *parser,
+ const void *data, uint32_t size);
+
+ uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser);
+ struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
+
+ void (CDECL *wg_parser_stream_get_preferred_format)(struct wg_parser_stream *stream, struct wg_format *format);
+ void (CDECL *wg_parser_stream_enable)(struct wg_parser_stream *stream, const struct wg_format *format);
+ void (CDECL *wg_parser_stream_disable)(struct wg_parser_stream *stream);
+
+ bool (CDECL *wg_parser_stream_get_event)(struct wg_parser_stream *stream, struct wg_parser_event *event);
+ bool (CDECL *wg_parser_stream_copy_buffer)(struct wg_parser_stream *stream,
+ void *data, uint32_t offset, uint32_t size);
+ void (CDECL *wg_parser_stream_release_buffer)(struct wg_parser_stream *stream);
+ void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream,
+ bool underflow, double proportion, int64_t diff, uint64_t timestamp);
+
+ /* Returns the duration in 100-nanosecond units. */
+ uint64_t (CDECL *wg_parser_stream_get_duration)(struct wg_parser_stream *stream);
+ /* 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);
+};
+
+#endif /* __WINE_WINEGSTREAMER_UNIXLIB_H */
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 21278682318..b89a50b5d8f 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -25,15 +25,22 @@
#endif
#include "config.h"
-#include "ntstatus.h"
-#define WIN32_NO_STATUS
-#include "gst_private.h"
-#include "winternl.h"
+
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/audio/audio.h>
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "winternl.h"
+#include "dshow.h"
+
+#include "unixlib.h"
+
typedef enum
{
GST_AUTOPLUG_SELECT_TRY,
@@ -1859,7 +1866,7 @@ static void init_gstreamer_once(void)
if (!gst_init_check(&argc, &argv, &err))
{
- fprintf(stderr, "winegstreamer: failed to initialize GStreamer: %s\n", debugstr_a(err->message));
+ fprintf(stderr, "winegstreamer: failed to initialize GStreamer: %s\n", err->message);
g_error_free(err);
return;
}
--
2.33.0