Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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.17.2.1  2005/02/07 00:41:30  csoutheren
00028  * Backported patches from Atlas-devel
00029  *
00030  * Revision 1.19  2004/12/08 02:03:58  csoutheren
00031  * Fixed problem with detection of non-FFH.263
00032  *
00033  * Revision 1.18  2004/11/29 06:30:51  csoutheren
00034  * Added support for wideband codecs
00035  *
00036  * Revision 1.17  2004/08/26 08:05:02  csoutheren
00037  * Codecs now appear in abstract factory system
00038  * Fixed Windows factory bootstrap system (again)
00039  *
00040  * Revision 1.16  2004/06/30 12:31:09  rjongbloed
00041  * Rewrite of plug in system to use single global variable for all factories to avoid all sorts
00042  *   of issues with startup orders and Windows DLL multiple instances.
00043  *
00044  * Revision 1.15  2004/06/03 23:20:46  csoutheren
00045  * Fixed compile problem on some gcc variants
00046  *
00047  * Revision 1.14  2004/06/01 07:30:27  csoutheren
00048  * Removed accidental cut & paste in new code that removed capabilities
00049  *
00050  * Revision 1.13  2004/06/01 05:49:27  csoutheren
00051  * Added code to cleanup some allocated memory upon shutdown
00052  *
00053  * Revision 1.12  2004/05/23 12:40:34  rjongbloed
00054  * Simplified call for getting H323 plug manager instance
00055  *
00056  * Revision 1.11  2004/05/18 23:03:10  csoutheren
00057  * Added empty destructor to prevent gcc 3.3.3 from getting link errors.
00058  *
00059  * Revision 1.10  2004/05/18 22:32:54  csoutheren
00060  * Added pragma inteface
00061  *
00062  * Revision 1.9  2004/05/18 22:26:28  csoutheren
00063  * Initial support for embedded codecs
00064  * Fixed problems with streamed codec support
00065  * Updates for abstract factory loading methods
00066  *
00067  * Revision 1.8  2004/05/18 06:02:25  csoutheren
00068  * Deferred plugin codec loading until after main has executed by using abstract factory classes
00069  *
00070  * Revision 1.7  2004/05/12 13:41:26  csoutheren
00071  * Added support for getting lists of media formats from plugin manager
00072  *
00073  * Revision 1.6  2004/04/22 22:35:00  csoutheren
00074  * Fixed mispelling of Guilhem Tardy - my apologies to him
00075  *
00076  * Revision 1.5  2004/04/22 14:22:20  csoutheren
00077  * Added RFC 2190 H.263 code as created by Guilhem Tardy and AliceStreet
00078  * Many thanks to them for their contributions.
00079  *
00080  * Revision 1.4  2004/04/14 08:14:40  csoutheren
00081  * Changed to use generic plugin manager
00082  *
00083  * Revision 1.3  2004/04/09 12:24:18  csoutheren
00084  * Renamed h323plugin.h to opalplugin.h, and modified everything else
00085  * as required
00086  *
00087  * Revision 1.2  2004/04/03 10:38:24  csoutheren
00088  * Added in initial cut at codec plugin code. Branches are for wimps :)
00089  *
00090  * Revision 1.1.2.1  2004/03/31 11:03:16  csoutheren
00091  * Initial public version
00092  *
00093  * Revision 1.2  2004/01/27 14:55:46  craigs
00094  * Implemented static linking of new codecs
00095  *
00096  * Revision 1.1  2004/01/04 13:37:51  craigs
00097  * Implementation of codec plugins
00098  *
00099  *
00100  */
00101 
00102 #ifndef __OPAL_H323PLUGINMGR_H
00103 #define __OPAL_H323PLUGINMGR_H
00104 
00105 #ifdef P_USE_PRAGMA
00106 #pragma interface
00107 #endif
00108 
00109 #include <ptlib/pluginmgr.h>
00110 #include <opalplugin.h>
00111 #include <mediafmt.h>
00112 #include <ptlib/pfactory.h>
00113 
00114 namespace PWLibStupidLinkerHacks {
00115 
00116 #ifndef NO_H323_VIDEO
00117 extern int h261Loader;
00118 extern int rfc2190h263Loader;
00119 #endif
00120 
00121 extern int opalwavfileLoader;
00122 
00123 extern void H323BootStrapPlugins();
00124 extern void H323BootStrapNonPlugins();
00125 
00126 } // namespace PWLibStupidLinkerHacks
00127 
00128 
00129 class H323PluginCodecManager : public PPluginModuleManager
00130 {
00131   PCLASSINFO(H323PluginCodecManager, PPluginModuleManager);
00132   public:
00133     H323PluginCodecManager(PPluginManager * pluginMgr = NULL);
00134     ~H323PluginCodecManager();
00135 
00136     void RegisterStaticCodec(const char * name,
00137                              PluginCodec_GetAPIVersionFunction getApiVerFn,
00138                              PluginCodec_GetCodecFunction getCodecFn);
00139 
00140     void OnLoadPlugin(PDynaLink & dll, INT code);
00141 
00142     static OpalMediaFormat::List GetMediaFormats();
00143     static void AddFormat(const OpalMediaFormat & fmt);
00144     static void AddFormat(OpalMediaFormat * fmt);
00145 
00146     virtual void OnShutdown();
00147 
00148   protected:
00149     void CreateCapabilityAndMediaFormat(
00150       PluginCodec_Definition * _encoderCodec,
00151       PluginCodec_Definition * _decoderCodec
00152     );
00153 
00154     static OpalMediaFormat::List & GetMediaFormatList();
00155     static PMutex & GetMediaFormatMutex();
00156 
00157     void RegisterCodecs  (unsigned int count, void * codecList);
00158     void UnregisterCodecs(unsigned int count, void * codecList);
00159 
00160     friend void PWLibStupidLinkerHacks::H323BootStrapPlugins();
00161 };
00162 
00163 class H323DynaLink : public PDynaLink
00164 {
00165   PCLASSINFO(H323DynaLink, PDynaLink)
00166     
00167  public:
00168   H323DynaLink(const char * basename, const char * reason = NULL);
00169 
00170   virtual void Load();
00171   virtual BOOL IsLoaded()
00172   { PWaitAndSignal m(processLock); return isLoadedOK; }
00173   virtual BOOL LoadPlugin (const PString & fileName);
00174 
00175 protected:
00176   PMutex processLock;
00177   BOOL isLoadedOK;
00178   const char * baseName;
00179   const char * reason;
00180 };
00181 
00183 //
00184 //  this is the base class for codecs accesible via the abstract factory functions
00185 //
00186 
00187 class OpalFactoryCodec : public PObject {
00188   PCLASSINFO(OpalFactoryCodec, PObject)
00189   public:
00190     virtual const struct PluginCodec_Definition * GetDefinition()
00191     { return NULL; }
00192 
00193     virtual PString GetInputFormat() const = 0;
00194     virtual PString GetOutputFormat() const = 0;
00195 
00196     virtual int Encode(const void * from, unsigned * fromLen,
00197                              void * to,   unsigned * toLen,
00198                      unsigned int * flag) = 0;
00199 
00200     virtual unsigned int GetSampleRate() const = 0;
00201     virtual unsigned int GetBitsPerSec() const = 0;
00202     virtual unsigned int GetFrameTime() const = 0;
00203     virtual unsigned int GetSamplesPerFrame() const = 0;
00204     virtual unsigned int GetBytesPerFrame() const = 0;
00205     virtual unsigned int GetRecommendedFramesPerPacket() const = 0;
00206     virtual unsigned int GetMaxFramesPerPacket() const = 0;
00207     virtual BYTE         GetRTPPayload() const = 0;
00208     virtual PString      GetSDPFormat() const = 0;
00209 };
00210 
00211 #endif

Generated on Sat Mar 5 14:59:06 2005 for OpenH323 by  doxygen 1.4.1