Commit 49b0e6c2 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Use append_element to build wg_parser pipeline.

parent 5ed0abf3
...@@ -34,6 +34,7 @@ extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN; ...@@ -34,6 +34,7 @@ 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;
/* wg_format.c */ /* wg_format.c */
......
...@@ -101,6 +101,30 @@ done: ...@@ -101,6 +101,30 @@ done:
return element; return element;
} }
bool append_element(GstElement *container, GstElement *element, GstElement **first, GstElement **last)
{
gchar *name = gst_element_get_name(element);
bool success = false;
if (!gst_bin_add(GST_BIN(container), element) ||
!gst_element_sync_state_with_parent(element) ||
(*last && !gst_element_link(*last, element)))
{
GST_ERROR("Failed to link %s element.", name);
}
else
{
GST_DEBUG("Linked %s element %p.", name, element);
if (!*first)
*first = element;
*last = element;
success = true;
}
g_free(name);
return success;
}
NTSTATUS wg_init_gstreamer(void *arg) NTSTATUS wg_init_gstreamer(void *arg)
{ {
char arg0[] = "wine"; char arg0[] = "wine";
......
...@@ -787,6 +787,7 @@ static void free_stream(struct wg_parser_stream *stream) ...@@ -787,6 +787,7 @@ static void free_stream(struct wg_parser_stream *stream)
static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
{ {
GstElement *first = NULL, *last = NULL;
struct wg_parser *parser = user; struct wg_parser *parser = user;
struct wg_parser_stream *stream; struct wg_parser_stream *stream;
const char *name; const char *name;
...@@ -806,62 +807,46 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user) ...@@ -806,62 +807,46 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
if (!strcmp(name, "video/x-raw")) if (!strcmp(name, "video/x-raw"))
{ {
GstElement *deinterlace, *vconv, *flip, *vconv2;
/* DirectShow can express interlaced video, but downstream filters can't /* DirectShow can express interlaced video, but downstream filters can't
* necessarily consume it. In particular, the video renderer can't. */ * necessarily consume it. In particular, the video renderer can't. */
if (!(deinterlace = create_element("deinterlace", "good"))) if (!(element = create_element("deinterlace", "good"))
|| !append_element(parser->container, element, &first, &last))
goto out; goto out;
/* decodebin considers many YUV formats to be "raw", but some quartz /* decodebin considers many YUV formats to be "raw", but some quartz
* filters can't handle those. Also, videoflip can't handle all "raw" * filters can't handle those. Also, videoflip can't handle all "raw"
* formats either. Add a videoconvert to swap color spaces. */ * formats either. Add a videoconvert to swap color spaces. */
if (!(vconv = create_element("videoconvert", "base"))) if (!(element = create_element("videoconvert", "base"))
|| !append_element(parser->container, element, &first, &last))
goto out; goto out;
/* GStreamer outputs RGB video top-down, but DirectShow expects bottom-up. */ /* GStreamer outputs RGB video top-down, but DirectShow expects bottom-up. */
if (!(flip = create_element("videoflip", "good"))) if (!(element = create_element("videoflip", "good"))
|| !append_element(parser->container, element, &first, &last))
goto out; goto out;
stream->flip = element;
/* videoflip does not support 15 and 16-bit RGB so add a second videoconvert /* videoflip does not support 15 and 16-bit RGB so add a second videoconvert
* to do the final conversion. */ * to do the final conversion. */
if (!(vconv2 = create_element("videoconvert", "base"))) if (!(element = create_element("videoconvert", "base"))
|| !append_element(parser->container, element, &first, &last))
goto out; goto out;
/* The bin takes ownership of these elements. */ stream->post_sink = gst_element_get_static_pad(first, "sink");
gst_bin_add(GST_BIN(parser->container), deinterlace); stream->post_src = gst_element_get_static_pad(last, "src");
gst_element_sync_state_with_parent(deinterlace);
gst_bin_add(GST_BIN(parser->container), vconv);
gst_element_sync_state_with_parent(vconv);
gst_bin_add(GST_BIN(parser->container), flip);
gst_element_sync_state_with_parent(flip);
gst_bin_add(GST_BIN(parser->container), vconv2);
gst_element_sync_state_with_parent(vconv2);
gst_element_link(deinterlace, vconv);
gst_element_link(vconv, flip);
gst_element_link(flip, vconv2);
stream->post_sink = gst_element_get_static_pad(deinterlace, "sink");
stream->post_src = gst_element_get_static_pad(vconv2, "src");
stream->flip = flip;
} }
else if (!strcmp(name, "audio/x-raw")) else if (!strcmp(name, "audio/x-raw"))
{ {
GstElement *convert;
/* Currently our dsound can't handle 64-bit formats or all /* Currently our dsound can't handle 64-bit formats or all
* surround-sound configurations. Native dsound can't always handle * surround-sound configurations. Native dsound can't always handle
* 64-bit formats either. Add an audioconvert to allow changing bit * 64-bit formats either. Add an audioconvert to allow changing bit
* depth and channel count. */ * depth and channel count. */
if (!(convert = create_element("audioconvert", "base"))) if (!(element = create_element("audioconvert", "base"))
|| !append_element(parser->container, element, &first, &last))
goto out; goto out;
gst_bin_add(GST_BIN(parser->container), convert); stream->post_sink = gst_element_get_static_pad(first, "sink");
gst_element_sync_state_with_parent(convert); stream->post_src = gst_element_get_static_pad(last, "src");
stream->post_sink = gst_element_get_static_pad(convert, "sink");
stream->post_src = gst_element_get_static_pad(convert, "src");
} }
if (stream->post_sink) if (stream->post_sink)
......
...@@ -267,30 +267,6 @@ NTSTATUS wg_transform_destroy(void *args) ...@@ -267,30 +267,6 @@ NTSTATUS wg_transform_destroy(void *args)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
static bool append_element(GstElement *container, GstElement *element, GstElement **first, GstElement **last)
{
gchar *name = gst_element_get_name(element);
bool success = false;
if (!gst_bin_add(GST_BIN(container), element) ||
!gst_element_sync_state_with_parent(element) ||
(*last && !gst_element_link(*last, element)))
{
GST_ERROR("Failed to link %s element.", name);
}
else
{
GST_DEBUG("Linked %s element %p.", name, element);
if (!*first)
*first = element;
*last = element;
success = true;
}
g_free(name);
return success;
}
static struct wg_sample *transform_request_sample(gsize size, void *context) static struct wg_sample *transform_request_sample(gsize size, void *context)
{ {
struct wg_transform *transform = context; struct wg_transform *transform = context;
......
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