Author: sayer
Date: 2009-02-18 17:42:39 +0100 (Wed, 18 Feb 2009)
New Revision: 1287

Modified:
   branches/wb/core/AmConfig.cpp
   branches/wb/core/AmPlugIn.cpp
   branches/wb/core/AmPlugIn.h
   branches/wb/core/etc/sems.conf.sample
Log:
wb: exclude_payloads for certain samplerates (implements SEMS-49)

Modified: branches/wb/core/AmConfig.cpp
===================================================================
--- branches/wb/core/AmConfig.cpp       2009-02-18 16:26:50 UTC (rev 1286)
+++ branches/wb/core/AmConfig.cpp       2009-02-18 16:42:39 UTC (rev 1287)
@@ -207,7 +207,7 @@
   // exclude_plugins
   ExcludePlugins = cfg.getParameter("exclude_plugins");
 
-  // exclude_plugins
+  // exclude_payloads
   ExcludePayloads = cfg.getParameter("exclude_payloads");
 
   // user_agent

Modified: branches/wb/core/AmPlugIn.cpp
===================================================================
--- branches/wb/core/AmPlugIn.cpp       2009-02-18 16:26:50 UTC (rev 1286)
+++ branches/wb/core/AmPlugIn.cpp       2009-02-18 16:42:39 UTC (rev 1287)
@@ -126,8 +126,19 @@
     explode(AmConfig::ExcludePayloads, ";");
   for (vector<string>::iterator it = 
         excluded_payloads_v.begin(); 
-       it != excluded_payloads_v.end();it++)
-    excluded_payloads.insert(*it);
+       it != excluded_payloads_v.end();it++) {
+    vector<string> e = explode(*it, "/");
+    if (e.size()==1) {
+      excluded_payloads.insert(make_pair(*it, 0));
+    } else if (e.size()==2) {
+      unsigned int rate = 0;
+      str2i(e[1], rate);
+      excluded_payloads.insert(make_pair(e[0], rate));   
+    } else {
+      ERROR("deciphering excluded payload '%s'\n",
+           it->c_str());
+    }      
+  }
 
   DBG("adding built-in codecs...\n");
   addCodec(&_codec_pcm16);
@@ -656,10 +667,12 @@
 
 int AmPlugIn::addPayload(amci_payload_t* p)
 {
-  if (excluded_payloads.find(p->name) != 
-      excluded_payloads.end()) {
-    DBG("Not enabling excluded payload '%s'\n", 
-       p->name);
+  if ((excluded_payloads.find(std::make_pair(p->name, p->sample_rate)) != 
+       excluded_payloads.end()) || 
+      (excluded_payloads.find(std::make_pair(p->name, 0)) != 
+       excluded_payloads.end())) {
+    DBG("Not enabling excluded payload '%s'/%d\n", 
+       p->name, p->sample_rate);
     return 0;
   }
 

Modified: branches/wb/core/AmPlugIn.h
===================================================================
--- branches/wb/core/AmPlugIn.h 2009-02-18 16:26:50 UTC (rev 1286)
+++ branches/wb/core/AmPlugIn.h 2009-02-18 16:42:39 UTC (rev 1287)
@@ -2,7 +2,7 @@
  * $Id$
  *
  * Copyright (C) 2002-2003 Fhg Fokus
- * Copyright (C) 2006 iptego GmbH
+ * Copyright (C) 2006-2009 iptego GmbH
  *
  * This file is part of sems, a free SIP media server.
  *
@@ -33,8 +33,10 @@
 #include <map>
 #include <vector>
 #include <set>
+#include <utility>
 using std::string;
 using std::vector;
+using std::pair;
 
 class AmPluginFactory;
 class AmSessionFactory;
@@ -102,7 +104,7 @@
   AmCtrlInterfaceFactory *ctrlIface;
 
   int dynamic_pl; // range: 96->127, see RFC 1890
-  std::set<string> excluded_payloads;  // don't load these payloads (named)
+  std::set<pair<string, unsigned int> > excluded_payloads;  // don't load 
these payloads (named)
     
   AmPlugIn();
   virtual ~AmPlugIn();

Modified: branches/wb/core/etc/sems.conf.sample
===================================================================
--- branches/wb/core/etc/sems.conf.sample       2009-02-18 16:26:50 UTC (rev 
1286)
+++ branches/wb/core/etc/sems.conf.sample       2009-02-18 16:42:39 UTC (rev 
1287)
@@ -119,6 +119,8 @@
 #  exclude_payloads=iLBC;speex;
 # only use G711 (exclude everything else):
 #  exclude_payloads=iLBC;speex;G726-40;G726-32;G721;G726-24;G726-16;GSM;L16
+# or exclude some narrowband codecs:
+#  exclude_payloads=PCMU/8000;PCMA/8000;L16/8000;
 
 # optional parameter: rtp_low_port=<port>
 #

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to