Fix FSF address
[platform/upstream/gstreamer.git] / gst-libs / gst / video / videoorientation.c
1 /* GStreamer
2  * Copyright (C) 2006 Nokia <stefan.kost@nokia.com>
3  *
4  * videoorientation.c: video flipping and centering interface
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., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 #include "videoorientation.h"
27
28 #include <string.h>
29
30 /**
31  * SECTION:gstvideoorientation
32  * @short_description: Interface for elements providing video orientation
33  * controls
34  *
35  * The interface allows unified access to control flipping and autocenter
36  * operation of video-sources or operators.
37  */
38
39 /* FIXME 0.11: check if we need to add API for sometimes-supportedness
40  * (aka making up for GstImplementsInterface removal) (probably yes) */
41
42 static void gst_video_orientation_iface_init (GstVideoOrientationInterface *
43     iface);
44
45 GType
46 gst_video_orientation_get_type (void)
47 {
48   static GType gst_video_orientation_type = 0;
49
50   if (!gst_video_orientation_type) {
51     static const GTypeInfo gst_video_orientation_info = {
52       sizeof (GstVideoOrientationInterface),
53       (GBaseInitFunc) gst_video_orientation_iface_init,
54       NULL,
55       NULL,
56       NULL,
57       NULL,
58       0,
59       0,
60       NULL,
61     };
62
63     gst_video_orientation_type = g_type_register_static (G_TYPE_INTERFACE,
64         "GstVideoOrientation", &gst_video_orientation_info, 0);
65   }
66
67   return gst_video_orientation_type;
68 }
69
70 static void
71 gst_video_orientation_iface_init (GstVideoOrientationInterface * iface)
72 {
73   /* default virtual functions */
74
75   iface->get_hflip = NULL;
76   iface->get_vflip = NULL;
77   iface->get_hcenter = NULL;
78   iface->get_vcenter = NULL;
79
80   iface->set_hflip = NULL;
81   iface->set_vflip = NULL;
82   iface->set_hcenter = NULL;
83   iface->set_vcenter = NULL;
84 }
85
86 /**
87  * gst_video_orientation_get_hflip:
88  * @video_orientation: #GstVideoOrientation interface of a #GstElement
89  * @flip: return location for the result
90  *
91  * Get the horizontal flipping state (%TRUE for flipped) from the given object.
92  * Returns: %TRUE in case the element supports flipping
93  */
94 gboolean
95 gst_video_orientation_get_hflip (GstVideoOrientation * video_orientation,
96     gboolean * flip)
97 {
98   GstVideoOrientationInterface *iface =
99       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
100
101   if (iface->get_hflip) {
102     return iface->get_hflip (video_orientation, flip);
103   }
104   return FALSE;
105 }
106
107 /**
108  * gst_video_orientation_get_vflip:
109  * @video_orientation: #GstVideoOrientation interface of a #GstElement
110  * @flip: return location for the result
111  *
112  * Get the vertical flipping state (%TRUE for flipped) from the given object.
113  * Returns: %TRUE in case the element supports flipping
114  */
115 gboolean
116 gst_video_orientation_get_vflip (GstVideoOrientation * video_orientation,
117     gboolean * flip)
118 {
119   GstVideoOrientationInterface *iface =
120       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
121
122   if (iface->get_vflip) {
123     return iface->get_vflip (video_orientation, flip);
124   }
125   return FALSE;
126 }
127
128 /**
129  * gst_video_orientation_get_hcenter:
130  * @video_orientation: #GstVideoOrientation interface of a #GstElement
131  * @center: return location for the result
132  *
133  * Get the horizontal centering offset from the given object.
134  * Returns: %TRUE in case the element supports centering
135  */
136 gboolean
137 gst_video_orientation_get_hcenter (GstVideoOrientation * video_orientation,
138     gint * center)
139 {
140   GstVideoOrientationInterface *iface =
141       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
142
143   if (iface->get_hcenter) {
144     return iface->get_hcenter (video_orientation, center);
145   }
146   return FALSE;
147 }
148
149 /**
150  * gst_video_orientation_get_vcenter:
151  * @video_orientation: #GstVideoOrientation interface of a #GstElement
152  * @center: return location for the result
153  *
154  * Get the vertical centering offset from the given object.
155  * Returns: %TRUE in case the element supports centering
156  */
157 gboolean
158 gst_video_orientation_get_vcenter (GstVideoOrientation * video_orientation,
159     gint * center)
160 {
161   GstVideoOrientationInterface *iface =
162       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
163
164   if (iface->get_vcenter) {
165     return iface->get_vcenter (video_orientation, center);
166   }
167   return FALSE;
168 }
169
170 /**
171  * gst_video_orientation_set_hflip:
172  * @video_orientation: #GstVideoOrientation interface of a #GstElement
173  * @flip: use flipping
174  *
175  * Set the horizontal flipping state (%TRUE for flipped) for the given object.
176  * Returns: %TRUE in case the element supports flipping
177  */
178 gboolean
179 gst_video_orientation_set_hflip (GstVideoOrientation * video_orientation,
180     gboolean flip)
181 {
182   GstVideoOrientationInterface *iface =
183       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
184
185   if (iface->set_hflip) {
186     return iface->set_hflip (video_orientation, flip);
187   }
188   return FALSE;
189 }
190
191 /**
192  * gst_video_orientation_set_vflip:
193  * @video_orientation: #GstVideoOrientation interface of a #GstElement
194  * @flip: use flipping
195  *
196  * Set the vertical flipping state (%TRUE for flipped) for the given object.
197  * Returns: %TRUE in case the element supports flipping
198  */
199 gboolean
200 gst_video_orientation_set_vflip (GstVideoOrientation * video_orientation,
201     gboolean flip)
202 {
203   GstVideoOrientationInterface *iface =
204       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
205
206   if (iface->set_vflip) {
207     return iface->set_vflip (video_orientation, flip);
208   }
209   return FALSE;
210 }
211
212 /**
213  * gst_video_orientation_set_hcenter:
214  * @video_orientation: #GstVideoOrientation interface of a #GstElement
215  * @center: centering offset
216  *
217  * Set the horizontal centering offset for the given object.
218  * Returns: %TRUE in case the element supports centering
219  */
220 gboolean
221 gst_video_orientation_set_hcenter (GstVideoOrientation * video_orientation,
222     gint center)
223 {
224   GstVideoOrientationInterface *iface =
225       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
226
227   if (iface->set_hcenter) {
228     return iface->set_hcenter (video_orientation, center);
229   }
230   return FALSE;
231 }
232
233 /**
234  * gst_video_orientation_set_vcenter:
235  * @video_orientation: #GstVideoOrientation interface of a #GstElement
236  * @center: centering offset
237  *
238  * Set the vertical centering offset for the given object.
239  * Returns: %TRUE in case the element supports centering
240  */
241 gboolean
242 gst_video_orientation_set_vcenter (GstVideoOrientation * video_orientation,
243     gint center)
244 {
245   GstVideoOrientationInterface *iface =
246       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
247
248   if (iface->set_vcenter) {
249     return iface->set_vcenter (video_orientation, center);
250   }
251   return FALSE;
252 }