From ad48fe00986f97c4a945f94308ca2963db65b91a Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 26 Jun 2012 15:46:15 +0200 Subject: [PATCH] Improve msfilter-add-fmtp command --- daemon/commands/msfilter-add-fmtp.cc | 32 ++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/daemon/commands/msfilter-add-fmtp.cc b/daemon/commands/msfilter-add-fmtp.cc index 41e0c104f..909b2f54c 100644 --- a/daemon/commands/msfilter-add-fmtp.cc +++ b/daemon/commands/msfilter-add-fmtp.cc @@ -5,15 +5,33 @@ using namespace std; MSFilterAddFmtpCommand::MSFilterAddFmtpCommand() : - DaemonCommand("msfilter-add-fmtp", "msfilter-add-fmtp ", "Add fmtp to current encoder") { + DaemonCommand("msfilter-add-fmtp", "msfilter-add-fmtp ", "Add fmtp to the encoder of a call or a stream") { } void MSFilterAddFmtpCommand::exec(Daemon *app, const char *args) { - LinphoneCore *lc = app->getCore(); - LinphoneCall *call = linphone_core_get_current_call(lc); - if (call == NULL) { - app->sendResponse(Response("No current call available.")); - return; + char type[256], fmtp[256]; + int id; + + if (sscanf(args, "%255s %d %255s", type, &id, fmtp) == 3) { + if(strcmp(type, "call") == 0) { + LinphoneCall *call = app->findCall(id); + if (call == NULL) { + app->sendResponse(Response("No Call with such id.")); + return; + } + ms_filter_call_method(call->audiostream->encoder, MS_FILTER_ADD_FMTP, (void*) args); + } else if(strcmp(type, "stream") == 0) { + AudioStream *stream = app->findAudioStream(id); + if (stream == NULL) { + app->sendResponse(Response("No Audio Stream with such id.")); + return; + } + ms_filter_call_method(stream->encoder, MS_FILTER_ADD_FMTP, (void*) args); + } else { + app->sendResponse(Response("Incorrect parameter(s).")); + } + app->sendResponse(Response()); + } else { + app->sendResponse(Response("Missing/Incorrect parameter(s).")); } - ms_filter_call_method(call->audiostream->encoder, MS_FILTER_ADD_FMTP, (void*) args); }