mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-24 06:38:08 +00:00
add cn command
This commit is contained in:
parent
880a20d53b
commit
85827cf851
4 changed files with 69 additions and 0 deletions
|
|
@ -79,6 +79,7 @@ linphone_daemon_SOURCES=daemon.cc \
|
|||
commands/quit.h \
|
||||
commands/contact.h \
|
||||
commands/netsim.cc commands/netsim.h\
|
||||
commands/cn.cc commands/cn.h \
|
||||
commands/version.h
|
||||
|
||||
linphone_daemon_pipetest_SOURCES=daemon-pipetest.c
|
||||
|
|
|
|||
54
daemon/commands/cn.cc
Normal file
54
daemon/commands/cn.cc
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#include "cn.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CNResponse : public Response {
|
||||
public:
|
||||
CNResponse(LinphoneCore *core);
|
||||
};
|
||||
|
||||
CNResponse::CNResponse(LinphoneCore *core) : Response() {
|
||||
ostringstream ost;
|
||||
bool cn_enabled = linphone_core_generic_confort_noise_enabled(core) == TRUE ? true : false;
|
||||
ost << "State: ";
|
||||
if (cn_enabled) {
|
||||
ost << "enabled\n";
|
||||
} else {
|
||||
ost << "disabled\n";
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
}
|
||||
|
||||
|
||||
CNCommand::CNCommand() :
|
||||
DaemonCommand("cn", "cn [enable|disable]",
|
||||
"Enable or disable generic confort noice (CN payload type) with the 'enable' and 'disable' parameters, return the status of the use of confort noise without parameter.") {
|
||||
addExample(new DaemonCommandExample("cn enable",
|
||||
"Status: Ok\n\n"
|
||||
"State: enabled"));
|
||||
addExample(new DaemonCommandExample("cn disable",
|
||||
"Status: Ok\n\n"
|
||||
"State: disabled"));
|
||||
addExample(new DaemonCommandExample("cn",
|
||||
"Status: Ok\n\n"
|
||||
"State: disabled"));
|
||||
}
|
||||
|
||||
void CNCommand::exec(Daemon *app, const char *args) {
|
||||
string status;
|
||||
istringstream ist(args);
|
||||
ist >> status;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(CNResponse(app->getCore()));
|
||||
} else {
|
||||
if (status.compare("enable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), TRUE);
|
||||
} else if (status.compare("disable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), FALSE);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(CNResponse(app->getCore()));
|
||||
}
|
||||
}
|
||||
12
daemon/commands/cn.h
Normal file
12
daemon/commands/cn.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef COMMAND_CN_H_
|
||||
#define COMMAND_CN_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
|
||||
class CNCommand: public DaemonCommand {
|
||||
public:
|
||||
CNCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_IPV6_H_
|
||||
|
|
@ -51,6 +51,7 @@
|
|||
#include "commands/quit.h"
|
||||
#include "commands/configcommand.h"
|
||||
#include "commands/netsim.h"
|
||||
#include "commands/cn.h"
|
||||
#include "commands/version.h"
|
||||
|
||||
#include "private.h"
|
||||
|
|
@ -471,6 +472,7 @@ void Daemon::initCommands() {
|
|||
mCommands.push_back(new ConfigGetCommand());
|
||||
mCommands.push_back(new ConfigSetCommand());
|
||||
mCommands.push_back(new NetsimCommand());
|
||||
mCommands.push_back(new CNCommand());
|
||||
}
|
||||
|
||||
void Daemon::uninitCommands() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue