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/wg_transform.c | 70 ++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index 29fe4618f07..4a92ebfc9e4 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -72,6 +72,49 @@ NTSTATUS wg_transform_destroy(void *args) return STATUS_SUCCESS; }
+static GstElement *tranform_find_element(GstElementFactoryListType type, GstCaps *src_caps, GstCaps *sink_caps) +{ + GstElement *element = NULL; + GList *tmp, *transforms; + gchar *name; + + transforms = gst_element_factory_list_get_elements(type, GST_RANK_MARGINAL); + if (!transforms) + goto done; + + tmp = gst_element_factory_list_filter(transforms, src_caps, GST_PAD_SINK, FALSE); + gst_plugin_feature_list_free(transforms); + if (!(transforms = tmp)) + goto done; + + tmp = gst_element_factory_list_filter(transforms, sink_caps, GST_PAD_SRC, FALSE); + gst_plugin_feature_list_free(transforms); + if (!(transforms = tmp)) + goto done; + + transforms = g_list_sort(transforms, gst_plugin_feature_rank_compare_func); + for (tmp = transforms; tmp != NULL && element == NULL; tmp = tmp->next) + { + name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(tmp->data)); + if (!(element = gst_element_factory_create(GST_ELEMENT_FACTORY(tmp->data), NULL))) + GST_WARNING("Failed to create %s element.", name); + } + gst_plugin_feature_list_free(transforms); + +done: + if (element) + GST_DEBUG("Created %s element %p.", name, element); + else + { + gchar *src_str = gst_caps_to_string(src_caps), *sink_str = gst_caps_to_string(sink_caps); + GST_WARNING("Failed to create transform matching caps %s / %s.", src_str, sink_str); + g_free(sink_str); + g_free(src_str); + } + + return element; +} + static bool transform_append_element(struct wg_transform *transform, GstElement *element, GstElement **first, GstElement **last) { @@ -97,13 +140,14 @@ static bool transform_append_element(struct wg_transform *transform, GstElement NTSTATUS wg_transform_create(void *args) { struct wg_transform_create_params *params = args; + GstCaps *raw_caps = NULL, *src_caps = NULL, *sink_caps = NULL; 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; NTSTATUS status = STATUS_UNSUCCESSFUL; GstPadTemplate *template = NULL; struct wg_transform *transform; + const gchar *media_type;
if (!init_gstreamer()) return STATUS_UNSUCCESSFUL; @@ -118,6 +162,28 @@ NTSTATUS wg_transform_create(void *args) if (!(sink_caps = wg_format_to_caps(&output_format))) goto done;
+ /* As we append conversion elements we don't want to filter decoders + * based on the actual output format now. Matching decoders with the + * raw output media type should be enough. + */ + media_type = gst_structure_get_name(gst_caps_get_structure(sink_caps, 0)); + if (!(raw_caps = gst_caps_new_empty_simple(media_type))) + goto done; + + switch (input_format.major_type) + { + case WG_MAJOR_TYPE_WMA: + if (!(element = tranform_find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) || + !transform_append_element(transform, element, &first, &last)) + goto done; + break; + case WG_MAJOR_TYPE_AUDIO: + case WG_MAJOR_TYPE_VIDEO: + case WG_MAJOR_TYPE_UNKNOWN: + GST_FIXME("Format %u not implemented!", input_format.major_type); + goto done; + } + switch (output_format.major_type) { case WG_MAJOR_TYPE_AUDIO: @@ -171,6 +237,8 @@ NTSTATUS wg_transform_create(void *args) done: if (template) g_object_unref(template); + if (raw_caps) + gst_caps_unref(raw_caps); if (sink_caps) gst_caps_unref(sink_caps); if (src_caps)