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

opalplugin.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: opalplugin.h,v $
00027  * Revision 1.3.4.1  2005/02/07 00:41:31  csoutheren
00028  * Backported patches from Atlas-devel
00029  *
00030  * Revision 1.5  2004/12/20 23:30:20  csoutheren
00031  * Added plugin support for packet loss concealment frames
00032  *
00033  * Revision 1.4  2004/11/29 06:30:53  csoutheren
00034  * Added support for wideband codecs
00035  *
00036  * Revision 1.3  2004/05/18 22:26:28  csoutheren
00037  * Initial support for embedded codecs
00038  * Fixed problems with streamed codec support
00039  * Updates for abstract factory loading methods
00040  *
00041  * Revision 1.2  2004/05/09 14:44:36  csoutheren
00042  * Added support for streamed plugin audio codecs
00043  *
00044  * Revision 1.1  2004/04/09 12:25:25  csoutheren
00045  * Renamed from h323plugin.h
00046  *
00047  * Revision 1.2  2004/04/03 10:38:24  csoutheren
00048  * Added in initial cut at codec plugin code. Branches are for wimps :)
00049  *
00050  * Revision 1.1.2.1  2004/03/31 11:03:16  csoutheren
00051  * Initial public version
00052  *
00053  * Revision 1.8  2004/02/23 13:17:32  craigs
00054  * Fixed problems with codec interface functions
00055  *
00056  * Revision 1.7  2004/02/23 13:04:09  craigs
00057  * Removed warnings when compliing plugins
00058  *
00059  * Revision 1.6  2004/01/27 14:55:46  craigs
00060  * Implemented static linking of new codecs
00061  *
00062  * Revision 1.5  2004/01/23 05:21:15  craigs
00063  * Updated for changes to the codec plugin interface
00064  *
00065  * Revision 1.4  2004/01/09 11:27:46  craigs
00066  * Plugin codec audio now works :)
00067  *
00068  * Revision 1.3  2004/01/09 07:32:22  craigs
00069  * More fixes for capability problems
00070  *
00071  * Revision 1.2  2004/01/06 07:05:03  craigs
00072  * Changed to support plugin codecs
00073  *
00074  * Revision 1.1  2004/01/04 13:37:51  craigs
00075  * Implementation of codec plugins
00076  *
00077  *
00078  */
00079 
00080 #ifndef __OPAL_H323PLUGIN_H
00081 #define __OPAL_H323PLUGIN_H
00082 
00083 #ifdef __cplusplus
00084 extern "C" {
00085 #endif
00086 
00087 #include <time.h>
00088 
00089 #ifdef _WIN32
00090 #  ifdef PLUGIN_CODEC_DLL_EXPORTS
00091 #    define PLUGIN_CODEC_DLL_API __declspec(dllexport)
00092 #  else
00093 #    define PLUGIN_CODEC_DLL_API __declspec(dllimport)
00094 #  endif
00095 
00096 #else
00097 
00098 #define PLUGIN_CODEC_DLL_API
00099 
00100 #endif
00101 
00102 #define PWLIB_PLUGIN_API_VERSION 0
00103 
00104 #define PLUGIN_CODEC_VERSION                     1    // initial version
00105 #define PLUGIN_CODEC_VERSION_WIDEBAND            2    // added wideband
00106 
00107 #define PLUGIN_CODEC_API_VER_FN       PWLibPlugin_GetAPIVersion
00108 #define PLUGIN_CODEC_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
00109 
00110 #define PLUGIN_CODEC_GET_CODEC_FN     OpalCodecPlugin_GetCodecs
00111 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
00112 
00113 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
00114 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00115 { return PWLIB_PLUGIN_API_VERSION; }
00116 
00117 enum {
00118   PluginCodec_Licence_None                           = 0,
00119   PluginCodec_License_GPL                            = 1,
00120   PluginCodec_License_MPL                            = 2,
00121   PluginCodec_License_Freeware                       = 3,
00122   PluginCodec_License_ResearchAndDevelopmentUseOnly  = 4,
00123   PluginCodec_License_BSD                            = 5,
00124 
00125   PluginCodec_License_NoRoyalties                    = 0x7f,
00126 
00127   // any license codes above here require royalty payments
00128   PluginCodec_License_RoyaltiesRequired              = 0x80
00129 };
00130 
00131 struct PluginCodec_information {
00132   // start of version 1 fields
00133   time_t timestamp;                     // codec creation time and date - obtain with command: date -u "+%c = %s"
00134 
00135   const char * sourceAuthor;            // source code author
00136   const char * sourceVersion;           // source code version
00137   const char * sourceEmail;             // source code email contact information
00138   const char * sourceURL;               // source code web site
00139   const char * sourceCopyright;         // source code copyright
00140   const char * sourceLicense;           // source code license
00141   unsigned char sourceLicenseCode;      // source code license
00142 
00143   const char * codecDescription;        // codec description
00144   const char * codecAuthor;             // codec author
00145   const char * codecVersion;            // codec version
00146   const char * codecEmail;              // codec email contact information
00147   const char * codecURL;                // codec web site
00148   const char * codecCopyright;          // codec copyright information
00149   const char * codecLicense;            // codec license
00150   unsigned short codecLicenseCode;      // codec license code
00151   // end of version 1 fields
00152 
00153 };
00154 
00155 enum PluginCodec_Flags {
00156   PluginCodec_MediaTypeMask          = 0x000f,
00157   PluginCodec_MediaTypeAudio         = 0x0000,
00158   PluginCodec_MediaTypeVideo         = 0x0001,
00159   PluginCodec_MediaTypeAudioStreamed = 0x0002,
00160 
00161   PluginCodec_InputTypeMask          = 0x0010,
00162   PluginCodec_InputTypeRaw           = 0x0000,
00163   PluginCodec_InputTypeRTP           = 0x0010,
00164 
00165   PluginCodec_OutputTypeMask         = 0x0020,
00166   PluginCodec_OutputTypeRaw          = 0x0000,
00167   PluginCodec_OutputTypeRTP          = 0x0020,
00168 
00169   PluginCodec_RTPTypeMask            = 0x0040,
00170   PluginCodec_RTPTypeDynamic         = 0x0000,
00171   PluginCodec_RTPTypeExplicit        = 0x0040,
00172 
00173   PluginCodec_RTPSharedMask          = 0x0080,
00174   PluginCodec_RTPTypeNotShared       = 0x0000,
00175   PluginCodec_RTPTypeShared          = 0x0080,
00176 
00177   PluginCodec_DecodeSilenceMask      = 0x0100,
00178   PluginCodec_NoDecodeSilence        = 0x0000,
00179   PluginCodec_DecodeSilence          = 0x0100,
00180 
00181   PluginCodec_BitsPerSamplePos       = 12,
00182   PluginCodec_BitsPerSampleMask      = 0xf000,
00183 };
00184 
00185 enum PluginCodec_CoderFlags {
00186   PluginCodec_CoderSilenceFrame      = 1
00187 };
00188 
00189 struct PluginCodec_Definition;
00190 
00191 struct PluginCodec_ControlDefn {
00192   const char * name;
00193   int (*control)(const struct PluginCodec_Definition * codec, void * context, 
00194                  const char * name, void * parm, unsigned * parmLen);
00195  
00196 };
00197 
00198 struct PluginCodec_Definition {
00199   unsigned int version;                                // codec structure version
00200 
00201   // start of version 1 fields
00202   struct PluginCodec_information * info;   // license information
00203 
00204   unsigned int flags;                      // b0-3: 0 = audio,        1 = video
00205                                            // b4:   0 = raw input,    1 = RTP input
00206                                            // b5:   0 = raw output,   1 = RTP output
00207                                            // b6:   0 = dynamic RTP,  1 = explicit RTP
00208                                            // b7:   0 = no share RTP, 1 = share RTP
00209 
00210   const char * descr;                                  // text decription
00211 
00212   const char * sourceFormat;               // source format
00213   const char * destFormat;                 // destination format
00214 
00215   const void * userData;                   // user data value
00216 
00217   unsigned int sampleRate;                 // samples per second
00218   unsigned int bitsPerSec;                       // raw bits per second
00219   unsigned int nsPerFrame;                 // nanoseconds per frame
00220   unsigned int samplesPerFrame;                  // samples per frame
00221   unsigned int bytesPerFrame;              // max bytes per frame
00222   unsigned int recommendedFramesPerPacket; // recommended number of frames per packet
00223   unsigned int maxFramesPerPacket;         // maximum number of frames per packet
00224 
00225   unsigned char rtpPayload;                      // IANA RTP payload code (if defined)
00226   const char * sdpFormat;                  // SDP format string (or NULL, if no SDP format)
00227 
00228   void * (*createCodec)(const struct PluginCodec_Definition * codec);                     // create codec 
00229   void (*destroyCodec) (const struct PluginCodec_Definition * codec,  void * context);  // destroy codec
00230   int (*codecFunction) (const struct PluginCodec_Definition * codec,  void * context,   // do codec function
00231                                   const void * from, unsigned * fromLen,
00232                                         void * to,   unsigned * toLen,
00233                                         unsigned int * flag);
00234   struct PluginCodec_ControlDefn * codecControls;
00235  
00236   // H323 specific fields
00237   unsigned char h323CapabilityType;
00238   void          * h323CapabilityData;
00239 
00240   // end of version 1 fields
00241 };
00242 
00243 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
00244 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
00245 
00247 //
00248 //  H.323 specific values
00249 //
00250 
00251 
00252 struct PluginCodec_H323CapabilityExtension {
00253   unsigned int index;
00254   void * data;
00255   unsigned dataLength;
00256 };
00257 
00258 struct PluginCodec_H323NonStandardCodecData {
00259   const char * objectId;
00260   unsigned char  t35CountryCode;
00261   unsigned char  t35Extension;
00262   unsigned short manufacturerCode;
00263   const unsigned char * data;
00264   unsigned int dataLength;
00265   int (*capabilityMatchFunction)(struct PluginCodec_H323NonStandardCodecData *);
00266 };
00267     
00268 struct PluginCodec_H323AudioGSMData {
00269   int comfortNoise:1;
00270   int scrambled:1;
00271 };
00272 
00273 struct  PluginCodec_H323AudioG7231AnnexC {
00274   unsigned char maxAl_sduAudioFrames;
00275   int silenceSuppression:1;
00276   int highRateMode0:6;                // INTEGER (27..78),      -- units octets
00277   int   highRateMode1:6;                // INTEGER (27..78),    -- units octets
00278   int   lowRateMode0:6;                 // INTEGER (23..66),    -- units octets
00279   int   lowRateMode1:6;                 // INTEGER (23..66),    -- units octets
00280   int   sidMode0:4;                         // INTEGER (6..17), -- units octets
00281   int   sidMode1:4;                         // INTEGER (6..17), -- units octets
00282 };
00283 
00284 struct PluginCodec_H323VideoH261
00285 {
00286   int qcifMPI:2;                         //     INTEGER (1..4) OPTIONAL,        -- units 1/29.97 Hz
00287   int cifMPI:2;                                // INTEGER (1..4) OPTIONAL,      -- units 1/29.97 Hz
00288         int temporalSpatialTradeOffCapability; //       BOOLEAN,
00289         int maxBitRate;                        //       INTEGER (1..19200),     -- units of 100 bit/s
00290   int stillImageTransmission:1;          //     BOOLEAN,        -- Annex D of H.261
00291   int videoBadMBsCap:1;                  //     BOOLEAN
00292   const struct PluginCodec_H323CapabilityExtension * extensions;
00293 };
00294 
00295 enum {
00296   PluginCodec_H323Codec_undefined,                      // must be zero, so empty struct is undefined
00297   PluginCodec_H323Codec_programmed,                     // H323ProgrammedCapability
00298   PluginCodec_H323Codec_nonStandard,            // H323NonStandardData
00299   PluginCodec_H323Codec_generic,        // not yet implemented
00300 
00301   // audio codecs
00302   PluginCodec_H323AudioCodec_g711Alaw_64k,                  // int
00303   PluginCodec_H323AudioCodec_g711Alaw_56k,                  // int
00304   PluginCodec_H323AudioCodec_g711Ulaw_64k,                  // int
00305   PluginCodec_H323AudioCodec_g711Ulaw_56k,                  // int
00306   PluginCodec_H323AudioCodec_g722_64k,                        // int
00307   PluginCodec_H323AudioCodec_g722_56k,                        // int
00308   PluginCodec_H323AudioCodec_g722_48k,                        // int
00309   PluginCodec_H323AudioCodec_g7231,                               // H323AudioG7231Data
00310   PluginCodec_H323AudioCodec_g728,                                // int
00311   PluginCodec_H323AudioCodec_g729,                                // int
00312   PluginCodec_H323AudioCodec_g729AnnexA,                      // int
00313   PluginCodec_H323AudioCodec_is11172,             // not yet implemented
00314   PluginCodec_H323AudioCodec_is13818Audio,        // not yet implemented
00315   PluginCodec_H323AudioCodec_g729wAnnexB,                     // int
00316   PluginCodec_H323AudioCodec_g729AnnexAwAnnexB,   // int
00317   PluginCodec_H323AudioCodec_g7231AnnexC,         // H323AudioG7231AnnexC
00318   PluginCodec_H323AudioCodec_gsmFullRate,                     // H323AudioGSMData
00319   PluginCodec_H323AudioCodec_gsmHalfRate,                     // H323AudioGSMData
00320   PluginCodec_H323AudioCodec_gsmEnhancedFullRate,       // H323AudioGSMData
00321   PluginCodec_H323AudioCodec_g729Extensions,      // not yet implemented
00322 
00323   // video codecs
00324   PluginCodec_H323VideoCodec_h261,                // not yet implemented 
00325   PluginCodec_H323VideoCodec_h262,                // not yet implemented
00326   PluginCodec_H323VideoCodec_h263,                // not yet implemented
00327   PluginCodec_H323VideoCodec_is11172,             // not yet implemented
00328 };
00329 
00330 
00331 
00332 #ifdef OPAL_STATIC_CODEC
00333 
00334 #  undef PLUGIN_CODEC_DLL_API
00335 #  define PLUGIN_CODEC_DLL_API static
00336 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00337 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
00338 { return PWLIB_PLUGIN_API_VERSION; } \
00339 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
00340 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
00341 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
00342 
00343 #else
00344 
00345 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00346 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00347 { return PWLIB_PLUGIN_API_VERSION; } \
00348 
00349 #endif
00350 
00351 #ifdef __cplusplus
00352 };
00353 #endif
00354 
00355 #endif

Generated on Mon Sep 26 15:44:49 2005 for OpenH323 by  doxygen 1.4.4