VO: clean up aspect.c, remove aspecttest tool
[mplayer.git] / input / input.h
blob10469f13adffed053485bf16705cff05e40624c8
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_INPUT_H
20 #define MPLAYER_INPUT_H
22 // All command IDs
23 typedef enum {
24 MP_CMD_SEEK,
25 MP_CMD_AUDIO_DELAY,
26 MP_CMD_QUIT,
27 MP_CMD_PAUSE,
28 MP_CMD_GRAB_FRAMES, // deprecated: was a no-op command for years
29 MP_CMD_PLAY_TREE_STEP,
30 MP_CMD_PLAY_TREE_UP_STEP,
31 MP_CMD_PLAY_ALT_SRC_STEP,
32 MP_CMD_SUB_DELAY,
33 MP_CMD_OSD,
34 MP_CMD_VOLUME,
35 MP_CMD_MIXER_USEMASTER,
36 MP_CMD_CONTRAST,
37 MP_CMD_BRIGHTNESS,
38 MP_CMD_HUE,
39 MP_CMD_SATURATION,
40 MP_CMD_FRAMEDROPPING,
41 MP_CMD_TV_STEP_CHANNEL,
42 MP_CMD_TV_STEP_NORM,
43 MP_CMD_TV_STEP_CHANNEL_LIST,
44 MP_CMD_CAPTURING,
45 MP_CMD_VO_FULLSCREEN,
46 MP_CMD_SUB_POS,
47 MP_CMD_DVDNAV,
48 MP_CMD_SCREENSHOT,
49 MP_CMD_PANSCAN,
50 MP_CMD_MUTE,
51 MP_CMD_LOADFILE,
52 MP_CMD_LOADLIST,
53 MP_CMD_VF_CHANGE_RECTANGLE,
54 MP_CMD_GAMMA,
55 MP_CMD_SUB_VISIBILITY,
56 MP_CMD_VOBSUB_LANG, // deprecated: combined with SUB_SELECT
57 MP_CMD_MENU,
58 MP_CMD_SET_MENU,
59 MP_CMD_GET_TIME_LENGTH,
60 MP_CMD_GET_PERCENT_POS,
61 MP_CMD_SUB_STEP,
62 MP_CMD_TV_SET_CHANNEL,
63 MP_CMD_EDL_MARK,
64 MP_CMD_SUB_ALIGNMENT,
65 MP_CMD_TV_LAST_CHANNEL,
66 MP_CMD_OSD_SHOW_TEXT,
67 MP_CMD_TV_SET_FREQ,
68 MP_CMD_TV_SET_NORM,
69 MP_CMD_TV_SET_BRIGHTNESS,
70 MP_CMD_TV_SET_CONTRAST,
71 MP_CMD_TV_SET_HUE,
72 MP_CMD_TV_SET_SATURATION,
73 MP_CMD_GET_VO_FULLSCREEN,
74 MP_CMD_GET_SUB_VISIBILITY,
75 MP_CMD_SUB_FORCED_ONLY,
76 MP_CMD_VO_ONTOP,
77 MP_CMD_SUB_SELECT,
78 MP_CMD_VO_ROOTWIN,
79 MP_CMD_SWITCH_VSYNC,
80 MP_CMD_SWITCH_RATIO,
81 MP_CMD_FRAME_STEP,
82 MP_CMD_SPEED_INCR,
83 MP_CMD_SPEED_MULT,
84 MP_CMD_SPEED_SET,
85 MP_CMD_RUN,
86 MP_CMD_SUB_LOG,
87 MP_CMD_SWITCH_AUDIO,
88 MP_CMD_GET_TIME_POS,
89 MP_CMD_SUB_LOAD,
90 MP_CMD_SUB_REMOVE,
91 MP_CMD_KEYDOWN_EVENTS,
92 MP_CMD_VO_BORDER,
93 MP_CMD_SET_PROPERTY,
94 MP_CMD_SET_PROPERTY_OSD,
95 MP_CMD_GET_PROPERTY,
96 MP_CMD_OSD_SHOW_PROPERTY_TEXT,
97 MP_CMD_OSD_SHOW_PROGRESSION,
98 MP_CMD_SEEK_CHAPTER,
99 MP_CMD_FILE_FILTER,
100 MP_CMD_GET_FILENAME,
101 MP_CMD_GET_VIDEO_CODEC,
102 MP_CMD_GET_VIDEO_BITRATE,
103 MP_CMD_GET_VIDEO_RESOLUTION,
104 MP_CMD_GET_AUDIO_CODEC,
105 MP_CMD_GET_AUDIO_BITRATE,
106 MP_CMD_GET_AUDIO_SAMPLES,
107 MP_CMD_GET_META_TITLE,
108 MP_CMD_GET_META_ARTIST,
109 MP_CMD_GET_META_ALBUM,
110 MP_CMD_GET_META_YEAR,
111 MP_CMD_GET_META_COMMENT,
112 MP_CMD_GET_META_TRACK,
113 MP_CMD_GET_META_GENRE,
114 MP_CMD_RADIO_STEP_CHANNEL,
115 MP_CMD_RADIO_SET_CHANNEL,
116 MP_CMD_RADIO_SET_FREQ,
117 MP_CMD_SET_MOUSE_POS,
118 MP_CMD_STEP_PROPERTY,
119 MP_CMD_STEP_PROPERTY_OSD,
120 MP_CMD_RADIO_STEP_FREQ,
121 MP_CMD_TV_STEP_FREQ,
122 MP_CMD_LOOP,
123 MP_CMD_BALANCE,
124 MP_CMD_SUB_SCALE,
125 MP_CMD_TV_TELETEXT_ADD_DEC,
126 MP_CMD_TV_TELETEXT_GO_LINK,
127 MP_CMD_TV_START_SCAN,
128 MP_CMD_SUB_SOURCE,
129 MP_CMD_SUB_FILE,
130 MP_CMD_SUB_VOB,
131 MP_CMD_SUB_DEMUX,
132 MP_CMD_SWITCH_ANGLE,
133 MP_CMD_ASS_USE_MARGINS,
134 MP_CMD_SWITCH_TITLE,
135 MP_CMD_STOP,
137 /// DVDNAV commands
138 MP_CMD_DVDNAV_UP = 1000,
139 MP_CMD_DVDNAV_DOWN,
140 MP_CMD_DVDNAV_LEFT,
141 MP_CMD_DVDNAV_RIGHT,
142 MP_CMD_DVDNAV_MENU,
143 MP_CMD_DVDNAV_SELECT,
144 MP_CMD_DVDNAV_PREVMENU,
145 MP_CMD_DVDNAV_MOUSECLICK,
147 /// DVB commands
148 MP_CMD_DVB_SET_CHANNEL = 5101,
150 /// Console commands
151 MP_CMD_CHELP = 7000,
152 MP_CMD_CEXIT,
153 MP_CMD_CHIDE,
155 /// Audio Filter commands
156 MP_CMD_AF_SWITCH,
157 MP_CMD_AF_ADD,
158 MP_CMD_AF_DEL,
159 MP_CMD_AF_CLR,
160 MP_CMD_AF_CMDLINE,
162 } mp_command_type;
164 // The arg types
165 #define MP_CMD_ARG_INT 0
166 #define MP_CMD_ARG_FLOAT 1
167 #define MP_CMD_ARG_STRING 2
168 #define MP_CMD_ARG_VOID 3
170 #ifndef MP_CMD_MAX_ARGS
171 #define MP_CMD_MAX_ARGS 10
172 #endif
174 // Error codes for the drivers
176 // An error occurred but we can continue
177 #define MP_INPUT_ERROR -1
178 // A fatal error occurred, this driver should be removed
179 #define MP_INPUT_DEAD -2
180 // No input was available
181 #define MP_INPUT_NOTHING -3
182 //! Input will be available if you try again
183 #define MP_INPUT_RETRY -4
184 // Key FIFO was full - release events may be lost, zero button-down status
185 #define MP_INPUT_RELEASE_ALL -5
188 #ifndef MP_MAX_KEY_DOWN
189 #define MP_MAX_KEY_DOWN 32
190 #endif
192 struct input_ctx;
194 typedef union mp_cmd_arg_value {
195 int i;
196 float f;
197 char* s;
198 void* v;
199 } mp_cmd_arg_value_t;
201 typedef struct mp_cmd_arg {
202 int type;
203 mp_cmd_arg_value_t v;
204 } mp_cmd_arg_t;
206 typedef struct mp_cmd {
207 int id;
208 char* name;
209 int nargs;
210 mp_cmd_arg_t args[MP_CMD_MAX_ARGS];
211 int pausing;
212 } mp_cmd_t;
215 // These typedefs are for the drivers. They are the functions used to retrieve
216 // the next key code or command.
218 // These functions should return the key code or one of the error codes
219 typedef int (*mp_key_func_t)(void *ctx, int fd);
220 // These functions should act like read but they must use our error code (if needed ;-)
221 typedef int (*mp_cmd_func_t)(int fd,char* dest,int size);
222 // These are used to close the driver
223 typedef void (*mp_close_func_t)(int fd);
225 // Set this to grab all incoming key codes
226 extern int (*mp_input_key_cb)(int code);
227 // Should return 1 if the command was processed
228 typedef int (*mp_input_cmd_filter)(mp_cmd_t *cmd, void *ctx);
230 // This function adds a new key driver.
231 // The first arg is a file descriptor (use a negative value if you don't use any fd)
232 // The second arg tells if we use select on the fd to know if something is available.
233 // The third arg is optional. If null a default function wich reads an int from the
234 // fd will be used.
235 // The last arg can be NULL if nothing is needed to close the driver. The close
236 // function can be used
237 int mp_input_add_cmd_fd(struct input_ctx *ictx, int fd, int select,
238 mp_cmd_func_t read_func, mp_close_func_t close_func);
240 // This removes a cmd driver, you usually don't need to use it.
241 void mp_input_rm_cmd_fd(struct input_ctx *ictx, int fd);
243 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
244 // give a read_func.
245 int mp_input_add_key_fd(struct input_ctx *ictx, int fd, int select,
246 mp_key_func_t read_func, mp_close_func_t close_func,
247 void *ctx);
249 // As for the cmd one you usually don't need this function.
250 void mp_input_rm_key_fd(struct input_ctx *ictx, int fd);
252 /// Get input key from its name.
253 int mp_input_get_key_from_name(const char *name);
255 // This function can be used to put a command in the system again. It's used by libmpdemux
256 // when it performs a blocking operation to resend the command it received to the main
257 // loop.
258 int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t* cmd);
260 // This function retrieves the next available command waiting no more than time msec.
261 // If pause is true, the next input will always return a pause command.
262 mp_cmd_t*
263 mp_input_get_cmd(struct input_ctx *ictx, int time, int peek_only);
265 mp_cmd_t*
266 mp_input_parse_cmd(char* str);
269 * Parse and queue commands separated by '\n'.
270 * @return count of commands new queued.
272 int mp_input_parse_and_queue_cmds(struct input_ctx *ictx, const char *str);
274 /// These filters allow you to process the command before MPlayer.
275 /// If a filter returns a true value mp_input_get_cmd will return NULL.
276 void
277 mp_input_add_cmd_filter(mp_input_cmd_filter, void* ctx);
279 // After getting a command from mp_input_get_cmd you need to free it using this
280 // function
281 void
282 mp_cmd_free(mp_cmd_t* cmd);
284 // This creates a copy of a command (used by the auto repeat stuff).
285 mp_cmd_t*
286 mp_cmd_clone(mp_cmd_t* cmd);
288 // Set current input section
289 void mp_input_set_section(struct input_ctx *ictx, char *name);
291 // Get current input section
292 char *mp_input_get_section(struct input_ctx *ictx);
294 // When you create a new driver you should add it in these 2 functions.
295 struct input_conf;
296 struct input_ctx *mp_input_init(struct input_conf *input_conf);
298 void mp_input_uninit(struct input_ctx *ictx);
300 struct m_config;
301 void mp_input_register_options(struct m_config *cfg);
303 // Interruptible usleep: (used by libmpdemux)
305 mp_input_check_interrupt(struct input_ctx *ictx, int time);
307 extern int async_quit_request;
309 #endif /* MPLAYER_INPUT_H */