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

Generated on Mon Feb 23 02:01:38 2009 for OPAL by  doxygen 1.5.1