• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * Copyright (C) 2019 Collabora Ltd.
4  *   Author: Stéphane Cerveau <scerveau@collabora.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library (COPYING); if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 #ifndef __GST_XMLHELPER_H__
22 #define __GST_XMLHELPER_H__
23 
24 #include <libxml/parser.h>
25 #include <libxml/tree.h>
26 #include <gst/gst.h>
27 
28 G_BEGIN_DECLS
29 
30 typedef struct _GstXMLRange                  GstXMLRange;
31 typedef struct _GstXMLRatio                  GstXMLRatio;
32 typedef struct _GstXMLFrameRate              GstXMLFrameRate;
33 typedef struct _GstXMLConditionalUintType    GstXMLConditionalUintType;
34 
35 struct _GstXMLRange
36 {
37   guint64 first_byte_pos;
38   guint64 last_byte_pos;
39 };
40 
41 struct _GstXMLRatio
42 {
43   guint num;
44   guint den;
45 };
46 
47 struct _GstXMLFrameRate
48 {
49   guint num;
50   guint den;
51 };
52 
53 struct _GstXMLConditionalUintType
54 {
55   gboolean flag;
56   guint value;
57 };
58 
59 GstXMLRange *gst_xml_helper_clone_range (GstXMLRange * range);
60 GstXMLRatio *gst_xml_helper_clone_ratio (GstXMLRatio * ratio);
61 GstXMLFrameRate *gst_xml_helper_clone_frame_rate (GstXMLFrameRate * frameRate);
62 
63 /* XML property get method */
64 gboolean gst_xml_helper_get_prop_validated_string (xmlNode * a_node,
65     const gchar * property_name, gchar ** property_value,
66     gboolean (*validator) (const char *));
67 gboolean gst_xml_helper_get_prop_string (xmlNode * a_node,
68     const gchar * property_name, gchar ** property_value);
69 gboolean gst_xml_helper_get_prop_string_stripped (xmlNode * a_node,
70     const gchar * property_name, gchar ** property_value);
71 gboolean gst_xml_helper_get_ns_prop_string (xmlNode * a_node,
72     const gchar * ns_name, const gchar * property_name,
73     gchar ** property_value);
74 gboolean gst_xml_helper_get_prop_string_vector_type (xmlNode * a_node,
75     const gchar * property_name, gchar *** property_value);
76 gboolean gst_xml_helper_get_prop_signed_integer (xmlNode * a_node,
77     const gchar * property_name, gint default_val, gint * property_value);
78 gboolean gst_xml_helper_get_prop_unsigned_integer (xmlNode * a_node,
79     const gchar * property_name, guint default_val, guint * property_value);
80 gboolean gst_xml_helper_get_prop_unsigned_integer_64 (xmlNode *
81     a_node, const gchar * property_name, guint64 default_val,
82     guint64 * property_value);
83 gboolean gst_xml_helper_get_prop_uint_vector_type (xmlNode * a_node,
84     const gchar * property_name, guint ** property_value, guint * value_size);
85 gboolean gst_xml_helper_get_prop_double (xmlNode * a_node,
86     const gchar * property_name, gdouble * property_value);
87 gboolean gst_xml_helper_get_prop_boolean (xmlNode * a_node,
88     const gchar * property_name, gboolean default_val,
89     gboolean * property_value);
90 gboolean gst_xml_helper_get_prop_range (xmlNode * a_node,
91     const gchar * property_name, GstXMLRange ** property_value);
92 gboolean gst_xml_helper_get_prop_ratio (xmlNode * a_node,
93     const gchar * property_name, GstXMLRatio ** property_value);
94 gboolean gst_xml_helper_get_prop_framerate (xmlNode * a_node,
95     const gchar * property_name, GstXMLFrameRate ** property_value);
96 gboolean gst_xml_helper_get_prop_cond_uint (xmlNode * a_node,
97     const gchar * property_name, GstXMLConditionalUintType ** property_value);
98 gboolean gst_xml_helper_get_prop_dateTime (xmlNode * a_node,
99     const gchar * property_name, GstDateTime ** property_value);
100 gboolean gst_xml_helper_get_prop_duration (xmlNode * a_node,
101     const gchar * property_name, guint64 default_value,
102     guint64 * property_value);
103 gboolean gst_xml_helper_get_prop_string_no_whitespace (xmlNode * a_node,
104     const gchar * property_name, gchar ** property_value);
105 
106 /* XML node get method */
107 gboolean gst_xml_helper_get_node_content (xmlNode * a_node,
108     gchar ** content);
109 gchar *gst_xml_helper_get_node_namespace (xmlNode * a_node,
110     const gchar * prefix);
111 gboolean gst_xml_helper_get_node_as_string (xmlNode * a_node,
112     gchar ** content);
113 
114 /* XML property set method */
115 void gst_xml_helper_set_prop_string (xmlNodePtr node, const gchar * name, gchar* value);
116 void gst_xml_helper_set_prop_boolean (xmlNodePtr node, const gchar * name, gboolean value);
117 void gst_xml_helper_set_prop_int (xmlNodePtr root, const gchar * name, gint value);
118 void gst_xml_helper_set_prop_uint (xmlNodePtr root, const gchar * name, guint value);
119 void gst_xml_helper_set_prop_int64 (xmlNodePtr node, const gchar * name, gint64 value);
120 void gst_xml_helper_set_prop_uint64 (xmlNodePtr node, const gchar * name, guint64 value);
121 void gst_xml_helper_set_prop_uint_vector_type (xmlNode * a_node,  const gchar * name, guint * value, guint value_size);
122 void gst_xml_helper_set_prop_double (xmlNodePtr node, const gchar * name, gdouble value);
123 void gst_xml_helper_set_prop_date_time (xmlNodePtr node, const gchar * name, GstDateTime* value);
124 void gst_xml_helper_set_prop_duration (xmlNode * node, const gchar * name, guint64 value);
125 void gst_xml_helper_set_prop_ratio (xmlNodePtr node, const gchar * name, GstXMLRatio* value);
126 void gst_xml_helper_set_prop_framerate (xmlNodePtr node, const gchar * name, GstXMLFrameRate* value);
127 void gst_xml_helper_set_prop_range (xmlNodePtr node, const gchar * name, GstXMLRange* value);
128 void gst_xml_helper_set_prop_cond_uint (xmlNode * a_node, const gchar * property_name, GstXMLConditionalUintType * cond);
129 void gst_xml_helper_set_content (xmlNodePtr node, gchar * content);
130 
131 G_END_DECLS
132 #endif /* __GST_XMLHELPER_H__ */
133