/* * Set the value of a property for the server sink. */ static void gst_shm_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstShmSink *self = GST_SHM_SINK (object); int ret = 0; switch (prop_id) { case PROP_SOCKET_PATH: GST_OBJECT_LOCK (object); g_free (self->socket_path); self->socket_path = g_value_dup_string (value); GST_OBJECT_UNLOCK (object); break; case PROP_PERMS: GST_OBJECT_LOCK (object); self->perms = g_value_get_uint (value); if (self->pipe) ret = sp_writer_setperms_shm (self->pipe, self->perms); GST_OBJECT_UNLOCK (object); if (ret < 0) GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s", strerror (ret)); break; case PROP_SHM_SIZE: GST_OBJECT_LOCK (object); if (self->pipe) { if (sp_writer_resize (self->pipe, g_value_get_uint (value)) < 0) { /* Swap allocators, so we can know immediately if the memory is * ours */ gst_object_unref (self->allocator); self->allocator = gst_shm_sink_allocator_new (self); GST_DEBUG_OBJECT (self, "Resized shared memory area from %u to " "%u bytes", self->size, g_value_get_uint (value)); } else { GST_WARNING_OBJECT (self, "Could not resize shared memory area from" "%u to %u bytes", self->size, g_value_get_uint (value)); } } self->size = g_value_get_uint (value); GST_OBJECT_UNLOCK (object); break; case PROP_WAIT_FOR_CONNECTION: GST_OBJECT_LOCK (object); self->wait_for_connection = g_value_get_boolean (value); GST_OBJECT_UNLOCK (object); g_cond_broadcast (&self->cond); break; case PROP_BUFFER_TIME: GST_OBJECT_LOCK (object); self->buffer_time = g_value_get_int64 (value); GST_OBJECT_UNLOCK (object); g_cond_broadcast (&self->cond); break; default: break; } }
static void shm_writer_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { ShmWriterPrivate *priv = SHM_WRITER (object)->priv; switch (property_id) { case PROP_CONTEXT: if (priv->context != NULL) g_main_context_unref (priv->context); priv->context = g_value_get_pointer (value); if (priv->context != NULL) g_main_context_ref (priv->context); break; case PROP_SIZE: { guint new_size = g_value_get_uint (value); if (priv->size == new_size) break; if (priv->open) { if (sp_writer_resize (priv->writer, new_size) == SHM_WRITER_FAILURE) /* Technically this should probably return an error, * but being that this is a property setter.. */ break; } priv->size = new_size; break; } case PROP_MODE: { guint new_mode = g_value_get_uint (value); if (priv->open) { sp_writer_setperms_shm (priv->writer, new_mode); } priv->mode = new_mode; break; } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } }
/* * Set the value of a property for the server sink. */ static void gst_shm_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstShmSink *self = GST_SHM_SINK (object); int ret = 0; switch (prop_id) { case PROP_SOCKET_PATH: GST_OBJECT_LOCK (object); g_free (self->socket_path); self->socket_path = g_value_dup_string (value); GST_OBJECT_UNLOCK (object); break; case PROP_PERMS: GST_OBJECT_LOCK (object); self->perms = g_value_get_uint (value); if (self->pipe) ret = sp_writer_setperms_shm (self->pipe, self->perms); GST_OBJECT_UNLOCK (object); if (ret < 0) GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s", strerror (ret)); break; case PROP_SHM_SIZE: GST_OBJECT_LOCK (object); if (self->pipe) { if (sp_writer_resize (self->pipe, g_value_get_uint (value)) < 0) GST_DEBUG_OBJECT (self, "Resized shared memory area from %u to " "%u bytes", self->size, g_value_get_uint (value)); else GST_WARNING_OBJECT (self, "Could not resize shared memory area from" "%u to %u bytes", self->size, g_value_get_uint (value)); } self->size = g_value_get_uint (value); GST_OBJECT_UNLOCK (object); break; case PROP_WAIT_FOR_CONNECTION: GST_OBJECT_LOCK (object); self->wait_for_connection = g_value_get_boolean (value); GST_OBJECT_UNLOCK (object); g_cond_broadcast (self->cond); break; default: break; } }
static void gst_shm_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstShmSink *self = GST_SHM_SINK (object); GST_OBJECT_LOCK (object); switch (prop_id) { case PROP_SOCKET_PATH: g_value_set_string (value, self->socket_path); break; case PROP_PERMS: self->perms = g_value_get_uint (value); if (self->pipe) { int ret; ret = sp_writer_setperms_shm (self->pipe, self->perms); if (ret < 0) GST_WARNING_OBJECT (object, "Could not set permissions on pipe: %s", strerror (ret)); } break; case PROP_SHM_SIZE: g_value_set_uint (value, self->size); break; case PROP_WAIT_FOR_CONNECTION: g_value_set_boolean (value, self->wait_for_connection); break; case PROP_BUFFER_TIME: g_value_set_int64 (value, self->buffer_time); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } GST_OBJECT_UNLOCK (object); }