yauap-0.2.4/0000755000175000001440000000000011152501362012011 5ustar saschausersyauap-0.2.4/commandline/0000755000175000001440000000000011152501362014277 5ustar saschausersyauap-0.2.4/commandline/kbd.c0000644000175000001440000001120311152501274015202 0ustar saschausers/* * kbd.c - keyboard input functions * Copyright (c) 2006 Sascha Sommer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA based on osdep/getch2.c from MPlayer (http://www.mplayerhq.hu) Copyright (c) 1999 A'rpi/ESP-team */ /* GyS-TermIO v2.0 (for GySmail v3) (C) 1999 A'rpi/ESP-team */ #define MAX_KEYS 64 #define BUF_LEN 256 #include #include #include #include #include #include #include #include #include "kbd.h" static int getch2_len=0; static char getch2_buf[BUF_LEN]; int getch2(void){ int len=0; int code=0; int time=0; while(!getch2_len || (getch2_len==1 && getch2_buf[0]==27)){ fd_set rfds; struct timeval tv; int retval; /* Watch stdin (fd 0) to see when it has input. */ FD_ZERO(&rfds); FD_SET(0,&rfds); /* Wait up to 'time' microseconds. */ tv.tv_sec=time/1000; tv.tv_usec = (time%1000)*1000; retval=select(1, &rfds, NULL, NULL, &tv); if (retval < 0 && errno == EINTR) continue; if(retval<=0) return -1; /* Data is available now. */ retval=read(0,&getch2_buf[getch2_len],BUF_LEN-getch2_len); /* stdin was closed, inject quit command */ if (retval == 0) return 'q'; if(retval<1) return -1; getch2_len+=retval; } len=1;code=getch2_buf[0]; /* Check the well-known codes... */ if(code!=27){ if(code=='A'-64){ code=KEY_HOME; goto found;} if(code=='E'-64){ code=KEY_END; goto found;} if(code=='D'-64){ code=KEY_DEL; goto found;} if(code=='H'-64){ code=KEY_BS; goto found;} if(code=='U'-64){ code=KEY_PGUP; goto found;} if(code=='V'-64){ code=KEY_PGDWN; goto found;} if(code==8 || code==127){ code=KEY_BS; goto found;} if(code==10 || code==13){ if(getch2_len>1){ int c=getch2_buf[1]; if(c==10 || c==13) if(c!=code) len=2; } code=KEY_ENTER; goto found; } } else if(getch2_len>1){ int c=getch2_buf[1]; if(c==27){ code=KEY_ESC; len=2; goto found;} if(c>='0' && c<='9'){ code=c-'0'+KEY_F; len=2; goto found;} if(getch2_len>=4 && c=='[' && getch2_buf[2]=='['){ int c=getch2_buf[3]; if(c>='A' && c<'A'+12){ code=KEY_F+1+c-'A';len=4;goto found;} } if(c=='[' || c=='O') if(getch2_len>=3){ int c=getch2_buf[2]; static short int ctable[]={ KEY_UP,KEY_DOWN,KEY_RIGHT,KEY_LEFT,0, KEY_END,KEY_PGDWN,KEY_HOME,KEY_PGUP,0,0,KEY_INS,0,0,0, KEY_F+1,KEY_F+2,KEY_F+3,KEY_F+4}; if(c>='A' && c<='S') if(ctable[c-'A']){ code=ctable[c-'A']; len=3; goto found;} } if(getch2_len>=4 && c=='[' && getch2_buf[3]=='~'){ int c=getch2_buf[2]; int ctable[8]={KEY_HOME,KEY_INS,KEY_DEL,KEY_END,KEY_PGUP,KEY_PGDWN,KEY_HOME,KEY_END}; if(c>='1' && c<='8'){ code=ctable[c-'1']; len=4; goto found;} } if(getch2_len>=5 && c=='[' && getch2_buf[4]=='~'){ int i=getch2_buf[2]-'0'; int j=getch2_buf[3]-'0'; if(i>=0 && i<=9 && j>=0 && j<=9){ static short int ftable[20]={ 11,12,13,14,15, 17,18,19,20,21, 23,24,25,26,28, 29,31,32,33,34 }; int a=i*10+j; for(i=0;i<20;i++) if(ftable[i]==a){ code=KEY_F+1+i;len=5;goto found;} } } } found: if((getch2_len-=len)>0){ int i; for(i=0;i * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include /* read() */ #include /* g_timeout_add() g_get_current_dir() */ #include "../yauap.h" #include "kbd.h" /* commandline frontend for yauap will accept commands from the keyboard see the README for keybindings enqeues all files given on the commandline into a playlist and plays it one after another quits after the last file */ /* track struct */ typedef struct track_s { char* url; struct track_s* next; struct track_s* prev; } track_t; /* private data for this frontend */ typedef struct commandline_frontend_s { int slave; /* true if using slave mode */ int noexit; /* quit after the last track is played */ track_t* playlist; track_t* playlist_head; track_t* current; } commandline_frontend_t; static int cmd_quit(yauap_frontend_t* frontend, char* args){ frontend->player->quit(frontend->player); return FALSE; } static int cmd_pause(yauap_frontend_t* frontend, char* args){ return frontend->player->pause(frontend->player); } static int cmd_set_volume(yauap_frontend_t* frontend,char * args){ player_t* player = frontend->player; double volume = player->get_volume(player); double value = 5.0; if(args) value = atof(args); /* default: value is relative */ volume += value; /* check if the value should be handled as absolute */ if((args = strstr(args," "))){ if(atoi(args)) volume = value; } player->set_volume(player,volume); return 1; } static int cmd_next_track(yauap_frontend_t* frontend,char* args){ commandline_frontend_t* priv = frontend->priv; player_t* player = frontend->player; player->stop(player); while(priv->current){ if(!priv->current->next){ printf("playlist finished\n"); if(!priv->noexit){ player->quit(player); return 0; } return 1; } priv->current = priv->current->next; /* check if we found a playable track */ if(player->can_decode(priv->current->url)){ player->load(player,priv->current->url); player->start(player); break; }else{ printf("can't handle %s\n",priv->current->url); } } return 1; } static int cmd_prev_track(yauap_frontend_t* frontend,char* args){ commandline_frontend_t* priv = frontend->priv; player_t* player = frontend->player; track_t* tmp = priv->current; player->stop(player); /* try to find a previous track */ while(tmp){ tmp = tmp->prev; if(tmp && player->can_decode(tmp->url)){ priv->current = tmp; break; } } if(priv->current){ player->load(player,priv->current->url); player->start(player); } return 1; } static int cmd_get_time_length(yauap_frontend_t* frontend,char* args){ printf("ANS_LENGTH=%.2lf\n",(double)frontend->player->get_time_length(frontend->player)/1000.0); return 1; } static int cmd_get_time_pos(yauap_frontend_t* frontend,char* args){ printf("ANS_TIME_POSITION=%.1f\n",(double)frontend->player->get_time_position(frontend->player)/1000.0 ); return 1; } static int cmd_seek(yauap_frontend_t* frontend,char* args){ unsigned int pos; int value,seek_type=0; player_t* player = frontend->player; if(!args || !strlen(args)){ //check if args are sane printf("invalid seek arguments\n"); return 1; } value = atoi(args); // get value args = strstr(args," "); // get seek_type if(args && strlen(args)){ seek_type = atoi(args); } pos = player->get_time_position(player); if(seek_type == 0){ pos += value*1000 ; } player->seek(player,pos); return 1; } /* output meta information */ static int cmd_info(yauap_frontend_t* frontend,char* args){ player_t* player = frontend->player; char** data=NULL; char** ptr; player->get_metadata(player,&data); for(ptr = data;*ptr;ptr++){ printf("%s\n",*ptr); free(*ptr); } free(data); return 1; } /* MPlayer style keyboard and slave mode commands */ static const struct { char* command; int key; int (*func)(yauap_frontend_t* frontend,char* args); char* args; } commandlist[] = { {"quit",'q',cmd_quit,NULL}, {NULL,KEY_ESC,cmd_quit,NULL}, {"pause",' ',cmd_pause,NULL}, {NULL,'p',cmd_pause,NULL}, {NULL,KEY_LEFT,cmd_seek,"-10 0"}, {NULL,KEY_RIGHT,cmd_seek,"10 0"}, {NULL,KEY_UP,cmd_seek,"60 0"}, {NULL,KEY_DOWN,cmd_seek,"-60 0"}, {NULL,'*',cmd_set_volume,"5.0"}, {NULL,'/',cmd_set_volume,"-5.0"}, {NULL,'>',cmd_next_track,NULL}, {NULL,'<',cmd_prev_track,NULL}, {"volume",0,cmd_set_volume,NULL}, {"get_time_length",0,cmd_get_time_length,NULL}, {"get_time_pos",0,cmd_get_time_pos,NULL}, {"info",'i',cmd_info,NULL}, }; #define CMD_BUF_LEN 256 /* handle slave commands from stdin */ static int handle_slave_cmd(yauap_frontend_t* frontend){ char buf[CMD_BUF_LEN]; int retval; int i; buf[CMD_BUF_LEN-1]='\0'; retval=read(0,buf,CMD_BUF_LEN-1); if(retval<1) return 1; for(i=0;iplayer; commandline_frontend_t* priv = frontend->priv; int returnv = 1; /* display time when not in slave mode */ if(!priv->slave){ unsigned int pos = player->get_time_position(player); unsigned int len = player->get_time_length(player); printf("\r\x1b[KTime: %" TIME_FORMAT " / %" TIME_FORMAT "\n\x1b[A\x1b[K",TIME_ARGS(pos) , TIME_ARGS(len)); } /* handle commands */ if(priv->slave) returnv = handle_slave_cmd(frontend); else returnv = handle_kbd_cmd(frontend); /* call me again */ return returnv; } /* signal callback will be called by the yauap backend */ static void signal_cb(yauap_frontend_t* frontend,unsigned int signal,char* message){ switch(signal){ case SIGNAL_EOS: cmd_next_track(frontend,NULL); break; case SIGNAL_METADATA: cmd_info(frontend,NULL); break; } } /* function checks if filename is already an uri and converts to a file uri otherwise the returned string has to be freed */ static char* create_url(const char* filename){ /* playbin always requires absolute paths */ char* current_dir = g_get_current_dir(); char* url; unsigned int max_len = strlen(current_dir); if(!filename) return NULL; max_len += strlen(filename) + strlen("file://") + 3; url = calloc(1,max_len+1); if(strstr(filename,"://")) strncpy(url,filename,max_len); else { /* assume that filename is a local file */ if(g_path_is_absolute(filename)) snprintf(url,max_len,"file://%s",filename); else snprintf(url,max_len,"file://%s/%s",current_dir,filename); } free(current_dir); return url; } /* free frontend resources */ static void commandline_free(yauap_frontend_t* frontend){ commandline_frontend_t* priv; if(!frontend) return; priv = frontend->priv; /* free playlist */ while(priv && priv->playlist_head){ track_t* tmp = priv->playlist_head->prev; if(priv->playlist_head->url) free(priv->playlist_head->url); free(priv->playlist_head); priv->playlist_head = tmp; if(priv->playlist_head) priv->playlist_head->next = NULL; } if(priv){ /* disable keyboard */ if(!priv->slave) kbd_disable(); free(priv); } free(frontend); } static void display_usage(void){ printf("Commandline usage: yauap [options] url1 [url2]\n" "options:\n" " -slave start in slave mode\n" " -noexit do not exit when the playlist is finished\n" "\n" "Keybindings:\n" " SPACE\n" " Pause/Unpause\n" " <- ->\n" " Seek backward/forward 10 seconds.\n" " up and down\n" " Seek backward/forward 1 minute.\n" " q / ESC\n" " Quit\n" " / and *\n" " Decrease/increase volume.\n\n"); } yauap_frontend_t* init_commandline(int argc, char* argv[],player_t* player){ int i; yauap_frontend_t* frontend = calloc(1,sizeof(yauap_frontend_t)); commandline_frontend_t* priv = calloc(1,sizeof(commandline_frontend_t)); /* fill functions and privdata */ frontend->priv = priv; frontend->free = commandline_free; frontend->player = player; frontend->signal_cb = signal_cb; /* set defaults */ priv->slave = 0; /* parse arguments */ for(i=1;islave = 1; if(!strcmp(argv[i],"-noexit")) priv->noexit = 1; else if(!strcmp(argv[i],"-h")){ display_usage(); commandline_free(frontend); return NULL; }else if(argv[i][0]=='-'){ //printf("ignoring unknown option %s\n",argv[i]); }else { /* append file to playlist */ if(!priv->playlist) priv->playlist = priv->current = priv->playlist_head = calloc(1,sizeof(track_t)); else{ priv->playlist_head->next = calloc(1,sizeof(track_t)); priv->playlist_head->next->prev = priv->playlist_head; priv->playlist_head=priv->playlist_head->next; } priv->playlist_head->url = create_url(argv[i]); } } if(!priv->slave) /* not runing in slave mode => enable keyboard */ kbd_enable(); /* add a player callback that handles input and displays status info */ g_timeout_add(200, (GSourceFunc) check_cmd_callback, frontend); /* if a filename is given try to start playback */ if(priv->current){ if(player->can_decode(priv->current->url)){ player->load(player,priv->current->url); player->start(player); }else{ printf("can't handle %s\n",priv->current->url); /* go to the first playable url */ if(!cmd_next_track(frontend,NULL)){ commandline_free(frontend); return NULL; } } }else{ if(!priv->noexit){ display_usage(); commandline_free(frontend); return NULL; } } if(player->verbose) printf("commandline frontend inited\n"); return frontend; } yauap-0.2.4/commandline/kbd.h0000644000175000001440000000572611152501274015224 0ustar saschausers/* * kbd.h - keyboard input functions * Copyright (c) 2006 Sascha Sommer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA based on osdep/keycodes.h from MPlayer (http://www.mplayerhq.hu) Copyright (c) 1999 A'rpi/ESP-team */ /* functions */ void kbd_enable(void); void kbd_disable(void); int getch2(); /* KEY code definitions for GyS-TermIO v2.0 (C) 1999 A'rpi/ESP-team */ #define KEY_ENTER 13 #define KEY_TAB 9 #define KEY_BASE 0x100 /* Function keys */ #define KEY_F (KEY_BASE+64) /* Control keys */ #define KEY_CTRL (KEY_BASE) #define KEY_BACKSPACE (KEY_CTRL+0) #define KEY_DELETE (KEY_CTRL+1) #define KEY_INSERT (KEY_CTRL+2) #define KEY_HOME (KEY_CTRL+3) #define KEY_END (KEY_CTRL+4) #define KEY_PAGE_UP (KEY_CTRL+5) #define KEY_PAGE_DOWN (KEY_CTRL+6) #define KEY_ESC (KEY_CTRL+7) /* Control keys short name */ #define KEY_BS KEY_BACKSPACE #define KEY_DEL KEY_DELETE #define KEY_INS KEY_INSERT #define KEY_PGUP KEY_PAGE_UP #define KEY_PGDOWN KEY_PAGE_DOWN #define KEY_PGDWN KEY_PAGE_DOWN /* Cursor movement */ #define KEY_CRSR (KEY_BASE+16) #define KEY_RIGHT (KEY_CRSR+0) #define KEY_LEFT (KEY_CRSR+1) #define KEY_DOWN (KEY_CRSR+2) #define KEY_UP (KEY_CRSR+3) /* Multimedia keyboard/remote keys */ #define KEY_MM_BASE (0x100+384) #define KEY_POWER (KEY_MM_BASE+0) #define KEY_MENU (KEY_MM_BASE+1) #define KEY_PLAY (KEY_MM_BASE+2) #define KEY_PAUSE (KEY_MM_BASE+3) #define KEY_PLAYPAUSE (KEY_MM_BASE+4) #define KEY_STOP (KEY_MM_BASE+5) #define KEY_FORWARD (KEY_MM_BASE+6) #define KEY_REWIND (KEY_MM_BASE+7) #define KEY_NEXT (KEY_MM_BASE+8) #define KEY_PREV (KEY_MM_BASE+9) #define KEY_VOLUME_UP (KEY_MM_BASE+10) #define KEY_VOLUME_DOWN (KEY_MM_BASE+11) #define KEY_MUTE (KEY_MM_BASE+12) /* Keypad keys */ #define KEY_KEYPAD (KEY_BASE+32) #define KEY_KP0 (KEY_KEYPAD+0) #define KEY_KP1 (KEY_KEYPAD+1) #define KEY_KP2 (KEY_KEYPAD+2) #define KEY_KP3 (KEY_KEYPAD+3) #define KEY_KP4 (KEY_KEYPAD+4) #define KEY_KP5 (KEY_KEYPAD+5) #define KEY_KP6 (KEY_KEYPAD+6) #define KEY_KP7 (KEY_KEYPAD+7) #define KEY_KP8 (KEY_KEYPAD+8) #define KEY_KP9 (KEY_KEYPAD+9) #define KEY_KPDEC (KEY_KEYPAD+10) #define KEY_KPINS (KEY_KEYPAD+11) #define KEY_KPDEL (KEY_KEYPAD+12) #define KEY_KPENTER (KEY_KEYPAD+13) /* Special keys */ #define KEY_INTERN (0x1000) #define KEY_CLOSE_WIN (KEY_INTERN+0) yauap-0.2.4/dbus-service/0000755000175000001440000000000011152501362014404 5ustar saschausersyauap-0.2.4/dbus-service/yauap-service.xml0000644000175000001440000000301011152501274017677 0ustar saschausers yauap-0.2.4/dbus-service/yauap-service.c0000644000175000001440000002143611152501274017335 0ustar saschausers/* * yauap-service.c - DBus frontend for yauap * Copyright (c) 2006 Sascha Sommer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include "../yauap.h" /* yauap dbus-service can be used to control yauap over the dbus IPC System see the amarok yauap engine for an example on how to use this the available functions and signals are listed in yauap-service.xml and described in the README */ /****************************** the yauap Object we export **********************************/ /* what a mess */ typedef struct { GObject parent; player_t* player; } yauapObject; typedef struct { GObjectClass parent; } yauapObjectClass; enum { METADATA_SIGNAL, EOS_SIGNAL, ERROR_SIGNAL, LAST_SIGNAL }; static guint signals[LAST_SIGNAL] = { 0 }; #define YAUAP_TYPE_OBJECT (yauap_object_get_type ()) G_DEFINE_TYPE(yauapObject, yauap_object, G_TYPE_OBJECT) /* methods: they are basically wrappers for the methods in the yauap struct */ static void yauap_object_init(yauapObject *obj){ } static void yauap_object_class_init(yauapObjectClass *klass){ /* only signal the metadata change */ /* leave it to the client if he wants to call get_metadata */ /* this way we do not need to create our own marshaller */ signals[METADATA_SIGNAL] = g_signal_new ("metadata_signal", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); signals[EOS_SIGNAL] = g_signal_new ("eos_signal", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); signals[ERROR_SIGNAL] = g_signal_new ("error_signal", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); } /* methods that should be usefull for amarok */ /* quit the player */ static gboolean yauap_object_quit(yauapObject *obj,GError **error){ obj->player->quit(obj->player); return TRUE; } /* stop playback */ static gboolean yauap_object_stop(yauapObject *obj,int* ret,GError **error){ *ret = obj->player->stop(obj->player); return TRUE; } /* start playback at offset in ms */ static gboolean yauap_object_start(yauapObject *obj,unsigned int offset,int* ret,GError **error){ *ret = obj->player->stop(obj->player); if(offset > 0) *ret = obj->player->seek(obj->player,offset); *ret = obj->player->start(obj->player); return TRUE; } /* load a uri */ static gboolean yauap_object_load(yauapObject *obj,const char* url,int* ret,GError **error){ *ret = obj->player->load(obj->player,url); return TRUE; } /* check wether we are able to decode the url */ static gboolean yauap_object_can_decode(yauapObject *obj,const char* url,int* can_decode,GError **error){ *can_decode = obj->player->can_decode(url); printf("can_decode(%s):%i\n",url,*can_decode); return TRUE; } /* pause playback, call this again to unpause */ static gboolean yauap_object_pause(yauapObject *obj,int* ret,GError **error){ *ret = obj->player->pause(obj->player); return TRUE; } /* fetch the metadata */ static gboolean yauap_object_get_metadata(yauapObject *obj, char ***ret, GError **error){ obj->player->get_metadata(obj->player,ret); return TRUE; } /* get audio_cd contents */ static gboolean yauap_object_get_audio_cd_contents(yauapObject *obj, char* device, char ***ret, GError **error){ obj->player->get_audio_cd_contents(obj->player,device,ret); return TRUE; } /* seek to position in ms */ static gboolean yauap_object_seek(yauapObject *obj,unsigned int position,int* ret,GError **error){ *ret = obj->player->seek(obj->player,position); return TRUE; } /* returns the track length in ms (player needs to be in the playing state for this to work) */ static gboolean yauap_object_get_length(yauapObject *obj,unsigned int* length,GError **error){ *length = obj->player->get_time_length(obj->player); return TRUE; } /* returns the current position in ms */ static gboolean yauap_object_get_position(yauapObject *obj,unsigned int* pos,GError **error){ *pos = obj->player->get_time_position(obj->player); return TRUE; } static gboolean yauap_object_get_volume(yauapObject *obj,unsigned int *volume,GError **error){ *volume = obj->player->get_volume(obj->player); return TRUE; } static gboolean yauap_object_set_volume(yauapObject *obj,unsigned int volume,int* ret,GError **error){ *ret = obj->player->set_volume(obj->player,volume); return TRUE; } static gboolean yauap_object_get_scopedata(yauapObject *obj,GArray** buf,GError **error){ *buf = g_array_new(FALSE,FALSE,sizeof(gchar)); *buf = g_array_set_size(*buf,SCOPE_SIZE); obj->player->get_scopedata(obj->player,(*buf)->data); return TRUE; } /* signal cb: informs the client that the updated metadata etc. can be fetched with get_metadata */ static void yauap_emit_metadata_signal(yauap_frontend_t* frontend,unsigned int signal,char* message){ yauapObject *obj = (yauapObject*)frontend->priv; switch(signal){ case SIGNAL_METADATA: g_signal_emit(obj, signals[METADATA_SIGNAL], 0,NULL); break; case SIGNAL_EOS: g_signal_emit(obj, signals[EOS_SIGNAL], 0,NULL); break; case SIGNAL_ERROR: g_signal_emit(obj, signals[ERROR_SIGNAL], 0, message); break; } if(obj->player->verbose) printf("emit signal %i %s\n",signal,message); } /* include glue code so that we can actually call these methods via dbus yauap-service-glue.h is autogenerated by dbus-binding-tool from yauap-service.xml which contains the interface definition */ #include "yauap-service-glue.h" /********************************* end of yauap object *******************************/ static void dbus_service_free(yauap_frontend_t* frontend){ if(frontend) free(frontend); } /* register dbus command interface */ yauap_frontend_t* init_dbus_service(player_t* player){ yauap_frontend_t* frontend = NULL; DBusGConnection *bus; DBusGProxy *bus_proxy; GError *error = NULL; yauapObject *obj; guint request_name_result; g_type_init(); dbus_g_object_type_install_info(YAUAP_TYPE_OBJECT, &dbus_glib_yauap_object_object_info); /* connect to the session bus */ bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if(!bus){ printf("Couldn't connect to session bus %s\n",error->message); return NULL; } bus_proxy = dbus_g_proxy_new_for_name(bus,"org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); /* Request a name */ if(!bus_proxy || !dbus_g_proxy_call(bus_proxy, "RequestName", &error, G_TYPE_STRING, "org.yauap.CommandService", G_TYPE_UINT, 0, G_TYPE_INVALID, G_TYPE_UINT, &request_name_result, G_TYPE_INVALID)){ printf("Failed to acquire org.yauap.CommandService %s\n", error->message); return NULL; } /* create and register our command object */ obj = g_object_new(YAUAP_TYPE_OBJECT, NULL); obj->player = player; /* connect us to yauap */ frontend = calloc(1,sizeof(yauap_frontend_t)); frontend->signal_cb = yauap_emit_metadata_signal; frontend->priv = obj; frontend->player = player; frontend->free = dbus_service_free; dbus_g_connection_register_g_object(bus, "/yauapObject", G_OBJECT(obj)); if(player->verbose) printf ("yauap dbus service running\n"); return frontend; } yauap-0.2.4/Makefile0000644000175000001440000000165111152501274013456 0ustar saschausers PREFIX=/usr bindir=$(DESTDIR)${PREFIX}/bin CFLAGS += -g3 -Wall #glib 2 CFLAGS += `pkg-config --cflags glib-2.0` LDFLAGS += `pkg-config --libs glib-2.0` #gstreamer CFLAGS += `pkg-config --cflags gstreamer-0.10` LDFLAGS += `pkg-config --libs gstreamer-0.10` -lgstpbutils-0.10 #dbus CFLAGS += `pkg-config --cflags dbus-1` LDFLAGS += `pkg-config --libs dbus-1` -ldbus-glib-1 CC=cc OBJS=main.o commandline/kbd.o commandline/commandline.o dbus-service/yauap-service.o BINDIR=/usr/local/bin DEPEND= makedepend $(CFLAGS) all: yauap $(SRCS): $(CC) $(CFLAGS) -c $*.c yauap-service-glue.h: dbus-binding-tool --prefix=yauap_object --mode=glib-server --output=dbus-service/yauap-service-glue.h dbus-service/yauap-service.xml yauap: yauap-service-glue.h $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) clean: -rm yauap $(OBJS) dbus-service/yauap-service-glue.h install: install -d "$(bindir)" install -m 755 yauap "$(bindir)" yauap-0.2.4/README0000644000175000001440000001173311152501274012700 0ustar saschausersyauap - A simple command-line frontend for GStreamer yauap is licenced under the GNU Lesser Public Licence. See the file COPYING for details. The latest version of yauap can be found at http://savannah.nongnu.org/projects/yauap/ SUSE RPMs can be downloaded from http://software.opensuse.org/download/home:/faust3/ Installation: In order to compile and run yauap you will need to have at least the following packages installed: gcc make pkgconfig gstreamer010 gstreamer010-plugins-base-oil gstreamer010-plugins-good gstreamer010-devel gstreamer010-plugins-base-devel dbus-1 dbus-1-x11 dbus-1-devel dbus-1-glib dbus-1-glib-devel glib2 glib2-devel Note that this list is for openSUSE 10.2. The packaging might be different for your distribution. Extract the yauap tarball with tar -xvzf yauap-version.tar.gz Then cd to the source dir and type make. If the build process completed without errors you can run "make install" to install the player binary to /usr/bin/yauap Afterwards yauap can be started by typing yauap on the command-line. "yauap -h" will list the available command-line options. To get started a simple yauap name_of_the_audio_file_you_want_to_play should do. Keybindings: SPACE Pause/Unpause <- -> Seek backward/forward 10 seconds. up and down Seek backward/forward 1 minute. q / ESC Quit / and * Decrease/increase volume. Amarok Engine: Amarok is a player with a nice graphical user interface available from http://amarok.kde.org . Amarok can be configured to use yauap for the actual playback part. In order to do this you need to compile Amarok with support for the yauap engine. First install the following additional packages. dbus-1-qt3 dbus-1-qt3-devel Then get the latest Amarok svn sources and build them like described in http://amarok.kde.org/wiki/Installation_HowTo . When you do the ./configure part make sure to pass the --with-yauap command-line switch to it. Check the output of configure for = The following extra functionality will be included: ... = + yauap-engine then continue with the Installation_HowTo After the installation the engine should be selectable in Amarok under Settings->Configure Amarok->Engine Development: CVS is available at the project page http://savannah.nongnu.org/projects/yauap/. The source layout ChangeLog - contains the latest Changes commandline/commandline.c - commandline control frontend for yauap commandline/kbd.c - keyboard i/o helper functions commandline/kbd.h - keyboard i/o declarations contrib/* - RPM specfiles and an early version of the yauap-engine for amarok COPYING - copy of the LGPL Licence dbus-service/yauap-service.c - dbus control frontend for yauap dbus-service/yauap-service.xml - Interface description for the yauap dbus service main.c - main player code Makefile - Makefile to build the main source dir and all subdirs README - this file yauap.h - c abstraction for the main player code (used by the frontends) yauap itself (main.c) is abstracted to a C player object. See the player_t struct in yauap.h. This player object initiates and controls the playback process. It uses GStreamer for the hard work. Currently the player object (and thus GStreamer) can be controlled with 2 frontends: 1. The commandline frontend - It accepts commands from the keyboard and outputs status information to the console. 2. The dbus-service - It accepts commands from the DBus session bus and sends events to it. Basically it creates a GObject from the C player struct and makes it accessible from the DBus. Events (errors, track end, etc.) get passed from the player to the frontends. The yauap DBus service: As explained above the dbus-service will provide a yauapObject that is accessible via the org.yauap.CommandService. The yauap object implements the org.yauap.CommandInterface with the following list of methods and their parameters: Parametertypes can be found in dbus-service/yauap-service.xml More detailed descriptions of the methods in yauap.h: can_decode IN url OUT 1 on success 0 on failure load IN url OUT 1 on success 0 on failure quit pause OUT 1 on success 0 on failure stop OUT 1 on success 0 on failure start IN start_offset in ms OUT 1 on success 0 on failure seek IN offset in ms OUT 1 on success 0 on failure get_length OUT length in ms get_position OUT position in ms get_metadata OUT NULL terminated string list of metadata in the form tag=value for example author=name etc... get_audio_cd_contents IN cdrom_device (unix device name /dev/hdc etc.) OUT NULL terminated track list in the form tracknr=length in seconds for example 01=400 get_scopedata OUT array with the size of 2048 bytes containing integer 16bit little endian stereo audio samples get_volume OUT current volume in the range [0-100] set_volume IN new_volume OUT 1 on success 0 on failure Signals: MetadataSignal: the streams metadata changed EosSignal: the current stream ended ErrorSignal IN message: a (fatal) error occured (note that the player will send an EosSignal afterwards) 2006.12.20 Sascha Sommer yauap-0.2.4/main.c0000644000175000001440000006416711152501274013121 0ustar saschausers/* * yauap - A simple commandline frontend for GStreamer * Copyright (c) 2006 - 2008 Sascha Sommer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include "yauap.h" #define VERSION "0.2.4" #define NUM_FRONTENDS 2 yauap_frontend_t* init_commandline(int argc, char* argv[],player_t* player); yauap_frontend_t* init_dbus_service(player_t* player); /* private data */ typedef struct yauap_priv_s { char* cdrom_device; GMainLoop *loop; GstElement *play; /* the playback pipeline */ GstTagList* tag_list; GstElement *volume; float cur_volume; GstElement *audio; /* audio chain (format conversion, resampling, volume, output sink) */ int num_frontends; yauap_frontend_t** frontends; int use_scope; #define SAMPLE_BUFFER_SIZE (SCOPE_SIZE * 1000) unsigned char sample_buffer[SAMPLE_BUFFER_SIZE]; unsigned int sample_scale; int write_pos; int read_pos; guint64 sample_timestamp; } yauap_priv_t; /* send signals to the frontends */ static void signal_frontend(player_t* player,unsigned int signal,char* message){ yauap_priv_t* priv = player->yauap_priv; int i; for(i=0;inum_frontends;i++){ yauap_frontend_t* frontend = priv->frontends[i]; if(frontend && frontend->signal_cb) frontend->signal_cb(frontend,signal,message); } } /* functions that interact with gstreamer they are used by the dbus service*/ /* quit the player */ static int player_quit(player_t* player){ yauap_priv_t* priv = player->yauap_priv; g_main_loop_quit(priv->loop); return TRUE; } /* pause / unpause */ static int player_pause(player_t* player){ yauap_priv_t* priv = player->yauap_priv; GstState state; if(!priv->play) return TRUE; if(!gst_element_get_state(priv->play, &state, NULL, 0)){ printf("error: player_pause: gst_element_get_state failed\n"); return FALSE; } if(state == GST_STATE_PLAYING){ gst_element_set_state(priv->play,GST_STATE_PAUSED); printf("pause\n"); }else gst_element_set_state(priv->play,GST_STATE_PLAYING); return TRUE; } /* return time length in ms */ static unsigned int player_get_time_length(player_t* player){ yauap_priv_t* priv = player->yauap_priv; GstFormat fmt = GST_FORMAT_TIME; gint64 len = 0; if(priv->play) gst_element_query_duration(priv->play, &fmt, &len); return len / GST_MSECOND; } /* return current position in ms */ static unsigned int player_get_time_position(player_t* player){ yauap_priv_t* priv = player->yauap_priv; GstFormat fmt = GST_FORMAT_TIME; gint64 pos = 0; if(priv->play) gst_element_query_position(priv->play, &fmt, &pos); return pos / GST_MSECOND; } /* stop playback */ static int player_stop(player_t* player){ yauap_priv_t* priv = player->yauap_priv; /* stop playback */ if(priv->play) gst_element_set_state(priv->play, GST_STATE_NULL); if(priv->tag_list){ gst_tag_list_free(priv->tag_list); priv->tag_list = NULL; } return TRUE; } /* seek to offset in ms */ static int player_seek(player_t* player,unsigned int offset){ yauap_priv_t* priv = player->yauap_priv; if(player->verbose) printf("seeking to %i\n",offset); if(!priv->play) return TRUE; /* reset sample buffer (for scope) */ priv->write_pos = priv->read_pos = 0; memset(priv->sample_buffer,0,SAMPLE_BUFFER_SIZE); if(!gst_element_seek(priv->play,1.0,GST_FORMAT_TIME,GST_SEEK_FLAG_ACCURATE|GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET,offset * GST_MSECOND,GST_SEEK_TYPE_NONE, 0)){ printf("seek failed\n"); player->start(player); } return TRUE; } /* return current volume [0-100] */ static float player_get_volume(player_t* player){ yauap_priv_t* priv = player->yauap_priv; gdouble volume = 0.0; /* get current volume */ if(priv->volume) g_object_get( G_OBJECT(priv->volume), "volume", &volume, NULL ); return volume * 10.0; } /* set new volume [0-100] */ static int player_set_volume(player_t* player,float value){ yauap_priv_t* priv = player->yauap_priv; gdouble volume = value; priv->cur_volume = value; if(!priv->volume) return TRUE; /* change range from 0 - 100 to 0 - 4 */ volume *= 0.1; /* ajust values */ if(volume < 0.0) volume = 0.0; else if(volume > 10.0) volume = 10.0; printf("\nsetting volume %f\n",value); g_object_set(G_OBJECT(priv->volume), "volume", volume, NULL); return TRUE; } /* start playback */ #define PLAY_TIMEOUT 1000 static int player_start(player_t* player){ yauap_priv_t* priv = player->yauap_priv; GstState state; int timeout = PLAY_TIMEOUT; if(!priv->play) return TRUE; /* reset sample buffer (for scope) */ priv->write_pos = priv->read_pos = 0; memset(priv->sample_buffer,0,SAMPLE_BUFFER_SIZE); /* start playback */ gst_element_set_state(priv->play, GST_STATE_PLAYING); /* wait until we are really playing back */ while(timeout > 0 && gst_element_get_state(priv->play, &state, NULL, 0) && state != GST_STATE_PLAYING){ // printf("waiting...\n"); usleep(100); --timeout; } if(timeout <= 0){ printf("timed out waiting for playback to start\n"); return TRUE; } return TRUE; } /* metadata handling */ static void list_append_string(char*** ret,const char* tag,char* str){ unsigned int len = strlen(tag)+strlen(str)+2; char* tmp = calloc(1,len); snprintf(tmp,len,"%s=%s",tag,str); (*ret)[0] = strdup(tmp); *ret = *ret + 1; free(tmp); } static void list_append_uint(char*** ret,const char* tag,unsigned int value){ char buf[100]; snprintf(buf,sizeof(buf),"%u",value); list_append_string(ret,tag,buf); } /* read out metadata and append it to the string list in user_data */ static void tag_for_each(const GstTagList *list,const gchar *tag,gpointer user_data){ char***ret = user_data; GType type = gst_tag_get_type(tag); if(type==G_TYPE_STRING){ char* str_value; if(gst_tag_list_get_string(list,tag,&str_value)){ list_append_string(ret,tag,str_value); g_free(str_value); } }else if(type == G_TYPE_UINT){ unsigned int uint_value=0; if(gst_tag_list_get_uint(list,tag,&uint_value)) list_append_uint(ret,tag,uint_value); }else if(type == GST_TYPE_DATE){ GDate* date=NULL; if(gst_tag_list_get_date(list,tag,&date)) list_append_uint(ret,tag,g_date_get_year(date)); } } /* count the entries in a taglist */ static void taglist_count_entries(const GstTagList *list,const gchar *tag,gpointer user_data){ unsigned int* cnt = user_data; *cnt = *cnt + 1; } /* get a list with all meta infos */ static int player_get_metadata(player_t* player,char*** ret){ yauap_priv_t* priv = player->yauap_priv; GstCaps *caps; GstStructure *str; GstPad *audiopad = NULL; unsigned int num_tags = 0; char** ptr; gst_tag_list_foreach(priv->tag_list,taglist_count_entries,&num_tags); /* count tags */ *ret = ptr = calloc(num_tags+4,sizeof(char*)); /* allocate taglist for tags + num_channels + samplerate + length */ /* get tags from tag_list */ gst_tag_list_foreach(priv->tag_list,tag_for_each,&ptr); /* get samplerate and channels */ if(priv->audio) audiopad = gst_element_get_pad(priv->audio, "sink"); /* get negotiated caps */ if(audiopad && GST_IS_PAD(audiopad)){ int rate=0,channels=0; caps = gst_pad_get_negotiated_caps(GST_PAD_CAST(audiopad)); str = gst_caps_get_structure(caps, 0); if(str && gst_structure_get_int(str,"rate",&rate)) list_append_uint(&ptr,"samplerate",rate); if(gst_structure_get_int(str,"channels",&channels)) list_append_uint(&ptr,"channels",channels); } /* get length */ list_append_uint(&ptr,"length",player_get_time_length(player)); /* terminate the list */ ptr[0]=NULL; /* test */ #if 0 ptr = *ret; while(*ptr){ printf("%s\n",*ptr); ++ptr; } #endif return TRUE; } /* return current audio sample buffer */ static int player_get_scopedata(player_t* player,char* buf){ yauap_priv_t* priv = player->yauap_priv; unsigned int remaining; if(!priv->use_scope){ memset(buf,0,SCOPE_SIZE); return TRUE; } #if 1 priv->read_pos = priv->write_pos - SCOPE_SIZE; if(priv->read_pos < 0) priv->read_pos += SAMPLE_BUFFER_SIZE; #endif remaining = SAMPLE_BUFFER_SIZE - priv->read_pos; memcpy(buf,priv->sample_buffer + priv->read_pos,(remaining > SCOPE_SIZE)?SCOPE_SIZE:remaining ); if(remaining < SCOPE_SIZE) memcpy(buf + remaining,priv->sample_buffer,SCOPE_SIZE - remaining); priv->read_pos = (priv->read_pos + SCOPE_SIZE) % SAMPLE_BUFFER_SIZE; return TRUE; } /* function that handles messages from gstreamer */ static gboolean gstreamer_callback(GstBus *bus,GstMessage *msg,gpointer data){ player_t* player = data; yauap_priv_t* priv = player->yauap_priv; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_TAG:{ GstTagList* tlist; gst_message_parse_tag(msg,&tlist); priv->tag_list = gst_tag_list_merge(priv->tag_list,tlist,GST_TAG_MERGE_PREPEND); /* signal metadata change */ signal_frontend(player,SIGNAL_METADATA,"new metadata"); } break; case GST_MESSAGE_EOS: printf("\nEnd-of-stream\n"); player_stop(player); signal_frontend(player,SIGNAL_EOS,"end of stream"); break; case GST_MESSAGE_ELEMENT: if(gst_is_missing_plugin_message(msg)){ char* desc = gst_missing_plugin_message_get_description(msg); char* installer_details = gst_missing_plugin_message_get_installer_detail(msg); size_t msg_len = strlen(desc) + strlen(installer_details) + strlen("plugin ") + strlen(" is missing (") + 2; char* text = malloc(msg_len); snprintf(text,msg_len,"plugin %s is missing (%s)",desc,installer_details); if(desc) g_free(desc); if(installer_details) g_free(installer_details); printf("\nError: %s\n",text); signal_frontend(player,SIGNAL_ERROR,text); free(text); signal_frontend(player,SIGNAL_EOS,"unable to continue"); player_stop(player); } break; case GST_MESSAGE_ERROR: { gchar *debug; GError *err; gst_message_parse_error (msg, &err, &debug); g_free (debug); printf("\nError: %s\n", err->message); signal_frontend(player,SIGNAL_ERROR,err->message); g_error_free (err); signal_frontend(player,SIGNAL_EOS,"unable to continue"); player_stop(player); break; } default: break; } return TRUE; } /* callback function that gets called once the output format of the decoder is figured out the audio filter chain gets connected to the pipeline here */ static void cb_new_decoded_pad(GstElement *decodebin,GstPad *pad,gboolean last,gpointer data){ GstCaps *caps; GstStructure *str; GstPad *audiopad; yauap_priv_t* priv = data; /* remove already linked element */ audiopad = gst_element_get_pad(priv->audio, "sink"); if (GST_PAD_IS_LINKED(audiopad)) { g_object_unref(audiopad); return; } caps = gst_pad_get_caps(pad); str = gst_caps_get_structure(caps, 0); if (!str || !g_strrstr(gst_structure_get_name(str), "audio")) { gst_caps_unref(caps); gst_object_unref(audiopad); return; } gst_caps_unref(caps); /* link */ gst_pad_link(pad, audiopad); } /* get sample buffer (assumes 16-bit 2 channel audio ) */ static void handoff_cb( GstPad* pad, GstBuffer* buf, gpointer arg){ player_t* player = arg; yauap_priv_t* priv = player->yauap_priv; unsigned char* data = GST_BUFFER_DATA(buf); unsigned int len = buf->size; GstStructure* s = gst_caps_get_structure(GST_BUFFER_CAPS(buf),0); int channels = 0; int endianness = 0; gboolean is_signed = 0; int width = 0; int space = SAMPLE_BUFFER_SIZE - priv->write_pos; s = gst_caps_get_structure ( GST_BUFFER_CAPS( buf ), 0); gst_structure_get_int(s,"channels",&channels); gst_structure_get_int(s,"endianness",&endianness); gst_structure_get_boolean(s,"signed",&is_signed); gst_structure_get_int(s,"width",&width); /* printf("%s\n", gst_caps_to_string(GST_BUFFER_CAPS(buf))); */ /* check format */ if(channels != 2 || endianness != 1234 || ! is_signed || width != 16 ) return; if(len > SAMPLE_BUFFER_SIZE){ printf("increase sample buffer size !!!!!!!!!\n"); return; } /* fill scope ring buffer */ if(space >= len){ memcpy(priv->sample_buffer + priv->write_pos,data,len); }else{ memcpy(priv->sample_buffer + priv->write_pos,data,space); memcpy(priv->sample_buffer, data + space, len - space); } priv->write_pos = ( priv->write_pos + len ) % SAMPLE_BUFFER_SIZE; /* update timestamp of the last sample */ priv->sample_timestamp = GST_BUFFER_TIMESTAMP( buf ) + GST_BUFFER_DURATION( buf ) ; /* calculate how many nanoseconds are represented by 1 byte */ priv->sample_scale = GST_BUFFER_DURATION(buf) / GST_BUFFER_SIZE(buf); } /* create/recreate the GStreamer playback pipeline */ static int create_play_pipeline(player_t* player,const char* url){ yauap_priv_t* priv = player->yauap_priv; GstBus *bus; GstElement* src = NULL; GstElement* decode = NULL; GstElement* convert; GstElement* resample; GstElement* audiosink; GstElement* identity; GstPad* audiopad; GstPad* convertpad; gchar* protocol; int is_cdda; player->stop(player); /* destroy the existing pipeline */ if(priv->play) gst_object_unref(GST_OBJECT(priv->play)); /* check for audio cds */ protocol = gst_uri_get_protocol(url); is_cdda = !strcmp(protocol,"cdda"); free(protocol); /* set up gstreamer pipeline */ src = gst_element_make_from_uri(GST_URI_SRC, url,"source"); if(!src){ printf("element make from uri failed for url %s\n",url); return 1; } /* set cdrom device */ if(priv->cdrom_device && !strcmp(G_OBJECT_TYPE_NAME(src),"GstCdParanoiaSrc")) g_object_set(src, "device", priv->cdrom_device, NULL); /* create a simple audio pipeline */ priv->play = gst_element_factory_make("pipeline","play"); /* create a generic decoder (the src element will be created in player_load) */ if(!is_cdda) decode = gst_element_factory_make("decodebin", "decoder"); /* create audio filter chain */ priv->audio = gst_bin_new("audiobin"); /* create conversion, resample, volume and audio output filters */ convert = gst_element_factory_make("audioconvert", "convert"); resample = gst_element_factory_make ("audioresample", "aresample"); priv->volume = gst_element_factory_make ("volume", "volume"); audiosink = gst_element_factory_make("gconfaudiosink", "audiosink"); if (!audiosink) audiosink = gst_element_factory_make("autoaudiosink", "audiosink"); /* clone the data for the scope */ identity = gst_element_factory_make("identity","identity"); /* check if the necessary plugins are really installed */ if(!convert || !resample || !priv->volume || !audiosink || !identity || (!is_cdda && !decode)){ printf("error couldn't load gstreamer plugins\n"); printf("convert=%p resample=%p volume=%p audiosink=%p identity=%p decode=%p\n",convert,resample,priv->volume,audiosink,identity,decode); return 1; } /* add them to the pipeline and link them */ gst_bin_add_many (GST_BIN(priv->audio), convert, identity,priv->volume,resample,audiosink, NULL); /* create a sink pad for our audio filter chain similar to the pad of the conversion filter */ audiopad = gst_element_get_pad(convert, "sink"); gst_element_add_pad(priv->audio,gst_ghost_pad_new ("sink", audiopad)); gst_object_unref(audiopad); if(priv->use_scope){ /* add a data probe to the src of the convert pad */ convertpad = gst_element_get_pad(convert, "src"); gst_pad_add_buffer_probe(convertpad, G_CALLBACK(handoff_cb), player); gst_object_unref(convertpad); } gst_element_link_many(convert,identity,priv->volume,resample,audiosink,NULL); /* add the src element, the audio decoder and the audio filter chain to our pipeline */ gst_bin_add_many(GST_BIN(priv->play), src, priv->audio, NULL); /* no decoder is used for cdda playback */ if(!is_cdda){ gst_bin_add(GST_BIN(priv->play),decode); gst_element_link(src,decode); /* connect the cb_new_decoded_pad callback */ g_signal_connect(decode, "new-decoded-pad", G_CALLBACK(cb_new_decoded_pad), priv); }else gst_element_link(src, priv->audio); /* connect bus callback */ bus = gst_pipeline_get_bus(GST_PIPELINE (priv->play)); gst_bus_add_watch(bus, gstreamer_callback, player); gst_object_unref(bus); /* set volume */ if(priv->cur_volume != 200.0) player->set_volume(player,priv->cur_volume); return 0; } /* load a new url */ static int player_load(player_t* player,const char* url){ /* uninit */ player_stop(player); printf("loading url %s\n",url); if(create_play_pipeline(player,url)) return TRUE; return TRUE; } /* get a list of available tracks for the auido cd in cdrom_device */ /* ret will be a NULL terminated list with entires TrackNr=length */ static int player_get_audio_cd_contents(player_t* player,char* cdrom_device, char*** ret){ yauap_priv_t* priv = player->yauap_priv; GstFormat format; /* create elements */ GstElement* src = gst_element_factory_make("cdparanoiasrc", "src"); GstElement* play = gst_element_factory_make("pipeline","play"); GstElement* output = gst_element_factory_make("fakesink","output"); if(!src || !play || !output){ printf("failed to create the required audio cd elements src=%p play=%p output=%p\n",src,play,output); return 0; } /* update cdrom_device what a hack */ if(cdrom_device){ printf("setting cdrom_device to %s\n",cdrom_device); if(priv->cdrom_device) free(priv->cdrom_device); priv->cdrom_device = strdup(cdrom_device); } /* create pipeline */ gst_bin_add_many(GST_BIN(play),src,output,NULL); gst_element_link_many(src,output,NULL); /* set audio device */ if(priv->cdrom_device) g_object_set(src, "device", priv->cdrom_device, NULL); gst_element_set_state( play, GST_STATE_PAUSED ) ; if((format = gst_format_get_by_nick("track")) != GST_FORMAT_UNDEFINED){ int i; gint64 tracks = 0; char tmp[200]; if(gst_element_query_duration(play,&format,&tracks)){ if(tracks) *ret = calloc(tracks + 1,sizeof(char*)); for(i=1;i <= tracks;i++){ GstFormat fmt = GST_FORMAT_TIME; gint64 len = 0; gst_element_set_state(play,GST_STATE_NULL); g_object_set(src, "track", i, NULL); /* reload to update metadata */ gst_element_set_state(play,GST_STATE_PAUSED); gst_element_query_duration(play, &fmt, &len); snprintf(tmp,sizeof(tmp),"%i=%lli",i,len / GST_SECOND); (*ret)[i-1] = strdup(tmp); printf("Track%i len %llis\n",i,len/ GST_SECOND); } } } gst_object_unref( GST_OBJECT( play ) ); return 1; } /************************ decodeable check ***************************************/ /* how many microseconds shall we wait for the detection to succeed */ #define DETECT_TIMEOUT 100000 /* callback function that checks if a audio decoder has been added */ static void can_decode_new_decode_pad_callback(GstElement* element, GstPad* pad, gboolean a, gpointer data){ int* can_decode=data; GstCaps* caps = gst_pad_get_caps( pad ); if(gst_caps_get_size(caps)>0) { GstStructure* str = gst_caps_get_structure( caps,0 ); if(g_strrstr(gst_structure_get_name( str ), "audio" )) *can_decode = 1; } gst_caps_unref( caps ); } /* callback function that terminates the detection process */ static void can_decode_no_more_pads_callback(GstElement* element, gpointer data){ int* last = (int*)data; *last = 1; } /* checks if we are able to decode the audio part of the given url */ /* simply starts playback with fake video and audio output devices */ /* returns nonzero on success, zero otherwise */ /* audio cds always succeed */ static int player_can_decode(const char* url){ GstElement* src; gchar* protocol; int can_decode=0; int last = 0; unsigned int timeout = 0; /* create a simple decode pipeline */ GstElement* play = gst_element_factory_make("pipeline", "can_decode_play"); if(!play) return 0; src = gst_element_make_from_uri(GST_URI_SRC, url,"can_decode_source"); /* check if we can handle the protocol */ if( !src || !(protocol = gst_uri_get_protocol(url))){ if(play) gst_object_unref( GST_OBJECT( play ) ); return 0; } gst_bin_add( GST_BIN( play ), src); /* check if we have a decoder for the given format if the uri is no audio cd */ if(!strcmp(protocol,"cdda")) can_decode = 1; else { GstElement* decodebin = gst_element_factory_make("decodebin", "can_decode_decode"); gst_bin_add( GST_BIN( play ), decodebin ); gst_element_link( src, decodebin ); /* connect signal handlers */ g_signal_connect( G_OBJECT( decodebin ), "new-decoded-pad", G_CALLBACK( can_decode_new_decode_pad_callback ), &can_decode ); g_signal_connect( G_OBJECT( decodebin ), "no-more-pads", G_CALLBACK( can_decode_no_more_pads_callback ), &last ); /* start decoding */ gst_element_set_state(play,GST_STATE_PLAYING ); /* wait a bit */ while ( !can_decode && !last && timeout < DETECT_TIMEOUT ) { timeout += 1000; usleep(1000); } /* stop playback */ gst_element_set_state(play,GST_STATE_NULL); } g_free(protocol); /* destroy pipeline */ gst_object_unref( GST_OBJECT( play ) ); return can_decode; } /****************************** end decodeabel ***************************************/ static void display_usage(void){ printf("General usage: yauap [options]\n" "General options:\n" " -h display this help\n" " -cdrom-device set the cdrom device\n" "\n"); } int main(int argc, char* argv[]){ player_t* player = calloc(1,sizeof(player_t)); yauap_priv_t* priv = calloc(1,sizeof(yauap_priv_t)); int i; int run=1; printf("yauap " VERSION " (C) 2006-2008 Sascha Sommer \n"); /* set function pointers */ player->quit = player_quit; player->pause = player_pause; player->can_decode = player_can_decode; player->stop = player_stop; player->load = player_load; player->start = player_start; player->get_time_length = player_get_time_length; player->get_time_position = player_get_time_position; player->seek = player_seek; player->get_metadata = player_get_metadata; player->get_audio_cd_contents = player_get_audio_cd_contents; player->get_scopedata = player_get_scopedata; player->get_volume = player_get_volume; player->set_volume = player_set_volume; player->yauap_priv = priv; priv->use_scope = 1; priv->cur_volume = 200.0; /* init value == do nothing */ priv->num_frontends = NUM_FRONTENDS; priv->frontends = calloc(1,sizeof(yauap_frontend_t*)*priv->num_frontends); /* init gstreamer */ gst_init(&argc, &argv); /* parse generic arguments */ for(i=1;iverbose=1; }else if(!strcmp(argv[i],"-cdrom-device")){ if(i + 1 >= argc){ printf("-cdrom-device requires a parameter\n"); run = 0; }else{ ++i; priv->cdrom_device=strdup(argv[i]); printf("setting cdrom-device %s\n",priv->cdrom_device); } } } /* create main loop */ priv->loop = g_main_loop_new(NULL, FALSE); priv->tag_list = gst_tag_list_new(); /* init frontends */ priv->frontends[0] = init_dbus_service(player); priv->frontends[1] = init_commandline(argc, argv,player); /* fixme currently we require the commandline frontend */ if(!priv->frontends[1]) run = 0; /* run the main loop */ if(run) g_main_loop_run(priv->loop); /* make sure that we really stopped */ player_stop(player); /* uninit frontends */ for(i=0;inum_frontends;i++){ if(priv->frontends[i] && priv->frontends[i]->free) priv->frontends[i]->free(priv->frontends[i]); } /* clean up */ if(priv->play) gst_object_unref(GST_OBJECT(priv->play)); free(priv->frontends); free(priv->cdrom_device); free(priv); free(player); gst_deinit(); printf("\n"); return 0; } yauap-0.2.4/contrib/0000755000175000001440000000000011152501321013444 5ustar saschausersyauap-0.2.4/contrib/yauap.spec0000644000175000001440000000270411152501274015451 0ustar saschausers# # spec file for package yauap (Version 0.2pre1) # # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine # package are under the same license as the package itself. # # Please submit bugfixes or comments via http://bugs.opensuse.org/ # # norootforbuild Name: yauap BuildRequires: dbus-1-devel gstreamer010-devel %if %suse_version > 1010 BuildRequires: dbus-1-glib-devel %endif Summary: The useless audio player Version: 0.2.1 Release: 32 URL: http://www.nongnu.org/yauap/ License: GNU Library General Public License v. 2.0 and 2.1 (LGPL) Group: Productivity/Multimedia/Sound/Players Requires: gstreamer010 gstreamer010-plugins-base-oil gstreamer010-plugins-good dbus-1-x11 BuildRoot: %{_tmppath}/%{name}-%{version}-build Source0: %{name}-%{version}.tar.gz %description yauap is a simple commandline audio player based on GStreamer. Authors: -------- Sascha Sommer %prep %setup -q %build export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" %__make %install %makeinstall %clean %{__rm} -rf "%{buildroot}" %files %defattr(-,root,root) %doc README COPYING %{_bindir}/yauap %changelog * Fri Jun 01 2007 - dmueller@suse.de - don't strip binaries * Fri Jun 01 2007 - ssommer@suse.de - strip binary - package documentation * Mon Jan 08 2007 - ssommer@suse.de - initial package of version 0.1 yauap-0.2.4/ChangeLog0000644000175000001440000000255211152501274013571 0ustar saschausersyauap 0.2.4 0.2.4: 01. Mar, 2009 use gconfaudiosink as default audiosink yauap 0.2.3 0.2.3: 05. Oct, 2008 fixed volume control of the playbin element (#22977) yauap 0.2.2 0.2.2: 14. Jan, 2008 make sure that the player stops before a new file starts to play fix segfault in player_get_scopedata (https://bugzilla.novell.com/show_bug.cgi?id=301791) report missing plugins (https://bugzilla.novell.com/show_bug.cgi?id=307754) terminate yauap when the stdin got closed yauap 0.2.1 0.2.1: 31. Jul, 2007 updated SUSE specfile yauap 0.2 0.2: 31. Jul, 2007 print version and keybindings in the help text 0.2pre1: 15. Jan, 2007 warning fixes yauap 0.1 0.1: 08. Jan, 2007 removed outdated amarok yauap engine diffs 0.1pre8: 20. Dec, 2006 Documentation updates 0.1pre7: 19. Dec, 2006 use ErrorSignal to send error messages 0.1pre6: 19. Dec, 2006 audio cd support 0.1pre5: 05. Dec, 2006 recreate filter chain during load() (fixes some mp3 playback issues) 0.1pre4: 16. Nov, 2006 skip unplayable files in commandline only mode be less verbose updated amarok engine diff 0.1pre3: 7. Nov, 2006 check format to avoid sending the wrong scope data improved scope synchronisation 0.1pre2: 6. Nov, 2006 make the yauap-engine compile on x86_64 added ChangeLog 0.1pre1: 2. Nov, 2006 initial revision yauap-0.2.4/COPYING0000644000175000001440000006347411152501274013064 0ustar saschausers GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! yauap-0.2.4/yauap.h0000644000175000001440000001206311152501274013305 0ustar saschausers/* * yauap - A simple commandline frontend for GStreamer * Copyright (c) 2006 Sascha Sommer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef YAUAP_H #define YAUAP_H 1 /* the player struct: must be plain C code do not introdue glib or dbus specific things here * function pointers get filled by main.c * this struct should not be changed from within the frontends */ typedef struct player_s{ /* private data used by main.c - ignore */ void* yauap_priv; /* player verbosity set to 1 to become more verbose */ int verbose; /* methods (if not explained otherwise return 1 on success, 0 on failure) */ int (*quit)(struct player_s* player); int (*pause)(struct player_s* player); /* check if a url can be decoded (files need to be prefixed with the file:// protocol) * this function can be called at any time */ int (*can_decode)(const char* url); int (*load)(struct player_s* player,const char* url); int (*stop)(struct player_s* player); int (*start)(struct player_s* player); /* get the current track length / position in ms */ unsigned int (*get_time_length)(struct player_s* player); unsigned int (*get_time_position)(struct player_s* player); /* seek to offset in ms */ int (*seek)(struct player_s* player,unsigned int offset); /* return current volume in the range [0.0 - 100.0] */ float (*get_volume)(struct player_s* player); int (*set_volume)(struct player_s* player,float volume); /* get a NULL terminated list of metadata for example: * author=blah * title=test * * the name of the tags is similar to the name of the tracks in GStreamer */ int (*get_metadata)(struct player_s* player,char ***metadata); /* get audio cd contents: overwrites the set cdrom_device when device is NULL * cdrom_device shall be an unix device * the NULL terminated track list will look like * 01=210 * 02=44 * * eg. the track numer followed by = and the track length in seconds * this function can be called at any time but remember that it overwrites the used cdrom_device */ int (*get_audio_cd_contents)(struct player_s* player,char* device,char*** tracks); #define SCOPE_SIZE 2048 /* get current scope buffer - data has to be at least SCOPE_SIZE bytes */ /* scope data is raw 16 bit little endian 2 channel audio data */ int (*get_scopedata)(struct player_s* player,char * data); } player_t; /* example call order for the various functions 1. can_decode() / get_audio_cd_contents() to check if a file is playable 2. load() to load a file 3. start() to start playback 4. a combination of the following functions get_volume() set_volume() get_time_length() seek() pause() (call start or pause again to unpause) get_metadata() to get the metadata for the current track get_scopedata() get scopedata for audio visualization etc. get_time_position() to update postion sliders whatever 5. stop() to stop playback 6. either start() to restart playback of the current track from the beginning quit() to terminate the player and its control frontends or can_decode() / get_audio_cd_contents() again for new files */ /* yauap can be controlled by frontends currently there is a commandline frontend in the commandline/ dir and a dbus service in the dbus-service/ dir these frontends use the player_t struct to control the main player code They should return the following struct (currently this is hardwired in main.c): */ typedef struct yauap_frontend_s { /* deallocate the frontend resources (and the memory for the passed frontend_struct) */ void (*free)(struct yauap_frontend_s* frontend); /* signal_cb() the player core in main.c will call this to inform the frontends when one of the following events happened: */ #define SIGNAL_METADATA 1 /* the streams metadata changed and should be refeteched with get_metadata() */ #define SIGNAL_EOS 2 /* end of stream reached or unplayable file */ #define SIGNAL_ERROR 3 /* an error occured: message will contain the error message */ void (*signal_cb)(struct yauap_frontend_s* frontend,unsigned int signal,char* message); /* priv can be used to store private data from the frontend */ void* priv; /* pointer to the player object (use this to control it */ struct player_s* player; } yauap_frontend_t; #endif