# 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  * $Revision: 21293 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2008-10-12 18:24:41 -0500 (Sun, 12 Oct 2008) $
    00030  */
    00031
    00032 #ifndef OPAL_LIDS_LIDPLUGIN_H
    00033 #define OPAL_LIDS_LIDPLUGIN_H
    00034
    00035 #ifdef __cplusplus
    00036 extern "C" {
    00037 #endif
    00038
    00039 #include <time.h>
    00040
    00041 #ifdef _WIN32
    00042 #  ifdef PLUGIN_DLL_EXPORTS
    00043 #    define PLUGIN_DLL_API __declspec(dllexport)
    00044 #  else
    00045 #    define PLUGIN_DLL_API __declspec(dllimport)
    00046 #  endif
    00047
    00048 #else
    00049
    00050 #define PLUGIN_DLL_API
    00051
    00052 #endif
    00053
    00054 #ifdef PWLIB_PLUGIN_API_VERSION
    00055 #undef PWLIB_PLUGIN_API_VERSION
    00056 #endif
    00057 #define PWLIB_PLUGIN_API_VERSION 1
    00058
    00060 //
    00061 //  LID Plugins
    00062
    00063 #define PLUGIN_LID_VERSION 1    // initial version
    00064
    00065 typedef int PluginLID_Boolean;
    00066
    00067 #ifndef FALSE
    00068 #define FALSE 0
    00069 #endif
    00070 #ifndef TRUE
    00071 #define TRUE 1
    00072 #endif
    00073
    00074
    00075 typedef enum PluginLID_Errors {
    00076   PluginLID_NoError = 0,
    00077   PluginLID_UnimplementedFunction,
    00078   PluginLID_BadContext,
    00079   PluginLID_InvalidParameter,
    00080   PluginLID_NoSuchDevice,
    00081   PluginLID_DeviceOpenFailed,
    00082   PluginLID_UsesSoundChannel,
    00083   PluginLID_DeviceNotOpen,
    00084   PluginLID_NoSuchLine,
    00085   PluginLID_OperationNotAllowed,
    00086   PluginLID_NoMoreNames,
    00087   PluginLID_BufferTooSmall,
    00088   PluginLID_UnsupportedMediaFormat,
    00089   PluginLID_NoDialTone,
    00090   PluginLID_LineBusy,
    00091   PluginLID_NoAnswer,
    00092   PluginLID_Aborted,
    00093   PluginLID_InternalError,
    00094   PluginLID_NumErrors
    00095 } PluginLID_Errors;
    00096
    00097
    00098 enum PluginLID_CallProgressTones {
    00099   PluginLID_NoTone       = 0x00,   // indicates no tones
    00100   PluginLID_DialTone     = 0x01,   // Dial tone
    00101   PluginLID_RingTone     = 0x02,   // Ring indication tone
    00102   PluginLID_BusyTone     = 0x04,   // Line engaged tone
    00103   PluginLID_FastBusyTone = 0x08,   // fast busy tone
    00104   PluginLID_ClearTone    = 0x10,   // Call failed/cleared tone (often same as busy tone)
    00105   PluginLID_CNGTone      = 0x20,   // Fax CNG tone
    00106   PluginLID_MwiTone      = 0x40,   // Message Waiting Tone
    00107   PluginLID_AllTones     = 0x4f
    00108 };
    00109
    00110
    00111 typedef struct PluginLID_DialParams
    00112 {
    00113   bool     m_requireTones;
    00114   unsigned m_dialToneTimeout;
    00115   unsigned m_dialStartDelay;
    00116   unsigned m_progressTimeout;
    00117   unsigned m_commaDelay;
    00118 } PluginLID_DialParams;
    00119
    00120
    00121 typedef struct PluginLID_Definition
    00122 {
    00123   unsigned int apiVersion;  // structure version
    00124
    00125   // start of version 1 fields
    00126   time_t timestamp;                 // creation time and date - obtain with command: date -u "+%c = %s"
    00127
    00128   const char * name;                // LID name text
    00129   const char * description;         // LID description text
    00130   const char * manufacturer;        // LID manufacturer name
    00131   const char * model;               // LID model name
    00132   const char * revision;            // LID hardware revision number
    00133   const char * manufacturerEmail;   // LID manufacturer email contact information
    00134   const char * manufacturerURL;     // LID manufacturer web site
    00135
    00136   const char * author;              // source code author
    00137   const char * authorEmail;         // source code email contact information
    00138   const char * authorURL;           // source code web site
    00139   const char * copyright;           // source code copyright
    00140   const char * license;             // source code license
    00141   const char * version;             // source code version
    00142
    00143   const void * userData;            // user data value
    00144
    00145   void * (*Create)(const struct PluginLID_Definition * definition);
    00146   void (*Destroy)(const struct PluginLID_Definition * definition,  void * context);
    00147
    00148   PluginLID_Errors (*GetDeviceName)(void * context, unsigned index, char * name, unsigned size);
    00149   PluginLID_Errors (*Open)(void * context, const char * device);
    00150   PluginLID_Errors (*Close)(void * context);
    00151
    00152   PluginLID_Errors (*GetLineCount)(void * context, unsigned * count);
    00153   PluginLID_Errors (*IsLineTerminal)(void * context, unsigned line, PluginLID_Boolean * isTerminal);
    00154   PluginLID_Errors (*IsLinePresent)(void * context, unsigned line, PluginLID_Boolean forceTest, PluginLID_Boolean * present);
    00155   PluginLID_Errors (*IsLineOffHook)(void * context, unsigned line, PluginLID_Boolean * offHook);
    00156   PluginLID_Errors (*SetLineOffHook)(void * context, unsigned line, PluginLID_Boolean newState);
    00157   PluginLID_Errors (*HookFlash)(void * context, unsigned line, unsigned flashTime);
    00158   PluginLID_Errors (*HasHookFlash)(void * context, unsigned line, PluginLID_Boolean * flashed);
    00159   PluginLID_Errors (*IsLineRinging)(void * context, unsigned line, unsigned long * cadence);
    00160   PluginLID_Errors (*RingLine)(void * context, unsigned line, unsigned nCadence, const unsigned * pattern, unsigned frequency);
    00161   PluginLID_Errors (*IsLineDisconnected)(void * context, unsigned line, PluginLID_Boolean checkForWink, PluginLID_Boolean * disconnected);
    00162   PluginLID_Errors (*SetLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean connect);
    00163   PluginLID_Errors (*IsLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean * connected);
    00164
    00165   PluginLID_Errors (*GetSupportedFormat)(void * context, unsigned index, char * mediaFormat, unsigned size);
    00166   PluginLID_Errors (*SetReadFormat)(void * context, unsigned line, const char * mediaFormat);
    00167   PluginLID_Errors (*SetWriteFormat)(void * context, unsigned line, const char * mediaFormat);
    00168   PluginLID_Errors (*GetReadFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
    00169   PluginLID_Errors (*GetWriteFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
    00170   PluginLID_Errors (*StopReading)(void * context, unsigned line);
    00171   PluginLID_Errors (*StopWriting)(void * context, unsigned line);
    00172   PluginLID_Errors (*SetReadFrameSize)(void * context, unsigned line, unsigned frameSize);
    00173   PluginLID_Errors (*SetWriteFrameSize)(void * context, unsigned line, unsigned frameSize);
    00174   PluginLID_Errors (*GetReadFrameSize)(void * context, unsigned line, unsigned * frameSize);
    00175   PluginLID_Errors (*GetWriteFrameSize)(void * context, unsigned line, unsigned * frameSize);
    00176   PluginLID_Errors (*ReadFrame)(void * context, unsigned line, void * buffer, unsigned * count);
    00177   PluginLID_Errors (*WriteFrame)(void * context, unsigned line, const void * buffer, unsigned count, unsigned * written);
    00178
    00179   PluginLID_Errors (*GetAverageSignalLevel)(void * context, unsigned line, PluginLID_Boolean playback, unsigned * signal);
    00180
    00181   PluginLID_Errors (*EnableAudio)(void * context, unsigned line, PluginLID_Boolean enable);
    00182   PluginLID_Errors (*IsAudioEnabled)(void * context, unsigned line, PluginLID_Boolean * enable);
    00183   PluginLID_Errors (*SetRecordVolume)(void * context, unsigned line, unsigned volume);
    00184   PluginLID_Errors (*SetPlayVolume)(void * context, unsigned line, unsigned volume);
    00185   PluginLID_Errors (*GetRecordVolume)(void * context, unsigned line, unsigned * volume);
    00186   PluginLID_Errors (*GetPlayVolume)(void * context, unsigned line, unsigned * volume);
    00187
    00188   PluginLID_Errors (*GetAEC)(void * context, unsigned line, unsigned * level);
    00189   PluginLID_Errors (*SetAEC)(void * context, unsigned line, unsigned level);
    00190
    00191   PluginLID_Errors (*GetVAD)(void * context, unsigned line, PluginLID_Boolean * enable);
    00192   PluginLID_Errors (*SetVAD)(void * context, unsigned line, PluginLID_Boolean enable);
    00193
    00194   PluginLID_Errors (*GetCallerID)(void * context, unsigned line, char * idString, unsigned size, PluginLID_Boolean full);
    00195   PluginLID_Errors (*SetCallerID)(void * context, unsigned line, const char * idString);
    00196   PluginLID_Errors (*SendVisualMessageWaitingIndicator)(void * context, unsigned line, PluginLID_Boolean on);
    00197
    00198   PluginLID_Errors (*PlayDTMF)(void * context, unsigned line, const char * digits, unsigned onTime, unsigned offTime);
    00199   PluginLID_Errors (*ReadDTMF)(void * context, unsigned line, char * digit);
    00200   PluginLID_Errors (*GetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean * removeTones);
    00201   PluginLID_Errors (*SetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean removeTones);
    00202
    00203   PluginLID_Errors (*IsToneDetected)(void * context, unsigned line, int * tone);
    00204   PluginLID_Errors (*WaitForToneDetect)(void * context, unsigned line, unsigned timeout, int * tone);
    00205   PluginLID_Errors (*WaitForTone)(void * context, unsigned line, int tone, unsigned timeout);
    00206
    00207   PluginLID_Errors (*SetToneParameters)(void * context, unsigned line,
    00208                                         unsigned tone,
    00209                                         unsigned lowFrequency,
    00210                                         unsigned highFrequency,
    00211                                         unsigned mixingMode,
    00212                                         unsigned numCadences,
    00213                                         const unsigned * onTimes,
    00214                                         const unsigned * offTimes);
    00215   PluginLID_Errors (*PlayTone)(void * context, unsigned line, unsigned tone);
    00216   PluginLID_Errors (*IsTonePlaying)(void * context, unsigned line, PluginLID_Boolean * playing);
    00217   PluginLID_Errors (*StopTone)(void * context, unsigned line);
    00218
    00219   PluginLID_Errors (*DialOut)(void * context, unsigned line, const char * number, struct PluginLID_DialParams * params);
    00220
    00221   PluginLID_Errors (*GetWinkDuration)(void * context, unsigned line, unsigned * winkDuration);
    00222   PluginLID_Errors (*SetWinkDuration)(void * context, unsigned line, unsigned winkDuration);
    00223
    00224   PluginLID_Errors (*SetCountryCode)(void * context, unsigned country);
    00225
    00226   PluginLID_Errors (*GetSupportedCountry)(void * context, unsigned index, unsigned * countryCode);
    00227   // end of version 1 fields
    00228
    00229   PluginLID_Errors (*SetLineConnected)(void * context, unsigned line);
    00230   PluginLID_Errors (*IsLineConnected)(void * context, unsigned line, PluginLID_Boolean * connected);
    00231
    00232 } PluginLID_Definition;
    00233
    00234
    00235 #ifdef __cplusplus
    00236
    00237 #define PLUGIN_LID_CTOR() \
    00238     static void * Create(const struct PluginLID_Definition * definition) { return new Context; } \
    00239     Context()
    00240
    00241 #define PLUGIN_LID_DTOR() \
    00242     static void Destroy(const struct PluginLID_Definition * definition,  void * context) { delete (Context *)context; } \
    00243     ~Context()
    00244
    00245 #define PLUGIN_FUNCTION_ARG0(fn) \
    00246      static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
    00247             PluginLID_Errors fn(              )
    00248
    00249 #define PLUGIN_FUNCTION_ARG0(fn) \
    00250      static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
    00251             PluginLID_Errors fn(              )
    00252
    00253 #define PLUGIN_FUNCTION_ARG1(fn,                type1,var1) \
    00254      static PluginLID_Errors fn(void * context, type1 var1) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1); } \
    00255             PluginLID_Errors fn(                type1 var1)
    00256
    00257 #define PLUGIN_FUNCTION_ARG2(fn,                type1,var1, type2,var2) \
    00258      static PluginLID_Errors fn(void * context, type1 var1, type2 var2) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2); } \
    00259             PluginLID_Errors fn(                type1 var1, type2 var2)
    00260
    00261 #define PLUGIN_FUNCTION_ARG3(fn,                type1,var1, type2,var2, type3,var3) \
    00262      static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3); } \
    00263             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3)
    00264
    00265 #define PLUGIN_FUNCTION_ARG4(fn,                type1,var1, type2,var2, type3,var3, type4,var4) \
    00266      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); } \
    00267             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3, type4 var4)
    00268
    00269 #define PLUGIN_FUNCTION_ARG8(fn,                type1,var1, type2,var2, type3,var3, type4,var4, type5,var5, type6,var6, type7,var7, type8,var8) \
    00270      static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3, type4 var4, type5 var5, type6 var6, type7 var7, type8 var8) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3, var4, var5, var6, var7, var8); } \
    00271             PluginLID_Errors fn(                type1 var1, type2 var2, type3 var3, type4 var4, type5 var5, type6 var6, type7 var7, type8 var8)
    00272
    00273 #endif // __cplusplus
    00274
    00275
    00276 #define PLUGIN_LID_API_VER_FN       PWLibPlugin_GetAPIVersion
    00277 #define PLUGIN_LID_API_VER_FN_STR   "PWLibPlugin_GetAPIVersion"
    00278
    00279 #define PLUGIN_LID_GET_LIDS_FN     OpalPluginLID_GetDefinitions
    00280 #define PLUGIN_LID_GET_LIDS_FN_STR "OpalPluginLID_GetDefinitions"
    00281
    00282
    00283 typedef struct PluginLID_Definition * (* PluginLID_GetDefinitionsFunction)(unsigned * /*count*/, unsigned /*version*/);
    00284
    00285
    00286 #define PLUGIN_LID_IMPLEMENTATION(defs) \
    00287   extern "C" { \
    00288     PLUGIN_DLL_API unsigned int PLUGIN_LID_API_VER_FN() { return PWLIB_PLUGIN_API_VERSION; } \
    00289     PLUGIN_DLL_API PluginLID_Definition * PLUGIN_LID_GET_LIDS_FN(unsigned * count, unsigned version) \
    00290       { *count = sizeof(defs)/sizeof(defs[0]); return defs; } \
    00291   }
    00292
    00293
    00294 #ifdef __cplusplus
    00295 };
    00296 #endif
    00297
    00298 #endif // OPAL_LIDS_LIDPLUGIN_H