int player_list_allpid(pid_info_t *pid)
{
    char buf[MAX_PLAYER_THREADS];
    int pnum = 0;
    int i;

    pnum = player_list_pid(buf, MAX_PLAYER_THREADS);
    pid->num = pnum;

    for (i = 0; i < pnum; i++) {
        pid->pid[i] = buf[i];
    }

    return 0;
}
static int shell_get_command(player_cmd_t *playercmd)
{

	int  ret;
    fd_set rfds;
    struct timeval tv;
	int fd=fileno(stdin);
    
#define is_CMD(str,cmd,s_cmd1,s_cmd2) (strcmp(str,cmd)==0 || strcmp(str,s_cmd1)==0 || strcmp(str,s_cmd2)==0)

	FD_ZERO(&rfds);
	FD_SET(fd, &rfds);
	tv.tv_sec = 0;
	tv.tv_usec = 3 * 1000 * 1000;       
	ret = select(fd+1, &rfds, NULL, NULL, &tv);
   
	if(ret > 0 && FD_ISSET(fd, &rfds))
	{            
    	char str[100]={0};
    	scanf("%s",str);
    	//gets(str);
    	if(is_CMD(str,"quit","x","X"))
		{
		    playercmd->ctrl_cmd = CMD_EXIT;
		}
	    else if(is_CMD(str,"stop","s","s"))
		{
		    playercmd->ctrl_cmd = CMD_STOP;
		}
	    else if(is_CMD(str,"pause","p","P"))
		{
		    playercmd->ctrl_cmd = CMD_PAUSE;              
		}
	    else if(is_CMD(str,"resume","r","R"))
		{
		    playercmd->ctrl_cmd = CMD_RESUME;
		}
	    else if(is_CMD(str,"mute","m","m"))
		{			
            playercmd->set_mode = CMD_MUTE ;
		}
	    else if(is_CMD(str,"unmute","M","M"))
		{		
            playercmd->set_mode = CMD_UNMUTE;
		}
	    else if(is_CMD(str,"volget","v","v"))
		{           
            playercmd->info_cmd = CMD_GET_VOLUME;
		}
	    else if(memcmp(str,"volset:",strlen("volset:"))==0 ||
			(str[0]=='V' && str[1]==':'))
    	{            
    		int r=-1;
    		char *p;
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);  
                playercmd->set_mode = CMD_SET_VOLUME;
                playercmd->param = r;
			}
    		else
			{
			    log_print("error command for set vol(fmt:\"V:value\")\n");
			}           
    	}
        else if(memcmp(str,"search:",strlen("search:"))==0 ||
			(str[0]=='t' && str[1]==':')||
			(str[0]=='T' && str[1]==':'))
		{            
    		int r=-1;
    		char *p;            
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);                
                playercmd->ctrl_cmd = CMD_SEARCH;
                playercmd->param = r;                
			}
    		else
			{
			    log_print("error command for search(fmt:\"T:value\")\n");
			}            
		}
        else if(memcmp(str,"forward:",strlen("forward:"))==0 ||
			(str[0]=='f' && str[1]==':')||
			(str[0]=='F' && str[1]==':'))
		{
    		int r=-1;
    		char *p;            
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);                 
                playercmd->ctrl_cmd = CMD_FF;
                playercmd->param= r;               
			}
    		else
			{
			    log_print("error command for forward(fmt:\"F:value\")\n");
			}
		}
        else if(memcmp(str,"backward:",strlen("backward:"))==0 ||
			(str[0]=='b' && str[1]==':')||
			(str[0]=='B' && str[1]==':'))
		{
    		int r=-1;
    		char *p;            
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);                  
                playercmd->ctrl_cmd = CMD_FB;
                playercmd->param= r;    
                log_print("[%s:%d]fb---step=%d\n",__FUNCTION__, __LINE__, r);
			}
    		else
			{
			    log_print("error command for backward(fmt:\"B:value\")\n");
			}
		}
        else if(memcmp(str,"aid:",strlen("aid:"))==0 ||
			(str[0]=='a' && str[1]==':'))
		{
    		int r=-1;
    		char *p;            
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);                  
                playercmd->ctrl_cmd = CMD_SWITCH_AID;
                playercmd->param= r;               
			}
    		else
			{
			    log_print("error command for audio id(fmt:\"a:value\")\n");
			}
		}
        else if(memcmp(str,"sid:",strlen("sid:"))==0 ||
			(str[0]=='y' && str[1]==':'))
		{
    		int r=-1;
    		char *p;            
    		p=strstr(str,":");
    		if(p!=NULL)
			{
    			p++;
    			sscanf(p,"%d",&r);                  
                playercmd->ctrl_cmd = CMD_SWITCH_SID;
                playercmd->param= r;               
			}
    		else
			{
			    log_print("error command for subtitle id(fmt:\"y:value\")\n");
			}
		}
        else if(is_CMD(str, "volrange", "g", "G"))
        {
            playercmd->info_cmd = CMD_GET_VOL_RANGE;
        }
        else if(is_CMD(str, "spectrum", "u", "U"))
        {
            playercmd->set_mode = CMD_SPECTRUM_SWITCH;
        }
        else if(is_CMD(str, "balance", "e", "E"))
        {
            playercmd->set_mode = CMD_SET_BALANCE;
        }
        else if(is_CMD(str, "swap", "w", "W"))
        {
            playercmd->set_mode = CMD_SWAP_LR;
        }       
        else if(is_CMD(str, "lmono", "l", "l"))
        {
            playercmd->set_mode = CMD_LEFT_MONO;
        }
        else if(is_CMD(str, "rmono", "L", "L"))
        {
            playercmd->set_mode = CMD_RIGHT_MONO;
        }
        else if(is_CMD(str, "setreo", "o", "O"))
        {
            playercmd->set_mode = CMD_SET_STEREO;
        }
        else if(is_CMD(str, "curtime", "c", "C"))
        {
            playercmd->info_cmd = CMD_GET_CURTIME;
        }
        else if(is_CMD(str, "duration", "d", "D"))
        {
            playercmd->info_cmd = CMD_GET_DURATION;
        }
        else if(is_CMD(str, "status", "S", "S"))
        {
            playercmd->info_cmd = CMD_GET_PLAY_STA;
        }
        else if(is_CMD(str, "media", "i", "I"))
        {
            playercmd->info_cmd = CMD_GET_MEDIA_INFO;
        }
        else if(is_CMD(str, "pid", "k", "K"))
        {
            playercmd->info_cmd = CMD_LIST_PID;
        }
        else if(is_CMD(str, "mutesta", "z", "z"))
        {
            ret = codec_get_mutesta(NULL);
            log_print("======[shell_get_command]mute status=%d\n",ret);
        }
    	else if(is_CMD(str,"help","h","H"))
    	{
    	    shell_usage();
    	}
    	else
    	{
        	if(strlen(str) > 1) // not only enter
        	    shell_usage();
    	}
	}  
    else if(ret < 0)
        log_print("[shell_get_command] select error!\n");
    //else    //ret = 0
        //log_print("[shell_get_command] select time out!\n");
    //log_print("[shell_get_command:%d]ccmd=%x param=%d\n",__LINE__,playercmd->ctrl_cmd,playercmd->param);    
	if((playercmd->ctrl_cmd!=0) || 
        (playercmd->info_cmd!=0)|| 
        (playercmd->set_mode != 0))
    {
       
        char pid[MAX_PLAYER_THREADS];
        int num = 0;
        num = player_list_pid(pid, MAX_PLAYER_THREADS);
        if(num == 1)
           playercmd->pid = pid[0];
        //log_print("[shell_get_command:%d]num=%d pid=%d param=%d\n",__LINE__,num,playercmd->pid, playercmd->param);
        return 0;
	}
    else
		return -1;
}