[MPlayer-dev-eng] Re: Custom input

Rok stefanic_rok at siol.net
Mon Mar 27 18:40:19 CEST 2006


Nevermind I have sorted it out, works perfectly...

thanks,
rok

On Mon, 2006-03-27 at 17:42 +0200, Rok wrote:
> Albeu:
> 
> I have done it as you said, and lets say it is kinda working.. But it doesn't do exactly as I imagined it would.
> 
> I want that my read function writes the command (nevermind if it is
> hardoced, it is to be fixed later on) to for example mutes the player
> 
> Should it be done something like in the code below... (I don't know how
> to write or in what format to write the command to its destination?)
> 
> I'm looking at the code from lirc.c which has this at the begining:
> 
> int mp_input_lirc_read(int fd,char* dest, int s) {
> fd_set fds;
> struct timeval tv;
> int r,cl = 0;
> char *code = NULL,*c = NULL;
> // We have something in the buffer return it
> 	if(cmd_buf != NULL) {
> 	int l = strlen(cmd_buf), w = l > s ? s : l;
> 	memcpy(dest,cmd_buf,w);
> 	l -= w;
> 	if(l > 0)
> 	memmove(cmd_buf,&cmd_buf[w],l+1);
> 	else {
> 		free(cmd_buf);
> 		cmd_buf = NULL;
> 	}
> 	return w;
> }
> 
> 
> 
> On Mon, 2006-03-27 at 15:13 +0200, Alban Bedel wrote:
> > 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
> > 
> > _______________________________________________
> > MPlayer-dev-eng mailing list
> > MPlayer-dev-eng at mplayerhq.hu
> > http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
> 
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng




More information about the MPlayer-dev-eng mailing list