Add the dtmf command to generate DTMFs.

This commit is contained in:
Ghislain MARY 2012-09-04 09:40:26 +02:00
parent 4ea873f149
commit b7b9d2d14c
4 changed files with 42 additions and 0 deletions

View file

@ -14,6 +14,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/call.cc \
commands/call-stats.cc \
commands/call-status.cc \
commands/dtmf.cc \
commands/firewall-policy.cc \
commands/help.cc \
commands/ipv6.cc \
@ -39,6 +40,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/call.h \
commands/call-stats.h \
commands/call-status.h \
commands/dtmf.h \
commands/firewall-policy.h \
commands/help.h \
commands/ipv6.h \

26
daemon/commands/dtmf.cc Normal file
View file

@ -0,0 +1,26 @@
#include "dtmf.h"
using namespace std;
DtmfCommand::DtmfCommand() :
DaemonCommand("dtmf", "dtmf <digit>", "Generate a DTMF (one of: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, *, #.") {
}
void DtmfCommand::exec(Daemon *app, const char *args) {
string digit_str;
char digit;
istringstream ist(args);
ist >> digit_str;
if (ist.fail()) {
app->sendResponse(Response("Missing digit parameter.", Response::Error));
} else {
digit = digit_str.at(0);
if (isdigit(digit) || (digit == 'A') || (digit == 'B') || (digit == 'C') || (digit == 'D') || (digit == '*') || (digit == '#')) {
linphone_core_play_dtmf(app->getCore(), digit, 100);
linphone_core_send_dtmf(app->getCore(), digit);
app->sendResponse(Response());
} else {
app->sendResponse(Response("Incorrect digit parameter.", Response::Error));
}
}
}

12
daemon/commands/dtmf.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef COMMAND_DTMF_H_
#define COMMAND_DTMF_H_
#include "../daemon.h"
class DtmfCommand: public DaemonCommand {
public:
DtmfCommand();
virtual void exec(Daemon *app, const char *args);
};
#endif //COMMAND_DTMF_H_

View file

@ -21,6 +21,7 @@
#include "commands/call.h"
#include "commands/call-stats.h"
#include "commands/call-status.h"
#include "commands/dtmf.h"
#include "commands/firewall-policy.h"
#include "commands/help.h"
#include "commands/ipv6.h"
@ -314,6 +315,7 @@ void Daemon::initCommands() {
mCommands.push_back(new UnregisterCommand());
mCommands.push_back(new CallCommand());
mCommands.push_back(new TerminateCommand());
mCommands.push_back(new DtmfCommand());
mCommands.push_back(new PopEventCommand());
mCommands.push_back(new AnswerCommand());
mCommands.push_back(new CallStatusCommand());