• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * @title: GstVideoOrientation
33  * @short_description: Interface for elements providing video orientation
34  * controls
35  *
36  * The interface allows unified access to control flipping and autocenter
37  * operation of video-sources or operators.
38  */
39 
40 /* FIXME 0.11: check if we need to add API for sometimes-supportedness
41  * (aka making up for GstImplementsInterface removal) (probably yes) */
42 
43 G_DEFINE_INTERFACE (GstVideoOrientation, gst_video_orientation, 0)
44 
45      static void
gst_video_orientation_default_init(GstVideoOrientationInterface * iface)46          gst_video_orientation_default_init (GstVideoOrientationInterface *
47     iface)
48 {
49   /* default virtual functions */
50 
51   iface->get_hflip = NULL;
52   iface->get_vflip = NULL;
53   iface->get_hcenter = NULL;
54   iface->get_vcenter = NULL;
55 
56   iface->set_hflip = NULL;
57   iface->set_vflip = NULL;
58   iface->set_hcenter = NULL;
59   iface->set_vcenter = NULL;
60 }
61 
62 /**
63  * gst_video_orientation_get_hflip:
64  * @video_orientation: #GstVideoOrientation interface of a #GstElement
65  * @flip: (out): return location for the result
66  *
67  * Get the horizontal flipping state (%TRUE for flipped) from the given object.
68  * Returns: %TRUE in case the element supports flipping
69  */
70 gboolean
gst_video_orientation_get_hflip(GstVideoOrientation * video_orientation,gboolean * flip)71 gst_video_orientation_get_hflip (GstVideoOrientation * video_orientation,
72     gboolean * flip)
73 {
74   GstVideoOrientationInterface *iface =
75       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
76 
77   if (iface->get_hflip) {
78     return iface->get_hflip (video_orientation, flip);
79   }
80   return FALSE;
81 }
82 
83 /**
84  * gst_video_orientation_get_vflip:
85  * @video_orientation: #GstVideoOrientation interface of a #GstElement
86  * @flip: (out): return location for the result
87  *
88  * Get the vertical flipping state (%TRUE for flipped) from the given object.
89  * Returns: %TRUE in case the element supports flipping
90  */
91 gboolean
gst_video_orientation_get_vflip(GstVideoOrientation * video_orientation,gboolean * flip)92 gst_video_orientation_get_vflip (GstVideoOrientation * video_orientation,
93     gboolean * flip)
94 {
95   GstVideoOrientationInterface *iface =
96       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
97 
98   if (iface->get_vflip) {
99     return iface->get_vflip (video_orientation, flip);
100   }
101   return FALSE;
102 }
103 
104 /**
105  * gst_video_orientation_get_hcenter:
106  * @video_orientation: #GstVideoOrientation interface of a #GstElement
107  * @center: (out): return location for the result
108  *
109  * Get the horizontal centering offset from the given object.
110  * Returns: %TRUE in case the element supports centering
111  */
112 gboolean
gst_video_orientation_get_hcenter(GstVideoOrientation * video_orientation,gint * center)113 gst_video_orientation_get_hcenter (GstVideoOrientation * video_orientation,
114     gint * center)
115 {
116   GstVideoOrientationInterface *iface =
117       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
118 
119   if (iface->get_hcenter) {
120     return iface->get_hcenter (video_orientation, center);
121   }
122   return FALSE;
123 }
124 
125 /**
126  * gst_video_orientation_get_vcenter:
127  * @video_orientation: #GstVideoOrientation interface of a #GstElement
128  * @center: (out): return location for the result
129  *
130  * Get the vertical centering offset from the given object.
131  * Returns: %TRUE in case the element supports centering
132  */
133 gboolean
gst_video_orientation_get_vcenter(GstVideoOrientation * video_orientation,gint * center)134 gst_video_orientation_get_vcenter (GstVideoOrientation * video_orientation,
135     gint * center)
136 {
137   GstVideoOrientationInterface *iface =
138       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
139 
140   if (iface->get_vcenter) {
141     return iface->get_vcenter (video_orientation, center);
142   }
143   return FALSE;
144 }
145 
146 /**
147  * gst_video_orientation_set_hflip:
148  * @video_orientation: #GstVideoOrientation interface of a #GstElement
149  * @flip: use flipping
150  *
151  * Set the horizontal flipping state (%TRUE for flipped) for the given object.
152  * Returns: %TRUE in case the element supports flipping
153  */
154 gboolean
gst_video_orientation_set_hflip(GstVideoOrientation * video_orientation,gboolean flip)155 gst_video_orientation_set_hflip (GstVideoOrientation * video_orientation,
156     gboolean flip)
157 {
158   GstVideoOrientationInterface *iface =
159       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
160 
161   if (iface->set_hflip) {
162     return iface->set_hflip (video_orientation, flip);
163   }
164   return FALSE;
165 }
166 
167 /**
168  * gst_video_orientation_set_vflip:
169  * @video_orientation: #GstVideoOrientation interface of a #GstElement
170  * @flip: use flipping
171  *
172  * Set the vertical flipping state (%TRUE for flipped) for the given object.
173  * Returns: %TRUE in case the element supports flipping
174  */
175 gboolean
gst_video_orientation_set_vflip(GstVideoOrientation * video_orientation,gboolean flip)176 gst_video_orientation_set_vflip (GstVideoOrientation * video_orientation,
177     gboolean flip)
178 {
179   GstVideoOrientationInterface *iface =
180       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
181 
182   if (iface->set_vflip) {
183     return iface->set_vflip (video_orientation, flip);
184   }
185   return FALSE;
186 }
187 
188 /**
189  * gst_video_orientation_set_hcenter:
190  * @video_orientation: #GstVideoOrientation interface of a #GstElement
191  * @center: centering offset
192  *
193  * Set the horizontal centering offset for the given object.
194  * Returns: %TRUE in case the element supports centering
195  */
196 gboolean
gst_video_orientation_set_hcenter(GstVideoOrientation * video_orientation,gint center)197 gst_video_orientation_set_hcenter (GstVideoOrientation * video_orientation,
198     gint center)
199 {
200   GstVideoOrientationInterface *iface =
201       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
202 
203   if (iface->set_hcenter) {
204     return iface->set_hcenter (video_orientation, center);
205   }
206   return FALSE;
207 }
208 
209 /**
210  * gst_video_orientation_set_vcenter:
211  * @video_orientation: #GstVideoOrientation interface of a #GstElement
212  * @center: centering offset
213  *
214  * Set the vertical centering offset for the given object.
215  * Returns: %TRUE in case the element supports centering
216  */
217 gboolean
gst_video_orientation_set_vcenter(GstVideoOrientation * video_orientation,gint center)218 gst_video_orientation_set_vcenter (GstVideoOrientation * video_orientation,
219     gint center)
220 {
221   GstVideoOrientationInterface *iface =
222       GST_VIDEO_ORIENTATION_GET_INTERFACE (video_orientation);
223 
224   if (iface->set_vcenter) {
225     return iface->set_vcenter (video_orientation, center);
226   }
227   return FALSE;
228 }
229