Rémi Bernon : winegstreamer: Create static pads on wg_transform struct.
Alexandre Julliard
julliard at winehq.org
Thu Feb 17 15:33:57 CST 2022
Module: wine
Branch: master
Commit: 71bf5b24d7efabfcacfa707198efc4be0da3e446
URL: https://source.winehq.org/git/wine.git/?a=commit;h=71bf5b24d7efabfcacfa707198efc4be0da3e446
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Wed Feb 16 12:19:09 2022 +0100
winegstreamer: Create static pads on wg_transform struct.
With caps created from the input / output formats.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winegstreamer/gst_private.h | 3 ++-
dlls/winegstreamer/main.c | 9 +++++--
dlls/winegstreamer/unixlib.h | 2 ++
dlls/winegstreamer/wg_format.c | 40 ++++++++++++++++++++++++++++--
dlls/winegstreamer/wg_transform.c | 51 ++++++++++++++++++++++++++++++++++++++-
dlls/winegstreamer/wma_decoder.c | 2 +-
6 files changed, 100 insertions(+), 7 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index 8bc9f838d29..a63daaf04b9 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -96,7 +96,8 @@ uint64_t wg_parser_stream_get_duration(struct wg_parser_stream *stream);
void 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);
-struct wg_transform *wg_transform_create(void);
+struct wg_transform *wg_transform_create(const struct wg_format *input_format,
+ const struct wg_format *output_format);
void wg_transform_destroy(struct wg_transform *transform);
unsigned int wg_format_get_max_size(const struct wg_format *format);
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c
index f23fa3abcdf..f85e9995525 100644
--- a/dlls/winegstreamer/main.c
+++ b/dlls/winegstreamer/main.c
@@ -254,9 +254,14 @@ void wg_parser_stream_seek(struct wg_parser_stream *stream, double rate,
__wine_unix_call(unix_handle, unix_wg_parser_stream_seek, ¶ms);
}
-struct wg_transform *wg_transform_create(void)
+struct wg_transform *wg_transform_create(const struct wg_format *input_format,
+ const struct wg_format *output_format)
{
- struct wg_transform_create_params params = {0};
+ struct wg_transform_create_params params =
+ {
+ .input_format = input_format,
+ .output_format = output_format,
+ };
if (__wine_unix_call(unix_handle, unix_wg_transform_create, ¶ms))
return NULL;
diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h
index 8e3f5e84bfb..4adbb694766 100644
--- a/dlls/winegstreamer/unixlib.h
+++ b/dlls/winegstreamer/unixlib.h
@@ -232,6 +232,8 @@ struct wg_parser_stream_seek_params
struct wg_transform_create_params
{
struct wg_transform *transform;
+ const struct wg_format *input_format;
+ const struct wg_format *output_format;
};
enum unix_funcs
diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c
index 8f771bb8abd..40b9acfefff 100644
--- a/dlls/winegstreamer/wg_format.c
+++ b/dlls/winegstreamer/wg_format.c
@@ -394,6 +394,43 @@ static GstCaps *wg_format_to_caps_video(const struct wg_format *format)
return caps;
}
+static GstCaps *wg_format_to_caps_wma(const struct wg_format *format)
+{
+ GstBuffer *buffer;
+ GstCaps *caps;
+
+ if (!(caps = gst_caps_new_empty_simple("audio/x-wma")))
+ return NULL;
+ if (format->u.wma.version)
+ gst_caps_set_simple(caps, "wmaversion", G_TYPE_INT, format->u.wma.version, NULL);
+
+ if (format->u.wma.bitrate)
+ gst_caps_set_simple(caps, "bitrate", G_TYPE_INT, format->u.wma.bitrate, NULL);
+ if (format->u.wma.rate)
+ gst_caps_set_simple(caps, "rate", G_TYPE_INT, format->u.wma.rate, NULL);
+ if (format->u.wma.depth)
+ gst_caps_set_simple(caps, "depth", G_TYPE_INT, format->u.wma.depth, NULL);
+ if (format->u.wma.channels)
+ gst_caps_set_simple(caps, "channels", G_TYPE_INT, format->u.wma.channels, NULL);
+ if (format->u.wma.block_align)
+ gst_caps_set_simple(caps, "block_align", G_TYPE_INT, format->u.wma.block_align, NULL);
+
+ if (format->u.wma.codec_data_len)
+ {
+ if (!(buffer = gst_buffer_new_and_alloc(format->u.wma.codec_data_len)))
+ {
+ gst_caps_unref(caps);
+ return NULL;
+ }
+
+ gst_buffer_fill(buffer, 0, format->u.wma.codec_data, format->u.wma.codec_data_len);
+ gst_caps_set_simple(caps, "codec_data", GST_TYPE_BUFFER, buffer, NULL);
+ gst_buffer_unref(buffer);
+ }
+
+ return caps;
+}
+
GstCaps *wg_format_to_caps(const struct wg_format *format)
{
switch (format->major_type)
@@ -401,8 +438,7 @@ GstCaps *wg_format_to_caps(const struct wg_format *format)
case WG_MAJOR_TYPE_UNKNOWN:
return NULL;
case WG_MAJOR_TYPE_WMA:
- GST_FIXME("WMA format not implemented!\n");
- return NULL;
+ return wg_format_to_caps_wma(format);
case WG_MAJOR_TYPE_AUDIO:
return wg_format_to_caps_audio(format);
case WG_MAJOR_TYPE_VIDEO:
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c
index 2f225e5bc55..e4545774428 100644
--- a/dlls/winegstreamer/wg_transform.c
+++ b/dlls/winegstreamer/wg_transform.c
@@ -44,13 +44,29 @@ GST_DEBUG_CATEGORY_EXTERN(wine);
struct wg_transform
{
- int dummy;
+ GstPad *my_src, *my_sink;
};
+static GstFlowReturn transform_sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *buffer)
+{
+ struct wg_transform *transform = gst_pad_get_element_private(pad);
+
+ GST_INFO("transform %p, buffer %p.", transform, buffer);
+
+ gst_buffer_unref(buffer);
+
+ return GST_FLOW_OK;
+}
+
NTSTATUS wg_transform_destroy(void *args)
{
struct wg_transform *transform = args;
+ if (transform->my_sink)
+ g_object_unref(transform->my_sink);
+ if (transform->my_src)
+ g_object_unref(transform->my_src);
+
free(transform);
return STATUS_SUCCESS;
}
@@ -58,6 +74,10 @@ NTSTATUS wg_transform_destroy(void *args)
NTSTATUS wg_transform_create(void *args)
{
struct wg_transform_create_params *params = args;
+ struct wg_format output_format = *params->output_format;
+ struct wg_format input_format = *params->input_format;
+ GstCaps *src_caps = NULL, *sink_caps = NULL;
+ GstPadTemplate *template = NULL;
struct wg_transform *transform;
NTSTATUS status;
@@ -69,9 +89,38 @@ NTSTATUS wg_transform_create(void *args)
if (!(transform = calloc(1, sizeof(*transform))))
goto done;
+ if (!(src_caps = wg_format_to_caps(&input_format)))
+ goto done;
+ if (!(sink_caps = wg_format_to_caps(&output_format)))
+ goto done;
+
+ if (!(template = gst_pad_template_new("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps)))
+ goto done;
+ if (!(transform->my_src = gst_pad_new_from_template(template, "src")))
+ goto done;
+ g_object_unref(template);
+ template = NULL;
+
+ if (!(template = gst_pad_template_new("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sink_caps)))
+ goto done;
+ if (!(transform->my_sink = gst_pad_new_from_template(template, "sink")))
+ goto done;
+ g_object_unref(template);
+ template = NULL;
+
+ gst_pad_set_element_private(transform->my_sink, transform);
+ gst_pad_set_chain_function(transform->my_sink, transform_sink_chain_cb);
+
status = STATUS_SUCCESS;
done:
+ if (template)
+ g_object_unref(template);
+ if (sink_caps)
+ gst_caps_unref(sink_caps);
+ if (src_caps)
+ gst_caps_unref(src_caps);
+
if (status)
{
GST_ERROR("Failed to create winegstreamer transform.");
diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c
index b14261706a7..6c198706944 100644
--- a/dlls/winegstreamer/wma_decoder.c
+++ b/dlls/winegstreamer/wma_decoder.c
@@ -78,7 +78,7 @@ static HRESULT try_create_wg_transform(struct wma_decoder *decoder)
if (output_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
return MF_E_INVALIDMEDIATYPE;
- if (!(decoder->wg_transform = wg_transform_create()))
+ if (!(decoder->wg_transform = wg_transform_create(&input_format, &output_format)))
return E_FAIL;
return S_OK;
More information about the wine-cvs
mailing list