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

Generated on Sun Nov 21 20:20:50 2010 for OPAL by  doxygen 1.4.7