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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Jun 13 17:10:10 CDT 2011


branch "media" has been updated
       via  d0ecc289997472e3662a7bb1add5e4c92c2ba683 (commit)
      from  142a3b1681235d5ff4e298adbbc6fc8fed58c52f (commit)

Summary of changes:
 src/SipEndpoint.cpp |  126 +++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 97 insertions(+), 29 deletions(-)


- Log -----------------------------------------------------------------
commit d0ecc289997472e3662a7bb1add5e4c92c2ba683
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Jun 13 19:10:43 2011 -0300

    Retrieve configured format information (class / SDP descriptor) and store it within the endpoint.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 0caf169..6d8f5e9 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -21,9 +21,11 @@
 
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
 
 using namespace AsteriskSCF::System::Logging;
+using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Media::SDP::V1;
 using namespace AsteriskSCF::Core::Discovery::V1;
 
@@ -38,6 +40,90 @@ namespace SipSessionManager
 {
 
 /**
+ * Class used to store information about the configured formats.
+ */
+class ConfiguredFormat : public IceUtil::Shared
+{
+public:
+    ConfiguredFormat(std::string& name) : mName(name), mAvailable(false) { }
+
+    void locateCB(const Ice::ObjectPrx& service)
+    {
+        // Store away the descriptor service proxy for future use
+        mDescriptorService = SDPDescriptorServicePrx::uncheckedCast(service);
+
+	// Setup an AMI request to get the named format
+        Callback_SDPDescriptorService_getNamedFormatPtr descriptorCB = newCallback_SDPDescriptorService_getNamedFormat(
+            this, &ConfiguredFormat::getNamedFormatCB, &ConfiguredFormat::getNamedFormatFailureCB);
+
+	// Send it off
+	mDescriptorService->begin_getNamedFormat(mName, descriptorCB);
+    }
+
+    void locateFailureCB(const Ice::Exception&)
+    {
+    }
+
+    void getNamedFormatCB(const FormatPtr& format)
+    {
+	// Store away the format
+	mFormat = format;
+
+	// Setup an AMI request to get the SDP descriptor
+        Callback_SDPDescriptorService_getDescriptorPtr descriptorCB = newCallback_SDPDescriptorService_getDescriptor(
+            this, &ConfiguredFormat::getDescriptorCB, &ConfiguredFormat::getDescriptorFailureCB);
+
+        // Send it off
+        mDescriptorService->begin_getDescriptor(mFormat, descriptorCB);
+    }
+
+    void getNamedFormatFailureCB(const Ice::Exception&)
+    {
+    }
+
+    void getDescriptorCB(const SDPDescriptorPtr& descriptor)
+    {
+	// Store it away
+	mDescriptor = descriptor;
+
+	// This configured format is now available for use
+	mAvailable = true;
+    }
+
+    void getDescriptorFailureCB(const Ice::Exception&)
+    {
+    }
+
+private:
+    /**
+     * Name of the media format.
+     */
+    std::string mName;
+
+    /**
+     * Whether this configured format is available or not.
+     */
+    bool mAvailable;
+
+    /**
+     * SDP descriptor service for this media format.
+     */
+    SDPDescriptorServicePrx mDescriptorService;
+
+    /**
+     * Media format concrete class, retrieved from SDP descriptor service.
+     */
+    FormatPtr mFormat;
+
+    /**
+     * SDP descriptor class, retrieved from the SDP descriptor service.
+     */
+    SDPDescriptorPtr mDescriptor;
+};
+
+typedef IceUtil::Handle<ConfiguredFormat> ConfiguredFormatPtr;
+
+/**
  * Private implementation details for SipEndpoint.
  */
 class SipEndpointImplPriv
@@ -81,6 +167,11 @@ public:
     std::vector<SipSessionPtr> mSessions;
 
     /**
+     * A vector of configured formats for this endpoint.
+     */
+    std::vector<ConfiguredFormatPtr> mFormats;
+
+    /**
      * A proxy to our endpoint.
      */
     AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mEndpointProxy;
@@ -102,33 +193,6 @@ public:
 };
 
 /**
- * Callback implementation for SDP descriptor locate request.
- */
-class SDPDescriptorLocateCallback : public IceUtil::Shared
-{
-public:
-    SDPDescriptorLocateCallback(std::string& name) : mName(name) { }
-
-    void locateCB(const Ice::ObjectPrx&)
-    {
-        std::cout << "Located media format" << std::endl;
-    }
-
-    void locateFailureCB(const Ice::Exception&)
-    {
-        std::cout << "Failed to locate media format" << std::endl;
-    }
-
-private:
-    /**
-     * Name of the media format.
-     */
-    std::string mName;
-};
-
-typedef IceUtil::Handle<SDPDescriptorLocateCallback> SDPDescriptorLocateCallbackPtr;
-
-/**
  * Default constructor.
  */
 SipEndpoint::SipEndpoint(const Ice::ObjectAdapterPtr& adapter, const boost::shared_ptr<SipEndpointFactory>& factory,
@@ -197,9 +261,13 @@ void SipEndpoint::setFormats(const Ice::StringSeq& formats)
 	params->category = "Media/SDP_Descriptor";
 	params->name = (*format);
 
-        SDPDescriptorLocateCallbackPtr callback = new SDPDescriptorLocateCallback(params->name);
+        ConfiguredFormatPtr configuredFormat = new ConfiguredFormat(params->name);
         Callback_ServiceLocator_locatePtr descriptorCB = newCallback_ServiceLocator_locate(
-            callback, &SDPDescriptorLocateCallback::locateCB, &SDPDescriptorLocateCallback::locateFailureCB);
+            configuredFormat, &ConfiguredFormat::locateCB, &ConfiguredFormat::locateFailureCB);
+
+        // Before we do the locate make sure this is part of the endpoint
+        mImplPriv->mFormats.push_back(configuredFormat);
+
         mImplPriv->mServiceLocator->begin_locate(params, descriptorCB);
     }
 }

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list