2 * Copyright (C) 2010 Wim Taymans <wim.taymans at gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include "rtsp-token.h"
24 typedef struct _GstRTSPTokenImpl
28 GstStructure *structure;
31 #define GST_RTSP_TOKEN_STRUCTURE(t) (((GstRTSPTokenImpl *)(t))->structure)
33 //GST_DEBUG_CATEGORY_STATIC (rtsp_token_debug);
34 //#define GST_CAT_DEFAULT rtsp_token_debug
36 GST_DEFINE_MINI_OBJECT_TYPE (GstRTSPToken, gst_rtsp_token);
38 static void gst_rtsp_token_init (GstRTSPTokenImpl * token,
39 GstStructure * structure);
42 _gst_rtsp_token_free (GstRTSPToken * token)
44 GstRTSPTokenImpl *impl = (GstRTSPTokenImpl *) token;
46 gst_structure_set_parent_refcount (impl->structure, NULL);
47 gst_structure_free (impl->structure);
49 g_slice_free1 (sizeof (GstRTSPTokenImpl), token);
53 _gst_rtsp_token_copy (GstRTSPTokenImpl * token)
55 GstRTSPTokenImpl *copy;
56 GstStructure *structure;
58 structure = gst_structure_copy (token->structure);
60 copy = g_slice_new0 (GstRTSPTokenImpl);
61 gst_rtsp_token_init (copy, structure);
63 return (GstRTSPToken *) copy;
67 gst_rtsp_token_init (GstRTSPTokenImpl * token, GstStructure * structure)
69 gst_mini_object_init (GST_MINI_OBJECT_CAST (token), 0,
71 (GstMiniObjectCopyFunction) _gst_rtsp_token_copy, NULL,
72 (GstMiniObjectFreeFunction) _gst_rtsp_token_free);
74 token->structure = structure;
75 gst_structure_set_parent_refcount (token->structure,
76 &token->token.mini_object.refcount);
82 * Create a new empty Authorization token.
84 * Returns: (transfer full): a new empty authorization token.
87 gst_rtsp_token_new (void)
89 GstRTSPTokenImpl *token;
91 token = g_slice_new0 (GstRTSPTokenImpl);
93 gst_rtsp_token_init (token, gst_structure_new_empty ("GstRTSPToken"));
95 return (GstRTSPToken *) token;
100 * gst_rtsp_token_get_structure:
101 * @token: The #GstRTSPToken.
103 * Access the structure of the token.
105 * Returns: The structure of the token. The structure is still
106 * owned by the token, which means that you should not free it and
107 * that the pointer becomes invalid when you free the token.
112 gst_rtsp_token_get_structure (GstRTSPToken * token)
114 g_return_val_if_fail (GST_IS_RTSP_TOKEN (token), NULL);
116 return GST_RTSP_TOKEN_STRUCTURE (token);
120 * gst_rtsp_token_writable_structure:
121 * @token: The #GstRTSPToken.
123 * Get a writable version of the structure.
125 * Returns: The structure of the token. The structure is still
126 * owned by the token, which means that you should not free it and
127 * that the pointer becomes invalid when you free the token.
128 * This function checks if @token is writable and will never return NULL.
133 gst_rtsp_token_writable_structure (GstRTSPToken * token)
135 g_return_val_if_fail (GST_IS_RTSP_TOKEN (token), NULL);
136 g_return_val_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST
139 return GST_RTSP_TOKEN_STRUCTURE (token);
143 * gst_rtsp_token_get_string:
144 * @token: a #GstRTSPToken
145 * @field: a field name
147 * Get the string value of @field in @token.
149 * Returns: the string value of @field in @token or NULL when @field is not
153 gst_rtsp_token_get_string (GstRTSPToken * token, const gchar * field)
155 return gst_structure_get_string (GST_RTSP_TOKEN_STRUCTURE (token), field);