diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-09-25 15:08:26 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-09-25 16:23:53 -0400 |
commit | dfcbd4cbcf111d6cfe6c174c4fdb5a9235062cf9 (patch) | |
tree | 168f70df15e0f7cf7d5d51ebbae320c8be5d9f1a /transmitters/nice | |
parent | 224a49a5c784efbe6bc4b9e8c7632332efcf7456 (diff) | |
download | farstream-dfcbd4cbcf111d6cfe6c174c4fdb5a9235062cf9.tar.gz |
Port to GLib 2.32
Diffstat (limited to 'transmitters/nice')
-rw-r--r-- | transmitters/nice/fs-nice-agent.c | 15 | ||||
-rw-r--r-- | transmitters/nice/fs-nice-stream-transmitter.c | 53 | ||||
-rw-r--r-- | transmitters/nice/fs-nice-transmitter.c | 16 |
3 files changed, 47 insertions, 37 deletions
diff --git a/transmitters/nice/fs-nice-agent.c b/transmitters/nice/fs-nice-agent.c index adcf5037..c1babbc3 100644 --- a/transmitters/nice/fs-nice-agent.c +++ b/transmitters/nice/fs-nice-agent.c @@ -67,7 +67,7 @@ struct _FsNiceAgentPrivate GList *preferred_local_candidates; - GMutex *mutex; + GMutex mutex; /* Everything below is protected by the mutex */ @@ -79,8 +79,8 @@ struct _FsNiceAgentPrivate FsNiceAgentPrivate)) -#define FS_NICE_AGENT_LOCK(o) g_mutex_lock ((o)->priv->mutex) -#define FS_NICE_AGENT_UNLOCK(o) g_mutex_unlock ((o)->priv->mutex) +#define FS_NICE_AGENT_LOCK(o) g_mutex_lock (&(o)->priv->mutex) +#define FS_NICE_AGENT_UNLOCK(o) g_mutex_unlock (&(o)->priv->mutex) static void fs_nice_agent_class_init ( FsNiceAgentClass *klass); @@ -175,7 +175,7 @@ fs_nice_agent_init (FsNiceAgent *self) /* member init */ self->priv = FS_NICE_AGENT_GET_PRIVATE (self); - self->priv->mutex = g_mutex_new (); + g_mutex_init (&self->priv->mutex); self->priv->main_context = g_main_context_new (); self->priv->main_loop = g_main_loop_new (self->priv->main_context, FALSE); @@ -213,8 +213,7 @@ fs_nice_agent_finalize (GObject *object) fs_candidate_list_destroy (self->priv->preferred_local_candidates); self->priv->preferred_local_candidates = NULL; - g_mutex_free (self->priv->mutex); - self->priv->mutex = NULL; + g_mutex_clear (&self->priv->mutex); parent_class->finalize (object); } @@ -418,8 +417,8 @@ fs_nice_agent_new (guint compatibility_mode, FS_NICE_AGENT_LOCK (self); - self->priv->thread = g_thread_create (fs_nice_agent_main_thread, - self, TRUE, error); + self->priv->thread = g_thread_try_new ("libnice agent thread", + fs_nice_agent_main_thread, self, error); if (!self->priv->thread) { diff --git a/transmitters/nice/fs-nice-stream-transmitter.c b/transmitters/nice/fs-nice-stream-transmitter.c index 697eb568..e266d632 100644 --- a/transmitters/nice/fs-nice-stream-transmitter.c +++ b/transmitters/nice/fs-nice-stream-transmitter.c @@ -84,7 +84,7 @@ struct _FsNiceStreamTransmitterPrivate guint compatibility_mode; - GMutex *mutex; + GMutex mutex; GList *preferred_local_candidates; @@ -95,7 +95,7 @@ struct _FsNiceStreamTransmitterPrivate gulong tos_changed_handler_id; - GValueArray *relay_info; + GPtrArray *relay_info; volatile gint associate_on_source; @@ -122,8 +122,8 @@ struct _FsNiceStreamTransmitterPrivate (G_TYPE_INSTANCE_GET_PRIVATE ((o), FS_TYPE_NICE_STREAM_TRANSMITTER, \ FsNiceStreamTransmitterPrivate)) -#define FS_NICE_STREAM_TRANSMITTER_LOCK(o) g_mutex_lock ((o)->priv->mutex) -#define FS_NICE_STREAM_TRANSMITTER_UNLOCK(o) g_mutex_unlock ((o)->priv->mutex) +#define FS_NICE_STREAM_TRANSMITTER_LOCK(o) g_mutex_lock (&(o)->priv->mutex) +#define FS_NICE_STREAM_TRANSMITTER_UNLOCK(o) g_mutex_unlock (&(o)->priv->mutex) static void fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass); @@ -287,7 +287,7 @@ fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass) /** * FsNiceStreamTransmitter:relay-info: * - * This is a #GValueArray containing one or more #GstStructure. + * This is a #GPtrArray containing one or more #GstStructure. * * The fields in the structure are: * <informaltable> @@ -328,15 +328,29 @@ fs_nice_stream_transmitter_class_init (FsNiceStreamTransmitterClass *klass) * </td> * </tr> * </informaltable> + * + * Example: + * |[ + GPtrArray *relay_info = g_ptr_array_new_full (1, (GDestroyNotify) gst_structure_free); + g_ptr_array_add (relay_info, + gst_structure_new ("aa", + "ip", G_TYPE_STRING, "127.0.0.1", + "port", G_TYPE_UINT, 7654, + "username", G_TYPE_STRING, "blah", + "password", G_TYPE_STRING, "blah2", + "relay-type", G_TYPE_STRING, "udp", + NULL)); + |] + * */ g_object_class_install_property (gobject_class, PROP_RELAY_INFO, - g_param_spec_value_array ( + g_param_spec_boxed ( "relay-info", "Information for the TURN server", "ip/port/username/password/relay-type/component of the TURN servers" - " in a GValueArray of GstStructures", - NULL, + " in a GPtrArray of GstStructures", + G_TYPE_PTR_ARRAY, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_DEBUG, @@ -356,7 +370,7 @@ fs_nice_stream_transmitter_init (FsNiceStreamTransmitter *self) self->priv = FS_NICE_STREAM_TRANSMITTER_GET_PRIVATE (self); self->priv->sending = TRUE; - self->priv->mutex = g_mutex_new (); + g_mutex_init (&self->priv->mutex); self->priv->controlling_mode = TRUE; } @@ -446,11 +460,11 @@ fs_nice_stream_transmitter_finalize (GObject *object) fs_candidate_list_destroy (self->priv->local_candidates); if (self->priv->relay_info) - g_value_array_free (self->priv->relay_info); + g_ptr_array_unref (self->priv->relay_info); g_free (self->priv->stun_ip); - g_mutex_free (self->priv->mutex); + g_mutex_clear (&self->priv->mutex); g_free (self->priv->username); g_free (self->priv->password); @@ -1179,15 +1193,14 @@ fs_nice_stream_transmitter_build (FsNiceStreamTransmitter *self, if (self->priv->relay_info) { - for (i = 0; i < self->priv->relay_info->n_values; i++) + for (i = 0; i < self->priv->relay_info->len; i++) { - GValue *val = g_value_array_get_nth (self->priv->relay_info, i); - const GstStructure *s = gst_value_get_structure (val); + const GstStructure *s = g_ptr_array_index (self->priv->relay_info, i); if (!s) { g_set_error (error, FS_ERROR, FS_ERROR_INVALID_ARGUMENTS, - "Element %d of the relay-info GValueArray is not a GstStructure", + "Element %d of the relay-info GPtrArray is NULL", i); return FALSE; } @@ -1349,10 +1362,9 @@ fs_nice_stream_transmitter_build (FsNiceStreamTransmitter *self, { gboolean relay_info_set = FALSE; - for (i = 0; i < self->priv->relay_info->n_values; i++) + for (i = 0; i < self->priv->relay_info->len; i++) { - GValue *val = g_value_array_get_nth (self->priv->relay_info, i); - const GstStructure *s = gst_value_get_structure (val); + const GstStructure *s = g_ptr_array_index (self->priv->relay_info, i); guint component_id; if (gst_structure_get_uint (s, "component", &component_id) && @@ -1366,10 +1378,9 @@ fs_nice_stream_transmitter_build (FsNiceStreamTransmitter *self, if (!relay_info_set) { - for (i = 0; i < self->priv->relay_info->n_values; i++) + for (i = 0; i < self->priv->relay_info->len; i++) { - GValue *val = g_value_array_get_nth (self->priv->relay_info, i); - const GstStructure *s = gst_value_get_structure (val); + const GstStructure *s = g_ptr_array_index (self->priv->relay_info, i); if (!gst_structure_has_field (s, "component")) if (!fs_nice_stream_transmitter_set_relay_info (self, s, c, error)) diff --git a/transmitters/nice/fs-nice-transmitter.c b/transmitters/nice/fs-nice-transmitter.c index 0798dd8e..4cca547b 100644 --- a/transmitters/nice/fs-nice-transmitter.c +++ b/transmitters/nice/fs-nice-transmitter.c @@ -699,7 +699,7 @@ struct _NiceGstStream { gulong *probe_ids; /* Protects the sending field and the addition/state of the elements */ - GMutex *mutex; + GMutex mutex; gboolean sending; gboolean desired_sending; @@ -720,7 +720,7 @@ fs_nice_transmitter_add_gst_stream (FsNiceTransmitter *self, ns = g_slice_new0 (NiceGstStream); ns->sending = TRUE; ns->desired_sending = TRUE; - ns->mutex = g_mutex_new (); + g_mutex_init (&ns->mutex); ns->nicesrcs = g_new0 (GstElement *, self->components + 1); ns->nicesinks = g_new0 (GstElement *, self->components + 1); ns->recvonly_filters = g_new0 (GstElement *, self->components + 1); @@ -858,7 +858,7 @@ fs_nice_transmitter_free_gst_stream (FsNiceTransmitter *self, g_free (ns->requested_tee_pads); g_free (ns->requested_funnel_pads); g_free (ns->probe_ids); - g_mutex_free (ns->mutex); + g_mutex_clear (&ns->mutex); g_slice_free (NiceGstStream, ns); } @@ -868,7 +868,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self, { guint c; - g_mutex_lock (ns->mutex); + g_mutex_lock (&ns->mutex); ns->desired_sending = sending; @@ -876,7 +876,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self, if (ns->modifying) { - g_mutex_unlock (ns->mutex); + g_mutex_unlock (&ns->mutex); return; } @@ -886,7 +886,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self, { gboolean current_sending = ns->sending; - g_mutex_unlock (ns->mutex); + g_mutex_unlock (&ns->mutex); GST_DEBUG ("Changing gst stream sending status to %d", !current_sending); @@ -936,7 +936,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self, } } - g_mutex_lock (ns->mutex); + g_mutex_lock (&ns->mutex); ns->sending = sending; @@ -944,7 +944,7 @@ fs_nice_transmitter_set_sending (FsNiceTransmitter *self, ns->modifying = FALSE; - g_mutex_unlock (ns->mutex); + g_mutex_unlock (&ns->mutex); } |