add gst_props_get_float function
[platform/upstream/gstreamer.git] / gst / gstprops.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstprops.h: Header for properties subsystem
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23
24 #ifndef __GST_PROPS_H__
25 #define __GST_PROPS_H__
26
27 #include <glib.h>
28 #include <parser.h> // NOTE: this is xml-config's fault
29
30 // Include compatability defines: if libxml hasn't already defined these,
31 // we have an old version 1.x
32 #ifndef xmlChildrenNode
33 #define xmlChildrenNode childs
34 #define xmlRootNode root
35 #endif
36
37
38 typedef struct _GstProps GstProps;
39
40 typedef enum {
41    GST_PROPS_END_ID = 0,
42    GST_PROPS_LIST_ID,
43    GST_PROPS_INT_ID,
44    GST_PROPS_INT_RANGE_ID,
45    GST_PROPS_FLOAT_ID,
46    GST_PROPS_FLOAT_RANGE_ID,
47    GST_PROPS_FOURCC_ID,
48    GST_PROPS_BOOL_ID,
49    GST_PROPS_STRING_ID,
50    GST_PROPS_LAST_ID = GST_PROPS_END_ID + 16,
51 } GstPropsId;
52
53 #define GST_MAKE_FOURCC(a,b,c,d)        ((a)|(b)<<8|(c)<<16|(d)<<24)
54 #define GST_STR_FOURCC(f)               (((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
55
56 #define GST_PROPS_LIST(a...)            GST_PROPS_LIST_ID,##a,NULL
57 #define GST_PROPS_INT(a)                GST_PROPS_INT_ID,(a)
58 #define GST_PROPS_INT_RANGE(a,b)        GST_PROPS_INT_RANGE_ID,(a),(b)
59 #define GST_PROPS_FLOAT(a)              GST_PROPS_FLOAT_ID,(a)
60 #define GST_PROPS_FLOAT_RANGE(a,b)      GST_PROPS_FLOAT_RANGE_ID,(a),(b)
61 #define GST_PROPS_FOURCC(a)             GST_PROPS_FOURCC_ID,(a)
62 #define GST_PROPS_BOOLEAN(a)            GST_PROPS_BOOL_ID,(a)
63 #define GST_PROPS_STRING(a)             GST_PROPS_STRING_ID,(a)
64
65
66 struct _GstProps {
67   gint refcount;
68   GMutex *lock;
69
70   GList *properties;            /* real properties for this property */
71 };
72
73 /* initialize the subsystem */
74 void            _gst_props_initialize           (void);
75
76 GstProps*       gst_props_new                   (const gchar *firstname, ...);
77 GstProps*       gst_props_newv                  (const gchar *firstname, va_list var_args);
78
79 void            gst_props_unref                 (GstProps *props);
80 void            gst_props_ref                   (GstProps *props);
81 void            gst_props_destroy               (GstProps *props);
82
83 GstProps*       gst_props_copy                  (GstProps *props);
84 GstProps*       gst_props_copy_on_write         (GstProps *props);
85
86 GstProps*       gst_props_merge                 (GstProps *props, GstProps *tomerge);
87
88 gboolean        gst_props_check_compatibility   (GstProps *fromprops, GstProps *toprops);
89
90 GstProps*       gst_props_set                   (GstProps *props, const gchar *name, ...);
91
92 gint            gst_props_get_int               (GstProps *props, const gchar *name);
93 gfloat          gst_props_get_float             (GstProps *props, const gchar *name);
94 gulong          gst_props_get_fourcc_int        (GstProps *props, const gchar *name);
95 gboolean        gst_props_get_boolean           (GstProps *props, const gchar *name);
96 const gchar*    gst_props_get_string            (GstProps *props, const gchar *name);
97
98 xmlNodePtr      gst_props_save_thyself          (GstProps *props, xmlNodePtr parent);
99 GstProps*       gst_props_load_thyself          (xmlNodePtr parent);
100
101 #endif /* __GST_PROPS_H__ */