Commit 6d37b673 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Introduce new link_src_to_element / link_element_to_sink helpers.

parent 8f7616f3
...@@ -35,6 +35,8 @@ extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN; ...@@ -35,6 +35,8 @@ extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN;
extern GstElement *create_element(const char *name, const char *plugin_set) 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 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 append_element(GstElement *container, GstElement *element, GstElement **first, GstElement **last) 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;
/* wg_format.c */ /* wg_format.c */
......
...@@ -125,6 +125,52 @@ bool append_element(GstElement *container, GstElement *element, GstElement **fir ...@@ -125,6 +125,52 @@ bool append_element(GstElement *container, GstElement *element, GstElement **fir
return success; return success;
} }
bool link_src_to_element(GstPad *src_pad, GstElement *element)
{
GstPadLinkReturn ret;
GstPad *sink_pad;
if (!(sink_pad = gst_element_get_static_pad(element, "sink")))
{
gchar *name = gst_element_get_name(element);
GST_ERROR("Failed to find sink 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 element pad %s with pad %s", src_name, sink_name);
g_free(sink_name);
g_free(src_name);
}
gst_object_unref(sink_pad);
return !ret;
}
bool link_element_to_sink(GstElement *element, GstPad *sink_pad)
{
GstPadLinkReturn ret;
GstPad *src_pad;
if (!(src_pad = gst_element_get_static_pad(element, "src")))
{
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);
g_free(sink_name);
g_free(src_name);
}
gst_object_unref(src_pad);
return !ret;
}
NTSTATUS wg_init_gstreamer(void *arg) NTSTATUS wg_init_gstreamer(void *arg)
{ {
char arg0[] = "wine"; char arg0[] = "wine";
......
...@@ -95,7 +95,7 @@ struct wg_parser_stream ...@@ -95,7 +95,7 @@ struct wg_parser_stream
struct wg_parser *parser; struct wg_parser *parser;
uint32_t number; uint32_t number;
GstPad *their_src, *post_sink, *post_src, *my_sink; GstPad *their_src, *my_sink;
GstElement *flip; GstElement *flip;
GstSegment segment; GstSegment segment;
struct wg_format preferred_format, current_format; struct wg_format preferred_format, current_format;
...@@ -763,15 +763,7 @@ static void free_stream(struct wg_parser_stream *stream) ...@@ -763,15 +763,7 @@ static void free_stream(struct wg_parser_stream *stream)
unsigned int i; unsigned int i;
if (stream->their_src) if (stream->their_src)
{
if (stream->post_sink)
{
gst_object_unref(stream->post_src);
gst_object_unref(stream->post_sink);
stream->post_src = stream->post_sink = NULL;
}
gst_object_unref(stream->their_src); gst_object_unref(stream->their_src);
}
gst_object_unref(stream->my_sink); gst_object_unref(stream->my_sink);
pthread_cond_destroy(&stream->event_cond); pthread_cond_destroy(&stream->event_cond);
...@@ -832,8 +824,8 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) ...@@ -832,8 +824,8 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
|| !append_element(parser->container, element, &first, &last)) || !append_element(parser->container, element, &first, &last))
goto out; goto out;
stream->post_sink = gst_element_get_static_pad(first, "sink"); if (!link_src_to_element(pad, first) || !link_element_to_sink(last, stream->my_sink))
stream->post_src = gst_element_get_static_pad(last, "src"); goto out;
} }
else if (!strcmp(name, "audio/x-raw")) else if (!strcmp(name, "audio/x-raw"))
{ {
...@@ -845,31 +837,8 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) ...@@ -845,31 +837,8 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
|| !append_element(parser->container, element, &first, &last)) || !append_element(parser->container, element, &first, &last))
goto out; goto out;
stream->post_sink = gst_element_get_static_pad(first, "sink"); if (!link_src_to_element(pad, first) || !link_element_to_sink(last, stream->my_sink))
stream->post_src = gst_element_get_static_pad(last, "src");
}
if (stream->post_sink)
{
if ((ret = gst_pad_link(pad, stream->post_sink)) < 0)
{
GST_ERROR("Failed to link decodebin source pad to post-processing elements, error %s.",
gst_pad_link_get_name(ret));
gst_object_unref(stream->post_sink);
stream->post_sink = NULL;
goto out;
}
if ((ret = gst_pad_link(stream->post_src, stream->my_sink)) < 0)
{
GST_ERROR("Failed to link post-processing elements to our sink pad, error %s.",
gst_pad_link_get_name(ret));
gst_object_unref(stream->post_src);
stream->post_src = NULL;
gst_object_unref(stream->post_sink);
stream->post_sink = NULL;
goto out; goto out;
}
} }
else if ((ret = gst_pad_link(pad, stream->my_sink)) < 0) else if ((ret = gst_pad_link(pad, stream->my_sink)) < 0)
{ {
......
...@@ -46,7 +46,6 @@ struct wg_transform ...@@ -46,7 +46,6 @@ struct wg_transform
GstElement *container; GstElement *container;
GstAllocator *allocator; GstAllocator *allocator;
GstPad *my_src, *my_sink; GstPad *my_src, *my_sink;
GstPad *their_sink, *their_src;
GstSegment segment; GstSegment segment;
GstQuery *drain_query; GstQuery *drain_query;
...@@ -254,8 +253,6 @@ NTSTATUS wg_transform_destroy(void *args) ...@@ -254,8 +253,6 @@ NTSTATUS wg_transform_destroy(void *args)
gst_sample_unref(sample); gst_sample_unref(sample);
wg_allocator_destroy(transform->allocator); wg_allocator_destroy(transform->allocator);
g_object_unref(transform->their_sink);
g_object_unref(transform->their_src);
g_object_unref(transform->container); g_object_unref(transform->container);
g_object_unref(transform->my_sink); g_object_unref(transform->my_sink);
g_object_unref(transform->my_src); g_object_unref(transform->my_src);
...@@ -414,13 +411,9 @@ NTSTATUS wg_transform_create(void *args) ...@@ -414,13 +411,9 @@ NTSTATUS wg_transform_create(void *args)
goto out; goto out;
} }
if (!(transform->their_sink = gst_element_get_static_pad(first, "sink"))) if (!link_src_to_element(transform->my_src, first))
goto out; goto out;
if (!(transform->their_src = gst_element_get_static_pad(last, "src"))) if (!link_element_to_sink(last, transform->my_sink))
goto out;
if (gst_pad_link(transform->my_src, transform->their_sink) < 0)
goto out;
if (gst_pad_link(transform->their_src, transform->my_sink) < 0)
goto out; goto out;
if (!gst_pad_set_active(transform->my_sink, 1)) if (!gst_pad_set_active(transform->my_sink, 1))
goto out; goto out;
...@@ -454,10 +447,6 @@ NTSTATUS wg_transform_create(void *args) ...@@ -454,10 +447,6 @@ NTSTATUS wg_transform_create(void *args)
return STATUS_SUCCESS; return STATUS_SUCCESS;
out: out:
if (transform->their_sink)
gst_object_unref(transform->their_sink);
if (transform->their_src)
gst_object_unref(transform->their_src);
if (transform->my_sink) if (transform->my_sink)
gst_object_unref(transform->my_sink); gst_object_unref(transform->my_sink);
if (transform->output_caps) if (transform->output_caps)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment