From: Ziqing Hui zhui@codeweavers.com
--- dlls/winegstreamer/unix_private.h | 1 + dlls/winegstreamer/unixlib.c | 58 ++++++++++++++++++------------- dlls/winegstreamer/wg_parser.c | 7 ++-- 3 files changed, 37 insertions(+), 29 deletions(-)
diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index 305d69c12a8..eefd3cdb259 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -37,6 +37,7 @@ extern GstStreamType stream_type_from_caps(GstCaps *caps) DECLSPEC_HIDDEN; 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; extern bool append_element(GstElement *container, GstElement *element, GstElement **first, GstElement **last) DECLSPEC_HIDDEN; +extern bool link_src_to_sink(GstPad *src_pad, GstPad *sink_pad) DECLSPEC_HIDDEN; extern bool link_src_to_element(GstPad *src_pad, GstElement *element) DECLSPEC_HIDDEN; extern bool link_element_to_sink(GstElement *element, GstPad *sink_pad) DECLSPEC_HIDDEN; extern bool push_event(GstPad *pad, GstEvent *event) DECLSPEC_HIDDEN; diff --git a/dlls/winegstreamer/unixlib.c b/dlls/winegstreamer/unixlib.c index 513ece95a90..273801ac398 100644 --- a/dlls/winegstreamer/unixlib.c +++ b/dlls/winegstreamer/unixlib.c @@ -162,50 +162,60 @@ bool append_element(GstElement *container, GstElement *element, GstElement **fir return success; }
-bool link_src_to_element(GstPad *src_pad, GstElement *element) +bool link_src_to_sink(GstPad *src_pad, GstPad *sink_pad) { GstPadLinkReturn ret; - GstPad *sink_pad;
- if (!(sink_pad = gst_element_get_static_pad(element, "sink"))) + if ((ret = gst_pad_link(src_pad, sink_pad)) != GST_PAD_LINK_OK) { - gchar *name = gst_element_get_name(element); - GST_ERROR("Failed to find sink pad on %s", name); - g_free(name); + gchar *src_name = gst_pad_get_name(src_pad), *sink_name = gst_pad_get_name(sink_pad); + + GST_ERROR("Failed to link src pad %s to sink pad %s, reason: %s", + src_name, sink_name, gst_pad_link_get_name(ret)); + + g_free(sink_name); + g_free(src_name); + return false; } - if ((ret = gst_pad_link(src_pad, sink_pad))) + + return true; +} + +bool link_src_to_element(GstPad *src_pad, GstElement *element) +{ + GstPad *sink_pad; + bool ret; + + if (!(sink_pad = gst_element_get_compatible_pad(element, src_pad, NULL))) { - gchar *src_name = gst_pad_get_name(src_pad), *sink_name = gst_pad_get_name(sink_pad); - GST_ERROR("Failed to link element pad %s with pad %s", src_name, sink_name); - g_free(sink_name); + gchar *element_name = gst_element_get_name(element), *src_name = gst_pad_get_name(src_pad); + GST_ERROR("Failed to find sink pad compatible to %s on %s", src_name, element_name); g_free(src_name); + g_free(element_name); + return false; } + ret = link_src_to_sink(src_pad, sink_pad); gst_object_unref(sink_pad); - return !ret; + return ret; }
bool link_element_to_sink(GstElement *element, GstPad *sink_pad) { - GstPadLinkReturn ret; GstPad *src_pad; + bool ret;
- if (!(src_pad = gst_element_get_static_pad(element, "src"))) + if (!(src_pad = gst_element_get_compatible_pad(element, sink_pad, NULL))) { - gchar *name = gst_element_get_name(element); - GST_ERROR("Failed to find src pad on %s", name); - g_free(name); - return false; - } - if ((ret = gst_pad_link(src_pad, sink_pad))) - { - gchar *src_name = gst_pad_get_name(src_pad), *sink_name = gst_pad_get_name(sink_pad); - GST_ERROR("Failed to link pad %s with element pad %s", src_name, sink_name); + gchar *element_name = gst_element_get_name(element), *sink_name = gst_pad_get_name(sink_pad); + GST_ERROR("Failed to find src pad compatible %s on %s", sink_name, element_name); g_free(sink_name); - g_free(src_name); + g_free(element_name); + return false; } + ret = link_src_to_sink(src_pad, sink_pad); gst_object_unref(src_pad); - return !ret; + return ret; }
bool push_event(GstPad *pad, GstEvent *event) diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 299eea09c90..ebdefb6a7f9 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -849,7 +849,6 @@ static bool stream_create_post_processing_elements(GstPad *pad, struct wg_parser struct wg_parser *parser = stream->parser; const char *name; GstCaps *caps; - int ret;
caps = gst_pad_query_caps(pad, NULL); name = gst_structure_get_name(gst_caps_get_structure(caps, 0)); @@ -898,11 +897,9 @@ static bool stream_create_post_processing_elements(GstPad *pad, struct wg_parser if (!link_src_to_element(pad, first) || !link_element_to_sink(last, stream->my_sink)) return false; } - else if ((ret = gst_pad_link(pad, stream->my_sink)) < 0) + else { - GST_ERROR("Failed to link decodebin source pad to our sink pad, error %s.", - gst_pad_link_get_name(ret)); - return false; + return link_src_to_sink(pad, stream->my_sink); }
return true;