Author: sayer
Date: 2009-02-18 17:26:50 +0100 (Wed, 18 Feb 2009)
New Revision: 1286

Modified:
   branches/wb/core/AmConfig.cpp
   branches/wb/core/AmConfig.h
   branches/wb/core/AmPlugIn.cpp
   branches/wb/core/etc/sems.conf.sample
Log:
adding sample rate to codec_order


Modified: branches/wb/core/AmConfig.cpp
===================================================================
--- branches/wb/core/AmConfig.cpp       2009-02-17 21:30:15 UTC (rev 1285)
+++ branches/wb/core/AmConfig.cpp       2009-02-18 16:26:50 UTC (rev 1286)
@@ -68,7 +68,7 @@
 unsigned int AmConfig::SessionLimitErrCode     = 503;
 string       AmConfig::SessionLimitErrReason   = "Server overload";
 
-vector <string> AmConfig::CodecOrder;
+vector <pair<string, unsigned int> > AmConfig::CodecOrder;
 
 Dtmf::InbandDetectorType 
 AmConfig::DefaultDTMFDetector     = Dtmf::SEMSInternal;
@@ -325,8 +325,25 @@
   }
 
   // codec_order
-  CodecOrder = explode(cfg.getParameter("codec_order"), ",");
+  vector<string> CodecOrderEntries = 
+    explode(cfg.getParameter("codec_order"), ",");
 
+  // todo: stereo
+  for (vector<string>::iterator it=
+        CodecOrderEntries.begin(); it != CodecOrderEntries.end(); it++) {
+    vector<string> co_entry = explode(*it, "/");
+    if (co_entry.size() == 1)
+      CodecOrder.push_back(make_pair(co_entry[0], 0));
+    else if (co_entry.size() == 2) {
+      unsigned int co_rate = 0;
+      str2i(co_entry[1], co_rate);
+      CodecOrder.push_back(make_pair(co_entry[0], co_rate));
+    }  else {
+      ERROR("undecipherable codec_order entry '%s'\n",
+           it->c_str());
+    }
+  }
+
   // dead_rtp_time
   if(cfg.hasParameter("dead_rtp_time")){
     if(!setDeadRtpTime(cfg.getParameter("dead_rtp_time"))){

Modified: branches/wb/core/AmConfig.h
===================================================================
--- branches/wb/core/AmConfig.h 2009-02-17 21:30:15 UTC (rev 1285)
+++ branches/wb/core/AmConfig.h 2009-02-18 16:26:50 UTC (rev 1286)
@@ -34,6 +34,7 @@
 #include <string>
 using std::string;
 #include <utility>
+using std::pair;
 
 #include <sys/types.h>
 #include <regex.h>
@@ -90,7 +91,7 @@
   static string Signature;
   /** If 200 OK reply should be limited to preferred codec only */
   static bool SingleCodecInOK;
-  static vector <string> CodecOrder;
+  static vector <pair<string, unsigned int> > CodecOrder;
   
   enum ApplicationSelector {
     App_RURIUSER,

Modified: branches/wb/core/AmPlugIn.cpp
===================================================================
--- branches/wb/core/AmPlugIn.cpp       2009-02-17 21:30:15 UTC (rev 1285)
+++ branches/wb/core/AmPlugIn.cpp       2009-02-18 16:26:50 UTC (rev 1286)
@@ -685,8 +685,13 @@
   }
 
   for (i = 0; i < AmConfig::CodecOrder.size(); i++) {
-      if (p->name == AmConfig::CodecOrder[i]) break;
+    if (((p->name == AmConfig::CodecOrder[i].first) && 
+        ((unsigned int)p->sample_rate == AmConfig::CodecOrder[i].second)) ||
+       ((p->name == AmConfig::CodecOrder[i].first) && 
+        (0 == AmConfig::CodecOrder[i].second)))
+       break;
   }
+
   if (i >= AmConfig::CodecOrder.size()) {
       payload_order.insert(std::make_pair(id + 100, id));
       DBG("payload '%s'/%d inserted with id %i and order %i\n",

Modified: branches/wb/core/etc/sems.conf.sample
===================================================================
--- branches/wb/core/etc/sems.conf.sample       2009-02-17 21:30:15 UTC (rev 
1285)
+++ branches/wb/core/etc/sems.conf.sample       2009-02-18 16:26:50 UTC (rev 
1286)
@@ -262,7 +262,7 @@
 #
 # single_codec_in_ok=no
 
-# optional parameter: codec_order=codec_name_1,codec_name2,...
+# optional parameter: codec_order=codec_name_1[/codec_rate_1],codec_name2,...
 #
 # - Codec order used when sending INVITE requests.  Codecs in codec_order
 #   will be on the top of the list followed by other supported codecs
@@ -270,6 +270,9 @@
 #
 #   default=empty
 #
+# to prefer wideband codecs:
+#  codec_order=L16/16000,PCMU/16000,PCMA/16000,g722/16000
+#
 # codec_order=iLBC,GSM
 
 # optional parameter: ignore_rtpxheaders={yes|no}

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

Reply via email to