[asterisk-scf-commits] asterisk-scf/integration/mediaformatgeneric.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Jun 26 14:47:52 CDT 2011


branch "master" has been updated
       via  0c84620d7aef579d4f223044b08428fdde7a2b21 (commit)
       via  08d9fe9d89022c8accd26e0f154f027f72397144 (commit)
       via  670c1f4cab6e9a64abe345203291804f79a7f82a (commit)
       via  07ddc5ef658ca5a97e4387ee1c5b8e7d92d86993 (commit)
      from  c2a93610f0a6981903c78118c58d07533e749dfc (commit)

Summary of changes:
 config/MediaFormatGeneric.config         |    9 +++++----
 config/MediaFormatGenericConfigurator.py |   20 ++++++++++----------
 src/MediaFormatGeneric.cpp               |   22 ++++++++++++++++------
 src/MediaFormatGeneric.h                 |   13 +++++++++++++
 4 files changed, 44 insertions(+), 20 deletions(-)


- Log -----------------------------------------------------------------
commit 0c84620d7aef579d4f223044b08428fdde7a2b21
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jun 26 16:36:04 2011 -0300

    Update configuration file based on changes.

diff --git a/config/MediaFormatGeneric.config b/config/MediaFormatGeneric.config
index 3ad1f5a..4b57a34 100644
--- a/config/MediaFormatGeneric.config
+++ b/config/MediaFormatGeneric.config
@@ -6,7 +6,7 @@ type=video
 
 # RTP payload for this format, if this is a dynamic payload you can set this to
 # -1 to have a payload assigned automatically
-sdp_payload=101
+sdp_payload=-1
 
 # SDP subtype
 sdp_subtype=BOB
@@ -15,4 +15,4 @@ sdp_subtype=BOB
 samplerate=8000
 
 # Additional parameters for the SDP
-sdp_parameters=fmtp:101 awesome
+sdp_parameters=awesome

commit 08d9fe9d89022c8accd26e0f154f027f72397144
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jun 26 16:17:14 2011 -0300

    Change values passed in for name to use the name from the format class.

diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index c10c623..94540cd 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -276,8 +276,8 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
     ulawSDP->type = "audio";
     ulawSDP->subtype = "PCMU";
     ulawSDP->samplerate = 8000;
-    descriptorService->addFormat("ulaw", ulaw, ulawSDP);
-    comparatorService->addFormat("ulaw");
+    descriptorService->addFormat(ulaw->name, ulaw, ulawSDP);
+    comparatorService->addFormat(ulaw->name);
 
     // Add the alaw audio format
     G711aLAWPtr alaw = new G711aLAW();
@@ -287,8 +287,8 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
     alawSDP->type = "audio";
     alawSDP->subtype = "PCMA";
     alawSDP->samplerate = 8000;
-    descriptorService->addFormat("alaw", alaw, alawSDP);
-    comparatorService->addFormat("alaw");
+    descriptorService->addFormat(alaw->name, alaw, alawSDP);
+    comparatorService->addFormat(alaw->name);
 
     // Register our custom comparator with the service locator
     ServiceLocatorParamsComparePrx comparatorServicePrx = ServiceLocatorParamsComparePrx::uncheckedCast(

commit 670c1f4cab6e9a64abe345203291804f79a7f82a
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jun 26 16:16:33 2011 -0300

    Add locking to supported formats. This uses a shared mutex since the supported formats will be rather static once pushed in and won't change that much.

diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index de56e75..c10c623 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -87,6 +87,7 @@ private:
 
 bool SDPDescriptorCompareServiceImpl::isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
 {
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
     SDPDescriptorServiceLocatorParamsPtr descriptorParams = SDPDescriptorServiceLocatorParamsPtr::dynamicCast(params);
 
     if (descriptorParams == 0)
@@ -106,11 +107,13 @@ bool SDPDescriptorCompareServiceImpl::isSupported(const ServiceLocatorParamsPtr&
 
 void SDPDescriptorCompareServiceImpl::addFormat(const std::string& name)
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
     mSupportedFormats.push_back(name);
 }
 
 void SDPDescriptorCompareServiceImpl::removeFormat(const std::string& name)
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
     Ice::StringSeq::iterator format = std::find(mSupportedFormats.begin(), mSupportedFormats.end(), name);
 
     if (format != mSupportedFormats.end())
@@ -121,23 +124,25 @@ void SDPDescriptorCompareServiceImpl::removeFormat(const std::string& name)
 
 void SDPDescriptorCompareServiceImpl::removeAllFormats()
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
     mSupportedFormats.clear();
 }
 
 FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int sampleRate, int frameSize, const Ice::StringSeq&, const Ice::Current&)
 {
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
     std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
 
     if (format == mNamedFormats.end())
     {
         return 0;
     }
-
-    // XXX Need to actually create a new format containing sampleRate / frameSize
 }
 
 FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
 {
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
+
     if (descriptor->payload < 96)
     {
         std::map<int, FormatPtr>::iterator format = mPayloadNumberFormats.find(descriptor->payload);
@@ -167,6 +172,7 @@ FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& d
 
 SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format, const Ice::Current&)
 {
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
     std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->name);
 
     if (descriptor == mFormatDescriptors.end())
@@ -182,6 +188,7 @@ SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format
  */
 void SDPDescriptorServiceImpl::addFormat(const std::string& name, const FormatPtr& format, const SDPDescriptorPtr& descriptor)
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
     mNamedFormats.insert(make_pair(name, format));
     mFormatDescriptors.insert(make_pair(format->name, descriptor));
 
@@ -205,6 +212,7 @@ void SDPDescriptorServiceImpl::addFormat(const std::string& name, const FormatPt
 
 void SDPDescriptorServiceImpl::removeFormat(const std::string& name)
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
     std::map<std::string, AsteriskSCF::Media::V1::FormatPtr>::iterator format = mNamedFormats.find(name);
 
     if (format == mNamedFormats.end())
@@ -232,6 +240,8 @@ void SDPDescriptorServiceImpl::removeFormat(const std::string& name)
 
 void SDPDescriptorServiceImpl::removeAllFormats()
 {
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+
     mNamedFormats.clear();
     mPayloadNumberFormats.clear();
     mPayloadNameFormats.clear();
diff --git a/src/MediaFormatGeneric.h b/src/MediaFormatGeneric.h
index 89e01aa..f5f52c0 100644
--- a/src/MediaFormatGeneric.h
+++ b/src/MediaFormatGeneric.h
@@ -18,6 +18,9 @@
 
 #include <Ice/Ice.h>
 
+#include <boost/thread.hpp>
+#include <boost/thread/shared_mutex.hpp>
+
 #include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
@@ -35,6 +38,11 @@ private:
      * Supported formats in named form
      */
     Ice::StringSeq mSupportedFormats;
+
+    /**
+     * Lock to protect supported formats
+     */
+    boost::shared_mutex mLock;
 };
 
 /**
@@ -78,6 +86,11 @@ private:
      * Mapping for format descriptors
      */
     std::map<std::string, AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr> mFormatDescriptors;
+
+    /**
+     * Lock to protect supportd formats
+     */
+    boost::shared_mutex mLock;
 };
 
 /**

commit 07ddc5ef658ca5a97e4387ee1c5b8e7d92d86993
Author: Joshua Colp <jcolp at digium.com>
Date:   Sun Jun 26 16:15:59 2011 -0300

    Update Configurator to latest changes and change some option names to better reflect they are for SDP.

diff --git a/config/MediaFormatGeneric.config b/config/MediaFormatGeneric.config
index 03d77c0..3ad1f5a 100644
--- a/config/MediaFormatGeneric.config
+++ b/config/MediaFormatGeneric.config
@@ -4,14 +4,15 @@
 # Type of media this format is for, valid options are audio and video
 type=video
 
-# RTP payload for this format
-payload=101
+# RTP payload for this format, if this is a dynamic payload you can set this to
+# -1 to have a payload assigned automatically
+sdp_payload=101
 
 # SDP subtype
-subtype=BOB
+sdp_subtype=BOB
 
 # Sample rate, obviously
 samplerate=8000
 
 # Additional parameters for the SDP
-parameters=fmtp:101 awesome
+sdp_parameters=fmtp:101 awesome
diff --git a/config/MediaFormatGenericConfigurator.py b/config/MediaFormatGenericConfigurator.py
index efbf0ed..fde156e 100755
--- a/config/MediaFormatGenericConfigurator.py
+++ b/config/MediaFormatGenericConfigurator.py
@@ -19,34 +19,34 @@
 # Rtp configurator
 
 # Bring in the common configuration infrastructure
-import Ice, Configurator, sys
+import Ice, Configurator, sys, os
 
 # Load our component specific configuration definitions
-Ice.loadSlice('-I. -I/opt/Ice-3.4.1/slice -I../../slice --all ../local-slice/MediaFormatGenericConfigurationIf.ice')
-import AsteriskSCF.Media.FormatGeneric.V1
+Ice.loadSlice("-I" + os.environ["ASTSCF_HOME"] + " -I" + Ice.getSliceDir() + " --all ../slice/AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice")
+import AsteriskSCF.Configuration.FormatGeneric.V1
 
 # Add our own visitor implementations for the sections we support
 class MediaFormatGenericSectionVisitors(Configurator.SectionVisitors):
     def __init__(self):
-        self.formats = AsteriskSCF.Media.FormatGeneric.V1.FormatsGroup()
+        self.formats = AsteriskSCF.Configuration.FormatGeneric.V1.FormatsGroup()
         self.formats.configurationItems = { }
         self.groups = [ ]
         self.groups.append(self.formats)
 
     def visit_unsupported(self, config, section):
-        format = AsteriskSCF.Media.FormatGeneric.V1.FormatConfigurationItem()
+        format = AsteriskSCF.Configuration.FormatGeneric.V1.FormatConfigurationItem()
         format.descriptor = AsteriskSCF.Media.SDP.V1.SDPDescriptor()
         format.name = section
 
         # Populate the SDP descriptor with configured values
-        format.descriptor.payload = config.getint(section, 'payload')
+        format.descriptor.payload = config.getint(section, 'sdp_payload')
         format.descriptor.type = config.get(section, 'type')
-        format.descriptor.subtype = config.get(section, 'subtype')
+        format.descriptor.subtype = config.get(section, 'sdp_subtype')
         format.descriptor.samplerate = config.getint(section, 'samplerate')
         format.descriptor.parameters = []
 
         # Add parameters if specified
-        parameters = config.get(section, 'parameters')
+        parameters = config.get(section, 'sdp_parameters')
         if parameters:
             format.descriptor.parameters.append(parameters)
 
@@ -60,8 +60,8 @@ class MediaFormatGenericSectionVisitors(Configurator.SectionVisitors):
         self.formats.configurationItems[section] = format
 
 # In order to do service locator based lookup we need to pass in a params object
-serviceLocatorParams = AsteriskSCF.Media.FormatGeneric.V1.ConfigurationParams()
-serviceLocatorParams.category = AsteriskSCF.Media.FormatGeneric.V1.ConfigurationDiscoveryCategory
+serviceLocatorParams = AsteriskSCF.Configuration.FormatGeneric.V1.ConfigurationParams()
+serviceLocatorParams.category = AsteriskSCF.Configuration.FormatGeneric.V1.ConfigurationDiscoveryCategory
 
 # Make a configurator application and let it run
 app = Configurator.ConfiguratorApp('MediaFormatGeneric.config', MediaFormatGenericSectionVisitors(), None, serviceLocatorParams)

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


-- 
asterisk-scf/integration/mediaformatgeneric.git



More information about the asterisk-scf-commits mailing list