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  * $Revision: 24885 $
00028  * $Author: rjongbloed $
00029  * $Date: 2010-11-21 17:31:12 -0600 (Sun, 21 Nov 2010) $
00030  */
00031 
00032 #ifndef OPAL_CODEC_OPALPLUGIN_H
00033 #define OPAL_CODEC_OPALPLUGIN_H
00034 
00035 #ifdef __cplusplus
00036 extern "C" {
00037 #endif
00038 
00039 #include <time.h>
00040 
00041 #ifdef _MSC_VER
00042 #pragma warning(disable:4201)
00043 #endif
00044 
00045 #ifdef _WIN32
00046 #  ifdef PLUGIN_CODEC_DLL_EXPORTS
00047 #    define PLUGIN_CODEC_DLL_API __declspec(dllexport)
00048 #  else
00049 #    define PLUGIN_CODEC_DLL_API __declspec(dllimport)
00050 #  endif
00051 
00052 #else
00053 
00054 #define PLUGIN_CODEC_DLL_API
00055 
00056 #endif
00057 
00058 #ifdef PWLIB_PLUGIN_API_VERSION
00059 #undef PWLIB_PLUGIN_API_VERSION
00060 #endif
00061 #define PWLIB_PLUGIN_API_VERSION 1
00062 
00063 #define  PLUGIN_CODEC_VERSION_FIRST     1    // initial version
00064 #define  PLUGIN_CODEC_VERSION_WIDEBAND  2    // added wideband
00065 #define  PLUGIN_CODEC_VERSION_VIDEO     3    // added video
00066 #define  PLUGIN_CODEC_VERSION_FAX       4    // added fax
00067 #define  PLUGIN_CODEC_VERSION_OPTIONS   5    // added options handling
00068 #define  PLUGIN_CODEC_VERSION_INTERSECT 6    // added media option intersection merge functionality
00069 
00070 #define  PLUGIN_CODEC_VERSION PLUGIN_CODEC_VERSION_INTERSECT // Always latest version
00071 
00072 #define PLUGIN_CODEC_API_VER_FN       PWLibPlugin_GetAPIVersion
00073 #define PLUGIN_CODEC_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
00074 
00075 #define PLUGIN_CODEC_GET_CODEC_FN     OpalCodecPlugin_GetCodecs
00076 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs"
00077 
00078 #define PLUGIN_CODEC_API_VER_FN_DECLARE \
00079 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00080 { return PWLIB_PLUGIN_API_VERSION; }
00081 
00082 enum {
00083   PluginCodec_License_None                           = 0,
00084   PluginCodec_Licence_None = PluginCodec_License_None,        // allow for old code with misspelled constant
00085   PluginCodec_License_GPL                            = 1,
00086   PluginCodec_License_MPL                            = 2,
00087   PluginCodec_License_Freeware                       = 3,
00088   PluginCodec_License_ResearchAndDevelopmentUseOnly  = 4,
00089   PluginCodec_License_BSD                            = 5,
00090   PluginCodec_License_LGPL                           = 6,
00091 
00092   PluginCodec_License_NoRoyalties                    = 0x7f,
00093 
00094   // any license codes above here require royalty payments
00095   PluginCodec_License_RoyaltiesRequired              = 0x80
00096 };
00097 
00098 struct PluginCodec_information {
00099   // start of version 1 fields
00100   time_t timestamp;                     // codec creation time and date - obtain with command: date -u "+%c = %s"
00101 
00102   const char * sourceAuthor;            // source code author
00103   const char * sourceVersion;           // source code version
00104   const char * sourceEmail;             // source code email contact information
00105   const char * sourceURL;               // source code web site
00106   const char * sourceCopyright;         // source code copyright
00107   const char * sourceLicense;           // source code license
00108   unsigned char sourceLicenseCode;      // source code license
00109 
00110   const char * codecDescription;        // codec description
00111   const char * codecAuthor;             // codec author
00112   const char * codecVersion;            // codec version
00113   const char * codecEmail;              // codec email contact information
00114   const char * codecURL;                // codec web site
00115   const char * codecCopyright;          // codec copyright information
00116   const char * codecLicense;            // codec license
00117   unsigned short codecLicenseCode;      // codec license code
00118   // end of version 1 fields
00119 
00120 };
00121 
00122 enum PluginCodec_Flags {
00123   PluginCodec_MediaTypeMask          = 0x000f,
00124   PluginCodec_MediaTypeAudio         = 0x0000,
00125   PluginCodec_MediaTypeVideo         = 0x0001,
00126   PluginCodec_MediaTypeAudioStreamed = 0x0002,
00127   PluginCodec_MediaTypeFax           = 0x0003,
00128 
00129   PluginCodec_InputTypeMask          = 0x0010,
00130   PluginCodec_InputTypeRaw           = 0x0000, // Note video is always RTP
00131   PluginCodec_InputTypeRTP           = 0x0010,
00132 
00133   PluginCodec_OutputTypeMask         = 0x0020,
00134   PluginCodec_OutputTypeRaw          = 0x0000, // Note video is always RTP
00135   PluginCodec_OutputTypeRTP          = 0x0020,
00136 
00137   PluginCodec_RTPTypeMask            = 0x0040,
00138   PluginCodec_RTPTypeDynamic         = 0x0000,
00139   PluginCodec_RTPTypeExplicit        = 0x0040,
00140 
00141   PluginCodec_RTPSharedMask          = 0x0080,
00142   PluginCodec_RTPTypeNotShared       = 0x0000,
00143   PluginCodec_RTPTypeShared          = 0x0080,
00144 
00145   PluginCodec_DecodeSilenceMask      = 0x0100,
00146   PluginCodec_NoDecodeSilence        = 0x0000,
00147   PluginCodec_DecodeSilence          = 0x0100,
00148 
00149   PluginCodec_EncodeSilenceMask      = 0x0200,
00150   PluginCodec_NoEncodeSilence        = 0x0000,
00151   PluginCodec_EncodeSilence          = 0x0200,
00152 
00153   PluginCodec_MediaExtensionMask     = 0x0400,
00154   PluginCodec_MediaTypeExtVideo      = 0x0400,
00155 
00156   PluginCodec_ComfortNoiseMask       = 0x0800,
00157   PluginCodec_ComfortNoise           = 0x0800,
00158 
00159   PluginCodec_EmptyPayloadMask       = 0x1000,
00160   PluginCodec_EmptyPayload           = 0x1000,
00161 
00162   PluginCodec_OtherPayloadMask       = 0x2000,
00163   PluginCodec_OtherPayload           = 0x2000,
00164 
00165   PluginCodec_BitsPerSamplePos       = 12,
00166   PluginCodec_BitsPerSampleMask      = 0xf000,
00167 };
00168 
00169 enum PluginCodec_CoderFlags {
00170   PluginCodec_CoderSilenceFrame      = 1,    // request audio codec to create silence frame
00171   PluginCodec_CoderForceIFrame       = 2     // request video codec to force I frame
00172 };
00173 
00174 enum PluginCodec_ReturnCoderFlags {
00175   PluginCodec_ReturnCoderLastFrame      = 1,    // indicates when video codec returns last data for frame
00176   PluginCodec_ReturnCoderIFrame         = 2,    // indicates when video returns I frame
00177   PluginCodec_ReturnCoderRequestIFrame  = 4,    // indicates when video decoder request I frame for resync
00178   PluginCodec_ReturnCoderBufferTooSmall = 8     // indicates when output buffer is not large enough to receive
00179                                                 // the data, another call to get_output_data_size is required
00180 };
00181 
00182 struct PluginCodec_Definition;
00183 
00184 // Control function names
00185 
00186 #define PLUGINCODEC_CONTROL_VALID_FOR_PROTOCOL    "valid_for_protocol"
00187 #define PLUGINCODEC_CONTROL_GET_CODEC_OPTIONS     "get_codec_options"
00188 #define PLUGINCODEC_CONTROL_FREE_CODEC_OPTIONS    "free_codec_options"
00189 #define PLUGINCODEC_CONTROL_GET_OUTPUT_DATA_SIZE  "get_output_data_size"
00190 #define PLUGINCODEC_CONTROL_SET_CODEC_OPTIONS     "set_codec_options"
00191 #define PLUGINCODEC_CONTROL_TO_NORMALISED_OPTIONS "to_normalised_options"
00192 #define PLUGINCODEC_CONTROL_TO_CUSTOMISED_OPTIONS "to_customised_options"
00193 #define PLUGINCODEC_CONTROL_SET_INSTANCE_ID       "set_instance_id"
00194 #define PLUGINCODEC_CONTROL_SET_LOG_FUNCTION      "set_log_function"
00195 #define PLUGINCODEC_CONTROL_GET_STATISTICS        "get_statistics"
00196 #define PLUGINCODEC_CONTROL_TERMINATE_CODEC       "terminate_codec"
00197 
00198 
00199 /* Log function, plug in gets a pointer to this function which allows
00200    it to use the standard OPAL logging system. The function returns 0 if
00201    no logging was performed due to the log level. Note if log == NULL
00202    then this return state is all that happens, so this may be executed
00203    first to prevent lengthy logs that would not result in any output. */
00204 typedef int (*PluginCodec_LogFunction)(unsigned level,
00205                                        const char * file,
00206                                        unsigned line,
00207                                        const char * section,
00208                                        const char * log);
00209 
00210 
00211 struct PluginCodec_ControlDefn {
00212   const char * name;
00213   int (*control)(const struct PluginCodec_Definition * codec, void * context,
00214                  const char * name, void * parm, unsigned * parmLen);
00215 
00216 };
00217 
00218 enum PluginCodec_OptionTypes {
00219   PluginCodec_StringOption,
00220   PluginCodec_BoolOption,
00221   PluginCodec_IntegerOption,
00222   PluginCodec_RealOption,
00223   PluginCodec_EnumOption,
00224   PluginCodec_OctetsOption,
00225   PluginCodec_NumOptionTypes,
00226 };
00227 
00228 enum PluginCodec_OptionMerge {
00229   PluginCodec_NoMerge,
00230   PluginCodec_MinMerge,
00231   PluginCodec_MaxMerge,
00232   PluginCodec_EqualMerge,
00233   PluginCodec_NotEqualMerge,
00234   PluginCodec_AlwaysMerge,
00235   PluginCodec_CustomMerge,
00236   PluginCodec_IntersectionMerge,
00237 
00238   PluginCodec_AndMerge = PluginCodec_MinMerge,
00239   PluginCodec_OrMerge  = PluginCodec_MaxMerge
00240 };
00241 
00242 #define PluginCodec_H245_Collapsing    0x40000000
00243 #define PluginCodec_H245_NonCollapsing 0x20000000
00244 #define PluginCodec_H245_Unsigned32    0x10000000
00245 #define PluginCodec_H245_BooleanArray  0x08000000
00246 #define PluginCodec_H245_TCS           0x04000000
00247 #define PluginCodec_H245_OLC           0x02000000
00248 #define PluginCodec_H245_ReqMode       0x01000000
00249 #define PluginCodec_H245_OrdinalMask   0x0000ffff
00250 
00251 typedef int (*PluginCodec_MergeFunction)(char ** result, const char * dest, const char * src);
00252 typedef void (*PluginCodec_FreeFunction)(char * string);
00253 
00254 struct PluginCodec_Option {
00255   // start of version 4 fields
00256   enum PluginCodec_OptionTypes m_type;
00257   const char *                 m_name;
00258   unsigned                     m_readOnly;
00259   enum PluginCodec_OptionMerge m_merge;
00260   const char *                 m_value;
00261   const char *                 m_FMTPName;
00262   const char *                 m_FMTPDefault;
00263   int                          m_H245Generic;
00264   const char *                 m_minimum;
00265   const char *                 m_maximum;
00266   PluginCodec_MergeFunction    m_mergeFunction; // Used if m_merge==PluginCodec_CustomMerge
00267   PluginCodec_FreeFunction     m_freeFunction;
00268 };
00269 
00270 
00271 // Normalised option names
00272 #define PLUGINCODEC_OPTION_NEEDS_JITTER               "Needs Jitter"
00273 #define PLUGINCODEC_OPTION_CLOCK_RATE                 "Clock Rate"
00274 #define PLUGINCODEC_OPTION_FRAME_TIME                 "Frame Time"
00275 #define PLUGINCODEC_OPTION_MAX_FRAME_SIZE             "Max Frame Size"
00276 #define PLUGINCODEC_OPTION_MAX_BIT_RATE               "Max Bit Rate"
00277 #define PLUGINCODEC_OPTION_TARGET_BIT_RATE            "Target Bit Rate"
00278 #define PLUGINCODEC_OPTION_RX_FRAMES_PER_PACKET       "Rx Frames Per Packet"
00279 #define PLUGINCODEC_OPTION_TX_FRAMES_PER_PACKET       "Tx Frames Per Packet"
00280 #define PLUGINCODEC_OPTION_FRAME_WIDTH                "Frame Width"
00281 #define PLUGINCODEC_OPTION_FRAME_HEIGHT               "Frame Height"
00282 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_WIDTH         "Min Rx Frame Width"
00283 #define PLUGINCODEC_OPTION_MIN_RX_FRAME_HEIGHT        "Min Rx Frame Height"
00284 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_WIDTH         "Max Rx Frame Width"
00285 #define PLUGINCODEC_OPTION_MAX_RX_FRAME_HEIGHT        "Max Rx Frame Height"
00286 #define PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF "Temporal Spatial Trade Off"
00287 #define PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD        "Tx Key Frame Period"
00288 
00289 
00290 
00291 // Full definition of the codec
00292 
00293 struct PluginCodec_Definition {
00294   unsigned int version;                     // codec structure version
00295 
00296   // start of version 1 fields
00297   struct PluginCodec_information * info;   // license information
00298 
00299   unsigned int flags;                      // b0-3: 0 = audio,        1 = video
00300                                            // b4:   0 = raw input,    1 = RTP input
00301                                            // b5:   0 = raw output,   1 = RTP output
00302                                            // b6:   0 = dynamic RTP,  1 = explicit RTP
00303                                            // b7:   0 = no share RTP, 1 = share RTP
00304 
00305   const char * descr;                       // text decription
00306 
00307   const char * sourceFormat;               // source format
00308   const char * destFormat;                 // destination format
00309 
00310   const void * userData;                   // user data value
00311 
00312   unsigned int sampleRate;                 // samples per second
00313   unsigned int bitsPerSec;                // raw bits per second
00314   unsigned int usPerFrame;                 // microseconds per frame
00315 
00316   union _parm {
00317     struct _audio {
00318       unsigned int samplesPerFrame;            // audio: samples per frame
00319       unsigned int bytesPerFrame;              // audio: max bytes per frame
00320       unsigned int recommendedFramesPerPacket; // audio: recommended number of frames per packet
00321       unsigned int maxFramesPerPacket;         // audio: maximum number of frames per packet
00322     } audio;
00323     struct _video {
00324       unsigned int maxFrameWidth;              // video: frame width
00325       unsigned int maxFrameHeight;             // video: frame height
00326       unsigned int recommendedFrameRate;       // video: recommended frame rate
00327       unsigned int maxFrameRate;               // video: max frame rate
00328     } video;
00329   } parm;
00330 
00331   unsigned char rtpPayload;                 // IANA RTP payload code (if defined)
00332   const char * sdpFormat;                  // SDP format string (or NULL, if no SDP format)
00333 
00334   void * (*createCodec)(const struct PluginCodec_Definition * codec);                    // create codec
00335   void (*destroyCodec) (const struct PluginCodec_Definition * codec,  void * context);   // destroy codec
00336   int (*codecFunction) (const struct PluginCodec_Definition * codec,  void * context,   // do codec function
00337                                   const void * from, unsigned * fromLen,
00338                                         void * to,   unsigned * toLen,
00339                                         unsigned int * flag);
00340   struct PluginCodec_ControlDefn * codecControls;
00341 
00342   // H323 specific fields
00343   unsigned char h323CapabilityType;
00344   const void  * h323CapabilityData;
00345 
00346   // end of version 1 fields
00347 
00348   // NOTE!!!!! Due to an error in judgement, you cannot add ANY more fields
00349   // to this structure without an API version change!!!!
00350 };
00351 
00352 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int);
00353 typedef unsigned (* PluginCodec_GetAPIVersionFunction)();
00354 
00356 //
00357 //  H.323 specific values
00358 //
00359 
00360 
00361 struct PluginCodec_H323CapabilityExtension {
00362   unsigned int index;
00363   void * data;
00364   unsigned dataLength;
00365 };
00366 
00367 struct PluginCodec_H323NonStandardCodecData {
00368   const char * objectId;
00369   unsigned char  t35CountryCode;
00370   unsigned char  t35Extension;
00371   unsigned short manufacturerCode;
00372   const unsigned char * data;
00373   unsigned int dataLength;
00374   int (*capabilityMatchFunction)(struct PluginCodec_H323NonStandardCodecData *);
00375 };
00376 
00377 
00378 struct PluginCodec_H323GenericParameterDefinition
00379 {
00380   /* The following used to be a simple integer for the collapsing flag in
00381      version 3 and earlier. We hope that all those implementations just used
00382      zero and one (a good bet) and thus the below bit fields will be backward
00383      compatible, putting the parameter in all three PDU types.
00384    */ 
00385 #ifndef SOLARIS   
00386   struct {
00387 #endif  
00388     int collapsing:1; /* boolean */
00389     int excludeTCS:1;
00390     int excludeOLC:1;
00391     int excludeReqMode:1;
00392     int readOnly:1;
00393 #ifndef SOLARIS    
00394   };
00395 #endif  
00396 
00397   unsigned int id;
00398 
00399   enum PluginCodec_H323GenericParameterType {
00400     /* these need to be in the same order as the choices in
00401       H245_ParameterValue::Choices, as the value is just cast to that type
00402     */
00403     PluginCodec_GenericParameter_Logical = 0,
00404     PluginCodec_GenericParameter_BooleanArray,
00405     PluginCodec_GenericParameter_UnsignedMin,
00406     PluginCodec_GenericParameter_UnsignedMax,
00407     PluginCodec_GenericParameter_Unsigned32Min,
00408     PluginCodec_GenericParameter_Unsigned32Max,
00409     PluginCodec_GenericParameter_OctetString,
00410     PluginCodec_GenericParameter_GenericParameter,
00411 
00412     PluginCodec_GenericParameter_logical = 0,
00413     PluginCodec_GenericParameter_booleanArray,
00414     PluginCodec_GenericParameter_unsignedMin,
00415     PluginCodec_GenericParameter_unsignedMax,
00416     PluginCodec_GenericParameter_unsigned32Min,
00417     PluginCodec_GenericParameter_unsigned32Max,
00418     PluginCodec_GenericParameter_octetString,
00419     PluginCodec_GenericParameter_genericParameter
00420   } type;
00421 
00422   union {
00423     unsigned long integer;
00424     const char * octetstring;
00425     struct PluginCodec_H323GenericParameterDefinition *genericparameter;
00426   } value;
00427 };
00428 
00429 struct PluginCodec_H323GenericCodecData
00430 {
00431   // some cunning structures & lists, and associated logic in
00432   // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability()
00433   const char * standardIdentifier;
00434   unsigned int maxBitRate; // Zero means use value from OpalMediaFormat
00435 
00436   /* parameters; these are the parameters which are set in the
00437      'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */
00438   unsigned int nParameters;
00439   /* an array of nParameters parameter definitions */
00440   const struct PluginCodec_H323GenericParameterDefinition *params;
00441 };
00442 
00443 
00444 struct PluginCodec_H323AudioGSMData {
00445   int comfortNoise:1;
00446   int scrambled:1;
00447 };
00448 
00449 struct  PluginCodec_H323AudioG7231AnnexC {
00450   unsigned char maxAl_sduAudioFrames;
00451   int silenceSuppression:1;
00452   int highRateMode0:6;          // INTEGER (27..78),  -- units octets
00453   int  highRateMode1:6;          // INTEGER (27..78),  -- units octets
00454   int  lowRateMode0:6;            // INTEGER (23..66),  -- units octets
00455   int  lowRateMode1:6;            // INTEGER (23..66),  -- units octets
00456   int  sidMode0:4;                // INTEGER (6..17),  -- units octets
00457   int  sidMode1:4;                // INTEGER (6..17),  -- units octets
00458 };
00459 
00460 
00461 enum {
00462   PluginCodec_H323Codec_undefined,      // must be zero, so empty struct is undefined
00463   PluginCodec_H323Codec_programmed,      // H323ProgrammedCapability
00464   PluginCodec_H323Codec_nonStandard,    // H323NonStandardData
00465   PluginCodec_H323Codec_generic,            // H323GenericCodecData
00466 
00467   // audio codecs
00468   PluginCodec_H323AudioCodec_g711Alaw_64k,        // int
00469   PluginCodec_H323AudioCodec_g711Alaw_56k,        // int
00470   PluginCodec_H323AudioCodec_g711Ulaw_64k,        // int
00471   PluginCodec_H323AudioCodec_g711Ulaw_56k,        // int
00472   PluginCodec_H323AudioCodec_g722_64k,            // int
00473   PluginCodec_H323AudioCodec_g722_56k,            // int
00474   PluginCodec_H323AudioCodec_g722_48k,            // int
00475   PluginCodec_H323AudioCodec_g7231,                // H323AudioG7231Data
00476   PluginCodec_H323AudioCodec_g728,                // int
00477   PluginCodec_H323AudioCodec_g729,                // int
00478   PluginCodec_H323AudioCodec_g729AnnexA,          // int
00479   PluginCodec_H323AudioCodec_is11172,             // not yet implemented
00480   PluginCodec_H323AudioCodec_is13818Audio,        // not yet implemented
00481   PluginCodec_H323AudioCodec_g729wAnnexB,          // int
00482   PluginCodec_H323AudioCodec_g729AnnexAwAnnexB,    // int
00483   PluginCodec_H323AudioCodec_g7231AnnexC,         // H323AudioG7231AnnexC
00484   PluginCodec_H323AudioCodec_gsmFullRate,          // H323AudioGSMData
00485   PluginCodec_H323AudioCodec_gsmHalfRate,          // H323AudioGSMData
00486   PluginCodec_H323AudioCodec_gsmEnhancedFullRate,  // H323AudioGSMData
00487   PluginCodec_H323AudioCodec_g729Extensions,      // not yet implemented
00488 
00489   // video codecs
00490   PluginCodec_H323VideoCodec_h261,                // implemented
00491   PluginCodec_H323VideoCodec_h262,                // not yet implemented
00492   PluginCodec_H323VideoCodec_h263,                // implemented
00493   PluginCodec_H323VideoCodec_is11172,             // not yet implemented
00494 
00495   // other capabilities
00496   PluginCodec_H323VideoCodec_Extended,            // implemented (for use with H.239)
00497   PluginCodec_H323T38Codec,                       // not yet implemented
00498 
00499   // special codes
00500   PluginCodec_H323Codec_NoH323 = 0xff,            // used for SIP-only codecs
00501 };
00502 
00504 //
00505 // Generic Codec Standard Identifiers
00506 //
00507 
00508 // Audio Capabilities
00509 // AMR (as defined in H.245v13 Annex I)
00510 #define OpalPluginCodec_Identifer_AMR             "0.0.8.245.1.1.1"
00511 
00512 // AMR-NB\WB  (as defined in H.245v13 Annex R)
00513 #define OpalPluginCodec_Identifer_AMR_NB          "0.0.8.245.1.1.9"
00514 #define OpalPluginCodec_Identifer_AMR_WB          "0.0.8.245.1.1.10"
00515 
00516 // G.722.1
00517 #define OpalPluginCodec_Identifer_G7221           "0.0.7.7221.1.0"
00518 #define OpalPluginCodec_Identifer_G7221ext        "0.0.7.7221.1.1.0"
00519 
00520 // G.722.2 (aka AMR-WB)
00521 #define OpalPluginCodec_Identifer_G7222           "0.0.7.7222.1.0"
00522 
00523 // iLBC (as defined in H.245v13 Annex S)
00524 #define OpalPluginCodec_Identifer_iLBC            "0.0.8.245.1.1.11"
00525 
00526 
00527 // Video Capabilities
00528 
00529 // H264 (as defined in H.241)
00530 #define OpalPluginCodec_Identifer_H264_Aligned        "0.0.8.241.0.0.0.0"
00531 #define OpalPluginCodec_Identifer_H264_NonInterleaved "0.0.8.241.0.0.0.1"
00532 #define OpalPluginCodec_Identifer_H264_Interleaved    "0.0.8.241.0.0.0.2"
00533 #define OpalPluginCodec_Identifer_H264_Generic        "0.0.8.241.0.0.1"
00534 
00535 // ISO/IEC 14496-2 MPEG4 part 2 (as defined in H.245v13 Annex E)
00536 #define OpalPluginCodec_Identifer_MPEG4           "0.0.8.245.1.0.0"
00537 
00538 
00540 //
00541 // Predefined options for H.323 codecs
00542 //
00543 
00544 #define PLUGINCODEC_SQCIF_MPI   "SQCIF MPI"
00545 #define PLUGINCODEC_QCIF_MPI     "QCIF MPI"
00546 #define PLUGINCODEC_CIF_MPI       "CIF MPI"
00547 #define PLUGINCODEC_CIF4_MPI     "CIF4 MPI"
00548 #define PLUGINCODEC_CIF16_MPI   "CIF16 MPI"
00549 #define PLUGINCODEC_CUSTOM_MPI "Custom MPI"
00550 
00551 #define PLUGINCODEC_MPI_DISABLED 33
00552 
00553 #define PLUGINCODEC_MEDIA_PACKETIZATION  "Media Packetization"
00554 #define PLUGINCODEC_MEDIA_PACKETIZATIONS "Media Packetizations"
00555 
00556 #define H261_ANNEX_D "Annex D - Still Image Transmit"
00557 #define H263_ANNEX_D "Annex D - Unrestricted Motion Vector"
00558 #define H263_ANNEX_F "Annex F - Advanced Prediction"
00559 #define H263_ANNEX_I "Annex I - Advanced INTRA Coding"
00560 #define H263_ANNEX_J "Annex J - Deblocking Filter"
00561 #define H263_ANNEX_K "Annex K - Slice Structure"
00562 #define H263_ANNEX_N "Annex N - Reference Picture Selection"
00563 #define H263_ANNEX_S "Annex S - Alternative INTER VLC"
00564 #define H263_ANNEX_T "Annex T - Modified Quantization"
00565 
00566 #ifndef STRINGIZE
00567 #define __INTERNAL_STRINGIZE__(v) #v
00568 #define STRINGIZE(v) __INTERNAL_STRINGIZE__(v)
00569 #endif
00570 
00571 
00573 //
00574 // RTP specific definitions
00575 //
00576 
00577 #define PluginCodec_RTP_MaxPacketSize  (1518-14-4-8-20-16)  // Max Ethernet packet (1518 bytes) minus 802.3/CRC, 802.3, IP, UDP headers
00578 #define PluginCodec_RTP_MinHeaderSize  (12)
00579 #define PluginCodec_RTP_MaxPayloadSize (PluginCodec_RTP_MaxPacketSize - PluginCodec_RTP_MinHeaderSize)
00580 
00581 #define PluginCodec_RTP_GetHeaderLength(ptr)      ((((unsigned char*)(ptr))[0] & 0x0f)*4 + PluginCodec_RTP_MinHeaderSize)
00582 #define PluginCodec_RTP_GetPayloadPtr(ptr)          ((unsigned char*)(ptr) + PluginCodec_RTP_GetHeaderLength(ptr))
00583 #define PluginCodec_RTP_GetPayloadType(ptr)        (((unsigned char*)(ptr))[1] & 0x7f)
00584 #define PluginCodec_RTP_SetPayloadType(ptr, type)  (((unsigned char*)(ptr))[1] = (((unsigned char*)(ptr))[1] & 0x80) | (type & 0x7f))
00585 #define PluginCodec_RTP_GetMarker(ptr)            ((((unsigned char*)(ptr))[1] & 0x80) != 0)
00586 #define PluginCodec_RTP_SetMarker(ptr, mark)       (((unsigned char*)(ptr))[1] = (((unsigned char*)(ptr))[1] & 0x7f) | (mark != 0 ? 0x80 : 0))
00587 #define PluginCodec_RTP_GetTimestamp(ptr)         ((((unsigned char*)(ptr))[4] << 24) | (((unsigned char*)(ptr))[5] << 16) | (((unsigned char*)(ptr))[6] << 8) | ((unsigned char*)(ptr))[7])
00588 #define PluginCodec_RTP_SetTimestamp(ptr, ts)     ((((unsigned char*)(ptr))[4] = ((ts) >> 24)),(((unsigned char*)(ptr))[5] = ((ts) >> 16)),(((unsigned char*)(ptr))[6] = ((ts) >> 8)),(((unsigned char*)(ptr))[7] = (ts)))
00589 #define PluginCodec_RTP_GetSequenceNumber(ptr)    ((((unsigned char*)(ptr))[2] << 8) | ((unsigned char*)(ptr))[3])
00590 #define PluginCodec_RTP_SetSequenceNumber(ptr, sn)((((unsigned char*)(ptr))[2] = ((sn) >> 8)),(((unsigned char*)(ptr))[3] = (sn)))
00591 
00592 
00594 //
00595 // video specific definitions
00596 //
00597 
00598 struct PluginCodec_Video_FrameHeader {
00599   unsigned int  x;
00600   unsigned int  y;
00601   unsigned int  width;
00602   unsigned int  height;
00603 };
00604 
00605 #ifdef __cplusplus
00606 };
00607 
00608 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(struct PluginCodec_Video_FrameHeader * base)
00609 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
00610 
00611 inline unsigned char * OPAL_VIDEO_FRAME_DATA_PTR(const PluginCodec_Video_FrameHeader * base)
00612 { return (((unsigned char *)base) + sizeof(PluginCodec_Video_FrameHeader)); }
00613 
00614 extern "C" {
00615 #endif
00616 
00617 #define PLUGIN_CODEC_VIDEO_SET_FRAME_SIZE_FN    "set_frame_size"    // argument is struct PluginCodec_VideoSetFrameInfo
00618 struct PluginCodec_Video_SetFrameInfo {
00619   int width;
00620   int height;
00621 };
00622 
00623 
00625 //
00626 // experimental definitions for statically linking codecs
00627 //
00628 
00629 #ifdef OPAL_STATIC_CODEC
00630 
00631 #  undef PLUGIN_CODEC_DLL_API
00632 #  define PLUGIN_CODEC_DLL_API static
00633 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00634 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
00635 { return PWLIB_PLUGIN_API_VERSION; } \
00636 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \
00637 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \
00638 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \
00639 
00640 #  define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
00641 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \
00642 { return PWLIB_PLUGIN_API_VERSION; } \
00643 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * count, unsigned version) \
00644 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
00645 
00646 
00647 #else
00648 
00649 #  define PLUGIN_CODEC_IMPLEMENT(name) \
00650 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \
00651 { return PWLIB_PLUGIN_API_VERSION; } \
00652 
00653 #  define PLUGIN_CODEC_IMPLEMENT_ALL(name, table, ver) \
00654 PLUGIN_CODEC_IMPLEMENT(name) \
00655 PLUGIN_CODEC_DLL_API struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned version) \
00656 { *count = sizeof(table)/sizeof(struct PluginCodec_Definition); return version < ver ? NULL : table; }
00657 
00658 
00659 #endif
00660 
00661 #ifdef __cplusplus
00662 };
00663 #endif
00664 
00665 
00666 #ifdef _MSC_VER
00667 #pragma warning(default:4201)
00668 #endif
00669 
00670 #endif // OPAL_CODEC_OPALPLUGIN_H

Generated on Mon Feb 21 20:19:21 2011 for OPAL by  doxygen 1.4.7