[farsight2/master] Add method to set the nice sink sending or not
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:26:51 PST 2008
---
transmitters/nice/fs-nice-transmitter.c | 64 +++++++++++++++++++++++++++----
transmitters/nice/fs-nice-transmitter.h | 3 +-
2 files changed, 58 insertions(+), 9 deletions(-)
diff --git a/transmitters/nice/fs-nice-transmitter.c b/transmitters/nice/fs-nice-transmitter.c
index 28e0f14..b2c4780 100644
--- a/transmitters/nice/fs-nice-transmitter.c
+++ b/transmitters/nice/fs-nice-transmitter.c
@@ -614,6 +614,8 @@ struct _NiceGstStream {
GstPad **requested_tee_pads;
gulong *probe_ids;
+
+ gboolean sending;
};
NiceGstStream *
@@ -668,6 +670,8 @@ fs_nice_transmitter_add_gst_stream (FsNiceTransmitter *self,
goto error;
}
+ ns->sending = TRUE;
+
return ns;
error:
@@ -681,6 +685,8 @@ fs_nice_transmitter_free_gst_stream (FsNiceTransmitter *self,
{
guint c;
+ fs_nice_transmitter_set_sending (self, ns, FALSE);
+
for (c = 1; c <= self->components; c++)
{
if (ns->nicesrcs[c])
@@ -705,14 +711,6 @@ fs_nice_transmitter_free_gst_stream (FsNiceTransmitter *self,
if (ns->nicesinks[c])
{
- GstStateChangeReturn ret;
- gst_element_set_locked_state (ns->nicesinks[c], TRUE);
- ret = gst_element_set_state (ns->nicesinks[c], GST_STATE_NULL);
- if (ret != GST_STATE_CHANGE_SUCCESS)
- GST_ERROR ("Error changing state of nicesink: %s",
- gst_element_state_change_return_get_name (ret));
- if (!gst_bin_remove (GST_BIN (self->priv->gst_sink), ns->nicesinks[c]))
- GST_ERROR ("Could not remove nicesink element from transmitter source");
gst_object_unref (ns->nicesinks[c]);
}
@@ -731,3 +729,53 @@ fs_nice_transmitter_free_gst_stream (FsNiceTransmitter *self,
g_free (ns->probe_ids);
g_slice_free (NiceGstStream, ns);
}
+
+void
+fs_nice_transmitter_set_sending (FsNiceTransmitter *self,
+ NiceGstStream *ns, gboolean sending)
+{
+ guint c;
+
+ if (ns->sending == sending)
+ return;
+
+ if (ns->sending)
+ {
+ for (c = 1; c <= self->components; c++)
+ {
+ GstStateChangeReturn ret;
+ gst_element_set_locked_state (ns->nicesinks[c], TRUE);
+ ret = gst_element_set_state (ns->nicesinks[c], GST_STATE_NULL);
+ if (ret != GST_STATE_CHANGE_SUCCESS)
+ GST_ERROR ("Error changing state of nicesink: %s",
+ gst_element_state_change_return_get_name (ret));
+ if (!gst_bin_remove (GST_BIN (self->priv->gst_sink), ns->nicesinks[c]))
+ GST_ERROR ("Could not remove nicesink element from transmitter"
+ " sink");
+ gst_element_set_locked_state (ns->nicesinks[c], FALSE);
+ }
+ }
+ else
+ {
+ for (c = 1; c <= self->components; c++)
+ {
+ GstStateChangeReturn ret;
+ GstPad *elempad;
+
+ if (!gst_bin_add (GST_BIN (self->priv->gst_sink), ns->nicesinks[c]))
+ GST_ERROR ("Could not add nicesink element to the transmitter"
+ " sink");
+
+ if (!gst_element_sync_state_with_parent (ns->nicesinks[c]))
+ GST_ERROR ("Could sync the state of the nicesink with its parent");
+
+ elempad = gst_element_get_static_pad (ns->nicesinks[c], "sink");
+ ret = gst_pad_link (ns->requested_tee_pads[c], elempad);
+ if (GST_PAD_LINK_FAILED(ret))
+ GST_ERROR ("Could not link nicesink to its tee pad");
+ gst_object_unref (elempad);
+ }
+ }
+
+ ns->sending = sending;
+}
diff --git a/transmitters/nice/fs-nice-transmitter.h b/transmitters/nice/fs-nice-transmitter.h
index 424ac30..4a46391 100644
--- a/transmitters/nice/fs-nice-transmitter.h
+++ b/transmitters/nice/fs-nice-transmitter.h
@@ -99,7 +99,8 @@ NiceGstStream *fs_nice_transmitter_add_gst_stream (FsNiceTransmitter *self,
void fs_nice_transmitter_free_gst_stream (FsNiceTransmitter *self,
NiceGstStream *ns);
-
+void fs_nice_transmitter_set_sending (FsNiceTransmitter *self,
+ NiceGstStream *ns, gboolean sending);
G_END_DECLS
--
1.5.6.5
More information about the farsight-commits
mailing list