index: remove GstIndex and GstIndexFactory for now
[platform/upstream/gstreamer.git] / libs / gst / controller / gsttimedvaluecontrolsource.h
1 /* GStreamer
2  *
3  * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
4  *               2011 Stefan Sauer <ensonic@users.sf.net>
5  *
6  * gsttimedvaluecontrolsource.h: Base class for timeed value based control
7  *                               sources
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24
25 #ifndef __GST_TIMED_VALUE_CONTROL_SOURCE_H__
26 #define __GST_TIMED_VALUE_CONTROL_SOURCE_H__
27
28 #include <glib-object.h>
29 #include <gst/gst.h>
30
31 #include <gst/gstcontrolsource.h>
32
33 G_BEGIN_DECLS
34
35 #define GST_TYPE_TIMED_VALUE_CONTROL_SOURCE \
36   (gst_timed_value_control_source_get_type ())
37 #define GST_TIMED_VALUE_CONTROL_SOURCE(obj) \
38   (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TIMED_VALUE_CONTROL_SOURCE, GstTimedValueControlSource))
39 #define GST_TIMED_VALUE_CONTROL_SOURCE_CLASS(vtable) \
40   (G_TYPE_CHECK_CLASS_CAST ((vtable), GST_TYPE_TIMED_VALUE_CONTROL_SOURCE, GstTimedValueControlSourceClass))
41 #define GST_IS_TIMED_VALUE_CONTROL_SOURCE(obj) \
42   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TIMED_VALUE_CONTROL_SOURCE))
43 #define GST_IS_TIMED_VALUE_CONTROL_SOURCE_CLASS(vtable) \
44   (G_TYPE_CHECK_CLASS_TYPE ((vtable), GST_TYPE_TIMED_VALUE_CONTROL_SOURCE))
45 #define GST_TIMED_VALUE_CONTROL_SOURCE_GET_CLASS(inst) \
46   (G_TYPE_INSTANCE_GET_CLASS ((inst), GST_TYPE_TIMED_VALUE_CONTROL_SOURCE, GstTimedValueControlSourceClass))
47
48 typedef struct _GstTimedValueControlSource GstTimedValueControlSource;
49 typedef struct _GstTimedValueControlSourceClass GstTimedValueControlSourceClass;
50 typedef struct _GstTimedValueControlSourcePrivate GstTimedValueControlSourcePrivate;
51
52 /**
53  * GstControlPoint:
54  *
55  * a internal structure for value+time and various temporary
56  * values used for interpolation. This "inherits" from
57  * GstTimedValue.
58  */
59 typedef struct _GstControlPoint
60 {
61   /* fields from GstTimedValue. DO NOT CHANGE! */
62   GstClockTime timestamp;       /* timestamp of the value change */
63   gdouble value;                /* the new value */
64
65   /* internal fields */
66
67   /* Caches for the interpolators */
68   // FIXME: we should not have this here already ...
69   union {
70     struct {
71       gdouble h;
72       gdouble z;
73     } cubic;
74   } cache;
75
76 } GstControlPoint;
77
78 /**
79  * GstTimedValueControlSource:
80  *
81  * The instance structure of #GstControlSource.
82  */
83 struct _GstTimedValueControlSource {
84   GstControlSource parent;
85
86   /*< protected >*/
87   GMutex *lock;
88
89   GSequence *values;            /* List of GstControlPoint */
90   gint nvalues;                 /* Number of control points */
91   gboolean valid_cache;
92
93   GstTimedValueControlSourcePrivate *priv;
94   gpointer _gst_reserved[GST_PADDING];
95 };
96
97 struct _GstTimedValueControlSourceClass {
98   GstControlSourceClass parent_class;
99
100   /*< private >*/
101   gpointer _gst_reserved[GST_PADDING];
102 };
103
104 #define GST_TIMED_VALUE_CONTROL_SOURCE_LOCK(o) \
105   g_mutex_lock(((GstTimedValueControlSource *)o)->lock)
106 #define GST_TIMED_VALUE_CONTROL_SOURCE_UNLOCK(o) \
107   g_mutex_unlock(((GstTimedValueControlSource *)o)->lock)
108
109 GType gst_timed_value_control_source_get_type (void);
110
111 /* Functions */
112
113 GSequenceIter * gst_timed_value_control_source_find_control_point_iter (
114                                                                GstTimedValueControlSource * self, 
115                                                                GstClockTime timestamp);
116
117 gboolean        gst_timed_value_control_source_set            (GstTimedValueControlSource * self,
118                                                                GstClockTime timestamp,
119                                                                const gdouble value);
120 gboolean        gst_timed_value_control_source_set_from_list  (GstTimedValueControlSource * self,
121                                                                const GSList * timedvalues);
122 gboolean        gst_timed_value_control_source_unset          (GstTimedValueControlSource * self,
123                                                                GstClockTime timestamp);
124 void            gst_timed_value_control_source_unset_all      (GstTimedValueControlSource *self);
125 GList *         gst_timed_value_control_source_get_all        (GstTimedValueControlSource * self);
126 gint            gst_timed_value_control_source_get_count      (GstTimedValueControlSource * self);
127 void            gst_timed_value_control_invalidate_cache      (GstTimedValueControlSource * self);
128
129 G_END_DECLS
130
131 #endif /* __GST_TIMED_VALUE_CONTROL_SOURCE_H__ */