controller: rename new cubic interpolation mode
[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., 51 Franklin St, Fifth Floor,
22  * Boston, MA 02110-1301, 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 typedef struct _GstControlPoint GstControlPoint;
52
53 /**
54  * GstControlPoint:
55  * @timestamp: timestamp of the value change
56  * @value: the new value
57  *
58  * An internal structure for value+time and various temporary
59  * values used for interpolation. This "inherits" from
60  * GstTimedValue.
61  */
62 struct _GstControlPoint
63 {
64   /* fields from GstTimedValue. DO NOT CHANGE! */
65   GstClockTime timestamp;
66   gdouble value;
67
68   /*< private >*/
69
70   /* Caches for the interpolators */
71   /* FIXME: we should not have this here already ... */
72   union {
73     struct { /* 16 bytes */
74       gdouble h;
75       gdouble z;
76     } cubic;
77     struct { /* 24 bytes */
78       gdouble c1s, c2s, c3s;
79     } cubic_monotonic;
80     guint8 _gst_reserved[64];
81   } cache;
82 };
83
84 GType gst_control_point_get_type (void);
85
86 /**
87  * GstTimedValueControlSource:
88  *
89  * The instance structure of #GstControlSource.
90  */
91 struct _GstTimedValueControlSource {
92   GstControlSource parent;
93
94   /*< protected >*/
95   GMutex lock;
96
97   GSequence *values;            /* List of GstControlPoint */
98   gint nvalues;                 /* Number of control points */
99   gboolean valid_cache;
100
101   /*< private >*/
102   GstTimedValueControlSourcePrivate *priv;
103   gpointer _gst_reserved[GST_PADDING];
104 };
105
106 struct _GstTimedValueControlSourceClass {
107   GstControlSourceClass parent_class;
108
109   /*< private >*/
110   gpointer _gst_reserved[GST_PADDING];
111 };
112
113 #define GST_TIMED_VALUE_CONTROL_SOURCE_LOCK(o) \
114   g_mutex_lock(&((GstTimedValueControlSource *)o)->lock)
115 #define GST_TIMED_VALUE_CONTROL_SOURCE_UNLOCK(o) \
116   g_mutex_unlock(&((GstTimedValueControlSource *)o)->lock)
117
118 GType gst_timed_value_control_source_get_type (void);
119
120 /* Functions */
121
122 GSequenceIter * gst_timed_value_control_source_find_control_point_iter (
123                                                                GstTimedValueControlSource * self,
124                                                                GstClockTime timestamp);
125
126 gboolean        gst_timed_value_control_source_set            (GstTimedValueControlSource * self,
127                                                                GstClockTime timestamp,
128                                                                const gdouble value);
129 gboolean        gst_timed_value_control_source_set_from_list  (GstTimedValueControlSource * self,
130                                                                const GSList * timedvalues);
131 gboolean        gst_timed_value_control_source_unset          (GstTimedValueControlSource * self,
132                                                                GstClockTime timestamp);
133 void            gst_timed_value_control_source_unset_all      (GstTimedValueControlSource *self);
134 GList *         gst_timed_value_control_source_get_all        (GstTimedValueControlSource * self);
135 gint            gst_timed_value_control_source_get_count      (GstTimedValueControlSource * self);
136 void            gst_timed_value_control_invalidate_cache      (GstTimedValueControlSource * self);
137
138 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
139 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTimedValueControlSource, gst_object_unref)
140 #endif
141
142 G_END_DECLS
143
144 #endif /* __GST_TIMED_VALUE_CONTROL_SOURCE_H__ */