test/aampcli.cpp
/**
 * @brief Process command
 * @param cmd command
 */
@brief Process command
@param cmd command
@brief Process command @param cmd command
static void ProcessCliCommand(char *cmd)
{
	double seconds = 0;
	int rate = 0;
	trim(&cmd);
	if (cmd[0] == 0)
	{
		if (mSingleton->aamp->mpStreamAbstractionAAMP)
		{
			mSingleton->aamp->mpStreamAbstractionAAMP->DumpProfiles();
		}
		logprintf("current bitrate ~= %ld\n", mSingleton->aamp->GetCurrentlyAvailableBandwidth());
	}
	else if (strcmp(cmd, "help") == 0)
	{
		ShowHelp();
	}
	else if (memcmp(cmd, "http", 4) == 0)
	{
		mSingleton->Tune(cmd);
	}
	else if (isNumber(cmd))
	{
		int channelNumber = atoi(cmd);
		logprintf("channel number: %d\n", channelNumber);
		for (std::list<VirtualChannelInfo>::iterator it = mVirtualChannelMap.begin(); it != mVirtualChannelMap.end(); ++it)
		{
			VirtualChannelInfo &channelInfo = *it;
			if(channelInfo.channelNumber == channelNumber)
			{
				mSingleton->Tune(channelInfo.uri.c_str());
				break;
			}
		}
	}
	else if (sscanf(cmd, "seek %lf", &seconds) == 1)
	{
		mSingleton->Seek(seconds);
	}
	else if (strcmp(cmd, "sf") == 0)
	{
		mSingleton->SetRate(0.5);
	}
	else if (sscanf(cmd, "ff%d", &rate) == 1)
	{
		if (rate != 4 && rate != 16 && rate != 32)
		{
			logprintf("Speed not supported.\n");
		}
		else
		{
			mSingleton->SetRate((float)rate);
		}
	}
	else if (strcmp(cmd, "play") == 0)
	{
		mSingleton->SetRate(1);
	}
	else if (strcmp(cmd, "pause") == 0)
	{
		mSingleton->SetRate(0);
	}
	else if (sscanf(cmd, "rw%d", &rate) == 1)
	{
		if ((rate < 4 || rate > 32) || (rate % 4))
		{
			logprintf("Speed not supported.\n");
		}
		else
		{
			mSingleton->SetRate((float)(-rate));
		}
	}
	else if (sscanf(cmd, "bps %d", &rate) == 1)
	{
		logprintf("Set video bitrate %d.\n", rate);
		mSingleton->SetVideoBitrate(rate);
	}
	else if (strcmp(cmd, "flush") == 0)
	{
		mSingleton->aamp->mStreamSink->Flush();
	}
	else if (strcmp(cmd, "stop") == 0)
	{
		mSingleton->Stop();
	}
	else if (strcmp(cmd, "underflow") == 0)
	{
		mSingleton->aamp->ScheduleRetune(eGST_ERROR_UNDERFLOW, eMEDIATYPE_VIDEO);
	}
	else if (strcmp(cmd, "retune") == 0)
	{
		mSingleton->aamp->ScheduleRetune(eDASH_ERROR_STARTTIME_RESET, eMEDIATYPE_VIDEO);
	}
	else if (strcmp(cmd, "status") == 0)
	{
		mSingleton->aamp->mStreamSink->DumpStatus();
	}
	else if (strcmp(cmd, "live") == 0)
	{
		mSingleton->SeekToLive();
	}
	else if (strcmp(cmd, "exit") == 0)
	{
		mSingleton->Stop();
		delete mSingleton;
		mVirtualChannelMap.clear();
		TermPlayerLoop();
		exit(0);
	}
	else if (memcmp(cmd, "rect", 4) == 0)
	{
		int x, y, w, h;
		if (sscanf(cmd, "rect %d %d %d %d", &x, &y, &w, &h) == 4)
		{
			mSingleton->SetVideoRectangle(x, y, w, h);
		}
	}
	else if (memcmp(cmd, "zoom", 4) == 0)
	{
		int zoom;
		if (sscanf(cmd, "zoom %d", &zoom) == 1)
		{
			if (zoom)
			{
				logprintf("Set zoom to full\n");
				mSingleton->SetVideoZoom(VIDEO_ZOOM_FULL);
			}
			else
			{
				logprintf("Set zoom to none\n");
				mSingleton->SetVideoZoom(VIDEO_ZOOM_NONE);
			}
		}
	}
	else if (strcmp(cmd, "sap") == 0)
	{
		gpGlobalConfig->SAP = !gpGlobalConfig->SAP;
		logprintf("SAP %s\n", gpGlobalConfig->SAP ? "on" : "off");
		if (gpGlobalConfig->SAP)
		{
			mSingleton->SetLanguage("es");
		}
		else
		{
			mSingleton->SetLanguage("en");
		}
	}
}
static void ProcessCliCommand ( char * cmd ) { double seconds = 0 ; int rate = 0 ; trim ( & cmd ) ; if ( cmd [ 0 ] == 0 ) { if ( mSingleton -> aamp -> mpStreamAbstractionAAMP ) { mSingleton -> aamp -> mpStreamAbstractionAAMP -> DumpProfiles ( ) ; } logprintf ( " \n " , mSingleton -> aamp -> GetCurrentlyAvailableBandwidth ( ) ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { ShowHelp ( ) ; } else if ( memcmp ( cmd , " " , 4 ) == 0 ) { mSingleton -> Tune ( cmd ) ; } else if ( isNumber ( cmd ) ) { int channelNumber = atoi ( cmd ) ; logprintf ( " \n " , channelNumber ) ; for ( std :: list < VirtualChannelInfo > :: iterator it = mVirtualChannelMap . begin ( ) ; it != mVirtualChannelMap . end ( ) ; ++ it ) { VirtualChannelInfo & channelInfo = * it ; if ( channelInfo . channelNumber == channelNumber ) { mSingleton -> Tune ( channelInfo . uri . c_str ( ) ) ; break ; } } } else if ( sscanf ( cmd , " " , & seconds ) == 1 ) { mSingleton -> Seek ( seconds ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> SetRate ( 0.5 ) ; } else if ( sscanf ( cmd , " " , & rate ) == 1 ) { if ( rate != 4 && rate != 16 && rate != 32 ) { logprintf ( " \n " ) ; } else { mSingleton -> SetRate ( ( float ) rate ) ; } } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> SetRate ( 1 ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> SetRate ( 0 ) ; } else if ( sscanf ( cmd , " " , & rate ) == 1 ) { if ( ( rate < 4 || rate > 32 ) || ( rate % 4 ) ) { logprintf ( " \n " ) ; } else { mSingleton -> SetRate ( ( float ) ( - rate ) ) ; } } else if ( sscanf ( cmd , " " , & rate ) == 1 ) { logprintf ( " \n " , rate ) ; mSingleton -> SetVideoBitrate ( rate ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> aamp -> mStreamSink -> Flush ( ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> Stop ( ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> aamp -> ScheduleRetune ( eGST_ERROR_UNDERFLOW , eMEDIATYPE_VIDEO ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> aamp -> ScheduleRetune ( eDASH_ERROR_STARTTIME_RESET , eMEDIATYPE_VIDEO ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> aamp -> mStreamSink -> DumpStatus ( ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> SeekToLive ( ) ; } else if ( strcmp ( cmd , " " ) == 0 ) { mSingleton -> Stop ( ) ; delete mSingleton ; mVirtualChannelMap . clear ( ) ; TermPlayerLoop ( ) ; exit ( 0 ) ; } else if ( memcmp ( cmd , " " , 4 ) == 0 ) { int x , y , w , h ; if ( sscanf ( cmd , " " , & x , & y , & w , & h ) == 4 ) { mSingleton -> SetVideoRectangle ( x , y , w , h ) ; } } else if ( memcmp ( cmd , " " , 4 ) == 0 ) { int zoom ; if ( sscanf ( cmd , " " , & zoom ) == 1 ) { if ( zoom ) { logprintf ( " \n " ) ; mSingleton -> SetVideoZoom ( VIDEO_ZOOM_FULL ) ; } else { logprintf ( " \n " ) ; mSingleton -> SetVideoZoom ( VIDEO_ZOOM_NONE ) ; } } } else if ( strcmp ( cmd , " " ) == 0 ) { gpGlobalConfig -> SAP = ! gpGlobalConfig -> SAP ; logprintf ( " \n " , gpGlobalConfig -> SAP ? " " : " " ) ; if ( gpGlobalConfig -> SAP ) { mSingleton -> SetLanguage ( " " ) ; } else { mSingleton -> SetLanguage ( " " ) ; } } }
@brief Process command
 @param cmd command
@brief Process command @param cmd command
//	logprintf("Found %d tuning to %s\n",channelInfo.channelNumber, channelInfo.uri.c_str());