[asterisk-scf-commits] asterisk-scf/release/mediaformatgeneric.git branch "master" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Sun Jul 10 09:31:04 CDT 2011
branch "master" has been created
at 3750d070df816e9afb44cf0550693839b55e3c30 (commit)
- Log -----------------------------------------------------------------
commit 3750d070df816e9afb44cf0550693839b55e3c30
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jul 10 11:31:19 2011 -0300
Remove unneeded test directory.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1ab178..8a47aeb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,5 @@
astscf_project(mediaformatgeneric 3.4)
add_subdirectory(src)
-if(BUILD_TESTING)
- add_subdirectory(test)
-endif()
+
astscf_slice_collection_install(PROJECT)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
deleted file mode 100644
index e69de29..0000000
commit 31bbce019ddaca8bb9e56dc2176d335f0d387322
Author: Joshua Colp <jcolp at digium.com>
Date: Sun Jul 3 16:27:04 2011 -0300
Fix a silly regression that I introduced when I was exploring some comparison stuff.
diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index 94540cd..c54e8f6 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -137,6 +137,8 @@ FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int
{
return 0;
}
+
+ return format->second;
}
FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
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)
commit c2a93610f0a6981903c78118c58d07533e749dfc
Author: Joshua Colp <jcolp at digium.com>
Date: Sat Jun 25 18:06:25 2011 -0300
Update to work with build system changes and slice changes.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index edca8f3..a1ab178 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,7 @@
-asterisk_scf_project(mediaformatgeneric 3.4)
+astscf_project(mediaformatgeneric 3.4)
add_subdirectory(src)
-add_subdirectory(test)
+if(BUILD_TESTING)
+ add_subdirectory(test)
+endif()
+astscf_slice_collection_install(PROJECT)
diff --git a/local-slice/MediaFormatGenericConfigurationIf.ice b/slice/AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice
similarity index 97%
rename from local-slice/MediaFormatGenericConfigurationIf.ice
rename to slice/AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice
index d4791a0..0de9cc9 100644
--- a/local-slice/MediaFormatGenericConfigurationIf.ice
+++ b/slice/AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice
@@ -25,7 +25,7 @@
module AsteriskSCF
{
-module Media
+module Configuration
{
module FormatGeneric
@@ -96,9 +96,9 @@ module V1
}; /* module V1 */
-}; /* module RTP */
+}; /* module FormatGeneric */
-}; /* module Media */
+}; /* module Configuration */
}; /* module Asterisk SCF */
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d5db525..e216ea7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,16 +1,14 @@
-include_directories(${API_INCLUDE_DIR})
-include_directories(${ice-util-cpp_dir}/include)
include_directories(${logger_dir}/include)
-asterisk_scf_slice_include_directories(${API_SLICE_DIR})
-
-asterisk_scf_component_init(mediaformatgenetic)
-asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.cpp)
-asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.h)
-asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGenericConfiguration.cpp)
-asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGenericConfiguration.h)
-asterisk_scf_component_add_slice(mediaformatgeneric ../local-slice/MediaFormatGenericConfigurationIf.ice)
-asterisk_scf_component_build_icebox(mediaformatgeneric)
+astscf_component_init(mediaformatgeneric)
+astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.cpp)
+astscf_component_add_files(mediaformatgeneric MediaFormatGeneric.h)
+astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.cpp)
+astscf_component_add_files(mediaformatgeneric MediaFormatGenericConfiguration.h)
+astscf_component_add_slices(mediaformatgeneric PROJECT AsteriskSCF/Configuration/MediaFormatGeneric/MediaFormatGenericConfigurationIf.ice)
+astscf_component_add_boost_libraries(mediaformatgeneric core thread)
+astscf_component_add_slice_collection_libraries(mediaformatgeneric ASTSCF)
+astscf_component_build_icebox(mediaformatgeneric)
target_link_libraries(mediaformatgeneric logging-client)
-target_link_libraries(mediaformatgeneric asterisk-scf-api)
-asterisk_scf_component_install(mediaformatgeneric)
+astscf_component_install(mediaformatgeneric)
+
diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index 146e9b9..de56e75 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -35,7 +35,7 @@ using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::Media::SDP::V1;
using namespace AsteriskSCF::Media::Formats::Audio::V1;
-using namespace AsteriskSCF::Media::FormatGeneric::V1;
+using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
@@ -124,7 +124,7 @@ void SDPDescriptorCompareServiceImpl::removeAllFormats()
mSupportedFormats.clear();
}
-FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, const Ice::Current&)
+FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, int sampleRate, int frameSize, const Ice::StringSeq&, const Ice::Current&)
{
std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
@@ -133,7 +133,7 @@ FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, cons
return 0;
}
- return format->second;
+ // XXX Need to actually create a new format containing sampleRate / frameSize
}
FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
@@ -330,7 +330,7 @@ void MediaFormatGenericApp::stop()
extern "C"
{
-ASTERISK_SCF_ICEBOX_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
+ASTSCF_DLL_EXPORT IceBox::Service* create(Ice::CommunicatorPtr)
{
return new MediaFormatGenericApp;
}
diff --git a/src/MediaFormatGeneric.h b/src/MediaFormatGeneric.h
index c52b931..89e01aa 100644
--- a/src/MediaFormatGeneric.h
+++ b/src/MediaFormatGeneric.h
@@ -48,7 +48,7 @@ typedef IceUtil::Handle<SDPDescriptorCompareServiceImpl> SDPDescriptorCompareSer
class SDPDescriptorServiceImpl : public AsteriskSCF::Media::SDP::V1::SDPDescriptorService
{
public:
- AsteriskSCF::Media::V1::FormatPtr getNamedFormat(const std::string&, const Ice::Current&);
+ AsteriskSCF::Media::V1::FormatPtr getNamedFormat(const std::string&, int, int, const Ice::StringSeq&, const Ice::Current&);
AsteriskSCF::Media::V1::FormatPtr getDescribedFormat(const AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr&,
const Ice::Current&);
AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr getDescriptor(const AsteriskSCF::Media::V1::FormatPtr&,
diff --git a/src/MediaFormatGenericConfiguration.cpp b/src/MediaFormatGenericConfiguration.cpp
index c205d86..a125576 100644
--- a/src/MediaFormatGenericConfiguration.cpp
+++ b/src/MediaFormatGenericConfiguration.cpp
@@ -27,7 +27,7 @@
#include "MediaFormatGeneric.h"
using namespace AsteriskSCF::System::Configuration::V1;
-using namespace AsteriskSCF::Media::FormatGeneric::V1;
+using namespace AsteriskSCF::Configuration::FormatGeneric::V1;
class ConfigurationServiceImplPriv
{
commit 64715c6cf02d0aeb7ce63ca31712394eba965c0d
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 20 19:17:49 2011 -0300
Add support for specifying additional parameters and also switch bob to be a video codec.
diff --git a/config/MediaFormatGeneric.config b/config/MediaFormatGeneric.config
index 7e550d9..03d77c0 100644
--- a/config/MediaFormatGeneric.config
+++ b/config/MediaFormatGeneric.config
@@ -2,7 +2,7 @@
[bob8]
# Type of media this format is for, valid options are audio and video
-type=audio
+type=video
# RTP payload for this format
payload=101
@@ -12,3 +12,6 @@ subtype=BOB
# Sample rate, obviously
samplerate=8000
+
+# Additional parameters for the SDP
+parameters=fmtp:101 awesome
diff --git a/config/MediaFormatGenericConfigurator.py b/config/MediaFormatGenericConfigurator.py
index f135e28..efbf0ed 100755
--- a/config/MediaFormatGenericConfigurator.py
+++ b/config/MediaFormatGenericConfigurator.py
@@ -43,6 +43,12 @@ class MediaFormatGenericSectionVisitors(Configurator.SectionVisitors):
format.descriptor.type = config.get(section, 'type')
format.descriptor.subtype = config.get(section, 'subtype')
format.descriptor.samplerate = config.getint(section, 'samplerate')
+ format.descriptor.parameters = []
+
+ # Add parameters if specified
+ parameters = config.get(section, 'parameters')
+ if parameters:
+ format.descriptor.parameters.append(parameters)
# Populate the Media format concrete class
if format.descriptor.type == 'audio':
commit bdb885e24930692ceb8568356ab9d5c09378e1e7
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 20 18:11:04 2011 -0300
Use the name to do baseline format identification.
diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index 95710e0..146e9b9 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -167,7 +167,7 @@ FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& d
SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format, const Ice::Current&)
{
- std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->ice_id());
+ std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->name);
if (descriptor == mFormatDescriptors.end())
{
@@ -183,7 +183,7 @@ SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format
void SDPDescriptorServiceImpl::addFormat(const std::string& name, const FormatPtr& format, const SDPDescriptorPtr& descriptor)
{
mNamedFormats.insert(make_pair(name, format));
- mFormatDescriptors.insert(make_pair(format->ice_id(), descriptor));
+ mFormatDescriptors.insert(make_pair(format->name, descriptor));
if (descriptor->payload < 96)
{
@@ -213,7 +213,7 @@ void SDPDescriptorServiceImpl::removeFormat(const std::string& name)
}
std::map<std::string, AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr>::iterator descriptor = mFormatDescriptors.find(
- format->second->ice_id());
+ format->second->name);
if (descriptor->second->payload < 96)
{
@@ -260,6 +260,7 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
// Add the ulaw audio format
G711uLAWPtr ulaw = new G711uLAW();
+ ulaw->name = "ulaw";
SDPDescriptorPtr ulawSDP = new SDPDescriptor();
ulawSDP->payload = 0;
ulawSDP->type = "audio";
@@ -270,6 +271,7 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
// Add the alaw audio format
G711aLAWPtr alaw = new G711aLAW();
+ alaw->name = "alaw";
SDPDescriptorPtr alawSDP = new SDPDescriptor();
alawSDP->payload = 8;
alawSDP->type = "audio";
commit 5ab8dc52554d57f2265898924fe099d208730d1d
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 20 16:41:45 2011 -0300
Finish up configuration support. You can now push basic formats in from a python script. More tweaking to come!
diff --git a/config/MediaFormatGenericConfigurator.py b/config/MediaFormatGenericConfigurator.py
index 7d17d94..f135e28 100755
--- a/config/MediaFormatGenericConfigurator.py
+++ b/config/MediaFormatGenericConfigurator.py
@@ -30,10 +30,11 @@ class MediaFormatGenericSectionVisitors(Configurator.SectionVisitors):
def __init__(self):
self.formats = AsteriskSCF.Media.FormatGeneric.V1.FormatsGroup()
self.formats.configurationItems = { }
- self.added = False
+ self.groups = [ ]
+ self.groups.append(self.formats)
def visit_unsupported(self, config, section):
- format = AsteriskSCF.Media.FormatGeneric.FormatItem()
+ format = AsteriskSCF.Media.FormatGeneric.V1.FormatConfigurationItem()
format.descriptor = AsteriskSCF.Media.SDP.V1.SDPDescriptor()
format.name = section
@@ -43,9 +44,14 @@ class MediaFormatGenericSectionVisitors(Configurator.SectionVisitors):
format.descriptor.subtype = config.get(section, 'subtype')
format.descriptor.samplerate = config.getint(section, 'samplerate')
- if self.added == False:
- self.groups.append(self.formats)
- self.added = True
+ # Populate the Media format concrete class
+ if format.descriptor.type == 'audio':
+ format.format = AsteriskSCF.Media.V1.AudioFormat()
+ elif format.descriptor.type == 'video':
+ format.format = AsteriskSCF.Media.V1.VideoFormat()
+ format.format.name = section
+
+ 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()
diff --git a/local-slice/MediaFormatGenericConfigurationIf.ice b/local-slice/MediaFormatGenericConfigurationIf.ice
index 8d16145..d4791a0 100644
--- a/local-slice/MediaFormatGenericConfigurationIf.ice
+++ b/local-slice/MediaFormatGenericConfigurationIf.ice
@@ -19,6 +19,7 @@
#include <Ice/BuiltinSequences.ice>
#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
+#include <AsteriskSCF/Media/MediaIf.ice>
#include <AsteriskSCF/Media/SDP/MediaSDPIf.ice>
module AsteriskSCF
@@ -83,6 +84,11 @@ module V1
string name;
/**
+ * Media format concrete class.
+ */
+ AsteriskSCF::Media::V1::Format format;
+
+ /**
* SDP Descriptor containing SDP parameters for the format.
*/
AsteriskSCF::Media::SDP::V1::SDPDescriptor descriptor;
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f8ead77..d5db525 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,7 +6,9 @@ asterisk_scf_slice_include_directories(${API_SLICE_DIR})
asterisk_scf_component_init(mediaformatgenetic)
asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.cpp)
-asterisk_scf_component_add_boost_libraries(mediaformatgeneric core thread)
+asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.h)
+asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGenericConfiguration.cpp)
+asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGenericConfiguration.h)
asterisk_scf_component_add_slice(mediaformatgeneric ../local-slice/MediaFormatGenericConfigurationIf.ice)
asterisk_scf_component_build_icebox(mediaformatgeneric)
target_link_libraries(mediaformatgeneric logging-client)
diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
index 1db9884..95710e0 100644
--- a/src/MediaFormatGeneric.cpp
+++ b/src/MediaFormatGeneric.cpp
@@ -18,8 +18,6 @@
#include <IceBox/IceBox.h>
#include <IceUtil/UUID.h>
-#include <boost/shared_ptr.hpp>
-
#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
#include <AsteriskSCF/Media/MediaIf.h>
#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
@@ -28,11 +26,16 @@
#include <AsteriskSCF/Logger/IceLogger.h>
#include <AsteriskSCF/logger.h>
+#include "MediaFormatGeneric.h"
+#include "MediaFormatGenericConfiguration.h"
+#include "MediaFormatGenericConfigurationIf.h"
+
using namespace std;
using namespace AsteriskSCF::Core::Discovery::V1;
using namespace AsteriskSCF::Media::V1;
using namespace AsteriskSCF::Media::SDP::V1;
using namespace AsteriskSCF::Media::Formats::Audio::V1;
+using namespace AsteriskSCF::Media::FormatGeneric::V1;
using namespace AsteriskSCF::System::Component::V1;
using namespace AsteriskSCF::System::Logging;
@@ -42,197 +45,198 @@ Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaFormatGeneric");
}
/**
- * Implementation of the ServiceLocatorParamsCompare class
+ * Implementation of the IceBox::Service class
*/
-class SDPDescriptorCompareServiceImpl : public ServiceLocatorParamsCompare
+class MediaFormatGenericApp : public IceBox::Service
{
public:
- bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
- {
- SDPDescriptorServiceLocatorParamsPtr descriptorParams = SDPDescriptorServiceLocatorParamsPtr::dynamicCast(params);
+ void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
+ void stop();
- if (descriptorParams == 0)
- {
- return false;
- }
+private:
+ /**
+ * Ice Communicator used for this service.
+ */
+ Ice::CommunicatorPtr mCommunicator;
- Ice::StringSeq::const_iterator format = std::find(mSupportedFormats.begin(), mSupportedFormats.end(), descriptorParams->name);
+ /**
+ * Object adapter that stuff is associated with.
+ */
+ Ice::ObjectAdapterPtr mAdapter;
- if (format == mSupportedFormats.end())
- {
- return false;
- }
+ /**
+ * A proxy to the service locator manager for our SDP descriptor service.
+ */
+ ServiceManagementPrx mServiceManagement;
- return true;
- };
+ /**
+ * A proxy to the service locator manager for our configuration service.
+ */
+ ServiceManagementPrx mConfigurationServiceManagement;
- void addFormat(const std::string& name)
- {
- mSupportedFormats.push_back(name);
- };
+ /**
+ * A proxy to the service locator management service.
+ */
+ ServiceLocatorManagementPrx mManagement;
-private:
/**
- * Supported formats in named form
+ * Unique guid for SDP descriptor service name comparator.
*/
- Ice::StringSeq mSupportedFormats;
+ std::string mCompareGuid;
};
-/**
- * Smart pointer for the SDPDescriptorCompareServiceImpl class
- */
-typedef IceUtil::Handle<SDPDescriptorCompareServiceImpl> SDPDescriptorCompareServiceImplPtr;
-
-/**
- * Implementation of the SDPDescriptorService class
- *
- * Note that this does not have a lock on purpose because the supported formats will not
- * be changed once the service goes into operation.
- */
-class SDPDescriptorServiceImpl : public SDPDescriptorService
+bool SDPDescriptorCompareServiceImpl::isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
{
-public:
- FormatPtr getNamedFormat(const std::string& name, const Ice::Current&)
- {
- std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
+ SDPDescriptorServiceLocatorParamsPtr descriptorParams = SDPDescriptorServiceLocatorParamsPtr::dynamicCast(params);
- if (format == mNamedFormats.end())
- {
- return 0;
- }
+ if (descriptorParams == 0)
+ {
+ return false;
+ }
- return format->second;
- };
+ Ice::StringSeq::const_iterator format = std::find(mSupportedFormats.begin(), mSupportedFormats.end(), descriptorParams->name);
- FormatPtr getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
+ if (format == mSupportedFormats.end())
{
- if (descriptor->payload < 96)
- {
- std::map<int, FormatPtr>::iterator format = mPayloadNumberFormats.find(descriptor->payload);
+ return false;
+ }
- if (format == mPayloadNumberFormats.end())
- {
- return 0;
- }
+ return true;
+}
- return format->second;
- }
- else
- {
- std::map<std::string, FormatPtr>::iterator format = mPayloadNameFormats.find(descriptor->subtype);
+void SDPDescriptorCompareServiceImpl::addFormat(const std::string& name)
+{
+ mSupportedFormats.push_back(name);
+}
- if (format == mPayloadNameFormats.end())
- {
- return 0;
- }
+void SDPDescriptorCompareServiceImpl::removeFormat(const std::string& name)
+{
+ Ice::StringSeq::iterator format = std::find(mSupportedFormats.begin(), mSupportedFormats.end(), name);
- return format->second;
- }
+ if (format != mSupportedFormats.end())
+ {
+ mSupportedFormats.erase(format);
+ }
+}
+
+void SDPDescriptorCompareServiceImpl::removeAllFormats()
+{
+ mSupportedFormats.clear();
+}
- // This will never get reached but just in case the compiler is silly...
+FormatPtr SDPDescriptorServiceImpl::getNamedFormat(const std::string& name, const Ice::Current&)
+{
+ std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
+
+ if (format == mNamedFormats.end())
+ {
return 0;
- };
+ }
+
+ return format->second;
+}
- SDPDescriptorPtr getDescriptor(const FormatPtr& format, const Ice::Current&)
+FormatPtr SDPDescriptorServiceImpl::getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
+{
+ if (descriptor->payload < 96)
{
- std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->ice_id());
+ std::map<int, FormatPtr>::iterator format = mPayloadNumberFormats.find(descriptor->payload);
- if (descriptor == mFormatDescriptors.end())
+ if (format == mPayloadNumberFormats.end())
{
return 0;
}
- return descriptor->second;
- };
-
- /**
- * Implementation specific function which adds a format to this descriptor service
- */
- void addFormat(const std::string& name, const FormatPtr& format, const SDPDescriptorPtr& descriptor)
+ return format->second;
+ }
+ else
{
- mNamedFormats.insert(make_pair(name, format));
- mFormatDescriptors.insert(make_pair(format->ice_id(), descriptor));
+ std::map<std::string, FormatPtr>::iterator format = mPayloadNameFormats.find(descriptor->subtype);
- if (descriptor->payload < 96)
+ if (format == mPayloadNameFormats.end())
{
- /*
- * If this is a static payload we store solely on the payload number itself
- * since some endpoints do not provide a payload name.
- */
- mPayloadNumberFormats.insert(make_pair(descriptor->payload, format));
- }
- else
- {
- /*
- * If this is a dynamic payload we store based on the payload name since the
- * payload number itself is not assigned to it.
- */
- mPayloadNameFormats.insert(make_pair(descriptor->subtype, format));
+ return 0;
}
- };
-private:
- /**
- * Mapping for named formats
- */
- std::map<std::string, FormatPtr> mNamedFormats;
+ return format->second;
+ }
- /**
- * Mapping for described formats using static payload number
- */
- std::map<int, FormatPtr> mPayloadNumberFormats;
+ // This will never get reached but just in case the compiler is silly...
+ return 0;
+}
- /**
- * Mapping for described formats using payload name
- */
- std::map<std::string, FormatPtr> mPayloadNameFormats;
+SDPDescriptorPtr SDPDescriptorServiceImpl::getDescriptor(const FormatPtr& format, const Ice::Current&)
+{
+ std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->ice_id());
- /**
- * Mapping for format descriptors
- */
- std::map<std::string, SDPDescriptorPtr> mFormatDescriptors;
-};
+ if (descriptor == mFormatDescriptors.end())
+ {
+ return 0;
+ }
-/**
- * Smart pointer for the SDPDescriptorServiceImpl class
- */
-typedef IceUtil::Handle<SDPDescriptorServiceImpl> SDPDescriptorServiceImplPtr;
+ return descriptor->second;
+}
/**
- * Implementation of the IceBox::Service class
+ * Implementation specific function which adds a format to this descriptor service
*/
-class MediaFormatGenericApp : public IceBox::Service
+void SDPDescriptorServiceImpl::addFormat(const std::string& name, const FormatPtr& format, const SDPDescriptorPtr& descriptor)
{
-public:
- void start(const std::string&, const Ice::CommunicatorPtr&, const Ice::StringSeq&);
- void stop();
+ mNamedFormats.insert(make_pair(name, format));
+ mFormatDescriptors.insert(make_pair(format->ice_id(), descriptor));
-private:
- /**
- * Ice Communicator used for this service.
- */
- Ice::CommunicatorPtr mCommunicator;
+ if (descriptor->payload < 96)
+ {
+ /*
+ * If this is a static payload we store solely on the payload number itself
+ * since some endpoints do not provide a payload name.
+ */
+ mPayloadNumberFormats.insert(make_pair(descriptor->payload, format));
+ }
+ else
+ {
+ /*
+ * If this is a dynamic payload we store based on the payload name since the
+ * payload number itself is not assigned to it.
+ */
+ mPayloadNameFormats.insert(make_pair(descriptor->subtype, format));
+ }
+}
- /**
- * Object adapter that stuff is associated with.
- */
- Ice::ObjectAdapterPtr mAdapter;
+void SDPDescriptorServiceImpl::removeFormat(const std::string& name)
+{
+ std::map<std::string, AsteriskSCF::Media::V1::FormatPtr>::iterator format = mNamedFormats.find(name);
- /**
- * A proxy to the service locator manager for our SDP descriptor service.
- */
- ServiceManagementPrx mServiceManagement;
+ if (format == mNamedFormats.end())
+ {
+ return;
+ }
- /**
- * A proxy to the service locator management service.
- */
- ServiceLocatorManagementPrx mManagement;
+ std::map<std::string, AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr>::iterator descriptor = mFormatDescriptors.find(
+ format->second->ice_id());
- /**
- * Unique guid for SDP descriptor service name comparator.
- */
- std::string mCompareGuid;
-};
+ if (descriptor->second->payload < 96)
+ {
+ std::map<int, AsteriskSCF::Media::V1::FormatPtr>::iterator number = mPayloadNumberFormats.find(descriptor->second->payload);
+ mPayloadNumberFormats.erase(number);
+ }
+ else
+ {
+ std::map<std::string, AsteriskSCF::Media::V1::FormatPtr>::iterator subtype = mPayloadNameFormats.find(descriptor->second->subtype);
+ mPayloadNameFormats.erase(subtype);
+ }
+
+ mFormatDescriptors.erase(descriptor);
+ mNamedFormats.erase(format);
+}
+
+void SDPDescriptorServiceImpl::removeAllFormats()
+{
+ mNamedFormats.clear();
+ mPayloadNumberFormats.clear();
+ mPayloadNameFormats.clear();
+ mFormatDescriptors.clear();
+}
/**
* Implementation of the IceBox::Service::start method.
@@ -251,8 +255,11 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
// Create an instance of our custom comparator service
SDPDescriptorCompareServiceImplPtr comparatorService = new SDPDescriptorCompareServiceImpl();
+ // Create an instance of our configuration service
+ ConfigurationServiceImplPtr configurationService = new ConfigurationServiceImpl(descriptorService, comparatorService);
+
// Add the ulaw audio format
- ULAWPtr ulaw = new ULAW();
+ G711uLAWPtr ulaw = new G711uLAW();
SDPDescriptorPtr ulawSDP = new SDPDescriptor();
ulawSDP->payload = 0;
ulawSDP->type = "audio";
@@ -262,7 +269,7 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
comparatorService->addFormat("ulaw");
// Add the alaw audio format
- ALAWPtr alaw = new ALAW();
+ G711aLAWPtr alaw = new G711aLAW();
SDPDescriptorPtr alawSDP = new SDPDescriptor();
alawSDP->payload = 8;
alawSDP->type = "audio";
@@ -277,6 +284,18 @@ void MediaFormatGenericApp::start(const std::string&, const Ice::CommunicatorPtr
mCompareGuid = IceUtil::generateUUID();
mManagement->addCompare(mCompareGuid, comparatorServicePrx);
+ // Add our configuration service to the service locator
+ Ice::ObjectPrx configurationServicePrx = mAdapter->addWithUUID(configurationService);
+ mConfigurationServiceManagement = ServiceManagementPrx::uncheckedCast(
+ mManagement->addService(configurationServicePrx, "Configuration/MediaFormatGeneric"));
+
+ // Populate some locator params so we can be found
+ ConfigurationParamsPtr configurationParams = new ConfigurationParams();
+ configurationParams->category = ConfigurationDiscoveryCategory;
+
+ // Tada! Add these and boom we are found
+ mConfigurationServiceManagement->addLocatorParams(configurationParams, "");
+
// Add ourselves to the service locator
Ice::ObjectPrx descriptorServicePrx = mAdapter->addWithUUID(descriptorService);
mServiceManagement = ServiceManagementPrx::uncheckedCast(
@@ -300,6 +319,9 @@ void MediaFormatGenericApp::stop()
// Remove our comparator from the service locator
mManagement->removeCompare(mCompareGuid);
+ // Remove our configuration service from the service locator
+ mConfigurationServiceManagement->unregister();
+
// Remove our SDP descriptor service from the service locator
mServiceManagement->unregister();
}
commit 669bb7f1ebe9c45a756c82cf5d94152897a6db5e
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 20 16:29:15 2011 -0300
Add pushable configuration of formats.
diff --git a/src/MediaFormatGeneric.h b/src/MediaFormatGeneric.h
new file mode 100644
index 0000000..c52b931
--- /dev/null
+++ b/src/MediaFormatGeneric.h
@@ -0,0 +1,86 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Media/MediaIf.h>
+#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
+
+class SDPDescriptorCompareServiceImpl : public AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsCompare
+{
+public:
+ bool isSupported(const AsteriskSCF::Core::Discovery::V1::ServiceLocatorParamsPtr&, const Ice::Current&);
+ void addFormat(const std::string&);
+ void removeFormat(const std::string&);
+ void removeAllFormats();
+
+private:
+ /**
+ * Supported formats in named form
+ */
+ Ice::StringSeq mSupportedFormats;
+};
+
+/**
+ * Smart pointer for the SDPDescriptorCompareServiceImpl class
+ */
+typedef IceUtil::Handle<SDPDescriptorCompareServiceImpl> SDPDescriptorCompareServiceImplPtr;
+
+/**
+ * Implementation of the SDPDescriptorService class
+ */
+class SDPDescriptorServiceImpl : public AsteriskSCF::Media::SDP::V1::SDPDescriptorService
+{
+public:
+ AsteriskSCF::Media::V1::FormatPtr getNamedFormat(const std::string&, const Ice::Current&);
+ AsteriskSCF::Media::V1::FormatPtr getDescribedFormat(const AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr&,
+ const Ice::Current&);
+ AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr getDescriptor(const AsteriskSCF::Media::V1::FormatPtr&,
+ const Ice::Current&);
+ void addFormat(const std::string&, const AsteriskSCF::Media::V1::FormatPtr&,
+ const AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr&);
+ void removeFormat(const std::string&);
+ void removeAllFormats();
+
+private:
+ /**
+ * Mapping for named formats
+ */
+ std::map<std::string, AsteriskSCF::Media::V1::FormatPtr> mNamedFormats;
+
+ /**
+ * Mapping for described formats using static payload number
+ */
+ std::map<int, AsteriskSCF::Media::V1::FormatPtr> mPayloadNumberFormats;
+
+ /**
+ * Mapping for described formats using payload name
+ */
+ std::map<std::string, AsteriskSCF::Media::V1::FormatPtr> mPayloadNameFormats;
+
+ /**
+ * Mapping for format descriptors
+ */
+ std::map<std::string, AsteriskSCF::Media::SDP::V1::SDPDescriptorPtr> mFormatDescriptors;
+};
+
+/**
+ * Smart pointer for the SDPDescriptorServiceImpl class
+ */
+typedef IceUtil::Handle<SDPDescriptorServiceImpl> SDPDescriptorServiceImplPtr;
diff --git a/src/MediaFormatGenericConfiguration.cpp b/src/MediaFormatGenericConfiguration.cpp
new file mode 100644
index 0000000..c205d86
--- /dev/null
+++ b/src/MediaFormatGenericConfiguration.cpp
@@ -0,0 +1,349 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <IceUtil/UUID.h>
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/shared_mutex.hpp>
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include "MediaFormatGenericConfigurationIf.h"
+#include "MediaFormatGenericConfiguration.h"
+#include "MediaFormatGeneric.h"
+
+using namespace AsteriskSCF::System::Configuration::V1;
+using namespace AsteriskSCF::Media::FormatGeneric::V1;
+
+class ConfigurationServiceImplPriv
+{
+public:
+ ConfigurationServiceImplPriv(const SDPDescriptorServiceImplPtr& descriptorService,
+ const SDPDescriptorCompareServiceImplPtr& comparatorService) :
+ mDescriptorService(descriptorService), mComparatorService(comparatorService) { };
+
+ /**
+ * Formats configuration group
+ */
+ FormatsGroupPtr mFormatsGroup;
+
+ /**
+ * A pointer to the SDP descriptor service implementation.
+ */
+ SDPDescriptorServiceImplPtr mDescriptorService;
+
+ /**
+ * A pointer to the SDP descriptor comparator service implementation.
+ */
+ SDPDescriptorCompareServiceImplPtr mComparatorService;
+
+ /**
+ * Shared mutex lock which protects the configuration
+ */
+ boost::shared_mutex mLock;
+};
+
+ConfigurationServiceImpl::ConfigurationServiceImpl(const SDPDescriptorServiceImplPtr& descriptorService,
+ const SDPDescriptorCompareServiceImplPtr& comparatorService) :
+ mImplPriv(new ConfigurationServiceImplPriv(descriptorService, comparatorService))
+{
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class GroupVisitor : public FormatsConfigurationGroupVisitor
+ {
+ public:
+ GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) : mImplPriv(implPriv), mGroups(visitorGroups) { };
+
+ private:
+ /**
+ * Internal helper function which determines what configuration items should be returned
+ */
+ void insertRequestedConfigurationItems(const ConfigurationItemDict& requestedItems,
+ const ConfigurationItemDict& localItems,
+ ConfigurationItemDict& returnedItems)
+ {
+
+ boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationItemDict::const_iterator requestedItem = requestedItems.begin();
+ requestedItem != requestedItems.end();
+ ++requestedItem)
+ {
+ ConfigurationItemDict::const_iterator localItem = localItems.find(requestedItem->first);
+
+ if (localItem != localItems.end())
+ {
+ returnedItems.insert((*requestedItem));
+ }
+ }
+ }
+
+ void visitFormatsGroup(const FormatsGroupPtr& group)
+ {
+ if (!mImplPriv->mFormatsGroup)
+ {
+ return;
+ }
+
+ FormatsGroupPtr returnedGroup = new FormatsGroup();
+
+ insertRequestedConfigurationItems(group->configurationItems, mImplPriv->mFormatsGroup->configurationItems, returnedGroup->configurationItems);
+
+ mGroups.push_back(returnedGroup);
+ };
+
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ ConfigurationGroupSeq& mGroups;
+ };
+
+ ConfigurationGroupSeq newGroups;
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+
+ return newGroups;
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class GroupVisitor : public FormatsConfigurationGroupVisitor
+ {
+ public:
+ GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv, ConfigurationGroupSeq& visitorGroups) :
+ mImplPriv(implPriv), mGroups(visitorGroups) { };
+
+ private:
+ void visitFormatsGroup(const FormatsGroupPtr&)
+ {
+ if (!mImplPriv->mFormatsGroup)
+ {
+ return;
+ }
+
+ mGroups.push_back(mImplPriv->mFormatsGroup);
+ };
+
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ ConfigurationGroupSeq& mGroups;
+ };
+
+ ConfigurationGroupSeq newGroups;
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv, newGroups);
+
+ boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+
+ return newGroups;
+}
+
+ConfigurationGroupSeq ConfigurationServiceImpl::getConfigurationGroups(const Ice::Current&)
+{
+ ConfigurationGroupSeq groups;
+
+ boost::shared_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ if (mImplPriv->mFormatsGroup)
+ {
+ FormatsGroupPtr general = new FormatsGroup();
+ groups.push_back(general);
+ }
+
+ return groups;
+}
+
+void ConfigurationServiceImpl::setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class GroupVisitor : public FormatsConfigurationGroupVisitor
+ {
+ public:
+ GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ private:
+ /**
+ * Helper function which performs serial number checking of items
+ */
+ void performSerialCheck(const ConfigurationItemDict& changedItems, const ConfigurationItemDict& localItems,
+ const AsteriskSCF::System::Configuration::V1::ConfigurationGroupPtr& group)
+ {
+ for (ConfigurationItemDict::const_iterator item = changedItems.begin();
+ item != changedItems.end();
+ ++item)
+ {
+ // If serial checking is to be skipped for this item just skip over it
+ if (item->second->serialNumber == -1)
+ {
+ continue;
+ }
+
+ ConfigurationItemDict::const_iterator localItem = localItems.find(item->first);
+
+ if (localItem == localItems.end())
+ {
+ // This is a new item so serial checking does not apply
+ continue;
+ }
+
+ if (item->second->serialNumber < localItem->second->serialNumber)
+ {
+ throw SerialConflict(group, item->second);
+ }
+ }
+ }
+
+ void visitFormatsGroup(const FormatsGroupPtr& group)
+ {
+ if (!mImplPriv->mFormatsGroup)
+ {
+ mImplPriv->mFormatsGroup = new FormatsGroup();
+ }
+ else
+ {
+ performSerialCheck(group->configurationItems, mImplPriv->mFormatsGroup->configurationItems, group);
+ }
+
+ for (ConfigurationItemDict::const_iterator item = group->configurationItems.begin();
+ item != group->configurationItems.end();
+ ++item)
+ {
+ FormatConfigurationItemPtr format;
+
+ if ((format = FormatConfigurationItemPtr::dynamicCast((item->second))))
+ {
+ mImplPriv->mDescriptorService->addFormat(format->name, format->format, format->descriptor);
+ mImplPriv->mComparatorService->addFormat(format->name);
+ }
+
+ mImplPriv->mFormatsGroup->configurationItems.erase(item->first);
+ mImplPriv->mFormatsGroup->configurationItems.insert((*item));
+ }
+ }
+
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
+
+void ConfigurationServiceImpl::removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class GroupVisitor : public FormatsConfigurationGroupVisitor
+ {
+ public:
+ GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ void removeItems(FormatsConfigurationItemVisitor* visitor, ConfigurationItemDict& itemsToRemove,
+ ConfigurationItemDict& localItems)
+ {
+ for (ConfigurationItemDict::const_iterator item = itemsToRemove.begin();
+ item != itemsToRemove.end();
+ ++item)
+ {
+ ConfigurationItemDict::iterator localItem = localItems.find(item->first);
+ if (localItem == localItems.end())
+ {
+ continue;
+ }
+ if (visitor != 0)
+ {
+ item->second->visit(visitor);
+ }
+
+ FormatConfigurationItemPtr format;
+
+ if ((format = FormatConfigurationItemPtr::dynamicCast((localItem->second))))
+ {
+ mImplPriv->mDescriptorService->removeFormat(format->name);
+ mImplPriv->mComparatorService->removeFormat(format->name);
+ }
+
+ localItems.erase(localItem);
+ }
+ }
+
+ void visitFormatsGroup(const FormatsGroupPtr& group)
+ {
+ if (!mImplPriv->mFormatsGroup)
+ {
+ return;
+ }
+
+ removeItems(0, group->configurationItems, mImplPriv->mFormatsGroup->configurationItems);
+ };
+
+ private:
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
+
+void ConfigurationServiceImpl::removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq& groups, const Ice::Current&)
+{
+ class GroupVisitor : public FormatsConfigurationGroupVisitor
+ {
+ public:
+ GroupVisitor(boost::shared_ptr<ConfigurationServiceImplPriv> implPriv) : mImplPriv(implPriv) { };
+
+ private:
+ void visitFormatsGroup(const FormatsGroupPtr&)
+ {
+ if (!mImplPriv->mFormatsGroup)
+ {
+ return;
+ }
+
+ mImplPriv->mDescriptorService->removeAllFormats();
+ mImplPriv->mComparatorService->removeAllFormats();
+
+ mImplPriv->mFormatsGroup = 0;
+ };
+
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+ };
+
+ FormatsConfigurationGroupVisitorPtr v = new GroupVisitor(mImplPriv);
+
+ boost::unique_lock<boost::shared_mutex> lock(mImplPriv->mLock);
+
+ for (ConfigurationGroupSeq::const_iterator group = groups.begin(); group != groups.end(); ++group)
+ {
+ (*group)->visit(v);
+ }
+}
diff --git a/src/MediaFormatGenericConfiguration.h b/src/MediaFormatGenericConfiguration.h
new file mode 100644
index 0000000..5982fc7
--- /dev/null
+++ b/src/MediaFormatGenericConfiguration.h
@@ -0,0 +1,55 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <Ice/Ice.h>
+
+#include <AsteriskSCF/System/Component/ConfigurationIf.h>
+
+#include "MediaFormatGeneric.h"
+
+/*
+ * Private implementation class for ConfigurationServiceImpl.
+ */
+class ConfigurationServiceImplPriv;
+
+/**
+ * Implementation of the configuration service.
+ */
+class ConfigurationServiceImpl : public AsteriskSCF::System::Configuration::V1::ConfigurationService
+{
+public:
+ ConfigurationServiceImpl(const SDPDescriptorServiceImplPtr&, const SDPDescriptorCompareServiceImplPtr&);
+
+ AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationAll(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq getConfigurationGroups(const Ice::Current&);
+ void setConfiguration(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationItems(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+ void removeConfigurationGroups(const AsteriskSCF::System::Configuration::V1::ConfigurationGroupSeq&, const Ice::Current&);
+
+private:
+ /**
+ * Private implementation details.
+ */
+ boost::shared_ptr<ConfigurationServiceImplPriv> mImplPriv;
+};
+
+/**
+ * A typedef which creates a smart pointer type for ConfigurationServiceImpl.
+ */
+typedef IceUtil::Handle<ConfigurationServiceImpl> ConfigurationServiceImplPtr;
commit 9a727a38321226821b3c1dda7ba504a7e824d639
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 20 12:50:32 2011 -0300
Add configuration slice for this component, as well as a python configurator and example configuration file.
diff --git a/config/MediaFormatGeneric.config b/config/MediaFormatGeneric.config
new file mode 100644
index 0000000..7e550d9
--- /dev/null
+++ b/config/MediaFormatGeneric.config
@@ -0,0 +1,14 @@
+# Define a dummy format
+[bob8]
+
+# Type of media this format is for, valid options are audio and video
+type=audio
+
+# RTP payload for this format
+payload=101
+
+# SDP subtype
+subtype=BOB
+
+# Sample rate, obviously
+samplerate=8000
diff --git a/config/MediaFormatGenericConfigurator.py b/config/MediaFormatGenericConfigurator.py
new file mode 100755
index 0000000..7d17d94
--- /dev/null
+++ b/config/MediaFormatGenericConfigurator.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+#
+# Asterisk SCF -- An open-source communications framework.
+#
+# Copyright (C) 2011, Digium, Inc.
+#
+# See http://www.asterisk.org for more information about
+# the Asterisk SCF project. Please do not directly contact
+# any of the maintainers of this project for assistance;
+# the project provides a web site, mailing lists and IRC
+# channels for your use.
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License Version 2. See the LICENSE.txt file
+# at the top of the source tree.
+#
+
+# Rtp configurator
+
+# Bring in the common configuration infrastructure
+import Ice, Configurator, sys
+
+# 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
+
+# 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.configurationItems = { }
+ self.added = False
+
+ def visit_unsupported(self, config, section):
+ format = AsteriskSCF.Media.FormatGeneric.FormatItem()
+ 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.type = config.get(section, 'type')
+ format.descriptor.subtype = config.get(section, 'subtype')
+ format.descriptor.samplerate = config.getint(section, 'samplerate')
+
+ if self.added == False:
+ self.groups.append(self.formats)
+ self.added = True
+
+# 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
+
+# Make a configurator application and let it run
+app = Configurator.ConfiguratorApp('MediaFormatGeneric.config', MediaFormatGenericSectionVisitors(), None, serviceLocatorParams)
+sys.exit(app.main(sys.argv))
diff --git a/local-slice/MediaFormatGenericConfigurationIf.ice b/local-slice/MediaFormatGenericConfigurationIf.ice
new file mode 100644
index 0000000..8d16145
--- /dev/null
+++ b/local-slice/MediaFormatGenericConfigurationIf.ice
@@ -0,0 +1,98 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <Ice/BuiltinSequences.ice>
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.ice>
+#include <AsteriskSCF/System/Component/ConfigurationIf.ice>
+#include <AsteriskSCF/Media/SDP/MediaSDPIf.ice>
+
+module AsteriskSCF
+{
+
+module Media
+{
+
+module FormatGeneric
+{
+
+["suppress"]
+module V1
+{
+ /**
+ * Service locator category for finding the configuration service
+ */
+ const string ConfigurationDiscoveryCategory = "MediaFormatGenericConfiguration";
+
+ /**
+ * Service locator parameters class for discovering the configuration service
+ */
+ unsliceable class ConfigurationParams extends AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams
+ {
+ /**
+ * Unique name for the configuration service
+ */
+ string name;
+ };
+
+ /**
+ * Local visitor class for visiting formats group
+ */
+ local class FormatsConfigurationGroupVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationGroupVisitor
+ {
+ };
+
+ /**
+ * User defined media format configuration group
+ */
+ ["visitor:FormatsConfigurationGroupVisitor"] class FormatsGroup extends AsteriskSCF::System::Configuration::V1::ConfigurationGroup
+ {
+ };
+
+ /**
+ * Local visitor class for visiting format item
+ */
+ local class FormatsConfigurationItemVisitor extends AsteriskSCF::System::Configuration::V1::ConfigurationItemVisitor
+ {
+ };
+
+ /**
+ * Individual format configuration item
+ *
+ * This should be inserted into the group using the unique format name.
+ */
+ ["visitor:FormatsConfigurationItemVisitor"] class FormatConfigurationItem extends AsteriskSCF::System::Configuration::V1::ConfigurationItem
+ {
+ /**
+ * Name of the format.
+ */
+ string name;
+
+ /**
+ * SDP Descriptor containing SDP parameters for the format.
+ */
+ AsteriskSCF::Media::SDP::V1::SDPDescriptor descriptor;
+ };
+
+}; /* module V1 */
+
+}; /* module RTP */
+
+}; /* module Media */
+
+}; /* module Asterisk SCF */
+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb48104..f8ead77 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,6 +7,7 @@ asterisk_scf_slice_include_directories(${API_SLICE_DIR})
asterisk_scf_component_init(mediaformatgenetic)
asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.cpp)
asterisk_scf_component_add_boost_libraries(mediaformatgeneric core thread)
+asterisk_scf_component_add_slice(mediaformatgeneric ../local-slice/MediaFormatGenericConfigurationIf.ice)
asterisk_scf_component_build_icebox(mediaformatgeneric)
target_link_libraries(mediaformatgeneric logging-client)
target_link_libraries(mediaformatgeneric asterisk-scf-api)
commit 424f6070ba77f654b30bf835e093f2921a7d80a4
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Jun 13 17:43:43 2011 -0300
Initial import of the generic media format component.
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..edca8f3
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,4 @@
+asterisk_scf_project(mediaformatgeneric 3.4)
+
+add_subdirectory(src)
+add_subdirectory(test)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..fb48104
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,13 @@
+include_directories(${API_INCLUDE_DIR})
+include_directories(${ice-util-cpp_dir}/include)
+include_directories(${logger_dir}/include)
+
+asterisk_scf_slice_include_directories(${API_SLICE_DIR})
+
+asterisk_scf_component_init(mediaformatgenetic)
+asterisk_scf_component_add_file(mediaformatgeneric MediaFormatGeneric.cpp)
+asterisk_scf_component_add_boost_libraries(mediaformatgeneric core thread)
+asterisk_scf_component_build_icebox(mediaformatgeneric)
+target_link_libraries(mediaformatgeneric logging-client)
+target_link_libraries(mediaformatgeneric asterisk-scf-api)
+asterisk_scf_component_install(mediaformatgeneric)
diff --git a/src/MediaFormatGeneric.cpp b/src/MediaFormatGeneric.cpp
new file mode 100644
index 0000000..1db9884
--- /dev/null
+++ b/src/MediaFormatGeneric.cpp
@@ -0,0 +1,313 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2011, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#include <Ice/Ice.h>
+#include <IceBox/IceBox.h>
+#include <IceUtil/UUID.h>
+
+#include <boost/shared_ptr.hpp>
+
+#include <AsteriskSCF/Core/Discovery/ServiceLocatorIf.h>
+#include <AsteriskSCF/Media/MediaIf.h>
+#include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
+#include <AsteriskSCF/Media/Formats/AudioFormats.h>
+#include <AsteriskSCF/System/Component/ComponentServiceIf.h>
+#include <AsteriskSCF/Logger/IceLogger.h>
+#include <AsteriskSCF/logger.h>
+
+using namespace std;
+using namespace AsteriskSCF::Core::Discovery::V1;
+using namespace AsteriskSCF::Media::V1;
+using namespace AsteriskSCF::Media::SDP::V1;
+using namespace AsteriskSCF::Media::Formats::Audio::V1;
+using namespace AsteriskSCF::System::Component::V1;
+using namespace AsteriskSCF::System::Logging;
+
+namespace
+{
+Logger lg = getLoggerFactory().getLogger("AsteriskSCF.MediaFormatGeneric");
+}
+
+/**
+ * Implementation of the ServiceLocatorParamsCompare class
+ */
+class SDPDescriptorCompareServiceImpl : public ServiceLocatorParamsCompare
+{
+public:
+ bool isSupported(const ServiceLocatorParamsPtr& params, const Ice::Current&)
+ {
+ SDPDescriptorServiceLocatorParamsPtr descriptorParams = SDPDescriptorServiceLocatorParamsPtr::dynamicCast(params);
+
+ if (descriptorParams == 0)
+ {
+ return false;
+ }
+
+ Ice::StringSeq::const_iterator format = std::find(mSupportedFormats.begin(), mSupportedFormats.end(), descriptorParams->name);
+
+ if (format == mSupportedFormats.end())
+ {
+ return false;
+ }
+
+ return true;
+ };
+
+ void addFormat(const std::string& name)
+ {
+ mSupportedFormats.push_back(name);
+ };
+
+private:
+ /**
+ * Supported formats in named form
+ */
+ Ice::StringSeq mSupportedFormats;
+};
+
+/**
+ * Smart pointer for the SDPDescriptorCompareServiceImpl class
+ */
+typedef IceUtil::Handle<SDPDescriptorCompareServiceImpl> SDPDescriptorCompareServiceImplPtr;
+
+/**
+ * Implementation of the SDPDescriptorService class
+ *
+ * Note that this does not have a lock on purpose because the supported formats will not
+ * be changed once the service goes into operation.
+ */
+class SDPDescriptorServiceImpl : public SDPDescriptorService
+{
+public:
+ FormatPtr getNamedFormat(const std::string& name, const Ice::Current&)
+ {
+ std::map<std::string, FormatPtr>::const_iterator format = mNamedFormats.find(name);
+
+ if (format == mNamedFormats.end())
+ {
+ return 0;
+ }
+
+ return format->second;
+ };
+
+ FormatPtr getDescribedFormat(const SDPDescriptorPtr& descriptor, const Ice::Current&)
+ {
+ if (descriptor->payload < 96)
+ {
+ std::map<int, FormatPtr>::iterator format = mPayloadNumberFormats.find(descriptor->payload);
+
+ if (format == mPayloadNumberFormats.end())
+ {
+ return 0;
+ }
+
+ return format->second;
+ }
+ else
+ {
+ std::map<std::string, FormatPtr>::iterator format = mPayloadNameFormats.find(descriptor->subtype);
+
+ if (format == mPayloadNameFormats.end())
+ {
+ return 0;
+ }
+
+ return format->second;
+ }
+
+ // This will never get reached but just in case the compiler is silly...
+ return 0;
+ };
+
+ SDPDescriptorPtr getDescriptor(const FormatPtr& format, const Ice::Current&)
+ {
+ std::map<std::string, SDPDescriptorPtr>::const_iterator descriptor = mFormatDescriptors.find(format->ice_id());
+
+ if (descriptor == mFormatDescriptors.end())
+ {
+ return 0;
+ }
+
+ return descriptor->second;
+ };
+
+ /**
+ * Implementation specific function which adds a format to this descriptor service
+ */
+ void addFormat(const std::string& name, const FormatPtr& format, const SDPDescriptorPtr& descriptor)
+ {
+ mNamedFormats.insert(make_pair(name, format));
+ mFormatDescriptors.insert(make_pair(format->ice_id(), descriptor));
+
+ if (descriptor->payload < 96)
+ {
+ /*
+ * If this is a static payload we store solely on the payload number itself
+ * since some endpoints do not provide a payload name.
+ */
+ mPayloadNumberFormats.insert(make_pair(descriptor->payload, format));
+ }
+ else
... 154 lines suppressed ...
--
asterisk-scf/release/mediaformatgeneric.git
More information about the asterisk-scf-commits
mailing list