27 #include "audiomanagerconfig.h"
39 static const std::string COLOR_WELCOME(
"\033[1;33m\033[44m");
40 static const std::string COLOR_HEAD(
"\033[1m\033[42m");
41 static const std::string COLOR_DEFAULT(
"\033[0m");
46 CAmTelnetMenuHelper* CAmTelnetMenuHelper::instance = NULL;
51 :mpTelenetServer(iTelnetServer), mpSocketHandler(iSocketHandler), mpCommandSender(iCommandSender), mpCommandReceiver(iCommandReceiver), mpRoutingSender(iRoutingSender), mpRoutingReceiver(iRoutingReceiver), mpControlSender(iControlSender), mpControlReceiver(iControlReceiver), mpDatabasehandler(iDatabasehandler), mpRouter(iRouter)
64 void CAmTelnetMenuHelper::createCommandMaps()
68 mRootCommands.clear();
69 mRootCommands.insert(std::make_pair(
"help", sCommandPrototypeInfo(
"show all possible commands", &CAmTelnetMenuHelper::helpCommand)));
70 mRootCommands.insert(std::make_pair(
"list", sCommandPrototypeInfo(
"Go into 'list'-submenu", &CAmTelnetMenuHelper::rootListCommand)));
71 mRootCommands.insert(std::make_pair(
"info", sCommandPrototypeInfo(
"Go into 'info'-submenu", &CAmTelnetMenuHelper::rootInfoCommand)));
72 mRootCommands.insert(std::make_pair(
"set", sCommandPrototypeInfo(
"Go into 'set'-submenu", &CAmTelnetMenuHelper::rootSetCommand)));
73 mRootCommands.insert(std::make_pair(
"get", sCommandPrototypeInfo(
"Go into 'get'-submenu", &CAmTelnetMenuHelper::rootGetCommand)));
74 mRootCommands.insert(std::make_pair(
"exit", sCommandPrototypeInfo(
"quit telnet session", &CAmTelnetMenuHelper::exitCommand)));
76 mListCommands.insert(std::make_pair(
"help", sCommandPrototypeInfo(std::string(
"show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
77 mListCommands.insert(std::make_pair(
"conn", sCommandPrototypeInfo(
"list all connections", &CAmTelnetMenuHelper::listConnectionsCommand)));
78 mListCommands.insert(std::make_pair(
"sources", sCommandPrototypeInfo(
"list all available sources", &CAmTelnetMenuHelper::listSourcesCommand)));
79 mListCommands.insert(std::make_pair(
"sinks", sCommandPrototypeInfo(
"list all available sinks", &CAmTelnetMenuHelper::listSinksCommands)));
80 mListCommands.insert(std::make_pair(
"crfader", sCommandPrototypeInfo(
"list all crossfaders", &CAmTelnetMenuHelper::listCrossfaders)));
81 mListCommands.insert(std::make_pair(
"domains", sCommandPrototypeInfo(
"list all domains", &CAmTelnetMenuHelper::listDomainsCommand)));
82 mListCommands.insert(std::make_pair(
"gws", sCommandPrototypeInfo(
"list all gateways", &CAmTelnetMenuHelper::listGatewaysCommand)));
83 mListCommands.insert(std::make_pair(
"mainconn", sCommandPrototypeInfo(
"list all main connections", &CAmTelnetMenuHelper::listMainConnectionsCommand)));
84 mListCommands.insert(std::make_pair(
"mainsinks", sCommandPrototypeInfo(
"list all main sinks", &CAmTelnetMenuHelper::listMainSinksCommand)));
85 mListCommands.insert(std::make_pair(
"mainsources", sCommandPrototypeInfo(
"list all main sources", &CAmTelnetMenuHelper::listMainSourcesCommand)));
86 mListCommands.insert(std::make_pair(
"..", sCommandPrototypeInfo(
"one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
87 mListCommands.insert(std::make_pair(
"exit", sCommandPrototypeInfo(
"close telnet session", &CAmTelnetMenuHelper::exitCommand)));
89 mSetCommands.insert(std::make_pair(
"help", sCommandPrototypeInfo(std::string(
"show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
90 mSetCommands.insert(std::make_pair(
"..", sCommandPrototypeInfo(
"one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
91 mSetCommands.insert(std::make_pair(
"exit", sCommandPrototypeInfo(
"close telnet session", &CAmTelnetMenuHelper::exitCommand)));
92 mSetCommands.insert(std::make_pair(
"conn", sCommandPrototypeInfo(
"use 'conn sourceId sinkId' to connect a source and a sink", &CAmTelnetMenuHelper::setConnection)));
93 mSetCommands.insert(std::make_pair(
"routing", sCommandPrototypeInfo(
"use 'routing sourceId sinkId' to get all\n\t possible routes between a sourceID and a sinkID", &CAmTelnetMenuHelper::setRoutingCommand)));
94 mSetCommands.insert(std::make_pair(
"disc", sCommandPrototypeInfo(
"use 'disc connectionID' to disconnect \n\t this connection", &CAmTelnetMenuHelper::setDisconnectConnId)));
95 mSetCommands.insert(std::make_pair(
"sinkvolume", sCommandPrototypeInfo(
"use 'sinkvolume sinkID volume' to set \n\t absorption in db of sink", &CAmTelnetMenuHelper::setSinkVolume)));
96 mSetCommands.insert(std::make_pair(
"sinkvolstep", sCommandPrototypeInfo(
"use 'sinkvolstep sinkID volumestep' to increment \n\t or decrement volume", &CAmTelnetMenuHelper::setVolumeStep)));
97 mSetCommands.insert(std::make_pair(
"sinkprop", sCommandPrototypeInfo(
"use 'sinkprop type value' to set \n\t a specific sinksoundproperty", &CAmTelnetMenuHelper::setSinkSoundProperty)));
98 mSetCommands.insert(std::make_pair(
"sinkmute", sCommandPrototypeInfo(
"use 'sinkmute sinkid mutestate' to mute \n\t or unmute", &CAmTelnetMenuHelper::setSinkMuteState)));
99 mSetCommands.insert(std::make_pair(
"sourceprop", sCommandPrototypeInfo(
"use 'sourceprop type value' to set \n\t a specific sinksoundproperty", &CAmTelnetMenuHelper::setSourceSoundProperty)));
101 mGetCommands.insert(std::make_pair(
"help", sCommandPrototypeInfo(std::string(
"show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
102 mGetCommands.insert(std::make_pair(
"routing", sCommandPrototypeInfo(
"show current routing", &CAmTelnetMenuHelper::getRoutingCommand)));
103 mGetCommands.insert(std::make_pair(
"sendv", sCommandPrototypeInfo(
"show senderversion", &CAmTelnetMenuHelper::getSenderversionCommand)));
104 mGetCommands.insert(std::make_pair(
"recv", sCommandPrototypeInfo(
"show receiverversion ", &CAmTelnetMenuHelper::getReceiverversionCommand)));
105 mGetCommands.insert(std::make_pair(
"..", sCommandPrototypeInfo(
"one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
106 mGetCommands.insert(std::make_pair(
"exit", sCommandPrototypeInfo(
"close telnet session", &CAmTelnetMenuHelper::exitCommand)));
108 mInfoCommands.insert(std::make_pair(
"help", sCommandPrototypeInfo(std::string(
"show all possible commands"), &CAmTelnetMenuHelper::helpCommand)));
109 mInfoCommands.insert(std::make_pair(
"sysprop", sCommandPrototypeInfo(
"show all systemproperties", &CAmTelnetMenuHelper::infoSystempropertiesCommand)));
110 mInfoCommands.insert(std::make_pair(
"dump", sCommandPrototypeInfo(
"create a database dump of currently used data", &CAmTelnetMenuHelper::infoDumpCommand)));
111 mInfoCommands.insert(std::make_pair(
"..", sCommandPrototypeInfo(
"one step back in menu tree (back to root folder)", &CAmTelnetMenuHelper::oneStepBackCommand)));
112 mInfoCommands.insert(std::make_pair(
"exit", sCommandPrototypeInfo(
"close telnet session", &CAmTelnetMenuHelper::exitCommand)));
120 std::map<int, EMainState>::iterator it;
121 std::stringstream welcome;
122 it = mCurrentMainStateMap.find(filedescriptor);
123 if (it != mCurrentMainStateMap.end())
126 mCurrentMainStateMap.erase(it);
128 it = mCurrentMainStateMap.begin();
130 mCurrentMainStateMap.insert(it, std::make_pair(filedescriptor, state));
132 welcome << COLOR_WELCOME <<
"Welcome to GENIVI AudioManager " << DAEMONVERSION << COLOR_DEFAULT <<
"\n>";
133 assert(send(filedescriptor, welcome.str().c_str(), welcome.str().size(), 0)>=0);
134 logInfo(
"[TN] New connection: ", filedescriptor);
141 std::map<int, EMainState>::iterator it;
142 it = mCurrentMainStateMap.find(filedescriptor);
143 if (it != mCurrentMainStateMap.end())
145 mCurrentMainStateMap.erase(it);
149 logError(
"[TN] socketConnectionsClosed, fd not found, ", filedescriptor);
157 std::map<int, EMainState>::iterator it;
159 tCommandMap::iterator cmditer;
161 it = mCurrentMainStateMap.find(filedescriptor);
162 while (!CmdQueue.empty())
164 cmd = CmdQueue.front();
171 cmditer = mRootCommands.find(cmd);
172 if (mRootCommands.end() != cmditer)
173 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
175 sendError(filedescriptor,
"Command not found\n");
179 cmditer = mListCommands.find(cmd);
180 if (mListCommands.end() != cmditer)
181 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
183 sendError(filedescriptor,
"Command not found\n");
187 cmditer = mInfoCommands.find(cmd);
188 if (mInfoCommands.end() != cmditer)
189 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
191 sendError(filedescriptor,
"Command not found\n");
195 cmditer = mGetCommands.find(cmd);
196 if (mGetCommands.end() != cmditer)
197 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
199 sendError(filedescriptor,
"Command not found\n");
203 cmditer = mSetCommands.find(cmd);
204 if (mSetCommands.end() != cmditer)
205 cmditer->second.CommandPrototype(CmdQueue, filedescriptor);
207 sendError(filedescriptor,
"Command not found\n");
215 sendCurrentCmdPrompt(filedescriptor);
219 void CAmTelnetMenuHelper::sendError(
int& filedescriptor, std::string error_string)
222 assert(send(filedescriptor, error_string.c_str(), error_string.size(), 0)>=0);
226 void CAmTelnetMenuHelper::sendTelnetLine(
int& filedescriptor, std::stringstream& line)
229 assert(send(filedescriptor, line.str().c_str(), line.str().size(), 0)>=0);
233 void CAmTelnetMenuHelper::sendCurrentCmdPrompt(
int& filedescriptor)
236 std::map<int, EMainState>::iterator it;
237 std::stringstream outputstream;
238 outputstream << std::endl;
239 it = mCurrentMainStateMap.find(filedescriptor);
240 if (it != mCurrentMainStateMap.end())
245 outputstream <<
"\\>";
248 outputstream <<
"\\List>";
251 outputstream <<
"\\Get>";
254 outputstream <<
"\\Set>";
257 outputstream <<
"\\Info>";
262 assert(send(filedescriptor, outputstream.str().c_str(), outputstream.str().size(), 0)>=0);
266 logInfo(
"[TN] sendCurrentCmdPrompt, fd not found: ", filedescriptor);
271 void CAmTelnetMenuHelper::exitCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
274 instance->exitCommandExec(CmdQueue, filedescriptor);
278 void CAmTelnetMenuHelper::oneStepBackCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
282 std::map<int, EMainState>::iterator it;
283 it = mCurrentMainStateMap.find(filedescriptor);
284 if (it != mCurrentMainStateMap.end())
311 logInfo(
"[TN] oneStepBackCommandExec, state: ", it->second);
317 void CAmTelnetMenuHelper::oneStepBackCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
320 instance->oneStepBackCommandExec(CmdQueue, filedescriptor);
324 void CAmTelnetMenuHelper::exitCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
328 std::map<int, EMainState>::iterator it;
329 std::stringstream line;
330 std::stringstream output;
332 output <<
"bye!" << COLOR_DEFAULT << std::endl;
333 sendTelnetLine(filedescriptor, output);
334 tCommandMap::iterator iter;
335 it = mCurrentMainStateMap.find(filedescriptor);
336 if (it != mCurrentMainStateMap.end())
338 if (NULL != mpTelenetServer)
340 logInfo(
"[TN] exitCommandExec, removing fd ", filedescriptor);
342 mCurrentMainStateMap.erase(it);
346 logError(
"[TN] exitCommandExec, mpTelenetServer == NULL, fd ", filedescriptor);
352 void CAmTelnetMenuHelper::helpCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
355 instance->helpCommandExec(CmdQueue, filedescriptor);
359 void CAmTelnetMenuHelper::helpCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
363 std::map<int, EMainState>::iterator it;
364 std::stringstream line;
365 tCommandMap::iterator cmdIter;
366 it = mCurrentMainStateMap.find(filedescriptor);
367 if (it != mCurrentMainStateMap.end())
369 line << COLOR_HEAD <<
"###################################################" << COLOR_DEFAULT << std::endl;
370 line << COLOR_HEAD <<
"###### The following commands are supported: ######" << COLOR_DEFAULT << std::endl;
371 line << COLOR_HEAD <<
"###################################################" << COLOR_DEFAULT << std::endl << std::endl;
375 cmdIter = mRootCommands.begin();
376 while (cmdIter != mRootCommands.end())
378 line << cmdIter->first <<
"\t\t- " << cmdIter->second.info << std::endl;
383 cmdIter = mListCommands.begin();
384 while (cmdIter != mListCommands.end())
386 line << cmdIter->first <<
"\t\t- " << cmdIter->second.info << std::endl;
391 cmdIter = mGetCommands.begin();
392 while (cmdIter != mGetCommands.end())
394 line << cmdIter->first <<
"\t\t- " << cmdIter->second.info << std::endl;
399 cmdIter = mSetCommands.begin();
400 while (cmdIter != mSetCommands.end())
402 line << cmdIter->first <<
"\t\t- " << cmdIter->second.info << std::endl;
407 cmdIter = mInfoCommands.begin();
408 while (cmdIter != mInfoCommands.end())
410 line << cmdIter->first <<
"\t\t- " << cmdIter->second.info << std::endl;
418 sendTelnetLine(filedescriptor, line);
424 void CAmTelnetMenuHelper::rootGetCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
427 instance->rootGetCommandExec(CmdQueue, filedescriptor);
431 void CAmTelnetMenuHelper::rootGetCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
435 std::map<int, EMainState>::iterator it;
436 it = mCurrentMainStateMap.find(filedescriptor);
437 if (it != mCurrentMainStateMap.end())
444 void CAmTelnetMenuHelper::rootSetCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
447 instance->rootSetCommandExec(CmdQueue, filedescriptor);
451 void CAmTelnetMenuHelper::rootSetCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
455 std::map<int, EMainState>::iterator it;
456 it = mCurrentMainStateMap.find(filedescriptor);
457 if (it != mCurrentMainStateMap.end())
464 void CAmTelnetMenuHelper::rootListCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
467 instance->rootListCommandExec(CmdQueue, filedescriptor);
471 void CAmTelnetMenuHelper::rootListCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
475 std::map<int, EMainState>::iterator it;
476 it = mCurrentMainStateMap.find(filedescriptor);
477 if (it != mCurrentMainStateMap.end())
484 void CAmTelnetMenuHelper::rootInfoCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
487 instance->rootInfoCommandExec(CmdQueue, filedescriptor);
491 void CAmTelnetMenuHelper::rootInfoCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
495 std::map<int, EMainState>::iterator it;
496 it = mCurrentMainStateMap.find(filedescriptor);
497 if (it != mCurrentMainStateMap.end())
504 void CAmTelnetMenuHelper::listConnectionsCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
507 instance->listConnectionsCommandExec(CmdQueue, filedescriptor);
511 void CAmTelnetMenuHelper::listConnectionsCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
515 std::vector < am_Connection_s > listConnections;
518 std::stringstream output;
519 output <<
"\tConnections: " << listConnections.size() << std::endl;
520 for (std::vector<am_Connection_s>::iterator iter(listConnections.begin()); iter < listConnections.end(); iter++)
522 output <<
"\tID: " << iter->connectionID <<
"\tSrcID: " << iter->sourceID <<
"\tSinkID: " << iter->sinkID <<
"\tFormat: " << iter->connectionFormat <<
"\tdelay: " << iter->delay << std::endl;
524 sendTelnetLine(filedescriptor, output);
528 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListConnections");
533 void CAmTelnetMenuHelper::listSourcesCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
536 instance->listSourcesCommandExec(CmdQueue, filedescriptor);
540 void CAmTelnetMenuHelper::listSourcesCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
544 std::vector < am_Source_s > listSources;
547 std::stringstream output;
548 output <<
"\tSources: " << listSources.size() << std::endl;
549 for (std::vector<am_Source_s>::iterator iter(listSources.begin()); iter < listSources.end(); iter++)
551 output <<
"\tID: " << iter->sourceID <<
"\tName: " << iter->name <<
"\tDomainID: " << iter->domainID <<
"\tState: " << iter->sourceState <<
"\tVolume: " << iter->volume << std::endl;
553 sendTelnetLine(filedescriptor, output);
557 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListSources");
562 void CAmTelnetMenuHelper::listSinksCommands(std::queue<std::string>& CmdQueue,
int& filedescriptor)
565 instance->listSinksCommandsExec(CmdQueue, filedescriptor);
569 void CAmTelnetMenuHelper::listSinksCommandsExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
573 std::vector < am_Sink_s > listSinks;
576 std::stringstream output;
577 output <<
"\tSinks: " << listSinks.size() << std::endl;
578 for (std::vector<am_Sink_s>::iterator iter(listSinks.begin()); iter < listSinks.end(); iter++)
580 output <<
"\tID: " << iter->sinkID <<
"\tDomainID: " << iter->domainID <<
"\tName: " << iter->name <<
"\tAvailable: " << iter->available.availability <<
"\tVolume: " << iter->volume << std::endl;
582 sendTelnetLine(filedescriptor, output);
586 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListSinks");
591 void CAmTelnetMenuHelper::listCrossfaders(std::queue<std::string>& CmdQueue,
int& filedescriptor)
594 instance->listCrossfadersExec(CmdQueue, filedescriptor);
598 void CAmTelnetMenuHelper::listCrossfadersExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
602 std::vector < am_Crossfader_s > listCrossfaders;
605 std::stringstream output;
606 output <<
"\tCrossfader: " << listCrossfaders.size() << std::endl;
607 for (std::vector<am_Crossfader_s>::iterator iter(listCrossfaders.begin()); iter < listCrossfaders.end(); iter++)
609 output <<
"\tID: " << iter->crossfaderID <<
"\tName: " << iter->name <<
"\tSinkA: " << iter->sinkID_A <<
"\tSinkB: " << iter->sinkID_B <<
"\tSourceID: " << iter->sourceID << std::endl;
611 sendTelnetLine(filedescriptor, output);
615 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListCrossfaders");
620 void CAmTelnetMenuHelper::listDomainsCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
623 instance->listDomainsCommandExec(CmdQueue, filedescriptor);
627 void CAmTelnetMenuHelper::listDomainsCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
631 std::vector < am_Domain_s > listDomains;
634 std::stringstream output;
635 output <<
"\tDomains: " << listDomains.size() << std::endl;
636 for (std::vector<am_Domain_s>::iterator iter(listDomains.begin()); iter < listDomains.end(); iter++)
638 output <<
"\tID: " << iter->domainID <<
"\tName: " << iter->name <<
"\tBusname: " << iter->busname <<
"\tNodename: " << iter->nodename <<
"\tState: " <<
static_cast<int>(iter->state) << std::endl;
640 sendTelnetLine(filedescriptor, output);
644 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListDomains");
649 void CAmTelnetMenuHelper::listGatewaysCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
652 instance->listGatewaysCommandExec(CmdQueue, filedescriptor);
656 void CAmTelnetMenuHelper::listGatewaysCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
660 std::vector < am_Gateway_s > listGateways;
663 std::stringstream output;
664 output <<
"\tGateways: " << listGateways.size();
665 for (std::vector<am_Gateway_s>::iterator iter(listGateways.begin()); iter < listGateways.end(); iter++)
667 output <<
"\tID: " << iter->gatewayID <<
"\tName: " << iter->name <<
"\tSourceID: " << iter->sourceID <<
"\tSinkID: " << iter->sinkID << std::endl;
669 sendTelnetLine(filedescriptor, output);
673 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListGateways");
678 void CAmTelnetMenuHelper::getRoutingCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
681 instance->getRoutingCommandExec(CmdQueue, filedescriptor);
685 void CAmTelnetMenuHelper::getRoutingCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
689 (void) (filedescriptor);
694 void CAmTelnetMenuHelper::getSenderversionCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
697 instance->getSenderversionCommandExec(CmdQueue, filedescriptor);
701 void CAmTelnetMenuHelper::getSenderversionCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
705 std::stringstream output;
706 std::string versionCommand;
707 std::string versionRouting;
708 std::string versionControl;
712 output <<
"\tSender versions:" << std::endl <<
"\tCtrl: " << versionControl <<
" | " <<
"Cmd: " << versionCommand <<
" | " <<
"Routing: " << versionRouting << std::endl;
713 sendTelnetLine(filedescriptor, output);
717 void CAmTelnetMenuHelper::getReceiverversionCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
720 instance->getReceiverversionCommandExec(CmdQueue, filedescriptor);
724 void CAmTelnetMenuHelper::getReceiverversionCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
728 std::stringstream output;
729 std::string versionCommand;
730 std::string versionRouting;
731 std::string versionControl;
735 output <<
"\tReceiver versions:" << std::endl <<
"\tCtrl: " << versionControl <<
" | " <<
"Cmd: " << versionCommand <<
" | " <<
"Routing: " << versionRouting << std::endl;
736 sendTelnetLine(filedescriptor, output);
740 void CAmTelnetMenuHelper::infoSystempropertiesCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
743 instance->infoSystempropertiesCommandExec(CmdQueue, filedescriptor);
747 void CAmTelnetMenuHelper::infoDumpCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
750 instance->infoDumpCommandExec(CmdQueue, filedescriptor);
755 void CAmTelnetMenuHelper::setVolumeStep(std::queue<std::string>& CmdQueue,
int& filedescriptor)
758 instance->setSinkVolumeExec(CmdQueue,filedescriptor);
762 void CAmTelnetMenuHelper::setVolumeStepExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
765 if (CmdQueue.size() >= 2)
767 int16_t volumestep = 0;
770 std::istringstream istream_sinkID(CmdQueue.front());
772 std::istringstream istream_volumestep(CmdQueue.front());
774 if (!(istream_volumestep >> volumestep))
777 if (!(istream_sinkID >> sinkID))
782 sendError(filedescriptor,
"Error parsing setVolumeStep 'sinkID' or 'volumestep'");
787 std::stringstream output;
788 output <<
"SetSinkVolumeStep set: " << sinkID <<
"->" << volumestep << std::endl;
789 sendTelnetLine(filedescriptor, output);
793 sendError(filedescriptor,
"Error SetSinkVolumeStep");
798 sendError(filedescriptor,
"Not enough arguments to set SetSinkVolumeStep, please enter 'sinkID' and 'volumestep' after command");
804 void CAmTelnetMenuHelper::setSinkMuteState(std::queue<std::string>& CmdQueue,
int& filedescriptor)
807 instance->setSinkMuteStateExec(CmdQueue,filedescriptor);
811 void CAmTelnetMenuHelper::setSinkMuteStateExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
814 if (CmdQueue.size() >= 2)
820 std::istringstream istream_sinkID(CmdQueue.front());
822 std::istringstream istream_mutestate(CmdQueue.front());
824 if (!(istream_mutestate >> tmp))
827 if (!(istream_sinkID >> sinkID))
836 sendError(filedescriptor,
"You tried to set an invalid am_MuteState_e");
842 sendError(filedescriptor,
"Error parsing setSinkMuteState 'sinkID' or 'mutestate'");
847 std::stringstream output;
848 output <<
"setSinkMuteState set: " << sinkID <<
"->" << MuteState << std::endl;
849 sendTelnetLine(filedescriptor, output);
853 sendError(filedescriptor,
"Error setSinkMuteState");
858 sendError(filedescriptor,
"Not enough arguments to set setSinkMuteState, please enter 'sinkID' and 'mutestate' after command");
864 void CAmTelnetMenuHelper::setSourceSoundProperty(std::queue<std::string>& CmdQueue,
int& filedescriptor)
867 instance->setSourceSoundPropertiesExec(CmdQueue,filedescriptor);
871 void CAmTelnetMenuHelper::setSourceSoundPropertyExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
874 unsigned int tmpType = 0;
876 if (CmdQueue.size() >= 3)
878 std::istringstream istream_sourceID(CmdQueue.front());
880 std::istringstream istream_type(CmdQueue.front());
882 std::istringstream istream_value(CmdQueue.front());
884 if (!(istream_type >> tmpType))
887 am_MainSoundProperty_s soundProperty;
890 if (!(istream_value >> soundProperty.value))
894 if (!(istream_sourceID >> sourceID))
899 sendError(filedescriptor,
"Error parsing setMainSourceSoundProperty 'type', 'value' or 'sourceID'");
904 std::stringstream output;
905 output <<
"setMainSourceSoundProperty set: " << soundProperty.type <<
"->" << soundProperty.value << std::endl;
906 sendTelnetLine(filedescriptor, output);
910 sendError(filedescriptor,
"Error setMainSourceSoundProperty");
915 sendError(filedescriptor,
"Not enough arguments to set setMainSourceSoundProperty, please enter 'sourceID', 'type' and 'value' after command");
921 void CAmTelnetMenuHelper::infoSystempropertiesCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
925 std::vector < am_SystemProperty_s > listSystemProperties;
928 std::stringstream output;
929 output <<
"\tSystemproperties: " << listSystemProperties.size() << std::endl;
930 std::vector<am_SystemProperty_s>::iterator it;
931 for (it = listSystemProperties.begin(); it < listSystemProperties.end(); it++)
933 output <<
"\tType: " << it->type <<
" Value: " << it->value << std::endl;
935 sendTelnetLine(filedescriptor, output);
939 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListSystemProperties");
944 void CAmTelnetMenuHelper::infoDumpCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
949 std::stringstream *pOutput =
new std::stringstream();
951 mpDatabasehandler->
dump(*pOutput);
953 sendTelnetLine(filedescriptor, *pOutput);
959 void CAmTelnetMenuHelper::setRoutingCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
962 instance->setRoutingCommandExec(CmdQueue, filedescriptor);
966 void CAmTelnetMenuHelper::setRoutingCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
969 if (CmdQueue.size() >= 2)
972 std::istringstream istream_sourceID(CmdQueue.front());
974 std::istringstream istream_sinkID(CmdQueue.front());
977 if (!(istream_sourceID >> sourceID))
981 if (!(istream_sinkID >> sinkID))
986 sendError(filedescriptor,
"Error parsing sourcID and sinkID");
989 std::vector < am_Route_s > routingList;
990 if (
E_OK == mpRouter->
getRoute(
true, sourceID, sinkID, routingList))
992 std::stringstream output;
993 std::vector<am_Route_s>::iterator rlIter = routingList.begin();
994 for (
int rlCnt = 1; rlIter < routingList.end(); rlIter++)
996 output <<
"#" << rlCnt <<
" ";
997 std::vector<am_RoutingElement_s>::iterator reIter = rlIter->route.begin();
998 for (; reIter < rlIter->route.end(); reIter++)
1000 output <<
">(" << reIter->sourceID <<
")->--[D:" << reIter->domainID <<
"][F:" << reIter->connectionFormat <<
"]-->-(" << reIter->sinkID <<
")" << std::endl;
1005 sendTelnetLine(filedescriptor, output);
1009 sendError(filedescriptor,
"Error getting route");
1014 if (!CmdQueue.empty())
1017 sendError(filedescriptor,
"Not enough arguments to set routing. Please enter sourceID and sinkID after command");
1022 void CAmTelnetMenuHelper::setConnection(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1025 instance->setConnectionExec(CmdQueue, filedescriptor);
1029 void CAmTelnetMenuHelper::setConnectionExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1034 if (CmdQueue.size() >= 2)
1036 std::istringstream istream_sourceID(CmdQueue.front());
1038 std::istringstream istream_sinkID(CmdQueue.front());
1041 if (!(istream_sourceID >> sourceID))
1045 if (!(istream_sinkID >> sinkID))
1050 sendError(filedescriptor,
"Error parsing sinkID and/or sourceID");
1055 rError = mpCommandReceiver->
connect(sourceID, sinkID, connID);
1058 std::stringstream output;
1059 output <<
"ConnID: " << connID <<
"\tSrc: " << sourceID <<
" ---> Sink: " << sinkID << std::endl;
1060 sendTelnetLine(filedescriptor, output);
1064 sendError(filedescriptor,
"Error connecting sourceID and sinkID");
1070 if (!CmdQueue.empty())
1073 sendError(filedescriptor,
"Not enough arguments to set routing. Please enter sourceID and sinkID after command");
1079 void CAmTelnetMenuHelper::setDisconnectConnId(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1082 instance->setDisconnectConnIdExec(CmdQueue, filedescriptor);
1086 void CAmTelnetMenuHelper::setDisconnectConnIdExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1092 if (CmdQueue.size() >= 1)
1094 std::istringstream istream_connID(CmdQueue.front());
1096 if (!(istream_connID >> connID))
1101 sendError(filedescriptor,
"Error parsing connID");
1105 rError = mpCommandReceiver->
disconnect(connID);
1108 std::stringstream output;
1109 output <<
"ConnID " << connID <<
" closed successfully! " << std::endl;
1110 sendTelnetLine(filedescriptor, output);
1114 sendError(filedescriptor,
"Error disconnecting connectionID");
1119 sendError(filedescriptor,
"Not enough arguments to disconnect a Main Connection, please enter 'connectionID' after command");
1125 void CAmTelnetMenuHelper::setSourceSoundProperties(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1128 instance->setConnectionExec(CmdQueue, filedescriptor);
1132 void CAmTelnetMenuHelper::setSourceSoundPropertiesExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1135 if (CmdQueue.size() >= 3)
1138 std::istringstream istream_sourceID(CmdQueue.front());
1140 std::istringstream istream_type(CmdQueue.front());
1142 std::istringstream istream_value(CmdQueue.front());
1144 unsigned int tmpType = 0;
1145 if (!(istream_type >> tmpType))
1148 am_MainSoundProperty_s soundProperty;
1151 if (!(istream_value >> soundProperty.value))
1155 if (!(istream_sourceID >> sourceID))
1160 sendError(filedescriptor,
"Error parsing MainSinkSoundProperty 'type', 'value' or 'sourceID'");
1165 std::stringstream output;
1166 output <<
"MainSourceSoundProperty set: " << soundProperty.type <<
"->" << soundProperty.value << std::endl;
1167 sendTelnetLine(filedescriptor, output);
1171 sendError(filedescriptor,
"Error setMainSourceSoundProperty");
1176 sendError(filedescriptor,
"Not enough arguments to set MainSourceSoundProperty, please enter 'sourceID', 'type' and 'value' after command");
1182 void CAmTelnetMenuHelper::setSinkSoundProperty(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1185 instance->setSinkSoundPropertyExec(CmdQueue, filedescriptor);
1189 void CAmTelnetMenuHelper::setSinkSoundPropertyExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1192 unsigned int tmpType = 0;
1194 if (CmdQueue.size() >= 3)
1196 std::istringstream istream_sinkID(CmdQueue.front());
1198 std::istringstream istream_type(CmdQueue.front());
1200 std::istringstream istream_value(CmdQueue.front());
1202 if (!(istream_type >> tmpType))
1205 am_MainSoundProperty_s soundProperty;
1208 if (!(istream_value >> soundProperty.value))
1212 if (!(istream_sinkID >> sinkID))
1217 sendError(filedescriptor,
"Error parsing MainSinkSoundProperty 'type', 'value' or 'sinkID'");
1222 std::stringstream output;
1223 output <<
"MainSinkSoundProperty set: " << soundProperty.type <<
"->" << soundProperty.value << std::endl;
1224 sendTelnetLine(filedescriptor, output);
1228 sendError(filedescriptor,
"Error setMainSinkSoundProperty");
1233 sendError(filedescriptor,
"Not enough arguments to set MainSinkSoundProperty, please enter 'sinkID', 'type' and 'value' after command");
1239 void CAmTelnetMenuHelper::setSinkVolume(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1242 instance->setSinkVolumeExec(CmdQueue, filedescriptor);
1246 void CAmTelnetMenuHelper::setSinkVolumeExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1249 if (CmdQueue.size() >= 2)
1254 std::istringstream istream_sinkID(CmdQueue.front());
1256 std::istringstream istream_volume(CmdQueue.front());
1258 if (!(istream_volume >> volume))
1261 if (!(istream_sinkID >> sinkID))
1266 sendError(filedescriptor,
"Error parsing SetSinkVolume 'sinkID' or 'volume'");
1271 std::stringstream output;
1272 output <<
"setVolume set: " << sinkID <<
"->" << volume << std::endl;
1273 sendTelnetLine(filedescriptor, output);
1277 sendError(filedescriptor,
"Error setVolume");
1282 sendError(filedescriptor,
"Not enough arguments to set setVolume, please enter 'sinkID' and 'volume' after command");
1288 void CAmTelnetMenuHelper::listPluginsCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1291 instance->listPluginsCommandExec(CmdQueue, filedescriptor);
1295 void CAmTelnetMenuHelper::listPluginsCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1299 std::vector < std::string > PlugInNames;
1300 std::vector<std::string>::iterator iter;
1301 std::stringstream output;
1304 output <<
"\tCommandSender Plugins loaded: " << PlugInNames.size() << std::endl;
1305 for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1307 output << iter->c_str() << std::endl;
1312 sendError(filedescriptor,
"ERROR: mCommandSender->getListPlugins");
1316 output << std::endl <<
"\tRoutingSender Plugins loaded: " << PlugInNames.size() << std::endl;
1317 for (iter = PlugInNames.begin(); iter < PlugInNames.end(); iter++)
1319 output << iter->c_str() << std::endl;
1324 sendError(filedescriptor,
"ERROR: mRoutingSender->getListPlugins");
1326 sendTelnetLine(filedescriptor, output);
1330 void CAmTelnetMenuHelper::listMainSourcesCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1333 instance->listMainSourcesCommandExec(CmdQueue, filedescriptor);
1337 void CAmTelnetMenuHelper::listMainSourcesCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1341 std::vector < am_SourceType_s > listMainSources;
1344 std::stringstream output;
1345 output << std::endl <<
"\tMainSources: " << listMainSources.size() << std::endl;
1346 std::vector<am_SourceType_s>::iterator iter;
1347 for (iter = listMainSources.begin(); iter < listMainSources.end(); iter++)
1349 output <<
"\tID: " << iter->sourceID <<
"\tName: " << iter->name <<
"\tsourceClassID: " << iter->sourceClassID <<
"\tavailability: " << iter->availability.availability << std::endl;
1351 sendTelnetLine(filedescriptor, output);
1355 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListMainSources");
1360 void CAmTelnetMenuHelper::listMainSinksCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1363 instance->listMainSinksCommandExec(CmdQueue, filedescriptor);
1367 void CAmTelnetMenuHelper::listMainSinksCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1371 std::vector < am_SinkType_s > listMainSinks;
1374 std::stringstream output;
1375 output << std::endl <<
"\tMainSinks: " << listMainSinks.size() << std::endl;
1376 std::vector<am_SinkType_s>::iterator iter;
1377 for (iter = listMainSinks.begin(); iter < listMainSinks.end(); iter++)
1379 output <<
"\tID: " << iter->sinkID <<
"\tsinkClassID: " << iter->sinkClassID <<
"\tName: " << iter->name <<
"\tAvailable: " << iter->availability.availability <<
"\tVolume: " << iter->volume << std::endl;
1381 sendTelnetLine(filedescriptor, output);
1385 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListMainSinks");
1390 void CAmTelnetMenuHelper::listMainConnectionsCommand(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1393 instance->listMainConnectionsCommandExec(CmdQueue, filedescriptor);
1397 void CAmTelnetMenuHelper::listMainConnectionsCommandExec(std::queue<std::string>& CmdQueue,
int& filedescriptor)
1401 std::vector<am_MainConnection_s> listMainConnections;
1405 std::stringstream output;
1406 output << std::endl <<
"\tMainConnections: " << listMainConnections.size() << std::endl;
1408 std::vector<am_MainConnection_s>::iterator iter;
1409 for (iter = listMainConnections.begin(); iter < listMainConnections.end(); iter++)
1411 output <<
"\tID: " << iter->mainConnectionID
1412 <<
"\tState: " << iter->connectionState
1413 <<
"\tDelay: " << iter->delay
1414 <<
"\tsourceID: " << iter->sourceID
1415 <<
"\tsinkID: " << iter->sinkID << std::endl;
1417 output <<
"ConnectionIDs: ";
1418 std::vector<am_connectionID_t>::iterator list_connIDs_iter = iter->listConnectionID.begin();
1419 for(;list_connIDs_iter < iter->listConnectionID.end();list_connIDs_iter++)
1421 output << *list_connIDs_iter <<
" ";
1424 output << std::endl;
1426 sendTelnetLine(filedescriptor,output);
1430 sendError(filedescriptor,
"ERROR: mDatabasehandler->getListMainSinks");
virtual am_Error_e getListConnections(std::vector< am_Connection_s > &listConnections) const =0
am_Error_e getListPlugins(std::vector< std::string > &interfaces) const
Implements the RoutingSendInterface.
virtual am_Error_e getListDomains(std::vector< am_Domain_s > &listDomains) const =0
am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID)
connects a source to sink
This class realizes the command Interface.
void getInterfaceVersion(std::string &version) const
am_Error_e
the errors of the audiomanager.
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
void getInterfaceVersion(std::string &version) const
This function returns the version of the interface.
void getInterfaceVersion(std::string &version) const
Implements an autorouting algorithm for connecting sinks and sources via different audio domains...
void getInterfaceVersion(std::string &version) const
This function returns the version of the interface.
This class is used to receive all commands from the control interface.
The am::CAmSocketHandler implements a mainloop for the AudioManager.
SPDX license identifier: MPL-2.0.
uint16_t am_CustomMainSoundPropertyType_t
Here are all SoundProperties that can be set via the CommandInterface.
virtual am_Error_e getListMainSinks(std::vector< am_SinkType_s > &listMainSinks) const =0
SPDX license identifier: MPL-2.0.
Implements the Receiving side of the RoutingPlugins.
am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID)
This method is used to set sound properties, e.g.
SPDX license identifier: MPL-2.0.
virtual am_Error_e getListSinks(std::vector< am_Sink_s > &listSinks) const =0
SPDX license identifier: MPL-2.0.
SPDX license identifier: MPL-2.0.
SPDX license identifier: MPL-2.0.
am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume)
sets the volume for a sink
am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep)
This function is used to increment or decrement the current volume for a sink.
virtual am_Error_e getListMainSources(std::vector< am_SourceType_s > &listMainSources) const =0
SPDX license identifier: MPL-2.0.
void getInterfaceVersion(std::string &version) const
This function returns the version of the interface.
void disconnectClient(int filedescriptor)
void getInterfaceVersion(std::string &version) const
uint16_t am_sourceID_t
a source ID
virtual am_Error_e getListSources(std::vector< am_Source_s > &lisSources) const =0
sends data to the commandInterface, takes the file of the library that needs to be loaded ...
virtual am_Error_e getListCrossfaders(std::vector< am_Crossfader_s > &listCrossfaders) const =0
This class handles and abstracts the database.
SPDX license identifier: MPL-2.0.
Implements a telnetserver that can be used to connect to the audiomanager, retrieve some information ...
int16_t am_volume_t
The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE).
am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
sets the mute state of a sink
am_Error_e getListPlugins(std::vector< std::string > &interfaces) const
virtual void dump(std::ostream &output) const =0
virtual am_Error_e getListSystemProperties(std::vector< am_SystemProperty_s > &listSystemProperties) const =0
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
virtual am_Error_e getListGateways(std::vector< am_Gateway_s > &listGateways) const =0
SPDX license identifier: MPL-2.0.
no error - positive reply
SPDX license identifier: MPL-2.0.
virtual am_Error_e getListMainConnections(std::vector< am_MainConnection_s > &listMainConnections) const =0
This class is used to send data to the CommandInterface.
uint16_t am_sinkID_t
a sink ID
uint16_t am_mainConnectionID_t
a mainConnection ID
am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID)
This method is used to set sound properties, e.g.
am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID)
disconnects a mainConnection
am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector< am_Route_s > &returnList)
Finds all possible paths between given source and sink.