From b8071fd687a3b1d90b1405a0c44abcf2db560d83 Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Thu, 3 May 2012 10:45:30 +0200 Subject: [PATCH] Add audio-codec-set --- daemon/Makefile.am | 1 + daemon/commands/audio-codec-set.cc | 42 ++++++++++++++++++++++++++++++ daemon/commands/audio-codec-set.h | 12 +++++++++ daemon/daemon.cc | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 daemon/commands/audio-codec-set.cc create mode 100644 daemon/commands/audio-codec-set.h diff --git a/daemon/Makefile.am b/daemon/Makefile.am index a89769731..6fa22f30b 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -8,6 +8,7 @@ linphone_daemon_SOURCES=daemon.cc \ commands/audio-codec-enable.cc \ commands/audio-codec-get.cc \ commands/audio-codec-move.cc \ + commands/audio-codec-set.cc \ commands/audio-stream-start.cc \ commands/audio-stream-stop.cc \ commands/call.cc \ diff --git a/daemon/commands/audio-codec-set.cc b/daemon/commands/audio-codec-set.cc new file mode 100644 index 000000000..c11ce64cd --- /dev/null +++ b/daemon/commands/audio-codec-set.cc @@ -0,0 +1,42 @@ +#include "audio-codec-set.h" + +#include + +using namespace std; + +AudioCodecSetCommand::AudioCodecSetCommand() : + DaemonCommand("audio-codec-set", "audio-codec-set ", "Set a property of a codec") { +} +void AudioCodecSetCommand::exec(Daemon *app, const char *args) { + int payload_type; + char param[256], value[256]; + if (sscanf(args, "%d %255s %255s", &payload_type, param, value) == 3) { + int index = 0; + for (const MSList *node = linphone_core_get_audio_codecs(app->getCore()); node != NULL; node = ms_list_next(node)) { + PayloadType *payload = reinterpret_cast(node->data); + if (payload_type == linphone_core_get_payload_type_number(app->getCore(), payload)) { + bool handled = false; + if (strcmp("clock_rate", param) == 0) { + payload->clock_rate = atoi(value); + handled = true; + } else if (strcmp("recv_fmtp", param) == 0) { + payload_type_set_recv_fmtp(payload, value); + handled = true; + } else if (strcmp("send_fmtp", param) == 0) { + payload_type_set_send_fmtp(payload, value); + handled = true; + } + if (handled) { + app->sendResponse(PayloadTypeResponse(app->getCore(), payload, index)); + } else { + app->sendResponse(Response("Invalid codec parameter")); + } + return; + } + ++index; + } + app->sendResponse(Response("Audio codec not found.")); + } else { + app->sendResponse(Response("Missing/Incorrect parameter(s).")); + } +} diff --git a/daemon/commands/audio-codec-set.h b/daemon/commands/audio-codec-set.h new file mode 100644 index 000000000..1f5a07369 --- /dev/null +++ b/daemon/commands/audio-codec-set.h @@ -0,0 +1,12 @@ +#ifndef COMMAND_AUDIO_CODEC_SET_H_ +#define COMMAND_AUDIO_CODEC_SET_H_ + +#include "../daemon.h" + +class AudioCodecSetCommand: public DaemonCommand { +public: + AudioCodecSetCommand(); + virtual void exec(Daemon *app, const char *args); +}; + +#endif //COMMAND_AUDIO_CODEC_SET_H_ diff --git a/daemon/daemon.cc b/daemon/daemon.cc index f4462ba47..1e1e6342e 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -13,6 +13,7 @@ #include "commands/audio-codec-move.h" #include "commands/audio-codec-enable.h" #include "commands/audio-codec-disable.h" +#include "commands/audio-codec-set.h" #include "commands/audio-stream-start.h" #include "commands/audio-stream-stop.h" #include "commands/call.h" @@ -171,6 +172,7 @@ void Daemon::initCommands() { mCommands.push_back(new AudioCodecEnableCommand()); mCommands.push_back(new AudioCodecDisableCommand()); mCommands.push_back(new AudioCodecMoveCommand()); + mCommands.push_back(new AudioCodecSetCommand()); mCommands.push_back(new AudioStreamStartCommand()); mCommands.push_back(new AudioStreamStopCommand()); mCommands.push_back(new PtimeCommand());