Added a signal which notifies when a required dparam is added.
[platform/upstream/gstreamer.git] / libs / gst / control / dparammanager.h
1 /* GStreamer
2  * Copyright (C) 2001 Steve Baker <stevebaker_org@yahoo.co.uk>
3  *
4  * gstdparammanager.h: Dynamic Parameter group functionality
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 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; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef __GST_DPMAN_H__
23 #define __GST_DPMAN_H__
24
25 #include <gst/gstobject.h>
26 #include <gst/gstprops.h>
27 #include <gst/control/dparamcommon.h>
28 #include <gst/control/dparam.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 #define GST_TYPE_DPMAN                  (gst_dpman_get_type ())
35 #define GST_DPMAN(obj)                  (G_TYPE_CHECK_INSTANCE_CAST     ((obj), GST_TYPE_DPMAN,GstDParamManager))
36 #define GST_DPMAN_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST        ((klass), GST_TYPE_DPMAN,GstDParamManager))
37 #define GST_IS_DPMAN(obj)                       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DPMAN))
38 #define GST_IS_DPMAN_CLASS(obj)         (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DPMAN))
39
40 #define GST_DPMAN_NAME(dpman)                   (GST_OBJECT_NAME(dpman))
41 #define GST_DPMAN_PARENT(dpman)         (GST_OBJECT_PARENT(dpman))
42 #define GST_DPMAN_DPARAMS(dpman)                ((dpman)->dparams)
43 #define GST_DPMAN_DPARAMS_LIST(dpman)           ((dpman)->dparams_list)
44
45 #define GST_DPMAN_MODE_NAME(dpman)                               ((dpman)->mode_name)
46 #define GST_DPMAN_MODE(dpman)                            ((dpman)->mode)
47 #define GST_DPMAN_MODE_DATA(dpman)                               ((dpman)->mode_data)
48 #define GST_DPMAN_RATE(dpman)                            ((dpman)->rate)
49
50 typedef enum {
51   GST_DPMAN_CALLBACK,
52   GST_DPMAN_DIRECT,
53   GST_DPMAN_ARRAY,
54 } GstDPMUpdateMethod;
55
56 typedef struct _GstDParamManagerClass GstDParamManagerClass;
57 typedef struct _GstDPMMode GstDPMMode;
58 typedef struct _GstDParamWrapper GstDParamWrapper;
59
60 typedef guint (*GstDPMModePreProcessFunction) (GstDParamManager *dpman, guint frames, gint64 timestamp);
61 typedef guint (*GstDPMModeProcessFunction) (GstDParamManager *dpman, guint frame_count);
62 typedef void (*GstDPMModeSetupFunction) (GstDParamManager *dpman);
63 typedef void (*GstDPMModeTeardownFunction) (GstDParamManager *dpman);
64
65 typedef void (*GstDPMUpdateFunction) (GValue *value, gpointer data);
66
67 struct _GstDParamManager {
68         GstObject               object;
69
70         GHashTable *dparams;
71         GSList *dparams_list;
72         
73         gchar *mode_name;
74         GstDPMMode* mode;
75         gpointer mode_data;
76         
77         gint64 timestamp;
78         guint rate;
79 };
80
81 struct _GstDParamManagerClass {
82         GstObjectClass parent_class;
83         void (*new_required_dparam) (GstDParamManager *dpman, gchar* dparam_name);
84         GHashTable *modes;
85         /* signal callbacks */
86 };
87
88 struct _GstDPMMode {
89         GstDPMModePreProcessFunction preprocessfunc;
90         GstDPMModeProcessFunction processfunc;
91         GstDPMModeSetupFunction setupfunc;
92         GstDPMModeTeardownFunction teardownfunc;
93 };
94
95 struct _GstDParamWrapper {
96         GParamSpec* param_spec;
97         GValue *value;
98         GstDParam *dparam;
99         GstDPMUpdateMethod update_method;
100         gpointer update_data;
101         GstDPMUpdateFunction update_func;
102         gboolean is_log;
103         gboolean is_rate;
104 };
105
106 #define GST_DPMAN_PREPROCESSFUNC(dpman)         (((dpman)->mode)->preprocessfunc)
107 #define GST_DPMAN_PROCESSFUNC(dpman)            (((dpman)->mode)->processfunc)
108 #define GST_DPMAN_SETUPFUNC(dpman)              (((dpman)->mode)->setupfunc)
109 #define GST_DPMAN_TEARDOWNFUNC(dpman)           (((dpman)->mode)->teardownfunc)
110
111 #define GST_DPMAN_PREPROCESS(dpman, buffer_size, timestamp) \
112                                 (GST_DPMAN_PREPROCESSFUNC(dpman)(dpman, buffer_size, timestamp))
113
114 #define GST_DPMAN_PROCESS(dpman, frame_count) \
115                                 (GST_DPMAN_PROCESSFUNC(dpman)(dpman, frame_count))
116
117 #define GST_DPMAN_PROCESS_COUNTDOWN(dpman, frame_countdown, frame_count) \
118                                 (frame_countdown-- || \
119                                 (frame_countdown = GST_DPMAN_PROCESS(dpman, frame_count)))
120                                 
121 #define GST_DPMAN_DO_UPDATE(dpwrap) ((dpwrap->update_func)(dpwrap->value, dpwrap->update_data))
122
123 void _gst_dpman_initialize();
124 GType gst_dpman_get_type (void);
125 GstDParamManager* gst_dpman_new (gchar *name, GstElement *parent);
126 void gst_dpman_set_parent (GstDParamManager *dpman, GstElement *parent);
127 GstDParamManager* gst_dpman_get_manager (GstElement *parent);
128
129 gboolean gst_dpman_add_required_dparam_callback (GstDParamManager *dpman, 
130                                                  GParamSpec *param_spec,
131                                                  gboolean is_log,
132                                                  gboolean is_rate,
133                                                  GstDPMUpdateFunction update_func, 
134                                                  gpointer update_data);
135 gboolean gst_dpman_add_required_dparam_direct (GstDParamManager *dpman, 
136                                                GParamSpec *param_spec,
137                                                gboolean is_log,
138                                                gboolean is_rate,
139                                                gpointer update_data);
140                                                                               
141 gboolean gst_dpman_add_required_dparam_array (GstDParamManager *dpman, 
142                                               GParamSpec *param_spec,
143                                               gboolean is_log,
144                                               gboolean is_rate,
145                                               gpointer update_data);
146                                      
147 void gst_dpman_remove_required_dparam (GstDParamManager *dpman, gchar *dparam_name);
148 gboolean gst_dpman_attach_dparam (GstDParamManager *dpman, gchar *dparam_name, GstDParam *dparam);
149 void gst_dpman_detach_dparam (GstDParamManager *dpman, gchar *dparam_name);                         
150 GstDParam* gst_dpman_get_dparam(GstDParamManager *dpman, gchar *name);
151 GType gst_dpman_get_dparam_type (GstDParamManager *dpman, gchar *name);
152
153 GParamSpec** gst_dpman_list_param_specs(GstDParamManager *dpman);
154 GParamSpec* gst_dpman_get_param_spec (GstDParamManager *dpman, gchar *dparam_name);
155 void gst_dpman_dparam_spec_has_changed (GstDParamManager *dpman, gchar *dparam_name);
156
157 void gst_dpman_set_rate_change_pad(GstDParamManager *dpman, GstPad *pad);
158 void gst_dpman_bypass_dparam(GstDParamManager *dpman, gchar *dparam_name);
159
160 gboolean gst_dpman_set_mode(GstDParamManager *dpman, gchar *modename);
161 void gst_dpman_register_mode (GstDParamManagerClass *klass,
162                            gchar *modename, 
163                            GstDPMModePreProcessFunction preprocessfunc,
164                            GstDPMModeProcessFunction processfunc,
165                            GstDPMModeSetupFunction setupfunc,
166                            GstDPMModeTeardownFunction teardownfunc);
167
168 #ifdef __cplusplus
169 }
170 #endif /* __cplusplus */
171
172 #endif /* __GST_DPMAN_H__ */