forked from mirrors/linphone-iphone
Huge cleaning in linphone-daemon.
This commit is contained in:
parent
2f508dc35a
commit
b485789d08
82 changed files with 1074 additions and 965 deletions
|
|
@ -32,7 +32,7 @@ public:
|
|||
AdaptiveBufferCompensationResponse(LinphoneCore *core, StreamType type);
|
||||
|
||||
private:
|
||||
void outputAdaptiveBufferCompensation(LinphoneCore *core, ostringstream &ost, const char *header, bool_t value);
|
||||
void outputAdaptiveBufferCompensation(LinphoneCore *core, ostringstream &ost, const string& header, bool_t value);
|
||||
};
|
||||
|
||||
AdaptiveBufferCompensationResponse::AdaptiveBufferCompensationResponse(LinphoneCore *core, StreamType type) : Response() {
|
||||
|
|
@ -54,10 +54,10 @@ AdaptiveBufferCompensationResponse::AdaptiveBufferCompensationResponse(LinphoneC
|
|||
outputAdaptiveBufferCompensation(core, ost, "Video", enabled);
|
||||
break;
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
void AdaptiveBufferCompensationResponse::outputAdaptiveBufferCompensation(LinphoneCore *core, ostringstream &ost, const char *header, bool_t value) {
|
||||
void AdaptiveBufferCompensationResponse::outputAdaptiveBufferCompensation(LinphoneCore *core, ostringstream &ost, const string& header, bool_t value) {
|
||||
ost << header << ": ";
|
||||
if (value) {
|
||||
ost << "enabled\n";
|
||||
|
|
@ -86,48 +86,51 @@ AdaptiveBufferCompensationCommand::AdaptiveBufferCompensationCommand() :
|
|||
"Video: enabled"));
|
||||
}
|
||||
|
||||
void AdaptiveBufferCompensationCommand::exec(Daemon *app, const char *args) {
|
||||
void AdaptiveBufferCompensationCommand::exec(Daemon *app, const string& args) {
|
||||
string stream;
|
||||
string state;
|
||||
istringstream ist(args);
|
||||
|
||||
ist >> stream;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::AllStreams));
|
||||
} else {
|
||||
ist >> state;
|
||||
if (ist.fail()) {
|
||||
if (stream.compare("audio") == 0) {
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::AudioStream));
|
||||
} else if (stream.compare("video") == 0) {
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::VideoStream));
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect stream parameter.", Response::Error));
|
||||
}
|
||||
} else {
|
||||
AdaptiveBufferCompensationResponse::StreamType type;
|
||||
bool enabled;
|
||||
if (stream.compare("audio") == 0) {
|
||||
type = AdaptiveBufferCompensationResponse::AudioStream;
|
||||
} else if (stream.compare("video") == 0) {
|
||||
type = AdaptiveBufferCompensationResponse::VideoStream;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect stream parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (state.compare("enable") == 0) {
|
||||
enabled = TRUE;
|
||||
} else if (state.compare("disable") == 0) {
|
||||
enabled = FALSE;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (type == AdaptiveBufferCompensationResponse::AudioStream) {
|
||||
linphone_core_enable_audio_adaptive_jittcomp(app->getCore(), enabled);
|
||||
} else if (type == AdaptiveBufferCompensationResponse::VideoStream) {
|
||||
linphone_core_enable_video_adaptive_jittcomp(app->getCore(), enabled);
|
||||
}
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::AllStreams));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ist >> state;
|
||||
if (ist.fail()) {
|
||||
if (stream.compare("audio") == 0) {
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::AudioStream));
|
||||
} else if (stream.compare("video") == 0) {
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::VideoStream));
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect stream parameter.", Response::Error));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AdaptiveBufferCompensationResponse::StreamType type;
|
||||
bool enabled;
|
||||
if (stream.compare("audio") == 0) {
|
||||
type = AdaptiveBufferCompensationResponse::AudioStream;
|
||||
} else if (stream.compare("video") == 0) {
|
||||
type = AdaptiveBufferCompensationResponse::VideoStream;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect stream parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (state.compare("enable") == 0) {
|
||||
enabled = TRUE;
|
||||
} else if (state.compare("disable") == 0) {
|
||||
enabled = FALSE;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (type == AdaptiveBufferCompensationResponse::AudioStream) {
|
||||
linphone_core_enable_audio_adaptive_jittcomp(app->getCore(), enabled);
|
||||
} else if (type == AdaptiveBufferCompensationResponse::VideoStream) {
|
||||
linphone_core_enable_video_adaptive_jittcomp(app->getCore(), enabled);
|
||||
}
|
||||
app->sendResponse(AdaptiveBufferCompensationResponse(app->getCore(), AdaptiveBufferCompensationResponse::AllStreams));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
#define COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AdaptiveBufferCompensationCommand: public DaemonCommand {
|
||||
public:
|
||||
AdaptiveBufferCompensationCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_ADAPTIVE_BUFFER_COMPENSATION_H_
|
||||
|
|
|
|||
|
|
@ -38,37 +38,40 @@ AnswerCommand::AnswerCommand() :
|
|||
"Reason: No call to accept."));
|
||||
}
|
||||
|
||||
void AnswerCommand::exec(Daemon *app, const char *args) {
|
||||
void AnswerCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
for (const MSList* elem = linphone_core_get_calls(lc); elem != NULL; elem = elem->next) {
|
||||
call = (LinphoneCall*)elem->data;
|
||||
LinphoneCallState cstate = linphone_call_get_state(call);
|
||||
if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallIncomingEarlyMedia) {
|
||||
if (linphone_core_accept_call(lc, call) == 0) {
|
||||
app->sendResponse(Response());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
} else {
|
||||
LinphoneCallState cstate = linphone_call_get_state(call);
|
||||
if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallIncomingEarlyMedia) {
|
||||
if (linphone_core_accept_call(lc, call) == 0) {
|
||||
app->sendResponse(Response());
|
||||
return;
|
||||
}
|
||||
}
|
||||
app->sendResponse(Response("Can't accept this call."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
for (const MSList* elem = linphone_core_get_calls(lc); elem != NULL; elem = elem->next) {
|
||||
call = (LinphoneCall*) elem->data;
|
||||
LinphoneCallState cstate = linphone_call_get_state(call);
|
||||
if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallIncomingEarlyMedia) {
|
||||
if (linphone_core_accept_call(lc, call) == 0) {
|
||||
app->sendResponse(Response());
|
||||
return;
|
||||
}
|
||||
|
||||
LinphoneCallState cstate = linphone_call_get_state(call);
|
||||
if (cstate == LinphoneCallIncomingReceived || cstate == LinphoneCallIncomingEarlyMedia) {
|
||||
if (linphone_core_accept_call(lc, call) == 0) {
|
||||
app->sendResponse(Response());
|
||||
return;
|
||||
}
|
||||
}
|
||||
app->sendResponse(Response("Can't accept this call."));
|
||||
return;
|
||||
}
|
||||
|
||||
app->sendResponse(Response("No call to accept."));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_ANSWER_H_
|
||||
#define COMMAND_ANSWER_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_ANSWER_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_ANSWER_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AnswerCommand: public DaemonCommand {
|
||||
public:
|
||||
AnswerCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_ANSWER_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_ANSWER_H_
|
||||
|
|
|
|||
|
|
@ -52,12 +52,12 @@ AudioCodecGetCommand::AudioCodecGetCommand() :
|
|||
"Reason: Audio codec not found."));
|
||||
}
|
||||
|
||||
void AudioCodecGetCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioCodecGetCommand::exec(Daemon *app, const string& args) {
|
||||
bool list = false;
|
||||
bool found = false;
|
||||
istringstream ist(args);
|
||||
ostringstream ost;
|
||||
PayloadType *pt=NULL;
|
||||
PayloadType *pt = NULL;
|
||||
|
||||
if (ist.peek() == EOF) {
|
||||
found = list = true;
|
||||
|
|
@ -88,6 +88,6 @@ void AudioCodecGetCommand::exec(Daemon *app, const char *args) {
|
|||
if (!found) {
|
||||
app->sendResponse(Response("Audio codec not found.", Response::Error));
|
||||
} else {
|
||||
app->sendResponse(Response(ost.str().c_str(), Response::Ok));
|
||||
app->sendResponse(Response(ost.str(), Response::Ok));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_CODEC_GET_H_
|
||||
#define COMMAND_AUDIO_CODEC_GET_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_GET_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_GET_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioCodecGetCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioCodecGetCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_CODEC_GET_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_GET_H_
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ AudioCodecMoveCommand::AudioCodecMoveCommand() :
|
|||
"Enabled: false"));
|
||||
}
|
||||
|
||||
void AudioCodecMoveCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioCodecMoveCommand::exec(Daemon *app, const string& args) {
|
||||
istringstream ist(args);
|
||||
|
||||
if (ist.peek() == EOF) {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
#define COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioCodecMoveCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioCodecMoveCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_MOVE_H_
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ static PayloadType *findPayload(LinphoneCore *lc, int payload_type, int *index){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void AudioCodecSetCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioCodecSetCommand::exec(Daemon *app, const string& args) {
|
||||
istringstream ist(args);
|
||||
|
||||
if (ist.peek() == EOF) {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_CODEC_SET_H_
|
||||
#define COMMAND_AUDIO_CODEC_SET_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_SET_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_SET_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioCodecSetCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioCodecSetCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_CODEC_SET_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_SET_H_
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ AudioCodecToggleCommand::AudioCodecToggleCommand(const char *name, const char *p
|
|||
DaemonCommand(name, proto, help), mEnable(enable) {
|
||||
}
|
||||
|
||||
void AudioCodecToggleCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioCodecToggleCommand::exec(Daemon *app, const string& args) {
|
||||
istringstream ist(args);
|
||||
|
||||
if (ist.peek() == EOF) {
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
#define COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioCodecToggleCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioCodecToggleCommand(const char *name, const char *proto, const char *help, bool enable);
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
protected:
|
||||
bool mEnable;
|
||||
};
|
||||
|
|
@ -40,4 +40,4 @@ public:
|
|||
AudioCodecDisableCommand();
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_CODEC_TOGGLE_H_
|
||||
|
|
|
|||
|
|
@ -31,65 +31,66 @@ AudioStreamStartCommand::AudioStreamStartCommand() :
|
|||
|
||||
static PayloadType *getPayloadType(LinphoneCore *lc, const MSList *codecs, int number){
|
||||
const MSList *elem;
|
||||
for (elem=codecs;elem!=NULL;elem=elem->next){
|
||||
PayloadType *pt=(PayloadType*)elem->data;
|
||||
if (linphone_core_get_payload_type_number(lc, pt)==number)
|
||||
for (elem = codecs; elem != NULL; elem = elem->next) {
|
||||
PayloadType *pt = (PayloadType*)elem->data;
|
||||
if (linphone_core_get_payload_type_number(lc, pt) == number)
|
||||
return pt;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AudioStreamStartCommand::exec(Daemon *app, const char *args) {
|
||||
char addr[256];
|
||||
void AudioStreamStartCommand::exec(Daemon *app, const string& args) {
|
||||
string addr;
|
||||
int port;
|
||||
int payload_type;
|
||||
MSFactory* factory ;
|
||||
|
||||
factory = (app->getCore())->factory;
|
||||
MSFactory* factory = app->getCore()->factory;
|
||||
|
||||
if (sscanf(args, "%255s %d %d", addr, &port, &payload_type) == 3) {
|
||||
int local_port = linphone_core_get_audio_port(app->getCore());
|
||||
int jitt = linphone_core_get_audio_jittcomp(app->getCore());
|
||||
bool_t echo_canceller = linphone_core_echo_cancellation_enabled(app->getCore());
|
||||
int ptime=linphone_core_get_upload_ptime(app->getCore());
|
||||
MSSndCardManager *manager = ms_factory_get_snd_card_manager(factory);
|
||||
MSSndCard *capture_card = ms_snd_card_manager_get_card(manager, linphone_core_get_capture_device(app->getCore()));
|
||||
MSSndCard *play_card = ms_snd_card_manager_get_card(manager, linphone_core_get_playback_device(app->getCore()));
|
||||
RtpProfile *prof=rtp_profile_new("stream");
|
||||
PayloadType *pt=getPayloadType(app->getCore(), linphone_core_get_audio_codecs(app->getCore()), payload_type);
|
||||
|
||||
if (!pt){
|
||||
app->sendResponse(Response("No payload type were assigned to this number."));
|
||||
return;
|
||||
}
|
||||
AudioStream *stream = audio_stream_new(factory, local_port, local_port + 1, linphone_core_ipv6_enabled(app->getCore()));
|
||||
audio_stream_set_features(stream,linphone_core_get_audio_features(app->getCore()));
|
||||
|
||||
pt=payload_type_clone(pt);
|
||||
if (ptime!=0){
|
||||
char fmtp[32];
|
||||
snprintf(fmtp,sizeof(fmtp)-1,"ptime=%i",ptime);
|
||||
payload_type_append_send_fmtp(pt,fmtp);
|
||||
}
|
||||
rtp_profile_set_payload(prof,payload_type,pt);
|
||||
if (linphone_core_generic_confort_noise_enabled(app->getCore())){
|
||||
rtp_profile_set_payload(prof,13,payload_type_clone(&payload_type_cn));
|
||||
}
|
||||
|
||||
|
||||
audio_stream_enable_adaptive_jittcomp(stream, linphone_core_audio_adaptive_jittcomp_enabled(app->getCore()));
|
||||
rtp_session_set_symmetric_rtp(stream->ms.sessions.rtp_session, linphone_core_symmetric_rtp_enabled(app->getCore()));
|
||||
|
||||
int err=audio_stream_start_now(stream, prof, addr, port, port + 1, payload_type, jitt, play_card, capture_card, echo_canceller);
|
||||
|
||||
if (err != 0) {
|
||||
app->sendResponse(Response("Error during audio stream creation."));
|
||||
return;
|
||||
}
|
||||
ostringstream ostr;
|
||||
ostr << "Id: " << app->updateAudioStreamId(stream) << "\n";
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> addr;
|
||||
ist >> port;
|
||||
ist >> payload_type;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
|
||||
int local_port = linphone_core_get_audio_port(app->getCore());
|
||||
int jitt = linphone_core_get_audio_jittcomp(app->getCore());
|
||||
bool_t echo_canceller = linphone_core_echo_cancellation_enabled(app->getCore());
|
||||
int ptime = linphone_core_get_upload_ptime(app->getCore());
|
||||
MSSndCardManager *manager = ms_factory_get_snd_card_manager(factory);
|
||||
MSSndCard *capture_card = ms_snd_card_manager_get_card(manager, linphone_core_get_capture_device(app->getCore()));
|
||||
MSSndCard *play_card = ms_snd_card_manager_get_card(manager, linphone_core_get_playback_device(app->getCore()));
|
||||
RtpProfile *prof = rtp_profile_new("stream");
|
||||
PayloadType *pt = getPayloadType(app->getCore(), linphone_core_get_audio_codecs(app->getCore()), payload_type);
|
||||
|
||||
if (!pt){
|
||||
app->sendResponse(Response("No payload type were assigned to this number."));
|
||||
return;
|
||||
}
|
||||
AudioStream *stream = audio_stream_new(factory, local_port, local_port + 1, linphone_core_ipv6_enabled(app->getCore()));
|
||||
audio_stream_set_features(stream, linphone_core_get_audio_features(app->getCore()));
|
||||
|
||||
pt = payload_type_clone(pt);
|
||||
if (ptime != 0) {
|
||||
char fmtp[32];
|
||||
snprintf(fmtp, sizeof(fmtp) - 1, "ptime=%i", ptime);
|
||||
payload_type_append_send_fmtp(pt, fmtp);
|
||||
}
|
||||
rtp_profile_set_payload(prof, payload_type,pt);
|
||||
if (linphone_core_generic_confort_noise_enabled(app->getCore())){
|
||||
rtp_profile_set_payload(prof, 13, payload_type_clone(&payload_type_cn));
|
||||
}
|
||||
audio_stream_enable_adaptive_jittcomp(stream, linphone_core_audio_adaptive_jittcomp_enabled(app->getCore()));
|
||||
rtp_session_set_symmetric_rtp(stream->ms.sessions.rtp_session, linphone_core_symmetric_rtp_enabled(app->getCore()));
|
||||
|
||||
int err = audio_stream_start_now(stream, prof, addr.c_str(), port, port + 1, payload_type, jitt, play_card, capture_card, echo_canceller);
|
||||
if (err != 0) {
|
||||
app->sendResponse(Response("Error during audio stream creation."));
|
||||
return;
|
||||
}
|
||||
|
||||
ostringstream ostr;
|
||||
ostr << "Id: " << app->updateAudioStreamId(stream) << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_STREAM_START_H_
|
||||
#define COMMAND_AUDIO_STREAM_START_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_START_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_START_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioStreamStartCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioStreamStartCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_STREAM_START_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_START_H_
|
||||
|
|
|
|||
|
|
@ -45,21 +45,21 @@ AudioStreamStatsCommand::AudioStreamStatsCommand() :
|
|||
"Reason: No audio stream with such id."));
|
||||
}
|
||||
|
||||
void AudioStreamStatsCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioStreamStatsCommand::exec(Daemon *app, const string& args) {
|
||||
int sid;
|
||||
AudioStreamAndOther *stream = NULL;
|
||||
if (sscanf(args, "%i", &sid) == 1) {
|
||||
stream = app->findAudioStreamAndOther(sid);
|
||||
if (!stream) {
|
||||
app->sendResponse(Response("No audio stream with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> sid;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("No stream specified."));
|
||||
return;
|
||||
}
|
||||
|
||||
ostringstream ostr;
|
||||
ostr << AudioStreamStatsResponse(app, stream->stream, &stream->stats, false).getBody();
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
stream = app->findAudioStreamAndOther(sid);
|
||||
if (!stream) {
|
||||
app->sendResponse(Response("No audio stream with such id."));
|
||||
return;
|
||||
}
|
||||
|
||||
app->sendResponse(Response(AudioStreamStatsResponse(app, stream->stream, &stream->stats, false).getBody(), Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_STREAM_STATS_H_
|
||||
#define COMMAND_AUDIO_STREAM_STATS_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STATS_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STATS_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioStreamStatsCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioStreamStatsCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_STREAM_STATS_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STATS_H_
|
||||
|
|
|
|||
|
|
@ -30,20 +30,23 @@ AudioStreamStopCommand::AudioStreamStopCommand() :
|
|||
"Reason: No Audio Stream with such id."));
|
||||
}
|
||||
|
||||
void AudioStreamStopCommand::exec(Daemon *app, const char *args) {
|
||||
void AudioStreamStopCommand::exec(Daemon *app, const string& args) {
|
||||
int id;
|
||||
if (sscanf(args, "%d", &id) == 1) {
|
||||
AudioStream *stream = app->findAudioStream(id);
|
||||
if (stream == NULL) {
|
||||
app->sendResponse(Response("No Audio Stream with such id."));
|
||||
return;
|
||||
}
|
||||
app->removeAudioStream(id);
|
||||
RtpProfile *prof=rtp_session_get_profile(stream->ms.sessions.rtp_session);
|
||||
audio_stream_stop(stream);
|
||||
rtp_profile_destroy(prof);
|
||||
app->sendResponse(Response());
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> id;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
|
||||
AudioStream *stream = app->findAudioStream(id);
|
||||
if (stream == NULL) {
|
||||
app->sendResponse(Response("No Audio Stream with such id."));
|
||||
return;
|
||||
}
|
||||
app->removeAudioStream(id);
|
||||
RtpProfile *prof=rtp_session_get_profile(stream->ms.sessions.rtp_session);
|
||||
audio_stream_stop(stream);
|
||||
rtp_profile_destroy(prof);
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUDIO_STREAM_STOP_H_
|
||||
#define COMMAND_AUDIO_STREAM_STOP_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STOP_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STOP_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AudioStreamStopCommand: public DaemonCommand {
|
||||
public:
|
||||
AudioStreamStopCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUDIO_STREAM_STOP_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUDIO_STREAM_STOP_H_
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ AuthInfosClearCommand::AuthInfosClearCommand() :
|
|||
"Reason: No auth info with such id."));
|
||||
}
|
||||
|
||||
void AuthInfosClearCommand::exec(Daemon *app, const char *args) {
|
||||
void AuthInfosClearCommand::exec(Daemon *app, const string& args) {
|
||||
string param;
|
||||
int pid;
|
||||
ostringstream ostr;
|
||||
|
|
@ -49,7 +49,7 @@ void AuthInfosClearCommand::exec(Daemon *app, const char *args) {
|
|||
int previous_size = app->maxAuthInfoId();
|
||||
linphone_core_clear_all_auth_info(app->getCore());
|
||||
ostr << "Successfully cleared " << previous_size - app->maxAuthInfoId() << " auth infos." << endl;
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
} else {
|
||||
LinphoneAuthInfo *auth_info = NULL;
|
||||
ist.clear();
|
||||
|
|
@ -66,6 +66,6 @@ void AuthInfosClearCommand::exec(Daemon *app, const char *args) {
|
|||
}
|
||||
linphone_core_remove_auth_info(app->getCore(), auth_info);
|
||||
ostr << "Successfully cleared auth info " << pid << "." << endl;
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
#define COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class AuthInfosClearCommand: public DaemonCommand {
|
||||
public:
|
||||
AuthInfosClearCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_AUTH_INFOS_CLEAR_H_
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "call-mute.h"
|
||||
|
||||
CallMute::CallMute() :
|
||||
using namespace std;
|
||||
|
||||
CallMuteCommand::CallMuteCommand() :
|
||||
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",
|
||||
|
|
@ -36,24 +38,25 @@ CallMute::CallMute() :
|
|||
"Reason: No call in progress. Can't mute."));
|
||||
}
|
||||
|
||||
void CallMute::exec(Daemon* app, const char* args)
|
||||
void CallMuteCommand::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int muted = TRUE; // no arg means MUTE
|
||||
int muted;
|
||||
LinphoneCall *call = linphone_core_get_current_call(lc);
|
||||
|
||||
if( call == NULL ){
|
||||
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);
|
||||
istringstream ist(args);
|
||||
ist >> muted;
|
||||
if (ist.fail() || (muted != 0)) {
|
||||
muted = TRUE;
|
||||
} else {
|
||||
linphone_core_enable_mic(lc, !muted);
|
||||
muted = FALSE;
|
||||
}
|
||||
linphone_core_enable_mic(lc, !muted);
|
||||
|
||||
app->sendResponse(Response(muted?"Microphone Muted"
|
||||
:"Microphone Unmuted",
|
||||
Response::Ok));
|
||||
app->sendResponse(Response(muted ? "Microphone Muted" : "Microphone Unmuted", Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLMUTE_H
|
||||
#define CALLMUTE_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_MUTE_H
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_MUTE_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
class CallMute : public DaemonCommand
|
||||
class CallMuteCommand : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
CallMute();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
CallMuteCommand();
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CALLMUTE_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_MUTE_H
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "call-pause.h"
|
||||
|
||||
CallPause::CallPause() :
|
||||
using namespace std;
|
||||
|
||||
CallPauseCommand::CallPauseCommand() :
|
||||
DaemonCommand("call-pause",
|
||||
"call-pause <call id>",
|
||||
"Pause a call (pause current if no id is specified).")
|
||||
|
|
@ -37,30 +39,31 @@ CallPause::CallPause() :
|
|||
"Reason: No current call available."));
|
||||
}
|
||||
|
||||
void CallPause::exec(Daemon* app, const char* args)
|
||||
void CallPauseCommand::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
bool current = false;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
current = true;
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( linphone_core_pause_call(lc, call) == 0 ) {
|
||||
app->sendResponse(Response(current?"Current call was paused":
|
||||
"Call was paused", Response::Ok));
|
||||
if (linphone_core_pause_call(lc, call) == 0) {
|
||||
app->sendResponse(Response(current ? "Current call was paused" : "Call was paused", Response::Ok));
|
||||
} else {
|
||||
app->sendResponse(Response("Error pausing call"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,17 +17,16 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLPAUSE_H
|
||||
#define CALLPAUSE_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_PAUSE_H
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_PAUSE_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
class CallPause : public DaemonCommand
|
||||
class CallPauseCommand : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
CallPause();
|
||||
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
CallPauseCommand();
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CALLPAUSE_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_PAUSE_H
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "call-resume.h"
|
||||
|
||||
CallResume::CallResume():
|
||||
using namespace std;
|
||||
|
||||
CallResumeCommand::CallResumeCommand():
|
||||
DaemonCommand("call-resume", "call-resume <call id>", "Pause a call (pause current if no id is specified).")
|
||||
{
|
||||
addExample(new DaemonCommandExample("call-resume 1",
|
||||
|
|
@ -35,30 +37,31 @@ CallResume::CallResume():
|
|||
"Reason: No current call available."));
|
||||
}
|
||||
|
||||
void CallResume::exec(Daemon* app, const char* args)
|
||||
void CallResumeCommand::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
bool current = false;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
current = true;
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( linphone_core_resume_call(lc, call) == 0 ) {
|
||||
app->sendResponse(Response(current?"Current call was resumed":
|
||||
"Call was resumed", Response::Ok));
|
||||
if (linphone_core_resume_call(lc, call) == 0) {
|
||||
app->sendResponse(Response(current ? "Current call was resumed" : "Call was resumed", Response::Ok));
|
||||
} else {
|
||||
app->sendResponse(Response("Error pausing call"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLRESUME_H
|
||||
#define CALLRESUME_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_RESUME_H
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_RESUME_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
class CallResume : public DaemonCommand
|
||||
class CallResumeCommand : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
CallResume();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
CallResumeCommand();
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CALLRESUME_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_RESUME_H
|
||||
|
|
|
|||
|
|
@ -52,26 +52,28 @@ CallStatsCommand::CallStatsCommand() :
|
|||
"Reason: No current call available."));
|
||||
}
|
||||
|
||||
void CallStatsCommand::exec(Daemon *app, const char *args) {
|
||||
void CallStatsCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ostringstream ostr;
|
||||
ostr << CallStatsResponse(app, call, linphone_call_get_audio_stats(call), false).getBody();
|
||||
ostr << CallStatsResponse(app, call, linphone_call_get_video_stats(call), false).getBody();
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CALL_STATS_H_
|
||||
#define COMMAND_CALL_STATS_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_STATS_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_STATS_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class CallStatsCommand: public DaemonCommand {
|
||||
public:
|
||||
CallStatsCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_CALL_STATS_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_STATS_H_
|
||||
|
|
|
|||
|
|
@ -36,22 +36,24 @@ CallStatusCommand::CallStatusCommand() :
|
|||
"Status: Error\n"
|
||||
"Reason: No current call available."));
|
||||
}
|
||||
void CallStatusCommand::exec(Daemon *app, const char *args) {
|
||||
void CallStatusCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LinphoneCallState call_state = LinphoneCallIdle;
|
||||
|
|
@ -82,5 +84,5 @@ void CallStatusCommand::exec(Daemon *app, const char *args) {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CALL_STATUS_H_
|
||||
#define COMMAND_CALL_STATUS_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_STATUS_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_STATUS_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class CallStatusCommand: public DaemonCommand {
|
||||
public:
|
||||
CallStatusCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_CALL_STATUS_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_STATUS_H_
|
||||
|
|
|
|||
|
|
@ -19,9 +19,11 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "call-transfer.h"
|
||||
|
||||
CallTransfer::CallTransfer() :
|
||||
using namespace std;
|
||||
|
||||
CallTransferCommand::CallTransferCommand() :
|
||||
DaemonCommand("call-transfer",
|
||||
"call-transfer <call id> <sip url>",
|
||||
"call-transfer <call_to_transfer_id> <call_to_transfer_to_id|sip_url_to_transfer_to>",
|
||||
"Transfer a call that you aswered to another party")
|
||||
{
|
||||
addExample(new DaemonCommandExample("call-transfer 1 sip:john",
|
||||
|
|
@ -32,33 +34,73 @@ CallTransfer::CallTransfer() :
|
|||
addExample(new DaemonCommandExample("call-transfer 2 sip:john",
|
||||
"Status: Error\n"
|
||||
"Reason: No call with such id."));
|
||||
|
||||
addExample(new DaemonCommandExample("call-transfer 1 2",
|
||||
"Status: Ok\n\n"
|
||||
"Call ID: 1\n"
|
||||
"Transfer to: 2"));
|
||||
}
|
||||
|
||||
void CallTransfer::exec(Daemon* app, const char* args)
|
||||
void CallTransferCommand::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
char sipurl[512];
|
||||
memset(sipurl, 0x00, 512);
|
||||
LinphoneCall *call_to_transfer = NULL;
|
||||
LinphoneCall *call_to_transfer_to = NULL;
|
||||
istringstream ist(args);
|
||||
|
||||
if (sscanf(args, "%i %511s", &cid, sipurl) == 2) {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
app->sendResponse(Response("Invalid command format."));
|
||||
if (ist.peek() == EOF) {
|
||||
app->sendResponse(Response("Missing call_to_transfer_id parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
if( linphone_core_transfer_call(lc, call, sipurl) == 0 ) {
|
||||
std::ostringstream ostr;
|
||||
ostr << "Call ID: " << cid << "\n";
|
||||
ostr << "Transfer to: " << sipurl << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
} else {
|
||||
app->sendResponse(Response("Error pausing call"));
|
||||
int call_to_transfer_id;
|
||||
int call_to_transfer_to_id;
|
||||
string sip_uri_to_transfer_to;
|
||||
ist >> call_to_transfer_id;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Invalid command format (wrong call_to_transfer_id parameter)."));
|
||||
return;
|
||||
}
|
||||
if (ist.peek() == EOF) {
|
||||
app->sendResponse(Response("Missing call_to_transfer_to_id or sip_uri_to_transfer_to parameter.", Response::Error));
|
||||
}
|
||||
ist >> call_to_transfer_to_id;
|
||||
if (ist.fail()) {
|
||||
ist.clear();
|
||||
ist >> sip_uri_to_transfer_to;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Invalid command format (wrong call_to_transfer_to_id or sip_uri_to_transfer_to parameter."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
call_to_transfer = app->findCall(call_to_transfer_id);
|
||||
if (call_to_transfer == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
if (sip_uri_to_transfer_to.empty()) {
|
||||
call_to_transfer_to = app->findCall(call_to_transfer_to_id);
|
||||
if (call_to_transfer_to == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
if (linphone_core_transfer_call_to_another(lc, call_to_transfer, call_to_transfer_to) == 0) {
|
||||
std::ostringstream ostr;
|
||||
ostr << "Call ID: " << call_to_transfer_id << "\n";
|
||||
ostr << "Transfer to: " << call_to_transfer_to_id << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (linphone_core_transfer_call(lc, call_to_transfer, sip_uri_to_transfer_to.c_str()) == 0) {
|
||||
std::ostringstream ostr;
|
||||
ostr << "Call ID: " << call_to_transfer_id << "\n";
|
||||
ostr << "Transfer to: " << sip_uri_to_transfer_to << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
app->sendResponse(Response("Error transferring call."));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLTRANSFER_H
|
||||
#define CALLTRANSFER_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_TRANSFER_H
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_TRANSFER_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
class CallTransfer : public DaemonCommand
|
||||
class CallTransferCommand : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
CallTransfer();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
CallTransferCommand();
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CALLTRANSFER_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_TRANSFER_H
|
||||
|
|
|
|||
|
|
@ -35,30 +35,37 @@ CallCommand::CallCommand() :
|
|||
"Reason: Call creation failed."));
|
||||
}
|
||||
|
||||
void CallCommand::exec(Daemon *app, const char *args) {
|
||||
void CallCommand::exec(Daemon *app, const string& args) {
|
||||
string address;
|
||||
string early_media;
|
||||
LinphoneCall *call;
|
||||
Response resp;
|
||||
ostringstream ostr;
|
||||
char address[256] = { 0 }, early_media[256] = { 0 };
|
||||
if (sscanf(args, "%s %s", address, early_media) == 2) {
|
||||
char *opt;
|
||||
LinphoneCallParams *cp;
|
||||
opt = strstr(early_media,"--early-media");
|
||||
cp = linphone_core_create_call_params(app->getCore(), NULL);
|
||||
if (opt) {
|
||||
|
||||
istringstream ist(args);
|
||||
ist >> address;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing address parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
ist >> early_media;
|
||||
if (!ist.fail()) {
|
||||
LinphoneCallParams *cp = linphone_core_create_call_params(app->getCore(), NULL);
|
||||
if (early_media.compare("--early-media") == 0) {
|
||||
linphone_call_params_enable_early_media_sending(cp, TRUE);
|
||||
ostr << "Early media: Ok\n";
|
||||
}
|
||||
call = linphone_core_invite_with_params(app->getCore(), address, cp);
|
||||
call = linphone_core_invite_with_params(app->getCore(), address.c_str(), cp);
|
||||
} else {
|
||||
call = linphone_core_invite(app->getCore(), args);
|
||||
call = linphone_core_invite(app->getCore(), address.c_str());
|
||||
}
|
||||
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("Call creation failed."));
|
||||
} else {
|
||||
ostr << "Id: " << app->updateCallId(call) << "\n";
|
||||
resp.setBody(ostr.str().c_str());
|
||||
app->sendResponse(resp);
|
||||
return;
|
||||
}
|
||||
|
||||
ostr << "Id: " << app->updateCallId(call) << "\n";
|
||||
resp.setBody(ostr.str());
|
||||
app->sendResponse(resp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CALL_H_
|
||||
#define COMMAND_CALL_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CALL_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CALL_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class CallCommand: public DaemonCommand {
|
||||
public:
|
||||
CallCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_CALL_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CALL_H_
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ CNResponse::CNResponse(LinphoneCore *core) : Response() {
|
|||
} else {
|
||||
ost << "disabled\n";
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -53,21 +53,22 @@ CNCommand::CNCommand() :
|
|||
"State: disabled"));
|
||||
}
|
||||
|
||||
void CNCommand::exec(Daemon *app, const char *args) {
|
||||
void CNCommand::exec(Daemon *app, const string& args) {
|
||||
string status;
|
||||
istringstream ist(args);
|
||||
ist >> status;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(CNResponse(app->getCore()));
|
||||
} else {
|
||||
if (status.compare("enable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), TRUE);
|
||||
} else if (status.compare("disable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), FALSE);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(CNResponse(app->getCore()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.compare("enable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), TRUE);
|
||||
} else if (status.compare("disable") == 0) {
|
||||
linphone_core_enable_generic_confort_noise(app->getCore(), FALSE);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(CNResponse(app->getCore()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CN_H_
|
||||
#define COMMAND_CN_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CN_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CN_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class CNCommand: public DaemonCommand {
|
||||
public:
|
||||
CNCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_IPV6_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CN_H_
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "conference.h"
|
||||
|
||||
Conference::Conference() :
|
||||
using namespace std;
|
||||
|
||||
ConferenceCommand::ConferenceCommand() :
|
||||
DaemonCommand("conference", "conference <subcommand> <call id>",
|
||||
"Create and manage an audio conference.\n"
|
||||
"Subcommands:\n"
|
||||
|
|
@ -44,45 +46,45 @@ Conference::Conference() :
|
|||
"Reason: No call with such id."));
|
||||
}
|
||||
|
||||
void Conference::exec(Daemon* app, const char* args)
|
||||
{
|
||||
void ConferenceCommand::exec(Daemon* app, const string& args) {
|
||||
LinphoneCore* lc = app->getCore();
|
||||
long id;
|
||||
char subcommand[32]={0};
|
||||
int n;
|
||||
n=sscanf(args, "%31s %li", subcommand,&id);
|
||||
if (n == 2){
|
||||
LinphoneCall *call=app->findCall(id);
|
||||
if (call==NULL){
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(subcommand,"add")==0){
|
||||
n = linphone_core_add_to_conference(lc,call);
|
||||
|
||||
}else if (strcmp(subcommand,"rm")==0){
|
||||
n = linphone_core_remove_from_conference(lc,call);
|
||||
|
||||
}else if (strcmp(subcommand,"enter")==0){
|
||||
n = linphone_core_enter_conference(lc);
|
||||
|
||||
}else if (strcmp(subcommand,"leave")==0){
|
||||
n = linphone_core_leave_conference(lc);
|
||||
} else {
|
||||
app->sendResponse("Invalid command format.");
|
||||
}
|
||||
|
||||
if ( n == 0 ){
|
||||
std::ostringstream ostr;
|
||||
ostr << "Call ID: " << id << "\n";
|
||||
ostr << "Conference: " << subcommand << " OK" << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
} else {
|
||||
app->sendResponse("Conference: command failed");
|
||||
}
|
||||
|
||||
} else {
|
||||
app->sendResponse("Invalid command format.");
|
||||
int id;
|
||||
string subcommand;
|
||||
int ret;
|
||||
istringstream ist(args);
|
||||
ist >> subcommand;
|
||||
ist >> id;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Invalid command format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
LinphoneCall *call=app->findCall(id);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
if (subcommand.compare("add") == 0) {
|
||||
ret = linphone_core_add_to_conference(lc, call);
|
||||
} else if (subcommand.compare("rm") == 0) {
|
||||
ret = linphone_core_remove_from_conference(lc, call);
|
||||
} else if (subcommand.compare("enter") == 0) {
|
||||
ret = linphone_core_enter_conference(lc);
|
||||
} else if (subcommand.compare("leave") == 0) {
|
||||
ret = linphone_core_leave_conference(lc);
|
||||
} else {
|
||||
app->sendResponse(Response("Invalid command format.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
std::ostringstream ostr;
|
||||
ostr << "Call ID: " << id << "\n";
|
||||
ostr << "Conference: " << subcommand << " OK" << "\n";
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
return;
|
||||
}
|
||||
|
||||
app->sendResponse(Response("Command failed", Response::Error));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMANDS_CONFERENCE_H
|
||||
#define COMMANDS_CONFERENCE_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CONFERENCE_H
|
||||
#define LINPHONE_DAEMON_COMMAND_CONFERENCE_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
class Conference : public DaemonCommand
|
||||
class ConferenceCommand : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
Conference();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
ConferenceCommand();
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CONFERENCE_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CONFERENCE_H
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
ConfigResponse::ConfigResponse(const char *value) : Response() {
|
||||
ostringstream ost;
|
||||
ost << "Value: "<<(value ? value : "<unset>");
|
||||
setBody(ost.str().c_str());
|
||||
ost << "Value: " << value ? value : "<unset>";
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
ConfigGetCommand::ConfigGetCommand() :
|
||||
|
|
@ -40,16 +40,16 @@ ConfigGetCommand::ConfigGetCommand() :
|
|||
"Value: <unset>"));
|
||||
}
|
||||
|
||||
void ConfigGetCommand::exec(Daemon *app, const char *args) {
|
||||
void ConfigGetCommand::exec(Daemon *app, const string& args) {
|
||||
string section,key;
|
||||
istringstream ist(args);
|
||||
ist >> section >> key;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing section and/or key names."));
|
||||
} else {
|
||||
const char *read_value=lp_config_get_string(linphone_core_get_config(app->getCore()),section.c_str(),key.c_str(),NULL);
|
||||
app->sendResponse(ConfigResponse(read_value));
|
||||
return;
|
||||
}
|
||||
const char *read_value=lp_config_get_string(linphone_core_get_config(app->getCore()),section.c_str(),key.c_str(),NULL);
|
||||
app->sendResponse(ConfigResponse(read_value));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -64,16 +64,16 @@ ConfigSetCommand::ConfigSetCommand() :
|
|||
"Value: <unset>"));
|
||||
}
|
||||
|
||||
void ConfigSetCommand::exec(Daemon *app, const char *args) {
|
||||
void ConfigSetCommand::exec(Daemon *app, const string& args) {
|
||||
string section,key,value;
|
||||
istringstream ist(args);
|
||||
ist >> section >> key;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing section and/or key names."));
|
||||
} else {
|
||||
ist>>value;
|
||||
lp_config_set_string(linphone_core_get_config(app->getCore()), section.c_str(), key.c_str(), value.size()>0 ? value.c_str() : NULL);
|
||||
app->sendResponse(ConfigResponse(value.c_str()));
|
||||
return;
|
||||
}
|
||||
ist>>value;
|
||||
lp_config_set_string(linphone_core_get_config(app->getCore()), section.c_str(), key.c_str(), value.size()>0 ? value.c_str() : NULL);
|
||||
app->sendResponse(ConfigResponse(value.c_str()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,21 +17,21 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CONFIG_H_
|
||||
#define COMMAND_CONFIG_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CONFIG_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CONFIG_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class ConfigGetCommand: public DaemonCommand {
|
||||
public:
|
||||
ConfigGetCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
class ConfigSetCommand: public DaemonCommand {
|
||||
public:
|
||||
ConfigSetCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_IPV6_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CONFIG_H_
|
||||
|
|
|
|||
|
|
@ -26,23 +26,26 @@ ContactCommand::ContactCommand() :
|
|||
addExample(new DaemonCommandExample("contact sip:root@unknown-host",
|
||||
"Status: Ok\n\n"));
|
||||
}
|
||||
void ContactCommand::exec(Daemon *app, const char *args) {
|
||||
|
||||
void ContactCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int result;
|
||||
char *contact;
|
||||
char username[256] = { 0 };
|
||||
char hostname[256] = { 0 };
|
||||
result = sscanf(args, "%255s %255s", username, hostname);
|
||||
if (result == 1) {
|
||||
linphone_core_set_primary_contact(lc,username);
|
||||
app->sendResponse(Response("", Response::Ok));
|
||||
string username;
|
||||
string hostname;
|
||||
istringstream ist(args);
|
||||
ist >> username;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
else if (result > 1) {
|
||||
contact=ortp_strdup_printf("sip:%s@%s",username,hostname);
|
||||
linphone_core_set_primary_contact(lc,contact);
|
||||
ms_free(contact);
|
||||
ist >> hostname;
|
||||
if (ist.fail()) {
|
||||
linphone_core_set_primary_contact(lc, username.c_str());
|
||||
app->sendResponse(Response("", Response::Ok));
|
||||
} else {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
contact = ortp_strdup_printf("sip:%s@%s", username.c_str(), hostname.c_str());
|
||||
linphone_core_set_primary_contact(lc, contact);
|
||||
ms_free(contact);
|
||||
app->sendResponse(Response("", Response::Ok));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_CONTACT_H_
|
||||
#define COMMAND_CONTACT_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_CONTACT_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_CONTACT_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class ContactCommand: public DaemonCommand {
|
||||
public:
|
||||
ContactCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_CONTACT_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_CONTACT_H_
|
||||
|
|
|
|||
|
|
@ -31,24 +31,25 @@ DtmfCommand::DtmfCommand() :
|
|||
"Status: Ok"));
|
||||
}
|
||||
|
||||
void DtmfCommand::exec(Daemon *app, const char *args) {
|
||||
void DtmfCommand::exec(Daemon *app, const string& args) {
|
||||
string digit_str;
|
||||
char digit;
|
||||
istringstream ist(args);
|
||||
ist >> digit_str;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing digit parameter.", Response::Error));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
digit = digit_str.at(0);
|
||||
if (isdigit(digit) || (digit == 'A') || (digit == 'B') || (digit == 'C') || (digit == 'D') || (digit == '*') || (digit == '#')) {
|
||||
LinphoneCall *call = linphone_core_get_current_call(app->getCore());
|
||||
linphone_core_play_dtmf(app->getCore(), digit, 100);
|
||||
if (call == NULL) {
|
||||
linphone_call_send_dtmf(call, digit);
|
||||
}
|
||||
app->sendResponse(Response());
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect digit parameter.", Response::Error));
|
||||
if (isdigit(digit) || (digit == 'A') || (digit == 'B') || (digit == 'C') || (digit == 'D') || (digit == '*') || (digit == '#')) {
|
||||
LinphoneCall *call = linphone_core_get_current_call(app->getCore());
|
||||
linphone_core_play_dtmf(app->getCore(), digit, 100);
|
||||
if (call == NULL) {
|
||||
linphone_call_send_dtmf(call, digit);
|
||||
}
|
||||
app->sendResponse(Response());
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect digit parameter.", Response::Error));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_DTMF_H_
|
||||
#define COMMAND_DTMF_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_DTMF_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_DTMF_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class DtmfCommand: public DaemonCommand {
|
||||
public:
|
||||
DtmfCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_DTMF_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_DTMF_H_
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ FirewallPolicyResponse::FirewallPolicyResponse(LinphoneCore *core) : Response()
|
|||
ost << "upnp\n";
|
||||
break;
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
FirewallPolicyCommand::FirewallPolicyCommand() :
|
||||
|
|
@ -71,50 +71,53 @@ FirewallPolicyCommand::FirewallPolicyCommand() :
|
|||
"Type: none"));
|
||||
}
|
||||
|
||||
void FirewallPolicyCommand::exec(Daemon *app, const char *args) {
|
||||
void FirewallPolicyCommand::exec(Daemon *app, const string& args) {
|
||||
string type;
|
||||
string address;
|
||||
istringstream ist(args);
|
||||
ist >> type;
|
||||
if (ist.eof() && (type.length() == 0)) {
|
||||
app->sendResponse(FirewallPolicyResponse(app->getCore()));
|
||||
} else if (ist.fail()) {
|
||||
return;
|
||||
}
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
|
||||
bool get_address;
|
||||
LinphoneFirewallPolicy policy;
|
||||
if (type.compare("none") == 0) {
|
||||
policy = LinphonePolicyNoFirewall;
|
||||
get_address = false;
|
||||
} else if (type.compare("nat") == 0) {
|
||||
policy = LinphonePolicyUseNatAddress;
|
||||
get_address = true;
|
||||
} else if (type.compare("stun") == 0) {
|
||||
policy = LinphonePolicyUseStun;
|
||||
get_address = true;
|
||||
} else if (type.compare("ice") == 0) {
|
||||
policy = LinphonePolicyUseIce;
|
||||
get_address = true;
|
||||
} else if (type.compare("upnp") == 0) {
|
||||
policy = LinphonePolicyUseUpnp;
|
||||
get_address = false;
|
||||
} else {
|
||||
bool get_address;
|
||||
LinphoneFirewallPolicy policy;
|
||||
if (type.compare("none") == 0) {
|
||||
policy = LinphonePolicyNoFirewall;
|
||||
get_address = false;
|
||||
} else if (type.compare("nat") == 0) {
|
||||
policy = LinphonePolicyUseNatAddress;
|
||||
get_address = true;
|
||||
} else if (type.compare("stun") == 0) {
|
||||
policy = LinphonePolicyUseStun;
|
||||
get_address = true;
|
||||
} else if (type.compare("ice") == 0) {
|
||||
policy = LinphonePolicyUseIce;
|
||||
get_address = true;
|
||||
} else if (type.compare("upnp") == 0) {
|
||||
policy = LinphonePolicyUseUpnp;
|
||||
get_address = false;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (get_address) {
|
||||
ist >> address;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect address parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (get_address) {
|
||||
ist >> address;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect address parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
linphone_core_set_firewall_policy(app->getCore(), policy);
|
||||
if (policy == LinphonePolicyUseNatAddress) {
|
||||
linphone_core_set_nat_address(app->getCore(), address.c_str());
|
||||
} else if ((policy == LinphonePolicyUseStun) || (policy == LinphonePolicyUseIce)) {
|
||||
linphone_core_set_stun_server(app->getCore(), address.c_str());
|
||||
}
|
||||
app->sendResponse(FirewallPolicyResponse(app->getCore()));
|
||||
}
|
||||
linphone_core_set_firewall_policy(app->getCore(), policy);
|
||||
if (policy == LinphonePolicyUseNatAddress) {
|
||||
linphone_core_set_nat_address(app->getCore(), address.c_str());
|
||||
} else if ((policy == LinphonePolicyUseStun) || (policy == LinphonePolicyUseIce)) {
|
||||
linphone_core_set_stun_server(app->getCore(), address.c_str());
|
||||
}
|
||||
app->sendResponse(FirewallPolicyResponse(app->getCore()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_FIREWALL_POLICY_H_
|
||||
#define COMMAND_FIREWALL_POLICY_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_FIREWALL_POLICY_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_FIREWALL_POLICY_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class FirewallPolicyCommand: public DaemonCommand {
|
||||
public:
|
||||
FirewallPolicyCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_FIREWALL_POLICY_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_FIREWALL_POLICY_H_
|
||||
|
|
|
|||
|
|
@ -25,21 +25,22 @@ HelpCommand::HelpCommand() :
|
|||
DaemonCommand("help", "help <command>", "Show <command> help notice, if command is unspecified or inexistent show all commands.") {
|
||||
}
|
||||
|
||||
void HelpCommand::exec(Daemon *app, const char *args) {
|
||||
void HelpCommand::exec(Daemon *app, const string& args) {
|
||||
ostringstream ost;
|
||||
list<DaemonCommand*>::const_iterator it;
|
||||
const list<DaemonCommand*> &l = app->getCommandList();
|
||||
if (args){
|
||||
bool found = false;
|
||||
if (!args.empty()){
|
||||
for (it = l.begin(); it != l.end(); ++it) {
|
||||
if ((*it)->matches(args)){
|
||||
ost << (*it)->getHelp();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (it==l.end()) args=NULL;
|
||||
}
|
||||
|
||||
if (args==NULL){
|
||||
if (!found){
|
||||
for (it = l.begin(); it != l.end(); ++it) {
|
||||
ost << (*it)->getProto() << endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_HELP_H_
|
||||
#define COMMAND_HELP_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_HELP_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_HELP_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class HelpCommand: public DaemonCommand {
|
||||
public:
|
||||
HelpCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_HELP_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_HELP_H_
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ IPv6Response::IPv6Response(LinphoneCore *core) : Response() {
|
|||
} else {
|
||||
ost << "disabled\n";
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
IPv6Command::IPv6Command() :
|
||||
|
|
@ -52,21 +52,22 @@ IPv6Command::IPv6Command() :
|
|||
"State: disabled"));
|
||||
}
|
||||
|
||||
void IPv6Command::exec(Daemon *app, const char *args) {
|
||||
void IPv6Command::exec(Daemon *app, const string& args) {
|
||||
string status;
|
||||
istringstream ist(args);
|
||||
ist >> status;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(IPv6Response(app->getCore()));
|
||||
} else {
|
||||
if (status.compare("enable") == 0) {
|
||||
linphone_core_enable_ipv6(app->getCore(), TRUE);
|
||||
} else if (status.compare("disable") == 0) {
|
||||
linphone_core_enable_ipv6(app->getCore(), FALSE);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(IPv6Response(app->getCore()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.compare("enable") == 0) {
|
||||
linphone_core_enable_ipv6(app->getCore(), TRUE);
|
||||
} else if (status.compare("disable") == 0) {
|
||||
linphone_core_enable_ipv6(app->getCore(), FALSE);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(IPv6Response(app->getCore()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_IPV6_H_
|
||||
#define COMMAND_IPV6_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_IPV6_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_IPV6_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class IPv6Command: public DaemonCommand {
|
||||
public:
|
||||
IPv6Command();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_IPV6_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_IPV6_H_
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
ostr<<"audio-jitter-buffer-size: "<<linphone_core_get_audio_jittcomp(lc)<<endl;
|
||||
if (video)
|
||||
ostr<<"video-jitter-buffer-size: "<<linphone_core_get_video_jittcomp(lc)<<endl;
|
||||
setBody(ostr.str().c_str());
|
||||
setBody(ostr.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -52,37 +52,37 @@ JitterBufferCommand::JitterBufferCommand() : DaemonCommand("jitter-buffer",
|
|||
}
|
||||
|
||||
|
||||
void JitterBufferCommand::exec(Daemon *app, const char *args){
|
||||
void JitterBufferCommand::exec(Daemon *app, const string& args) {
|
||||
istringstream istr(args);
|
||||
string arg1;
|
||||
istr>>arg1;
|
||||
istr >> arg1;
|
||||
if (istr.fail()){
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(),true,true));
|
||||
}else{
|
||||
if (arg1!="audio" && arg1!="video"){
|
||||
app->sendResponse("Invalid argument.");
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(), true, true));
|
||||
return;
|
||||
}
|
||||
if (arg1 != "audio" && arg1 != "video") {
|
||||
app->sendResponse(Response("Invalid argument."));
|
||||
return;
|
||||
}
|
||||
string arg2;
|
||||
istr >> arg2;
|
||||
if (istr.fail()) {
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(), arg1 == "audio", arg1 == "video"));
|
||||
return;
|
||||
}
|
||||
if (arg2 == "size") {
|
||||
int arg3;
|
||||
istr >> arg3;
|
||||
if (istr.fail()) {
|
||||
app->sendResponse(Response("Bad command argument."));
|
||||
return;
|
||||
}
|
||||
string arg2;
|
||||
istr>>arg2;
|
||||
if (istr.fail()){
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(),arg1=="audio",arg1=="video"));
|
||||
}else{
|
||||
if (arg2=="size"){
|
||||
int arg3;
|
||||
istr>>arg3;
|
||||
if (!istr.fail()){
|
||||
if (arg1=="audio")
|
||||
linphone_core_set_audio_jittcomp(app->getCore(),arg3);
|
||||
else if (arg1=="video")
|
||||
linphone_core_set_video_jittcomp(app->getCore(),arg3);
|
||||
}
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(),arg1=="audio",arg1=="video"));
|
||||
}else{
|
||||
app->sendResponse(Response("Bad command argument."));
|
||||
}
|
||||
}
|
||||
if (arg1 == "audio")
|
||||
linphone_core_set_audio_jittcomp(app->getCore(), arg3);
|
||||
else if (arg1=="video")
|
||||
linphone_core_set_video_jittcomp(app->getCore(), arg3);
|
||||
}
|
||||
app->sendResponse(JitterBufferResponse(app->getCore(), arg1 == "audio", arg1 == "video"));
|
||||
}
|
||||
|
||||
JitterBufferResetCommand::JitterBufferResetCommand() : DaemonCommand("jitter-buffer-reset",
|
||||
|
|
@ -96,53 +96,52 @@ JitterBufferResetCommand::JitterBufferResetCommand() : DaemonCommand("jitter-buf
|
|||
}
|
||||
|
||||
|
||||
void JitterBufferResetCommand::exec(Daemon *app, const char *args){
|
||||
void JitterBufferResetCommand::exec(Daemon *app, const string& args) {
|
||||
istringstream istr(args);
|
||||
string arg1;
|
||||
istr>>arg1;
|
||||
if (istr.fail()){
|
||||
istr >> arg1;
|
||||
if (istr.fail()) {
|
||||
app->sendResponse(Response("Missing arguments"));
|
||||
}else{
|
||||
if (arg1!="call" && arg1!="stream"){
|
||||
app->sendResponse(Response("Invalid command syntax."));
|
||||
return;
|
||||
}
|
||||
int arg2;
|
||||
istr>>arg2;
|
||||
if (istr.fail()){
|
||||
app->sendResponse(Response("Missing call or stream id."));
|
||||
return;
|
||||
}else{
|
||||
MSFilter *rtprecv=NULL;
|
||||
if (arg1=="call"){
|
||||
LinphoneCall *call=app->findCall(arg2);
|
||||
string streamtype;
|
||||
if (call==NULL){
|
||||
app->sendResponse(Response("No such call id"));
|
||||
return;
|
||||
}
|
||||
istr>>streamtype;
|
||||
if (streamtype=="video"){
|
||||
rtprecv=call->videostream ? call->videostream->ms.rtprecv : NULL;
|
||||
}else{
|
||||
rtprecv=call->audiostream ? call->audiostream->ms.rtprecv : NULL;
|
||||
}
|
||||
}else{
|
||||
AudioStream *stream=app->findAudioStream(arg2);
|
||||
if (stream==NULL){
|
||||
app->sendResponse(Response("No such stream id"));
|
||||
return;
|
||||
}
|
||||
rtprecv=stream->ms.rtprecv;
|
||||
}
|
||||
if (rtprecv==NULL){
|
||||
app->sendResponse(Response("No such active stream"));
|
||||
return;
|
||||
}
|
||||
ms_filter_call_method_noarg(rtprecv,MS_RTP_RECV_RESET_JITTER_BUFFER);
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (arg1 != "call" && arg1 != "stream") {
|
||||
app->sendResponse(Response("Invalid command syntax."));
|
||||
return;
|
||||
}
|
||||
int arg2;
|
||||
istr >> arg2;
|
||||
if (istr.fail()) {
|
||||
app->sendResponse(Response("Missing call or stream id."));
|
||||
return;
|
||||
}
|
||||
MSFilter *rtprecv = NULL;
|
||||
if (arg1 == "call") {
|
||||
LinphoneCall *call = app->findCall(arg2);
|
||||
string streamtype;
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No such call id"));
|
||||
return;
|
||||
}
|
||||
istr >> streamtype;
|
||||
if (streamtype == "video") {
|
||||
rtprecv = call->videostream ? call->videostream->ms.rtprecv : NULL;
|
||||
} else {
|
||||
rtprecv = call->audiostream ? call->audiostream->ms.rtprecv : NULL;
|
||||
}
|
||||
} else {
|
||||
AudioStream *stream = app->findAudioStream(arg2);
|
||||
if (stream == NULL) {
|
||||
app->sendResponse(Response("No such stream id"));
|
||||
return;
|
||||
}
|
||||
rtprecv = stream->ms.rtprecv;
|
||||
}
|
||||
if (rtprecv == NULL) {
|
||||
app->sendResponse(Response("No such active stream"));
|
||||
return;
|
||||
}
|
||||
ms_filter_call_method_noarg(rtprecv, MS_RTP_RECV_RESET_JITTER_BUFFER);
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,23 +17,23 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_JITTER_SIZE_H_
|
||||
#define COMMAND_JITTER_SIZE_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_JITTER_BUFFER_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_JITTER_BUFFER_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
|
||||
class JitterBufferCommand : public DaemonCommand{
|
||||
public:
|
||||
JitterBufferCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
|
||||
class JitterBufferResetCommand : public DaemonCommand{
|
||||
public:
|
||||
JitterBufferResetCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // LINPHONE_DAEMON_COMMAND_JITTER_BUFFER_H
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ MediaEncryptionResponse::MediaEncryptionResponse(LinphoneCore *core) : Response(
|
|||
ost << "DTLS\n";
|
||||
break;
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
MediaEncryptionCommand::MediaEncryptionCommand() :
|
||||
|
|
@ -61,30 +61,32 @@ MediaEncryptionCommand::MediaEncryptionCommand() :
|
|||
"Encryption: srtp"));
|
||||
}
|
||||
|
||||
void MediaEncryptionCommand::exec(Daemon *app, const char *args) {
|
||||
void MediaEncryptionCommand::exec(Daemon *app, const string& args) {
|
||||
string encryption_str;
|
||||
istringstream ist(args);
|
||||
ist >> encryption_str;
|
||||
if (ist.eof() && (encryption_str.length() == 0)) {
|
||||
app->sendResponse(MediaEncryptionResponse(app->getCore()));
|
||||
} else if (ist.fail()) {
|
||||
return;
|
||||
}
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
LinphoneMediaEncryption encryption;
|
||||
if (encryption_str.compare("none") == 0) {
|
||||
encryption = LinphoneMediaEncryptionNone;
|
||||
} else if (encryption_str.compare("srtp") == 0) {
|
||||
encryption = LinphoneMediaEncryptionSRTP;
|
||||
} else if (encryption_str.compare("zrtp") == 0) {
|
||||
encryption = LinphoneMediaEncryptionZRTP;
|
||||
} else {
|
||||
LinphoneMediaEncryption encryption;
|
||||
if (encryption_str.compare("none") == 0) {
|
||||
encryption = LinphoneMediaEncryptionNone;
|
||||
} else if (encryption_str.compare("srtp") == 0) {
|
||||
encryption = LinphoneMediaEncryptionSRTP;
|
||||
} else if (encryption_str.compare("zrtp") == 0) {
|
||||
encryption = LinphoneMediaEncryptionZRTP;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (linphone_core_set_media_encryption(app->getCore(), encryption)==0){
|
||||
app->sendResponse(MediaEncryptionResponse(app->getCore()));
|
||||
}else{
|
||||
app->sendResponse(Response("Unsupported media encryption", Response::Error));
|
||||
}
|
||||
app->sendResponse(Response("Incorrect parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
if (linphone_core_set_media_encryption(app->getCore(), encryption) == 0) {
|
||||
app->sendResponse(MediaEncryptionResponse(app->getCore()));
|
||||
}else{
|
||||
app->sendResponse(Response("Unsupported media encryption", Response::Error));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_MEDIA_ENCRYPTION_H_
|
||||
#define COMMAND_MEDIA_ENCRYPTION_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_MEDIA_ENCRYPTION_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_MEDIA_ENCRYPTION_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class MediaEncryptionCommand: public DaemonCommand {
|
||||
public:
|
||||
MediaEncryptionCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_MEDIA_ENCRYPTION_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_MEDIA_ENCRYPTION_H_
|
||||
|
|
|
|||
|
|
@ -35,34 +35,40 @@ MSFilterAddFmtpCommand::MSFilterAddFmtpCommand() :
|
|||
"Reason: No Audio Stream with such id."));
|
||||
}
|
||||
|
||||
void MSFilterAddFmtpCommand::exec(Daemon *app, const char *args) {
|
||||
char type[16]={0}, fmtp[512]={0};
|
||||
void MSFilterAddFmtpCommand::exec(Daemon *app, const string& args) {
|
||||
string type;
|
||||
int id;
|
||||
string fmtp;
|
||||
|
||||
if (sscanf(args, "%15s %d %511s", 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;
|
||||
}
|
||||
if (call->audiostream==NULL || call->audiostream->ms.encoder==NULL){
|
||||
app->sendResponse(Response("This call doesn't have an active audio stream."));
|
||||
return;
|
||||
}
|
||||
ms_filter_call_method(call->audiostream->ms.encoder, MS_FILTER_ADD_FMTP, fmtp);
|
||||
} 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->ms.encoder, MS_FILTER_ADD_FMTP, fmtp);
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter(s)."));
|
||||
}
|
||||
app->sendResponse(Response());
|
||||
} else {
|
||||
istringstream ist(args);
|
||||
ist >> type;
|
||||
ist >> id;
|
||||
ist >> fmtp;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
if (type.compare("call") == 0) {
|
||||
LinphoneCall *call = app->findCall(id);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No Call with such id."));
|
||||
return;
|
||||
}
|
||||
if (call->audiostream == NULL || call->audiostream->ms.encoder == NULL) {
|
||||
app->sendResponse(Response("This call doesn't have an active audio stream."));
|
||||
return;
|
||||
}
|
||||
ms_filter_call_method(call->audiostream->ms.encoder, MS_FILTER_ADD_FMTP, (void *)fmtp.c_str());
|
||||
} else if (type.compare("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->ms.encoder, MS_FILTER_ADD_FMTP, (void *)fmtp.c_str());
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_MSFILTER_ADD_FMTP
|
||||
#define COMMAND_MSFILTER_ADD_FMTP
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_MSFILTER_ADD_FMTP
|
||||
#define LINPHONE_DAEMON_COMMAND_MSFILTER_ADD_FMTP
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class MSFilterAddFmtpCommand : public DaemonCommand {
|
||||
public:
|
||||
MSFilterAddFmtpCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif /* COMMAND_MSFILTER_ADD_FMTP */
|
||||
#endif // LINPHONE_DAEMON_COMMAND_MSFILTER_ADD_FMTP
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ NetsimResponse::NetsimResponse(LinphoneCore *lc) : Response() {
|
|||
ost<<"jitter_burst_density: "<<params->jitter_burst_density<<endl;
|
||||
ost<<"jitter_strength: "<<params->jitter_strength<<endl;
|
||||
ost<<"mode: "<<ortp_network_simulator_mode_to_string(params->mode)<<endl;
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
NetsimCommand::NetsimCommand(): DaemonCommand("netsim","netsim [enabled|disabled|parameters <parameters]",
|
||||
|
|
@ -68,7 +68,7 @@ NetsimCommand::NetsimCommand(): DaemonCommand("netsim","netsim [enabled|disabled
|
|||
"State: enabled\nmax_bandwidth: 384000\nmax_buffer_size: 384000\nloss_rate: 2"));
|
||||
}
|
||||
|
||||
void NetsimCommand::exec(Daemon* app, const char* args){
|
||||
void NetsimCommand::exec(Daemon* app, const string& args) {
|
||||
LinphoneCore *lc=app->getCore();
|
||||
OrtpNetworkSimulatorParams params=*linphone_core_get_network_simulator_params(lc);
|
||||
string subcommand;
|
||||
|
|
@ -79,46 +79,45 @@ void NetsimCommand::exec(Daemon* app, const char* args){
|
|||
return;
|
||||
}
|
||||
if (subcommand.compare("enable")==0){
|
||||
params.enabled=TRUE;
|
||||
params.enabled = TRUE;
|
||||
}else if (subcommand.compare("disable")==0){
|
||||
params.enabled=FALSE;
|
||||
params.enabled = FALSE;
|
||||
}else if (subcommand.compare("parameters")==0){
|
||||
string parameters;
|
||||
char value[128]={0};
|
||||
char value[128] = { 0 };
|
||||
ist >> parameters;
|
||||
if (fmtp_get_value(parameters.c_str(),"max_bandwidth",value, sizeof(value))){
|
||||
params.max_bandwidth=(float)atoi(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "max_bandwidth", value, sizeof(value))) {
|
||||
params.max_bandwidth = (float)atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"max_buffer_size",value, sizeof(value))){
|
||||
params.max_buffer_size=atoi(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "max_buffer_size", value, sizeof(value))) {
|
||||
params.max_buffer_size = atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"loss_rate",value, sizeof(value))){
|
||||
params.loss_rate=(float)atoi(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "loss_rate", value, sizeof(value))) {
|
||||
params.loss_rate = (float)atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"latency",value, sizeof(value))){
|
||||
params.latency=atoi(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "latency", value, sizeof(value))) {
|
||||
params.latency = atoi(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"consecutive_loss_probability",value, sizeof(value))){
|
||||
params.consecutive_loss_probability=(float)atof(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "consecutive_loss_probability", value, sizeof(value))) {
|
||||
params.consecutive_loss_probability = (float)atof(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"jitter_burst_density",value, sizeof(value))){
|
||||
params.jitter_burst_density=(float)atof(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "jitter_burst_density", value, sizeof(value))) {
|
||||
params.jitter_burst_density = (float)atof(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"jitter_strength",value, sizeof(value))){
|
||||
params.jitter_strength=(float)atof(value);
|
||||
if (fmtp_get_value(parameters.c_str(), "jitter_strength", value, sizeof(value))) {
|
||||
params.jitter_strength = (float)atof(value);
|
||||
}
|
||||
if (fmtp_get_value(parameters.c_str(),"mode",value, sizeof(value))){
|
||||
OrtpNetworkSimulatorMode mode=ortp_network_simulator_mode_from_string(value);
|
||||
if (mode==OrtpNetworkSimulatorInvalid){
|
||||
if (fmtp_get_value(parameters.c_str(), "mode",value, sizeof(value))) {
|
||||
OrtpNetworkSimulatorMode mode = ortp_network_simulator_mode_from_string(value);
|
||||
if (mode == OrtpNetworkSimulatorInvalid) {
|
||||
app->sendResponse(Response("Invalid mode"));
|
||||
return;
|
||||
}
|
||||
params.mode=mode;
|
||||
params.mode = mode;
|
||||
}
|
||||
}
|
||||
linphone_core_set_network_simulator_params(lc,¶ms);
|
||||
linphone_core_set_network_simulator_params(lc, ¶ms);
|
||||
app->sendResponse(NetsimResponse(app->getCore()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_NETSIM_H_
|
||||
#define COMMAND_NETSIM_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_NETSIM_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_NETSIM_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class NetsimCommand: public DaemonCommand {
|
||||
public:
|
||||
NetsimCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_NETSIM_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_NETSIM_H_
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ void playWavFinished(LsdPlayer *p) {
|
|||
linphone_sound_daemon_release_player(lsd_player_get_daemon(p), p);
|
||||
}
|
||||
|
||||
void PlayWavCommand::exec(Daemon *app, const char *args) {
|
||||
void PlayWavCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneSoundDaemon *lsd = app->getLSD();
|
||||
if (!lsd) {
|
||||
app->sendResponse(Response("The linphone sound daemon (LSD) is not enabled.", Response::Error));
|
||||
|
|
@ -45,12 +45,14 @@ void PlayWavCommand::exec(Daemon *app, const char *args) {
|
|||
ist >> filename;
|
||||
if (ist.eof() && (filename.length() == 0)) {
|
||||
app->sendResponse(Response("Missing filename parameter.", Response::Error));
|
||||
} else if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect filename parameter.", Response::Error));
|
||||
} else {
|
||||
LsdPlayer *p = linphone_sound_daemon_get_player(lsd);
|
||||
lsd_player_set_callback(p, playWavFinished);
|
||||
lsd_player_play(p, filename.c_str());
|
||||
app->sendResponse(Response());
|
||||
return;
|
||||
}
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect filename parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
LsdPlayer *p = linphone_sound_daemon_get_player(lsd);
|
||||
lsd_player_set_callback(p, playWavFinished);
|
||||
lsd_player_play(p, filename.c_str());
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_PLAY_WAV_H_
|
||||
#define COMMAND_PLAY_WAV_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_PLAY_WAV_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_PLAY_WAV_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class PlayWavCommand: public DaemonCommand {
|
||||
public:
|
||||
PlayWavCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_PLAY_WAV_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_PLAY_WAV_H_
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ PopEventCommand::PopEventCommand() :
|
|||
"Status: Ok\n\n"
|
||||
"Size: 0"));
|
||||
}
|
||||
void PopEventCommand::exec(Daemon *app, const char *args) {
|
||||
void PopEventCommand::exec(Daemon *app, const string& args) {
|
||||
app->pullEvent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_POP_EVENT_H_
|
||||
#define COMMAND_POP_EVENT_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_POP_EVENT_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_POP_EVENT_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class PopEventCommand: public DaemonCommand {
|
||||
public:
|
||||
PopEventCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_POP_EVENT_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_POP_EVENT_H_
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ PortResponse::PortResponse(LinphoneCore *core, PortResponse::PortType type) : Re
|
|||
outputVideoRTPPort(core, ost);
|
||||
break;
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
void PortResponse::outputSIPPort(LinphoneCore *core, ostringstream &ost) {
|
||||
|
|
@ -116,7 +116,7 @@ PortCommand::PortCommand() :
|
|||
"Video RTP: 9078"));
|
||||
}
|
||||
|
||||
void PortCommand::exec(Daemon *app, const char *args) {
|
||||
void PortCommand::exec(Daemon *app, const string& args) {
|
||||
string type;
|
||||
int port;
|
||||
istringstream ist(args);
|
||||
|
|
@ -124,61 +124,63 @@ void PortCommand::exec(Daemon *app, const char *args) {
|
|||
ist >> type;
|
||||
if (ist.eof() && (type.length() == 0)) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::AllPorts));
|
||||
} else if (ist.fail()) {
|
||||
return;
|
||||
}
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
} else {
|
||||
ist >> port;
|
||||
if (ist.fail()) {
|
||||
if (type.compare("sip") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::SIPPort));
|
||||
} else if (type.compare("audio") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::AudioRTPPort));
|
||||
} else if (type.compare("video") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::VideoRTPPort));
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
}
|
||||
return;
|
||||
}
|
||||
ist >> port;
|
||||
if (ist.fail()) {
|
||||
if (type.compare("sip") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::SIPPort));
|
||||
} else if (type.compare("audio") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::AudioRTPPort));
|
||||
} else if (type.compare("video") == 0) {
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::VideoRTPPort));
|
||||
} else {
|
||||
if (type.compare("sip") == 0) {
|
||||
Protocol protocol = UDPProtocol;
|
||||
string protocol_str;
|
||||
ist >> protocol_str;
|
||||
if (!ist.fail()) {
|
||||
if (protocol_str.compare("udp") == 0) {
|
||||
protocol = UDPProtocol;
|
||||
} else if (protocol_str.compare("tcp") == 0) {
|
||||
protocol = TCPProtocol;
|
||||
} else if (protocol_str.compare("tls") == 0) {
|
||||
protocol = TLSProtocol;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect protocol parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
LCSipTransports transports;
|
||||
memset(&transports, 0, sizeof(transports));
|
||||
switch (protocol) {
|
||||
case UDPProtocol:
|
||||
transports.udp_port = port;
|
||||
break;
|
||||
case TCPProtocol:
|
||||
transports.tcp_port = port;
|
||||
break;
|
||||
case TLSProtocol:
|
||||
transports.tls_port = port;
|
||||
break;
|
||||
}
|
||||
linphone_core_set_sip_transports(app->getCore(), &transports);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::SIPPort));
|
||||
} else if (type.compare("audio") == 0) {
|
||||
linphone_core_set_audio_port(app->getCore(), port);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::AudioRTPPort));
|
||||
} else if (type.compare("video") == 0) {
|
||||
linphone_core_set_video_port(app->getCore(), port);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::VideoRTPPort));
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (type.compare("sip") == 0) {
|
||||
Protocol protocol = UDPProtocol;
|
||||
string protocol_str;
|
||||
ist >> protocol_str;
|
||||
if (!ist.fail()) {
|
||||
if (protocol_str.compare("udp") == 0) {
|
||||
protocol = UDPProtocol;
|
||||
} else if (protocol_str.compare("tcp") == 0) {
|
||||
protocol = TCPProtocol;
|
||||
} else if (protocol_str.compare("tls") == 0) {
|
||||
protocol = TLSProtocol;
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
app->sendResponse(Response("Incorrect protocol parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
LCSipTransports transports;
|
||||
memset(&transports, 0, sizeof(transports));
|
||||
switch (protocol) {
|
||||
case UDPProtocol:
|
||||
transports.udp_port = port;
|
||||
break;
|
||||
case TCPProtocol:
|
||||
transports.tcp_port = port;
|
||||
break;
|
||||
case TLSProtocol:
|
||||
transports.tls_port = port;
|
||||
break;
|
||||
}
|
||||
linphone_core_set_sip_transports(app->getCore(), &transports);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::SIPPort));
|
||||
} else if (type.compare("audio") == 0) {
|
||||
linphone_core_set_audio_port(app->getCore(), port);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::AudioRTPPort));
|
||||
} else if (type.compare("video") == 0) {
|
||||
linphone_core_set_video_port(app->getCore(), port);
|
||||
app->sendResponse(PortResponse(app->getCore(), PortResponse::VideoRTPPort));
|
||||
} else {
|
||||
app->sendResponse(Response("Incorrect type parameter.", Response::Error));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_PORT_H_
|
||||
#define COMMAND_PORT_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_PORT_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_PORT_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class PortCommand: public DaemonCommand {
|
||||
public:
|
||||
PortCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_PORT_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_PORT_H_
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ PtimeResponse::PtimeResponse(LinphoneCore *core, Direction dir) : Response() {
|
|||
ost << "Download: " << linphone_core_get_download_ptime(core) << "\n";
|
||||
break;
|
||||
}
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
PtimeCommand::PtimeCommand() :
|
||||
|
|
@ -65,34 +65,34 @@ PtimeCommand::PtimeCommand() :
|
|||
"Download: 30"));
|
||||
}
|
||||
|
||||
void PtimeCommand::exec(Daemon *app, const char *args) {
|
||||
void PtimeCommand::exec(Daemon *app, const string& args) {
|
||||
string direction;
|
||||
int ms;
|
||||
istringstream ist(args);
|
||||
ist >> direction;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(PtimeResponse(app->getCore(), PtimeResponse::BothDirections));
|
||||
} else {
|
||||
if (direction.compare("up") == 0) {
|
||||
if (!ist.eof()) {
|
||||
ist >> ms;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect ms parameter.", Response::Error));
|
||||
}
|
||||
linphone_core_set_upload_ptime(app->getCore(), ms);
|
||||
return;
|
||||
}
|
||||
if (direction.compare("up") == 0) {
|
||||
if (!ist.eof()) {
|
||||
ist >> ms;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect ms parameter.", Response::Error));
|
||||
}
|
||||
app->sendResponse(PtimeResponse(app->getCore(), PtimeResponse::Upload));
|
||||
} else if (direction.compare("down") == 0) {
|
||||
if (!ist.eof()) {
|
||||
ist >> ms;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect ms parameter.", Response::Error));
|
||||
}
|
||||
linphone_core_set_download_ptime(app->getCore(), ms);
|
||||
}
|
||||
app->sendResponse(PtimeResponse(app->getCore(), PtimeResponse::Download));
|
||||
} else {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s).", Response::Error));
|
||||
linphone_core_set_upload_ptime(app->getCore(), ms);
|
||||
}
|
||||
app->sendResponse(PtimeResponse(app->getCore(), PtimeResponse::Upload));
|
||||
} else if (direction.compare("down") == 0) {
|
||||
if (!ist.eof()) {
|
||||
ist >> ms;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Incorrect ms parameter.", Response::Error));
|
||||
}
|
||||
linphone_core_set_download_ptime(app->getCore(), ms);
|
||||
}
|
||||
app->sendResponse(PtimeResponse(app->getCore(), PtimeResponse::Download));
|
||||
} else {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s).", Response::Error));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_PTIME_H_
|
||||
#define COMMAND_PTIME_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_PTIME_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_PTIME_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class PtimeCommand: public DaemonCommand {
|
||||
public:
|
||||
PtimeCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_PTIME_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_PTIME_H_
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ QuitCommand::QuitCommand() :
|
|||
DaemonCommand("quit", "quit", "Quit the application.") {
|
||||
}
|
||||
|
||||
void QuitCommand::exec(Daemon *app, const char *args) {
|
||||
void QuitCommand::exec(Daemon *app, const string& args) {
|
||||
app->quit();
|
||||
app->sendResponse(Response());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_QUIT_H_
|
||||
#define COMMAND_QUIT_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_QUIT_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_QUIT_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class QuitCommand: public DaemonCommand {
|
||||
public:
|
||||
QuitCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_QUIT_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_QUIT_H_
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void RegisterStatusResponse::append(int id, const LinphoneProxyConfig* cfg) {
|
|||
}
|
||||
ost << "Id: " << id << "\n";
|
||||
ost << "State: " << linphone_registration_state_to_string(linphone_proxy_config_get_state(cfg)) << "\n";
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
RegisterStatusCommand::RegisterStatusCommand() :
|
||||
|
|
@ -63,7 +63,7 @@ RegisterStatusCommand::RegisterStatusCommand() :
|
|||
"Reason: No register with such id."));
|
||||
}
|
||||
|
||||
void RegisterStatusCommand::exec(Daemon *app, const char *args) {
|
||||
void RegisterStatusCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneProxyConfig *cfg = NULL;
|
||||
string param;
|
||||
int pid;
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_REGISTER_STATUS_H_
|
||||
#define COMMAND_REGISTER_STATUS_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_REGISTER_STATUS_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_REGISTER_STATUS_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class RegisterStatusCommand: public DaemonCommand {
|
||||
public:
|
||||
RegisterStatusCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_REGISTER_STATUS_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_REGISTER_STATUS_H_
|
||||
|
|
|
|||
|
|
@ -32,42 +32,54 @@ RegisterCommand::RegisterCommand() :
|
|||
"Status: Ok\n\n"
|
||||
"Id: 1"));
|
||||
}
|
||||
void RegisterCommand::exec(Daemon *app, const char *args) {
|
||||
void RegisterCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCore *lc = app->getCore();
|
||||
ostringstream ostr;
|
||||
char proxy[256] = { 0 }, identity[128] = { 0 }, password[64] = { 0 }, userid[128] = { 0 }, realm[128] = { 0 }, parameter[256] = { 0 };
|
||||
if (sscanf(args, "%255s %127s %63s %127s %127s %255s", identity, proxy, password, userid, realm, parameter) >= 2) {
|
||||
if (strcmp(password, "NULL") == 0) {
|
||||
password[0] = 0;
|
||||
}
|
||||
if (strcmp(userid, "NULL") == 0) {
|
||||
userid[0] = 0;
|
||||
}
|
||||
if (strcmp(realm, "NULL") == 0) {
|
||||
realm[0] = 0;
|
||||
}
|
||||
if (strcmp(parameter, "NULL") == 0) {
|
||||
parameter[0] = 0;
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_proxy_config_new();
|
||||
if (password[0] != '\0') {
|
||||
LinphoneAddress *from = linphone_address_new(identity);
|
||||
if (from != NULL) {
|
||||
LinphoneAuthInfo *info = linphone_auth_info_new(linphone_address_get_username(from),
|
||||
userid, password, NULL, realm, NULL);
|
||||
linphone_core_add_auth_info(lc, info); /*add authentication info to LinphoneCore*/
|
||||
linphone_address_destroy(from);
|
||||
linphone_auth_info_destroy(info);
|
||||
}
|
||||
}
|
||||
linphone_proxy_config_set_identity(cfg, identity);
|
||||
linphone_proxy_config_set_server_addr(cfg, proxy);
|
||||
linphone_proxy_config_enable_register(cfg, TRUE);
|
||||
linphone_proxy_config_set_contact_parameters(cfg, parameter);
|
||||
ostr << "Id: " << app->updateProxyId(cfg) << "\n";
|
||||
linphone_core_add_proxy_config(lc, cfg);
|
||||
app->sendResponse(Response(ostr.str().c_str(), Response::Ok));
|
||||
} else {
|
||||
string identity;
|
||||
string proxy;
|
||||
string password;
|
||||
string userid;
|
||||
string realm;
|
||||
string parameter;
|
||||
istringstream ist(args);
|
||||
const char *cidentity;
|
||||
const char *cproxy;
|
||||
const char *cpassword = NULL;
|
||||
const char *cuserid = NULL;
|
||||
const char *crealm = NULL;
|
||||
const char *cparameter = NULL;
|
||||
|
||||
ist >> identity;
|
||||
ist >> proxy;
|
||||
ist >> password;
|
||||
ist >> userid;
|
||||
ist >> realm;
|
||||
ist >> parameter;
|
||||
if (proxy.empty()) {
|
||||
app->sendResponse(Response("Missing/Incorrect parameter(s)."));
|
||||
return;
|
||||
}
|
||||
cidentity = identity.c_str();
|
||||
cproxy = proxy.c_str();
|
||||
if (!password.empty()) cpassword = password.c_str();
|
||||
if (!userid.empty()) cuserid = userid.c_str();
|
||||
if (!realm.empty()) crealm = realm.c_str();
|
||||
if (!parameter.empty()) cparameter = parameter.c_str();
|
||||
LinphoneProxyConfig *cfg = linphone_proxy_config_new();
|
||||
if (cpassword != NULL) {
|
||||
LinphoneAddress *from = linphone_address_new(cidentity);
|
||||
if (from != NULL) {
|
||||
LinphoneAuthInfo *info = linphone_auth_info_new(linphone_address_get_username(from), cuserid, cpassword, NULL, crealm, NULL);
|
||||
linphone_core_add_auth_info(lc, info); /* Add authentication info to LinphoneCore */
|
||||
linphone_address_destroy(from);
|
||||
linphone_auth_info_destroy(info);
|
||||
}
|
||||
}
|
||||
linphone_proxy_config_set_identity(cfg, cidentity);
|
||||
linphone_proxy_config_set_server_addr(cfg, cproxy);
|
||||
linphone_proxy_config_enable_register(cfg, TRUE);
|
||||
linphone_proxy_config_set_contact_parameters(cfg, cparameter);
|
||||
ostr << "Id: " << app->updateProxyId(cfg) << "\n";
|
||||
linphone_core_add_proxy_config(lc, cfg);
|
||||
app->sendResponse(Response(ostr.str(), Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_REGISTER_H_
|
||||
#define COMMAND_REGISTER_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_REGISTER_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_REGISTER_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class RegisterCommand: public DaemonCommand {
|
||||
public:
|
||||
RegisterCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_REGISTER_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_REGISTER_H_
|
||||
|
|
|
|||
|
|
@ -34,21 +34,23 @@ TerminateCommand::TerminateCommand() :
|
|||
"Status: Error\n"
|
||||
"Reason: No active call."));
|
||||
}
|
||||
void TerminateCommand::exec(Daemon *app, const char *args) {
|
||||
void TerminateCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneCall *call = NULL;
|
||||
int cid;
|
||||
const MSList *elem;
|
||||
if (sscanf(args, "%i", &cid) == 1) {
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
elem = linphone_core_get_calls(app->getCore());
|
||||
if (elem != NULL && elem->next == NULL) {
|
||||
call = (LinphoneCall*)elem->data;
|
||||
}
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
elem = linphone_core_get_calls(app->getCore());
|
||||
if (elem != NULL && elem->next == NULL) {
|
||||
call = (LinphoneCall*) elem->data;
|
||||
}
|
||||
}
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No active call."));
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_TERMINATE_H_
|
||||
#define COMMAND_TERMINATE_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_TERMINATE_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_TERMINATE_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class TerminateCommand: public DaemonCommand {
|
||||
public:
|
||||
TerminateCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_TERMINATE_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_TERMINATE_H_
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ UnregisterCommand::UnregisterCommand() :
|
|||
"Status: Ok"));
|
||||
}
|
||||
|
||||
void UnregisterCommand::exec(Daemon *app, const char *args) {
|
||||
void UnregisterCommand::exec(Daemon *app, const string& args) {
|
||||
LinphoneProxyConfig *cfg = NULL;
|
||||
string param;
|
||||
int pid;
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_UNREGISTER_H_
|
||||
#define COMMAND_UNREGISTER_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_UNREGISTER_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_UNREGISTER_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class UnregisterCommand: public DaemonCommand {
|
||||
public:
|
||||
UnregisterCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_UNREGISTER_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_UNREGISTER_H_
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VersionResponse::VersionResponse(LinphoneCore *core) : Response() {
|
||||
ostringstream ost;
|
||||
ost << "Version: " << linphone_core_get_version();
|
||||
setBody(ost.str().c_str());
|
||||
setBody(ost.str());
|
||||
}
|
||||
|
||||
VersionCommand::VersionCommand() :
|
||||
|
|
@ -39,6 +39,6 @@ VersionCommand::VersionCommand() :
|
|||
"Version: 3.5.99.0_6c2f4b9312fd4717b2f8ae0a7d7c97b752768c7c"));
|
||||
}
|
||||
|
||||
void VersionCommand::exec(Daemon *app, const char *args) {
|
||||
void VersionCommand::exec(Daemon *app, const string& args) {
|
||||
app->sendResponse(VersionResponse(app->getCore()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef COMMAND_VERSION_H_
|
||||
#define COMMAND_VERSION_H_
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_VERSION_H_
|
||||
#define LINPHONE_DAEMON_COMMAND_VERSION_H_
|
||||
|
||||
#include "../daemon.h"
|
||||
#include "daemon.h"
|
||||
|
||||
class VersionCommand: public DaemonCommand {
|
||||
public:
|
||||
VersionCommand();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif //COMMAND_VERSION_H_
|
||||
#endif // LINPHONE_DAEMON_COMMAND_VERSION_H_
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "commands/video.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Video::Video() :
|
||||
DaemonCommand("video",
|
||||
"video <call id>",
|
||||
|
|
@ -42,15 +44,15 @@ Video::Video() :
|
|||
"Reason: No call with such id."));
|
||||
}
|
||||
|
||||
void Video::exec(Daemon* app, const char* args)
|
||||
void Video::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
int cid;
|
||||
LinphoneCall *call = NULL;
|
||||
bool activate = false;
|
||||
int argc = sscanf(args, "%i", &cid);
|
||||
|
||||
if ( argc == 1) { // should take current call
|
||||
istringstream ist(args);
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
|
|
@ -64,12 +66,12 @@ void Video::exec(Daemon* app, const char* args)
|
|||
}
|
||||
}
|
||||
|
||||
if (linphone_call_get_state(call)==LinphoneCallStreamsRunning){
|
||||
if (linphone_call_get_state(call) == LinphoneCallStreamsRunning) {
|
||||
LinphoneCallParams *new_params = linphone_core_create_call_params(lc, call);
|
||||
activate = !linphone_call_params_video_enabled(new_params);
|
||||
|
||||
linphone_call_params_enable_video(new_params,activate);
|
||||
linphone_core_update_call(lc,call,new_params);
|
||||
linphone_call_params_enable_video(new_params, activate);
|
||||
linphone_core_update_call(lc, call, new_params);
|
||||
linphone_call_params_destroy(new_params);
|
||||
|
||||
} else {
|
||||
|
|
@ -77,8 +79,7 @@ void Video::exec(Daemon* app, const char* args)
|
|||
return;
|
||||
}
|
||||
|
||||
app->sendResponse(Response(activate?"Camera activated.":
|
||||
"Camera deactivated", Response::Ok));
|
||||
app->sendResponse(Response(activate ? "Camera activated." : "Camera deactivated", Response::Ok));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -105,41 +106,46 @@ VideoSource::VideoSource():
|
|||
"Reason: No call with such id."));
|
||||
}
|
||||
|
||||
void VideoSource::exec(Daemon* app, const char* args)
|
||||
void VideoSource::exec(Daemon* app, const string& args)
|
||||
{
|
||||
LinphoneCore *lc = app->getCore();
|
||||
LinphoneCall *call = NULL;
|
||||
string subcommand;
|
||||
int cid;
|
||||
int argc = 0;
|
||||
bool activate = false;
|
||||
char command[6];
|
||||
|
||||
argc = sscanf(args, "%5s %i", command, &cid);
|
||||
command[5] = 0;
|
||||
|
||||
if ( argc == 1) { // should take current call
|
||||
istringstream ist(args);
|
||||
ist >> subcommand;
|
||||
if (ist.fail()) {
|
||||
app->sendResponse(Response("Missing parameter.", Response::Error));
|
||||
return;
|
||||
}
|
||||
ist >> cid;
|
||||
if (ist.fail()) {
|
||||
call = linphone_core_get_current_call(lc);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No current call available."));
|
||||
return;
|
||||
}
|
||||
} else if( argc == 2 ) {
|
||||
} else {
|
||||
call = app->findCall(cid);
|
||||
if (call == NULL) {
|
||||
app->sendResponse(Response("No call with such id."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
app->sendResponse(Response("Invalid command"));
|
||||
return;
|
||||
}
|
||||
|
||||
activate = (strcmp(command,"cam") == 0);
|
||||
|
||||
if (subcommand.compare("cam") == 0) {
|
||||
activate = true;
|
||||
} else if (subcommand.compare("dummy") == 0) {
|
||||
activate = false;
|
||||
} else {
|
||||
app->sendResponse(Response("Invalid source.", Response::Error));
|
||||
return;
|
||||
}
|
||||
linphone_call_enable_camera(call,activate);
|
||||
|
||||
app->sendResponse(Response(activate?"Dummy source selected.":
|
||||
"Webcam source selected.", Response::Ok));
|
||||
app->sendResponse(Response(activate ? "Dummy source selected." : "Webcam source selected.", Response::Ok));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -157,11 +163,10 @@ AutoVideo::AutoVideo():
|
|||
"Auto video OFF"));
|
||||
}
|
||||
|
||||
void AutoVideo::exec(Daemon* app, const char* args)
|
||||
void AutoVideo::exec(Daemon* app, const std::string& args)
|
||||
{
|
||||
bool enable = (strcmp(args,"on") == 0);
|
||||
bool enable = (args.compare("on") == 0);
|
||||
|
||||
app->setAutoVideo(enable);
|
||||
app->sendResponse(Response(enable?"Auto video ON":
|
||||
"Auto video OFF", Response::Ok));
|
||||
app->sendResponse(Response(enable?"Auto video ON": "Auto video OFF", Response::Ok));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ along with this library; if not, write to the Free Software Foundation,
|
|||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef CALLCAMERA_H
|
||||
#define CALLCAMERA_H
|
||||
#ifndef LINPHONE_DAEMON_COMMAND_VIDEO_H
|
||||
#define LINPHONE_DAEMON_COMMAND_VIDEO_H
|
||||
|
||||
#include "daemon.h"
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ class Video : public DaemonCommand
|
|||
{
|
||||
public:
|
||||
Video();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -34,14 +34,14 @@ class VideoSource : public DaemonCommand
|
|||
{
|
||||
public:
|
||||
VideoSource();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
class AutoVideo : public DaemonCommand
|
||||
{
|
||||
public:
|
||||
AutoVideo();
|
||||
virtual void exec(Daemon *app, const char *args);
|
||||
virtual void exec(Daemon *app, const std::string& args);
|
||||
};
|
||||
|
||||
#endif // CALLCAMERA_H
|
||||
#endif // LINPHONE_DAEMON_COMMAND_VIDEO_H
|
||||
|
|
|
|||
124
daemon/daemon.cc
124
daemon/daemon.cc
|
|
@ -287,10 +287,10 @@ PayloadTypeParser::PayloadTypeParser(LinphoneCore *core, const string &mime_type
|
|||
}
|
||||
}
|
||||
|
||||
DaemonCommandExample::DaemonCommandExample(const char *command, const char *output)
|
||||
DaemonCommandExample::DaemonCommandExample(const string& command, const string& output)
|
||||
: mCommand(command), mOutput(output) {}
|
||||
|
||||
DaemonCommand::DaemonCommand(const char *name, const char *proto, const char *description) :
|
||||
DaemonCommand::DaemonCommand(const string& name, const string& proto, const string& description) :
|
||||
mName(name), mProto(proto), mDescription(description) {
|
||||
}
|
||||
|
||||
|
|
@ -313,8 +313,8 @@ const string DaemonCommand::getHelp() const {
|
|||
return ost.str();
|
||||
}
|
||||
|
||||
bool DaemonCommand::matches(const char *name) const {
|
||||
return strcmp(name, mName.c_str()) == 0;
|
||||
bool DaemonCommand::matches(const string& name) const {
|
||||
return mName.compare(name) == 0;
|
||||
}
|
||||
|
||||
Daemon::Daemon(const char *config_path, const char *factory_config_path, const char *log_file, const char *pipe_name, bool display_video, bool capture_video) :
|
||||
|
|
@ -475,14 +475,14 @@ void Daemon::initCommands() {
|
|||
mCommands.push_back(new AnswerCommand());
|
||||
mCommands.push_back(new CallStatusCommand());
|
||||
mCommands.push_back(new CallStatsCommand());
|
||||
mCommands.push_back(new CallPause());
|
||||
mCommands.push_back(new CallMute());
|
||||
mCommands.push_back(new CallResume());
|
||||
mCommands.push_back(new CallTransfer());
|
||||
mCommands.push_back(new CallPauseCommand());
|
||||
mCommands.push_back(new CallMuteCommand());
|
||||
mCommands.push_back(new CallResumeCommand());
|
||||
mCommands.push_back(new CallTransferCommand());
|
||||
mCommands.push_back(new Video());
|
||||
mCommands.push_back(new VideoSource());
|
||||
mCommands.push_back(new AutoVideo());
|
||||
mCommands.push_back(new Conference());
|
||||
mCommands.push_back(new ConferenceCommand());
|
||||
mCommands.push_back(new AudioCodecGetCommand());
|
||||
mCommands.push_back(new AudioCodecEnableCommand());
|
||||
mCommands.push_back(new AudioCodecDisableCommand());
|
||||
|
|
@ -591,10 +591,14 @@ void Daemon::iterate() {
|
|||
}
|
||||
}
|
||||
|
||||
void Daemon::execCommand(const char *cl) {
|
||||
char args[sLineSize] = { 0 };
|
||||
char name[sLineSize] = { 0 };
|
||||
sscanf(cl, "%511s %511[^\n]", name, args); //Read the rest of line in args
|
||||
void Daemon::execCommand(const string &command) {
|
||||
istringstream ist(command);
|
||||
string name;
|
||||
ist >> name;
|
||||
stringbuf argsbuf;
|
||||
ist.get(argsbuf);
|
||||
string args = argsbuf.str();
|
||||
if (!args.empty() && (args[0] == ' ')) args.erase(0, 1);
|
||||
list<DaemonCommand*>::iterator it = find_if(mCommands.begin(), mCommands.end(), bind2nd(mem_fun(&DaemonCommand::matches), name));
|
||||
if (it != mCommands.end()) {
|
||||
ms_mutex_lock(&mMutex);
|
||||
|
|
@ -606,27 +610,26 @@ void Daemon::execCommand(const char *cl) {
|
|||
}
|
||||
|
||||
void Daemon::sendResponse(const Response &resp) {
|
||||
char buf[4096] = { 0 };
|
||||
int size;
|
||||
size = resp.toBuf(buf, sizeof(buf));
|
||||
string buf = resp.toBuf();
|
||||
if (mChildFd != (ortp_pipe_t)-1) {
|
||||
if (ortp_pipe_write(mChildFd, (uint8_t *)buf, size) == -1) {
|
||||
if (ortp_pipe_write(mChildFd, (uint8_t *)buf.c_str(), buf.size()) == -1) {
|
||||
ms_error("Fail to write to pipe: %s", strerror(errno));
|
||||
}
|
||||
} else {
|
||||
fprintf(stdout, "%s", buf);
|
||||
fflush(stdout);
|
||||
cout << buf << flush;
|
||||
}
|
||||
}
|
||||
|
||||
char *Daemon::readPipe(char *buffer, int buflen) {
|
||||
string Daemon::readPipe() {
|
||||
char buffer[32768];
|
||||
memset(buffer, '\0', sizeof(buffer));
|
||||
#ifdef _WIN32
|
||||
if (mChildFd == (ortp_pipe_t)-1) {
|
||||
mChildFd = ortp_server_pipe_accept_client(mServerFd);
|
||||
ms_message("Client accepted");
|
||||
}
|
||||
if (mChildFd != (ortp_pipe_t)-1) {
|
||||
int ret = ortp_pipe_read(mChildFd, (uint8_t *)buffer, buflen);
|
||||
int ret = ortp_pipe_read(mChildFd, (uint8_t *)buffer, sizeof(buffer));
|
||||
if (ret == -1) {
|
||||
ms_error("Fail to read from pipe: %s", strerror(errno));
|
||||
mChildFd = (ortp_pipe_t)-1;
|
||||
|
|
@ -634,9 +637,9 @@ char *Daemon::readPipe(char *buffer, int buflen) {
|
|||
if (ret == 0) {
|
||||
ms_message("Client disconnected");
|
||||
mChildFd = (ortp_pipe_t)-1;
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
buffer[ret] = 0;
|
||||
buffer[ret] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
|
@ -671,7 +674,7 @@ char *Daemon::readPipe(char *buffer, int buflen) {
|
|||
}
|
||||
if (mChildFd != (ortp_pipe_t)-1 && (pfd[1].revents & POLLIN)) {
|
||||
int ret;
|
||||
if ((ret = ortp_pipe_read(mChildFd, (uint8_t *)buffer, buflen)) == -1) {
|
||||
if ((ret = ortp_pipe_read(mChildFd, (uint8_t *)buffer, sizeof(buffer))) == -1) {
|
||||
ms_error("Fail to read from pipe: %s", strerror(errno));
|
||||
} else {
|
||||
if (ret == 0) {
|
||||
|
|
@ -680,7 +683,7 @@ char *Daemon::readPipe(char *buffer, int buflen) {
|
|||
mChildFd = (ortp_pipe_t)-1;
|
||||
return NULL;
|
||||
}
|
||||
buffer[ret] = 0;
|
||||
buffer[ret] = '\0;
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
|
@ -763,74 +766,77 @@ void Daemon::dumpCommandsHelpHtml(){
|
|||
|
||||
|
||||
static void printHelp() {
|
||||
fprintf(stdout, "daemon-linphone [<options>]\n"
|
||||
cout << "daemon-linphone [<options>]" << endl <<
|
||||
#if defined(LICENCE_GPL) || defined(LICENCE_COMMERCIAL)
|
||||
"Licence: "
|
||||
"Licence: "
|
||||
#ifdef LICENCE_GPL
|
||||
"GPL"
|
||||
"GPL"
|
||||
#endif
|
||||
#ifdef LICENCE_COMMERCIAL
|
||||
"Commercial"
|
||||
"Commercial"
|
||||
#endif
|
||||
"\n"
|
||||
<< endl <<
|
||||
#endif
|
||||
|
||||
"where options are :\n"
|
||||
"\t--help\t\t\tPrint this notice.\n"
|
||||
"\t--dump-commands-help\tDump the help of every available commands.\n"
|
||||
"\t--dump-commands-html-help\tDump the help of every available commands.\n"
|
||||
"\t--pipe <pipename>\tCreate an unix server socket to receive commands.\n"
|
||||
"\t--log <path>\t\tSupply a file where the log will be saved.\n"
|
||||
"\t--factory-config <path>\tSupply a readonly linphonerc style config file to start with.\n"
|
||||
"\t--config <path>\t\tSupply a linphonerc style config file to start with.\n"
|
||||
"\t--disable-stats-events\t\tDo not automatically raise RTP statistics events.\n"
|
||||
"\t--enable-lsd\t\tUse the linphone sound daemon.\n"
|
||||
"\t-C\t\t\tenable video capture.\n"
|
||||
"\t-D\t\t\tenable video display.\n");
|
||||
"where options are :" << endl <<
|
||||
"\t--help Print this notice." << endl <<
|
||||
"\t--dump-commands-help Dump the help of every available commands." << endl <<
|
||||
"\t--dump-commands-html-help Dump the help of every available commands." << endl <<
|
||||
"\t--pipe <pipename> Create an unix server socket to receive commands." << endl <<
|
||||
"\t--log <path> Supply a file where the log will be saved." << endl <<
|
||||
"\t--factory-config <path> Supply a readonly linphonerc style config file to start with." << endl <<
|
||||
"\t--config <path> Supply a linphonerc style config file to start with." << endl <<
|
||||
"\t--disable-stats-events Do not automatically raise RTP statistics events." << endl <<
|
||||
"\t--enable-lsd Use the linphone sound daemon." << endl <<
|
||||
"\t-C Enable video capture." << endl <<
|
||||
"\t-D Enable video display." << endl;
|
||||
}
|
||||
|
||||
void Daemon::startThread() {
|
||||
ms_thread_create(&this->mThread, NULL, Daemon::iterateThread, this);
|
||||
}
|
||||
|
||||
char *Daemon::readLine(const char *prompt, bool *eof) {
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
string Daemon::readLine(const string& prompt, bool *eof) {
|
||||
*eof=false;
|
||||
#ifdef HAVE_READLINE
|
||||
return readline(prompt);
|
||||
return readline(prompt.c_str());
|
||||
#else
|
||||
if (cin.eof()) {
|
||||
*eof=true;
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
cout << prompt;
|
||||
char *buff = (char *) malloc(sLineSize);
|
||||
cin.getline(buff, sLineSize);
|
||||
return buff;
|
||||
stringbuf outbuf;
|
||||
cin.get(outbuf);
|
||||
cin.clear();
|
||||
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
return outbuf.str();
|
||||
#endif
|
||||
}
|
||||
|
||||
int Daemon::run() {
|
||||
char line[sLineSize] = "daemon-linphone>";
|
||||
char *ret;
|
||||
const string prompt("daemon-linphone>");
|
||||
mRunning = true;
|
||||
startThread();
|
||||
while (mRunning) {
|
||||
string line;
|
||||
bool eof=false;
|
||||
if (mServerFd == (ortp_pipe_t)-1) {
|
||||
ret = readLine(line,&eof);
|
||||
if (ret && ret[0] != '\0') {
|
||||
line = readLine(prompt, &eof);
|
||||
if (!line.empty()) {
|
||||
#ifdef HAVE_READLINE
|
||||
add_history(ret);
|
||||
add_history(line.c_str());
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
ret = readPipe(line, sLineSize);
|
||||
line = readPipe();
|
||||
}
|
||||
if (ret && ret[0] != '\0') {
|
||||
execCommand(ret);
|
||||
}
|
||||
if (mServerFd == (ortp_pipe_t)-1 && ret != NULL) {
|
||||
free(ret);
|
||||
if (!line.empty()) {
|
||||
execCommand(line);
|
||||
}
|
||||
if (eof && mRunning) {
|
||||
mRunning = false; // ctrl+d
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Daemon;
|
|||
|
||||
class DaemonCommandExample {
|
||||
public:
|
||||
DaemonCommandExample(const char *command, const char *output);
|
||||
DaemonCommandExample(const std::string& command, const std::string& output);
|
||||
~DaemonCommandExample() {}
|
||||
const std::string &getCommand() const {
|
||||
return mCommand;
|
||||
|
|
@ -74,8 +74,8 @@ private:
|
|||
class DaemonCommand {
|
||||
public:
|
||||
virtual ~DaemonCommand() {}
|
||||
virtual void exec(Daemon *app, const char *args)=0;
|
||||
bool matches(const char *name) const;
|
||||
virtual void exec(Daemon *app, const std::string& args)=0;
|
||||
bool matches(const std::string& name) const;
|
||||
const std::string getHelp() const;
|
||||
const std::string &getProto() const {
|
||||
return mProto;
|
||||
|
|
@ -88,7 +88,7 @@ public:
|
|||
}
|
||||
void addExample(const DaemonCommandExample *example);
|
||||
protected:
|
||||
DaemonCommand(const char *name, const char *proto, const char *description);
|
||||
DaemonCommand(const std::string& name, const std::string& proto, const std::string& description);
|
||||
const std::string mName;
|
||||
const std::string mProto;
|
||||
const std::string mDescription;
|
||||
|
|
@ -105,14 +105,6 @@ public:
|
|||
Response() :
|
||||
mStatus(Ok) {
|
||||
}
|
||||
Response(const char *msg, Status status = Error) :
|
||||
mStatus(status) {
|
||||
if (status == Ok) {
|
||||
mBody = msg;
|
||||
} else {
|
||||
mReason = msg;
|
||||
}
|
||||
}
|
||||
Response(const std::string& msg, Status status = Error):
|
||||
mStatus(status) {
|
||||
if( status == Ok) {
|
||||
|
|
@ -125,25 +117,26 @@ public:
|
|||
void setStatus(Status st) {
|
||||
mStatus = st;
|
||||
}
|
||||
void setReason(const char *reason) {
|
||||
void setReason(const std::string& reason) {
|
||||
mReason = reason;
|
||||
}
|
||||
void setBody(const char *body) {
|
||||
void setBody(const std::string& body) {
|
||||
mBody = body;
|
||||
}
|
||||
const std::string &getBody() const {
|
||||
return mBody;
|
||||
}
|
||||
virtual int toBuf(char *dst, int dstlen) const {
|
||||
int i = 0;
|
||||
i += snprintf(dst + i, dstlen - i, "Status: %s\n", mStatus == Ok ? "Ok" : "Error");
|
||||
if (mReason.size() > 0) {
|
||||
i += snprintf(dst + i, dstlen - i, "Reason: %s\n", mReason.c_str());
|
||||
virtual std::string toBuf() const {
|
||||
std::ostringstream buf;
|
||||
std::string status = (mStatus == Ok) ? "Ok" : "Error";
|
||||
buf << "Status: " << status << "\n";
|
||||
if (!mReason.empty()) {
|
||||
buf << "Reason: " << mReason << "\n";
|
||||
}
|
||||
if (mBody.size() > 0) {
|
||||
i += snprintf(dst + i, dstlen - i, "\n%s\n", mBody.c_str());
|
||||
if (!mBody.empty()) {
|
||||
buf << "\n" << mBody << "\n";
|
||||
}
|
||||
return i;
|
||||
return buf.str();
|
||||
}
|
||||
private:
|
||||
Status mStatus;
|
||||
|
|
@ -250,16 +243,15 @@ private:
|
|||
void callStateChanged(LinphoneCall *call, LinphoneCallState state, const char *msg);
|
||||
void callStatsUpdated(LinphoneCall *call, const LinphoneCallStats *stats);
|
||||
void dtmfReceived(LinphoneCall *call, int dtmf);
|
||||
void execCommand(const char *cl);
|
||||
char *readLine(const char *, bool*);
|
||||
char *readPipe(char *buffer, int buflen);
|
||||
void execCommand(const std::string &command);
|
||||
std::string readLine(const std::string&, bool*);
|
||||
std::string readPipe();
|
||||
void iterate();
|
||||
void iterateStreamStats();
|
||||
void startThread();
|
||||
void stopThread();
|
||||
void initCommands();
|
||||
void uninitCommands();
|
||||
void iterateStreamStats(LinphoneCore *lc);
|
||||
LinphoneCore *mLc;
|
||||
LinphoneSoundDaemon *mLSD;
|
||||
std::list<DaemonCommand*> mCommands;
|
||||
|
|
@ -276,7 +268,6 @@ private:
|
|||
int mAudioStreamIds;
|
||||
ms_thread_t mThread;
|
||||
ms_mutex_t mMutex;
|
||||
static const int sLineSize = 512;
|
||||
std::map<int, AudioStreamAndOther*> mAudioStreams;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue