AmPlugIn.h

Go to the documentation of this file.
00001 /*
00002  * $Id: AmPlugIn.h 817 2008-03-19 13:26:03Z sayer $
00003  *
00004  * Copyright (C) 2002-2003 Fhg Fokus
00005  * Copyright (C) 2006 iptego GmbH
00006  *
00007  * This file is part of sems, a free SIP media server.
00008  *
00009  * sems is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * For a license to use the ser software under conditions
00015  * other than those described here, or to purchase support for this
00016  * software, please contact iptel.org by e-mail at the following addresses:
00017  *    info@iptel.org
00018  *
00019  * sems is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License 
00025  * along with this program; if not, write to the Free Software 
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  */
00029 #ifndef _AmPlugIn_h_
00030 #define _AmPlugIn_h_
00031 
00032 #include <string>
00033 #include <map>
00034 #include <vector>
00035 #include <set>
00036 using std::string;
00037 using std::vector;
00038 
00039 class AmPluginFactory;
00040 class AmSessionFactory;
00041 class AmSessionEventHandlerFactory;
00042 class AmDynInvokeFactory;
00043 class AmSIPEventHandler;
00044 class AmLoggingFacility;
00045 class AmCtrlInterfaceFactory;
00046 
00047 struct amci_exports_t;
00048 struct amci_codec_t;
00049 struct amci_payload_t;
00050 struct amci_inoutfmt_t;
00051 struct amci_subtype_t;
00052 
00054 class AmPayloadProviderInterface {
00055  public: 
00056   AmPayloadProviderInterface() { }
00057   virtual ~AmPayloadProviderInterface() { }
00058   
00064   virtual amci_payload_t*  payload(int payload_id) = 0;
00065 
00071   virtual int getDynPayload(const string& name, int rate, int encoding_param) = 0;
00072 };
00073 
00077 class AmPlugIn : public AmPayloadProviderInterface
00078 {
00079  public:
00080   //     enum PlugInType {
00081   //       Audio,
00082   //       App
00083   //     };
00084 
00085  private:
00086   static AmPlugIn* _instance;
00087 
00088   vector<void*> dlls;
00089 
00090   std::map<int,amci_codec_t*>       codecs;
00091   std::map<int,amci_payload_t*>     payloads;
00092   std::map<int,int>                 payload_order;
00093   std::map<string,amci_inoutfmt_t*> file_formats;
00094   std::map<string,AmSessionFactory*>  name2app;
00095 
00096   std::map<string,AmSessionEventHandlerFactory*> name2seh;
00097   std::map<string,AmPluginFactory*> name2base;
00098   std::map<string,AmDynInvokeFactory*> name2di;
00099   std::map<string,AmSIPEventHandler*> name2sipeh;
00100   std::map<string,AmLoggingFacility*> name2logfac;
00101   AmCtrlInterfaceFactory *ctrlIface;
00102 
00103   int dynamic_pl; // range: 96->127, see RFC 1890
00104   std::set<string> excluded_payloads;  // don't load these payloads (named)
00105     
00106   AmPlugIn();
00107   virtual ~AmPlugIn();
00108 
00110   int loadPlugIn(const string& file);
00111 
00112   int loadAudioPlugIn(amci_exports_t* exports);
00113   int loadAppPlugIn(AmPluginFactory* cb);
00114   int loadSehPlugIn(AmPluginFactory* cb);
00115   int loadBasePlugIn(AmPluginFactory* cb);
00116   int loadDiPlugIn(AmPluginFactory* cb);
00117   int loadSIPehPlugIn(AmPluginFactory* f);
00118   int loadLogFacPlugIn(AmPluginFactory* f);
00119   int loadCtrlFacPlugIn(AmPluginFactory* f);
00120 
00121  public:
00122 
00123   int addCodec(amci_codec_t* c);
00124   int addPayload(amci_payload_t* p);
00125   int addFileFormat(amci_inoutfmt_t* f);
00126 
00127   static AmPlugIn* instance();
00128 
00129   void init();
00130 
00135   int load(const string& directory, const string& plugins);
00136 
00142   amci_payload_t*  payload(int payload_id);
00143 
00149   int getDynPayload(const string& name, int rate, int encoding_param);
00150 
00152   const std::map<int,amci_payload_t*>& getPayloads() { return payloads; }
00154   const std::map<int,int>& getPayloadOrder() { return payload_order; }
00162   amci_inoutfmt_t* fileFormat(const string& fmt_name, const string& ext = "");
00169   amci_subtype_t*  subtype(amci_inoutfmt_t* iofmt, int subtype);
00175   amci_codec_t*    codec(int id);
00181   AmSessionFactory* getFactory4App(const string& app_name);
00182 
00188   AmSessionEventHandlerFactory* getFactory4Seh(const string& name);
00189 
00193   AmDynInvokeFactory* getFactory4Di(const string& name);
00194 
00200   AmSIPEventHandler* getFactory4SIPeh(const string& name);
00201 
00207   AmLoggingFacility* getFactory4LogFaclty(const string& name);
00208 
00210   bool registerFactory4App(const string& app_name, AmSessionFactory* f);
00211 };
00212 
00213 #endif

Generated on Fri May 16 12:02:05 2008 for SEMS by  doxygen 1.5.1
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login