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@codeweavers.com --- dlls/winegstreamer/unix_private.h | 1 + dlls/winegstreamer/wg_parser.c | 2 +- dlls/winegstreamer/wg_transform.c | 47 +++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index f9c4da2f6ea..d3f32484ee6 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -26,6 +26,7 @@ #include <gst/gst.h>
extern bool init_gstreamer(void) DECLSPEC_HIDDEN; +extern GstElement *create_element(const char *name, const char *plugin_set) DECLSPEC_HIDDEN;
extern void wg_format_from_caps(struct wg_format *format, const GstCaps *caps) DECLSPEC_HIDDEN; extern bool wg_format_compare(const struct wg_format *a, const struct wg_format *b) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 37da2d1e1c4..d9bbc60964e 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -699,7 +699,7 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) } }
-static GstElement *create_element(const char *name, const char *plugin_set) +GstElement *create_element(const char *name, const char *plugin_set) { GstElement *element;
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index c52650b80d9..120d9fcf1a5 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -78,11 +78,41 @@ NTSTATUS wg_transform_destroy(void *args) return STATUS_SUCCESS; }
+static bool transform_append_element(struct wg_transform *transform, GstElement *element, + GstElement **first, GstElement **last) +{ + gchar *name = gst_element_get_name(element); + + if (!gst_bin_add(GST_BIN(transform->container), element)) + { + GST_ERROR("Failed to add %s element to bin.", name); + g_free(name); + return false; + } + + if (*last && !gst_element_link(*last, element)) + { + GST_ERROR("Failed to link %s element.", name); + g_free(name); + return false; + } + + GST_DEBUG("Appended %s element %p.", name, element); + g_free(name); + + if (!*first) + *first = element; + + *last = element; + return true; +} + 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; + GstElement *first = NULL, *last = NULL, *element; GstCaps *src_caps = NULL, *sink_caps = NULL; GstPadTemplate *template = NULL; struct wg_transform *transform; @@ -105,6 +135,23 @@ NTSTATUS wg_transform_create(void *args) if (!(transform->container = gst_bin_new("wg_transform"))) goto done;
+ switch (output_format.major_type) + { + case WG_MAJOR_TYPE_AUDIO: + if (!(element = create_element("audioconvert", "base")) || + !transform_append_element(transform, element, &first, &last)) + goto done; + if (!(element = create_element("audioresample", "base")) || + !transform_append_element(transform, element, &first, &last)) + goto done; + break; + case WG_MAJOR_TYPE_VIDEO: + case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_UNKNOWN: + GST_FIXME("Format %u not implemented!", output_format.major_type); + 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")))