Fix FSF address
[platform/upstream/gstreamer.git] / gst-libs / gst / video / navigation.h
1 /* GStreamer Navigation
2  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
3  * Copyright (C) 2003 David A. Schleef <ds@schleef.org>
4  *
5  * navigation.h: navigation interface design
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef __GST_NAVIGATION_H__
24 #define __GST_NAVIGATION_H__
25
26 #include <gst/gst.h>
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_NAVIGATION \
31   (gst_navigation_get_type ())
32 #define GST_NAVIGATION(obj) \
33     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_NAVIGATION, GstNavigation))
34 #define GST_IS_NAVIGATION(obj) \
35       (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_NAVIGATION))
36 #define GST_NAVIGATION_GET_INTERFACE(obj) \
37     (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GST_TYPE_NAVIGATION, GstNavigationInterface))
38
39 typedef struct _GstNavigation GstNavigation;
40 typedef struct _GstNavigationInterface GstNavigationInterface;
41
42 /**
43  * GstNavigationInterface:
44  * @iface: the parent interface
45  * @send_event: sending a navigation event
46  *
47  * Navigation interface.
48  */
49 struct _GstNavigationInterface {
50   GTypeInterface iface;
51
52   /* virtual functions */
53   void (*send_event) (GstNavigation *navigation, GstStructure *structure);
54 };
55
56 GType           gst_navigation_get_type (void);
57
58 /* Navigation commands */
59
60 /**
61  * GstNavigationCommand:
62  * @GST_NAVIGATION_COMMAND_INVALID: An invalid command entry
63  * @GST_NAVIGATION_COMMAND_MENU1: Execute navigation menu command 1. For DVD,
64  * this enters the DVD root menu, or exits back to the title from the menu.
65  * @GST_NAVIGATION_COMMAND_MENU2: Execute navigation menu command 2. For DVD,
66  * this jumps to the DVD title menu.
67  * @GST_NAVIGATION_COMMAND_MENU3: Execute navigation menu command 3. For DVD,
68  * this jumps into the DVD root menu.
69  * @GST_NAVIGATION_COMMAND_MENU4: Execute navigation menu command 4. For DVD,
70  * this jumps to the Subpicture menu.
71  * @GST_NAVIGATION_COMMAND_MENU5: Execute navigation menu command 5. For DVD,
72  * the jumps to the audio menu.
73  * @GST_NAVIGATION_COMMAND_MENU6: Execute navigation menu command 6. For DVD,
74  * this jumps to the angles menu.
75  * @GST_NAVIGATION_COMMAND_MENU7: Execute navigation menu command 7. For DVD,
76  * this jumps to the chapter menu.
77  * @GST_NAVIGATION_COMMAND_LEFT: Select the next button to the left in a menu,
78  * if such a button exists.
79  * @GST_NAVIGATION_COMMAND_RIGHT: Select the next button to the right in a menu,
80  * if such a button exists.
81  * @GST_NAVIGATION_COMMAND_UP: Select the button above the current one in a
82  * menu, if such a button exists.
83  * @GST_NAVIGATION_COMMAND_DOWN: Select the button below the current one in a
84  * menu, if such a button exists.
85  * @GST_NAVIGATION_COMMAND_ACTIVATE: Activate (click) the currently selected
86  * button in a menu, if such a button exists.
87  * @GST_NAVIGATION_COMMAND_PREV_ANGLE: Switch to the previous angle in a
88  * multiangle feature.
89  * @GST_NAVIGATION_COMMAND_NEXT_ANGLE: Switch to the next angle in a multiangle
90  * feature.
91  *
92  * A set of commands that may be issued to an element providing the
93  * #GstNavigation interface. The available commands can be queried via
94  * the gst_navigation_query_new_commands() query.
95  *
96  * For convenience in handling DVD navigation, the MENU commands are aliased as:
97  *    GST_NAVIGATION_COMMAND_DVD_MENU            = @GST_NAVIGATION_COMMAND_MENU1
98  *    GST_NAVIGATION_COMMAND_DVD_TITLE_MENU      = @GST_NAVIGATION_COMMAND_MENU2
99  *    GST_NAVIGATION_COMMAND_DVD_ROOT_MENU       = @GST_NAVIGATION_COMMAND_MENU3
100  *    GST_NAVIGATION_COMMAND_DVD_SUBPICTURE_MENU = @GST_NAVIGATION_COMMAND_MENU4
101  *    GST_NAVIGATION_COMMAND_DVD_AUDIO_MENU      = @GST_NAVIGATION_COMMAND_MENU5
102  *    GST_NAVIGATION_COMMAND_DVD_ANGLE_MENU      = @GST_NAVIGATION_COMMAND_MENU6
103  *    GST_NAVIGATION_COMMAND_DVD_CHAPTER_MENU    = @GST_NAVIGATION_COMMAND_MENU7
104  */
105 typedef enum {
106   GST_NAVIGATION_COMMAND_INVALID  = 0,
107
108   GST_NAVIGATION_COMMAND_MENU1    = 1,
109   GST_NAVIGATION_COMMAND_MENU2    = 2,
110   GST_NAVIGATION_COMMAND_MENU3    = 3,
111   GST_NAVIGATION_COMMAND_MENU4    = 4,
112   GST_NAVIGATION_COMMAND_MENU5    = 5,
113   GST_NAVIGATION_COMMAND_MENU6    = 6,
114   GST_NAVIGATION_COMMAND_MENU7    = 7,
115
116   GST_NAVIGATION_COMMAND_LEFT     = 20,
117   GST_NAVIGATION_COMMAND_RIGHT    = 21,
118   GST_NAVIGATION_COMMAND_UP       = 22,
119   GST_NAVIGATION_COMMAND_DOWN     = 23,
120   GST_NAVIGATION_COMMAND_ACTIVATE = 24,
121
122   GST_NAVIGATION_COMMAND_PREV_ANGLE = 30,
123   GST_NAVIGATION_COMMAND_NEXT_ANGLE = 31
124 } GstNavigationCommand;
125
126 /* Some aliases for the menu command types */
127 #define GST_NAVIGATION_COMMAND_DVD_MENU            GST_NAVIGATION_COMMAND_MENU1
128 #define GST_NAVIGATION_COMMAND_DVD_TITLE_MENU      GST_NAVIGATION_COMMAND_MENU2
129 #define GST_NAVIGATION_COMMAND_DVD_ROOT_MENU       GST_NAVIGATION_COMMAND_MENU3
130 #define GST_NAVIGATION_COMMAND_DVD_SUBPICTURE_MENU GST_NAVIGATION_COMMAND_MENU4
131 #define GST_NAVIGATION_COMMAND_DVD_AUDIO_MENU      GST_NAVIGATION_COMMAND_MENU5
132 #define GST_NAVIGATION_COMMAND_DVD_ANGLE_MENU      GST_NAVIGATION_COMMAND_MENU6
133 #define GST_NAVIGATION_COMMAND_DVD_CHAPTER_MENU    GST_NAVIGATION_COMMAND_MENU7
134
135 /* Queries */
136 /**
137  * GstNavigationQueryType:
138  * @GST_NAVIGATION_QUERY_INVALID: invalid query
139  * @GST_NAVIGATION_QUERY_COMMANDS: command query
140  * @GST_NAVIGATION_QUERY_ANGLES: viewing angle query
141  *
142  * Tyoes of navigation interface queries.
143  */
144 typedef enum
145 {
146   GST_NAVIGATION_QUERY_INVALID     = 0,
147   GST_NAVIGATION_QUERY_COMMANDS    = 1,
148   GST_NAVIGATION_QUERY_ANGLES      = 2
149 } GstNavigationQueryType;
150
151 GstNavigationQueryType gst_navigation_query_get_type (GstQuery *query);
152
153 GstQuery *      gst_navigation_query_new_commands       (void);
154 void            gst_navigation_query_set_commands       (GstQuery *query, gint n_cmds, ...);
155 void            gst_navigation_query_set_commandsv      (GstQuery *query, gint n_cmds,
156                                                          GstNavigationCommand *cmds);
157 gboolean        gst_navigation_query_parse_commands_length     (GstQuery *query,
158                                                                 guint *n_cmds);
159 gboolean        gst_navigation_query_parse_commands_nth        (GstQuery *query, guint nth,
160                                                                 GstNavigationCommand *cmd);
161
162 GstQuery *      gst_navigation_query_new_angles         (void);
163 void            gst_navigation_query_set_angles         (GstQuery *query, guint cur_angle,
164                                                          guint n_angles);
165 gboolean        gst_navigation_query_parse_angles       (GstQuery *query, guint *cur_angle,
166                                                          guint *n_angles);
167
168 /* Element messages */
169 /**
170  * GstNavigationMessageType:
171  * @GST_NAVIGATION_MESSAGE_INVALID: Returned from
172  * gst_navigation_message_get_type() when the passed message is not a
173  * navigation message.
174  * @GST_NAVIGATION_MESSAGE_MOUSE_OVER: Sent when the mouse moves over or leaves a
175  * clickable region of the output, such as a DVD menu button.
176  * @GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED: Sent when the set of available commands
177  * changes and should re-queried by interested applications.
178  * @GST_NAVIGATION_MESSAGE_ANGLES_CHANGED: Sent when display angles in a multi-angle
179  * feature (such as a multiangle DVD) change - either angles have appeared or
180  * disappeared.
181  *
182  * A set of notifications that may be received on the bus when navigation
183  * related status changes.
184  */
185 typedef enum {
186   GST_NAVIGATION_MESSAGE_INVALID,
187   GST_NAVIGATION_MESSAGE_MOUSE_OVER,
188   GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED,
189   GST_NAVIGATION_MESSAGE_ANGLES_CHANGED
190 } GstNavigationMessageType;
191
192 GstNavigationMessageType gst_navigation_message_get_type (GstMessage *message);
193
194 GstMessage *    gst_navigation_message_new_mouse_over       (GstObject *src,
195                                                              gboolean active);
196 gboolean        gst_navigation_message_parse_mouse_over     (GstMessage *message,
197                                                              gboolean *active);
198
199 GstMessage *    gst_navigation_message_new_commands_changed (GstObject *src);
200
201 GstMessage *    gst_navigation_message_new_angles_changed   (GstObject *src,
202                                                              guint cur_angle,
203                                                              guint n_angles);
204 gboolean        gst_navigation_message_parse_angles_changed (GstMessage *message,
205                                                              guint *cur_angle,
206                                                              guint *n_angles);
207
208 /* event parsing functions */
209 /**
210  * GstNavigationEventType:
211  * @GST_NAVIGATION_EVENT_INVALID: Returned from
212  * gst_navigation_event_get_type() when the passed event is not a navigation event.
213  * @GST_NAVIGATION_EVENT_KEY_PRESS: A key press event. Use
214  * gst_navigation_event_parse_key_event() to extract the details from the event.
215  * @GST_NAVIGATION_EVENT_KEY_RELEASE: A key release event. Use
216  * gst_navigation_event_parse_key_event() to extract the details from the event.
217  * @GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS: A mouse button press event. Use
218  * gst_navigation_event_parse_mouse_button_event() to extract the details from the
219  * event.
220  * @GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE: A mouse button release event. Use
221  * gst_navigation_event_parse_mouse_button_event() to extract the details from the
222  * event.
223  * @GST_NAVIGATION_EVENT_MOUSE_MOVE: A mouse movement event. Use
224  * gst_navigation_event_parse_mouse_move_event() to extract the details from the
225  * event.
226  * @GST_NAVIGATION_EVENT_COMMAND: A navigation command event. Use
227  * gst_navigation_event_parse_command() to extract the details from the event.
228  *
229  * Enum values for the various events that an element implementing the
230  * GstNavigation interface might send up the pipeline.
231  */
232 typedef enum {
233   GST_NAVIGATION_EVENT_INVALID                    = 0,
234   GST_NAVIGATION_EVENT_KEY_PRESS                  = 1,
235   GST_NAVIGATION_EVENT_KEY_RELEASE                = 2,
236   GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS         = 3,
237   GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE       = 4,
238   GST_NAVIGATION_EVENT_MOUSE_MOVE                 = 5,
239   GST_NAVIGATION_EVENT_COMMAND                    = 6
240 } GstNavigationEventType;
241
242 GstNavigationEventType gst_navigation_event_get_type          (GstEvent *event);
243
244 gboolean        gst_navigation_event_parse_key_event          (GstEvent *event,
245                                                                const gchar **key);
246 gboolean        gst_navigation_event_parse_mouse_button_event (GstEvent *event,
247                                                                gint *button, gdouble *x, gdouble *y);
248 gboolean        gst_navigation_event_parse_mouse_move_event   (GstEvent *event,
249                                                                gdouble *x, gdouble *y);
250 gboolean        gst_navigation_event_parse_command            (GstEvent *event,
251                                                                GstNavigationCommand *command);
252
253 /* interface virtual function wrappers */
254 void    gst_navigation_send_event       (GstNavigation *navigation,
255                                          GstStructure *structure);
256 void    gst_navigation_send_key_event   (GstNavigation *navigation,
257                                          const char *event, const char *key);
258 void    gst_navigation_send_mouse_event (GstNavigation *navigation,
259                                          const char *event, int button, double x, double y);
260 void    gst_navigation_send_command     (GstNavigation *navigation,
261                                          GstNavigationCommand command);
262
263 G_END_DECLS
264
265 #endif /* __GST_NAVIGATION_H__ */