diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 1e1e6342efb9b9109faaea01e9078f87405661fa..c6ceef9b0bd192358ab481cf88dd549b4d1c84bf 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 7d435099f6379dac8f05aec1a4de5cf1b23bd6ac..cbe4ae6c364cb8770c46ccdfa6d05863ae8c0121 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;