mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-07 14:18:25 +00:00
Add audio-codec-set
This commit is contained in:
parent
74fddfca2e
commit
b8071fd687
4 changed files with 57 additions and 0 deletions
|
|
@ -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 \
|
||||
|
|
|
|||
42
daemon/commands/audio-codec-set.cc
Normal file
42
daemon/commands/audio-codec-set.cc
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "audio-codec-set.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
AudioCodecSetCommand::AudioCodecSetCommand() :
|
||||
DaemonCommand("audio-codec-set", "audio-codec-set <payload type number> <param> <value>", "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<PayloadType*>(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)."));
|
||||
}
|
||||
}
|
||||
12
daemon/commands/audio-codec-set.h
Normal file
12
daemon/commands/audio-codec-set.h
Normal file
|
|
@ -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_
|
||||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue