lidplugin.h

Go to the documentation of this file.
00001 /*
00002  * lidplugins.h
00003  *
00004  * Line Interface Device plugins handler
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (C) 2006 Post Increment
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Post Increment
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Log: lidplugin.h,v $
00028  * Revision 2.6  2007/09/04 02:21:20  rjongbloed
00029  * Allow for plug in API versions other than zero.
00030  *
00031  * Revision 2.5  2006/11/05 05:04:46  rjongbloed
00032  * Improved the terminal LID line ringing, epecially for country emulation.
00033  *
00034  * Revision 2.4  2006/10/25 22:26:14  rjongbloed
00035  * Changed LID tone handling to use new tone generation for accurate country based tones.
00036  *
00037  * Revision 2.3  2006/10/22 12:08:51  rjongbloed
00038  * Major change so that sound card based LIDs, eg USB handsets. are handled in
00039  *   common code so not requiring lots of duplication.
00040  *
00041  * Revision 2.2  2006/10/15 06:29:12  rjongbloed
00042  * Added more error codes
00043  *
00044  * Revision 2.1  2006/10/02 13:30:50  rjongbloed
00045  * Added LID plug ins
00046  *
00047  */
00048 
00049 #ifndef __OPAL_LIDPLUGIN_H
00050 #define __OPAL_LIDPLUGIN_H
00051 
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055 
00056 #include <time.h>
00057 
00058 #ifdef _WIN32
00059 #  ifdef PLUGIN_DLL_EXPORTS
00060 #    define PLUGIN_DLL_API __declspec(dllexport)
00061 #  else
00062 #    define PLUGIN_DLL_API __declspec(dllimport)
00063 #  endif
00064 
00065 #else
00066 
00067 #define PLUGIN_DLL_API
00068 
00069 #endif
00070 
00071 #ifdef PWLIB_PLUGIN_API_VERSION
00072 #undef PWLIB_PLUGIN_API_VERSION
00073 #endif
00074 #define PWLIB_PLUGIN_API_VERSION 1
00075 
00077 //
00078 //  LID Plugins
00079 
00080 #define PLUGIN_LID_VERSION 1    // initial version
00081 
00082 typedef int PluginLID_Boolean;
00083 
00084 #ifndef FALSE
00085 #define FALSE 0
00086 #endif
00087 #ifndef TRUE
00088 #define TRUE 1
00089 #endif
00090 
00091 
00092 typedef enum PluginLID_Errors {
00093   PluginLID_NoError = 0,
00094   PluginLID_UnimplementedFunction,
00095   PluginLID_BadContext,
00096   PluginLID_InvalidParameter,
00097   PluginLID_NoSuchDevice,
00098   PluginLID_DeviceOpenFailed,
00099   PluginLID_UsesSoundChannel,
00100   PluginLID_DeviceNotOpen,
00101   PluginLID_NoSuchLine,
00102   PluginLID_OperationNotAllowed,
00103   PluginLID_NoMoreNames,
00104   PluginLID_BufferTooSmall,
00105   PluginLID_UnsupportedMediaFormat,
00106   PluginLID_NoDialTone,
00107   PluginLID_LineBusy,
00108   PluginLID_NoAnswer,
00109   PluginLID_Aborted,
00110   PluginLID_InternalError,
00111   PluginLID_NumErrors
00112 } PluginLID_Errors;
00113 
00114 
00115 enum PluginLID_CallProgressTones {
00116   PluginLID_NoTone       = 0x00,   // indicates no tones
00117   PluginLID_DialTone     = 0x01,   // Dial tone
00118   PluginLID_RingTone     = 0x02,   // Ring indication tone
00119   PluginLID_BusyTone     = 0x04,   // Line engaged tone
00120   PluginLID_FastBusyTone = 0x08,   // fast busy tone
00121   PluginLID_ClearTone    = 0x10,   // Call failed/cleared tone (often same as busy tone)
00122   PluginLID_CNGTone      = 0x20,   // Fax CNG tone
00123   PluginLID_MwiTone      = 0x40,   // Message Waiting Tone
00124   PluginLID_AllTones     = 0x4f
00125 };
00126 
00127 
00128 typedef struct PluginLID_Definition
00129 {
00130   unsigned int apiVersion;  // structure version
00131 
00132   // start of version 1 fields
00133   time_t timestamp;                 // creation time and date - obtain with command: date -u "+%c = %s"
00134 
00135   const char * name;                // LID name text
00136   const char * description;         // LID description text
00137   const char * manufacturer;        // LID manufacturer name
00138   const char * model;               // LID model name
00139   const char * revision;            // LID hardware revision number
00140   const char * manufacturerEmail;   // LID manufacturer email contact information
00141   const char * manufacturerURL;     // LID manufacturer web site
00142 
00143   const char * author;              // source code author
00144   const char * authorEmail;         // source code email contact information
00145   const char * authorURL;           // source code web site
00146   const char * copyright;           // source code copyright
00147   const char * license;             // source code license
00148   const char * version;             // source code version
00149 
00150   const void * userData;            // user data value
00151 
00152   void * (*Create)(const struct PluginLID_Definition * definition);
00153   void (*Destroy)(const struct PluginLID_Definition * definition,  void * context);
00154 
00155   PluginLID_Errors (*GetDeviceName)(void * context, unsigned index, char * name, unsigned size);
00156   PluginLID_Errors (*Open)(void * context, const char * device);
00157   PluginLID_Errors (*Close)(void * context);
00158 
00159   PluginLID_Errors (*GetLineCount)(void * context, unsigned * count);
00160   PluginLID_Errors (*IsLineTerminal)(void * context, unsigned line, PluginLID_Boolean * isTerminal);
00161   PluginLID_Errors (*IsLinePresent)(void * context, unsigned line, PluginLID_Boolean forceTest, PluginLID_Boolean * present);
00162   PluginLID_Errors (*IsLineOffHook)(void * context, unsigned line, PluginLID_Boolean * offHook);
00163   PluginLID_Errors (*SetLineOffHook)(void * context, unsigned line, PluginLID_Boolean newState);
00164   PluginLID_Errors (*HookFlash)(void * context, unsigned line, unsigned flashTime);
00165   PluginLID_Errors (*HasHookFlash)(void * context, unsigned line, PluginLID_Boolean * flashed);
00166   PluginLID_Errors (*IsLineRinging)(void * context, unsigned line, unsigned long * cadence);
00167   PluginLID_Errors (*RingLine)(void * context, unsigned line, unsigned nCadence, const unsigned * pattern, unsigned frequency);
00168   PluginLID_Errors (*IsLineConnected)(void * context, unsigned line, PluginLID_Boolean checkForWink, PluginLID_Boolean * connected);
00169   PluginLID_Errors (*SetLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean connect);
00170   PluginLID_Errors (*IsLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean * connected);
00171 
00172   PluginLID_Errors (*GetSupportedFormat)(void * context, unsigned index, char * mediaFormat, unsigned size);
00173   PluginLID_Errors (*SetReadFormat)(void * context, unsigned line, const char * mediaFormat);
00174   PluginLID_Errors (*SetWriteFormat)(void * context, unsigned line, const char * mediaFormat);
00175   PluginLID_Errors (*GetReadFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
00176   PluginLID_Errors (*GetWriteFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
00177   PluginLID_Errors (*StopReading)(void * context, unsigned line);
00178   PluginLID_Errors (*StopWriting)(void * context, unsigned line);
00179   PluginLID_Errors (*SetReadFrameSize)(void * context, unsigned line, unsigned frameSize);
00180   PluginLID_Errors (*SetWriteFrameSize)(void * context, unsigned line, unsigned frameSize);
00181   PluginLID_Errors (*GetReadFrameSize)(void * context, unsigned line, unsigned * frameSize);
00182   PluginLID_Errors (*GetWriteFrameSize)(void * context, unsigned line, unsigned * frameSize);
00183   PluginLID_Errors (*ReadFrame)(void * context, unsigned line, void * buffer, unsigned * count);
00184   PluginLID_Errors (*WriteFrame)(void * context, unsigned line, const void * buffer, unsigned count, unsigned * written);
00185 
00186   PluginLID_Errors (*GetAverageSignalLevel)(void * context, unsigned line, PluginLID_Boolean playback, unsigned * signal);
00187 
00188   PluginLID_Errors (*EnableAudio)(void * context, unsigned line, PluginLID_Boolean enable);
00189   PluginLID_Errors (*IsAudioEnabled)(void * context, unsigned line, PluginLID_Boolean * enable);
00190   PluginLID_Errors (*SetRecordVolume)(void * context, unsigned line, unsigned volume);
00191   PluginLID_Errors (*SetPlayVolume)(void * context, unsigned line, unsigned volume);
00192   PluginLID_Errors (*GetRecordVolume)(void * context, unsigned line, unsigned * volume);
00193   PluginLID_Errors (*GetPlayVolume)(void * context, unsigned line, unsigned * volume);
00194 
00195   PluginLID_Errors (*GetAEC)(void * context, unsigned line, unsigned * level);
00196   PluginLID_Errors (*SetAEC)(void * context, unsigned line, unsigned level);
00197 
00198   PluginLID_Errors (*GetVAD)(void * context, unsigned line, PluginLID_Boolean * enable);
00199   PluginLID_Errors (*SetVAD)(void * context, unsigned line, PluginLID_Boolean enable);
00200 
00201   PluginLID_Errors (*GetCallerID)(void * context, unsigned line, char * idString, unsigned size, PluginLID_Boolean full);
00202   PluginLID_Errors (*SetCallerID)(void * context, unsigned line, const char * idString);
00203   PluginLID_Errors (*SendCallerIDOnCallWaiting)(void * context, unsigned line, const char * idString);
00204   PluginLID_Errors (*SendVisualMessageWaitingIndicator)(void * context, unsigned line, PluginLID_Boolean on);
00205 
00206   PluginLID_Errors (*PlayDTMF)(void * context, unsigned line, const char * digits, unsigned onTime, unsigned offTime);
00207   PluginLID_Errors (*ReadDTMF)(void * context, unsigned line, char * digit);
00208   PluginLID_Errors (*GetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean * removeTones);
00209   PluginLID_Errors (*SetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean removeTones);
00210 
00211   PluginLID_Errors (*IsToneDetected)(void * context, unsigned line, int * tone);
00212   PluginLID_Errors (*WaitForToneDetect)(void * context, unsigned line, unsigned timeout, int * tone);
00213   PluginLID_Errors (*WaitForTone)(void * context, unsigned line, int tone, unsigned timeout);
00214 
00215   PluginLID_Errors (*SetToneFilterParameters)(void * context, unsigned line,
00216                                               unsigned tone,
00217                                               unsigned lowFrequency,
00218                                               unsigned highFrequency,
00219                                               unsigned numCadences,
00220                                               const unsigned * onTimes,
00221                                               const unsigned * offTimes);
00222   PluginLID_Errors (*PlayTone)(void * context, unsigned line, unsigned tone);
00223   PluginLID_Errors (*IsTonePlaying)(void * context, unsigned line, PluginLID_Boolean * playing);
00224   PluginLID_Errors (*StopTone)(void * context, unsigned line);
00225 
00226   PluginLID_Errors (*DialOut)(void * context, unsigned line, const char * number, PluginLID_Boolean requireTones, unsigned uiDialDelay);
00227 
00228   PluginLID_Errors (*GetWinkDuration)(void * context, unsigned line, unsigned * winkDuration);
00229   PluginLID_Errors (*SetWinkDuration)(void * context, unsigned line, unsigned winkDuration);
00230 
00231   PluginLID_Errors (*SetCountryCode)(void * context, unsigned country);
00232 
00233   PluginLID_Errors (*GetSupportedCountry)(void * context, unsigned index, unsigned * countryCode);
00234   // end of version 1 fields
00235 } PluginLID_Definition;
00236 
00237 
00238 #ifdef __cplusplus
00239 
00240 #define PLUGIN_LID_CTOR() \
00241     static void * Create(const struct PluginLID_Definition * definition) { return new Context; } \
00242     Context()
00243 
00244 #define PLUGIN_LID_DTOR() \
00245     static void Destroy(const struct PluginLID_Definition * definition,  void * context) { delete (Context *)context; } \
00246     ~Context()
00247 
00248 #define PLUGIN_FUNCTION_ARG0(fn) \
00249      static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
00250             PluginLID_Errors fn(              )
00251 
00252 #define PLUGIN_FUNCTION_ARG0(fn) \
00253      static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
00254             PluginLID_Errors fn(              )
00255 
00256 #define PLUGIN_FUNCTION_ARG1(fn,                type1,var1) \
00257      static PluginLID_Errors fn(void * context, type1 var1) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1); } \
00258             PluginLID_Errors fn(                type1 var1)
00259 
00260 #define PLUGIN_FUNCTION_ARG2(fn,                type1,var1, type2,var2) \
00261      static PluginLID_Errors fn(void * context, type1 var1, type2 var2) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2); } \
00262             PluginLID_Errors fn(                type1 var1, type2 var2)
00263 
00264 #define PLUGIN_FUNCTION_ARG3(fn,                type1,var1, type2,var2, type3,var3) \
00265      static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3); } \
00266             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3)
00267 
00268 #define PLUGIN_FUNCTION_ARG4(fn,                type1,var1, type2,var2, type3,var3, type4,var4) \
00269      static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3, type4 var4) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3, var4); } \
00270             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3, type4 var4)
00271 
00272 #define PLUGIN_FUNCTION_ARG7(fn,                type1,var1, type2,var2, type3,var3, type4,var4, type5,var5, type6,var6, type7,var7) \
00273      static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3, type4 var4, type5 var5, type6 var6, type7 var7) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3, var4, var5, var6, var7); } \
00274             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3, type4 var4, type5 var5, type6 var6, type7 var7)
00275 
00276 #endif // __cplusplus
00277 
00278 
00279 #define PLUGIN_LID_API_VER_FN       PWLibPlugin_GetAPIVersion
00280 #define PLUGIN_LID_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
00281 
00282 #define PLUGIN_LID_GET_LIDS_FN     OpalPluginLID_GetDefinitions
00283 #define PLUGIN_LID_GET_LIDS_FN_STR "OpalPluginLID_GetDefinitions"
00284 
00285 
00286 typedef struct PluginLID_Definition * (* PluginLID_GetDefinitionsFunction)(unsigned * /*count*/, unsigned /*version*/);
00287 
00288 
00289 #define PLUGIN_LID_IMPLEMENTATION(defs) \
00290   extern "C" { \
00291     PLUGIN_DLL_API unsigned int PLUGIN_LID_API_VER_FN() { return PWLIB_PLUGIN_API_VERSION; } \
00292     PLUGIN_DLL_API PluginLID_Definition * PLUGIN_LID_GET_LIDS_FN(unsigned * count, unsigned version) \
00293       { *count = sizeof(defs)/sizeof(defs[0]); return defs; } \
00294   }
00295 
00296 
00297 #ifdef __cplusplus
00298 };
00299 #endif
00300 
00301 #endif // __OPAL_LIDPLUGIN_H

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