linphone-iphone/daemon/commands/call-mute.cc
Sandrine Avakian d4ff86db9d License update.
2016-06-17 14:53:59 +02:00

59 lines
1.9 KiB
C++

/*
call-mute.cc
Copyright (C) 2016 Belledonne Communications, Grenoble, France
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "call-mute.h"
CallMute::CallMute() :
DaemonCommand("call-mute", "call-mute 0|1", "mute/unmute the microphone (1 to mute, 0 to unmute). No argument means MUTE.")
{
addExample(new DaemonCommandExample("call-mute 1",
"Status: Ok\n\n"
"Microphone Muted"));
addExample(new DaemonCommandExample("call-mute",
"Status: Ok\n\n"
"Microphone Muted"));
addExample(new DaemonCommandExample("call-mute 0",
"Status: Ok\n\n"
"Microphone Unmuted"));
addExample(new DaemonCommandExample("call-mute 1",
"Status: Error\n\n"
"Reason: No call in progress. Can't mute."));
}
void CallMute::exec(Daemon* app, const char* args)
{
LinphoneCore *lc = app->getCore();
int muted = TRUE; // no arg means MUTE
LinphoneCall *call = linphone_core_get_current_call(lc);
if( call == NULL ){
app->sendResponse(Response("No call in progress. Can't mute."));
return;
}
if (sscanf(args, "%i", &muted) == 1) {
linphone_core_enable_mic(lc, !muted);
} else {
linphone_core_enable_mic(lc, !muted);
}
app->sendResponse(Response(muted?"Microphone Muted"
:"Microphone Unmuted",
Response::Ok));
}