Module: wine Branch: master Commit: c23f6650bfbd02bc1e0f1029a04ff47b973f7ee4 URL: https://gitlab.winehq.org/wine/wine/-/commit/c23f6650bfbd02bc1e0f1029a04ff47...
Author: Rémi Bernon rbernon@codeweavers.com Date: Wed Mar 15 10:29:39 2023 +0100
winegstreamer: Move some wg_parser / wg_transform helpers to unixlib.c.
---
dlls/winegstreamer/unix_private.h | 3 +-- dlls/winegstreamer/unixlib.c | 54 +++++++++++++++++++++++++++++++++++++++ dlls/winegstreamer/wg_parser.c | 10 -------- dlls/winegstreamer/wg_transform.c | 46 +-------------------------------- 4 files changed, 56 insertions(+), 57 deletions(-)
diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index 7ae3002ac0b..81db1728aa8 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -32,9 +32,8 @@ GST_DEBUG_CATEGORY_EXTERN(wine) DECLSPEC_HIDDEN;
extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN;
-/* wg_parser.c */ - extern GstElement *create_element(const char *name, const char *plugin_set) DECLSPEC_HIDDEN; +extern GstElement *find_element(GstElementFactoryListType type, GstCaps *src_caps, GstCaps *sink_caps) DECLSPEC_HIDDEN;
/* wg_format.c */
diff --git a/dlls/winegstreamer/unixlib.c b/dlls/winegstreamer/unixlib.c index a1799f8043d..cba6d4adf00 100644 --- a/dlls/winegstreamer/unixlib.c +++ b/dlls/winegstreamer/unixlib.c @@ -47,6 +47,60 @@
GST_DEBUG_CATEGORY(wine);
+GstElement *create_element(const char *name, const char *plugin_set) +{ + GstElement *element; + + if (!(element = gst_element_factory_make(name, NULL))) + fprintf(stderr, "winegstreamer: failed to create %s, are %u-bit GStreamer "%s" plugins installed?\n", + name, 8 * (unsigned int)sizeof(void *), plugin_set); + return element; +} + +GstElement *find_element(GstElementFactoryListType type, GstCaps *src_caps, GstCaps *sink_caps) +{ + GstElement *element = NULL; + GList *tmp, *transforms; + const gchar *name; + + if (!(transforms = gst_element_factory_list_get_elements(type, GST_RANK_MARGINAL))) + 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 element matching caps %s / %s.", src_str, sink_str); + g_free(sink_str); + g_free(src_str); + } + + return element; +} + NTSTATUS wg_init_gstreamer(void *arg) { char arg0[] = "wine"; diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index f371fc3b336..49db4f3118e 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -727,16 +727,6 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) } }
-GstElement *create_element(const char *name, const char *plugin_set) -{ - GstElement *element; - - if (!(element = gst_element_factory_make(name, NULL))) - fprintf(stderr, "winegstreamer: failed to create %s, are %u-bit GStreamer "%s" plugins installed?\n", - name, 8 * (unsigned int)sizeof(void *), plugin_set); - return element; -} - static struct wg_parser_stream *create_stream(struct wg_parser *parser) { struct wg_parser_stream *stream, **new_array; diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index ca89c883f62..cfc04f2093e 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -267,50 +267,6 @@ NTSTATUS wg_transform_destroy(void *args) return STATUS_SUCCESS; }
-static GstElement *transform_find_element(GstElementFactoryListType type, GstCaps *src_caps, GstCaps *sink_caps) -{ - GstElement *element = NULL; - GList *tmp, *transforms; - const gchar *name; - - if (!(transforms = gst_element_factory_list_get_elements(type, GST_RANK_MARGINAL))) - 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) { @@ -423,7 +379,7 @@ NTSTATUS wg_transform_create(void *args) case WG_MAJOR_TYPE_VIDEO_CINEPAK: case WG_MAJOR_TYPE_VIDEO_INDEO: case WG_MAJOR_TYPE_VIDEO_WMV: - if (!(element = transform_find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) + if (!(element = find_element(GST_ELEMENT_FACTORY_TYPE_DECODER, src_caps, raw_caps)) || !transform_append_element(transform, element, &first, &last)) { gst_caps_unref(raw_caps);