1 #ifndef MPLAYER_INPUT_H
2 #define MPLAYER_INPUT_H
10 MP_CMD_GRAB_FRAMES
, // deprecated: was a no-op command for years
11 MP_CMD_PLAY_TREE_STEP
,
12 MP_CMD_PLAY_TREE_UP_STEP
,
13 MP_CMD_PLAY_ALT_SRC_STEP
,
17 MP_CMD_MIXER_USEMASTER
,
23 MP_CMD_TV_STEP_CHANNEL
,
25 MP_CMD_TV_STEP_CHANNEL_LIST
,
34 MP_CMD_VF_CHANGE_RECTANGLE
,
36 MP_CMD_SUB_VISIBILITY
,
37 MP_CMD_VOBSUB_LANG
, // deprecated: combined with SUB_SELECT
40 MP_CMD_GET_TIME_LENGTH
,
41 MP_CMD_GET_PERCENT_POS
,
43 MP_CMD_TV_SET_CHANNEL
,
46 MP_CMD_TV_LAST_CHANNEL
,
50 MP_CMD_TV_SET_BRIGHTNESS
,
51 MP_CMD_TV_SET_CONTRAST
,
53 MP_CMD_TV_SET_SATURATION
,
54 MP_CMD_GET_VO_FULLSCREEN
,
55 MP_CMD_GET_SUB_VISIBILITY
,
56 MP_CMD_SUB_FORCED_ONLY
,
72 MP_CMD_KEYDOWN_EVENTS
,
76 MP_CMD_OSD_SHOW_PROPERTY_TEXT
,
80 MP_CMD_GET_VIDEO_CODEC
,
81 MP_CMD_GET_VIDEO_BITRATE
,
82 MP_CMD_GET_VIDEO_RESOLUTION
,
83 MP_CMD_GET_AUDIO_CODEC
,
84 MP_CMD_GET_AUDIO_BITRATE
,
85 MP_CMD_GET_AUDIO_SAMPLES
,
86 MP_CMD_GET_META_TITLE
,
87 MP_CMD_GET_META_ARTIST
,
88 MP_CMD_GET_META_ALBUM
,
90 MP_CMD_GET_META_COMMENT
,
91 MP_CMD_GET_META_TRACK
,
92 MP_CMD_GET_META_GENRE
,
93 MP_CMD_RADIO_STEP_CHANNEL
,
94 MP_CMD_RADIO_SET_CHANNEL
,
95 MP_CMD_RADIO_SET_FREQ
,
98 MP_CMD_RADIO_STEP_FREQ
,
103 MP_CMD_TV_TELETEXT_ADD_DEC
,
104 MP_CMD_TV_TELETEXT_GO_LINK
,
105 MP_CMD_TV_START_SCAN
,
111 MP_CMD_ASS_USE_MARGINS
,
116 MP_CMD_DVDNAV_UP
= 1000,
121 MP_CMD_DVDNAV_SELECT
,
122 MP_CMD_DVDNAV_PREVMENU
,
123 MP_CMD_DVDNAV_MOUSECLICK
,
126 MP_CMD_GUI_EVENTS
= 5000,
128 MP_CMD_GUI_LOADSUBTITLE
,
133 MP_CMD_GUI_PREFERENCES
,
134 MP_CMD_GUI_FULLSCREEN
,
135 MP_CMD_GUI_SKINBROWSER
,
138 MP_CMD_DVB_SET_CHANNEL
= 5101,
147 #define MP_CMD_ARG_INT 0
148 #define MP_CMD_ARG_FLOAT 1
149 #define MP_CMD_ARG_STRING 2
150 #define MP_CMD_ARG_VOID 3
152 #ifndef MP_CMD_MAX_ARGS
153 #define MP_CMD_MAX_ARGS 10
156 // Error codes for the drivers
158 // An error occurred but we can continue
159 #define MP_INPUT_ERROR -1
160 // A fatal error occurred, this driver should be removed
161 #define MP_INPUT_DEAD -2
162 // No input was available
163 #define MP_INPUT_NOTHING -3
164 //! Input will be available if you try again
165 #define MP_INPUT_RETRY -4
167 // For the key's drivers, if possible you can send key up and key down
168 // events. Key up is the default, to send a key down you must use the
169 // OR operator between the key code and MP_KEY_DOWN.
170 #define MP_KEY_DOWN (1<<29)
171 // Use this when the key shouldn't be auto-repeated (like mouse buttons)
172 #define MP_NO_REPEAT_KEY (1<<28)
174 #ifndef MP_MAX_KEY_DOWN
175 #define MP_MAX_KEY_DOWN 32
180 typedef union mp_cmd_arg_value
{
185 } mp_cmd_arg_value_t
;
187 typedef struct mp_cmd_arg
{
189 mp_cmd_arg_value_t v
;
192 typedef struct mp_cmd
{
196 mp_cmd_arg_t args
[MP_CMD_MAX_ARGS
];
201 // These typedefs are for the drivers. They are the functions used to retrieve
202 // the next key code or command.
204 // These functions should return the key code or one of the error codes
205 typedef int (*mp_key_func_t
)(void *ctx
, int fd
);
206 // These functions should act like read but they must use our error code (if needed ;-)
207 typedef int (*mp_cmd_func_t
)(int fd
,char* dest
,int size
);
208 // These are used to close the driver
209 typedef void (*mp_close_func_t
)(int fd
);
211 // Set this to grab all incoming key codes
212 int (*mp_input_key_cb
)(int code
);
213 // Should return 1 if the command was processed
214 typedef int (*mp_input_cmd_filter
)(mp_cmd_t
* cmd
, int paused
, void* ctx
);
216 // This function adds a new key driver.
217 // The first arg is a file descriptor (use a negative value if you don't use any fd)
218 // The second arg tells if we use select on the fd to know if something is available.
219 // The third arg is optional. If null a default function wich reads an int from the
221 // The last arg can be NULL if nothing is needed to close the driver. The close
222 // function can be used
223 int mp_input_add_cmd_fd(struct input_ctx
*ictx
, int fd
, int select
,
224 mp_cmd_func_t read_func
, mp_close_func_t close_func
);
226 // This removes a cmd driver, you usually don't need to use it.
227 void mp_input_rm_cmd_fd(struct input_ctx
*ictx
, int fd
);
229 // The args are the same as for the key's drivers. If you don't use any valid fd you MUST
231 int mp_input_add_key_fd(struct input_ctx
*ictx
, int fd
, int select
,
232 mp_key_func_t read_func
, mp_close_func_t close_func
,
235 // As for the cmd one you usually don't need this function.
236 void mp_input_rm_key_fd(struct input_ctx
*ictx
, int fd
);
238 /// Get input key from its name.
239 int mp_input_get_key_from_name(const char *name
);
241 // This function can be used to put a command in the system again. It's used by libmpdemux
242 // when it performs a blocking operation to resend the command it received to the main
244 int mp_input_queue_cmd(struct input_ctx
*ictx
, mp_cmd_t
* cmd
);
246 // This function retrieves the next available command waiting no more than time msec.
247 // If pause is true, the next input will always return a pause command.
249 mp_input_get_cmd(struct input_ctx
*ictx
, int time
, int paused
, int peek_only
);
252 mp_input_parse_cmd(char* str
);
255 * Parse and queue commands separated by '\n'.
256 * @return count of commands new queued.
258 int mp_input_parse_and_queue_cmds(struct input_ctx
*ictx
, const char *str
);
260 /// These filters allow you to process the command before MPlayer.
261 /// If a filter returns a true value mp_input_get_cmd will return NULL.
263 mp_input_add_cmd_filter(mp_input_cmd_filter
, void* ctx
);
265 // After getting a command from mp_input_get_cmd you need to free it using this
268 mp_cmd_free(mp_cmd_t
* cmd
);
270 // This creates a copy of a command (used by the auto repeat stuff).
272 mp_cmd_clone(mp_cmd_t
* cmd
);
274 // Set current input section
275 void mp_input_set_section(struct input_ctx
*ictx
, char *name
);
277 // Get current input section
278 char *mp_input_get_section(struct input_ctx
*ictx
);
280 // When you create a new driver you should add it in these 2 functions.
282 struct input_ctx
*mp_input_init(struct input_conf
*input_conf
, int use_gui
);
284 void mp_input_uninit(struct input_ctx
*ictx
);
287 void mp_input_register_options(struct m_config
*cfg
);
289 // Interruptible usleep: (used by libmpdemux)
291 mp_input_check_interrupt(struct input_ctx
*ictx
, int time
);
293 extern int async_quit_request
;
295 #endif /* MPLAYER_INPUT_H */