OPAL  Version 3.14.3
lidplugin.h
Go to the documentation of this file.
1 /*
2  * lidplugins.h
3  *
4  * Line Interface Device plugins handler
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (C) 2006 Post Increment
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Post Increment
24  *
25  * Contributor(s): ______________________________________.
26  *
27  * $Revision: 21293 $
28  * $Author: rjongbloed $
29  * $Date: 2008-10-13 10:24:41 +1100 (Mon, 13 Oct 2008) $
30  */
31 
32 #ifndef OPAL_LIDS_LIDPLUGIN_H
33 #define OPAL_LIDS_LIDPLUGIN_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <time.h>
40 
41 #ifdef _WIN32
42 # ifdef PLUGIN_DLL_EXPORTS
43 # define PLUGIN_DLL_API __declspec(dllexport)
44 # else
45 # define PLUGIN_DLL_API __declspec(dllimport)
46 # endif
47 
48 #else
49 
50 #define PLUGIN_DLL_API
51 
52 #endif
53 
54 #ifdef PWLIB_PLUGIN_API_VERSION
55 #undef PWLIB_PLUGIN_API_VERSION
56 #endif
57 #define PWLIB_PLUGIN_API_VERSION 1
58 
60 //
61 // LID Plugins
62 
63 #define PLUGIN_LID_VERSION 1 // initial version
64 
65 typedef int PluginLID_Boolean;
66 
67 #ifndef FALSE
68 #define FALSE 0
69 #endif
70 #ifndef TRUE
71 #define TRUE 1
72 #endif
73 
74 
75 typedef enum PluginLID_Errors {
96 
97 
99  PluginLID_NoTone = 0x00, // indicates no tones
100  PluginLID_DialTone = 0x01, // Dial tone
101  PluginLID_RingTone = 0x02, // Ring indication tone
102  PluginLID_BusyTone = 0x04, // Line engaged tone
103  PluginLID_FastBusyTone = 0x08, // fast busy tone
104  PluginLID_ClearTone = 0x10, // Call failed/cleared tone (often same as busy tone)
105  PluginLID_CNGTone = 0x20, // Fax CNG tone
106  PluginLID_MwiTone = 0x40, // Message Waiting Tone
108 };
109 
110 
111 typedef struct PluginLID_DialParams
112 {
114  unsigned m_dialToneTimeout;
115  unsigned m_dialStartDelay;
116  unsigned m_progressTimeout;
117  unsigned m_commaDelay;
119 
120 
121 typedef struct PluginLID_Definition
122 {
123  unsigned int apiVersion; // structure version
124 
125  // start of version 1 fields
126  time_t timestamp; // creation time and date - obtain with command: date -u "+%c = %s"
127 
128  const char * name; // LID name text
129  const char * description; // LID description text
130  const char * manufacturer; // LID manufacturer name
131  const char * model; // LID model name
132  const char * revision; // LID hardware revision number
133  const char * manufacturerEmail; // LID manufacturer email contact information
134  const char * manufacturerURL; // LID manufacturer web site
135 
136  const char * author; // source code author
137  const char * authorEmail; // source code email contact information
138  const char * authorURL; // source code web site
139  const char * copyright; // source code copyright
140  const char * license; // source code license
141  const char * version; // source code version
142 
143  const void * userData; // user data value
144 
145  void * (*Create)(const struct PluginLID_Definition * definition);
146  void (*Destroy)(const struct PluginLID_Definition * definition, void * context);
147 
148  PluginLID_Errors (*GetDeviceName)(void * context, unsigned index, char * name, unsigned size);
149  PluginLID_Errors (*Open)(void * context, const char * device);
150  PluginLID_Errors (*Close)(void * context);
151 
152  PluginLID_Errors (*GetLineCount)(void * context, unsigned * count);
153  PluginLID_Errors (*IsLineTerminal)(void * context, unsigned line, PluginLID_Boolean * isTerminal);
154  PluginLID_Errors (*IsLinePresent)(void * context, unsigned line, PluginLID_Boolean forceTest, PluginLID_Boolean * present);
155  PluginLID_Errors (*IsLineOffHook)(void * context, unsigned line, PluginLID_Boolean * offHook);
156  PluginLID_Errors (*SetLineOffHook)(void * context, unsigned line, PluginLID_Boolean newState);
157  PluginLID_Errors (*HookFlash)(void * context, unsigned line, unsigned flashTime);
158  PluginLID_Errors (*HasHookFlash)(void * context, unsigned line, PluginLID_Boolean * flashed);
159  PluginLID_Errors (*IsLineRinging)(void * context, unsigned line, unsigned long * cadence);
160  PluginLID_Errors (*RingLine)(void * context, unsigned line, unsigned nCadence, const unsigned * pattern, unsigned frequency);
161  PluginLID_Errors (*IsLineDisconnected)(void * context, unsigned line, PluginLID_Boolean checkForWink, PluginLID_Boolean * disconnected);
162  PluginLID_Errors (*SetLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean connect);
163  PluginLID_Errors (*IsLineToLineDirect)(void * context, unsigned line1, unsigned line2, PluginLID_Boolean * connected);
164 
165  PluginLID_Errors (*GetSupportedFormat)(void * context, unsigned index, char * mediaFormat, unsigned size);
166  PluginLID_Errors (*SetReadFormat)(void * context, unsigned line, const char * mediaFormat);
167  PluginLID_Errors (*SetWriteFormat)(void * context, unsigned line, const char * mediaFormat);
168  PluginLID_Errors (*GetReadFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
169  PluginLID_Errors (*GetWriteFormat)(void * context, unsigned line, char * mediaFormat, unsigned size);
170  PluginLID_Errors (*StopReading)(void * context, unsigned line);
171  PluginLID_Errors (*StopWriting)(void * context, unsigned line);
172  PluginLID_Errors (*SetReadFrameSize)(void * context, unsigned line, unsigned frameSize);
173  PluginLID_Errors (*SetWriteFrameSize)(void * context, unsigned line, unsigned frameSize);
174  PluginLID_Errors (*GetReadFrameSize)(void * context, unsigned line, unsigned * frameSize);
175  PluginLID_Errors (*GetWriteFrameSize)(void * context, unsigned line, unsigned * frameSize);
176  PluginLID_Errors (*ReadFrame)(void * context, unsigned line, void * buffer, unsigned * count);
177  PluginLID_Errors (*WriteFrame)(void * context, unsigned line, const void * buffer, unsigned count, unsigned * written);
178 
179  PluginLID_Errors (*GetAverageSignalLevel)(void * context, unsigned line, PluginLID_Boolean playback, unsigned * signal);
180 
181  PluginLID_Errors (*EnableAudio)(void * context, unsigned line, PluginLID_Boolean enable);
182  PluginLID_Errors (*IsAudioEnabled)(void * context, unsigned line, PluginLID_Boolean * enable);
183  PluginLID_Errors (*SetRecordVolume)(void * context, unsigned line, unsigned volume);
184  PluginLID_Errors (*SetPlayVolume)(void * context, unsigned line, unsigned volume);
185  PluginLID_Errors (*GetRecordVolume)(void * context, unsigned line, unsigned * volume);
186  PluginLID_Errors (*GetPlayVolume)(void * context, unsigned line, unsigned * volume);
187 
188  PluginLID_Errors (*GetAEC)(void * context, unsigned line, unsigned * level);
189  PluginLID_Errors (*SetAEC)(void * context, unsigned line, unsigned level);
190 
191  PluginLID_Errors (*GetVAD)(void * context, unsigned line, PluginLID_Boolean * enable);
192  PluginLID_Errors (*SetVAD)(void * context, unsigned line, PluginLID_Boolean enable);
193 
194  PluginLID_Errors (*GetCallerID)(void * context, unsigned line, char * idString, unsigned size, PluginLID_Boolean full);
195  PluginLID_Errors (*SetCallerID)(void * context, unsigned line, const char * idString);
196  PluginLID_Errors (*SendVisualMessageWaitingIndicator)(void * context, unsigned line, PluginLID_Boolean on);
197 
198  PluginLID_Errors (*PlayDTMF)(void * context, unsigned line, const char * digits, unsigned onTime, unsigned offTime);
199  PluginLID_Errors (*ReadDTMF)(void * context, unsigned line, char * digit);
200  PluginLID_Errors (*GetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean * removeTones);
201  PluginLID_Errors (*SetRemoveDTMF)(void * context, unsigned line, PluginLID_Boolean removeTones);
202 
203  PluginLID_Errors (*IsToneDetected)(void * context, unsigned line, int * tone);
204  PluginLID_Errors (*WaitForToneDetect)(void * context, unsigned line, unsigned timeout, int * tone);
205  PluginLID_Errors (*WaitForTone)(void * context, unsigned line, int tone, unsigned timeout);
206 
207  PluginLID_Errors (*SetToneParameters)(void * context, unsigned line,
208  unsigned tone,
209  unsigned lowFrequency,
210  unsigned highFrequency,
211  unsigned mixingMode,
212  unsigned numCadences,
213  const unsigned * onTimes,
214  const unsigned * offTimes);
215  PluginLID_Errors (*PlayTone)(void * context, unsigned line, unsigned tone);
216  PluginLID_Errors (*IsTonePlaying)(void * context, unsigned line, PluginLID_Boolean * playing);
217  PluginLID_Errors (*StopTone)(void * context, unsigned line);
218 
219  PluginLID_Errors (*DialOut)(void * context, unsigned line, const char * number, struct PluginLID_DialParams * params);
220 
221  PluginLID_Errors (*GetWinkDuration)(void * context, unsigned line, unsigned * winkDuration);
222  PluginLID_Errors (*SetWinkDuration)(void * context, unsigned line, unsigned winkDuration);
223 
224  PluginLID_Errors (*SetCountryCode)(void * context, unsigned country);
225 
226  PluginLID_Errors (*GetSupportedCountry)(void * context, unsigned index, unsigned * countryCode);
227  // end of version 1 fields
228 
229  PluginLID_Errors (*SetLineConnected)(void * context, unsigned line);
230  PluginLID_Errors (*IsLineConnected)(void * context, unsigned line, PluginLID_Boolean * connected);
231 
233 
234 
235 #ifdef __cplusplus
236 
237 #define PLUGIN_LID_CTOR() \
238  static void * Create(const struct PluginLID_Definition * definition) { return new Context; } \
239  Context()
240 
241 #define PLUGIN_LID_DTOR() \
242  static void Destroy(const struct PluginLID_Definition * definition, void * context) { delete (Context *)context; } \
243  ~Context()
244 
245 #define PLUGIN_FUNCTION_ARG0(fn) \
246  static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
247  PluginLID_Errors fn( )
248 
249 #define PLUGIN_FUNCTION_ARG0(fn) \
250  static PluginLID_Errors fn(void * context) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(); } \
251  PluginLID_Errors fn( )
252 
253 #define PLUGIN_FUNCTION_ARG1(fn, type1,var1) \
254  static PluginLID_Errors fn(void * context, type1 var1) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1); } \
255  PluginLID_Errors fn( type1 var1)
256 
257 #define PLUGIN_FUNCTION_ARG2(fn, type1,var1, type2,var2) \
258  static PluginLID_Errors fn(void * context, type1 var1, type2 var2) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2); } \
259  PluginLID_Errors fn( type1 var1, type2 var2)
260 
261 #define PLUGIN_FUNCTION_ARG3(fn, type1,var1, type2,var2, type3,var3) \
262  static PluginLID_Errors fn(void * context, type1 var1, type2 var2, type3 var3) { return context == NULL ? PluginLID_BadContext : ((Context *)context)->fn(var1, var2, var3); } \
263  PluginLID_Errors fn( type1 var1, type2 var2, type3 var3)
264 
265 #define PLUGIN_FUNCTION_ARG4(fn, type1,var1, type2,var2, type3,var3, type4,var4) \
266  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); } \
267  PluginLID_Errors fn( type1 var1, type2 var2, type3 var3, type4 var4)
268 
269 #define PLUGIN_FUNCTION_ARG8(fn, type1,var1, type2,var2, type3,var3, type4,var4, type5,var5, type6,var6, type7,var7, type8,var8) \
270  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); } \
271  PluginLID_Errors fn( type1 var1, type2 var2, type3 var3, type4 var4, type5 var5, type6 var6, type7 var7, type8 var8)
272 
273 #endif // __cplusplus
274 
275 
276 #define PLUGIN_LID_API_VER_FN PWLibPlugin_GetAPIVersion
277 #define PLUGIN_LID_API_VER_FN_STR "PWLibPlugin_GetAPIVersion"
278 
279 #define PLUGIN_LID_GET_LIDS_FN OpalPluginLID_GetDefinitions
280 #define PLUGIN_LID_GET_LIDS_FN_STR "OpalPluginLID_GetDefinitions"
281 
282 
283 typedef struct PluginLID_Definition * (* PluginLID_GetDefinitionsFunction)(unsigned * /*count*/, unsigned /*version*/);
284 
285 
286 #define PLUGIN_LID_IMPLEMENTATION(defs) \
287  extern "C" { \
288  PLUGIN_DLL_API unsigned int PLUGIN_LID_API_VER_FN() { return PWLIB_PLUGIN_API_VERSION; } \
289  PLUGIN_DLL_API PluginLID_Definition * PLUGIN_LID_GET_LIDS_FN(unsigned * count, unsigned version) \
290  { *count = sizeof(defs)/sizeof(defs[0]); return defs; } \
291  }
292 
293 
294 #ifdef __cplusplus
295 };
296 #endif
297 
298 #endif // OPAL_LIDS_LIDPLUGIN_H