OpenH323 1.18.0
|
00001 /* 00002 * h323plugins.h 00003 * 00004 * H.323 codec plugins handler 00005 * 00006 * Open H323 Library 00007 * 00008 * Copyright (C) 2004 Post Increment 00009 * 00010 * The contents of this file are subject to the Mozilla Public License 00011 * Version 1.0 (the "License"); you may not use this file except in 00012 * compliance with the License. You may obtain a copy of the License at 00013 * http://www.mozilla.org/MPL/ 00014 * 00015 * Software distributed under the License is distributed on an "AS IS" 00016 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 00017 * the License for the specific language governing rights and limitations 00018 * under the License. 00019 * 00020 * The Original Code is Open H323 Library. 00021 * 00022 * The Initial Developer of the Original Code is Post Increment 00023 * 00024 * Contributor(s): ______________________________________. 00025 * 00026 * $Log: opalplugin.h,v $ 00027 * Revision 1.9 2005/11/21 21:04:10 shorne 00028 * Added more HID input switches 00029 * 00030 * Revision 1.8 2005/08/23 08:13:06 shorne 00031 * Added HID plugin volume & LCD display support 00032 * 00033 * Revision 1.7 2005/07/03 13:54:23 shorne 00034 * Added Initial LID Plugin Support 00035 * 00036 * Revision 1.6 2005/06/07 03:22:22 csoutheren 00037 * Added patch 1198741 with support for plugin codecs with generic capabilities 00038 * Added patch 1198754 with support for setting quality level on audio codecs 00039 * Added patch 1198760 with GSM-AMR codec support 00040 * Many thanks to Richard van der Hoff for his work 00041 * 00042 * Revision 1.5 2004/12/20 23:30:20 csoutheren 00043 * Added plugin support for packet loss concealment frames 00044 * 00045 * Revision 1.4 2004/11/29 06:30:53 csoutheren 00046 * Added support for wideband codecs 00047 * 00048 * Revision 1.3 2004/05/18 22:26:28 csoutheren 00049 * Initial support for embedded codecs 00050 * Fixed problems with streamed codec support 00051 * Updates for abstract factory loading methods 00052 * 00053 * Revision 1.2 2004/05/09 14:44:36 csoutheren 00054 * Added support for streamed plugin audio codecs 00055 * 00056 * Revision 1.1 2004/04/09 12:25:25 csoutheren 00057 * Renamed from h323plugin.h 00058 * 00059 * Revision 1.2 2004/04/03 10:38:24 csoutheren 00060 * Added in initial cut at codec plugin code. Branches are for wimps :) 00061 * 00062 * Revision 1.1.2.1 2004/03/31 11:03:16 csoutheren 00063 * Initial public version 00064 * 00065 * Revision 1.8 2004/02/23 13:17:32 craigs 00066 * Fixed problems with codec interface functions 00067 * 00068 * Revision 1.7 2004/02/23 13:04:09 craigs 00069 * Removed warnings when compliing plugins 00070 * 00071 * Revision 1.6 2004/01/27 14:55:46 craigs 00072 * Implemented static linking of new codecs 00073 * 00074 * Revision 1.5 2004/01/23 05:21:15 craigs 00075 * Updated for changes to the codec plugin interface 00076 * 00077 * Revision 1.4 2004/01/09 11:27:46 craigs 00078 * Plugin codec audio now works :) 00079 * 00080 * Revision 1.3 2004/01/09 07:32:22 craigs 00081 * More fixes for capability problems 00082 * 00083 * Revision 1.2 2004/01/06 07:05:03 craigs 00084 * Changed to support plugin codecs 00085 * 00086 * Revision 1.1 2004/01/04 13:37:51 craigs 00087 * Implementation of codec plugins 00088 * 00089 * 00090 */ 00091 00092 #ifndef __OPAL_H323PLUGIN_H 00093 #define __OPAL_H323PLUGIN_H 00094 00095 #ifdef __cplusplus 00096 extern "C" { 00097 #endif 00098 00099 #include <time.h> 00100 00101 #ifdef _WIN32 00102 # ifdef PLUGIN_CODEC_DLL_EXPORTS 00103 # define PLUGIN_CODEC_DLL_API __declspec(dllexport) 00104 # else 00105 # define PLUGIN_CODEC_DLL_API __declspec(dllimport) 00106 # endif 00107 00108 #else 00109 00110 #define PLUGIN_CODEC_DLL_API 00111 00112 #endif 00113 00114 #define PWLIB_PLUGIN_API_VERSION 0 00115 00116 #define PLUGIN_CODEC_VERSION 1 // initial version 00117 #define PLUGIN_CODEC_VERSION_WIDEBAND 2 // added wideband 00118 00119 #define PLUGIN_CODEC_API_VER_FN PWLibPlugin_GetAPIVersion 00120 #define PLUGIN_CODEC_API_VER_FN_STR "PWLibPlugin_GetAPIVersion" 00121 00122 #define PLUGIN_CODEC_GET_CODEC_FN OpalCodecPlugin_GetCodecs 00123 #define PLUGIN_CODEC_GET_CODEC_FN_STR "OpalCodecPlugin_GetCodecs" 00124 00125 #define PLUGIN_CODEC_API_VER_FN_DECLARE \ 00126 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \ 00127 { return PWLIB_PLUGIN_API_VERSION; } 00128 00129 enum { 00130 PluginCodec_License_None = 0, 00131 PluginCodec_Licence_None = PluginCodec_License_None, // allow for old code with misspelled constant 00132 PluginCodec_License_GPL = 1, 00133 PluginCodec_License_MPL = 2, 00134 PluginCodec_License_Freeware = 3, 00135 PluginCodec_License_ResearchAndDevelopmentUseOnly = 4, 00136 PluginCodec_License_BSD = 5, 00137 00138 PluginCodec_License_NoRoyalties = 0x7f, 00139 00140 // any license codes above here require royalty payments 00141 PluginCodec_License_RoyaltiesRequired = 0x80 00142 }; 00143 00144 struct PluginCodec_information { 00145 // start of version 1 fields 00146 time_t timestamp; // codec creation time and date - obtain with command: date -u "+%c = %s" 00147 00148 const char * sourceAuthor; // source code author 00149 const char * sourceVersion; // source code version 00150 const char * sourceEmail; // source code email contact information 00151 const char * sourceURL; // source code web site 00152 const char * sourceCopyright; // source code copyright 00153 const char * sourceLicense; // source code license 00154 unsigned char sourceLicenseCode; // source code license 00155 00156 const char * codecDescription; // codec description 00157 const char * codecAuthor; // codec author 00158 const char * codecVersion; // codec version 00159 const char * codecEmail; // codec email contact information 00160 const char * codecURL; // codec web site 00161 const char * codecCopyright; // codec copyright information 00162 const char * codecLicense; // codec license 00163 unsigned short codecLicenseCode; // codec license code 00164 // end of version 1 fields 00165 00166 }; 00167 00168 enum PluginCodec_Flags { 00169 PluginCodec_MediaTypeMask = 0x000f, 00170 PluginCodec_MediaTypeAudio = 0x0000, 00171 PluginCodec_MediaTypeVideo = 0x0001, 00172 PluginCodec_MediaTypeAudioStreamed = 0x0002, 00173 00174 PluginCodec_InputTypeMask = 0x0010, 00175 PluginCodec_InputTypeRaw = 0x0000, 00176 PluginCodec_InputTypeRTP = 0x0010, 00177 00178 PluginCodec_OutputTypeMask = 0x0020, 00179 PluginCodec_OutputTypeRaw = 0x0000, 00180 PluginCodec_OutputTypeRTP = 0x0020, 00181 00182 PluginCodec_RTPTypeMask = 0x0040, 00183 PluginCodec_RTPTypeDynamic = 0x0000, 00184 PluginCodec_RTPTypeExplicit = 0x0040, 00185 00186 PluginCodec_RTPSharedMask = 0x0080, 00187 PluginCodec_RTPTypeNotShared = 0x0000, 00188 PluginCodec_RTPTypeShared = 0x0080, 00189 00190 PluginCodec_DecodeSilenceMask = 0x0100, 00191 PluginCodec_NoDecodeSilence = 0x0000, 00192 PluginCodec_DecodeSilence = 0x0100, 00193 00194 PluginCodec_BitsPerSamplePos = 12, 00195 PluginCodec_BitsPerSampleMask = 0xf000, 00196 }; 00197 00198 enum PluginCodec_CoderFlags { 00199 PluginCodec_CoderSilenceFrame = 1 00200 }; 00201 00202 struct PluginCodec_Definition; 00203 00204 struct PluginCodec_ControlDefn { 00205 const char * name; 00206 int (*control)(const struct PluginCodec_Definition * codec, void * context, 00207 const char * name, void * parm, unsigned * parmLen); 00208 00209 }; 00210 00211 struct PluginCodec_Definition { 00212 unsigned int version; // codec structure version 00213 00214 // start of version 1 fields 00215 struct PluginCodec_information * info; // license information 00216 00217 unsigned int flags; // b0-3: 0 = audio, 1 = video 00218 // b4: 0 = raw input, 1 = RTP input 00219 // b5: 0 = raw output, 1 = RTP output 00220 // b6: 0 = dynamic RTP, 1 = explicit RTP 00221 // b7: 0 = no share RTP, 1 = share RTP 00222 00223 const char * descr; // text decription 00224 00225 const char * sourceFormat; // source format 00226 const char * destFormat; // destination format 00227 00228 const void * userData; // user data value 00229 00230 unsigned int sampleRate; // samples per second 00231 unsigned int bitsPerSec; // raw bits per second 00232 unsigned int nsPerFrame; // nanoseconds per frame 00233 unsigned int samplesPerFrame; // samples per frame 00234 unsigned int bytesPerFrame; // max bytes per frame 00235 unsigned int recommendedFramesPerPacket; // recommended number of frames per packet 00236 unsigned int maxFramesPerPacket; // maximum number of frames per packet 00237 00238 unsigned char rtpPayload; // IANA RTP payload code (if defined) 00239 const char * sdpFormat; // SDP format string (or NULL, if no SDP format) 00240 00241 void * (*createCodec)(const struct PluginCodec_Definition * codec); // create codec 00242 void (*destroyCodec) (const struct PluginCodec_Definition * codec, void * context); // destroy codec 00243 int (*codecFunction) (const struct PluginCodec_Definition * codec, void * context, // do codec function 00244 const void * from, unsigned * fromLen, 00245 void * to, unsigned * toLen, 00246 unsigned int * flag); 00247 struct PluginCodec_ControlDefn * codecControls; 00248 00249 // H323 specific fields 00250 unsigned char h323CapabilityType; 00251 void * h323CapabilityData; 00252 00253 // end of version 1 fields 00254 }; 00255 00256 typedef struct PluginCodec_Definition * (* PluginCodec_GetCodecFunction)(unsigned int *, unsigned int); 00257 typedef unsigned (* PluginCodec_GetAPIVersionFunction)(); 00258 00260 // 00261 // H.323 specific values 00262 // 00263 00264 00265 struct PluginCodec_H323CapabilityExtension { 00266 unsigned int index; 00267 void * data; 00268 unsigned dataLength; 00269 }; 00270 00271 struct PluginCodec_H323NonStandardCodecData { 00272 const char * objectId; 00273 unsigned char t35CountryCode; 00274 unsigned char t35Extension; 00275 unsigned short manufacturerCode; 00276 const unsigned char * data; 00277 unsigned int dataLength; 00278 int (*capabilityMatchFunction)(struct PluginCodec_H323NonStandardCodecData *); 00279 }; 00280 00281 00282 struct PluginCodec_H323GenericParameterDefinition 00283 { 00284 int collapsing; /* boolean */ 00285 unsigned int id; 00286 enum PluginCodec_H323GenericParameterType { 00287 /* these need to be in the same order as the choices in 00288 H245_ParameterValue::Choices, as the value is just cast to that type 00289 */ 00290 PluginCodec_GenericParameter_Logical = 0, 00291 PluginCodec_GenericParameter_Bitfield, 00292 PluginCodec_GenericParameter_ShortMin, 00293 PluginCodec_GenericParameter_ShortMax, 00294 PluginCodec_GenericParameter_LongMin, 00295 PluginCodec_GenericParameter_LongMax, 00296 PluginCodec_GenericParameter_OctetString, 00297 PluginCodec_GenericParameter_GenericParameter 00298 } type; 00299 union { 00300 unsigned long integer; 00301 char *octetstring; 00302 struct PluginCodec_H323GenericParameterDefinition *genericparameter; 00303 } value; 00304 }; 00305 00306 00307 struct PluginCodec_H323GenericCodecData { 00308 // XXX need a way of specifying non-standard identifiers? 00309 00310 // some cunning structures & lists, and associated logic in 00311 // H323CodecPluginGenericAudioCapability::H323CodecPluginGenericAudioCapability() 00312 const char * standardIdentifier; 00313 unsigned int maxBitRate; 00314 00315 /* parameters; these are the parameters which are set in the 00316 'TerminalCapabilitySet' and 'OpenLogicalChannel' requests */ 00317 unsigned int nParameters; 00318 /* an array of nParameters parameter definitions */ 00319 const struct PluginCodec_H323GenericParameterDefinition *params; 00320 }; 00321 00322 struct PluginCodec_H323AudioGSMData { 00323 int comfortNoise:1; 00324 int scrambled:1; 00325 }; 00326 00327 struct PluginCodec_H323AudioG7231AnnexC { 00328 unsigned char maxAl_sduAudioFrames; 00329 int silenceSuppression:1; 00330 int highRateMode0:6; // INTEGER (27..78), -- units octets 00331 int highRateMode1:6; // INTEGER (27..78), -- units octets 00332 int lowRateMode0:6; // INTEGER (23..66), -- units octets 00333 int lowRateMode1:6; // INTEGER (23..66), -- units octets 00334 int sidMode0:4; // INTEGER (6..17), -- units octets 00335 int sidMode1:4; // INTEGER (6..17), -- units octets 00336 }; 00337 00338 struct PluginCodec_H323VideoH261 00339 { 00340 int qcifMPI:2; // INTEGER (1..4) OPTIONAL, -- units 1/29.97 Hz 00341 int cifMPI:2; // INTEGER (1..4) OPTIONAL, -- units 1/29.97 Hz 00342 int temporalSpatialTradeOffCapability; // BOOLEAN, 00343 int maxBitRate; // INTEGER (1..19200), -- units of 100 bit/s 00344 int stillImageTransmission:1; // BOOLEAN, -- Annex D of H.261 00345 int videoBadMBsCap:1; // BOOLEAN 00346 const struct PluginCodec_H323CapabilityExtension * extensions; 00347 }; 00348 00349 enum { 00350 PluginCodec_H323Codec_undefined, // must be zero, so empty struct is undefined 00351 PluginCodec_H323Codec_programmed, // H323ProgrammedCapability 00352 PluginCodec_H323Codec_nonStandard, // H323NonStandardData 00353 PluginCodec_H323Codec_generic, // H323GenericCodecData 00354 00355 // audio codecs 00356 PluginCodec_H323AudioCodec_g711Alaw_64k, // int 00357 PluginCodec_H323AudioCodec_g711Alaw_56k, // int 00358 PluginCodec_H323AudioCodec_g711Ulaw_64k, // int 00359 PluginCodec_H323AudioCodec_g711Ulaw_56k, // int 00360 PluginCodec_H323AudioCodec_g722_64k, // int 00361 PluginCodec_H323AudioCodec_g722_56k, // int 00362 PluginCodec_H323AudioCodec_g722_48k, // int 00363 PluginCodec_H323AudioCodec_g7231, // H323AudioG7231Data 00364 PluginCodec_H323AudioCodec_g728, // int 00365 PluginCodec_H323AudioCodec_g729, // int 00366 PluginCodec_H323AudioCodec_g729AnnexA, // int 00367 PluginCodec_H323AudioCodec_is11172, // not yet implemented 00368 PluginCodec_H323AudioCodec_is13818Audio, // not yet implemented 00369 PluginCodec_H323AudioCodec_g729wAnnexB, // int 00370 PluginCodec_H323AudioCodec_g729AnnexAwAnnexB, // int 00371 PluginCodec_H323AudioCodec_g7231AnnexC, // H323AudioG7231AnnexC 00372 PluginCodec_H323AudioCodec_gsmFullRate, // H323AudioGSMData 00373 PluginCodec_H323AudioCodec_gsmHalfRate, // H323AudioGSMData 00374 PluginCodec_H323AudioCodec_gsmEnhancedFullRate, // H323AudioGSMData 00375 PluginCodec_H323AudioCodec_g729Extensions, // not yet implemented 00376 00377 // video codecs 00378 PluginCodec_H323VideoCodec_h261, // not yet implemented 00379 PluginCodec_H323VideoCodec_h262, // not yet implemented 00380 PluginCodec_H323VideoCodec_h263, // not yet implemented 00381 PluginCodec_H323VideoCodec_is11172, // not yet implemented 00382 }; 00383 00384 00385 00386 #ifdef OPAL_STATIC_CODEC 00387 00388 # undef PLUGIN_CODEC_DLL_API 00389 # define PLUGIN_CODEC_DLL_API static 00390 # define PLUGIN_CODEC_IMPLEMENT(name) \ 00391 unsigned int Opal_StaticCodec_##name##_GetAPIVersion() \ 00392 { return PWLIB_PLUGIN_API_VERSION; } \ 00393 static struct PluginCodec_Definition * PLUGIN_CODEC_GET_CODEC_FN(unsigned * count, unsigned /*version*/); \ 00394 struct PluginCodec_Definition * Opal_StaticCodec_##name##_GetCodecs(unsigned * p1, unsigned p2) \ 00395 { return PLUGIN_CODEC_GET_CODEC_FN(p1,p2); } \ 00396 00397 #else 00398 00399 # define PLUGIN_CODEC_IMPLEMENT(name) \ 00400 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \ 00401 { return PWLIB_PLUGIN_API_VERSION; } \ 00402 00403 #endif 00404 00405 #ifdef __cplusplus 00406 }; 00407 #endif 00408 00410 // LID/HID Plugins 00411 00412 #ifdef _WIN32 // Only Support Win32 at the moment 00413 00414 // Harware Input Device 00415 #define PLUGIN_HID_GET_DEVICE_FN OpalHIDPlugin_GetDevice 00416 #define PLUGIN_HID_GET_DEVICE_FN_STR "OpalHIDPlugin_GetDevice" 00417 00418 #define PLUGIN_HID_VERSION 1 // initial version 00419 00420 # define PLUGIN_HID_IMPLEMENT(name) \ 00421 PLUGIN_CODEC_DLL_API unsigned int PLUGIN_CODEC_API_VER_FN() \ 00422 { return PWLIB_PLUGIN_API_VERSION; } \ 00423 00424 00425 struct PluginHID_information { 00426 // start of version 1 fields 00427 time_t timestamp; // codec creation time and date - obtain with command: date -u "+%c = %s" 00428 00429 const char * sourceAuthor; // source code author 00430 const char * sourceVersion; // source code version 00431 const char * sourceEmail; // source code email contact information 00432 const char * sourceURL; // source code web site 00433 const char * sourceCopyright; // source code copyright 00434 const char * sourceLicense; // source code license 00435 unsigned char sourceLicenseCode; // source code license 00436 00437 const char * HIDDescription; // HID description 00438 const char * HIDManufacturer; // HID Manufacturer 00439 const char * HIDModel; // HID Model 00440 const char * HIDEmail; // HID email contact information 00441 const char * HIDURL; // HID Manufacturer web site 00442 00443 // end of version 1 fields 00444 00445 }; 00446 00447 enum PluginHID_Flags { 00448 PluginHID_TypeMask = 0x000f, 00449 PluginHID_TypeUSBAudio = 0x0000, // USB Audio device 00450 PluginHID_TypePCIAudio = 0x0001, // PCI Audio device 00451 00452 PluginHID_ToneMask = 0x0010, 00453 PluginHID_NoTone = 0x0000, 00454 PluginHID_Tone = 0x0010, // Audio device needs a Tone generator 00455 00456 PluginHID_GatewayMask = 0x0020, 00457 PluginHID_NoPSTN = 0x0000, 00458 PluginHID_PSTN = 0x0020, // Audio device with PSTN interoperability 00459 00460 PluginHID_DeviceTypeMask = 0x0040, 00461 PluginHID_DevicePOTS = 0x0000, // Operate like traditional Phone 00462 PluginHID_DeviceCell = 0x0040, // Operate Like a Cell Phone 00463 00464 PluginHID_DeviceSoundMask = 0x0080, 00465 PluginHID_DeviceInternal = 0x0000, 00466 PluginHID_DeviceSound = 0x0080 // is regular PC sound device 00467 }; 00468 00469 // Key Input Mask 00470 enum PluginHID_Input { 00471 PluginHID_None = 0x0000, 00472 PluginHID_KeyPadMask = 0x0010, 00473 PluginHID_Key0 = 0x0010, 00474 PluginHID_Key1 = 0x0011, 00475 PluginHID_Key2 = 0x0012, 00476 PluginHID_Key3 = 0x0013, 00477 PluginHID_Key4 = 0x0014, 00478 PluginHID_Key5 = 0x0015, 00479 PluginHID_Key6 = 0x0016, 00480 PluginHID_Key7 = 0x0017, 00481 PluginHID_Key8 = 0x0018, 00482 PluginHID_Key9 = 0x0019, 00483 PluginHID_KeyStar = 0x001a, // '*' character 00484 PluginHID_KeyHash = 0x001b, // '#' character 00485 PluginHID_KeyA = 0x001c, // (USB) Dial Button 00486 PluginHID_KeyB = 0x001d, // (USB) End Call Button 00487 PluginHID_KeyC = 0x001e, // (USB) Left Menu Navigator key 00488 PluginHID_KeyD = 0x001f, // (USB) Right Menu Navigator key 00489 00490 PluginHID_HookMask = 0x0020, 00491 PluginHID_OffHook = 0x0021, // Hook State (OffHook) N/A for Cell Type 00492 PluginHID_OnHook = 0x0022, // Hook State (OnHook) N/A for Cell Type 00493 00494 PluginHID_RingMask = 0x0030, 00495 PluginHID_StartRing = 0x0031, // Start Ringing the device 00496 PluginHID_StopRing = 0x0032, // Stop Ringing the device 00497 00498 PluginHID_VolumeMask = 0x0040, 00499 PluginHID_VolumeUp = 0x0040, // Volume Up Key pressed 00500 PluginHID_VolumeDown = 0x0041, // Volume Down key presses 00501 PluginHID_SetRecVol = 0x0042, // Set the Record Volume 00502 PluginHID_GetRecVol = 0x0043, // Get Record Volume 00503 PluginHID_SetPlayVol = 0x0044, // Set Play Volume 00504 PluginHID_GetPlayVol = 0x0045, // Get Play Volume 00505 00506 PluginHID_StateMask = 0x0050, 00507 PluginHID_PluggedIn = 0x0050, // Device is pluggedIn 00508 PluginHID_Unplugged = 0x0051, // Device is unplugged 00509 00510 PluginHID_FunctionMask = 0x0060, // Special Function Mark 00511 PluginHID_ClearDisplay = 0x0061, // Clear the digit buffer 00512 00513 }; 00514 00515 struct PluginHID_Definition { 00516 unsigned int version; // codec structure version 00517 00518 // start of version 1 fields 00519 struct PluginHID_information * info; // license information 00520 00521 unsigned int flags; // PluginHID_Flags, 00522 00523 const char * descr; // text decription 00524 const char * sound; // sound device name 00525 00526 void * (*createHID)(const struct PluginHID_Definition * def); // create HID 00527 void (*destroyHID) (const struct PluginHID_Definition * def); // destroy HID 00528 unsigned int (*HIDFunction) (const struct PluginHID_Definition * def, 00529 unsigned int * InputMask, unsigned int * newVal); // do HID function (Polling Function) 00530 void (*displayHID) (const struct PluginHID_Definition * def, const char * display); // LCD display 00531 00532 00533 // end of version 1 fields 00534 }; 00535 00536 typedef struct PluginHID_Definition * (* PluginHID_GetHIDFunction)(unsigned int *, unsigned int); 00537 typedef unsigned (* PluginHID_GetAPIVersionFunction)(); 00538 00539 #endif // LID Plugins 00540 00541 #endif