Add dtfm message

This commit is contained in:
Yann Diorcet 2012-05-09 15:26:37 +02:00
parent 7d83d04d6f
commit 908b70f585
2 changed files with 28 additions and 1 deletions

View file

@ -40,6 +40,16 @@ EventResponse::EventResponse(LinphoneCall *call, LinphoneCallState state) {
ms_free(remote);
}
DtmfResponse::DtmfResponse(LinphoneCall *call, int dtmf) {
ostringstream ostr;
char *remote = linphone_call_get_remote_address_as_string(call);
ostr << "Event-type: receiving-tone\nTone: " << (char) dtmf << "\n";
ostr << "From: " << remote << "\n";
ostr << "Id: " << Daemon::getCallId(call) << "\n";
setBody(ostr.str().c_str());
ms_free(remote);
}
PayloadTypeResponse::PayloadTypeResponse(LinphoneCore *core, const PayloadType *payloadType, int index, const string &prefix, bool enabled_status) {
ostringstream ostr;
if (payloadType != NULL) {
@ -93,6 +103,7 @@ Daemon::Daemon(const char *config_path, const char *factory_config_path, const c
LinphoneCoreVTable vtable = { 0 };
vtable.call_state_changed = callStateChanged;
vtable.dtmf_received = dtmfReceived;
mLc = linphone_core_new(&vtable, config_path, factory_config_path, this);
linphone_core_enable_video(mLc, display_video, capture_video);
linphone_core_enable_echo_cancellation(mLc, false);
@ -219,10 +230,18 @@ void Daemon::callStateChanged(LinphoneCall *call, LinphoneCallState state, const
}
}
void Daemon::dtmfReceived(LinphoneCall *call, int dtmf) {
mEventQueue.push(new DtmfResponse(call, dtmf));
}
void Daemon::callStateChanged(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, const char *msg) {
Daemon *app = (Daemon*) linphone_core_get_user_data(lc);
app->callStateChanged(call, state, msg);
}
void Daemon::dtmfReceived(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
Daemon *app = (Daemon*) linphone_core_get_user_data(lc);
app->dtmfReceived(call, dtmf);
}
void Daemon::iterate() {
linphone_core_iterate(mLc);

View file

@ -84,6 +84,12 @@ public:
private:
};
class DtmfResponse: public Response {
public:
DtmfResponse(LinphoneCall *call, int dtmf);
private:
};
class PayloadTypeResponse: public Response {
public:
PayloadTypeResponse(LinphoneCore *core, const PayloadType *payloadType, int index = -1, const std::string &prefix = std::string(), bool enabled_status = true);
@ -113,8 +119,10 @@ public:
private:
static void callStateChanged(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, const char *msg);
static void dtmfReceived(LinphoneCore *lc, LinphoneCall *call, int dtmf);
static int readlineHook();
void callStateChanged(LinphoneCall *call, LinphoneCallState state, const char *msg);
void dtmfReceived(LinphoneCall *call, int dtmf);
void execCommand(const char *cl);
void initReadline();
char *readPipe(char *buffer, int buflen);
@ -123,7 +131,7 @@ private:
void uninitCommands();
LinphoneCore *mLc;
std::list<DaemonCommand*> mCommands;
std::queue<EventResponse*> mEventQueue;
std::queue<Response*> mEventQueue;
int mServerFd;
int mChildFd;
std::string mHistfile;