This functionality used to be in sipXtapi but was lost during a merge a long 
time ago.
Here is a patch for svn trunk 8978 to put it back in.

   ...Carsten
Index: sipx/sipXcallLib/include/tapi/SipXtapiEventDispatcher.h
===================================================================
--- sipx/sipXcallLib/include/tapi/SipXtapiEventDispatcher.h     (revision 8978)
+++ sipx/sipXcallLib/include/tapi/SipXtapiEventDispatcher.h     (working copy)
@@ -59,7 +59,7 @@
 
     UtlBoolean handleMessage(OsMsg& message);
 
-    void dtmfToSipXtapiMinorEvent(int dtmfButton, SIPX_CALLSTATE_MINOR& 
sipxTapiMinorEvent);
+    void dtmfToSipXtapiEventCause(int dtmfButton, SIPX_CALLSTATE_CAUSE& 
sipxTapiMinorEvent);
 
 /* ========================== A C C E S S O R S =========================== */
 
Index: sipx/sipXcallLib/include/tapi/sipXtapiInternal.h
===================================================================
--- sipx/sipXcallLib/include/tapi/sipXtapiInternal.h    (revision 8978)
+++ sipx/sipXcallLib/include/tapi/sipXtapiInternal.h    (working copy)
@@ -48,7 +48,9 @@
 // FORWARD DECLARATIONS
 class SipSubscribeServer;
 class SipSubscribeClient;
+class SipXtapiEventDispatcher;
 
+
 // STRUCTS
 
 // TYPEDEFS
@@ -121,6 +123,7 @@
     SipRefreshMgr*   pRefreshManager ;
     SipSubscribeServer* pSubscribeServer;
     SipSubscribeClient* pSubscribeClient;
+    SipXtapiEventDispatcher* mpEventDispatcher;
 
     MIC_SETTING      micSetting ;
     SPEAKER_SETTING  speakerSettings[2] ;
Index: sipx/sipXcallLib/include/tapi/sipXtapi.h
===================================================================
--- sipx/sipXcallLib/include/tapi/sipXtapi.h    (revision 8978)
+++ sipx/sipXcallLib/include/tapi/sipXtapi.h    (working copy)
@@ -965,6 +965,18 @@
 
 
 /**
+ * Enable the detection of DTMF events (RFC 2933 only).  Events
+ * are notified through the callback/observer registered with
+ * sipxListenerAdd.
+ *
+ * @param hCall Handle to a call.  Call handles are obtained either by
+ *        invoking sipxCallCreate or passed to your application through
+ *        a listener interface.
+*/
+SIPXTAPI_API SIPX_RESULT sipxCallReceiveTones(const SIPX_CALL hCall);
+
+
+/**
  * Set a media property on the media interface or connection associated with 
the
  * given call.  The property names may be media subsystem specific.  This may
  * be used to set stream specific properties assocated with a call.
Index: sipx/sipXcallLib/include/tapi/sipXtapiEvents.h
===================================================================
--- sipx/sipXcallLib/include/tapi/sipXtapiEvents.h      (revision 8978)
+++ sipx/sipXcallLib/include/tapi/sipXtapiEvents.h      (working copy)
@@ -172,8 +172,15 @@
     CALLSTATE_SECURITY_EVENT   = 11000, /** The SECURITY_EVENT is sent to the 
application 
                                            when S/MIME or SRTP events occur 
which the application
                                            should know about. */ 
-    CALLSTATE_IDENTITY_CHANGE  = 12000 /** The identity of the remote party on 
this call has changed
+    CALLSTATE_IDENTITY_CHANGE  = 12000, /** The identity of the remote party 
on this call has changed
                                            to the identity given  in 
szRemoteIdentity. */
+
+    CALLSTATE_DTMF_DOWN        = 14000,  /**< A DTMF button down event has 
been received from the
+                                 remote party of the indicated call.  The 
minor event 
+                                 indicates which button has been pressed. */
+    CALLSTATE_DTMF_UP          = 14500,  /**< A DTMF button up event has been 
received from the
+                                 remote party of the indicated call.  The 
minor event 
+                                 indicates which button has been released. */
 } SIPX_CALLSTATE_EVENT;
 
  
@@ -258,6 +265,24 @@
                                                                              
The identity may have changed because of a transfer or
                                                                              
some other reason, but the signalling did not give any
                                                                              
indication as to why it changed. */
+
+    CALLSTATE_DTMF_0                      = CALLSTATE_DTMF_DOWN + '0',  /**< 0 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_1                      = CALLSTATE_DTMF_DOWN + '1',  /**< 1 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_2                      = CALLSTATE_DTMF_DOWN + '2',  /**< 2 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_3                      = CALLSTATE_DTMF_DOWN + '3',  /**< 3 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_4                      = CALLSTATE_DTMF_DOWN + '4',  /**< 4 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_5                      = CALLSTATE_DTMF_DOWN + '5',  /**< 5 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_6                      = CALLSTATE_DTMF_DOWN + '6',  /**< 6 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_7                      = CALLSTATE_DTMF_DOWN + '7',  /**< 7 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_8                      = CALLSTATE_DTMF_DOWN + '8',  /**< 8 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_9                      = CALLSTATE_DTMF_DOWN + '9',  /**< 9 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_STAR                   = CALLSTATE_DTMF_DOWN + '*',  /**< * 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_POUND                  = CALLSTATE_DTMF_DOWN + '#',  /**< # 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_A                      = CALLSTATE_DTMF_DOWN + 'A',  /**< A 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_B                      = CALLSTATE_DTMF_DOWN + 'B',  /**< B 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_C                      = CALLSTATE_DTMF_DOWN + 'C',  /**< C 
key in DTMF_DOWN or DTMF_UP event */
+    CALLSTATE_DTMF_D                      = CALLSTATE_DTMF_DOWN + 'D',  /**< D 
key in DTMF_DOWN or DTMF_UP event */
+
     CALLSTATE_CAUSE_UNKNOWN,                                            /* 
used in applicaiton when not event based */
 
 } SIPX_CALLSTATE_CAUSE ;
Index: sipx/sipXcallLib/src/Makefile.am
===================================================================
--- sipx/sipXcallLib/src/Makefile.am    (revision 8978)
+++ sipx/sipXcallLib/src/Makefile.am    (working copy)
@@ -151,7 +151,8 @@
     tapi/sipXtapiEvents.cpp \
     tapi/sipXtapiInternal.cpp \
     tapi/SipXHandleMap.cpp \
-    tapi/SipXMessageObserver.cpp
+    tapi/SipXMessageObserver.cpp \
+    tapi/SipXtapiEventDispatcher.cpp
 
 noinst_HEADERS = \
     cp/ConfirmationTone.h \
Index: sipx/sipXcallLib/src/tapi/sipXtapi.cpp
===================================================================
--- sipx/sipXcallLib/src/tapi/sipXtapi.cpp      (revision 8978)
+++ sipx/sipXcallLib/src/tapi/sipXtapi.cpp      (working copy)
@@ -33,6 +33,7 @@
 #include "tapi/sipXtapiInternal.h"
 #include "tapi/SipXHandleMap.h"
 #include "tapi/SipXMessageObserver.h"
+#include "tapi/SipXtapiEventDispatcher.h"
 //#include "rtcp/RTCManager.h"
 #include "net/SipUserAgent.h"
 #include "net/SdpCodecFactory.h"
@@ -450,6 +451,10 @@
         pInst->pCallManager->setOutboundLine(localAddress) ;
         pInst->pCallManager->start();
 
+        // Initialize the event dispatcher
+        pInst->mpEventDispatcher = new SipXtapiEventDispatcher(*pInst);
+        pInst->mpEventDispatcher->start();
+
         CpMediaInterfaceFactoryImpl* pInterface = 
                 
pInst->pCallManager->getMediaInterfaceFactory()->getFactoryImplementation() ;
 
@@ -525,6 +530,7 @@
             pInst->pCallManager->requestShutdown();
             pInst->pRefreshManager->requestShutdown(); 
             pInst->pSipUserAgent->requestShutdown();
+            pInst->mpEventDispatcher->requestShutdown();
             pInst->pSubscribeClient->requestShutdown();
             pInst->pSubscribeServer->requestShutdown();
             pInst->pMessageObserver->requestShutdown();
@@ -534,10 +540,12 @@
             delete pInst->pSubscribeServer ;
             delete pInst->pCallManager;
             delete pInst->pLineManager;
+               delete pInst->mpEventDispatcher;                
             delete pInst->pCodecFactory;
             delete pInst->pRefreshManager ;
 
             pInst->pCallManager = NULL;
+                       pInst->mpEventDispatcher = NULL;
 
             int codecIndex;
             // Did we previously allocate an audio codecs array and store it 
in our codec settings?
@@ -1503,7 +1511,26 @@
     return sr ;
 }
 
+// [ADOMO:cavenhaus]
+SIPXTAPI_API SIPX_RESULT sipxCallReceiveTones(const SIPX_CALL callHandle)
+{
+    OsSysLog::add(FAC_SIPXTAPI, PRI_NOTICE, "sipxCallReceiveTones");
 
+    SIPX_RESULT result = SIPX_RESULT_FAILURE;
+    SIPX_INSTANCE_DATA *instanceHandle;
+    UtlString callId;
+
+    if (sipxCallGetCommonData(callHandle, &instanceHandle, &callId, NULL, 
NULL))
+    {
+        instanceHandle->pCallManager->addToneListener(callId,
+                              (int) instanceHandle->mpEventDispatcher);
+        result = SIPX_RESULT_SUCCESS;
+    }
+
+    return(result);
+}
+
+
 SIPXTAPI_API SIPX_RESULT sipxCallPlayFile(const SIPX_CALL hCall,
                                           const char* szFile,
                                           const bool bLocal,
Index: sipx/sipXcallLib/src/tapi/SipXtapiEventDispatcher.cpp
===================================================================
--- sipx/sipXcallLib/src/tapi/SipXtapiEventDispatcher.cpp       (revision 0)
+++ sipx/sipXcallLib/src/tapi/SipXtapiEventDispatcher.cpp       (revision 0)
@@ -0,0 +1,186 @@
+// 
+// 
+//
+// Copyright (C) 2005 SIPfoundry Inc.
+// Licensed by SIPfoundry under the LGPL license.
+//
+// Copyright (C) 2005 SIPez LLC.
+// Licensed to SIPfoundry under a Contributor Agreement.
+// 
+// Author: Daniel Petrie
+//         dpetrie AT SIPez DOT com
+//////////////////////////////////////////////////////////////////////////////
+
+// SYSTEM INCLUDES
+// APPLICATION INCLUDES
+#include <tapi/sipXtapi.h>
+#include <tapi/sipXtapiEvents.h>
+#include <tapi/sipXtapiInternal.h>
+#include <tapi/SipXtapiEventDispatcher.h>
+#include <tao/TaoMessage.h>
+#include <tao/TaoString.h>
+
+// EXTERNAL FUNCTIONS
+// EXTERNAL VARIABLES
+// CONSTANTS
+// STATIC VARIABLE INITIALIZATIONS
+
+//__________________________________________________________________________//
+/* ============================= P U B L I C ============================== */
+
+/* ============================ C R E A T O R S =========================== */
+
+// Constructor
+SipXtapiEventDispatcher::SipXtapiEventDispatcher(SIPX_INSTANCE_DATA& instance)
+{
+    mpInstance = &instance;
+}
+
+// Copy constructor
+SipXtapiEventDispatcher::SipXtapiEventDispatcher(const 
SipXtapiEventDispatcher& rSipXtapiEventDispatcher)
+{
+}
+
+// Destructor
+SipXtapiEventDispatcher::~SipXtapiEventDispatcher()
+{
+}
+
+/* ======================== M A N I P U L A T O R S ======================= */
+
+// Assignment operator
+SipXtapiEventDispatcher& SipXtapiEventDispatcher::operator=(const 
SipXtapiEventDispatcher& rhs)
+{
+    if (this == &rhs)            // handle the assignment to self case
+    {
+        // Do nothing
+    }
+
+    else
+    {
+    }
+
+   return *this;
+}
+
+UtlBoolean SipXtapiEventDispatcher::handleMessage(OsMsg& message)
+{
+    int messageType = message.getMsgType(); 
+    int messageSubType = message.getMsgSubType(); 
+
+    if (messageType == OsMsg::TAO_MSG)
+    {
+        if(messageSubType == TaoMessage::EVENT)
+        {
+            TaoMessage* taoMessage = (TaoMessage*) (&message) ; 
+
+            TaoString args = TaoString(taoMessage->getArgList(), 
TAOMESSAGE_DELIMITER); 
+            UtlString callId = args[0];
+            UtlString toneInfo = args[1];
+            UtlString connectionId = args[2];
+
+            unsigned int toneInfoBits = atoi(toneInfo.data());
+
+            int dtmfButton = (toneInfoBits >> 16);
+            int pressDuration = (toneInfoBits & 0xFFFF);
+            int buttonUp = (toneInfoBits & 0x80000000);
+
+            if(buttonUp)
+            {
+                dtmfButton = dtmfButton & 0x0003FFF;
+            }
+  
+            // Fire the appropriate sipXtapi event
+            SIPX_CALLSTATE_CAUSE sipXtapiDtmfMinorEvent;
+            dtmfToSipXtapiEventCause(dtmfButton, sipXtapiDtmfMinorEvent);
+            osPrintf("SipXtapiEventDispatcher::handleMessage DTMF %s for key: 
%d sipXtapi minor event: %d on call: %s\n",
+                buttonUp ? "up" : "down",
+                dtmfButton,
+                sipXtapiDtmfMinorEvent,
+                callId.data());
+
+            sipxFireCallEvent(mpInstance->pCallManager,
+                          callId.data(),
+                          NULL, //SipSession*
+                          NULL,
+                          (SIPX_CALLSTATE_MAJOR)(buttonUp ? CALLSTATE_DTMF_UP 
: CALLSTATE_DTMF_DOWN),
+                          (SIPX_CALLSTATE_MINOR)sipXtapiDtmfMinorEvent);
+
+
+        }
+    }
+
+
+    return(TRUE);
+}
+
+void SipXtapiEventDispatcher::dtmfToSipXtapiEventCause(int dtmfButton, 
+                                                       SIPX_CALLSTATE_CAUSE& 
sipxTapiMinorEvent)
+{
+    switch(dtmfButton)
+    {
+    case 0:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_0;
+        break;
+    case 1:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_1;
+        break;
+    case 2:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_2;
+        break;
+    case 3:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_3;
+        break;
+    case 4:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_4;
+        break;
+    case 5:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_5;
+        break;
+    case 6:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_6;
+        break;
+    case 7:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_7;
+        break;
+    case 8:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_8;
+        break;
+    case 9:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_9;
+        break;
+    case 10:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_STAR;
+        break;
+    case 11:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_POUND;
+        break;
+    case 12:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_A;
+        break;
+    case 13:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_B;
+        break;
+    case 14:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_C;
+        break;
+    case 15:
+        sipxTapiMinorEvent = CALLSTATE_DTMF_D;
+        break;
+    }
+}
+
+
+/* ========================== A C C E S S O R S =========================== */
+
+/* ============================ I N Q U I R Y ============================= */
+
+//__________________________________________________________________________//
+/* ========================== P R O T E C T E D =========================== */
+
+//__________________________________________________________________________//
+/* ============================ P R I V A T E ============================= */
+
+/* ========================== F U N C T I O N S =========================== */
+
+//__________________________________________________________________________//
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to