[asterisk-scf-commits] asterisk-scf/integration/media_rtp_pjmedia.git branch "modular-transport-refactor" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Jun 9 12:12:48 CDT 2011


branch "modular-transport-refactor" has been updated
       via  54cd52fa82cafdb5fd23aa0ead3ab70f5f4296d3 (commit)
      from  aea9742129a5dadacaef6f891b95e4672c48f592 (commit)

Summary of changes:
 src/PJLibConfiguration.cpp |   38 +++++++++++++++
 src/PJLibConfiguration.h   |   66 +++++++++++++++++++++++++++
 src/PJMediaEnvironment.cpp |   55 ++++++++++++++++++++++
 src/PJMediaEnvironment.h   |  108 ++++++++++++++++++++++++++++++++++++++++++++
 src/PJUtil.h               |   49 ++++++++++++++++++++
 5 files changed, 316 insertions(+), 0 deletions(-)
 create mode 100644 src/PJLibConfiguration.cpp
 create mode 100644 src/PJLibConfiguration.h
 create mode 100644 src/PJMediaEnvironment.cpp
 create mode 100644 src/PJMediaEnvironment.h
 create mode 100644 src/PJUtil.h


- Log -----------------------------------------------------------------
commit 54cd52fa82cafdb5fd23aa0ead3ab70f5f4296d3
Author: Brent Eagles <beagles at digium.com>
Date:   Thu Jun 9 14:42:39 2011 -0230

    Add missing files.

diff --git a/src/PJLibConfiguration.cpp b/src/PJLibConfiguration.cpp
new file mode 100644
index 0000000..ae25b7d
--- /dev/null
+++ b/src/PJLibConfiguration.cpp
@@ -0,0 +1,38 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 "PJLibConfiguration.h"
+#include <Ice/Properties.h>
+
+using namespace std;
+using namespace AsteriskSCF::PJMediaRTP;
+
+PJLibConfigurationPtr AsteriskSCF::PJMediaRTP::PJLibConfiguration::create(const Ice::PropertiesPtr& props,
+        const string& propertyPrefix)
+{
+    string prefix(propertyPrefix);
+    if (!prefix.empty() && *(--prefix.end()) != '.')
+    {
+        prefix  += '.';
+    }
+    int timerHeapSize = props->getPropertyAsIntWithDefault(prefix + "TimerHeap.Size", 1000); 
+    return PJLibConfigurationPtr(new PJLibConfiguration(timerHeapSize));
+}
+
+PJLibConfiguration::PJLibConfiguration(int heapSize) :
+    mTimerHeapSize(heapSize)
+{
+}
diff --git a/src/PJLibConfiguration.h b/src/PJLibConfiguration.h
new file mode 100644
index 0000000..85ee8c6
--- /dev/null
+++ b/src/PJLibConfiguration.h
@@ -0,0 +1,66 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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/PropertiesF.h>
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+namespace AsteriskSCF
+{
+namespace PJMediaRTP
+{
+
+/**
+ *
+ * PJLibConfiguration is fairly minimal at the moment, but may grow in the future. The intent is to reduce code
+ * duplication when dealing with pjproject related configuration. This is also an immutable object, so locking is not an
+ * issue.
+ *
+ **/
+class PJLibConfiguration
+{
+public:
+
+    int timerHeapSize() const
+    {
+        return mTimerHeapSize;
+    }
+
+    /**
+     * Create configuration instance from Ice properties.  TODO: This could be extended by adding additional factory
+     * overrides.
+     **/
+    static boost::shared_ptr<PJLibConfiguration> create(const Ice::PropertiesPtr& props,
+            const std::string& propertyPrefix);
+
+private:
+    int mTimerHeapSize;
+
+    PJLibConfiguration(int timerHeapSize);
+
+    //
+    // Hidden, not implemented.
+    //
+    PJLibConfiguration(const PJLibConfiguration&);
+    void operator=(const PJLibConfiguration&);
+};
+
+typedef boost::shared_ptr<PJLibConfiguration> PJLibConfigurationPtr;
+
+} /* end of namespace PJMediaRTP */
+} /* End of namespace AsteriskSCF */
diff --git a/src/PJMediaEnvironment.cpp b/src/PJMediaEnvironment.cpp
new file mode 100644
index 0000000..2abde30
--- /dev/null
+++ b/src/PJMediaEnvironment.cpp
@@ -0,0 +1,55 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 "PJMediaEnvironment.h"
+#include <Ice/Properties.h>
+#include <pjlib.h>
+#include <pjmedia.h>
+#include <pjnath.h>
+#include "PJUtil.h"
+#include <AsteriskSCF/System/ExceptionsIf.h>
+
+using namespace std;
+using namespace AsteriskSCF::PJMediaRTP;
+using namespace AsteriskSCF::System::V1;
+using namespace AsteriskSCF::PJUtil;
+
+//
+// The main work of creating the various objects is done by the factory, not the PJMediaEnvironment constructor.
+//
+PJMediaEnvironmentPtr AsteriskSCF::PJMediaRTP::PJMediaEnvironment::create(const Ice::PropertiesPtr& props,
+        const string& propertyPrefix)
+{
+    return PJMediaEnvironmentPtr(
+        new PJMediaEnvironment(PJLibConfiguration::create(props, propertyPrefix)));
+}
+        
+PJMediaEnvironment::PJMediaEnvironment(const PJLibConfigurationPtr& libCfg) :
+    mPJLibConfig(libCfg),
+    mCachingPool(new pj_caching_pool)
+{
+    //
+    // I find this practice a little sketchy since the pointers that might be retrieve through the accessors *must* not be
+    // used outside of the scope of this object's lifetime.
+    //
+    pj_caching_pool_init(mCachingPool.get(), & pj_pool_factory_default_policy, 0);
+    mPoolFactory = &(mCachingPool->factory);
+    
+    //
+    // TODO: should these values come from configuration.
+    //
+    mMemoryPool = pj_pool_create(mPoolFactory, "media_rtp_pjmedia", 1024, 1024, 0);
+}
diff --git a/src/PJMediaEnvironment.h b/src/PJMediaEnvironment.h
new file mode 100644
index 0000000..b6a85f8
--- /dev/null
+++ b/src/PJMediaEnvironment.h
@@ -0,0 +1,108 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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 "PJLibConfiguration.h"
+
+#include <Ice/PropertiesF.h>
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+//
+// Forward declarations.
+//
+struct pj_pool_factory;
+struct pjmedia_endpt;
+struct pj_pool_t;
+struct pj_caching_pool;
+
+namespace AsteriskSCF
+{
+namespace PJMediaRTP
+{
+
+class PJMediaEnvironment;
+typedef boost::shared_ptr<PJMediaEnvironment> PJMediaEnvironmentPtr;
+
+/**
+ *
+ * PJMediaEnvironment pulls together all of the different configuration modules for the current pjproject library
+ * features. Objects that need this info should use these accessors instead of caching their own copies. The
+ * PJMediaEnvironment can be updated with new configuration without affecting operations in progress. In progress
+ * operations will simply use the version of the configuration that was available when it started. The exception to this
+ * guideline is if there are multiple operations in a small scope that need a consistent version of the
+ * configuration. In this case, that operation should keep a scope-local copy for the duration of those operations. This
+ * can extend to AMI operations.
+ *
+ * PJMediaEnvironment provides accessors for the pool and pool factory used in so many pjX related operations. This
+ * prevents having pj related details peppered throughout the method signatures.
+ *
+ * Generally speaking this object should be instantiated when the service is loaded *or* as soon as the relevant
+ * configuration becomes available.
+ *
+ **/
+class PJMediaEnvironment
+{
+public:
+
+    /**
+     * Get generic configuration object.
+     */
+    PJLibConfigurationPtr libConfig() const
+    {
+        return mPJLibConfig;
+    }
+
+    /**
+     * Get our library instance's main pool factory. As this function does not return a reference counted pointer, its
+     * value should not be cached at all. It's validity is directly related to the lifetime of the PJMediaEnvironment
+     * object.
+     */
+    pj_pool_factory* poolFactory() const
+    {
+        return mPoolFactory;
+    }
+    
+    /**
+     * Get the main memory pool. As this function does not return a reference counted pointer, its value should
+     * not be cached at all. It's validity is directly related to the lifetime of the PJMediaEnvironment object.
+     */
+    pj_pool_t* memoryPool() const
+    {
+        return mMemoryPool;
+    }
+
+    /**
+     * Create an instance of the object based on the Ice properties.
+     *
+     * XXX: This needs to be extended to work with the configuration service.
+     */
+    static PJMediaEnvironmentPtr create(const Ice::PropertiesPtr& props, const std::string& prefix);
+
+private:
+
+    PJLibConfigurationPtr mPJLibConfig;
+
+    pj_pool_factory* mPoolFactory;
+    pj_pool_t* mMemoryPool;
+    boost::shared_ptr<pj_caching_pool> mCachingPool;
+
+    PJMediaEnvironment(const PJLibConfigurationPtr& libConfig);
+};
+
+} /* End of namespace PJMediaRTP */
+} /* End of namespace AsteriskSCF */
diff --git a/src/PJUtil.h b/src/PJUtil.h
new file mode 100644
index 0000000..2794652
--- /dev/null
+++ b/src/PJUtil.h
@@ -0,0 +1,49 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, 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
+
+#ifdef _WIN32
+#pragma warning(push)
+#pragma warning(disable: 4267 4244)
+#endif
+
+#include <pjlib.h>
+
+#ifdef _WIN32
+#pragma warning(pop)
+#endif
+
+namespace AsteriskSCF
+{
+namespace PJUtil
+{
+
+/**
+ * Simple result checking functions overloaded on pj_status_t result type.
+ **/
+inline bool success(pj_status_t r)
+{
+    return r == PJ_SUCCESS;
+}
+
+inline bool fail(pj_status_t r)
+{
+    return !success(r);
+}
+
+} /* End of namespace PJUtil */
+} /* End of namespace AsteriskSCF */

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


-- 
asterisk-scf/integration/media_rtp_pjmedia.git



More information about the asterisk-scf-commits mailing list