[farsight2/master] Implement the stop method in the rawudp transmitter
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:23:48 PST 2008
---
transmitters/rawudp/fs-rawudp-component.c | 30 ++++++++++++++------
transmitters/rawudp/fs-rawudp-component.h | 3 ++
transmitters/rawudp/fs-rawudp-stream-transmitter.c | 24 ++++++++++++++++
3 files changed, 48 insertions(+), 9 deletions(-)
diff --git a/transmitters/rawudp/fs-rawudp-component.c b/transmitters/rawudp/fs-rawudp-component.c
index aa81a8b..b3e5cb7 100644
--- a/transmitters/rawudp/fs-rawudp-component.c
+++ b/transmitters/rawudp/fs-rawudp-component.c
@@ -465,11 +465,31 @@ fs_rawudp_component_dispose (GObject *object)
/* If dispose did already run, return. */
return;
- FS_RAWUDP_COMPONENT_LOCK (self);
+ if (self->priv->udpport)
+ {
+ GST_ERROR ("You must call fs_stream_transmitter_stop() before dropping"
+ " the last reference to a stream transmitter");
+ fs_rawudp_component_stop (self);
+ }
/* Make sure dispose does not run twice. */
self->priv->disposed = TRUE;
+ FS_RAWUDP_COMPONENT_LOCK (self);
+ ts = self->priv->transmitter;
+ self->priv->transmitter = NULL;
+ FS_RAWUDP_COMPONENT_UNLOCK (self);
+
+ g_object_unref (ts);
+
+ parent_class->dispose (object);
+}
+
+void
+fs_rawudp_component_stop (FsRawUdpComponent *self)
+{
+
+ FS_RAWUDP_COMPONENT_LOCK (self);
if (self->priv->stun_timeout_thread != NULL)
{
FS_RAWUDP_COMPONENT_UNLOCK (self);
@@ -478,7 +498,6 @@ fs_rawudp_component_dispose (GObject *object)
self->priv->stun_timeout_thread = NULL;
}
-
FS_RAWUDP_COMPONENT_UNLOCK (self);
@@ -503,16 +522,9 @@ fs_rawudp_component_dispose (GObject *object)
FS_RAWUDP_COMPONENT_LOCK (self);
self->priv->udpport = NULL;
- ts = self->priv->transmitter;
- self->priv->transmitter = NULL;
FS_RAWUDP_COMPONENT_UNLOCK (self);
-
- g_object_unref (ts);
-
- parent_class->dispose (object);
}
-
static void
fs_rawudp_component_finalize (GObject *object)
{
diff --git a/transmitters/rawudp/fs-rawudp-component.h b/transmitters/rawudp/fs-rawudp-component.h
index 0cecda6..ad3c91e 100644
--- a/transmitters/rawudp/fs-rawudp-component.h
+++ b/transmitters/rawudp/fs-rawudp-component.h
@@ -113,6 +113,9 @@ fs_rawudp_component_gather_local_candidates (FsRawUdpComponent *self,
gboolean
fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error);
+void
+fs_rawudp_component_stop (FsRawUdpComponent *self);
+
G_END_DECLS
#endif /* __FS_RAWUDP_COMPONENT_H__ */
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.c b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
index 90cd607..fc1b762 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
@@ -147,6 +147,9 @@ static void fs_rawudp_stream_transmitter_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
+static void
+fs_rawudp_stream_transmitter_stop (FsStreamTransmitter *streamtransmitter);
+
static gboolean fs_rawudp_stream_transmitter_set_remote_candidates (
FsStreamTransmitter *streamtransmitter,
GList *candidates,
@@ -227,6 +230,7 @@ fs_rawudp_stream_transmitter_class_init (FsRawUdpStreamTransmitterClass *klass)
fs_rawudp_stream_transmitter_set_remote_candidates;
streamtransmitterclass->gather_local_candidates =
fs_rawudp_stream_transmitter_gather_local_candidates;
+ streamtransmitterclass->stop = fs_rawudp_stream_transmitter_stop;
g_object_class_override_property (gobject_class, PROP_SENDING, "sending");
g_object_class_override_property (gobject_class,
@@ -541,6 +545,25 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
return FALSE;
}
+
+static void
+fs_rawudp_stream_transmitter_stop (FsStreamTransmitter *streamtransmitter)
+{
+ FsRawUdpStreamTransmitter *self =
+ FS_RAWUDP_STREAM_TRANSMITTER (streamtransmitter);
+ gint c;
+
+ if (self->priv->component)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->component[c])
+ fs_rawudp_component_stop (self->priv->component[c]);
+ }
+ }
+}
+
+
/**
* fs_rawudp_stream_transmitter_set_remote_candidates
*/
@@ -737,3 +760,4 @@ _component_known_source_packet_received (FsRawUdpComponent *component,
g_signal_emit_by_name (self, "known-source-packet-received", component_id,
buffer);
}
+
--
1.5.6.5
More information about the farsight-commits
mailing list