Use variable arguments to make easier API.
GstRTSPAuth *auth;
GstRTSPToken *token;
gchar *basic;
- GstStructure *s;
gst_init (&argc, &argv);
auth = gst_rtsp_auth_new ();
/* make user token */
- token = gst_rtsp_token_new ();
- s = gst_rtsp_token_writable_structure (token);
- gst_structure_set (s, "resources.class", G_TYPE_STRING, "user", NULL);
- gst_structure_set (s, "media.factory.role", G_TYPE_STRING, "user", NULL);
+ token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "user",
+ "media.factory.role", G_TYPE_STRING, "user", NULL);
basic = gst_rtsp_auth_make_basic ("user", "password");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
gst_rtsp_token_unref (token);
/* make admin token */
- token = gst_rtsp_token_new ();
- s = gst_rtsp_token_writable_structure (token);
- gst_structure_set (s, "resources.class", G_TYPE_STRING, "admin", NULL);
- gst_structure_set (s, "media.factory.role", G_TYPE_STRING, "admin", NULL);
+ token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "admin",
+ "media.factory.role", G_TYPE_STRING, "admin", NULL);
basic = gst_rtsp_auth_make_basic ("admin", "power");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
gst_rtsp_token_unref (token);
/* make admin2 token */
- token = gst_rtsp_token_new ();
- s = gst_rtsp_token_writable_structure (token);
- gst_structure_set (s, "resources.class", G_TYPE_STRING, "admin", NULL);
- gst_structure_set (s, "media.factory.role", G_TYPE_STRING, "admin2", NULL);
+ token = gst_rtsp_token_new ("resources.class", G_TYPE_STRING, "admin",
+ "media.factory.role", G_TYPE_STRING, "admin2", NULL);
basic = gst_rtsp_auth_make_basic ("admin2", "power2");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
GstRTSPAuth *auth;
GstRTSPToken *token;
gchar *basic;
- GstStructure *s;
GstRTSPThreadPool *thread_pool;
gst_init (&argc, &argv);
auth = gst_rtsp_auth_new ();
/* make user token */
- token = gst_rtsp_token_new ();
- s = gst_rtsp_token_writable_structure (token);
- gst_structure_set (s, "cgroup.pool.media.class", G_TYPE_STRING, "user", NULL);
- gst_structure_set (s, "media.factory.role", G_TYPE_STRING, "user", NULL);
+ token = gst_rtsp_token_new ("cgroup.pool.media.class", G_TYPE_STRING, "user",
+ "media.factory.role", G_TYPE_STRING, "user", NULL);
basic = gst_rtsp_auth_make_basic ("user", "password");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
gst_rtsp_token_unref (token);
/* make admin token */
- token = gst_rtsp_token_new ();
- s = gst_rtsp_token_writable_structure (token);
- gst_structure_set (s, "cgroup.pool.media.class", G_TYPE_STRING, "admin",
- NULL);
- gst_structure_set (s, "media.factory.role", G_TYPE_STRING, "admin", NULL);
+ token = gst_rtsp_token_new ("cgroup.pool.media.class", G_TYPE_STRING, "admin",
+ "media.factory.role", G_TYPE_STRING, "admin", NULL);
basic = gst_rtsp_auth_make_basic ("admin", "power");
gst_rtsp_auth_add_basic (auth, basic, token);
g_free (basic);
}
/**
- * gst_rtsp_token_new:
+ * gst_rtsp_token_new_empty:
*
* Create a new empty Authorization token.
*
* Returns: (transfer full): a new empty authorization token.
*/
GstRTSPToken *
-gst_rtsp_token_new (void)
+gst_rtsp_token_new_empty (void)
+{
+ return gst_rtsp_token_new (NULL, NULL);
+}
+
+/**
+ * gst_rtsp_token_new:
+ * @firstfield: the first fieldname
+ * @...: additional arguments
+ *
+ * Create a new Authorization token with the given fieldnames and values.
+ * Arguments are given similar to gst_structure_new().
+ *
+ * Returns: (transfer full): a new authorization token.
+ */
+GstRTSPToken *
+gst_rtsp_token_new (const gchar * firstfield, ...)
+{
+ GstRTSPToken *result;
+ va_list var_args;
+
+ va_start (var_args, firstfield);
+ result = gst_rtsp_token_new_valist (firstfield, var_args);
+ va_end (var_args);
+
+ return result;
+}
+
+/**
+ * gst_rtsp_token_new:
+ * @firstfield: the first fieldname
+ * @var_args additional arguments
+ *
+ * Create a new Authorization token with the given fieldnames and values.
+ * Arguments are given similar to gst_structure_new_valist().
+ *
+ * Returns: (transfer full): a new authorization token.
+ */
+GstRTSPToken *
+gst_rtsp_token_new_valist (const gchar * firstfield, va_list var_args)
{
GstRTSPTokenImpl *token;
+ GstStructure *s;
- token = g_slice_new0 (GstRTSPTokenImpl);
+ g_return_val_if_fail (firstfield != NULL, NULL);
+
+ s = gst_structure_new_valist ("GstRTSPToken", firstfield, var_args);
+ g_return_val_if_fail (s != NULL, NULL);
- gst_rtsp_token_init (token, gst_structure_new_empty ("GstRTSPToken"));
+ token = g_slice_new0 (GstRTSPTokenImpl);
+ gst_rtsp_token_init (token, s);
return (GstRTSPToken *) token;
}
}
-GstRTSPToken * gst_rtsp_token_new (void);
+GstRTSPToken * gst_rtsp_token_new_empty (void);
+GstRTSPToken * gst_rtsp_token_new (const gchar * firstfield, ...);
+GstRTSPToken * gst_rtsp_token_new_valist (const gchar * firstfield, va_list var_args);
const GstStructure * gst_rtsp_token_get_structure (GstRTSPToken *token);
GstStructure * gst_rtsp_token_writable_structure (GstRTSPToken *token);