[MPlayer-dev-eng] Re: Custom input

Alban Bedel albeu at free.fr
Mon Mar 27 15:13:57 CEST 2006


On Sun, 26 Mar 2006 18:00:33 +0200
Rok <stefanic_rok at siol.net> wrote:

> Hey, 
> 
> thank you for your reply on the list.

Please don't reply off-list, this can be useful for others.

> I need to explain why I need to send commands.. I'm trying to include a
> small server listening for commands, which would then be properly
> paresed and sent to mplayer for execution. 

Well the input layer already take care of parsing commands, so generally
their is no need to process them before.

> In the input header file there is a header for function:
> mp_input_add_cmd_fd(int fd, int select, mp_cmd_func_t read_func,
> mp_close_func_t close_func);
> 
> In my input I have those two functions, but I still don't know how to
> actually send the command? I dont't understand the return type of int
> from those functions...

The read function should fill the buffer and return the number of bytes
read, or some error code.

> Goal: I'm trying to achieve that the player when "asking the input part"
> for any change would also ask my "server" which would pass the command
> to it.

I'm not sure i got what you want to do, but here is how one could implement
controlling mplayer via tcp:

At init:
 * Create the listening socket and turn it non-blocking.
 * Register the listening socket with select enabled.

Listening socket read:
 * Accept the incomming connection.
 * Register the new socket as command input with select enabled.
 * Return MP_INPUT_NOTHING.

Basically that's it, a full solution would need a bit more code to handle
closing client sockets, etc but this alone should already work.

	Albeu




More information about the MPlayer-dev-eng mailing list