Utilise new MergeSym feature to no longer overwrite the source .DEF file when buildin...
[openh323.git] / include / lid.h
blobafd0db54ec46d9433dc2e3a4cb97ff216e33ab99
1 /*
2 * lid.h
4 * Line Interface Device
6 * Open Phone Abstraction Library
8 * Copyright (c) 1999-2000 Equivalence Pty. Ltd.
10 * The contents of this file are subject to the Mozilla Public License
11 * Version 1.0 (the "License"); you may not use this file except in
12 * compliance with the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS"
16 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17 * the License for the specific language governing rights and limitations
18 * under the License.
20 * The Original Code is Open H323 Library.
22 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24 * Portions of this code were written with the assisance of funding from
25 * Quicknet Technologies, Inc. http://www.quicknet.net.
27 * Contributor(s): ______________________________________.
29 * $Log$
30 * Revision 1.58 2005/11/30 13:05:01 csoutheren
31 * Changed tags for Doxygen
33 * Revision 1.57 2005/07/03 13:59:43 shorne
34 * Add LID type identifier (for Plugin LID support)
36 * Revision 1.56 2003/04/29 08:29:13 robertj
37 * Cleaned up documentation for new wink duration functions.
39 * Revision 1.55 2003/04/28 01:47:52 dereks
40 * Add ability to set/get wink duration for ixj device.
42 * Revision 1.54 2003/03/05 06:26:40 robertj
43 * Added function to play a WAV file to LID, thanks Pietro Ravasio
45 * Revision 1.53 2002/11/05 04:26:48 robertj
46 * Imported RingLine() by array from OPAL.
48 * Revision 1.52 2002/10/29 00:46:04 dereks
49 * Fix typo in comments.
51 * Revision 1.51 2002/09/16 01:14:15 robertj
52 * Added #define so can select if #pragma interface/implementation is used on
53 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
55 * Revision 1.50 2002/09/03 06:19:37 robertj
56 * Normalised the multi-include header prevention ifdef/define symbol.
58 * Revision 1.49 2002/08/05 10:03:47 robertj
59 * Cosmetic changes to normalise the usage of pragma interface/implementation.
61 * Revision 1.48 2002/06/27 08:52:53 robertj
62 * Fixed typo and naming convention for Cisco G.723.1 annex A capability.
64 * Revision 1.47 2002/06/26 05:45:41 robertj
65 * Added capability for Cisco IOS non-standard name for G.723.1 Annex A so
66 * can now utilise SID frames with Cisco gateways.
68 * Revision 1.46 2002/06/25 08:30:08 robertj
69 * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
70 * the OLC dataType silenceSuppression field so does not send SID frames
71 * to receiver codecs that do not understand them.
73 * Revision 1.45 2002/05/09 06:26:30 robertj
74 * Added fuction to get the current audio enable state for line in device.
75 * Changed IxJ EnableAudio() semantics so is exclusive, no direct switching
76 * from PSTN to POTS and vice versa without disabling the old one first.
78 * Revision 1.44 2002/01/23 01:58:25 robertj
79 * Added function to determine if codecs raw data channel is native format.
81 * Revision 1.43 2001/07/19 05:54:27 robertj
82 * Updated interface to xJACK drivers to utilise cadence and filter functions
83 * for dial tone, busy tone and ringback tone detection.
85 * Revision 1.42 2001/05/22 00:31:41 robertj
86 * Changed to allow optional wink detection for line disconnect
88 * Revision 1.41 2001/03/29 23:42:34 robertj
89 * Added ability to get average signal level for both receive and transmit.
90 * Changed silence detection to use G.723.1 SID frames as indicator of
91 * silence instead of using the average energy and adaptive threshold.
93 * Revision 1.40 2001/02/13 05:02:39 craigs
94 * Extended PlayDTMF to allow generation of additional simple tones
96 * Revision 1.39 2001/02/09 05:16:24 robertj
97 * Added #pragma interface for GNU C++.
99 * Revision 1.38 2001/01/25 07:27:14 robertj
100 * Major changes to add more flexible OpalMediaFormat class to normalise
101 * all information about media types, especially codecs.
103 * Revision 1.37 2001/01/24 05:34:49 robertj
104 * Altered volume control range to be percentage, ie 100 is max volume.
106 * Revision 1.36 2001/01/11 05:39:44 robertj
107 * Fixed usage of G.723.1 CNG 1 byte frames.
109 * Revision 1.35 2000/12/19 06:38:57 robertj
110 * Fixed missing virtual on IsTonePlaying() function.
112 * Revision 1.34 2000/12/17 22:08:20 craigs
113 * Changed GetCountryCodeList to return PStringList
115 * Revision 1.33 2000/12/11 01:23:32 craigs
116 * Added extra routines to allow country string manipulation
118 * Revision 1.32 2000/11/30 08:48:35 robertj
119 * Added functions to enable/disable Voice Activity Detection in LID's
121 * Revision 1.31 2000/11/26 23:12:18 craigs
122 * Added hook flash detection API
124 * Revision 1.30 2000/11/24 10:46:12 robertj
125 * Added a raw PCM dta mode for generating/detecting standard tones.
126 * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
128 * Revision 1.29 2000/11/20 03:15:13 craigs
129 * Changed tone detection API slightly to allow detection of multiple
130 * simultaneous tones
131 * Added fax CNG tone to tone list
133 * Revision 1.28 2000/11/06 02:00:18 eokerson
134 * Added support for AGC on ixj devices under Linux.
136 * Revision 1.27 2000/11/03 06:22:48 robertj
137 * Added flag to IsLinePresent() to force slow test, guarenteeing correct value.
139 * Revision 1.26 2000/10/13 02:24:06 robertj
140 * Moved frame reblocking code from LID channel to LID itself and added
141 * ReadBlock/WriteBlock functions to allow non integral frame sizes.
143 * Revision 1.25 2000/09/25 22:31:19 craigs
144 * Added G.723.1 frame erasure capability
146 * Revision 1.24 2000/09/23 07:20:28 robertj
147 * Fixed problem with being able to distinguish between sw and hw codecs in LID channel.
149 * Revision 1.23 2000/09/22 01:35:03 robertj
150 * Added support for handling LID's that only do symmetric codecs.
152 * Revision 1.22 2000/08/31 13:14:40 craigs
153 * Added functions to LID
154 * More bulletproofing to Linux driver
156 * Revision 1.21 2000/08/30 23:24:24 robertj
157 * Renamed string version of SetCountrCode() to SetCountryCodeName() to avoid
158 * C++ masking ancestor overloaded function when overriding numeric version.
160 * Revision 1.20 2000/08/18 04:17:48 robertj
161 * Added Auto setting to AEC enum.
163 * Revision 1.19 2000/06/19 00:32:13 robertj
164 * Changed functionf or adding all lid capabilities to not assume it is to an endpoint.
166 * Revision 1.18 2000/06/01 07:52:19 robertj
167 * Changed some LID capability code back again so does not unneedfully break existing API.
169 * Revision 1.17 2000/05/30 10:19:17 robertj
170 * Added function to add capabilities given a LID.
171 * Improved LID capabilities so cannot create one that is not explicitly supported.
173 * Revision 1.16 2000/05/24 06:42:18 craigs
174 * Added calls to get volume settings
176 * Revision 1.15 2000/05/10 04:05:26 robertj
177 * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
179 * Revision 1.14 2000/05/02 04:32:24 robertj
180 * Fixed copyright notice comment.
182 * Revision 1.13 2000/04/14 17:18:25 robertj
183 * Fixed problem with error reporting from LID hardware.
185 * Revision 1.12 2000/04/10 17:44:52 robertj
186 * Added higher level "DialOut" function for PSTN lines.
187 * Added hook flash function.
189 * Revision 1.11 2000/04/05 18:04:12 robertj
190 * Changed caller ID code for better portability.
192 * Revision 1.10 2000/03/30 23:10:50 robertj
193 * Fixed error in comments regarding GetFramerate() function.
195 * Revision 1.9 2000/03/29 20:54:19 robertj
196 * Added function on LID to get available codecs.
197 * Changed codec to use number of frames rather than number of bytes.
199 * Revision 1.8 2000/03/23 23:36:48 robertj
200 * Added more calling tone detection functionality.
202 * Revision 1.7 2000/03/23 02:43:15 robertj
203 * Fixed default DTMF timing.
205 * Revision 1.6 2000/03/22 17:18:49 robertj
206 * Changed default DTMF tone string times.
208 * Revision 1.5 2000/03/21 03:06:48 robertj
209 * Changes to make RTP TX of exact numbers of frames in some codecs.
211 * Revision 1.4 2000/01/13 12:39:29 robertj
212 * Added string based country codes to LID.
214 * Revision 1.3 2000/01/13 04:03:45 robertj
215 * Added video transmission
217 * Revision 1.2 2000/01/07 08:28:09 robertj
218 * Additions and changes to line interface device base class.
220 * Revision 1.1 1999/12/23 23:02:35 robertj
221 * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
225 #ifndef __OPAL_LID_H
226 #define __OPAL_LID_H
228 #ifdef P_USE_PRAGMA
229 #pragma interface
230 #endif
233 #include "codecs.h"
234 #include "h323caps.h"
237 ///////////////////////////////////////////////////////////////////////////////
239 /** Line Interface Device abstraction.
240 Note all functions in this device abstraction are assumed to be thread atomic.
242 class OpalLineInterfaceDevice : public PObject
244 PCLASSINFO(OpalLineInterfaceDevice, PObject);
246 public:
247 /**Construct a new line interface device.
249 OpalLineInterfaceDevice();
251 /**Open the line interface device.
253 virtual BOOL Open(
254 const PString & device ///< Device identifier name.
255 ) = 0;
257 /**Determine if the line interface device is open.
259 virtual BOOL IsOpen() const;
261 /**Close the line interface device.
263 virtual BOOL Close();
265 /**Determine the type of line interface device.
266 This is a string indication of the card type for user interface
267 display purposes or device specific control. The device should be
268 as detailed as possible eg "Quicknet LineJACK".
270 virtual PString GetName() const = 0;
272 /**Get the total number of lines supported by this device.
274 virtual unsigned GetLineCount() = 0;
276 /**Get the type of the line.
277 A "terminal" line is one where a call may terminate. For example a POTS
278 line with a standard telephone handset on it would be a terminal line.
279 The alternative is a "network" line, that is one connected to switched
280 network eg the standard PSTN.
282 virtual BOOL IsLineTerminal(
283 unsigned line ///< Number of line
287 /**Determine if a physical line is present on the logical line.
289 virtual BOOL IsLinePresent(
290 unsigned line, ///< Number of line
291 BOOL force = FALSE ///< Force test, do not optimise
295 /**Determine if line is currently off hook.
296 This function implies that the state is debounced and that a return
297 value of TRUE indicates that the phone is really off hook. That is
298 hook flashes and winks are masked out.
300 virtual BOOL IsLineOffHook(
301 unsigned line ///< Number of line
302 ) = 0;
304 /**Set the hook state of the line.
305 Note that not be possible on a given line, for example a POTS line with
306 a standard telephone handset. The hook state is determined by external
307 hardware and cannot be changed by the software.
309 virtual BOOL SetLineOffHook(
310 unsigned line, ///< Number of line
311 BOOL newState = TRUE ///< New state to set
312 ) = 0;
314 /**Set the hook state of the line.
315 This is the complement of SetLineOffHook().
317 virtual BOOL SetLineOnHook(
318 unsigned line ///< Number of line
319 ) { return SetLineOffHook(line, FALSE); }
321 /**Set the hook state off then straight back on again.
322 This will only operate if the line is currently off hook.
324 virtual BOOL HookFlash(
325 unsigned line, ///< Number of line
326 unsigned flashTime = 200 ///< Time for hook flash in milliseconds
329 /**Return TRUE if a hook flash has been detected
331 virtual BOOL HasHookFlash(unsigned line);
334 /**Determine if line is ringing.
335 This function implies that the state is "debounced" and that a return
336 value of TRUE indicates that the phone is still ringing and it is not
337 simply a pause in the ring cadence.
339 If cadence is not NULL then it is set with the bit pattern for the
340 incoming ringing. Note that in this case the funtion may take a full
341 sequence to return. If it is NULL it can be assumed that the function
342 will return quickly.
344 virtual BOOL IsLineRinging(
345 unsigned line, ///< Number of line
346 DWORD * cadence = NULL ///< Cadence of incoming ring
349 /**Begin ringing local phone set with specified cadence.
350 If cadence is zero then stops ringing.
352 Note that not be possible on a given line, for example on a PSTN line
353 the ring state is determined by external hardware and cannot be
354 changed by the software.
356 Also note that the cadence may be ignored by particular hardware driver
357 so that only the zero or non-zero values are significant.
359 virtual BOOL RingLine(
360 unsigned line, ///< Number of line
361 DWORD cadence ///< Cadence bit map for ring pattern
364 /**Begin ringing local phone set with specified cadence.
365 If nCadence is zero then stops ringing.
367 Note that not be possible on a given line, for example on a PSTN line
368 the ring state is determined by external hardware and cannot be
369 changed by the software.
371 Also note that the cadence may be ignored by particular hardware driver
372 so that only the zero or non-zero values are significant.
374 The ring pattern is an array of millisecond times for on and off parts
375 of the cadence. Thus the Australian ring cadence would be represented
376 by the array unsigned AusRing[] = { 400, 200, 400, 2000 }
378 virtual BOOL RingLine(
379 unsigned line, ///< Number of line
380 PINDEX nCadence, ///< Number of entries in cadence array
381 unsigned * pattern ///< Ring pattern times
385 /**Determine if line has been disconnected from a call.
386 This uses the hardware (and country) dependent means for determining
388 virtual BOOL IsLineDisconnected(
389 unsigned line, ///< Number of line
390 BOOL checkForWink = TRUE
394 /**Directly connect the two lines.
396 virtual BOOL SetLineToLineDirect(
397 unsigned line1, ///< Number of first line
398 unsigned line2, ///< Number of second line
399 BOOL connect ///< Flag for connect/disconnect
402 /**Determine if the two lines are directly connected.
404 virtual BOOL IsLineToLineDirect(
405 unsigned line1, ///< Number of first line
406 unsigned line2 ///< Number of second line
410 /**Get the media formats this device is capable of using.
412 virtual OpalMediaFormat::List GetMediaFormats() const = 0;
414 /**Set the media format (codec) for reading on the specified line.
416 virtual BOOL SetReadFormat(
417 unsigned line, ///< Number of line
418 const OpalMediaFormat & mediaFormat ///< Codec type
419 ) = 0;
421 /**Set the media format (codec) for writing on the specified line.
423 virtual BOOL SetWriteFormat(
424 unsigned line, ///< Number of line
425 const OpalMediaFormat & mediaFormat ///< Codec type
426 ) = 0;
428 /**Get the media format (codec) for reading on the specified line.
430 virtual OpalMediaFormat GetReadFormat(
431 unsigned line ///< Number of line
432 ) = 0;
434 /**Get the media format (codec) for writing on the specified line.
436 virtual OpalMediaFormat GetWriteFormat(
437 unsigned line ///< Number of line
438 ) = 0;
440 /**Set the line codec for reading.
441 Note this function is now deprecated as it could not distinguish between
442 some codec subtypes (eg G.729 and G.729B) or non standard formats. Use
443 the SetReadFormat function instead.
445 The default behaviour now finds the first OpalMediaFormat with the
446 payload type and uses that.
448 virtual BOOL SetReadCodec(
449 unsigned line, ///< Number of line
450 RTP_DataFrame::PayloadTypes codec ///< Codec type
453 /**Set the line codec for writing.
454 Note this function is now deprecated as it could not distinguish between
455 some codec subtypes (eg G.729 and G.729B) or non standard formats. Use
456 the SetReadFormat function instead.
458 virtual BOOL SetWriteCodec(
459 unsigned line, ///< Number of line
460 RTP_DataFrame::PayloadTypes codec ///< Codec type
463 /**Set the line codec for reading/writing raw PCM data.
464 A descendent may use this to do anything special to the device before
465 beginning special PCM output. For example disabling AEC and set
466 volume levels to standard values. This can then be used for generating
467 standard tones using PCM if the driver is not capable of generating or
468 detecting them directly.
470 The default behaviour simply does a SetReadCodec and SetWriteCodec for
471 PCM data.
473 virtual BOOL SetRawCodec(
474 unsigned line ///< Number of line
477 /**Stop the read codec.
479 virtual BOOL StopReadCodec(
480 unsigned line ///< Number of line
483 /**Stop the write codec.
485 virtual BOOL StopWriteCodec(
486 unsigned line ///< Number of line
489 /**Stop the raw PCM mode codec.
491 virtual BOOL StopRawCodec(
492 unsigned line ///< Number of line
495 /**Set the read frame size in bytes.
496 Note that a LID may ignore this value so always use GetReadFrameSize()
497 for I/O.
499 virtual BOOL SetReadFrameSize(
500 unsigned line, ///< Number of line
501 PINDEX frameSize ///< New frame size
504 /**Set the write frame size in bytes.
505 Note that a LID may ignore this value so always use GetReadFrameSize()
506 for I/O.
508 virtual BOOL SetWriteFrameSize(
509 unsigned line, ///< Number of line
510 PINDEX frameSize ///< New frame size
513 /**Get the read frame size in bytes.
514 All calls to ReadFrame() will return this number of bytes.
516 virtual PINDEX GetReadFrameSize(
517 unsigned line ///< Number of line
518 ) = 0;
520 /**Get the write frame size in bytes.
521 All calls to WriteFrame() must be this number of bytes.
523 virtual PINDEX GetWriteFrameSize(
524 unsigned line ///< Number of line
525 ) = 0;
527 /**Low level read of a frame from the device.
529 virtual BOOL ReadFrame(
530 unsigned line, ///< Number of line
531 void * buf, ///< Pointer to a block of memory to receive data.
532 PINDEX & count ///< Number of bytes read, <= GetReadFrameSize()
533 ) = 0;
535 /**Low level write frame to the device.
537 virtual BOOL WriteFrame(
538 unsigned line, ///< Number of line
539 const void * buf, ///< Pointer to a block of memory to write.
540 PINDEX count, ///< Number of bytes to write, <= GetWriteFrameSize()
541 PINDEX & written ///< Number of bytes written, <= GetWriteFrameSize()
542 ) = 0;
544 /**High level read of audio data from the device.
545 This version will allow non-integral number of frames to be read.
547 virtual BOOL ReadBlock(
548 unsigned line, ///< Number of line
549 void * buf, ///< Pointer to a block of memory to receive the read bytes.
550 PINDEX count ///< Count of bytes to read.
553 /**High level write audio data to the device.
555 virtual BOOL WriteBlock(
556 unsigned line, ///< Number of line
557 const void * buf, ///< Pointer to a block of memory to write.
558 PINDEX count ///< Count of bytes to write.
562 /**Get average signal level in last frame.
564 virtual unsigned GetAverageSignalLevel(
565 unsigned line, ///< Number of line
566 BOOL playback ///< Get average playback or record level.
570 /**Enable audio for the line.
572 virtual BOOL EnableAudio(
573 unsigned line, ///< Number of line
574 BOOL enable = TRUE
577 /**Disable audio for the line.
579 BOOL DisableAudio(
580 unsigned line ///< Number of line
581 ) { return EnableAudio(line, FALSE); }
583 /**Determine if audio for the line is enabled.
585 virtual BOOL IsAudioEnabled(
586 unsigned line ///< Number of line
590 enum {
591 MaxVolume = 100
594 /**Set volume level for recording.
595 A value of 100 is the maximum volume possible for the hardware.
596 A value of 0 is the minimum volume possible for the hardware.
598 virtual BOOL SetRecordVolume(
599 unsigned line, ///< Number of line
600 unsigned volume ///< Volume level from 0 to 100%
603 /**Set volume level for playing.
604 A value of 100 is the maximum volume possible for the hardware.
605 A value of 0 is the minimum volume possible for the hardware.
607 virtual BOOL SetPlayVolume(
608 unsigned line, ///< Number of line
609 unsigned volume ///< Volume level from 0 to 100%
612 /**Get volume level for recording.
613 A value of 100 is the maximum volume possible for the hardware.
614 A value of 0 is the minimum volume possible for the hardware.
616 virtual BOOL GetRecordVolume(
617 unsigned line, ///< Number of line
618 unsigned & volume ///< Volume level from 0 to 100%
621 /**Set volume level for playing.
622 A value of 100 is the maximum volume possible for the hardware.
623 A value of 0 is the minimum volume possible for the hardware.
625 virtual BOOL GetPlayVolume(
626 unsigned line, ///< Number of line
627 unsigned & volume ///< Volume level from 0 to 100%
631 enum AECLevels {
632 AECOff,
633 AECLow,
634 AECMedium,
635 AECHigh,
636 AECAuto,
637 AECAGC,
638 AECError
641 /**Get acoustic echo cancellation.
642 Note, not all devices may support this function.
644 virtual AECLevels GetAEC(
645 unsigned line ///< Number of line
648 /**Set acoustic echo cancellation.
649 Note, not all devices may support this function.
651 virtual BOOL SetAEC(
652 unsigned line, ///< Number of line
653 AECLevels level ///< AEC level
656 /**Get wink detect minimum duration.
657 This is the signal used by telcos to end PSTN call.
659 virtual unsigned GetWinkDuration(
660 unsigned line ///< Number of line
663 /**Set wink detect minimum duration.
664 This is the signal used by telcos to end PSTN call.
666 virtual BOOL SetWinkDuration(
667 unsigned line, ///< Number of line
668 unsigned winkDuration ///< New minimum duration
671 /**Get voice activity detection.
672 Note, not all devices, or selected codecs, may support this function.
674 virtual BOOL GetVAD(
675 unsigned line ///< Number of line
678 /**Set voice activity detection.
679 Note, not all devices, or selected codecs, may support this function.
681 virtual BOOL SetVAD(
682 unsigned line, ///< Number of line
683 BOOL enable ///< Flag for enabling VAD
687 /**Get Caller ID from the last incoming ring.
688 The idString parameter is either simply the "number" field of the caller
689 ID data, or if full is TRUE, all of the fields in the caller ID data.
691 The full data of the caller ID string consists of the number field, the
692 time/date and the name field separated by tabs ('\t').
694 virtual BOOL GetCallerID(
695 unsigned line, ///< Number of line
696 PString & idString, ///< ID string returned
697 BOOL full = FALSE ///< Get full information in idString
700 /**Set Caller ID for use in next RingLine() call.
701 The full data of the caller ID string consists of the number field, the
702 time/date and the name field separated by tabs ('\t').
704 If the date field is missing (two consecutive tabs) then the current
705 time and date is used. Using an empty string will clear the caller ID
706 so that no caller ID is sent on the next RingLine() call.
708 virtual BOOL SetCallerID(
709 unsigned line, ///< Number of line
710 const PString & idString ///< ID string to use
713 /**Send a Caller ID on call waiting command
714 The full data of the caller ID string consists of the number field, the
715 time/date and the name field separated by tabs ('\t').
717 If the date field is missing (two consecutive tabs) then the current
718 time and date is used. Using an empty string will clear the caller ID
719 so that no caller ID is sent on the next RingLine() call.
721 virtual BOOL SendCallerIDOnCallWaiting(
722 unsigned line, ///< Number of line
723 const PString & idString ///< ID string to use
726 /**Send a Visual Message Waiting Indicator
728 virtual BOOL SendVisualMessageWaitingIndicator(
729 unsigned line, ///< Number of line
730 BOOL on
734 enum {
735 DefaultDTMFOnTime = 180,
736 DefaultDTMFOffTime = 120
739 /**Play a DTMF digit.
740 Any characters that are not in the set 0-9, A-D, * or # will be ignored.
742 virtual BOOL PlayDTMF(
743 unsigned line, ///< Number of line
744 const char * digits, ///< DTMF digits to be played
745 DWORD onTime = DefaultDTMFOnTime, ///< Number of milliseconds to play each DTMF digit
746 DWORD offTime = DefaultDTMFOffTime ///< Number of milliseconds between digits
749 /**Read a DTMF digit detected.
750 This may be characters from the set 0-9, A-D, * or #. A null ('\0')
751 character indicates that there are no tones in the queue.
752 Characters E through P indicate the following tones:
754 E = 800 F = 1000 G = 1250 H = 950 I = 1100 J = 1400
755 K = 1500 L = 1600 M = 1800 N = 2100 O = 1300 P = 2450
758 virtual char ReadDTMF(
759 unsigned line ///< Number of line
762 /**Get DTMF removal mode.
763 When set in this mode the DTMF tones detected are removed from the
764 encoded data stream as returned by ReadFrame().
766 virtual BOOL GetRemoveDTMF(
767 unsigned line ///< Number of line
770 /**Set DTMF removal mode.
771 When set in this mode the DTMF tones detected are removed from the
772 encoded data stream as returned by ReadFrame().
774 virtual BOOL SetRemoveDTMF(
775 unsigned line, ///< Number of line
776 BOOL removeTones ///< Flag for removing DTMF tones.
780 enum CallProgressTones {
781 NoTone = 0x00, // indicates no tones
782 DialTone = 0x01, // Dial tone
783 RingTone = 0x02, // Ring indication tone
784 BusyTone = 0x04, // Line engaged tone
785 ClearTone = 0x08, // Call failed/cleared tone (often same as busy tone)
786 CNGTone = 0x10, // Fax CNG tone
787 AllTones = 0x1f
790 /**See if any tone is detected.
792 virtual unsigned IsToneDetected(
793 unsigned line ///< Number of line
796 /**See if any tone is detected.
798 virtual unsigned WaitForToneDetect(
799 unsigned line, ///< Number of line
800 unsigned timeout = 3000 ///< Milliseconds to wait for
803 /**See if a specific tone is detected.
805 virtual BOOL WaitForTone(
806 unsigned line, ///< Number of line
807 CallProgressTones tone, ///< Tone to wait for
808 unsigned timeout = 3000 ///< Milliseconds to wait for
811 /**Set a tones filter information.
812 The description string is of the form
813 frequence ':' cadence
814 where frequency is either
815 frequency
816 low '-' high
817 and cadence is
818 mintime
819 ontime '-' offtime
820 ontime '-' offtime '-' ontime '-' offtime
821 examples:
822 300:0.25 300Hz for minimum 250ms
823 1100:0.4-0.4 1100Hz with cadence 400ms on, 400ms off
824 900-1300:1.5 900Hz to 1300Hz for minimum of 1.5 seconds
825 425:0.4-0.2-0.4-2 425Hz with cadence
826 400ms on, 200ms off, 400ms on, 2 seconds off
828 virtual BOOL SetToneFilter(
829 unsigned line, ///< Number of line
830 CallProgressTones tone, ///< Tone filter to change
831 const PString & description ///< Description of filter parameters
834 /**Set a tones filter information.
836 virtual BOOL SetToneFilterParameters(
837 unsigned line, ///< Number of line
838 CallProgressTones tone, ///< Tone filter to change
839 unsigned lowFrequency, ///< Low frequency
840 unsigned highFrequency, /// High frequency
841 PINDEX numCadences, /// Number of cadence times
842 const unsigned * onTimes, /// Cadence ON times
843 const unsigned * offTimes /// Cadence OFF times
846 /**Play a tone.
848 virtual BOOL PlayTone(
849 unsigned line, /// Number of line
850 CallProgressTones tone /// Tone to be played
853 /**Determine if a tone is still playing
855 virtual BOOL IsTonePlaying(
856 unsigned line /// Number of line
859 /**Stop playing a tone.
861 virtual BOOL StopTone(
862 unsigned line /// Number of line
865 /**Play a wav file
867 virtual BOOL PlayAudio(
868 unsigned line, /// Number of line
869 const PString & filename /// File Name
872 /**Stop playing the Wave File
874 virtual BOOL StopAudio(
875 unsigned line ///Number of line
879 /**Dial a number on network line.
880 The takes the line off hook, waits for dial tone, and transmits the
881 specified number as DTMF tones.
883 If the requireTones flag is TRUE the call is aborted of the call
884 progress tones are not detected. Otherwise the call proceeds with short
885 delays while it tries to detect the call progress tones.
887 The return code indicates the following:
888 DialTone No dial tone detected
889 RingTone Dial was successful
890 BusyTone The remote phone was busy
891 ClearTone Dial failed (usually means rang out)
892 NoTone There was an internal error making the call
894 virtual CallProgressTones DialOut(
895 unsigned line, /// Number of line
896 const PString & number, /// Number to dial
897 BOOL requireTones = FALSE /// Require dial/ring tone to be detected
901 enum T35CountryCodes {
902 Japan, Albania, Algeria, AmericanSamoa, Germany, Anguilla, AntiguaAndBarbuda,
903 Argentina, Ascension, Australia, Austria, Bahamas, Bahrain, Bangladesh,
904 Barbados, Belgium, Belize, Benin, Bermudas, Bhutan, Bolivia, Botswana,
905 Brazil, BritishAntarcticTerritory, BritishIndianOceanTerritory,
906 BritishVirginIslands, BruneiDarussalam, Bulgaria, Myanmar, Burundi,
907 Byelorussia, Cameroon, Canada, CapeVerde, CaymanIslands,
908 CentralAfricanRepublic, Chad, Chile, China, Colombia, Comoros, Congo,
909 CookIslands, CostaRica, Cuba, Cyprus, Czechoslovakia, Cambodia,
910 DemocraticPeoplesRepublicOfKorea, Denmark, Djibouti, DominicanRepublic,
911 Dominica, Ecuador, Egypt, ElSalvador, EquatorialGuinea, Ethiopia,
912 FalklandIslands, Fiji, Finland, France, FrenchPolynesia,
913 FrenchSouthernAndAntarcticLands, Gabon, Gambia, Germany2, Angola, Ghana,
914 Gibraltar, Greece, Grenada, Guam, Guatemala, Guernsey, Guinea, GuineaBissau,
915 Guayana, Haiti, Honduras, Hongkong, Hungary, Iceland, India, Indonesia,
916 Iran, Iraq, Ireland, Israel, Italy, CotedIvoire, Jamaica, Afghanistan,
917 Jersey, Jordan, Kenya, Kiribati, KoreaRepublic, Kuwait, Lao, Lebanon,
918 Lesotho, Liberia, Libya, Liechtenstein, Luxemborg, Macao, Madagascar,
919 Malaysia, Malawi, Maldives, Mali, Malta, Mauritania, Mauritius, Mexico,
920 Monaco, Mongolia, Montserrat, Morocco, Mozambique, Nauru, Nepal,
921 Netherlands, NetherlandsAntilles, NewCaledonia, NewZealand, Nicaragua,
922 Niger, Nigeria, Norway, Oman, Pakistan, Panama, PapuaNewGuinea, Paraguay,
923 Peru, Philippines, Poland, Portugal, PuertoRico, Qatar, Romania, Rwanda,
924 SaintKittsAndNevis, SaintCroix, SaintHelenaAndAscension, SaintLucia,
925 SanMarino, SaintThomas, SaoTomeAndPrincipe, SaintVicentAndTheGrenadines,
926 SaudiArabia, Senegal, Seychelles, SierraLeone, Singapore, SolomonIslands,
927 Somalia, SouthAfrica, Spain, SriLanka, Sudan, Suriname, Swaziland, Sweden,
928 Switzerland, Syria, Tanzania, Thailand, Togo, Tonga, TrinidadAndTobago,
929 Tunisia, Turkey, TurksAndCaicosIslands, Tuvalu, Uganda, Ukraine,
930 UnitedArabEmirates, UnitedKingdom, UnitedStates, BurkinaFaso, Uruguay,
931 USSR, Vanuatu, VaticanCityState, Venezuela, VietNam, WallisAndFutuna,
932 WesternSamoa, Yemen, Yemen2, Yugoslavia, Zaire, Zambia, Zimbabwe,
933 NumCountryCodes,
934 UnknownCountry = -1
937 /**Get the country code set for the device.
939 T35CountryCodes GetCountryCode() const { return countryCode; }
941 /**Get the country code set for the device as a string.
943 PString GetCountryCodeName() const;
945 /**Get the country code set for the device as a string.
947 static PString GetCountryCodeName(T35CountryCodes code);
948 static T35CountryCodes GetCountryCode(const PString & name);
950 /**Set the country code set for the device.
951 This may change the line analogue coefficients, ring detect, call
952 disconnect detect and call progress tones to fit the countries
953 telephone network.
955 virtual BOOL SetCountryCode(
956 T35CountryCodes country /// COuntry code for device
959 /**Set the country code set for the device.
961 virtual BOOL SetCountryCodeName(
962 const PString & countryName /// COuntry code for device
965 /**Get the list of countries actually supported by the device
967 virtual PStringList GetCountryCodeNameList() const;
970 /**Return number for last error.
972 int GetErrorNumber() const { return osError; }
974 /**Return text for last error.
976 PString GetErrorText() const;
978 virtual void PrintOn(
979 ostream & strm
980 ) const;
982 /** LID Device Type
984 enum DeviceType{
985 POTSLine, // Behaves as a normal Phone
986 Gateway, // Behaves as a gateway
987 CellEmulate // Behaves as like a CellPhone
991 /** Get the LID Device Type.
993 virtual OpalLineInterfaceDevice::DeviceType GetDeviceType() { return POTSLine; };
995 protected:
996 int os_handle;
997 int osError;
998 T35CountryCodes countryCode;
999 PBYTEArray readDeblockingBuffer, writeDeblockingBuffer;
1000 PINDEX readDeblockingOffset, writeDeblockingOffset;
1002 #if PTRACING
1003 friend ostream & operator<<(ostream & o, CallProgressTones t);
1004 #endif
1008 /**This class describes an I/O channel that uses a Line Interface Device.
1010 class OpalLineChannel : public PChannel
1012 PCLASSINFO(OpalLineChannel, PChannel);
1014 public:
1015 /**Create a new channel to a line interface device.
1017 OpalLineChannel(
1018 OpalLineInterfaceDevice & device, ///< Device for channel I/O
1019 unsigned line, ///< Number of line
1020 const H323AudioCodec & codec ///< Codec that uses the channel
1022 ~OpalLineChannel();
1024 /**Get the device name.
1026 PString GetName() const;
1028 /**Close the channel.
1030 BOOL Close();
1032 /** Low level read from the channel. This function may block until the
1033 requested number of characters were read or the read timeout was
1034 reached. The GetLastReadCount() function returns the actual number
1035 of bytes read.
1037 The GetErrorCode() function should be consulted after Read() returns
1038 FALSE to determine what caused the failure.
1040 @return
1041 TRUE indicates that at least one character was read from the channel.
1042 FALSE means no bytes were read due to timeout or some other I/O error.
1044 virtual BOOL Read(
1045 void * buf, ///< Pointer to a block of memory to receive the read bytes.
1046 PINDEX len ///< Maximum number of bytes to read into the buffer.
1049 /** Low level write to the channel. This function will block until the
1050 requested number of characters are written or the write timeout is
1051 reached. The GetLastWriteCount() function returns the actual number
1052 of bytes written.
1054 The GetErrorCode() function should be consulted after Write() returns
1055 FALSE to determine what caused the failure.
1057 @return
1058 TRUE if at least len bytes were written to the channel.
1060 virtual BOOL Write(
1061 const void * buf, ///< Pointer to a block of memory to write.
1062 PINDEX len ///< Number of bytes to write.
1066 /**Get the device the channel is writing to.
1068 OpalLineInterfaceDevice & GetDevice() const { return device; }
1070 /**Get the line number on device the channel is writing to.
1072 unsigned GetLineNumber() const { return lineNumber; }
1075 protected:
1076 OpalLineInterfaceDevice & device;
1077 unsigned lineNumber;
1078 BOOL reading;
1079 BOOL useDeblocking;
1086 /**This class describes the LID based codec capability.
1088 class H323_LIDCapability : public H323AudioCapability
1090 PCLASSINFO(H323_LIDCapability, H323AudioCapability);
1092 public:
1093 /**@name Construction */
1094 //@{
1095 /**Create a new capability.
1097 H323_LIDCapability(
1098 const OpalMediaFormat & mediaFormat ///< RTP codec type for capability
1100 //@}
1102 /**@name Overrides from class PObject */
1103 //@{
1104 /**Compare the object with another of the same class.
1106 Comparison Compare(const PObject & obj) const;
1108 /**Create a copy of the object.
1110 virtual PObject * Clone() const;
1112 /**Get the name of the media data format this class represents.
1114 virtual PString GetFormatName() const;
1115 //@}
1117 /**@name Identification functions */
1118 //@{
1119 /**Get the sub-type of the capability. This is a code dependent on the
1120 main type of the capability.
1122 This returns H245_AudioCapability::e_nonStandard.
1124 virtual unsigned GetSubType() const;
1125 //@}
1127 /**@name Operations */
1128 //@{
1129 /**Create the codec instance, allocating resources as required.
1131 virtual H323Codec * CreateCodec(
1132 H323Codec::Direction direction ///< Direction in which this instance runs
1133 ) const;
1135 /**Determine if the codec specified for the object is valid.
1137 BOOL IsValid() const;
1139 /**Add all of the capabilities that a LID is capable of.
1141 static void AddAllCapabilities(
1142 const OpalLineInterfaceDevice & device, ///< Device to get codecs from
1143 H323Capabilities & capabilities, ///< Table to add capabilities to
1144 PINDEX descriptorNum, ///< The member of the capabilityDescriptor to add
1145 PINDEX simultaneous ///< The member of the SimultaneousCapabilitySet to add
1147 //@}
1149 /**@name Protocol manipulation */
1150 //@{
1151 /**This function is called whenever and outgoing TerminalCapabilitySet
1152 or OpenLogicalChannel PDU is being constructed for the control channel.
1153 It allows the capability to set the PDU fields from information in
1154 members specific to the class.
1156 The default behaviour sets the data rate field in the PDU.
1158 virtual BOOL OnSendingPDU(
1159 H245_AudioCapability & pdu, ///< PDU to set information on
1160 unsigned packetSize ///< Packet size to use in capability
1161 ) const;
1163 /**This function is called whenever and incoming TerminalCapabilitySet
1164 or OpenLogicalChannel PDU has been used to construct the control
1165 channel. It allows the capability to set from the PDU fields,
1166 information in members specific to the class.
1168 The default behaviour gets the data rate field from the PDU.
1170 virtual BOOL OnReceivedPDU(
1171 const H245_AudioCapability & pdu, ///< PDU to get information from
1172 unsigned & packetSize ///< Packet size to use in capability
1174 //@}
1176 protected:
1177 OpalMediaFormat mediaFormat;
1178 PINDEX codecTableIndex;
1182 /**This class describes the Cisco non-standard G.723.1 Annex A codec capability.
1184 class H323_CiscoG7231aLIDCapability : public H323NonStandardAudioCapability
1186 PCLASSINFO(H323_CiscoG7231aLIDCapability, H323NonStandardAudioCapability);
1188 public:
1189 /**@name Construction */
1190 //@{
1191 /**Create a new Cisco non-standard G.723.1 Annex A capability.
1193 H323_CiscoG7231aLIDCapability();
1194 //@}
1196 /**@name Overrides from class PObject */
1197 //@{
1198 /**Create a copy of the object.
1200 virtual PObject * Clone() const;
1201 //@}
1203 /**@name Operations */
1204 //@{
1205 /**Create the codec instance, allocating resources as required.
1207 virtual H323Codec * CreateCodec(
1208 H323Codec::Direction direction ///< Direction in which this instance runs
1209 ) const;
1210 //@}
1212 /**@name Identification functions */
1213 //@{
1214 /**Get the name of the media data format this class represents.
1216 virtual PString GetFormatName() const;
1217 //@}
1221 /**This class is a LID codec that only converts data for playback on some
1222 other audio device.
1224 class H323_LIDCodec : public H323AudioCodec
1226 PCLASSINFO(H323_LIDCodec, H323AudioCodec);
1228 public:
1229 /**Create a new LID based codec.
1231 H323_LIDCodec(
1232 const char * mediaFormat, ///< Media format for codec
1233 Direction direction, ///< Direction in which this instance runs
1234 unsigned numFrames, ///< Number of frames to transmit in packet
1235 PINDEX codecTableIndex ///< Type of codec to use
1238 /**Encode the data from the appropriate device.
1239 This will encode a frame of data for transmission. The exact size and
1240 description of the data placed in the buffer is codec dependent but
1241 should be less than H323Capability::GetTxFramesInPacket() *
1242 OpalMediaFormat::GetFrameSize() in length.
1244 The length parameter is filled with the actual length of the encoded
1245 data, often this will be the same as the size parameter.
1247 This function is called every GetFrameRate() timestamp units, so MUST
1248 take less than (or equal to) that amount of time to complete!
1250 Note that a returned length of zero indicates that time has passed but
1251 there is no data encoded. This is typically used for silence detection
1252 in an audio codec.
1254 virtual BOOL Read(
1255 BYTE * buffer, ///< Buffer of encoded data
1256 unsigned & length, ///< Actual length of encoded data buffer
1257 RTP_DataFrame & rtpFrame ///< RTP data frame
1260 /**Decode the data and output it to appropriate device.
1261 This will decode a single frame of received data. The exact size and
1262 description of the data required in the buffer is codec dependent but
1263 should be less than H323Capability::GetRxFramesInPacket() *
1264 OpalMediaFormat::GetFrameSize() in length.
1266 It is expected this function anunciates the data. That is, for example
1267 with audio data, the sound is output on a speaker.
1269 This function is called every GetFrameRate() timestamp units, so MUST
1270 take less than that amount of time to complete!
1272 virtual BOOL Write(
1273 const BYTE * buffer, ///< Buffer of encoded data
1274 unsigned length, ///< Length of encoded data buffer
1275 const RTP_DataFrame & frame, ///< Entire RTP frame
1276 unsigned & written ///< Number of bytes used from data buffer
1279 /**Return flag indicating raw channel is native.
1280 For audio codecs, FALSE typically means that the format is PCM-16.
1281 For video codecs, FALSE typically means that the format is YUV411P.
1283 The default behaviour returns TRUE.
1285 virtual BOOL IsRawDataChannelNative() const;
1287 /**Check frame for a talk burst.
1288 This does the deadband calculations on the average signal levels
1289 returned by the GetAverageSignalLevel() function and based on the
1290 levelThreshold, signalDeadbandFrames and silenceDeadbandFrames
1291 member variables.
1293 virtual BOOL DetectSilence();
1295 /**Calculate the energy in the audio stream.
1296 This is called from within DetectSilence() to calculate the average
1297 energy since the last call to DetectSilence().
1299 virtual unsigned GetAverageSignalLevel();
1302 PINDEX GetCodecTableIndex() const { return codecTableIndex; }
1304 protected:
1305 PINDEX codecTableIndex;
1306 unsigned packetSize;
1307 unsigned missedCount;
1308 BYTE lastSID[4];
1309 BOOL lastFrameWasSignal;
1313 #endif // __OPAL_LID_H
1316 // End of File ///////////////////////////////////////////////////////////////