Commit 6385f6d4 authored by Guillaume BIENKOWSKI's avatar Guillaume BIENKOWSKI

Added new commands to the linphone daemon executable.

parent ea935eb8
......@@ -15,6 +15,12 @@ linphone_daemon_SOURCES=daemon.cc \
commands/call.cc \
commands/call-stats.cc \
commands/call-status.cc \
commands/call-pause.cc \
commands/call-resume.cc \
commands/call-mute.cc \
commands/call-camera.cc \
commands/call-transfer.cc \
commands/conference.cc \
commands/dtmf.cc \
commands/firewall-policy.cc \
commands/help.cc \
......@@ -46,6 +52,12 @@ linphone_daemon_SOURCES=daemon.cc \
commands/call.h \
commands/call-stats.h \
commands/call-status.h \
commands/call-pause.h \
commands/call-resume.h \
commands/call-mute.h \
commands/call-camera.h \
commands/call-transfer.h \
commands/conference.h \
commands/dtmf.h \
commands/firewall-policy.h \
commands/help.h \
......
#include "call-mute.h"
CallMute::CallMute()
{
}
#ifndef CALLMUTE_H
#define CALLMUTE_H
class CallMute : public DaemonCommand
{
public:
CallMute();
};
#endif // CALLMUTE_H
#include "call-pause.h"
CallPause::CallPause()
{
}
void CallPause::exec(Daemon* app, const char* 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 {
call = linphone_core_get_current_call(lc);
if (call == NULL) {
app->sendResponse(Response("No current call available."));
return;
}
}
if( linphone_core_pause_call(lc, call) == 0 ) {
app->sendResponse(Response("Call was paused", Response::Ok));
} else {
app->sendResponse(Response("Error pausing call"));
}
}
#ifndef CALLPAUSE_H
#define CALLPAUSE_H
#include "daemon.h"
class CallPause : public DaemonCommand
{
public:
CallPause();
virtual void exec(Daemon *app, const char *args);
};
#endif // CALLPAUSE_H
#include "call-resume.h"
CallResume::CallResume()
{
}
#ifndef CALLRESUME_H
#define CALLRESUME_H
class CallResume : public DaemonCommand
{
public:
CallResume();
};
#endif // CALLRESUME_H
#include "call-transfer.h"
CallTransfer::CallTransfer()
{
}
#ifndef CALLTRANSFER_H
#define CALLTRANSFER_H
class CallTransfer : public DaemonCommand
{
public:
CallTransfer();
};
#endif // CALLTRANSFER_H
#include "conference.h"
Conference::Conference()
{
}
#ifndef CONFERENCE_H
#define CONFERENCE_H
class Conference : public DaemonCommand
{
public:
Conference();
};
#endif // CONFERENCE_H
#include "call-camera.h"
CallCamera::CallCamera()
{
}
#ifndef CALLCAMERA_H
#define CALLCAMERA_H
class CallCamera : public DaemonCommand
{
public:
CallCamera();
};
#endif // CALLCAMERA_H
......@@ -26,6 +26,12 @@
#include "commands/call.h"
#include "commands/call-stats.h"
#include "commands/call-status.h"
#include "commands/call-pause.h"
#include "commands/call-mute.h"
#include "commands/call-resume.h"
#include "commands/call-camera.h"
#include "commands/call-transfer.h"
#include "commands/conference.h"
#include "commands/contact.h"
#include "commands/dtmf.h"
#include "commands/firewall-policy.h"
......@@ -186,7 +192,7 @@ CallStatsResponse::CallStatsResponse(Daemon *daemon, LinphoneCall *call, const L
AudioStreamStatsResponse::AudioStreamStatsResponse(Daemon* daemon, AudioStream* stream,
const LinphoneCallStats *stats, bool event) {
const char *prefix = "";
ostringstream ostr;
if (event) {
ostr << "Event-type: audio-stream-stats\n";
......@@ -201,9 +207,9 @@ AudioStreamStatsResponse::AudioStreamStatsResponse(Daemon* daemon, AudioStream*
} else {
prefix = ((stats->type == LINPHONE_CALL_STATS_AUDIO) ? "Audio-" : "Video-");
}
printCallStatsHelper(ostr, stats, prefix);
setBody(ostr.str().c_str());
}
......@@ -413,6 +419,12 @@ 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 CallCamera());
mCommands.push_back(new Conference());
mCommands.push_back(new AudioCodecGetCommand());
mCommands.push_back(new AudioCodecEnableCommand());
mCommands.push_back(new AudioCodecDisableCommand());
......@@ -459,8 +471,9 @@ bool Daemon::pullEvent() {
void Daemon::callStateChanged(LinphoneCall *call, LinphoneCallState state, const char *msg) {
switch (state) {
case LinphoneCallOutgoingProgress:
case LinphoneCallIncomingReceived:
linphone_call_enable_camera (call,mAutoVideo);
case LinphoneCallOutgoingProgress:
case LinphoneCallIncomingEarlyMedia:
case LinphoneCallConnected:
case LinphoneCallStreamsRunning:
......
......@@ -93,6 +93,15 @@ public:
mReason = msg;
}
}
Response(const std::string& msg, Status status = Error):
mStatus(status) {
if( status == Ok) {
mBody = msg;
} else {
mReason = msg;
}
}
void setStatus(Status st) {
mStatus = st;
}
......@@ -151,9 +160,9 @@ public:
class PayloadTypeParser {
public:
PayloadTypeParser(LinphoneCore *core, const std::string &mime_type, bool accept_all = false);
inline bool all() { return mAll; };
inline bool successful() { return mSuccesful; };
inline int payloadTypeNumber() { return mPayloadTypeNumber; };
inline bool all() { return mAll; }
inline bool successful() { return mSuccesful; }
inline int payloadTypeNumber() { return mPayloadTypeNumber; }
private:
bool mAll;
bool mSuccesful;
......@@ -195,12 +204,16 @@ public:
bool pullEvent();
int updateCallId(LinphoneCall *call);
int updateProxyId(LinphoneProxyConfig *proxy);
inline int maxProxyId() { return mProxyIds; };
inline int maxProxyId() { return mProxyIds; }
int updateAudioStreamId(AudioStream *audio_stream);
void dumpCommandsHelp();
void dumpCommandsHelpHtml();
void enableStatsEvents(bool enabled);
void enableLSD(bool enabled);
void setAutoVideo( bool enabled ){ mAutoVideo = enabled; }
inline bool autoVideo(){ return mAutoVideo; }
private:
static void* iterateThread(void *arg);
static void callStateChanged(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, const char *msg);
......@@ -229,6 +242,7 @@ private:
bool mRunning;
bool mUseStatsEvents;
FILE *mLogFile;
bool mAutoVideo;
int mCallIds;
int mProxyIds;
int mAudioStreamIds;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment