[farsight2/master] Implement the components property on the rawudp transmitter and make pads src%d and sink%d
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:19:40 PST 2008
---
tests/check/transmitter/generic.c | 13 ++++---
transmitters/rawudp/fs-rawudp-transmitter.c | 48 +++++++++++++++++++-------
2 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/tests/check/transmitter/generic.c b/tests/check/transmitter/generic.c
index 4bbaace..8124c3d 100644
--- a/tests/check/transmitter/generic.c
+++ b/tests/check/transmitter/generic.c
@@ -51,6 +51,7 @@ setup_fakesrc (FsTransmitter *trans, GstElement *pipeline, guint component_id)
{
GstElement *src;
GstElement *trans_sink;
+ gchar *padname;
src = gst_element_factory_make ("fakesrc", NULL);
g_object_set (src, "num-buffers", 20, "sizetype", 2, "sizemax",
@@ -61,10 +62,10 @@ setup_fakesrc (FsTransmitter *trans, GstElement *pipeline, guint component_id)
g_object_get (trans, "gst-sink", &trans_sink, NULL);
- fail_unless (gst_element_link_pads (src, "src", trans_sink,
- (component_id == 1) ? "sink": "rtcpsink"),
- "Could not link the fakesrc to %s",
- (component_id == 1) ? "sink": "rtcpsink");
+ padname = g_strdup_printf ("sink%d", component_id);
+ fail_unless (gst_element_link_pads (src, "src", trans_sink, padname),
+ "Could not link the fakesrc to %s", padname);
+ g_free (padname);
fail_if (gst_element_set_state (src, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE, "Could not set the fakesrc to playing");
@@ -104,10 +105,10 @@ setup_pipeline (FsTransmitter *trans, GCallback cb)
gst_bin_add_many (GST_BIN (pipeline), rtpfakesink, rtcpfakesink,
trans_sink, trans_src, NULL);
- fail_unless (gst_element_link_pads (trans_src, "src",
+ fail_unless (gst_element_link_pads (trans_src, "src1",
rtpfakesink, "sink"),
"Coult not link transmitter src and fakesink");
- fail_unless (gst_element_link_pads (trans_src, "rtcpsrc",
+ fail_unless (gst_element_link_pads (trans_src, "src2",
rtcpfakesink, "sink"),
"Coult not link transmitter src and fakesink");
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index 701e56a..d210568 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -60,7 +60,8 @@ enum
{
PROP_0,
PROP_GST_SINK,
- PROP_GST_SRC
+ PROP_GST_SRC,
+ PROP_COMPONENTS
};
struct _FsRawUdpTransmitterPrivate
@@ -86,6 +87,7 @@ struct _FsRawUdpTransmitterPrivate
static void fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass);
static void fs_rawudp_transmitter_init (FsRawUdpTransmitter *self);
+static void fs_rawudp_transmitter_constructed (GObject *object);
static void fs_rawudp_transmitter_dispose (GObject *object);
static void fs_rawudp_transmitter_finalize (GObject *object);
@@ -157,8 +159,12 @@ fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass)
gobject_class->set_property = fs_rawudp_transmitter_set_property;
gobject_class->get_property = fs_rawudp_transmitter_get_property;
+ gobject_class->constructed = fs_rawudp_transmitter_constructed;
+
g_object_class_override_property (gobject_class, PROP_GST_SRC, "gst-src");
g_object_class_override_property (gobject_class, PROP_GST_SINK, "gst-sink");
+ g_object_class_override_property (gobject_class, PROP_COMPONENTS,
+ "components");
transmitter_class->new_stream_transmitter =
fs_rawudp_transmitter_new_stream_transmitter;
@@ -172,16 +178,24 @@ fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass)
static void
fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
{
- FsTransmitter *trans = FS_TRANSMITTER_CAST (self);
- GstPad *pad = NULL;
- GstPad *ghostpad = NULL;
- int c; /* component_id */
/* member init */
self->priv = FS_RAWUDP_TRANSMITTER_GET_PRIVATE (self);
self->priv->disposed = FALSE;
self->components = 2;
+}
+
+static void
+fs_rawudp_transmitter_constructed (GObject *object)
+{
+ FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER_CAST (object);
+ FsTransmitter *trans = FS_TRANSMITTER_CAST (self);
+ GstPad *pad = NULL;
+ GstPad *ghostpad = NULL;
+ gchar *padname;
+ int c; /* component_id */
+
/* We waste one space in order to have the index be the component_id */
self->priv->udpsrc_funnels = g_new0 (GstElement *, self->components+1);
@@ -236,10 +250,9 @@ fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
}
pad = gst_element_get_static_pad (self->priv->udpsrc_funnels[c], "src");
- if (c == FS_COMPONENT_RTP)
- ghostpad = gst_ghost_pad_new ("src", pad);
- else if (c == FS_COMPONENT_RTCP)
- ghostpad = gst_ghost_pad_new ("rtcpsrc", pad);
+ padname = g_strdup_printf ("src%d", c);
+ ghostpad = gst_ghost_pad_new (padname, pad);
+ g_free (padname);
gst_object_unref (pad);
gst_pad_set_active (ghostpad, TRUE);
@@ -265,10 +278,9 @@ fs_rawudp_transmitter_init (FsRawUdpTransmitter *self)
}
pad = gst_element_get_static_pad (self->priv->udpsink_tees[c], "sink");
- if (c == FS_COMPONENT_RTP)
- ghostpad = gst_ghost_pad_new ("sink", pad);
- else if (c == FS_COMPONENT_RTCP)
- ghostpad = gst_ghost_pad_new ("rtcpsink", pad);
+ padname = g_strdup_printf ("sink%d", c);
+ ghostpad = gst_ghost_pad_new (padname, pad);
+ g_free (padname);
gst_object_unref (pad);
gst_pad_set_active (ghostpad, TRUE);
@@ -353,6 +365,16 @@ fs_rawudp_transmitter_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
+ FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (object);
+
+ switch (prop_id) {
+ case PROP_COMPONENTS:
+ self->components = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
--
1.5.6.5
More information about the farsight-commits
mailing list