OPAL Version 3.10.2
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  * $Revision: 26069 $
00028  * $Author: rjongbloed $
00029  * $Date: 2011-06-23 19:56:50 -0500 (Thu, 23 Jun 2011) $
00030  */
00031 
00032 #ifndef OPAL_OPAL_PCSS_H
00033 #define OPAL_OPAL_PCSS_H
00034 
00035 #ifdef P_USE_PRAGMA
00036 #pragma interface
00037 #endif
00038 
00039 
00040 #include <opal/buildopts.h>
00041 
00042 #if OPAL_HAS_PCSS
00043 
00044 #include <ptlib/sound.h>
00045 #include <opal/localep.h>
00046 
00047 
00048 class OpalPCSSConnection;
00049 
00050 
00053 class OpalPCSSEndPoint : public OpalLocalEndPoint
00054 {
00055     PCLASSINFO(OpalPCSSEndPoint, OpalLocalEndPoint);
00056   public:
00061     OpalPCSSEndPoint(
00062       OpalManager & manager,  
00063       const char * prefix = "pc" 
00064     );
00065 
00068     ~OpalPCSSEndPoint();
00070 
00102     virtual PSafePtr<OpalConnection> MakeConnection(
00103       OpalCall & call,           
00104       const PString & party,     
00105       void * userData = NULL,    
00106       unsigned options = 0,                    
00107       OpalConnection::StringOptions * stringOptions = NULL 
00108     );
00110 
00118     virtual bool OnOutgoingCall(
00119       const OpalLocalConnection & connection 
00120     );
00121 
00131     virtual bool OnIncomingCall(
00132       OpalLocalConnection & connection 
00133     );
00134 
00140     virtual bool OnUserInput(
00141       const OpalLocalConnection & connection, 
00142       const PString & indication              
00143     );
00145 
00151     virtual OpalPCSSConnection * CreateConnection(
00152       OpalCall & call,    
00153       const PString & playDevice, 
00154       const PString & recordDevice, 
00155       void * userData,    
00156       unsigned options,                    
00157       OpalConnection::StringOptions * stringOptions 
00158     );
00159 
00162     virtual PSoundChannel * CreateSoundChannel(
00163       const OpalPCSSConnection & connection, 
00164       const OpalMediaFormat & mediaFormat,   
00165       PBoolean isSource                          
00166     );
00168 
00177     PSafePtr<OpalPCSSConnection> GetPCSSConnectionWithLock(
00178       const PString & token,     
00179       PSafetyMode mode = PSafeReadWrite 
00180     ) { return GetConnectionWithLockAs<OpalPCSSConnection>(token, mode); }
00181 
00190     virtual PBoolean OnShowIncoming(
00191       const OpalPCSSConnection & connection 
00192     ) = 0;
00193 
00198     virtual PBoolean AcceptIncomingConnection(
00199       const PString & connectionToken 
00200     );
00201 
00206     virtual PBoolean RejectIncomingConnection(
00207       const PString & connectionToken,       
00208       const OpalConnection::CallEndReason & reason = OpalConnection::EndedByAnswerDenied 
00209     );
00210 
00216     virtual PBoolean OnShowOutgoing(
00217       const OpalPCSSConnection & connection 
00218     ) = 0;
00219 
00225     virtual PBoolean OnShowUserInput(
00226       const OpalPCSSConnection & connection, 
00227       const PString & indication             
00228     );
00230 
00240     virtual PBoolean SetSoundChannelPlayDevice(const PString & name);
00241 
00246     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
00247 
00255     virtual PBoolean SetSoundChannelRecordDevice(const PString & name);
00256 
00261     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
00262 
00267     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
00268 
00273     void SetSoundChannelBufferDepth(
00274       unsigned depth    
00275     );
00276 
00281     unsigned GetSoundChannelBufferTime() const { return m_soundChannelBufferTime; }
00282 
00287     void SetSoundChannelBufferTime(
00288       unsigned depth    
00289     );
00291 
00292   protected:
00293     PString  soundChannelPlayDevice;
00294     PString  soundChannelRecordDevice;
00295     unsigned soundChannelBuffers;
00296     unsigned m_soundChannelBufferTime;
00297 
00298   private:
00299     P_REMOVE_VIRTUAL(OpalPCSSConnection *, CreateConnection(OpalCall &, const PString &, const PString &, void *), 0)
00300 };
00301 
00302 
00305 class OpalPCSSConnection : public OpalLocalConnection
00306 {
00307     PCLASSINFO(OpalPCSSConnection, OpalLocalConnection);
00308   public:
00313     OpalPCSSConnection(
00314       OpalCall & call,              
00315       OpalPCSSEndPoint & endpoint,  
00316       const PString & playDevice,   
00317       const PString & recordDevice,  
00318       unsigned options = 0,                    
00319       OpalConnection::StringOptions * stringOptions = NULL 
00320     );
00321 
00324     ~OpalPCSSConnection();
00326 
00335     virtual bool TransferConnection(
00336       const PString & remoteParty   
00337     );
00338 
00353     virtual OpalMediaStream * CreateMediaStream(
00354       const OpalMediaFormat & mediaFormat, 
00355       unsigned sessionID,                  
00356       PBoolean isSource                        
00357     );
00358 
00361     virtual PBoolean SetAudioVolume(
00362       PBoolean source,                  
00363       unsigned percentage           
00364     );
00365 
00369     virtual unsigned GetAudioSignalLevel(
00370       PBoolean source                   
00371     );
00373 
00378     virtual PSoundChannel * CreateSoundChannel(
00379       const OpalMediaFormat & mediaFormat, 
00380       PBoolean isSource                        
00381     );
00383 
00390     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
00391 
00396     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
00397 
00402     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
00403 
00408     unsigned GetSoundChannelBufferTime() const { return m_soundChannelBufferTime; }
00410 
00411 
00412   protected:
00413     OpalPCSSEndPoint & endpoint;
00414     PString            soundChannelPlayDevice;
00415     PString            soundChannelRecordDevice;
00416     unsigned           soundChannelBuffers;
00417     unsigned           m_soundChannelBufferTime;
00418 };
00419 
00420 #else
00421 
00422 #ifdef _MSC_VER
00423 #pragma message("PTLib soundcard support not available")
00424 #else
00425 #warning "PTLib soundcard support not available"
00426 #endif
00427 
00428 
00429 #endif // OPAL_HAS_PCSS
00430 
00431 #endif // OPAL_OPAL_PCSS_H
00432 
00433 
00434 // End of File ///////////////////////////////////////////////////////////////