opalplugin.h

Go to the documentation of this file.
00001 /*
00002  * opalplugins.h
00003  *
00004  * OPAL codec plugins handler
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (C) 2004-2006 Post Increment
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Post Increment
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Log: opalplugin.h,v $
00028  * Revision 2.16  2007/10/08 01:45:16  rjongbloed
00029  * Fixed bad virtual function causing uninitialised variable whcih prevented video from working.
00030  * Some more clean ups.
00031  *
00032  * Revision 2.15  2007/09/24 07:05:44  rjongbloed
00033  * Added some extra RTP magic numbers: min header size, max packet size etc
00034  *
00035  * Revision 2.14  2007/09/04 02:21:20  rjongbloed
00036  * Allow for plug in API versions other than zero.
00037  *
00038  * Revision 2.13  2007/09/04 02:05:03  rjongbloed
00039  * Fixed benign warning trace on API level for codec plug ins.
00040  *
00041  * Revision 2.12  2007/08/10 09:04:57  rjongbloed
00042  * Fixed numerous spelling errors.
00043  * Added extra symbols for backward compatibility.
00044  * Removed unused (and commented out) code.
00045  *
00046  * Revision 2.11  2007/06/27 12:29:45  rjongbloed
00047  * Add new OpalMediaOption for octet strings (simple block of bytes).
00048  *
00049  * Revision 2.10  2007/06/22 17:58:30  csoutheren
00050  * Added explicit names to union in plugin defn for gcc
00051  *
00052  * Revision 2.9  2007/06/22 05:41:47  rjongbloed
00053  * Major codec API update:
00054  *   Automatically map OpalMediaOptions to SIP/SDP FMTP parameters.
00055  *   Automatically map OpalMediaOptions to H.245 Generic Capability parameters.
00056  *   Largely removed need to distinguish between SIP and H.323 codecs.
00057  *   New mechanism for setting OpalMediaOptions from within a plug in.
00058  *
00059  * Revision 2.8  2007/05/15 09:39:37  rjongbloed
00060  * Fixed various OIDs for H.245 generic capabilities.
00061  * Added G.722.2 OID for H.245 generic capabilities.
00062  * Changed the H.323 capability "extra info" pointer to be const.
00063  *
00064  * Revision 2.7  2007/03/12 23:17:04  csoutheren
00065  * Add new code plugins types (backport from OpenH323)
00066  *
00067  * Revision 2.6  2006/11/01 06:57:23  csoutheren
00068  * Fixed usage of YUV frame header
00069  *
00070  * Revision 2.5  2006/10/17 13:04:36  shorne
00071  * comments were accidently truncated
00072  *
00073  * Revision 2.4  2006/10/17 04:09:08  shorne
00074  * Corrected generic parameter identifiers & added generic codec identifiers
00075  *
00076  * Revision 2.3  2006/10/02 13:30:50  rjongbloed
00077  * Added LID plug ins
00078  *
00079  * Revision 2.2  2006/08/11 07:52:00  csoutheren
00080  * Fix problem with media format factory in VC 2005
00081  * Fixing problems with Speex codec
00082  * Remove non-portable usages of PFactory code
00083  *
00084  * Revision 2.1  2006/07/24 14:03:38  csoutheren
00085  * Merged in audio and video plugins from CVS branch PluginBranch
00086  *
00087  * Revision 1.1.2.4  2006/04/24 09:09:37  csoutheren
00088  * Added LGPL license
00089  *
00090  * Revision 1.1.2.3  2006/04/19 07:52:30  csoutheren
00091  * Add ability to have SIP-only and H.323-only codecs, and implement for H.261
00092  *
00093  * Revision 1.1.2.2  2006/04/06 01:21:16  csoutheren
00094  * More implementation of video codec plugins
00095  *
00096  * Revision 1.1.2.1  2006/03/16 07:06:00  csoutheren
00097  * Initial support for audio plugins
00098  *
00099  * Revision 1.9  2005/11/21 21:04:10  shorne
00100  * Added more HID input switches
00101  *
00102  * Revision 1.8  2005/08/23 08:13:06  shorne
00103  * Added HID plugin volume & LCD display support
00104  *
00105  * Revision 1.7  2005/07/03 13:54:23  shorne
00106  * Added Initial LID Plugin Support
00107  *
00108  * Revision 1.6  2005/06/07 03:22:22  csoutheren
00109  * Added patch 1198741 with support for plugin codecs with generic capabilities
00110  * Added patch 1198754 with support for setting quality level on audio codecs
00111  * Added patch 1198760 with GSM-AMR codec support
00112  * Many thanks to Richard van der Hoff for his work
00113  *
00114  * Revision 1.5  2004/12/20 23:30:20  csoutheren
00115  * Added plugin support for packet loss concealment frames
00116  *
00117  * Revision 1.4  2004/11/29 06:30:53  csoutheren
00118  * Added support for wideband codecs
00119  *
00120  * Revision 1.3  2004/05/18 22:26:28  csoutheren
00121  * Initial support for embedded codecs
00122  * Fixed problems with streamed codec support
00123  * Updates for abstract factory loading methods
00124  *
00125  * Revision 1.2  2004/05/09 14:44:36  csoutheren
00126  * Added support for streamed plugin audio codecs
00127  *
00128  * Revision 1.1  2004/04/09 12:25:25  csoutheren
00129  * Renamed from h323plugin.h
00130  *
00131  * Revision 1.2  2004/04/03 10:38:24  csoutheren
00132  * Added in initial cut at codec plugin code. Branches are for wimps :)
00133  *
00134  * Revision 1.1.2.1  2004/03/31 11:03:16  csoutheren
00135  * Initial public version
00136  *
00137  * Revision 1.8  2004/02/23 13:17:32  craigs
00138  * Fixed problems with codec interface functions
00139  *
00140  * Revision 1.7  2004/02/23 13:04:09  craigs
00141  * Removed warnings when compliing plugins
00142  *
00143  * Revision 1.6  2004/01/27 14:55:46  craigs
00144  * Implemented static linking of new codecs
00145  *
00146  * Revision 1.5  2004/01/23 05:21:15  craigs
00147  * Updated for changes to the codec plugin interface
00148  *
00149  * Revision 1.4  2004/01/09 11:27:46  craigs
00150  * Plugin codec audio now works :)
00151  *
00152  * Revision 1.3  2004/01/09 07:32:22  craigs
00153  * More fixes for capability problems
00154  *
00155  * Revision 1.2  2004/01/06 07:05:03  craigs
00156  * Changed to support plugin codecs
00157  *
00158  * Revision 1.1  2004/01/04 13:37:51  craigs
00159  * Implementation of codec plugins
00160  *
00161  *
00162  */
00163 
00164 #ifndef __OPAL_CODECPLUGIN_H
00165 #define __OPAL_CODECPLUGIN_H
00166 
00167 #ifdef __cplusplus
00168 extern "C" {
00169 #endif
00170 
00171 #include <time.h>
00172 
00173 #ifdef _MSC_VER
00174 #pragma warning(disable:4201)
00175 #endif
00176 
00177 #ifdef _WIN32
00178 #  ifdef PLUGIN_CODEC_DLL_EXPORTS
00179 #    define PLUGIN_CODEC_DLL_API __declspec(dllexport)
00180 #  else
00181 #    define PLUGIN_CODEC_DLL_API __declspec(dllimport)
00182 #  endif
00183 
00184 #else
00185 
00186 #define PLUGIN_CODEC_DLL_API
00187 
00188 #endif
00189 
00190 #ifdef PWLIB_PLUGIN_API_VERSION
00191 #undef PWLIB_PLUGIN_API_VERSION
00192 #endif
00193 #define PWLIB_PLUGIN_API_VERSION 1
00194 
00195 #define  PLUGIN_CODEC_VERSION           1    // initial version
00196 #define  PLUGIN_CODEC_VERSION_WIDEBAND  2    // added wideband
00197 #define  PLUGIN_CODEC_VERSION_VIDEO     3    // added video
00198 #define  PLUGIN_CODEC_VERSION_FAX       4    // added fax
00199 #define  PLUGIN_CODEC_VERSION_OPTIONS   5    // added options handling
00200 
00201 #define PLUGIN_CODEC_API_VER_FN       PWLibPlugin_GetAPIVersion
00202 #define PLUGIN_CODEC_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
00203 
00204 #define PLUGIN_CODEC_GET_CODEC_FN     OpalCodecPlugin_GetCodecs
00205 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
00206 
00207 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
00208 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00209 { return PWLIB_PLUGIN_API_VERSION; }
00210 
00211 enum {
00212   PluginCodec_License_None                           = 0,
00213   PluginCodec_Licence_None = PluginCodec_License_None,        // allow for old code with misspelled constant
00214   PluginCodec_License_GPL                            = 1,
00215   PluginCodec_License_MPL                            = 2,
00216   PluginCodec_License_Freeware                       = 3,
00217   PluginCodec_License_ResearchAndDevelopmentUseOnly  = 4,
00218   PluginCodec_License_BSD                            = 5,
00219   PluginCodec_License_LGPL                           = 6,
00220 
00221   PluginCodec_License_NoRoyalties                    = 0x7f,
00222 
00223   // any license codes above here require royalty payments
00224   PluginCodec_License_RoyaltiesRequired              = 0x80
00225 };
00226 
00227 struct PluginCodec_information {
00228   // start of version 1 fields
00229   time_t timestamp;                     // codec creation time and date - obtain with command: date -u "+%c = %s"
00230 
00231   const char * sourceAuthor;            // source code author
00232   const char * sourceVersion;           // source code version
00233   const char * sourceEmail;             // source code email contact information
00234   const char * sourceURL;               // source code web site
00235   const char * sourceCopyright;         // source code copyright
00236   const char * sourceLicense;           // source code license
00237   unsigned char sourceLicenseCode;      // source code license
00238 
00239   const char * codecDescription;        // codec description
00240   const char * codecAuthor;             // codec author
00241   const char * codecVersion;            // codec version
00242   const char * codecEmail;              // codec email contact information
00243   const char * codecURL;                // codec web site
00244   const char * codecCopyright;          // codec copyright information
00245   const char * codecLicense;            // codec license
00246   unsigned short codecLicenseCode;      // codec license code
00247   // end of version 1 fields
00248 
00249 };
00250 
00251 enum PluginCodec_Flags {
00252   PluginCodec_MediaTypeMask          = 0x000f,
00253   PluginCodec_MediaTypeAudio         = 0x0000,
00254   PluginCodec_MediaTypeVideo         = 0x0001,
00255   PluginCodec_MediaTypeAudioStreamed = 0x0002,
00256   PluginCodec_MediaTypeFax           = 0x0003,
00257   PluginCodec_MediaTypeExtVideo      = 0x0004,
00258 
00259   PluginCodec_InputTypeMask          = 0x0010,
00260   PluginCodec_InputTypeRaw           = 0x0000,
00261   PluginCodec_InputTypeRTP           = 0x0010,
00262 
00263   PluginCodec_OutputTypeMask         = 0x0020,
00264   PluginCodec_OutputTypeRaw          = 0x0000,
00265   PluginCodec_OutputTypeRTP          = 0x0020,
00266 
00267   PluginCodec_RTPTypeMask            = 0x0040,
00268   PluginCodec_RTPTypeDynamic         = 0x0000,
00269   PluginCodec_RTPTypeExplicit        = 0x0040,
00270 
00271   PluginCodec_RTPSharedMask          = 0x0080,
00272   PluginCodec_RTPTypeNotShared       = 0x0000,
00273   PluginCodec_RTPTypeShared          = 0x0080,
00274 
00275   PluginCodec_DecodeSilenceMask      = 0x0100,
00276   PluginCodec_NoDecodeSilence        = 0x0000,
00277   PluginCodec_DecodeSilence          = 0x0100,
00278 
00279   PluginCodec_EncodeSilenceMask      = 0x0200,
00280   PluginCodec_NoEncodeSilence        = 0x0000,
00281   PluginCodec_EncodeSilence          = 0x0200,
00282 
00283   PluginCodec_BitsPerSamplePos       = 12,
00284   PluginCodec_BitsPerSampleMask      = 0xf000,
00285 };
00286 
00287 enum PluginCodec_CoderFlags {
00288   PluginCodec_CoderSilenceFrame      = 1,    // request audio codec to create silence frame
00289   PluginCodec_CoderForceIFrame       = 2     // request video codec to force I frame
00290 };
00291 
00292 enum PluginCodec_ReturnCoderFlags {
00293   PluginCodec_ReturnCoderLastFrame     = 1,    // indicates when video codec returns last data for frame
00294   PluginCodec_ReturnCoderIFrame        = 2,    // indicates when video returns I frame
00295   PluginCodec_ReturnCoderRequestIFrame = 4     // indicates when video decoder request I frame for resync
00296 };
00297 
00298 struct PluginCodec_Definition;
00299 
00300 // Control function names
00301 
00302 #define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL    "valid_for_protocol"
00303 #define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS     "get_codec_options"
00304 #define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS    "free_codec_options"
00305 #define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE  "get_output_data_size"
00306 #define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS     "set_codec_options"
00307 #define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS "to_normalised_options"
00308 #define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS "to_customised_options"
00309 #define PLUGINCODEC_CONTROL_SET_INSTANCE_ID       "set_instance_id"
00310 
00311 
00312 struct PluginCodec_ControlDefn {
00313   const char * name;
00314   int (*control)(const struct PluginCodec_Definition * codec, void * context,
00315                  const char * name, void * parm, unsigned * parmLen);
00316 
00317 };
00318 
00319 enum PluginCodec_OptionTypes {
00320   PluginCodec_StringOption,
00321   PluginCodec_BoolOption,
00322   PluginCodec_IntegerOption,
00323   PluginCodec_RealOption,
00324   PluginCodec_EnumOption,
00325   PluginCodec_OctetsOption,
00326   PluginCodec_NumOptionTypes,
00327 };
00328 
00329 enum PluginCodec_OptionMerge {
00330   PluginCodec_NoMerge,
00331   PluginCodec_MinMerge,
00332   PluginCodec_MaxMerge,
00333   PluginCodec_EqualMerge,
00334   PluginCodec_NotEqualMerge,
00335   PluginCodec_AlwaysMerge,
00336   PluginCodec_NumOptionMerge,
00337 
00338   PluginCodec_AndMerge = PluginCodec_MinMerge,
00339   PluginCodec_OrMerge  = PluginCodec_MaxMerge
00340 };
00341 
00342 #define PluginCodec_H245_Collapsing    0x40000000
00343 #define PluginCodec_H245_NonCollapsing 0x20000000
00344 #define PluginCodec_H245_Unsigned32    0x10000000
00345 #define PluginCodec_H245_BooleanArray  0x08000000
00346 #define PluginCodec_H245_TCS           0x04000000
00347 #define PluginCodec_H245_OLC           0x02000000
00348 #define PluginCodec_H245_ReqMode       0x01000000
00349 #define PluginCodec_H245_OrdinalMask   0x0000ffff
00350 
00351 struct PluginCodec_Option {
00352   // start of version 4 fields
00353   enum PluginCodec_OptionTypes m_type;
00354   const char *                 m_name;
00355   unsigned                     m_readOnly;
00356   enum PluginCodec_OptionMerge m_merge;
00357   const char *                 m_value;
00358   const char *                 m_FMTPName;
00359   const char *                 m_FMTPDefault;
00360   int                          m_H245Generic;
00361   const char *                 m_minimum;
00362   const char *                 m_maximum;
00363 };
00364 
00365 
00366 struct PluginCodec_Definition {
00367   unsigned int version;                     // codec structure version
00368 
00369   // start of version 1 fields
00370   struct PluginCodec_information * info;   // license information
00371 
00372   unsigned int flags;                      // b0-3: 0 = audio,        1 = video
00373                                            // b4:   0 = raw input,    1 = RTP input
00374                                            // b5:   0 = raw output,   1 = RTP output
00375                                            // b6:   0 = dynamic RTP,  1 = explicit RTP
00376                                            // b7:   0 = no share RTP, 1 = share RTP
00377 
00378   const char * descr;                       // text decription
00379 
00380   const char * sourceFormat;               // source format
00381   const char * destFormat;                 // destination format
00382 
00383   const void * userData;                   // user data value
00384 
00385   unsigned int sampleRate;                 // samples per second
00386   unsigned int bitsPerSec;                // raw bits per second
00387   unsigned int usPerFrame;                 // microseconds per frame
00388 
00389   union _parm {
00390     struct _audio {
00391       unsigned int samplesPerFrame;            // audio: samples per frame
00392       unsigned int bytesPerFrame;              // audio: max bytes per frame
00393       unsigned int recommendedFramesPerPacket; // audio: recommended number of frames per packet
00394       unsigned int maxFramesPerPacket;         // audio: maximum number of frames per packet
00395     } audio;
00396     struct _video {
00397       unsigned int maxFrameWidth;              // video: frame width
00398       unsigned int maxFrameHeight;             // video: frame height
00399       unsigned int recommendedFrameRate;       // video: recommended frame rate
00400       unsigned int maxFrameRate;               // video: max frame rate
00401     } video;
00402   } parm;
00403 
00404   unsigned char rtpPayload;                 // IANA RTP payload code (if defined)
00405   const char * sdpFormat;                  // SDP format string (or NULL, if no SDP format)
00406 
00407   void * (*createCodec)(const struct PluginCodec_Definition * codec);                    // create codec
00408   void (*destroyCodec) (const struct PluginCodec_Definition * codec,  void * context);   // destroy codec
00409   int (*codecFunction) (const struct PluginCodec_Definition * codec,  void * context,   // do codec function
00410                                   const void * from, unsigned * fromLen,
00411                                         void * to,   unsigned * toLen,
00412                                         unsigned int * flag);
00413   struct PluginCodec_ControlDefn * codecControls;
00414 
00415   // H323 specific fields
00416   unsigned char h323CapabilityType;
00417   const void  * h323CapabilityData;
00418 
00419   // end of version 1 fields
00420 
00421   // NOTE!!!!! Due to an error in judgement, you cannot add ANY more fields
00422   // to this structure without an API version change!!!!
00423 };
00424 
00425 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
00426 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
00427 
00429 //
00430 //  H.323 specific values
00431 //
00432 
00433 
00434 struct PluginCodec_H323CapabilityExtension {
00435   unsigned int index;
00436   void * data;
00437   unsigned dataLength;
00438 };
00439 
00440 struct PluginCodec_H323NonStandardCodecData {
00441   const char * objectId;
00442   unsigned char  t35CountryCode;
00443   unsigned char  t35Extension;
00444   unsigned short manufacturerCode;
00445   const unsigned char * data;
00446   unsigned int dataLength;
00447   int (*capabilityMatchFunction)(struct PluginCodec_H323NonStandardCodecData *);
00448 };
00449 
00450 
00451 struct PluginCodec_H323GenericParameterDefinition
00452 {
00453   /* The following used to be a simple integer for the collapsing flag in
00454      version 3 and earlier. We hope that all those implementations just used
00455      zero and one (a good bet) and thus the below bit fields will be backward
00456      compatible, putting the parameter in all three PDU types.
00457    */ 
00458   struct {
00459     int collapsing:1; /* boolean */
00460     int excludeTCS:1;
00461     int excludeOLC:1;
00462     int excludeReqMode:1;
00463     int readOnly:1;
00464   };
00465 
00466   unsigned int id;
00467 
00468   enum PluginCodec_H323GenericParameterType {
00469     /* these need to be in the same order as the choices in
00470       H245_ParameterValue::Choices, as the value is just cast to that type
00471     */
00472         PluginCodec_GenericParameter_Logical = 0,
00473         PluginCodec_GenericParameter_BooleanArray,
00474         PluginCodec_GenericParameter_UnsignedMin,
00475         PluginCodec_GenericParameter_UnsignedMax,
00476         PluginCodec_GenericParameter_Unsigned32Min,
00477         PluginCodec_GenericParameter_Unsigned32Max,
00478         PluginCodec_GenericParameter_OctetString,
00479         PluginCodec_GenericParameter_GenericParameter,
00480         
00481     PluginCodec_GenericParameter_logical = 0,
00482     PluginCodec_GenericParameter_booleanArray,
00483     PluginCodec_GenericParameter_unsignedMin,
00484     PluginCodec_GenericParameter_unsignedMax,
00485     PluginCodec_GenericParameter_unsigned32Min,
00486     PluginCodec_GenericParameter_unsigned32Max,
00487     PluginCodec_GenericParameter_octetString,
00488     PluginCodec_GenericParameter_genericParameter
00489   } type;
00490 
00491   union {
00492     unsigned long integer;
00493     const char * octetstring;
00494     struct PluginCodec_H323GenericParameterDefinition *genericparameter;
00495   } value;
00496 };
00497 
00498 struct PluginCodec_H323GenericCodecData
00499 {
00500   // some cunning structures & lists, and associated logic in
00501   // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
00502   const char * standardIdentifier;
00503   unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
00504 
00505   /* parameters; these are the parameters which are set in the
00506      'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
00507   unsigned int nParameters;
00508   /* an array of nParameters parameter definitions */
00509   const struct PluginCodec_H323GenericParameterDefinition *params;
00510 };
00511 
00512 
00513 struct PluginCodec_H323AudioGSMData {
00514   int comfortNoise:1;
00515   int scrambled:1;
00516 };
00517 
00518 struct  PluginCodec_H323AudioG7231AnnexC {
00519   unsigned char maxAl_sduAudioFrames;
00520   int silenceSuppression:1;
00521   int highRateMode0:6;          // INTEGER (27..78),  -- units octets
00522   int  highRateMode1:6;          // INTEGER (27..78),  -- units octets
00523   int  lowRateMode0:6;            // INTEGER (23..66),  -- units octets
00524   int  lowRateMode1:6;            // INTEGER (23..66),  -- units octets
00525   int  sidMode0:4;                // INTEGER (6..17),  -- units octets
00526   int  sidMode1:4;                // INTEGER (6..17),  -- units octets
00527 };
00528 
00529 
00530 enum {
00531   PluginCodec_H323Codec_undefined,      // must be zero, so empty struct is undefined
00532   PluginCodec_H323Codec_programmed,      // H323ProgrammedCapability
00533   PluginCodec_H323Codec_nonStandard,    // H323NonStandardData
00534   PluginCodec_H323Codec_generic,            // H323GenericCodecData
00535 
00536   // audio codecs
00537   PluginCodec_H323AudioCodec_g711Alaw_64k,        // int
00538   PluginCodec_H323AudioCodec_g711Alaw_56k,        // int
00539   PluginCodec_H323AudioCodec_g711Ulaw_64k,        // int
00540   PluginCodec_H323AudioCodec_g711Ulaw_56k,        // int
00541   PluginCodec_H323AudioCodec_g722_64k,            // int
00542   PluginCodec_H323AudioCodec_g722_56k,            // int
00543   PluginCodec_H323AudioCodec_g722_48k,            // int
00544   PluginCodec_H323AudioCodec_g7231,                // H323AudioG7231Data
00545   PluginCodec_H323AudioCodec_g728,                // int
00546   PluginCodec_H323AudioCodec_g729,                // int
00547   PluginCodec_H323AudioCodec_g729AnnexA,          // int
00548   PluginCodec_H323AudioCodec_is11172,             // not yet implemented
00549   PluginCodec_H323AudioCodec_is13818Audio,        // not yet implemented
00550   PluginCodec_H323AudioCodec_g729wAnnexB,          // int
00551   PluginCodec_H323AudioCodec_g729AnnexAwAnnexB,    // int
00552   PluginCodec_H323AudioCodec_g7231AnnexC,         // H323AudioG7231AnnexC
00553   PluginCodec_H323AudioCodec_gsmFullRate,          // H323AudioGSMData
00554   PluginCodec_H323AudioCodec_gsmHalfRate,          // H323AudioGSMData
00555   PluginCodec_H323AudioCodec_gsmEnhancedFullRate,  // H323AudioGSMData
00556   PluginCodec_H323AudioCodec_g729Extensions,      // not yet implemented
00557 
00558   // video codecs
00559   PluginCodec_H323VideoCodec_h261,                // implemented
00560   PluginCodec_H323VideoCodec_h262,                // not yet implemented
00561   PluginCodec_H323VideoCodec_h263,                // implemented
00562   PluginCodec_H323VideoCodec_is11172,             // not yet implemented
00563 
00564   // other capabilities
00565   PluginCodec_H323VideoCodec_Extended,            // implemented (for use with H.239)
00566   PluginCodec_H323T38Codec,                       // not yet implemented
00567 
00568   // special codes
00569   PluginCodec_H323Codec_NoH323 = 0xff,            // used for SIP-only codecs
00570 };
00571 
00573 //
00574 // Generic Codec Standard Identifiers
00575 //
00576 
00577 // Audio Capabilities
00578 // AMR (as defined in H.245v13 Annex I)
00579 #define OpalPluginCodec_Identifer_AMR             "0.0.8.245.1.1.1"
00580 
00581 // AMR-NB\WB  (as defined in H.245v13 Annex R)
00582 #define OpalPluginCodec_Identifer_AMR_NB          "0.0.8.245.1.1.9"
00583 #define OpalPluginCodec_Identifer_AMR_WB          "0.0.8.245.1.1.10"
00584 
00585 // G.722.2 (aka AMR-WB)
00586 #define OpalPluginCodec_Identifer_G7222           "0.0.7.7222.1.0"
00587 
00588 // iLBC (as defined in H.245v13 Annex S)
00589 #define OpalPluginCodec_Identifer_iLBC            "0.0.8.245.1.1.11"
00590 
00591 
00592 // Video Capabilities
00593 
00594 // H264 (as defined in H.241)
00595 #define OpalPluginCodec_Identifer_H264            "0.0.8.241.0.0.0.0"
00596 #define OpalPluginCodec_Identifer_H264_RFC3984    "0.0.8.241.0.0.0.1"
00597 #define OpalPluginCodec_Identifer_H264_RFC3984Int "0.0.8.241.0.0.0.2"
00598 #define OpalPluginCodec_Identifer_H264_Generic    "0.0.8.241.0.0.1"
00599 
00600 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
00601 #define OpalPluginCodec_Identifer_MPEG4           "0.0.8.245.1.0.0"
00602 
00603 
00605 //
00606 // RTP specific definitions
00607 //
00608 
00609 #define PluginCodec_RTP_MaxPacketSize  (1518-14-4-8-20-16)  // Max Ethernet packet (1518 bytes) minus 802.3/CRC, 802.3, IP, UDP headers
00610 #define PluginCodec_RTP_MinHeaderSize  (12)
00611 #define PluginCodec_RTP_MaxPayloadSize (PluginCodec_RTP_MaxPacketSize - PluginCodec_RTP_MinHeaderSize)
00612 
00613 #define PluginCodec_RTP_GetHeaderLength(ptr)      ((((BYTE*)(ptr))[0] & 0x0f)*4 + PluginCodec_RTP_MinHeaderSize)
00614 #define PluginCodec_RTP_GetPayloadPtr(ptr)          ((BYTE*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
00615 #define PluginCodec_RTP_GetPayloadType(ptr)        (((BYTE*)(ptr))[1] & 0x7f)
00616 #define PluginCodec_RTP_SetPayloadType(ptr, type)  (((BYTE*)(ptr))[1] = (((BYTE*)(ptr))[1] & 0x80) | (type & 0x7f))
00617 #define PluginCodec_RTP_GetMarker(ptr)            ((((BYTE*)(ptr))[1] & 0x80) != 0)
00618 #define PluginCodec_RTP_SetMarker(ptr, mark)       (((BYTE*)(ptr))[1] = (((BYTE*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0))
00619 #define PluginCodec_RTP_GetTimestamp(ptr)         ((((BYTE*)(ptr))[4] << 24) | (((BYTE*)(ptr))[5] << 16) | (((BYTE*)(ptr))[6] << 8) | ((BYTE*)(ptr))[7])
00620 #define PluginCodec_RTP_SetTimestamp(ptr, ts)     ((((BYTE*)(ptr))[4] = ((ts) >> 24)),(((BYTE*)(ptr))[5] = ((ts) >> 16)),(((BYTE*)(ptr))[6] = ((ts) >> 8)),(((BYTE*)(ptr))[7] = (ts)))
00621 
00622 
00624 //
00625 // video specific definitions
00626 //
00627 
00628 struct PluginCodec_Video_FrameHeader {
00629   unsigned int  x;
00630   unsigned int  y;
00631   unsigned int  width;
00632   unsigned int  height;
00633 };
00634 
00635 #ifdef __cplusplus
00636 };
00637 
00638 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
00639 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
00640 
00641 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
00642 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
00643 
00644 extern "C" {
00645 #endif
00646 
00647 #define PLUGIN_CODEC_VIDEO_SET_FRAME_SIZE_FN    "set_frame_size"    // argument is struct PluginCodec_VideoSetFrameInfo
00648 struct PluginCodec_Video_SetFrameInfo {
00649   int width;
00650   int height;
00651 };
00652 
00653 
00655 //
00656 // experimental definitions for statically linking codecs
00657 //
00658 
00659 #ifdef OPAL_STATIC_CODEC
00660 
00661 #  undef PLUGIN_CODEC_DLL_API
00662 #  define PLUGIN_CODEC_DLL_API static
00663 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00664 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
00665 { return PWLIB_PLUGIN_API_VERSION; } \
00666 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
00667 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
00668 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
00669 
00670 #else
00671 
00672 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00673 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00674 { return PWLIB_PLUGIN_API_VERSION; } \
00675 
00676 #  define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
00677 PLUGIN_CODEC_IMPLEMENT(name) \
00678 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
00679 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
00680 
00681 
00682 #endif
00683 
00684 #ifdef __cplusplus
00685 };
00686 #endif
00687 
00688 
00689 #ifdef _MSC_VER
00690 #pragma warning(default:4201)
00691 #endif
00692 
00693 #endif // __OPAL_CODECPLUGIN_H

Generated on Fri Mar 7 06:33:40 2008 for OPAL by  doxygen 1.5.1