[farsight2/master] Re-indent rawudp transmitter according to standardised fs2 indentation rules
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:21:15 PST 2008
---
transmitters/rawudp/fs-rawudp-stream-transmitter.c | 432 +++++++++++--------
transmitters/rawudp/fs-rawudp-stream-transmitter.h | 27 +-
transmitters/rawudp/fs-rawudp-transmitter.c | 277 ++++++++-----
transmitters/rawudp/fs-rawudp-transmitter.h | 29 +-
4 files changed, 451 insertions(+), 314 deletions(-)
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.c b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
index f6dcd36..79b5c74 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.c
@@ -151,43 +151,51 @@ struct _FsRawUdpStreamTransmitterPrivate
GList *sources;
};
-#define FS_RAWUDP_STREAM_TRANSMITTER_GET_PRIVATE(o) \
+#define FS_RAWUDP_STREAM_TRANSMITTER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_RAWUDP_STREAM_TRANSMITTER, \
- FsRawUdpStreamTransmitterPrivate))
+ FsRawUdpStreamTransmitterPrivate))
-static void fs_rawudp_stream_transmitter_class_init (FsRawUdpStreamTransmitterClass *klass);
+static void fs_rawudp_stream_transmitter_class_init (
+ FsRawUdpStreamTransmitterClass *klass);
static void fs_rawudp_stream_transmitter_init (FsRawUdpStreamTransmitter *self);
static void fs_rawudp_stream_transmitter_dispose (GObject *object);
static void fs_rawudp_stream_transmitter_finalize (GObject *object);
static void fs_rawudp_stream_transmitter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void fs_rawudp_stream_transmitter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
static gboolean fs_rawudp_stream_transmitter_add_remote_candidate (
- FsStreamTransmitter *streamtransmitter, FsCandidate *candidate,
+ FsStreamTransmitter *streamtransmitter,
+ FsCandidate *candidate,
GError **error);
static gboolean fs_rawudp_stream_transmitter_start_stun (
- FsRawUdpStreamTransmitter *self, guint component_id, GError **error);
+ FsRawUdpStreamTransmitter *self,
+ guint component_id,
+ GError **error);
static void fs_rawudp_stream_transmitter_stop_stun (
- FsRawUdpStreamTransmitter *self, guint component_id);
+ FsRawUdpStreamTransmitter *self,
+ guint component_id);
-static FsCandidate * fs_rawudp_stream_transmitter_build_forced_candidate (
- FsRawUdpStreamTransmitter *self, const char *ip, gint port,
+static FsCandidate* fs_rawudp_stream_transmitter_build_forced_candidate (
+ FsRawUdpStreamTransmitter *self,
+ const char *ip,
+ gint port,
guint component_id);
static gboolean fs_rawudp_stream_transmitter_no_stun (
gpointer user_data);
static void fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (
- FsRawUdpStreamTransmitter *self, guint component_id);
-static gboolean
-fs_rawudp_stream_transmitter_emit_local_candidates (
- FsRawUdpStreamTransmitter *self, guint component_id);
+ FsRawUdpStreamTransmitter *self,
+ guint component_id);
+static gboolean fs_rawudp_stream_transmitter_emit_local_candidates (
+ FsRawUdpStreamTransmitter *self,
+ guint component_id);
static GObjectClass *parent_class = NULL;
@@ -217,7 +225,7 @@ fs_rawudp_stream_transmitter_register_type (FsPlugin *module)
};
type = g_type_module_register_type (G_TYPE_MODULE (module),
- FS_TYPE_STREAM_TRANSMITTER, "FsRawUdpStreamTransmitter", &info, 0);
+ FS_TYPE_STREAM_TRANSMITTER, "FsRawUdpStreamTransmitter", &info, 0);
return type;
}
@@ -239,31 +247,31 @@ fs_rawudp_stream_transmitter_class_init (FsRawUdpStreamTransmitterClass *klass)
g_object_class_override_property (gobject_class, PROP_SENDING, "sending");
g_object_class_override_property (gobject_class,
- PROP_PREFERRED_LOCAL_CANDIDATES, "preferred-local-candidates");
+ PROP_PREFERRED_LOCAL_CANDIDATES, "preferred-local-candidates");
g_object_class_install_property (gobject_class,
- PROP_STUN_IP,
- g_param_spec_string ("stun-ip",
- "The IP address of the STUN server",
- "The IPv4 address of the STUN server as a x.x.x.x string",
- NULL,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ PROP_STUN_IP,
+ g_param_spec_string ("stun-ip",
+ "The IP address of the STUN server",
+ "The IPv4 address of the STUN server as a x.x.x.x string",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- PROP_STUN_PORT,
- g_param_spec_uint ("stun-port",
- "The port of the STUN server",
- "The IPv4 UDP port of the STUN server as a ",
- 1, 65535, 3478,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ PROP_STUN_PORT,
+ g_param_spec_uint ("stun-port",
+ "The port of the STUN server",
+ "The IPv4 UDP port of the STUN server as a ",
+ 1, 65535, 3478,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- PROP_STUN_TIMEOUT,
- g_param_spec_uint ("stun-timeout",
- "The timeout for the STUN reply",
- "How long to wait for for the STUN reply (in seconds) before giving up",
- 1, G_MAXUINT, 30,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ PROP_STUN_TIMEOUT,
+ g_param_spec_uint ("stun-timeout",
+ "The timeout for the STUN reply",
+ "How long to wait for for the STUN reply (in seconds) before giving up",
+ 1, G_MAXUINT, 30,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
gobject_class->dispose = fs_rawudp_stream_transmitter_dispose;
gobject_class->finalize = fs_rawudp_stream_transmitter_finalize;
@@ -295,22 +303,23 @@ fs_rawudp_stream_transmitter_dispose (GObject *object)
FsRawUdpStreamTransmitter *self = FS_RAWUDP_STREAM_TRANSMITTER (object);
gint c;
- if (self->priv->disposed) {
+ if (self->priv->disposed)
/* If dispose did already run, return. */
return;
- }
g_mutex_lock (self->priv->sources_mutex);
- if (self->priv->stun_recv_id) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (self->priv->stun_recv_id[c]) {
+ if (self->priv->stun_recv_id)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->stun_recv_id[c])
fs_rawudp_stream_transmitter_stop_stun (self, c);
- }
}
}
- if (self->priv->sources) {
+ if (self->priv->sources)
+ {
g_list_foreach (self->priv->sources, (GFunc) g_source_remove, NULL);
g_list_free (self->priv->sources);
self->priv->sources = NULL;
@@ -330,24 +339,29 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
FsRawUdpStreamTransmitter *self = FS_RAWUDP_STREAM_TRANSMITTER (object);
gint c; /* component_id */
- if (self->priv->stun_ip) {
+ if (self->priv->stun_ip)
+ {
g_free (self->priv->stun_ip);
self->priv->stun_ip = NULL;
}
- if (self->priv->preferred_local_candidates) {
+ if (self->priv->preferred_local_candidates)
+ {
fs_candidate_list_destroy (self->priv->preferred_local_candidates);
self->priv->preferred_local_candidates = NULL;
}
- if (self->priv->remote_candidate) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (self->priv->remote_candidate[c]) {
+ if (self->priv->remote_candidate)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->remote_candidate[c])
+ {
if (self->priv->udpports && self->priv->udpports[c] &&
- self->priv->sending)
+ self->priv->sending)
fs_rawudp_transmitter_udpport_remove_dest (self->priv->udpports[c],
- self->priv->remote_candidate[c]->ip,
- self->priv->remote_candidate[c]->port);
+ self->priv->remote_candidate[c]->ip,
+ self->priv->remote_candidate[c]->port);
fs_candidate_destroy (self->priv->remote_candidate[c]);
}
}
@@ -356,11 +370,14 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
self->priv->remote_candidate = NULL;
}
- if (self->priv->udpports) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (self->priv->udpports[c]) {
+ if (self->priv->udpports)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->udpports[c])
+ {
fs_rawudp_transmitter_put_udpport (self->priv->transmitter,
- self->priv->udpports[c]);
+ self->priv->udpports[c]);
self->priv->udpports[c] = NULL;
}
}
@@ -369,8 +386,10 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
self->priv->udpports = NULL;
}
- if (self->priv->local_forced_candidate) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
+ if (self->priv->local_forced_candidate)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
if (self->priv->local_forced_candidate[c]) {
fs_candidate_destroy (self->priv->local_forced_candidate[c]);
self->priv->local_forced_candidate[c] = NULL;
@@ -380,9 +399,12 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
self->priv->local_forced_candidate = NULL;
}
- if (self->priv->local_stun_candidate) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (self->priv->local_stun_candidate[c]) {
+ if (self->priv->local_stun_candidate)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->local_stun_candidate[c])
+ {
fs_candidate_destroy (self->priv->local_stun_candidate[c]);
self->priv->local_stun_candidate[c] = NULL;
}
@@ -391,9 +413,12 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
self->priv->local_stun_candidate = NULL;
}
- if (self->priv->local_active_candidate) {
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (self->priv->local_active_candidate[c]) {
+ if (self->priv->local_active_candidate)
+ {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (self->priv->local_active_candidate[c])
+ {
fs_candidate_destroy (self->priv->local_active_candidate[c]);
self->priv->local_active_candidate[c] = NULL;
}
@@ -402,17 +427,20 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
self->priv->local_active_candidate = NULL;
}
- if (self->priv->sources_mutex) {
+ if (self->priv->sources_mutex)
+ {
g_mutex_free (self->priv->sources_mutex);
self->priv->sources_mutex = NULL;
}
- if (self->priv->stun_recv_id) {
+ if (self->priv->stun_recv_id)
+ {
g_free (self->priv->stun_recv_id);
self->priv->stun_recv_id = NULL;
}
- if (self->priv->stun_timeout_id) {
+ if (self->priv->stun_timeout_id)
+ {
g_free (self->priv->stun_timeout_id);
self->priv->stun_timeout_id = NULL;
}
@@ -422,13 +450,14 @@ fs_rawudp_stream_transmitter_finalize (GObject *object)
static void
fs_rawudp_stream_transmitter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
FsRawUdpStreamTransmitter *self = FS_RAWUDP_STREAM_TRANSMITTER (object);
- switch (prop_id) {
+ switch (prop_id)
+ {
case PROP_SENDING:
g_value_set_boolean (value, self->priv->sending);
break;
@@ -452,13 +481,14 @@ fs_rawudp_stream_transmitter_get_property (GObject *object,
static void
fs_rawudp_stream_transmitter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
FsRawUdpStreamTransmitter *self = FS_RAWUDP_STREAM_TRANSMITTER (object);
- switch (prop_id) {
+ switch (prop_id)
+ {
case PROP_SENDING:
{
gboolean old_sending = self->priv->sending;
@@ -466,8 +496,10 @@ fs_rawudp_stream_transmitter_set_property (GObject *object,
self->priv->sending = g_value_get_boolean (value);
- if (self->priv->sending != old_sending) {
- if (self->priv->sending) {
+ if (self->priv->sending != old_sending)
+ {
+ if (self->priv->sending)
+ {
for (c = 1; c <= self->priv->transmitter->components; c++)
if (self->priv->remote_candidate[c])
@@ -508,10 +540,10 @@ fs_rawudp_stream_transmitter_set_property (GObject *object,
static gboolean
fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
- GError **error)
+ GError **error)
{
const gchar **ips = g_new0 (const gchar *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
guint16 *ports = g_new0 (guint16, self->priv->transmitter->components + 1);
GList *item;
@@ -519,19 +551,19 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
guint16 next_port;
self->priv->udpports = g_new0 (UdpPort *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->remote_candidate = g_new0 (FsCandidate *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->local_forced_candidate = g_new0 (FsCandidate *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->local_stun_candidate = g_new0 (FsCandidate *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->local_active_candidate = g_new0 (FsCandidate *,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->stun_recv_id = g_new0 (gulong,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
self->priv->stun_timeout_id = g_new0 (guint,
- self->priv->transmitter->components + 1);
+ self->priv->transmitter->components + 1);
for (item = g_list_first (self->priv->preferred_local_candidates);
item;
@@ -540,31 +572,33 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
if (candidate->proto != FS_NETWORK_PROTOCOL_UDP) {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "You set preferred candidate of a type %d that is not"
- " FS_NETWORK_PROTOCOL_UDP",
- candidate->proto);
+ "You set preferred candidate of a type %d that is not"
+ " FS_NETWORK_PROTOCOL_UDP",
+ candidate->proto);
goto error;
}
if (candidate->component_id == 0) {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "Component id 0 is invalid");
+ "Component id 0 is invalid");
goto error;
}
- if (candidate->component_id > self->priv->transmitter->components) {
+ if (candidate->component_id > self->priv->transmitter->components)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "You specified an invalid component id %d with is higher"
- " than the maximum %d", candidate->component_id,
- self->priv->transmitter->components);
+ "You specified an invalid component id %d with is higher"
+ " than the maximum %d", candidate->component_id,
+ self->priv->transmitter->components);
goto error;
}
- if (ips[candidate->component_id] || ports[candidate->component_id]) {
+ if (ips[candidate->component_id] || ports[candidate->component_id])
+ {
g_set_error (error, FS_ERROR,
- FS_ERROR_INVALID_ARGUMENTS,
- "You set more than one preferred local candidate for component %u",
- candidate->component_id);
+ FS_ERROR_INVALID_ARGUMENTS,
+ "You set more than one preferred local candidate for component %u",
+ candidate->component_id);
goto error;
}
@@ -584,7 +618,8 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
next_port = ports[1];
- for (c = 1; c <= self->priv->transmitter->components; c++) {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
gint requested_port = ports[c];
gint used_port;
@@ -593,7 +628,7 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
self->priv->udpports[c] =
fs_rawudp_transmitter_get_udpport (self->priv->transmitter, c, ips[c],
- requested_port, error);
+ requested_port, error);
if (!self->priv->udpports[c])
goto error;
@@ -604,13 +639,15 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
* package of components, all non-forced ports must be consecutive!
*/
- if (used_port != requested_port && !ports[c]) {
+ if (used_port != requested_port && !ports[c])
+ {
do {
fs_rawudp_transmitter_put_udpport (self->priv->transmitter,
- self->priv->udpports[c]);
+ self->priv->udpports[c]);
self->priv->udpports[c] = NULL;
- if (self->priv->local_forced_candidate[c]) {
+ if (self->priv->local_forced_candidate[c])
+ {
fs_candidate_destroy (self->priv->local_forced_candidate[c]);
self->priv->local_forced_candidate[c] = NULL;
}
@@ -625,22 +662,25 @@ fs_rawudp_stream_transmitter_build (FsRawUdpStreamTransmitter *self,
if (ips[c])
self->priv->local_forced_candidate[c] =
fs_rawudp_stream_transmitter_build_forced_candidate (self, ips[c],
- used_port, c);
+ used_port, c);
next_port = used_port+1;
}
- if (self->priv->stun_ip && self->priv->stun_port) {
+ if (self->priv->stun_ip && self->priv->stun_port)
+ {
for (c = 1; c <= self->priv->transmitter->components; c++)
if (!fs_rawudp_stream_transmitter_start_stun (self, c, error))
goto error;
- } else {
+ }
+ else
+ {
guint id;
id = g_idle_add (fs_rawudp_stream_transmitter_no_stun, self);
g_assert (id);
g_mutex_lock (self->priv->sources_mutex);
self->priv->sources = g_list_prepend (self->priv->sources,
- GUINT_TO_POINTER(id));
+ GUINT_TO_POINTER(id));
g_mutex_unlock (self->priv->sources_mutex);
}
@@ -676,24 +716,27 @@ fs_rawudp_stream_transmitter_add_remote_candidate (
FsRawUdpStreamTransmitter *self =
FS_RAWUDP_STREAM_TRANSMITTER (streamtransmitter);
- if (candidate->proto != FS_NETWORK_PROTOCOL_UDP) {
+ if (candidate->proto != FS_NETWORK_PROTOCOL_UDP)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "You set a candidate of a type %d that is not FS_NETWORK_PROTOCOL_UDP",
- candidate->proto);
+ "You set a candidate of a type %d that is not FS_NETWORK_PROTOCOL_UDP",
+ candidate->proto);
return FALSE;
}
- if (!candidate->ip || !candidate->port) {
+ if (!candidate->ip || !candidate->port)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "The candidate passed does not contain a valid ip or port");
+ "The candidate passed does not contain a valid ip or port");
return FALSE;
}
if (candidate->component_id == 0 ||
- candidate->component_id > self->priv->transmitter->components) {
+ candidate->component_id > self->priv->transmitter->components)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "The candidate passed has has an invalid component id %u (not in [0,%u])",
- candidate->component_id, self->priv->transmitter->components);
+ "The candidate passed has has an invalid component id %u (not in [0,%u])",
+ candidate->component_id, self->priv->transmitter->components);
return FALSE;
}
@@ -701,12 +744,14 @@ fs_rawudp_stream_transmitter_add_remote_candidate (
* IMPROVE ME: We should probably check that the candidate's IP
* has the format x.x.x.x where x is [0,255] using GRegex, etc
*/
- if (self->priv->sending) {
+ if (self->priv->sending)
+ {
fs_rawudp_transmitter_udpport_add_dest (
self->priv->udpports[candidate->component_id],
candidate->ip, candidate->port);
}
- if (self->priv->remote_candidate[candidate->component_id]) {
+ if (self->priv->remote_candidate[candidate->component_id])
+ {
fs_rawudp_transmitter_udpport_remove_dest (
self->priv->udpports[candidate->component_id],
self->priv->remote_candidate[candidate->component_id]->ip,
@@ -718,7 +763,7 @@ fs_rawudp_stream_transmitter_add_remote_candidate (
fs_candidate_copy (candidate);
fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (self,
- candidate->component_id);
+ candidate->component_id);
return TRUE;
}
@@ -726,22 +771,24 @@ fs_rawudp_stream_transmitter_add_remote_candidate (
FsRawUdpStreamTransmitter *
fs_rawudp_stream_transmitter_newv (FsRawUdpTransmitter *transmitter,
- guint n_parameters, GParameter *parameters, GError **error)
+ guint n_parameters, GParameter *parameters, GError **error)
{
FsRawUdpStreamTransmitter *streamtransmitter = NULL;
streamtransmitter = g_object_newv (FS_TYPE_RAWUDP_STREAM_TRANSMITTER,
- n_parameters, parameters);
+ n_parameters, parameters);
- if (!streamtransmitter) {
+ if (!streamtransmitter)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not build the stream transmitter");
+ "Could not build the stream transmitter");
return NULL;
}
streamtransmitter->priv->transmitter = transmitter;
- if (!fs_rawudp_stream_transmitter_build (streamtransmitter, error)) {
+ if (!fs_rawudp_stream_transmitter_build (streamtransmitter, error))
+ {
g_object_unref (streamtransmitter);
return NULL;
}
@@ -770,8 +817,10 @@ fs_rawudp_stream_transmitter_emit_stun_candidate (gpointer user_data)
g_signal_emit_by_name (data->self, "new-local-candidate", data->candidate);
- for (c = 1; c <= data->self->priv->transmitter->components; c++) {
- if (!data->self->priv->local_active_candidate[c]) {
+ for (c = 1; c <= data->self->priv->transmitter->components; c++)
+ {
+ if (!data->self->priv->local_active_candidate[c])
+ {
all_active = FALSE;
break;
}
@@ -784,7 +833,8 @@ fs_rawudp_stream_transmitter_emit_stun_candidate (gpointer user_data)
/* Lets remove this source from the list of sources to destroy */
source = g_main_current_source ();
- if (source) {
+ if (source)
+ {
guint id = g_source_get_id (source);
g_mutex_lock (data->self->priv->sources_mutex);
@@ -794,7 +844,7 @@ fs_rawudp_stream_transmitter_emit_stun_candidate (gpointer user_data)
}
fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (data->self,
- data->component_id);
+ data->component_id);
g_free (data);
@@ -811,7 +861,7 @@ fs_rawudp_stream_transmitter_emit_stun_candidate (gpointer user_data)
static gboolean
fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
- gpointer user_data)
+ gpointer user_data)
{
FsRawUdpStreamTransmitter *self = FS_RAWUDP_STREAM_TRANSMITTER (user_data);
gint component_id = -1;
@@ -821,45 +871,47 @@ fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
gint c;
- if (GST_BUFFER_SIZE (buffer) < 4) {
+ if (GST_BUFFER_SIZE (buffer) < 4)
/* Packet is too small to be STUN */
return TRUE;
- }
- if (GST_BUFFER_DATA (buffer)[0] >> 6) {
+ if (GST_BUFFER_DATA (buffer)[0] >> 6)
/* Non stun packet */
return TRUE;
- }
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (fs_rawudp_transmitter_udpport_is_pad (self->priv->udpports[c], pad)) {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (fs_rawudp_transmitter_udpport_is_pad (self->priv->udpports[c], pad))
+ {
component_id = c;
break;
}
}
- if (component_id < 0) {
+ if (component_id < 0)
+ {
g_error ("We've been called from a pad we shouldn't be listening to");
return FALSE;
}
msg = stun_message_unpack (GST_BUFFER_SIZE (buffer),
- (const gchar *) GST_BUFFER_DATA (buffer));
- if (!msg) {
+ (const gchar *) GST_BUFFER_DATA (buffer));
+ if (!msg)
/* invalid message */
return TRUE;
- }
- if (memcmp (msg->transaction_id, self->priv->stun_cookie, 16) != 0) {
+ if (memcmp (msg->transaction_id, self->priv->stun_cookie, 16) != 0)
+ {
/* not ours */
stun_message_free (msg);
return TRUE;
}
- if (msg->type == STUN_MESSAGE_BINDING_ERROR_RESPONSE) {
+ if (msg->type == STUN_MESSAGE_BINDING_ERROR_RESPONSE)
+ {
fs_stream_transmitter_emit_error (FS_STREAM_TRANSMITTER (self),
- FS_ERROR_NETWORK, "Got an error message from the STUN server",
- "The STUN process produced an error");
+ FS_ERROR_NETWORK, "Got an error message from the STUN server",
+ "The STUN process produced an error");
stun_message_free (msg);
// fs_rawudp_stream_transmitter_stop_stun (self, component_id);
/* Lets not stop the STUN now and wait for the timeout
@@ -868,18 +920,21 @@ fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
return FALSE;
}
- if (msg->type != STUN_MESSAGE_BINDING_RESPONSE) {
+ if (msg->type != STUN_MESSAGE_BINDING_RESPONSE)
+ {
stun_message_free (msg);
return TRUE;
}
- for (attr = msg->attributes; *attr; attr++) {
- if ((*attr)->type == STUN_ATTRIBUTE_MAPPED_ADDRESS) {
+ for (attr = msg->attributes; *attr; attr++)
+ {
+ if ((*attr)->type == STUN_ATTRIBUTE_MAPPED_ADDRESS)
+ {
candidate = g_new0 (FsCandidate,1);
candidate->candidate_id = g_strdup_printf ("L%u",
- self->priv->next_candidate_id);
+ self->priv->next_candidate_id);
candidate->component_id = component_id;
candidate->ip = g_strdup_printf ("%u.%u.%u.%u",
((*attr)->address.ip & 0xff000000) >> 24,
@@ -903,7 +958,8 @@ fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
fs_rawudp_stream_transmitter_stop_stun (self, component_id);
g_mutex_unlock (self->priv->sources_mutex);
- if (candidate) {
+ if (candidate)
+ {
guint id;
struct CandidateTransit *data = g_new0 (struct CandidateTransit, 1);
data->self = self;
@@ -913,12 +969,12 @@ fs_rawudp_stream_transmitter_stun_recv_cb (GstPad *pad, GstBuffer *buffer,
g_assert (id);
g_mutex_lock (self->priv->sources_mutex);
self->priv->sources = g_list_prepend (self->priv->sources,
- GUINT_TO_POINTER(id));
+ GUINT_TO_POINTER(id));
g_mutex_unlock (self->priv->sources_mutex);
}
/* It was a stun packet, lets drop it */
- stun_message_free (msg);
+ stun_message_free (msg);
return FALSE;
}
@@ -937,8 +993,10 @@ fs_rawudp_stream_transmitter_stun_timeout_cb (gpointer user_data)
data->component_id))
return FALSE;
- for (c = 1; c <= data->self->priv->transmitter->components; c++) {
- if (!data->self->priv->local_active_candidate[c]) {
+ for (c = 1; c <= data->self->priv->transmitter->components; c++)
+ {
+ if (!data->self->priv->local_active_candidate[c])
+ {
all_active = FALSE;
break;
}
@@ -952,7 +1010,7 @@ fs_rawudp_stream_transmitter_stun_timeout_cb (gpointer user_data)
static gboolean
fs_rawudp_stream_transmitter_start_stun (FsRawUdpStreamTransmitter *self,
- guint component_id, GError **error)
+ guint component_id, GError **error)
{
struct addrinfo hints;
struct addrinfo *result = NULL;
@@ -968,10 +1026,11 @@ fs_rawudp_stream_transmitter_start_stun (FsRawUdpStreamTransmitter *self,
hints.ai_family = AF_INET;
hints.ai_flags = AI_NUMERICHOST;
retval = getaddrinfo (self->priv->stun_ip, NULL, &hints, &result);
- if (retval != 0) {
+ if (retval != 0)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Invalid IP address %s passed for STUN: %s",
- self->priv->stun_ip, gai_strerror (retval));
+ "Invalid IP address %s passed for STUN: %s",
+ self->priv->stun_ip, gai_strerror (retval));
return FALSE;
}
memcpy (&address, result->ai_addr, sizeof(struct sockaddr_in));
@@ -988,20 +1047,20 @@ fs_rawudp_stream_transmitter_start_stun (FsRawUdpStreamTransmitter *self,
g_mutex_unlock (self->priv->sources_mutex);
msg = stun_message_new (STUN_MESSAGE_BINDING_REQUEST,
- self->priv->stun_cookie, 0);
- if (!msg) {
+ self->priv->stun_cookie, 0);
+ if (!msg)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Could not create a new STUN binding request");
+ "Could not create a new STUN binding request");
return FALSE;
}
length = stun_message_pack (msg, &packed);
if (!fs_rawudp_transmitter_udpport_sendto (self->priv->udpports[component_id],
- packed, length, (const struct sockaddr *)&address, sizeof(address),
- error)) {
+ packed, length, (const struct sockaddr *)&address, sizeof(address),
+ error))
ret = FALSE;
- }
g_free (packed);
stun_message_free (msg);
@@ -1036,16 +1095,18 @@ fs_rawudp_stream_transmitter_start_stun (FsRawUdpStreamTransmitter *self,
static void
fs_rawudp_stream_transmitter_stop_stun (FsRawUdpStreamTransmitter *self,
- guint component_id)
+ guint component_id)
{
- if (self->priv->stun_recv_id[component_id]) {
+ if (self->priv->stun_recv_id[component_id])
+ {
fs_rawudp_transmitter_udpport_disconnect_recv (
self->priv->udpports[component_id],
self->priv->stun_recv_id[component_id]);
self->priv->stun_recv_id[component_id] = 0;
}
- if (self->priv->stun_timeout_id[component_id]) {
+ if (self->priv->stun_timeout_id[component_id])
+ {
g_source_remove (self->priv->stun_timeout_id[component_id]);
self->priv->stun_timeout_id[component_id] = 0;
}
@@ -1060,7 +1121,7 @@ fs_rawudp_stream_transmitter_build_forced_candidate (
candidate = g_new0 (FsCandidate,1);
candidate->candidate_id = g_strdup_printf ("L%u",
- self->priv->next_candidate_id++);
+ self->priv->next_candidate_id++);
candidate->component_id = component_id;
candidate->ip = g_strdup (ip);
candidate->port = port;
@@ -1078,22 +1139,24 @@ fs_rawudp_stream_transmitter_emit_local_candidates (
GList *current;
guint port;
- if (component_id > self->priv->transmitter->components) {
+ if (component_id > self->priv->transmitter->components)
+ {
gchar *text = g_strdup_printf ("Internal error: invalid component %d",
- component_id);
+ component_id);
fs_stream_transmitter_emit_error (FS_STREAM_TRANSMITTER (self),
- FS_ERROR_INVALID_ARGUMENTS, text, text);
+ FS_ERROR_INVALID_ARGUMENTS, text, text);
g_free (text);
return FALSE;
}
- if (self->priv->local_forced_candidate[component_id]) {
+ if (self->priv->local_forced_candidate[component_id])
+ {
self->priv->local_active_candidate[component_id] = fs_candidate_copy (
self->priv->local_forced_candidate[component_id]);
g_signal_emit_by_name (self, "new-local-candidate",
- self->priv->local_forced_candidate[component_id]);
+ self->priv->local_forced_candidate[component_id]);
fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (self,
- component_id);
+ component_id);
return TRUE;
}
@@ -1104,11 +1167,12 @@ fs_rawudp_stream_transmitter_emit_local_candidates (
for (current = g_list_first (ips);
current;
- current = g_list_next(current)) {
+ current = g_list_next(current))
+ {
FsCandidate *candidate = g_new0 (FsCandidate, 1);
candidate->candidate_id = g_strdup_printf ("L%u",
- self->priv->next_candidate_id++);
+ self->priv->next_candidate_id++);
candidate->component_id = component_id;
candidate->ip = g_strdup (current->data);
candidate->port = port;
@@ -1138,7 +1202,7 @@ fs_rawudp_stream_transmitter_emit_local_candidates (
}
fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (self,
- component_id);
+ component_id);
return TRUE;
}
@@ -1157,8 +1221,10 @@ fs_rawudp_stream_transmitter_no_stun (gpointer user_data)
/* If we have a STUN'd candidate, dont send the locally generated
* ones */
- for (c = 1; c <= self->priv->transmitter->components; c++) {
- if (!self->priv->local_active_candidate[c]) {
+ for (c = 1; c <= self->priv->transmitter->components; c++)
+ {
+ if (!self->priv->local_active_candidate[c])
+ {
if (!fs_rawudp_stream_transmitter_emit_local_candidates (self, c))
return FALSE;
}
@@ -1171,12 +1237,13 @@ fs_rawudp_stream_transmitter_no_stun (gpointer user_data)
* For the case when its called from an idle source
*/
source = g_main_current_source ();
- if (source) {
+ if (source)
+ {
guint id = g_source_get_id (source);
g_mutex_lock (self->priv->sources_mutex);
self->priv->sources = g_list_remove (self->priv->sources,
- GUINT_TO_POINTER (id));
+ GUINT_TO_POINTER (id));
g_mutex_unlock (self->priv->sources_mutex);
}
@@ -1188,10 +1255,11 @@ fs_rawudp_stream_transmitter_maybe_new_active_candidate_pair (
FsRawUdpStreamTransmitter *self, guint component_id)
{
if (self->priv->local_active_candidate[component_id] &&
- self->priv->remote_candidate[component_id]) {
+ self->priv->remote_candidate[component_id])
+ {
g_signal_emit_by_name (self, "new-active-candidate-pair",
- self->priv->local_active_candidate[component_id],
- self->priv->remote_candidate[component_id]);
+ self->priv->local_active_candidate[component_id],
+ self->priv->remote_candidate[component_id]);
}
}
diff --git a/transmitters/rawudp/fs-rawudp-stream-transmitter.h b/transmitters/rawudp/fs-rawudp-stream-transmitter.h
index ad49d4e..35b43d7 100644
--- a/transmitters/rawudp/fs-rawudp-stream-transmitter.h
+++ b/transmitters/rawudp/fs-rawudp-stream-transmitter.h
@@ -35,22 +35,23 @@
G_BEGIN_DECLS
/* TYPE MACROS */
-#define FS_TYPE_RAWUDP_STREAM_TRANSMITTER \
+#define FS_TYPE_RAWUDP_STREAM_TRANSMITTER \
(fs_rawudp_stream_transmitter_get_type())
-#define FS_RAWUDP_STREAM_TRANSMITTER(obj) \
+#define FS_RAWUDP_STREAM_TRANSMITTER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), FS_TYPE_RAWUDP_STREAM_TRANSMITTER, \
- FsRawUdpStreamTransmitter))
-#define FS_RAWUDP_STREAM_TRANSMITTER_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_RAWUDP_STREAM_TRANSMITTER, \
- FsRawUdpStreamTransmitterClass))
-#define FS_IS_RAWUDP_STREAM_TRANSMITTER(obj) \
+ FsRawUdpStreamTransmitter))
+#define FS_RAWUDP_STREAM_TRANSMITTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), FS_TYPE_RAWUDP_STREAM_TRANSMITTER, \
+ FsRawUdpStreamTransmitterClass))
+#define FS_IS_RAWUDP_STREAM_TRANSMITTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), FS_TYPE_RAWUDP_STREAM_TRANSMITTER))
-#define FS_IS_RAWUDP_STREAM_TRANSMITTER_CLASS(klass) \
+#define FS_IS_RAWUDP_STREAM_TRANSMITTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), FS_TYPE_RAWUDP_STREAM_TRANSMITTER))
-#define FS_RAWUDP_STREAM_TRANSMITTER_GET_CLASS(obj) \
+#define FS_RAWUDP_STREAM_TRANSMITTER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), FS_TYPE_RAWUDP_STREAM_TRANSMITTER, \
- FsRawUdpStreamTransmitterClass))
-#define FS_RAWUDP_STREAM_TRANSMITTER_CAST(obj) ((FsRawUdpStreamTransmitter *) (obj))
+ FsRawUdpStreamTransmitterClass))
+#define FS_RAWUDP_STREAM_TRANSMITTER_CAST(obj) \
+ ((FsRawUdpStreamTransmitter *) (obj))
typedef struct _FsRawUdpStreamTransmitter FsRawUdpStreamTransmitter;
typedef struct _FsRawUdpStreamTransmitterClass FsRawUdpStreamTransmitterClass;
@@ -90,7 +91,9 @@ GType fs_rawudp_stream_transmitter_get_type (void);
FsRawUdpStreamTransmitter *
fs_rawudp_stream_transmitter_newv (FsRawUdpTransmitter *transmitter,
- guint n_parameters, GParameter *parameters, GError **error);
+ guint n_parameters,
+ GParameter *parameters,
+ GError **error);
G_END_DECLS
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.c b/transmitters/rawudp/fs-rawudp-transmitter.c
index c795377..b24cf1d 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.c
+++ b/transmitters/rawudp/fs-rawudp-transmitter.c
@@ -83,9 +83,9 @@ struct _FsRawUdpTransmitterPrivate
gboolean disposed;
};
-#define FS_RAWUDP_TRANSMITTER_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_RAWUDP_TRANSMITTER, \
- FsRawUdpTransmitterPrivate))
+#define FS_RAWUDP_TRANSMITTER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_RAWUDP_TRANSMITTER, \
+ FsRawUdpTransmitterPrivate))
static void fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass);
static void fs_rawudp_transmitter_init (FsRawUdpTransmitter *self);
@@ -94,17 +94,20 @@ static void fs_rawudp_transmitter_dispose (GObject *object);
static void fs_rawudp_transmitter_finalize (GObject *object);
static void fs_rawudp_transmitter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
static void fs_rawudp_transmitter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
static FsStreamTransmitter *fs_rawudp_transmitter_new_stream_transmitter (
- FsTransmitter *transmitter, FsParticipant *participant,
- guint n_parameters, GParameter *parameters, GError **error);
+ FsTransmitter *transmitter,
+ FsParticipant *participant,
+ guint n_parameters,
+ GParameter *parameters,
+ GError **error);
static GType fs_rawudp_transmitter_get_stream_transmitter_type (
FsTransmitter *transmitter,
GError **error);
@@ -150,7 +153,7 @@ fs_rawudp_transmitter_register_type (FsPlugin *module)
fs_rawudp_stream_transmitter_register_type (module);
type = g_type_module_register_type (G_TYPE_MODULE (module),
- FS_TYPE_TRANSMITTER, "FsRawUdpTransmitter", &info, 0);
+ FS_TYPE_TRANSMITTER, "FsRawUdpTransmitter", &info, 0);
return type;
}
@@ -184,7 +187,7 @@ fs_rawudp_transmitter_class_init (FsRawUdpTransmitterClass *klass)
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");
+ "components");
transmitter_class->new_stream_transmitter =
fs_rawudp_transmitter_new_stream_transmitter;
@@ -229,10 +232,11 @@ fs_rawudp_transmitter_constructed (GObject *object)
self->priv->gst_src = gst_bin_new (NULL);
- if (!self->priv->gst_src) {
+ if (!self->priv->gst_src)
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not build the transmitter src bin");
+ FS_ERROR_CONSTRUCTION,
+ "Could not build the transmitter src bin");
return;
}
@@ -243,34 +247,38 @@ fs_rawudp_transmitter_constructed (GObject *object)
self->priv->gst_sink = gst_bin_new (NULL);
- if (!self->priv->gst_sink) {
+ if (!self->priv->gst_sink)
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not build the transmitter sink bin");
+ FS_ERROR_CONSTRUCTION,
+ "Could not build the transmitter sink bin");
return;
}
gst_object_ref (self->priv->gst_sink);
- for (c = 1; c <= self->components; c++) {
+ for (c = 1; c <= self->components; c++)
+ {
GstElement *fakesink = NULL;
/* Lets create the RTP source funnel */
self->priv->udpsrc_funnels[c] = gst_element_factory_make ("fsfunnel", NULL);
- if (!self->priv->udpsrc_funnels[c]) {
+ if (!self->priv->udpsrc_funnels[c])
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not make the fsfunnel element");
+ FS_ERROR_CONSTRUCTION,
+ "Could not make the fsfunnel element");
return;
}
if (!gst_bin_add (GST_BIN (self->priv->gst_src),
- self->priv->udpsrc_funnels[c])) {
+ self->priv->udpsrc_funnels[c]))
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not add the fsfunnel element to the transmitter src bin");
+ FS_ERROR_CONSTRUCTION,
+ "Could not add the fsfunnel element to the transmitter src bin");
}
pad = gst_element_get_static_pad (self->priv->udpsrc_funnels[c], "src");
@@ -287,18 +295,20 @@ fs_rawudp_transmitter_constructed (GObject *object)
self->priv->udpsink_tees[c] = gst_element_factory_make ("tee", NULL);
- if (!self->priv->udpsink_tees[c]) {
+ if (!self->priv->udpsink_tees[c])
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not make the tee element");
+ FS_ERROR_CONSTRUCTION,
+ "Could not make the tee element");
return;
}
if (!gst_bin_add (GST_BIN (self->priv->gst_sink),
- self->priv->udpsink_tees[c])) {
+ self->priv->udpsink_tees[c]))
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not add the tee element to the transmitter sink bin");
+ FS_ERROR_CONSTRUCTION,
+ "Could not add the tee element to the transmitter sink bin");
}
pad = gst_element_get_static_pad (self->priv->udpsink_tees[c], "sink");
@@ -312,10 +322,11 @@ fs_rawudp_transmitter_constructed (GObject *object)
fakesink = gst_element_factory_make ("fakesink", NULL);
- if (!fakesink) {
+ if (!fakesink)
+ {
trans->construction_error = g_error_new (FS_ERROR,
- FS_ERROR_CONSTRUCTION,
- "Could not make the fakesink element");
+ FS_ERROR_CONSTRUCTION,
+ "Could not make the fakesink element");
return;
}
@@ -341,7 +352,8 @@ fs_rawudp_transmitter_constructed (GObject *object)
gst_object_unref (pad2);
gst_object_unref (pad);
- if (GST_PAD_LINK_FAILED(ret)) {
+ if (GST_PAD_LINK_FAILED(ret))
+ {
trans->construction_error = g_error_new (FS_ERROR,
FS_ERROR_CONSTRUCTION,
"Could not link the tee to the fakesink");
@@ -355,17 +367,18 @@ fs_rawudp_transmitter_dispose (GObject *object)
{
FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (object);
- if (self->priv->disposed) {
+ if (self->priv->disposed)
/* If dispose did already run, return. */
return;
- }
- if (self->priv->gst_src) {
+ if (self->priv->gst_src)
+ {
gst_object_unref (self->priv->gst_src);
self->priv->gst_src = NULL;
}
- if (self->priv->gst_sink) {
+ if (self->priv->gst_sink)
+ {
gst_object_unref (self->priv->gst_sink);
self->priv->gst_sink = NULL;
}
@@ -381,17 +394,20 @@ fs_rawudp_transmitter_finalize (GObject *object)
{
FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (object);
- if (self->priv->udpsrc_funnels) {
+ if (self->priv->udpsrc_funnels)
+ {
g_free (self->priv->udpsrc_funnels);
self->priv->udpsrc_funnels = NULL;
}
- if (self->priv->udpsink_tees) {
+ if (self->priv->udpsink_tees)
+ {
g_free (self->priv->udpsink_tees);
self->priv->udpsink_tees = NULL;
}
- if (self->priv->udpports) {
+ if (self->priv->udpports)
+ {
g_free (self->priv->udpports);
self->priv->udpports = NULL;
}
@@ -401,13 +417,14 @@ fs_rawudp_transmitter_finalize (GObject *object)
static void
fs_rawudp_transmitter_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (object);
- switch (prop_id) {
+ switch (prop_id)
+ {
case PROP_GST_SINK:
g_value_set_object (value, self->priv->gst_sink);
break;
@@ -422,13 +439,14 @@ fs_rawudp_transmitter_get_property (GObject *object,
static void
fs_rawudp_transmitter_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (object);
- switch (prop_id) {
+ switch (prop_id)
+ {
case PROP_COMPONENTS:
self->components = g_value_get_uint (value);
break;
@@ -453,8 +471,10 @@ fs_rawudp_transmitter_set_property (GObject *object,
static FsStreamTransmitter *
fs_rawudp_transmitter_new_stream_transmitter (FsTransmitter *transmitter,
- FsParticipant *participant, guint n_parameters, GParameter *parameters,
- GError **error)
+ FsParticipant *participant,
+ guint n_parameters,
+ GParameter *parameters,
+ GError **error)
{
FsRawUdpTransmitter *self = FS_RAWUDP_TRANSMITTER (transmitter);
@@ -493,7 +513,11 @@ struct _UdpPort {
};
static gint
-_bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
+_bind_port (
+ const gchar *ip,
+ guint port,
+ guint *used_port,
+ GError **error)
{
int sock;
struct sockaddr_in address;
@@ -502,7 +526,8 @@ _bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
- if (ip) {
+ if (ip)
+ {
struct addrinfo hints;
struct addrinfo *result = NULL;
@@ -510,18 +535,20 @@ _bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
hints.ai_family = AF_INET;
hints.ai_flags = AI_NUMERICHOST;
retval = getaddrinfo (ip, NULL, &hints, &result);
- if (retval != 0) {
+ if (retval != 0)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Invalid IP address %s passed: %s", ip, gai_strerror (retval));
+ "Invalid IP address %s passed: %s", ip, gai_strerror (retval));
return -1;
}
memcpy (&address, result->ai_addr, sizeof(struct sockaddr_in));
freeaddrinfo (result);
}
- if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) <= 0) {
+ if ((sock = socket (AF_INET, SOCK_DGRAM, 0)) <= 0)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Error creating socket: %s", g_strerror (errno));
+ "Error creating socket: %s", g_strerror (errno));
return -1;
}
@@ -532,9 +559,10 @@ _bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
{
GST_INFO ("could not bind port %d", port);
port += 2;
- if (port > 65535) {
+ if (port > 65535)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Could not bind the socket to a port");
+ "Could not bind the socket to a port");
close (sock);
return -1;
}
@@ -547,9 +575,14 @@ _bind_port (const gchar *ip, guint port, guint *used_port, GError **error)
}
static GstElement *
-_create_sinksource (gchar *elementname, GstBin *bin,
- GstElement *teefunnel, gint fd, GstPadDirection direction,
- GstPad **requested_pad, GError **error)
+_create_sinksource (
+ gchar *elementname,
+ GstBin *bin,
+ GstElement *teefunnel,
+ gint fd,
+ GstPadDirection direction,
+ GstPad **requested_pad,
+ GError **error)
{
GstElement *elem;
GstPadLinkReturn ret;
@@ -559,21 +592,23 @@ _create_sinksource (gchar *elementname, GstBin *bin,
g_assert (direction == GST_PAD_SINK || direction == GST_PAD_SRC);
elem = gst_element_factory_make (elementname, NULL);
- if (!elem) {
+ if (!elem)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not create the %s element", elementname);
+ "Could not create the %s element", elementname);
return NULL;
}
g_object_set (elem,
- "closefd", FALSE,
- "sockfd", fd,
- NULL);
+ "closefd", FALSE,
+ "sockfd", fd,
+ NULL);
- if (!gst_bin_add (bin, elem)) {
+ if (!gst_bin_add (bin, elem))
+ {
g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not add the %s element to the gst %s bin", elementname,
- (direction == GST_PAD_SINK) ? "sink" : "src");
+ "Could not add the %s element to the gst %s bin", elementname,
+ (direction == GST_PAD_SINK) ? "sink" : "src");
gst_object_unref (elem);
return NULL;
}
@@ -583,11 +618,12 @@ _create_sinksource (gchar *elementname, GstBin *bin,
else
*requested_pad = gst_element_get_request_pad (teefunnel, "sink%d");
- if (!*requested_pad) {
+ if (!*requested_pad)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not get the %s request pad from the %s",
- (direction == GST_PAD_SINK) ? "src" : "sink",
- (direction == GST_PAD_SINK) ? "tee" : "funnel");
+ "Could not get the %s request pad from the %s",
+ (direction == GST_PAD_SINK) ? "src" : "sink",
+ (direction == GST_PAD_SINK) ? "tee" : "funnel");
goto error;
}
@@ -603,16 +639,18 @@ _create_sinksource (gchar *elementname, GstBin *bin,
gst_object_unref (elempad);
- if (GST_PAD_LINK_FAILED(ret)) {
+ 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);
+ "Could not link the new element %s (%d)", elementname, ret);
goto error;
}
- if (!gst_element_sync_state_with_parent (elem)) {
+ if (!gst_element_sync_state_with_parent (elem))
+ {
g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
- "Could not sync the state of the new %s with its parent",
- elementname);
+ "Could not sync the state of the new %s with its parent",
+ elementname);
goto error;
}
@@ -637,26 +675,31 @@ _create_sinksource (gchar *elementname, GstBin *bin,
UdpPort *
fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
- guint component_id, const gchar *requested_ip, guint requested_port,
- GError **error)
+ guint component_id,
+ const gchar *requested_ip,
+ guint requested_port,
+ GError **error)
{
UdpPort *udpport;
GList *udpport_e;
/* First lets check if we already have one */
- if (component_id > trans->components) {
+ if (component_id > trans->components)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS,
- "Invalid component %d > %d", component_id, trans->components);
+ "Invalid component %d > %d", component_id, trans->components);
return NULL;
}
for (udpport_e = g_list_first (trans->priv->udpports[component_id]);
udpport_e;
- udpport_e = g_list_next (udpport_e)) {
+ udpport_e = g_list_next (udpport_e))
+ {
udpport = udpport_e->data;
if (requested_port == udpport->requested_port &&
((requested_ip == NULL && udpport->requested_ip == NULL) ||
- !strcmp (requested_ip, udpport->requested_ip))) {
+ !strcmp (requested_ip, udpport->requested_ip)))
+ {
GST_LOG ("Got port refcount %d->%d", udpport->refcount,
udpport->refcount+1);
udpport->refcount++;
@@ -678,7 +721,7 @@ fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
/* Now lets bind both ports */
udpport->fd = _bind_port (requested_ip, requested_port, &udpport->port,
- error);
+ error);
if (udpport->fd < 0)
goto error;
@@ -688,14 +731,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, 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, udpport->fd, GST_PAD_SINK,
+ &udpport->udpsink_requested_pad, error);
if (!udpport->udpsink)
goto error;
@@ -718,7 +761,8 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
{
GST_LOG ("Put port refcount %d->%d", udpport->refcount, udpport->refcount-1);
- if (udpport->refcount > 1) {
+ if (udpport->refcount > 1)
+ {
udpport->refcount--;
return;
}
@@ -726,37 +770,41 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
trans->priv->udpports[udpport->component_id] =
g_list_remove (trans->priv->udpports[udpport->component_id], udpport);
- if (udpport->udpsrc) {
+ if (udpport->udpsrc)
+ {
GstStateChangeReturn ret;
gst_element_set_locked_state (udpport->udpsrc, TRUE);
ret = gst_element_set_state (udpport->udpsrc, GST_STATE_NULL);
if (ret != GST_STATE_CHANGE_SUCCESS)
GST_ERROR ("Error changing state of udpsrc: %s",
- gst_element_state_change_return_get_name (ret));
+ gst_element_state_change_return_get_name (ret));
if (!gst_bin_remove (GST_BIN (trans->priv->gst_src), udpport->udpsrc))
GST_ERROR ("Could not remove udpsrc element from transmitter source");
}
- if (udpport->udpsrc_requested_pad) {
+ if (udpport->udpsrc_requested_pad)
+ {
gst_element_release_request_pad (udpport->funnel,
- udpport->udpsrc_requested_pad);
+ udpport->udpsrc_requested_pad);
gst_object_unref (udpport->udpsrc_requested_pad);
}
- if (udpport->udpsink) {
+ if (udpport->udpsink)
+ {
GstStateChangeReturn ret;
gst_element_set_locked_state (udpport->udpsink, TRUE);
ret = gst_element_set_state (udpport->udpsink, GST_STATE_NULL);
if (ret != GST_STATE_CHANGE_SUCCESS)
GST_ERROR ("Error changing state of udpsink: %s",
- gst_element_state_change_return_get_name (ret));
+ gst_element_state_change_return_get_name (ret));
if (!gst_bin_remove (GST_BIN (trans->priv->gst_sink), udpport->udpsink))
GST_ERROR ("Could not remove udpsink element from transmitter source");
}
- if (udpport->udpsink_requested_pad) {
+ if (udpport->udpsink_requested_pad)
+ {
gst_element_release_request_pad (udpport->tee,
- udpport->udpsink_requested_pad);
+ udpport->udpsink_requested_pad);
gst_object_unref (udpport->udpsink_requested_pad);
}
@@ -769,7 +817,8 @@ fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
void
fs_rawudp_transmitter_udpport_add_dest (UdpPort *udpport,
- const gchar *ip, gint port)
+ const gchar *ip,
+ gint port)
{
GST_DEBUG ("Adding dest %s:%d", ip, port);
g_signal_emit_by_name (udpport->udpsink, "add", ip, port);
@@ -778,19 +827,24 @@ fs_rawudp_transmitter_udpport_add_dest (UdpPort *udpport,
void
fs_rawudp_transmitter_udpport_remove_dest (UdpPort *udpport,
- const gchar *ip, gint port)
+ const gchar *ip,
+ gint port)
{
g_signal_emit_by_name (udpport->udpsink, "remove", ip, port);
}
gboolean
fs_rawudp_transmitter_udpport_sendto (UdpPort *udpport,
- gchar *msg, size_t len, const struct sockaddr *to, socklen_t tolen,
- GError **error)
+ gchar *msg,
+ size_t len,
+ const struct sockaddr *to,
+ socklen_t tolen,
+ GError **error)
{
- if (sendto (udpport->fd, msg, len, 0, to, tolen) != len) {
+ if (sendto (udpport->fd, msg, len, 0, to, tolen) != len)
+ {
g_set_error (error, FS_ERROR, FS_ERROR_NETWORK,
- "Could not send STUN request: %s", g_strerror (errno));
+ "Could not send STUN request: %s", g_strerror (errno));
return FALSE;
}
@@ -799,7 +853,8 @@ fs_rawudp_transmitter_udpport_sendto (UdpPort *udpport,
gulong
fs_rawudp_transmitter_udpport_connect_recv (UdpPort *udpport,
- GCallback callback, gpointer user_data)
+ GCallback callback,
+ gpointer user_data)
{
GstPad *pad;
gulong id;
@@ -815,7 +870,8 @@ fs_rawudp_transmitter_udpport_connect_recv (UdpPort *udpport,
void
-fs_rawudp_transmitter_udpport_disconnect_recv (UdpPort *udpport, gulong id)
+fs_rawudp_transmitter_udpport_disconnect_recv (UdpPort *udpport,
+ gulong id)
{
GstPad *pad = gst_element_get_static_pad (udpport->udpsrc, "src");
@@ -825,7 +881,8 @@ fs_rawudp_transmitter_udpport_disconnect_recv (UdpPort *udpport, gulong id)
}
gboolean
-fs_rawudp_transmitter_udpport_is_pad (UdpPort *udpport, GstPad *pad)
+fs_rawudp_transmitter_udpport_is_pad (UdpPort *udpport,
+ GstPad *pad)
{
GstPad *mypad;
gboolean res;
diff --git a/transmitters/rawudp/fs-rawudp-transmitter.h b/transmitters/rawudp/fs-rawudp-transmitter.h
index 0d92e93..1189735 100644
--- a/transmitters/rawudp/fs-rawudp-transmitter.h
+++ b/transmitters/rawudp/fs-rawudp-transmitter.h
@@ -91,27 +91,36 @@ GType fs_rawudp_transmitter_get_type (void);
UdpPort *fs_rawudp_transmitter_get_udpport (FsRawUdpTransmitter *trans,
- guint component_id, const gchar *requested_ip, guint requested_port,
- GError **error);
+ guint component_id,
+ const gchar *requested_ip,
+ guint requested_port,
+ GError **error);
void fs_rawudp_transmitter_put_udpport (FsRawUdpTransmitter *trans,
- UdpPort *udpport);
+ UdpPort *udpport);
void fs_rawudp_transmitter_udpport_add_dest (UdpPort *udpport,
- const gchar *ip, gint port);
+ const gchar *ip,
+ gint port);
void fs_rawudp_transmitter_udpport_remove_dest (UdpPort *udpport,
- const gchar *ip, gint port);
+ const gchar *ip,
+ gint port);
gboolean fs_rawudp_transmitter_udpport_sendto (UdpPort *udpport,
- gchar *msg, size_t len, const struct sockaddr *to, socklen_t tolen,
- GError **error);
+ gchar *msg,
+ size_t len,
+ const struct sockaddr *to,
+ socklen_t tolen,
+ GError **error);
gulong fs_rawudp_transmitter_udpport_connect_recv (UdpPort *udpport,
- GCallback callback, gpointer user_data);
+ GCallback callback,
+ gpointer user_data);
void fs_rawudp_transmitter_udpport_disconnect_recv (UdpPort *udpport,
- gulong id);
+ gulong id);
-gboolean fs_rawudp_transmitter_udpport_is_pad (UdpPort *udpport, GstPad *pad);
+gboolean fs_rawudp_transmitter_udpport_is_pad (UdpPort *udpport,
+ GstPad *pad);
gint fs_rawudp_transmitter_udpport_get_port (UdpPort *udpport);
--
1.5.6.5
More information about the farsight-commits
mailing list