[farsight2/master] Factor out the stun sending part
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:26:40 PST 2008
---
transmitters/rawudp/fs-rawudp-component.c | 52 +++++++++++++++++++----------
1 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/transmitters/rawudp/fs-rawudp-component.c b/transmitters/rawudp/fs-rawudp-component.c
index ae3dcc4..68d489d 100644
--- a/transmitters/rawudp/fs-rawudp-component.c
+++ b/transmitters/rawudp/fs-rawudp-component.c
@@ -1134,7 +1134,7 @@ fs_rawudp_component_gather_local_candidates (FsRawUdpComponent *self,
}
static gboolean
-fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error)
+fs_rawudp_component_send_stun (FsRawUdpComponent *self, GError **error)
{
struct addrinfo hints;
struct addrinfo *result = NULL;
@@ -1143,16 +1143,6 @@ fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error)
guint length;
int retval;
StunMessage *msg;
- gboolean res = TRUE;
- GstClock *sysclock = NULL;
-
- sysclock = gst_system_clock_obtain ();
- if (sysclock == NULL)
- {
- g_set_error (error, FS_ERROR, FS_ERROR_INTERNAL,
- "Could not obtain gst system clock");
- return FALSE;
- }
memset (&hints, 0, sizeof (struct addrinfo));
hints.ai_family = AF_INET;
@@ -1171,13 +1161,6 @@ fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error)
address.sin_family = AF_INET;
address.sin_port = htons (self->priv->stun_port);
- FS_RAWUDP_COMPONENT_LOCK (self);
- self->priv->stun_recv_id =
- fs_rawudp_transmitter_udpport_connect_recv (
- self->priv->udpport,
- G_CALLBACK (stun_recv_cb), self);
- FS_RAWUDP_COMPONENT_UNLOCK (self);
-
msg = stun_message_new (STUN_MESSAGE_BINDING_REQUEST,
self->priv->stun_cookie, 0);
if (!msg)
@@ -1200,6 +1183,39 @@ fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error)
g_free (packed);
stun_message_free (msg);
+ return TRUE;
+}
+
+static gboolean
+fs_rawudp_component_start_stun (FsRawUdpComponent *self, GError **error)
+{
+ gboolean res = TRUE;
+ GstClock *sysclock = NULL;
+
+ sysclock = gst_system_clock_obtain ();
+ if (sysclock == NULL)
+ {
+ g_set_error (error, FS_ERROR, FS_ERROR_INTERNAL,
+ "Could not obtain gst system clock");
+ return FALSE;
+ }
+
+ FS_RAWUDP_COMPONENT_LOCK (self);
+ self->priv->stun_recv_id =
+ fs_rawudp_transmitter_udpport_connect_recv (
+ self->priv->udpport,
+ G_CALLBACK (stun_recv_cb), self);
+ FS_RAWUDP_COMPONENT_UNLOCK (self);
+
+ if (!fs_rawudp_component_send_stun (self, error))
+ {
+ FS_RAWUDP_COMPONENT_LOCK (self);
+ fs_rawudp_component_stop_stun_locked (self);
+ FS_RAWUDP_COMPONENT_UNLOCK (self);
+
+ return FALSE;
+ }
+
FS_RAWUDP_COMPONENT_LOCK (self);
self->priv->next_stun_timeout = gst_clock_get_time (sysclock) +
--
1.5.6.5
More information about the farsight-commits
mailing list