[farsight2/master] Extend the rawudp sink/src creation function to support filters
Olivier Crête
olivier.crete at collabora.co.uk
Thu Feb 5 06:32:05 PST 2009
---
transmitters/rawudp/fs-rawudp-transmitter.c | 76 +++++++++++++++++++++++----
1 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index 051c58a..8ce24f9 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -601,13 +601,14 @@ _create_sinksource (
gchar *elementname,
GstBin *bin,
GstElement *teefunnel,
+ GstElement *filter,
gint fd,
GstPadDirection direction,
GstPad **requested_pad,
GError **error)
{
GstElement *elem;
- GstPadLinkReturn ret;
+ GstPadLinkReturn ret = GST_PAD_LINK_OK;
GstPad *elempad = NULL;
GstStateChangeReturn state_ret;
@@ -659,12 +660,55 @@ _create_sinksource (
else
elempad = gst_element_get_static_pad (elem, "src");
- if (direction == GST_PAD_SINK)
- ret = gst_pad_link (*requested_pad, elempad);
- else
- ret = gst_pad_link (elempad, *requested_pad);
+ if (filter)
+ {
+ GstPad *filterpad = NULL;
+
+ if (!gst_bin_add (bin, filter))
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "Could not add the filter element to the gst %s bin",
+ (direction == GST_PAD_SINK) ? "sink" : "src");
+ goto error;
+ }
+
+ if (direction == GST_PAD_SINK)
+ filterpad = gst_element_get_static_pad (filter, "src");
+ else
+ filterpad = gst_element_get_static_pad (filter, "sink");
+
+ if (direction == GST_PAD_SINK)
+ ret = gst_pad_link (filterpad, elempad);
+ else
+ ret = gst_pad_link (elempad, filterpad);
+
+ gst_object_unref (elempad);
+ gst_object_unref (filterpad);
+ elempad = NULL;
+
+ if (GST_PAD_LINK_FAILED(ret))
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "Could not link the new element %s (%d)", elementname, ret);
+ goto error;
+ }
+
+ if (direction == GST_PAD_SINK)
+ elempad = gst_element_get_static_pad (filter, "sink");
+ else
+ elempad = gst_element_get_static_pad (filter, "src");
- gst_object_unref (elempad);
+
+ if (!gst_element_sync_state_with_parent (filter))
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "Could not sync the state of the new filte rwith its parent");
+ goto error;
+ }
+ }
+
+ if (direction != GST_PAD_SINK)
+ ret = gst_pad_link (elempad, *requested_pad);
if (GST_PAD_LINK_FAILED(ret))
{
@@ -681,6 +725,18 @@ _create_sinksource (
goto error;
}
+ if (direction == GST_PAD_SINK)
+ ret = gst_pad_link (*requested_pad, elempad);
+
+ if (GST_PAD_LINK_FAILED(ret))
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
+ "Could not link the new element %s (%d)", elementname, ret);
+ goto error;
+ }
+
+ gst_object_unref (elempad);
+
return elem;
error:
@@ -782,14 +838,14 @@ fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
udpport->funnel = trans->priv->udpsrc_funnels[component_id];
udpport->udpsrc = _create_sinksource ("udpsrc",
- GST_BIN (trans->priv->gst_src), udpport->funnel, udpport->fd, GST_PAD_SRC,
- &udpport->udpsrc_requested_pad, error);
+ GST_BIN (trans->priv->gst_src), udpport->funnel, NULL,
+ udpport->fd, GST_PAD_SRC, &udpport->udpsrc_requested_pad, error);
if (!udpport->udpsrc)
goto error;
udpport->udpsink = _create_sinksource ("multiudpsink",
- GST_BIN (trans->priv->gst_sink), udpport->tee, udpport->fd, GST_PAD_SINK,
- &udpport->udpsink_requested_pad, error);
+ GST_BIN (trans->priv->gst_sink), udpport->tee, NULL,
+ udpport->fd, GST_PAD_SINK, &udpport->udpsink_requested_pad, error);
if (!udpport->udpsink)
goto error;
--
1.5.6.5
More information about the farsight-commits
mailing list