gst_rtsp_media_factory_get_permissions
gst_rtsp_media_factory_set_permissions
gst_rtsp_media_factory_add_role
+gst_rtsp_media_factory_add_role_from_structure
gst_rtsp_media_factory_set_shared
gst_rtsp_media_factory_is_shared
gst_rtsp_permissions_add_role
gst_rtsp_permissions_add_role_valist
gst_rtsp_permissions_add_role_empty
+gst_rtsp_permissions_add_role_from_structure
gst_rtsp_permissions_add_permission_for_role
gst_rtsp_permissions_remove_role
gst_rtsp_permissions_get_role
}
/**
+ * gst_rtsp_media_factory_add_role_from_structure:
+ *
+ * A convenience wrapper around gst_rtsp_permissions_add_role_from_structure().
+ * If @factory had no permissions, new permissions will be created and the
+ * role will be added to it.
+ */
+void
+gst_rtsp_media_factory_add_role_from_structure (GstRTSPMediaFactory * factory,
+ GstStructure * structure)
+{
+ GstRTSPMediaFactoryPrivate *priv;
+ g_return_if_fail (GST_IS_RTSP_MEDIA_FACTORY (factory));
+ g_return_if_fail (GST_IS_STRUCTURE (structure));
+
+ priv = factory->priv;
+
+ GST_RTSP_MEDIA_FACTORY_LOCK (factory);
+ if (priv->permissions == NULL)
+ priv->permissions = gst_rtsp_permissions_new ();
+
+ gst_rtsp_permissions_add_role_from_structure (priv->permissions, structure);
+ GST_RTSP_MEDIA_FACTORY_UNLOCK (factory);
+}
+
+/**
* gst_rtsp_media_factory_set_launch:
* @factory: a #GstRTSPMediaFactory
* @launch: the launch description
const gchar *fieldname, ...);
GST_EXPORT
+void gst_rtsp_media_factory_add_role_from_structure (GstRTSPMediaFactory * factory,
+ GstStructure *structure);
+GST_EXPORT
void gst_rtsp_media_factory_set_shared (GstRTSPMediaFactory *factory,
gboolean shared);
g_ptr_array_new_with_free_func ((GDestroyNotify) free_structure);
}
+static void
+add_role_from_structure (GstRTSPPermissionsImpl * impl,
+ GstStructure * structure)
+{
+ guint i, len;
+ const gchar *role = gst_structure_get_name (structure);
+
+ len = impl->roles->len;
+ for (i = 0; i < len; i++) {
+ GstStructure *entry = g_ptr_array_index (impl->roles, i);
+
+ if (gst_structure_has_name (entry, role)) {
+ g_ptr_array_remove_index_fast (impl->roles, i);
+ break;
+ }
+ }
+
+ gst_structure_set_parent_refcount (structure,
+ &impl->permissions.mini_object.refcount);
+ g_ptr_array_add (impl->roles, structure);
+}
+
/**
* gst_rtsp_permissions_new:
*
{
GstRTSPPermissionsImpl *impl = (GstRTSPPermissionsImpl *) permissions;
GstStructure *structure;
- guint i, len;
g_return_if_fail (GST_IS_RTSP_PERMISSIONS (permissions));
g_return_if_fail (gst_mini_object_is_writable (&permissions->mini_object));
structure = gst_structure_new_valist (role, fieldname, var_args);
g_return_if_fail (structure != NULL);
- len = impl->roles->len;
- for (i = 0; i < len; i++) {
- GstStructure *entry = g_ptr_array_index (impl->roles, i);
+ add_role_from_structure (impl, structure);
+}
- if (gst_structure_has_name (entry, role)) {
- g_ptr_array_remove_index_fast (impl->roles, i);
- break;
- }
- }
+/**
+ * gst_rtsp_permissions_add_role_from_structure:
+ *
+ * Add a new role to @permissions based on @structure
+ */
+void
+gst_rtsp_permissions_add_role_from_structure (GstRTSPPermissions * permissions,
+ GstStructure * structure)
+{
+ GstRTSPPermissionsImpl *impl = (GstRTSPPermissionsImpl *) permissions;
+ GstStructure *copy;
- gst_structure_set_parent_refcount (structure,
- &impl->permissions.mini_object.refcount);
- g_ptr_array_add (impl->roles, structure);
+ g_return_if_fail (GST_IS_RTSP_PERMISSIONS (permissions));
+ g_return_if_fail (GST_IS_STRUCTURE (structure));
+
+ copy = gst_structure_copy (structure);
+
+ add_role_from_structure (impl, copy);
}
/**
const gchar * role);
GST_EXPORT
+void gst_rtsp_permissions_add_role_from_structure (GstRTSPPermissions * permissions,
+ GstStructure *structure);
+GST_EXPORT
void gst_rtsp_permissions_add_permission_for_role (GstRTSPPermissions * permissions,
const gchar * role,
const gchar * permission,
{
GstRTSPPermissions *perms;
GstRTSPPermissions *copy;
+ GstStructure *role_structure;
perms = gst_rtsp_permissions_new ();
fail_if (gst_rtsp_permissions_is_allowed (perms, "missing", "permission1"));
gst_rtsp_permissions_add_role_empty (perms, "noone");
fail_if (gst_rtsp_permissions_is_allowed (perms, "noone", "permission1"));
+ role_structure = gst_structure_new ("tester", "permission1", G_TYPE_BOOLEAN,
+ TRUE, NULL);
+ gst_rtsp_permissions_add_role_from_structure (perms, role_structure);
+ gst_structure_free (role_structure);
+ fail_unless (gst_rtsp_permissions_is_allowed (perms, "tester",
+ "permission1"));
+ fail_if (gst_rtsp_permissions_is_allowed (perms, "tester", "permission2"));
+
gst_rtsp_permissions_unref (perms);
}