OpenH323 1.18.0
h323pluginmgr.h
Go to the documentation of this file.
00001 /*
00002  * h323plugins.h
00003  *
00004  * H.323 codec plugins handler
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (C) 2004 Post Increment
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Post Increment
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: h323pluginmgr.h,v $
00027  * Revision 1.24  2005/11/30 13:05:01  csoutheren
00028  * Changed tags for Doxygen
00029  *
00030  * Revision 1.23  2005/06/21 06:46:35  csoutheren
00031  * Add ability to create capabilities without codecs for external RTP interface
00032  *
00033  * Revision 1.22  2005/04/28 04:00:15  dereksmithies
00034  * Add documentation to the OpalFactoryCodec. Thanks to Craig Southeren for clarifying
00035  * the meaning of the toLen field.
00036  *
00037  * Revision 1.21  2005/01/04 08:08:39  csoutheren
00038  * More changes to implement the new configuration methodology, and also to
00039  * attack the global static problem
00040  *
00041  * Revision 1.20  2005/01/03 14:03:20  csoutheren
00042  * Added new configure options and ability to disable/enable modules
00043  *
00044  * Revision 1.19  2004/12/08 02:03:58  csoutheren
00045  * Fixed problem with detection of non-FFH.263
00046  *
00047  * Revision 1.18  2004/11/29 06:30:51  csoutheren
00048  * Added support for wideband codecs
00049  *
00050  * Revision 1.17  2004/08/26 08:05:02  csoutheren
00051  * Codecs now appear in abstract factory system
00052  * Fixed Windows factory bootstrap system (again)
00053  *
00054  * Revision 1.16  2004/06/30 12:31:09  rjongbloed
00055  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00056  *   of issues with startup orders and Windows DLL multiple instances.
00057  *
00058  * Revision 1.15  2004/06/03 23:20:46  csoutheren
00059  * Fixed compile problem on some gcc variants
00060  *
00061  * Revision 1.14  2004/06/01 07:30:27  csoutheren
00062  * Removed accidental cut & paste in new code that removed capabilities
00063  *
00064  * Revision 1.13  2004/06/01 05:49:27  csoutheren
00065  * Added code to cleanup some allocated memory upon shutdown
00066  *
00067  * Revision 1.12  2004/05/23 12:40:34  rjongbloed
00068  * Simplified call for getting H323 plug manager instance
00069  *
00070  * Revision 1.11  2004/05/18 23:03:10  csoutheren
00071  * Added empty destructor to prevent gcc 3.3.3 from getting link errors.
00072  *
00073  * Revision 1.10  2004/05/18 22:32:54  csoutheren
00074  * Added pragma inteface
00075  *
00076  * Revision 1.9  2004/05/18 22:26:28  csoutheren
00077  * Initial support for embedded codecs
00078  * Fixed problems with streamed codec support
00079  * Updates for abstract factory loading methods
00080  *
00081  * Revision 1.8  2004/05/18 06:02:25  csoutheren
00082  * Deferred plugin codec loading until after main has executed by using abstract factory classes
00083  *
00084  * Revision 1.7  2004/05/12 13:41:26  csoutheren
00085  * Added support for getting lists of media formats from plugin manager
00086  *
00087  * Revision 1.6  2004/04/22 22:35:00  csoutheren
00088  * Fixed mispelling of Guilhem Tardy - my apologies to him
00089  *
00090  * Revision 1.5  2004/04/22 14:22:20  csoutheren
00091  * Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet
00092  * Many thanks to them for their contributions.
00093  *
00094  * Revision 1.4  2004/04/14 08:14:40  csoutheren
00095  * Changed to use generic plugin manager
00096  *
00097  * Revision 1.3  2004/04/09 12:24:18  csoutheren
00098  * Renamed h323plugin.h to opalplugin.h, and modified everything else
00099  * as required
00100  *
00101  * Revision 1.2  2004/04/03 10:38:24  csoutheren
00102  * Added in initial cut at codec plugin code. Branches are for wimps :)
00103  *
00104  * Revision 1.1.2.1  2004/03/31 11:03:16  csoutheren
00105  * Initial public version
00106  *
00107  * Revision 1.2  2004/01/27 14:55:46  craigs
00108  * Implemented static linking of new codecs
00109  *
00110  * Revision 1.1  2004/01/04 13:37:51  craigs
00111  * Implementation of codec plugins
00112  *
00113  *
00114  */
00115 
00116 #ifndef __OPAL_H323PLUGINMGR_H
00117 #define __OPAL_H323PLUGINMGR_H
00118 
00119 #ifdef P_USE_PRAGMA
00120 #pragma interface
00121 #endif
00122 
00123 #include <ptlib/pluginmgr.h>
00124 #include <opalplugin.h>
00125 #include <mediafmt.h>
00126 #include <ptlib/pfactory.h>
00127 
00128 class H323Capability;
00129 
00130 class H323PluginCodecManager : public PPluginModuleManager
00131 {
00132   PCLASSINFO(H323PluginCodecManager, PPluginModuleManager);
00133   public:
00134     H323PluginCodecManager(PPluginManager * pluginMgr = NULL);
00135     ~H323PluginCodecManager();
00136 
00137     void RegisterStaticCodec(const char * name,
00138                              PluginCodec_GetAPIVersionFunction getApiVerFn,
00139                              PluginCodec_GetCodecFunction getCodecFn);
00140 
00141     void OnLoadPlugin(PDynaLink & dll, INT code);
00142 
00143     static OpalMediaFormat::List GetMediaFormats();
00144     static void AddFormat(const OpalMediaFormat & fmt);
00145     static void AddFormat(OpalMediaFormat * fmt);
00146 
00147     virtual void OnShutdown();
00148 
00149     static void Bootstrap();
00150 
00151     H323Capability * CreateCapability(
00152           const PString & _mediaFormat, 
00153           const PString & _baseName,
00154                  unsigned maxFramesPerPacket, 
00155                  unsigned recommendedFramesPerPacket,
00156                  unsigned _pluginSubType);
00157 
00158   protected:
00159     void CreateCapabilityAndMediaFormat(
00160       PluginCodec_Definition * _encoderCodec,
00161       PluginCodec_Definition * _decoderCodec
00162     );
00163 
00164     static OpalMediaFormat::List & GetMediaFormatList();
00165     static PMutex & GetMediaFormatMutex();
00166 
00167     void RegisterCodecs  (unsigned int count, void * codecList);
00168     void UnregisterCodecs(unsigned int count, void * codecList);
00169 };
00170 
00171 class H323DynaLink : public PDynaLink
00172 {
00173   PCLASSINFO(H323DynaLink, PDynaLink)
00174     
00175  public:
00176   H323DynaLink(const char * basename, const char * reason = NULL);
00177 
00178   virtual void Load();
00179   virtual BOOL IsLoaded()
00180   { PWaitAndSignal m(processLock); return isLoadedOK; }
00181   virtual BOOL LoadPlugin (const PString & fileName);
00182 
00183 protected:
00184   PMutex processLock;
00185   BOOL isLoadedOK;
00186   const char * baseName;
00187   const char * reason;
00188 };
00189 
00191 //
00192 //  this is the base class for codecs accesible via the abstract factory functions
00193 //
00194 
00202 class OpalFactoryCodec : public PObject {
00203   PCLASSINFO(OpalFactoryCodec, PObject)
00204   public:
00206     virtual const struct PluginCodec_Definition * GetDefinition()
00207     { return NULL; }
00208 
00210     virtual PString GetInputFormat() const = 0;
00211 
00213     virtual PString GetOutputFormat() const = 0;
00214 
00216     virtual int Encode(const void * from,      
00217                          unsigned * fromLen,   
00218                              void * to,        
00219                                  unsigned * toLen,     
00220                      unsigned int * flag       
00221                        ) = 0;  
00222 
00224     virtual unsigned int GetSampleRate() const = 0;
00225 
00227     virtual unsigned int GetBitsPerSec() const = 0;
00228 
00230     virtual unsigned int GetFrameTime() const = 0;
00231 
00233     virtual unsigned int GetSamplesPerFrame() const = 0;
00234 
00236     virtual unsigned int GetBytesPerFrame() const = 0;
00237 
00239     virtual unsigned int GetRecommendedFramesPerPacket() const = 0;
00240 
00242     virtual unsigned int GetMaxFramesPerPacket() const = 0;
00243 
00245     virtual BYTE         GetRTPPayload() const = 0;
00246 
00248     virtual PString      GetSDPFormat() const = 0;
00249 };
00250 
00251 #endif