Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-base.git] / gst-libs / gst / interfaces / 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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, 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  * Since: 0.10.23
106  */
107 typedef enum {
108   GST_NAVIGATION_COMMAND_INVALID  = 0,
109
110   GST_NAVIGATION_COMMAND_MENU1    = 1,
111   GST_NAVIGATION_COMMAND_MENU2    = 2,
112   GST_NAVIGATION_COMMAND_MENU3    = 3,
113   GST_NAVIGATION_COMMAND_MENU4    = 4,
114   GST_NAVIGATION_COMMAND_MENU5    = 5,
115   GST_NAVIGATION_COMMAND_MENU6    = 6,
116   GST_NAVIGATION_COMMAND_MENU7    = 7,
117
118   GST_NAVIGATION_COMMAND_LEFT     = 20,
119   GST_NAVIGATION_COMMAND_RIGHT    = 21,
120   GST_NAVIGATION_COMMAND_UP       = 22,
121   GST_NAVIGATION_COMMAND_DOWN     = 23,
122   GST_NAVIGATION_COMMAND_ACTIVATE = 24,
123
124   GST_NAVIGATION_COMMAND_PREV_ANGLE = 30,
125   GST_NAVIGATION_COMMAND_NEXT_ANGLE = 31
126 } GstNavigationCommand;
127
128 /* Some aliases for the menu command types */
129 #define GST_NAVIGATION_COMMAND_DVD_MENU            GST_NAVIGATION_COMMAND_MENU1
130 #define GST_NAVIGATION_COMMAND_DVD_TITLE_MENU      GST_NAVIGATION_COMMAND_MENU2
131 #define GST_NAVIGATION_COMMAND_DVD_ROOT_MENU       GST_NAVIGATION_COMMAND_MENU3
132 #define GST_NAVIGATION_COMMAND_DVD_SUBPICTURE_MENU GST_NAVIGATION_COMMAND_MENU4
133 #define GST_NAVIGATION_COMMAND_DVD_AUDIO_MENU      GST_NAVIGATION_COMMAND_MENU5
134 #define GST_NAVIGATION_COMMAND_DVD_ANGLE_MENU      GST_NAVIGATION_COMMAND_MENU6
135 #define GST_NAVIGATION_COMMAND_DVD_CHAPTER_MENU    GST_NAVIGATION_COMMAND_MENU7
136
137 /* Queries */
138 /**
139  * GstNavigationQueryType:
140  * @GST_NAVIGATION_QUERY_INVALID: invalid query
141  * @GST_NAVIGATION_QUERY_COMMANDS: command query
142  * @GST_NAVIGATION_QUERY_ANGLES: viewing angle query
143  *
144  * Tyoes of navigation interface queries.
145  */
146 typedef enum
147 {
148   GST_NAVIGATION_QUERY_INVALID     = 0,
149   GST_NAVIGATION_QUERY_COMMANDS    = 1,
150   GST_NAVIGATION_QUERY_ANGLES      = 2
151 } GstNavigationQueryType;
152
153 GstNavigationQueryType gst_navigation_query_get_type (GstQuery *query);
154
155 GstQuery *      gst_navigation_query_new_commands       (void);
156 void            gst_navigation_query_set_commands       (GstQuery *query, gint n_cmds, ...);
157 void            gst_navigation_query_set_commandsv      (GstQuery *query, gint n_cmds,
158                                                          GstNavigationCommand *cmds);
159 gboolean        gst_navigation_query_parse_commands_length     (GstQuery *query,
160                                                                 guint *n_cmds);
161 gboolean        gst_navigation_query_parse_commands_nth        (GstQuery *query, guint nth,
162                                                                 GstNavigationCommand *cmd);
163
164 GstQuery *      gst_navigation_query_new_angles         (void);
165 void            gst_navigation_query_set_angles         (GstQuery *query, guint cur_angle,
166                                                          guint n_angles);
167 gboolean        gst_navigation_query_parse_angles       (GstQuery *query, guint *cur_angle,
168                                                          guint *n_angles);
169
170 /* Element messages */
171 /**
172  * GstNavigationMessageType:
173  * @GST_NAVIGATION_MESSAGE_INVALID: Returned from
174  * gst_navigation_message_get_type() when the passed message is not a
175  * navigation message.
176  * @GST_NAVIGATION_MESSAGE_MOUSE_OVER: Sent when the mouse moves over or leaves a
177  * clickable region of the output, such as a DVD menu button.
178  * @GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED: Sent when the set of available commands
179  * changes and should re-queried by interested applications.
180  * @GST_NAVIGATION_MESSAGE_ANGLES_CHANGED: Sent when display angles in a multi-angle
181  * feature (such as a multiangle DVD) change - either angles have appeared or
182  * disappeared.
183  *
184  * A set of notifications that may be received on the bus when navigation
185  * related status changes.
186  *
187  * Since: 0.10.23
188  */
189 typedef enum {
190   GST_NAVIGATION_MESSAGE_INVALID,
191   GST_NAVIGATION_MESSAGE_MOUSE_OVER,
192   GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED,
193   GST_NAVIGATION_MESSAGE_ANGLES_CHANGED
194 } GstNavigationMessageType;
195
196 GstNavigationMessageType gst_navigation_message_get_type (GstMessage *message);
197
198 GstMessage *    gst_navigation_message_new_mouse_over       (GstObject *src,
199                                                              gboolean active);
200 gboolean        gst_navigation_message_parse_mouse_over     (GstMessage *message,
201                                                              gboolean *active);
202
203 GstMessage *    gst_navigation_message_new_commands_changed (GstObject *src);
204
205 GstMessage *    gst_navigation_message_new_angles_changed   (GstObject *src,
206                                                              guint cur_angle,
207                                                              guint n_angles);
208 gboolean        gst_navigation_message_parse_angles_changed (GstMessage *message,
209                                                              guint *cur_angle,
210                                                              guint *n_angles);
211
212 /* event parsing functions */
213 /**
214  * GstNavigationEventType:
215  * @GST_NAVIGATION_EVENT_INVALID: Returned from
216  * gst_navigation_event_get_type() when the passed event is not a navigation event.
217  * @GST_NAVIGATION_EVENT_KEY_PRESS: A key press event. Use
218  * gst_navigation_event_parse_key_event() to extract the details from the event.
219  * @GST_NAVIGATION_EVENT_KEY_RELEASE: A key release event. Use
220  * gst_navigation_event_parse_key_event() to extract the details from the event.
221  * @GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS: A mouse button press event. Use
222  * gst_navigation_event_parse_mouse_button_event() to extract the details from the
223  * event.
224  * @GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE: A mouse button release event. Use
225  * gst_navigation_event_parse_mouse_button_event() to extract the details from the
226  * event.
227  * @GST_NAVIGATION_EVENT_MOUSE_MOVE: A mouse movement event. Use
228  * gst_navigation_event_parse_mouse_move_event() to extract the details from the
229  * event.
230  * @GST_NAVIGATION_EVENT_COMMAND: A navigation command event. Use
231  * gst_navigation_event_parse_command() to extract the details from the event.
232  *
233  * Enum values for the various events that an element implementing the
234  * GstNavigation interface might send up the pipeline.
235  *
236  * Since: 0.10.23
237  */
238 typedef enum {
239   GST_NAVIGATION_EVENT_INVALID                    = 0,
240   GST_NAVIGATION_EVENT_KEY_PRESS                  = 1,
241   GST_NAVIGATION_EVENT_KEY_RELEASE                = 2,
242   GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS         = 3,
243   GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE       = 4,
244   GST_NAVIGATION_EVENT_MOUSE_MOVE                 = 5,
245   GST_NAVIGATION_EVENT_COMMAND                    = 6
246 } GstNavigationEventType;
247
248 GstNavigationEventType gst_navigation_event_get_type          (GstEvent *event);
249
250 gboolean        gst_navigation_event_parse_key_event          (GstEvent *event,
251                                                                const gchar **key);
252 gboolean        gst_navigation_event_parse_mouse_button_event (GstEvent *event,
253                                                                gint *button, gdouble *x, gdouble *y);
254 gboolean        gst_navigation_event_parse_mouse_move_event   (GstEvent *event,
255                                                                gdouble *x, gdouble *y);
256 gboolean        gst_navigation_event_parse_command            (GstEvent *event,
257                                                                GstNavigationCommand *command);
258
259 /* interface virtual function wrappers */
260 void    gst_navigation_send_event       (GstNavigation *navigation,
261                                          GstStructure *structure);
262 void    gst_navigation_send_key_event   (GstNavigation *navigation,
263                                          const char *event, const char *key);
264 void    gst_navigation_send_mouse_event (GstNavigation *navigation,
265                                          const char *event, int button, double x, double y);
266 void    gst_navigation_send_command     (GstNavigation *navigation,
267                                          GstNavigationCommand command);
268
269 G_END_DECLS
270
271 #endif /* __GST_NAVIGATION_H__ */