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
25 enum mp_command_type
{
30 MP_CMD_PLAY_TREE_STEP
,
31 MP_CMD_PLAY_TREE_UP_STEP
,
32 MP_CMD_PLAY_ALT_SRC_STEP
,
41 MP_CMD_TV_STEP_CHANNEL
,
43 MP_CMD_TV_STEP_CHANNEL_LIST
,
53 MP_CMD_VF_CHANGE_RECTANGLE
,
55 MP_CMD_SUB_VISIBILITY
,
56 MP_CMD_GET_TIME_LENGTH
,
57 MP_CMD_GET_PERCENT_POS
,
59 MP_CMD_TV_SET_CHANNEL
,
62 MP_CMD_TV_LAST_CHANNEL
,
66 MP_CMD_TV_SET_BRIGHTNESS
,
67 MP_CMD_TV_SET_CONTRAST
,
69 MP_CMD_TV_SET_SATURATION
,
70 MP_CMD_GET_VO_FULLSCREEN
,
71 MP_CMD_GET_SUB_VISIBILITY
,
72 MP_CMD_SUB_FORCED_ONLY
,
88 MP_CMD_KEYDOWN_EVENTS
,
91 MP_CMD_SET_PROPERTY_OSD
,
93 MP_CMD_OSD_SHOW_PROPERTY_TEXT
,
94 MP_CMD_OSD_SHOW_PROGRESSION
,
97 MP_CMD_GET_VIDEO_CODEC
,
98 MP_CMD_GET_VIDEO_BITRATE
,
99 MP_CMD_GET_VIDEO_RESOLUTION
,
100 MP_CMD_GET_AUDIO_CODEC
,
101 MP_CMD_GET_AUDIO_BITRATE
,
102 MP_CMD_GET_AUDIO_SAMPLES
,
103 MP_CMD_GET_META_TITLE
,
104 MP_CMD_GET_META_ARTIST
,
105 MP_CMD_GET_META_ALBUM
,
106 MP_CMD_GET_META_YEAR
,
107 MP_CMD_GET_META_COMMENT
,
108 MP_CMD_GET_META_TRACK
,
109 MP_CMD_GET_META_GENRE
,
110 MP_CMD_RADIO_STEP_CHANNEL
,
111 MP_CMD_RADIO_SET_CHANNEL
,
112 MP_CMD_RADIO_SET_FREQ
,
113 MP_CMD_SET_MOUSE_POS
,
114 MP_CMD_STEP_PROPERTY
,
115 MP_CMD_STEP_PROPERTY_OSD
,
116 MP_CMD_RADIO_STEP_FREQ
,
121 MP_CMD_TV_TELETEXT_ADD_DEC
,
122 MP_CMD_TV_TELETEXT_GO_LINK
,
123 MP_CMD_TV_START_SCAN
,
129 MP_CMD_ASS_USE_MARGINS
,
134 MP_CMD_DVDNAV_UP
= 1000,
139 MP_CMD_DVDNAV_SELECT
,
140 MP_CMD_DVDNAV_PREVMENU
,
141 MP_CMD_DVDNAV_MOUSECLICK
,
144 MP_CMD_DVB_SET_CHANNEL
= 5101,
146 /// Audio Filter commands
155 #define MP_CMD_ARG_INT 1
156 #define MP_CMD_ARG_FLOAT 2
157 #define MP_CMD_ARG_STRING 3
159 #define MP_CMD_MAX_ARGS 10
161 // Error codes for the drivers
163 // An error occurred but we can continue
164 #define MP_INPUT_ERROR -1
165 // A fatal error occurred, this driver should be removed
166 #define MP_INPUT_DEAD -2
167 // No input was available
168 #define MP_INPUT_NOTHING -3
169 //! Input will be available if you try again
170 #define MP_INPUT_RETRY -4
171 // Key FIFO was full - release events may be lost, zero button-down status
172 #define MP_INPUT_RELEASE_ALL -5
187 typedef struct mp_cmd
{
190 struct mp_cmd_arg args
[MP_CMD_MAX_ARGS
];
193 struct mp_cmd
*queue_prev
;
194 struct mp_cmd
*queue_next
;
198 /* Add a new command input source.
199 * "fd" is a file descriptor (use a negative value if you don't use any fd)
200 * "select" tells whether to use select() on the fd to determine when to
202 * "read_func" is optional. If NULL a default function which reads data
203 * directly from the fd will be used. It must return either text data
204 * or one of the MP_INPUT error codes above.
205 * "close_func" will be called when closing. Can be NULL. Its return value
206 * is ignored (it's only there to allow using standard close() as the func).
208 int mp_input_add_cmd_fd(struct input_ctx
*ictx
, int fd
, int select
,
209 int read_func(int fd
, char *dest
, int size
),
210 int close_func(int fd
));
212 // This removes a cmd driver, you usually don't need to use it.
213 void mp_input_rm_cmd_fd(struct input_ctx
*ictx
, int fd
);
215 /* The args are similar to the cmd version above, except you must give
216 * a read_func, and it should return key codes (ASCII plus keycodes.h).
218 int mp_input_add_key_fd(struct input_ctx
*ictx
, int fd
, int select
,
219 int read_func(void *ctx
, int fd
),
220 int close_func(int fd
), void *ctx
);
222 // Feed a keypress (alternative to being returned from read_func above)
223 void mp_input_feed_key(struct input_ctx
*ictx
, int code
);
225 // As for the cmd one you usually don't need this function.
226 void mp_input_rm_key_fd(struct input_ctx
*ictx
, int fd
);
228 // Get input key from its name.
229 int mp_input_get_key_from_name(const char *name
);
231 // Add a command to the command queue.
232 int mp_input_queue_cmd(struct input_ctx
*ictx
, struct mp_cmd
*cmd
);
234 /* Return next available command, or sleep up to "time" ms if none is
235 * available. If "peek_only" is true return a reference to the command
236 * but leave it queued.
238 struct mp_cmd
*mp_input_get_cmd(struct input_ctx
*ictx
, int time
,
241 /* Parse text and return corresponding struct mp_cmd. */
242 struct mp_cmd
*mp_input_parse_cmd(char *str
);
244 // After getting a command from mp_input_get_cmd you need to free it using this
246 void mp_cmd_free(struct mp_cmd
*cmd
);
248 // This creates a copy of a command (used by the auto repeat stuff).
249 struct mp_cmd
*mp_cmd_clone(struct mp_cmd
*cmd
);
251 // Set current input section
252 void mp_input_set_section(struct input_ctx
*ictx
, char *name
);
254 // Initialize the input system
256 struct input_ctx
*mp_input_init(struct input_conf
*input_conf
);
258 void mp_input_uninit(struct input_ctx
*ictx
);
261 void mp_input_register_options(struct m_config
*cfg
);
263 // Wake up sleeping input loop from another thread.
264 void mp_input_wakeup(struct input_ctx
*ictx
);
266 // Interruptible usleep: (used by libmpdemux)
267 int mp_input_check_interrupt(struct input_ctx
*ictx
, int time
);
269 extern int async_quit_request
;
271 #endif /* MPLAYER_INPUT_H */