pcss.h

Go to the documentation of this file.
00001 /*
00002  * pcss.h
00003  *
00004  * PC Sound System support.
00005  *
00006  * Open Phone Abstraction Library (OPAL)
00007  * Formally known as the Open H323 project.
00008  *
00009  * Copyright (c) 2001 Equivalence Pty. Ltd.
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 Equivalence Pty. Ltd.
00024  *
00025  * Contributor(s): ______________________________________.
00026  *
00027  * $Log: pcss.h,v $
00028  * Revision 2.29  2007/04/03 07:59:13  rjongbloed
00029  * Warning: API change to PCSS callbacks:
00030  *   changed return on OnShowIncoming to BOOL, now agrees with
00031  *     documentation and allows UI to abort calls early.
00032  *   added BOOL to AcceptIncomingConnection indicating the
00033  *     supplied token is invalid.
00034  *   removed redundent OnGetDestination() function, was never required.
00035  *
00036  * Revision 2.28  2007/03/13 00:32:16  csoutheren
00037  * Simple but messy changes to allow compile time removal of protocol
00038  * options such as H.450 and H.460
00039  * Fix MakeConnection overrides
00040  *
00041  * Revision 2.27  2007/03/01 05:51:04  rjongbloed
00042  * Fixed backward compatibility of OnIncomingConnection() virtual
00043  *   functions on various classes. If an old override returned FALSE
00044  *   then it will now abort the call as it used to.
00045  *
00046  * Revision 2.26  2007/01/24 04:00:56  csoutheren
00047  * Arrrghh. Changing OnIncomingConnection turned out to have a lot of side-effects
00048  * Added some pure viritual functions to prevent old code from breaking silently
00049  * New OpalEndpoint and OpalConnection descendants will need to re-implement
00050  * OnIncomingConnection. Sorry :)
00051  *
00052  * Revision 2.25  2006/12/18 03:18:41  csoutheren
00053  * Messy but simple fixes
00054  *   - Add access to SIP REGISTER timeout
00055  *   - Ensure OpalConnection options are correctly progagated
00056  *
00057  * Revision 2.24  2006/10/15 06:23:35  rjongbloed
00058  * Fixed the mechanism where both A-party and B-party are indicated by the application. This now works
00059  *   for LIDs as well as PC endpoint, wheich is the only one that was used before.
00060  *
00061  * Revision 2.23  2006/10/10 07:18:18  csoutheren
00062  * Allow compilation with and without various options
00063  *
00064  * Revision 2.22  2006/08/29 08:47:43  rjongbloed
00065  * Added functions to get average audio signal level from audio streams in
00066  *   suitable connection types.
00067  *
00068  * Revision 2.21  2006/08/17 23:09:03  rjongbloed
00069  * Added volume controls
00070  *
00071  * Revision 2.20  2006/06/21 04:54:15  csoutheren
00072  * Fixed build with latest PWLib
00073  *
00074  * Revision 2.19  2005/12/28 20:03:00  dsandras
00075  * Attach the silence detector in OnPatchMediaStream so that it can be attached
00076  * before the echo cancellation filter.
00077  *
00078  * Revision 2.18  2005/12/27 22:25:55  dsandras
00079  * Added propagation of the callback to the pcss endpoint.
00080  *
00081  * Revision 2.17  2005/12/27 20:48:01  dsandras
00082  * Added media format parameter when opening the sound channel so that its
00083  * parameters can be used in the body of the method.
00084  *
00085  * Revision 2.16  2005/11/30 13:35:26  csoutheren
00086  * Changed tags for Doxygen
00087  *
00088  * Revision 2.15  2005/11/24 20:31:54  dsandras
00089  * Added support for echo cancelation using Speex.
00090  * Added possibility to add a filter to an OpalMediaPatch for all patches of a connection.
00091  *
00092  * Revision 2.14  2005/10/12 21:11:21  dsandras
00093  * Control if the video streams are started or not from this class.
00094  *
00095  * Revision 2.13  2004/08/14 07:56:29  rjongbloed
00096  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00097  *
00098  * Revision 2.12  2004/07/11 12:42:10  rjongbloed
00099  * Added function on endpoints to get the list of all media formats any
00100  *   connection the endpoint may create can support.
00101  *
00102  * Revision 2.11  2004/05/17 13:24:18  rjongbloed
00103  * Added silence suppression.
00104  *
00105  * Revision 2.10  2004/03/11 06:54:27  csoutheren
00106  * Added ability to disable SIP or H.323 stacks
00107  *
00108  * Revision 2.9  2003/03/17 10:11:05  robertj
00109  * Added call back functions for creating sound channel.
00110  * Added video support.
00111  *
00112  * Revision 2.8  2003/03/06 03:57:47  robertj
00113  * IVR support (work in progress) requiring large changes everywhere.
00114  *
00115  * Revision 2.7  2002/09/16 02:52:35  robertj
00116  * Added #define so can select if #pragma interface/implementation is used on
00117  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00118  *
00119  * Revision 2.6  2002/06/16 02:19:31  robertj
00120  * Fixed and clarified function for initiating call, thanks Ted Szoczei
00121  *
00122  * Revision 2.5  2002/01/22 05:05:16  robertj
00123  * Revamp of user input API triggered by RFC2833 support
00124  *
00125  * Revision 2.4  2001/11/13 06:25:56  robertj
00126  * Changed SetUpConnection() so returns BOOL as returning
00127  *   pointer to connection is not useful.
00128  *
00129  * Revision 2.3  2001/10/15 04:29:26  robertj
00130  * Removed answerCall signal and replaced with state based functions.
00131  *
00132  * Revision 2.2  2001/08/17 08:33:38  robertj
00133  * More implementation.
00134  *
00135  * Revision 2.1  2001/08/01 05:52:24  robertj
00136  * Moved media formats list from endpoint to connection.
00137  *
00138  * Revision 2.0  2001/07/27 15:48:24  robertj
00139  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00140  *
00141  */
00142 
00143 #ifndef __OPAL_PCSS_H
00144 #define __OPAL_PCSS_H
00145 
00146 #ifdef P_USE_PRAGMA
00147 #pragma interface
00148 #endif
00149 
00150 #include <ptbuildopts.h>
00151 
00152 #ifndef P_AUDIO
00153 #warning "PTLib soundcard support not available"
00154 #else
00155 
00156 #include <ptlib/sound.h>
00157 #include <opal/buildopts.h>
00158 #include <opal/endpoint.h>
00159 
00160 class OpalPCSSConnection;
00161 
00162 
00165 class OpalPCSSEndPoint : public OpalEndPoint
00166 {
00167     PCLASSINFO(OpalPCSSEndPoint, OpalEndPoint);
00168   public:
00173     OpalPCSSEndPoint(
00174       OpalManager & manager,  
00175       const char * prefix = "pc" 
00176     );
00177 
00180     ~OpalPCSSEndPoint();
00182 
00214     virtual BOOL MakeConnection(
00215       OpalCall & call,           
00216       const PString & party,     
00217       void * userData = NULL,    
00218       unsigned int options = 0,  
00219       OpalConnection::StringOptions * stringOptions  = NULL
00220     );
00221 
00231     virtual OpalMediaFormatList GetMediaFormats() const;
00233 
00239     virtual OpalPCSSConnection * CreateConnection(
00240       OpalCall & call,    
00241       const PString & playDevice, 
00242       const PString & recordDevice, 
00243       void * userData     
00244     );
00245 
00248     virtual PSoundChannel * CreateSoundChannel(
00249       const OpalPCSSConnection & connection, 
00250       const OpalMediaFormat & mediaFormat,   
00251       BOOL isSource                          
00252     );
00254 
00261     PSafePtr<OpalPCSSConnection> GetPCSSConnectionWithLock(
00262       const PString & token,     
00263       PSafetyMode mode = PSafeReadWrite
00264     ) { return PSafePtrCast<OpalConnection, OpalPCSSConnection>(GetConnectionWithLock(token, mode)); }
00265 
00271     virtual BOOL OnShowIncoming(
00272       const OpalPCSSConnection & connection 
00273     ) = 0;
00274 
00279     virtual BOOL AcceptIncomingConnection(
00280       const PString & connectionToken 
00281     );
00282 
00288     virtual BOOL OnShowOutgoing(
00289       const OpalPCSSConnection & connection 
00290     ) = 0;
00291 
00297     virtual BOOL OnShowUserInput(
00298       const OpalPCSSConnection & connection, 
00299       const PString & indication
00300     );
00301 
00302     
00307     virtual void OnPatchMediaStream(
00308       const OpalPCSSConnection & connection, 
00309       BOOL isSource,                         
00310       OpalMediaPatch & patch                 
00311     );
00313 
00323     virtual BOOL SetSoundChannelPlayDevice(const PString & name);
00324 
00329     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
00330 
00338     virtual BOOL SetSoundChannelRecordDevice(const PString & name);
00339 
00344     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
00345 
00348     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
00349 
00352     void SetSoundChannelBufferDepth(
00353       unsigned depth    
00354     );
00356 
00357 
00358   protected:
00359     PString  soundChannelPlayDevice;
00360     PString  soundChannelRecordDevice;
00361     unsigned soundChannelBuffers;
00362 };
00363 
00364 
00367 class OpalPCSSConnection : public OpalConnection
00368 {
00369     PCLASSINFO(OpalPCSSConnection, OpalConnection);
00370   public:
00375     OpalPCSSConnection(
00376       OpalCall & call,              
00377       OpalPCSSEndPoint & endpoint,  
00378       const PString & playDevice,   
00379       const PString & recordDevice  
00380     );
00381 
00384     ~OpalPCSSConnection();
00386 
00395     virtual BOOL SetUpConnection();
00396 
00407     virtual BOOL SetAlerting(
00408       const PString & calleeName,   
00409       BOOL withMedia                
00410     );
00411 
00416     virtual BOOL SetConnected();
00417 
00425     virtual OpalMediaFormatList GetMediaFormats() const;
00426 
00441     virtual OpalMediaStream * CreateMediaStream(
00442       const OpalMediaFormat & mediaFormat, 
00443       unsigned sessionID,                  
00444       BOOL isSource                        
00445     );
00446 
00454     virtual void OnPatchMediaStream(
00455       BOOL isSource,
00456       OpalMediaPatch & patch    
00457     );
00458 
00461     virtual BOOL OpenSourceMediaStream(
00462       const OpalMediaFormatList & mediaFormats, 
00463       unsigned sessionID                   
00464     );
00465 
00468     virtual OpalMediaStream * OpenSinkMediaStream(
00469       OpalMediaStream & source    
00470     );
00471 
00474     virtual BOOL SetAudioVolume(
00475       BOOL source,                  
00476       unsigned percentage           
00477     );
00478 
00482     virtual unsigned GetAudioSignalLevel(
00483       BOOL source                   
00484     );
00485 
00493     virtual BOOL SendUserInputString(
00494       const PString & value                   
00495     );
00497 
00502     virtual void AcceptIncoming();
00503 
00506     virtual PSoundChannel * CreateSoundChannel(
00507       const OpalMediaFormat & mediaFormat, 
00508       BOOL isSource                        
00509     );
00511 
00518     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
00519 
00524     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
00525 
00528     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
00530 
00531 
00532   protected:
00533     OpalPCSSEndPoint & endpoint;
00534     PString            soundChannelPlayDevice;
00535     PString            soundChannelRecordDevice;
00536     unsigned           soundChannelBuffers;
00537 };
00538 
00539 #endif // P_AUDIO
00540 
00541 #endif // __OPAL_PCSS_H
00542 
00543 
00544 // End of File ///////////////////////////////////////////////////////////////

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