navigation.h 12 KB

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