config option to selectively exclude some payloads (=codecs)

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@600 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 19 years ago
parent cf26b15dbf
commit 943509231e

@ -44,6 +44,7 @@ unsigned int AmConfig::SmtpServerPort = SMTP_PORT;
string AmConfig::PlugInPath = PLUG_IN_PATH;
string AmConfig::LoadPlugins = "";
string AmConfig::ExcludePlugins = "";
string AmConfig::ExcludePayloads = "";
int AmConfig::DaemonMode = DEFAULT_DAEMON_MODE;
string AmConfig::LocalIP = "";
string AmConfig::PrefixSep = PREFIX_SEPARATOR;
@ -192,6 +193,9 @@ int AmConfig::readConfiguration()
// exclude_plugins
ExcludePlugins = cfg.getParameter("exclude_plugins");
// exclude_plugins
ExcludePayloads = cfg.getParameter("exclude_payloads");
// user_agent
if (cfg.getParameter("use_default_signature")=="yes")
Signature = DEFAULT_SIGNATURE;

@ -58,6 +58,8 @@ struct AmConfig
static string LoadPlugins;
/** semicolon separated list of plugins to exclude from loading */
static string ExcludePlugins;
/** semicolon separated list of payloads to exclude from loading */
static string ExcludePayloads;
//static unsigned int MaxRecordTime;
/** run the programm in daemon mode? */
static int DaemonMode;

@ -101,13 +101,9 @@ amci_payload_t _payload_tevent = {
AmPlugIn* AmPlugIn::_instance=0;
AmPlugIn::AmPlugIn()
: dynamic_pl(DYNAMIC_PAYLOAD_TYPE_START)
: dynamic_pl(DYNAMIC_PAYLOAD_TYPE_START),
ctrlIface(NULL)
{
DBG("adding built-in codecs...\n");
addCodec(&_codec_pcm16);
addCodec(&_codec_tevent);
addPayload(&_payload_tevent);
ctrlIface = NULL;
}
AmPlugIn::~AmPlugIn()
@ -124,6 +120,20 @@ AmPlugIn* AmPlugIn::instance()
return _instance;
}
void AmPlugIn::init() {
vector<string> excluded_payloads_v =
explode(AmConfig::ExcludePayloads, ";");
for (vector<string>::iterator it =
excluded_payloads_v.begin();
it != excluded_payloads_v.end();it++)
excluded_payloads.insert(*it);
DBG("adding built-in codecs...\n");
addCodec(&_codec_pcm16);
addCodec(&_codec_tevent);
addPayload(&_payload_tevent);
}
int AmPlugIn::load(const string& directory, const string& plugins)
{
@ -621,10 +631,18 @@ int AmPlugIn::addCodec(amci_codec_t* c)
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);
return 0;
}
amci_codec_t* c;
unsigned int i, id;
if( !(c = codec(p->codec_id)) ){
ERROR("in payload '%s': codec id (%i) not supported\n",p->name,p->codec_id);
ERROR("in payload '%s': codec id (%i) not supported\n",
p->name, p->codec_id);
return -1;
}
if(p->payload_id != -1){

@ -32,9 +32,11 @@
#include <string>
#include <map>
#include <vector>
#include <set>
using std::string;
using std::map;
using std::vector;
using std::set;
class AmPluginFactory;
class AmSessionFactory;
@ -80,6 +82,7 @@ class AmPlugIn
AmCtrlInterface *ctrlIface;
int dynamic_pl; // range: 96->127, see RFC 1890
set<string> excluded_payloads; // don't load these payloads (named)
AmPlugIn();
~AmPlugIn();
@ -104,6 +107,8 @@ class AmPlugIn
static AmPlugIn* instance();
void init();
/**
* Loads all plug-ins from the directory given as parameter.
* @return -1 if failed, else 0.

@ -67,6 +67,19 @@ plugin_path=/usr/local/lib/sems/plug-in/
#
exclude_plugins=binrpcctrl;
# optional parameter: exclude_payloads=<payload list>
#
# semicolon-separated list of payloads to exclude from loading
# ('blacklist').
#
# For example, to only use low bandwidth codecs:
# exclude_payloads=PCMU;PCMA;G726-40;G726-32;G721;
# or, to use only codecs which are not CPU-intensive:
# exclude_payloads=iLBC;speex;
# only use G711 (exclude everything else):
# exclude_payloads=iLBC;speex;G726-40;G726-32;G721;G726-24;G726-16;GSM
# optional parameter: smtp_server=<hostname>
#
# - sets address of smtp server

@ -361,6 +361,7 @@ int main(int argc, char* argv[])
return -1;
DBG("Loading plug-ins\n");
AmPlugIn::instance()->init();
if(AmPlugIn::instance()->load(AmConfig::PlugInPath, AmConfig::LoadPlugins))
return -1;

Loading…
Cancel
Save