From 908b70f5854674e78fa2166b005a646c689d803d Mon Sep 17 00:00:00 2001 From: Yann Diorcet <yann.diorcet@belledonne-communications.com> Date: Wed, 9 May 2012 15:26:37 +0200 Subject: [PATCH] Add dtfm message --- daemon/daemon.cc | 19 +++++++++++++++++++ daemon/daemon.h | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 1e1e6342ef..c6ceef9b0b 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -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); diff --git a/daemon/daemon.h b/daemon/daemon.h index 7d435099f6..cbe4ae6c36 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -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; -- GitLab