[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "telephone-events" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Jul 11 10:53:22 CDT 2011


branch "telephone-events" has been updated
       via  b6c7ea6815ff93f17fd2355ef5f003712e0242fe (commit)
       via  de27bed2a112156fcd9d5af46ecb60bddc136554 (commit)
      from  6fed3a431208755055ab5a0cb697e8777e5a221c (commit)

Summary of changes:
 src/SipSession.cpp |   95 ++++++++++++++++++++++++++++++++++++++++++++-------
 src/SipSession.h   |   21 +++++++++++-
 2 files changed, 102 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit b6c7ea6815ff93f17fd2355ef5f003712e0242fe
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Jul 11 10:53:13 2011 -0500

    Assuming that telephony events slice is approved, this is a good starting point: stubs for methods.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index e5ccca6..35864d6 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -255,6 +255,33 @@ public:
     SessionWorkPtr mSessionWork;
 };
 
+void SipTelephonyEventsSink::write(const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr&, const Ice::Current&)
+{
+    //Stub
+}
+
+void SipTelephonyEventsSink::setSource(const AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourcePrx& source, const Ice::Current&)
+{
+    //Stub
+}
+
+AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourcePrx SipTelephonyEventsSink::getSource(const Ice::Current&)
+{
+    //Stub
+    return 0;
+}
+
+void SipTelephonyEventsSource::addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkPrx& sink, const Ice::Current&)
+{
+    //stub
+}
+
+AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq SipTelephonyEventsSource::getSinks(const Ice::Current&)
+{
+    //stub
+    return AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq();
+}
+
 void SipSession::initializePJSIPStructs()
 {
     pj_str_t local_uri, remote_uri;
@@ -1088,6 +1115,18 @@ AsteriskSCF::SessionCommunications::V1::SessionCookieDict SipSession::getAllCook
     return mImplPriv->mSessionCookies;
 }
 
+AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourceSeq SipSession::getSources(const Ice::Current&)
+{
+    //Stub
+    return AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourceSeq();
+}
+
+AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq SipSession::getSinks(const Ice::Current&)
+{
+    //Stub
+    return AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq();
+}
+
 /**
  * Internal function called to destroy an endpoint. This is controlled by signaling.
  */
diff --git a/src/SipSession.h b/src/SipSession.h
index f670454..1e00a28 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -88,10 +88,23 @@ private:
 
 typedef IceUtil::Handle<SessionWork> SessionWorkPtr;
 
+class SipTelephonyEventsSink : public AsteriskSCF::SessionCommunications::V1::TelephonyEventsSink
+{
+    void write(const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr&, const Ice::Current&);
+    void setSource(const AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourcePrx& source, const Ice::Current&);
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourcePrx getSource(const Ice::Current&);
+};
+
+class SipTelephonyEventsSource : public AsteriskSCF::SessionCommunications::V1::TelephonyEventsSource
+{
+    void addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkPrx& sink, const Ice::Current&);
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq getSinks(const Ice::Current&);
+};
+
 /*
  * Implementation of the Session interface as defined in SessionCommunicationsIf.ice
  */
-class SipSession : public AsteriskSCF::SessionCommunications::V1::Session
+class SipSession : public AsteriskSCF::SessionCommunications::V1::TelephonySession
 {
 public:
     SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&,
@@ -170,6 +183,12 @@ public:
     AsteriskSCF::SessionCommunications::V1::SessionCookieDict getAllCookies();
 
     /**
+     * TelephonySession overrides
+     */
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventsSourceSeq getSources(const Ice::Current&);
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventsSinkSeq getSinks(const Ice::Current&);
+
+    /**
      * Implementation specific functions.
      */
     void destroy();

commit de27bed2a112156fcd9d5af46ecb60bddc136554
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Jul 8 09:31:42 2011 -0500

    Send Flash via INFO if configured for it.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 145a5d7..e5ccca6 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -443,6 +443,11 @@ public:
         else if ((Flash = AsteriskSCF::SessionCommunications::V1::FlashIndicationPtr::dynamicCast(mIndication)))
         {
             lg(Debug) << "Processing a Flash indication";
+            SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
+            if (config.sessionConfig.dtmf == AsteriskSCF::Configuration::SipSessionManager::V1::INFO)
+            {
+                sendFlashINFO();
+            }
             // This is usually transported using INFO or RFC2833, so for now just pretend it does not exist
         }
         else if ((Hold = AsteriskSCF::SessionCommunications::V1::HoldIndicationPtr::dynamicCast(mIndication)))
@@ -479,7 +484,7 @@ public:
             SipEndpointConfig &config = mImplPriv->mEndpoint->getConfig();
             if (config.sessionConfig.dtmf == AsteriskSCF::Configuration::SipSessionManager::V1::INFO)
             {
-                sendDTMFInfo(endDTMF);
+                sendDTMFINFO(endDTMF);
             }
             else
             {
@@ -503,44 +508,69 @@ public:
 
 private:
 
-    void sendDTMFInfo(const AsteriskSCF::SessionCommunications::V1::EndDTMFPtr& endDTMF)
+    pjsip_tx_data *createINFORequest()
     {
         pjsip_method infoMethod;
         pj_str_t infoStr;
         pj_cstr(&infoStr, "INFO");
         pjsip_method_init_np(&infoMethod, &infoStr);
 
-        pjsip_tx_data *tdata;
         pj_status_t status;
+        pjsip_tx_data *tdata;
         status = pjsip_dlg_create_request(mImplPriv->mInviteSession->dlg, &infoMethod, -1, &tdata);
         
         if (status != PJ_SUCCESS)
         {
-            return; //yo!
+            throw AsteriskSCF::SessionCommunications::V1::IndicationException();
         }
 
-        pj_str_t infoPackage;
-        pj_cstr(&infoPackage, "Info-Package");
-        pj_str_t infoPackageVal;
-        pj_cstr(&infoPackageVal, "dtmf");
-        pjsip_generic_string_hdr *infoPackageHdr = pjsip_generic_string_hdr_create(tdata->pool, &infoPackage, &infoPackageVal);
-
-        pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) infoPackageHdr);
+        return tdata;
+    }
 
+    void fillINFOBody(pjsip_tx_data *tdata, char signal, int duration)
+    {
         pj_str_t type;
         pj_cstr(&type, "application");
         pj_str_t subtype;
         pj_cstr(&subtype, "dtmf-relay");
         std::stringstream bodyText;
-        bodyText << "Signal= " << endDTMF->digit 
-            << "\r\nDuration= " << endDTMF->duration << "\r\n\r\n";
+        bodyText << "Signal= " << signal 
+            << "\r\nDuration= " << duration << "\r\n\r\n";
         pj_str_t bodyStr;
         pj_cstr(&bodyStr, bodyText.str().c_str());
 
         pjsip_msg_body *body = pjsip_msg_body_create(tdata->pool, &type, &subtype, &bodyStr);
 
+        if (!body)
+        {
+            throw AsteriskSCF::SessionCommunications::V1::IndicationException();
+        }
+
         tdata->msg->body = body;
 
+    }
+
+    void sendDTMFINFO(const AsteriskSCF::SessionCommunications::V1::EndDTMFPtr& endDTMF)
+    {
+        pjsip_tx_data *tdata = createINFORequest();
+
+        pj_str_t infoPackage;
+        pj_cstr(&infoPackage, "Info-Package");
+        pj_str_t infoPackageVal;
+        pj_cstr(&infoPackageVal, "dtmf");
+        pjsip_generic_string_hdr *infoPackageHdr = pjsip_generic_string_hdr_create(tdata->pool, &infoPackage, &infoPackageVal);
+
+        pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) infoPackageHdr);
+
+        fillINFOBody(tdata, endDTMF->digit, endDTMF->duration);
+
+        pjsip_dlg_send_request(mImplPriv->mInviteSession->dlg, tdata, -1, NULL);
+    }
+
+    void sendFlashINFO()
+    {
+        pjsip_tx_data *tdata = createINFORequest();
+        fillINFOBody(tdata, '!', 100);
         pjsip_dlg_send_request(mImplPriv->mInviteSession->dlg, tdata, -1, NULL);
     }
 

-----------------------------------------------------------------------


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list