mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
rtsp-token: add some API to set fields from bindings
The existing functions are all vararg-based and as such not usable from bindings. https://bugzilla.gnome.org/show_bug.cgi?id=787073
This commit is contained in:
parent
4e048f7b8a
commit
54a8c6bddf
4 changed files with 70 additions and 1 deletions
|
@ -725,7 +725,9 @@ gst_rtsp_token_ref
|
|||
gst_rtsp_token_unref
|
||||
gst_rtsp_token_get_structure
|
||||
gst_rtsp_token_writable_structure
|
||||
gst_rtsp_token_set_string
|
||||
gst_rtsp_token_get_string
|
||||
gst_rtsp_token_set_bool
|
||||
gst_rtsp_token_is_allowed
|
||||
<SUBSECTION Standard>
|
||||
GST_RTSP_TOKEN_CAST
|
||||
|
|
|
@ -165,6 +165,54 @@ gst_rtsp_token_new_valist (const gchar * firstfield, va_list var_args)
|
|||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_token_set_string:
|
||||
* @token: The #GstRTSPToken.
|
||||
* @field: field to set
|
||||
* @string_value: string value to set
|
||||
*
|
||||
* Sets a string value on @token.
|
||||
*
|
||||
* Since: 1.14
|
||||
*/
|
||||
void
|
||||
gst_rtsp_token_set_string (GstRTSPToken * token, const gchar * field,
|
||||
const gchar * string_value)
|
||||
{
|
||||
GstStructure *s;
|
||||
|
||||
g_return_if_fail (token != NULL);
|
||||
g_return_if_fail (field != NULL);
|
||||
g_return_if_fail (string_value != NULL);
|
||||
|
||||
s = gst_rtsp_token_writable_structure (token);
|
||||
if (s != NULL)
|
||||
gst_structure_set (s, field, G_TYPE_STRING, string_value, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_token_set_bool:
|
||||
* @token: The #GstRTSPToken.
|
||||
* @field: field to set
|
||||
* @bool_value: boolean value to set
|
||||
*
|
||||
* Sets a boolean value on @token.
|
||||
*
|
||||
* Since: 1.14
|
||||
*/
|
||||
void
|
||||
gst_rtsp_token_set_bool (GstRTSPToken * token, const gchar * field,
|
||||
gboolean bool_value)
|
||||
{
|
||||
GstStructure *s;
|
||||
|
||||
g_return_if_fail (token != NULL);
|
||||
g_return_if_fail (field != NULL);
|
||||
|
||||
s = gst_rtsp_token_writable_structure (token);
|
||||
if (s != NULL)
|
||||
gst_structure_set (s, field, G_TYPE_BOOLEAN, bool_value, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_token_get_structure:
|
||||
|
|
|
@ -89,13 +89,21 @@ const GstStructure * gst_rtsp_token_get_structure (GstRTSPToken *token);
|
|||
GST_EXPORT
|
||||
GstStructure * gst_rtsp_token_writable_structure (GstRTSPToken *token);
|
||||
|
||||
GST_EXPORT
|
||||
void gst_rtsp_token_set_string (GstRTSPToken * token,
|
||||
const gchar * field,
|
||||
const gchar * string_value);
|
||||
GST_EXPORT
|
||||
const gchar * gst_rtsp_token_get_string (GstRTSPToken *token,
|
||||
const gchar *field);
|
||||
|
||||
GST_EXPORT
|
||||
void gst_rtsp_token_set_bool (GstRTSPToken * token,
|
||||
const gchar * field,
|
||||
gboolean bool_value);
|
||||
GST_EXPORT
|
||||
gboolean gst_rtsp_token_is_allowed (GstRTSPToken *token,
|
||||
const gchar *field);
|
||||
|
||||
#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPToken, gst_rtsp_token_unref)
|
||||
#endif
|
||||
|
|
|
@ -78,6 +78,17 @@ GST_START_TEST (test_token)
|
|||
fail_unless (gst_rtsp_token_is_allowed (token, "permission1"));
|
||||
fail_unless (gst_rtsp_token_is_allowed (token, "permission2"));
|
||||
fail_unless_equals_string (gst_rtsp_token_get_string (token, "role"), "user");
|
||||
|
||||
gst_rtsp_token_set_bool (token, "permission3", FALSE);
|
||||
fail_unless (!gst_rtsp_token_is_allowed (token, "permission3"));
|
||||
gst_rtsp_token_set_bool (token, "permission4", TRUE);
|
||||
fail_unless (gst_rtsp_token_is_allowed (token, "permission4"));
|
||||
|
||||
fail_unless_equals_string (gst_rtsp_token_get_string (token, "role"), "user");
|
||||
gst_rtsp_token_set_string (token, "role", "admin");
|
||||
fail_unless_equals_string (gst_rtsp_token_get_string (token, "role"),
|
||||
"admin");
|
||||
|
||||
gst_rtsp_token_unref (token);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue