Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

vblasterlid.h

Go to the documentation of this file.
00001 /*
00002  * vblasterlid.h
00003  *
00004  * Creative Labs VOIP Blaster codec interface
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 2001 Equivalence Pty. Ltd.
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 Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): ______________________________________.
00025  *
00026  * $Log: vblasterlid.h,v $
00027  * Revision 1.7  2003/12/03 06:58:30  csoutheren
00028  * More vblaster implementation
00029  *
00030  * Revision 1.6  2003/11/10 12:37:46  csoutheren
00031  * Additional fixes for Fobbit Windows driver
00032  *
00033  * Revision 1.5  2002/09/16 01:14:15  robertj
00034  * Added #define so can select if #pragma interface/implementation is used on
00035  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00036  *
00037  * Revision 1.4  2002/09/03 06:19:37  robertj
00038  * Normalised the multi-include header prevention ifdef/define symbol.
00039  *
00040  * Revision 1.3  2002/08/05 10:03:47  robertj
00041  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00042  *
00043  * Revision 1.2  2002/01/15 07:23:24  craigs
00044  * Added IsDevicePresent command
00045  *
00046  * Revision 1.1  2002/01/15 04:16:32  craigs
00047  * Initial version
00048  *
00049  *
00050  */
00051 
00052 #ifndef __OPAL_VBLASTERLID_H
00053 #define __OPAL_VBLASTERLID_H
00054 
00055 #ifdef P_USE_PRAGMA
00056 #pragma interface
00057 #endif
00058 
00059 
00060 #define HAS_VBLASTER
00061 
00062 #include "lid.h"
00063 #include "h323caps.h"
00064 
00065 #include <ptclib/delaychan.h>
00066 
00067 
00068 
00070 
00071 class VoipBlasterInterface : public PObject
00072 {
00073   PCLASSINFO(VoipBlasterInterface, PObject)
00074   public:
00075     enum Command {
00076       Command_PHONE_OFF  = 0x01, // drop loop current
00077       Command_PHONE_ON   = 0x02, // used on startup
00078       Command_RING_ON    = 0x03, // start ringing
00079       Command_RING_OFF   = 0x04, // used on startup & to stop ringing
00080       Command_VOUT_START = 0x05, // start audio output
00081       Command_VOUT_STOP  = 0x06, // stop audio output
00082       Command_VINP_START = 0x07, // start audio input
00083       Command_VINP_STOP  = 0x08, // stop audio input
00084       Command_UNKNOWN_1  = 0x09, // Unknown (TESTSTART)
00085       Command_UNKNOWN_2  = 0x0a, // Unknown (TESTSTOP)
00086       Command_UNKNOWN_3  = 0x0b, // Unknown (SENDFAXTONE)
00087       Command_HS_OFFHOOK = 0x0c, // Go offhook for headset
00088       Command_HS_ONHOOK  = 0x0d, // Go onhook for headset
00089       Command_SETUP_MODE = 0x0e, // Unknown(goto setup mode)
00090       Command_VOUT_DONE  = 0x0f, // voice in/out off, report output drained
00091       Command_0x10       = 0x10, // Unknown (used in file output, seems ok without)
00092       Command_0x11       = 0x11, // Unknown (used in file output, seems ok without)
00093       Command_MUTE_ON    = 0x12, // Audio mute on
00094       Command_MUTE_OFF   = 0x13, // Audio mute off
00095       Command_VOL_0      = 0x34, // Set volume (min)
00096       Command_VOL_1      = 0x35, // Set volume
00097       Command_VOL_2      = 0x36, // Set volume
00098       Command_VOL_3      = 0x37, // Set volume (default)
00099       Command_VOL_4      = 0x38, // Set volume
00100       Command_VOL_5      = 0x39, // Set volume
00101       Command_VOL_6      = 0x3a, // Set volume (max)
00102     };
00103 
00104     enum Status {
00105       //Status_NONE        = 0x00, // No status
00106       Status_HOOK_OFF    = 0x01, // Offhook
00107       Status_HOOK_ON     = 0x02, // Onhook
00108       //Status_DEBUG       = 0x03, // Not used (DEBUG)
00109       //Status_RINGDETECT  = 0x04, // Not used (RINGDETECT)
00110       Status_RINGING_ON  = 0x05, // Ring started 
00111       Status_RINGING_OFF = 0x06, // Ring stopped
00112       Status_HEADSET_IN  = 0x08, // Headset plugged in
00113       Status_HEADSET_OUT = 0x09, // Headset unplugged
00114       Status_0x0a        = 0x0a, // Unknown (setup accepted?)
00115       Status_VOUT_DONE   = 0x0c, // Voice output done
00116       Status_Empty
00117     };
00118 
00119     VoipBlasterInterface();
00120 
00121     BOOL IsDevicePresent(PINDEX deviceIndex);
00122 
00123     BOOL OpenCommand(PINDEX deviceIndex);
00124     BOOL WriteCommand(Command cmd);
00125     Status ReadStatus(const PTimeInterval dur = 0);
00126     BOOL CloseCommand();
00127 
00128     BOOL OpenData();
00129     BOOL WriteData(const void * data, PINDEX len);
00130     int  ReadData (void * data,       PINDEX len, const PTimeInterval dur = 0);
00131     void Flush(const PTimeInterval wait = 500);
00132     BOOL CloseData();
00133 
00134     PDECLARE_NOTIFIER(PTimer, VoipBlasterInterface, CloseTimeout);
00135 
00136   protected:
00137     PINDEX deviceIndex;
00138 
00139 // Linux specific defines are included here
00140 #ifdef P_LINUX
00141 #endif
00142 
00143 // Windows specific defines are included here
00144 #ifdef _WIN32
00145     enum Pipe {
00146       VoiceOutPipe = 0,
00147       VoiceInPipe  = 1,
00148       CommandPipe  = 2,
00149       StatusPipe   = 3,
00150       NumPipes
00151     };
00152 
00153   protected:
00154     int WritePipe(HANDLE fd, const void *bp, DWORD len);
00155     int ReadPipe (HANDLE fd, void *bp,       DWORD len, const PTimeInterval dur = 0);
00156     BOOL OpenVOIPPipe(Pipe pipeIndex);
00157 
00158     HANDLE pipes[4];
00159 #endif
00160 };
00161 
00163 
00166 class OpalVoipBlasterDevice : public OpalLineInterfaceDevice
00167 {
00168   PCLASSINFO(OpalVoipBlasterDevice, OpalLineInterfaceDevice);
00169 
00170   public:
00171 
00172     enum { DTMFQueueSize = 10 };
00173 
00174     class ByteQueue : public PObject {
00175       PCLASSINFO(ByteQueue, PObject);
00176       public:
00177         ByteQueue(PINDEX size);
00178         int Dequeue();
00179         BOOL Enqueue(BYTE ch);
00180 
00181       protected:
00182         PBYTEArray queue;
00183         PINDEX qLen, qOut, qMax;
00184         PMutex mutex;
00185     };
00186 
00189     OpalVoipBlasterDevice();
00190 
00194     ~OpalVoipBlasterDevice();
00195 
00198     virtual BOOL Open(
00199       const PString & device  
00200     );
00201 
00204     virtual BOOL Close();
00205 
00208     virtual PString GetName() const;
00209 
00212     virtual unsigned GetLineCount()
00213       { return 1; }
00214 
00217     virtual BOOL IsLineTerminal(
00218       unsigned /*line*/   
00219     ) { return TRUE; }
00220 
00221 
00224     virtual BOOL IsLinePresent(
00225       unsigned /*line*/,      
00226       BOOL /*force*/ = FALSE  
00227     )
00228       { return FALSE; }
00229 
00230 
00235     virtual BOOL IsLineOffHook(
00236       unsigned line   
00237     );
00238 
00242     virtual BOOL SetLineOffHook(
00243       unsigned line,        
00244       BOOL newState = TRUE  
00245     );
00246 
00247 
00250     virtual BOOL IsLineRinging(
00251       unsigned line,          
00252       DWORD * cadence = NULL  
00253     );
00254 
00258     virtual BOOL RingLine(
00259       unsigned line,    
00260       DWORD cadence     
00261     );
00262 
00263 
00266     virtual BOOL IsLineDisconnected(
00267       unsigned line,   
00268       BOOL checkForWink = TRUE
00269     );
00270 
00271 
00274     BOOL SetLineToLineDirect(
00275       unsigned line1,   
00276       unsigned line2,   
00277       BOOL connect      
00278     );
00279 
00282     BOOL IsLineToLineDirect(
00283       unsigned line1,   
00284       unsigned line2    
00285     );
00286 
00287 
00290     virtual OpalMediaFormat::List GetMediaFormats() const;
00291 
00294     virtual BOOL SetReadFormat(
00295       unsigned line,    
00296       const OpalMediaFormat & mediaFormat   
00297     );
00298 
00301     virtual BOOL SetWriteFormat(
00302       unsigned line,    
00303       const OpalMediaFormat & mediaFormat   
00304     );
00305 
00308     virtual OpalMediaFormat GetReadFormat(
00309       unsigned line    
00310     );
00311 
00314     virtual OpalMediaFormat GetWriteFormat(
00315       unsigned line    
00316     );
00317 
00328     virtual BOOL SetRawCodec(
00329       unsigned line    
00330     );
00331 
00334     virtual BOOL StopRawCodec(
00335       unsigned line   
00336     );
00337 
00340     virtual BOOL StopReadCodec(
00341       unsigned line   
00342     );
00343 
00346     virtual BOOL StopWriteCodec(
00347       unsigned line   
00348     );
00349 
00353     virtual PINDEX GetReadFrameSize(
00354       unsigned line   
00355     );
00356 
00357     virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00358 
00362     virtual PINDEX GetWriteFrameSize(
00363       unsigned line   
00364     );
00365 
00366     virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00367 
00370     virtual BOOL ReadFrame(
00371       unsigned line,    
00372       void * buf,       
00373       PINDEX & count    
00374     );
00375 
00378     virtual BOOL WriteFrame(
00379       unsigned line,    
00380       const void * buf, 
00381       PINDEX count,     
00382       PINDEX & written  
00383     );
00384 
00387     virtual unsigned GetAverageSignalLevel(
00388       unsigned line,  
00389       BOOL playback   
00390     );
00391 
00392 
00395     virtual BOOL EnableAudio(
00396       unsigned line,      
00397       BOOL enable = TRUE
00398     );
00399 
00400 
00405     virtual BOOL SetRecordVolume(
00406       unsigned line,    
00407       unsigned volume   
00408     );
00409 
00414     virtual BOOL SetPlayVolume(
00415       unsigned line,    
00416       unsigned volume   
00417     );
00418 
00423     virtual BOOL GetRecordVolume(
00424       unsigned line,      
00425       unsigned & volume   
00426     );
00427 
00432     virtual BOOL GetPlayVolume(
00433       unsigned line,      
00434       unsigned & volume   
00435     );
00436 
00437 
00440     AECLevels GetAEC(
00441       unsigned line    
00442     );
00443 
00446     BOOL SetAEC(
00447       unsigned line,    
00448       AECLevels level  
00449     );
00450 
00451 
00455     virtual BOOL GetVAD(
00456       unsigned line    
00457     );
00458 
00462     virtual BOOL SetVAD(
00463       unsigned line,    
00464       BOOL enable       
00465     );
00466 
00467 
00475     virtual BOOL GetCallerID(
00476       unsigned line,      
00477       PString & idString, 
00478       BOOL full = FALSE   
00479     );
00480 
00489     virtual BOOL SetCallerID(
00490       unsigned line,            
00491       const PString & idString  
00492     );
00493 
00496     virtual BOOL SendCallerIDOnCallWaiting(
00497       unsigned line,            
00498       const PString & idString  
00499     );
00500 
00503     virtual BOOL SendVisualMessageWaitingIndicator(
00504       unsigned line,            
00505       BOOL on
00506     );
00507 
00508 
00509 
00513     virtual BOOL PlayDTMF(
00514       unsigned line,            
00515       const char * digits,      
00516       DWORD onTime = DefaultDTMFOnTime,  
00517       DWORD offTime = DefaultDTMFOffTime 
00518     );
00519 
00525     virtual char ReadDTMF(
00526       unsigned line   
00527     );
00528 
00533     virtual BOOL GetRemoveDTMF(
00534       unsigned line            
00535     );
00536 
00541     virtual BOOL SetRemoveDTMF(
00542       unsigned line,            
00543       BOOL removeTones   
00544     );
00545 
00546 
00549     virtual unsigned IsToneDetected(
00550       unsigned line   
00551     );
00552 
00555     virtual BOOL PlayTone(
00556       unsigned line,          
00557       CallProgressTones tone  
00558     );
00559 
00562     virtual BOOL IsTonePlaying(
00563       unsigned line   
00564     );
00565 
00568     virtual BOOL StopTone(
00569       unsigned line   
00570     );
00571 
00574     virtual BOOL HasHookFlash(unsigned line);
00575 
00581     virtual BOOL SetCountryCode(
00582       T35CountryCodes country   
00583     );
00584 
00585 
00588     virtual DWORD GetSerialNumber();
00589 
00592     static PStringArray GetDeviceNames();
00593 
00597     PDECLARE_NOTIFIER(PThread, OpalVoipBlasterDevice, StatusHandler);
00598 
00599   protected:
00600     void HandleStatus(int status);
00601 
00602     PThread * statusThread;
00603     BOOL statusRunning;
00604     BOOL hookState;
00605     BOOL headset;
00606     BOOL ringOn;
00607     BOOL firstTime;
00608 
00609     ByteQueue dtmfQueue;
00610 
00611     PAdaptiveDelay writeDelay;
00612     PAdaptiveDelay readDelay;
00613 
00614     PString   deviceName;
00615     PMutex    readMutex, writeMutex;
00616     BOOL      readStopped, writeStopped;
00617     PINDEX    readFrameSize, writeFrameSize;
00618     PINDEX    readCodecType, writeCodecType;
00619     BOOL      lastHookStatus;
00620 
00621     PMutex               vbMutex;
00622     VoipBlasterInterface vBlaster;
00623 };
00624 
00625 
00626 #endif // __OPAL_VBLASTERLID_H
00627 
00628 

Generated on Tue Mar 15 11:17:08 2005 for OpenH323 by  doxygen 1.4.0