# 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: 21004 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2008-09-16 07:08:56 +0000 (Tue, 16 Sep 2008) $
    00030  */
    00031
    00032 #ifndef __OPAL_PCSS_H
    00033 #define __OPAL_PCSS_H
    00034
    00035 #ifdef P_USE_PRAGMA
    00036 #pragma interface
    00037 #endif
    00038
    00039
    00040 #include <opal/buildopts.h>
    00041
    00042 #ifndef OPAL_PTLIB_AUDIO
    00043 #ifdef _MSC_VER
    00044 #pragma message("PTLib soundcard support not available")
    00045 #else
    00046 #warning "PTLib soundcard support not available"
    00047 #endif
    00048 #else
    00049
    00050 #include <ptlib/sound.h>
    00051 #include <opal/endpoint.h>
    00052
    00053 class OpalPCSSConnection;
    00054
    00055
    00058 class OpalPCSSEndPoint : public OpalEndPoint
    00059 {
    00060     PCLASSINFO(OpalPCSSEndPoint, OpalEndPoint);
    00061   public:
    00066     OpalPCSSEndPoint(
    00067       OpalManager & manager,
    00068       const char * prefix = "pc"
    00069     );
    00070
    00073     ~OpalPCSSEndPoint();
    00075
    00107     virtual PBoolean MakeConnection(
    00108       OpalCall & call,
    00109       const PString & party,
    00110       void * userData = NULL,
    00111       unsigned int options = 0,
    00112       OpalConnection::StringOptions * stringOptions  = NULL
    00113     );
    00115
    00121     virtual OpalPCSSConnection * CreateConnection(
    00122       OpalCall & call,
    00123       const PString & playDevice,
    00124       const PString & recordDevice,
    00125       void * userData
    00126     );
    00127
    00130     virtual PSoundChannel * CreateSoundChannel(
    00131       const OpalPCSSConnection & connection,
    00132       const OpalMediaFormat & mediaFormat,
    00133       PBoolean isSource
    00134     );
    00136
    00145     PSafePtr<OpalPCSSConnection> GetPCSSConnectionWithLock(
    00146       const PString & token,
    00147       PSafetyMode mode = PSafeReadWrite
    00148     ) { return GetConnectionWithLockAs<OpalPCSSConnection>(token, mode); }
    00149
    00155     virtual PBoolean OnShowIncoming(
    00156       const OpalPCSSConnection & connection
    00157     ) = 0;
    00158
    00163     virtual PBoolean AcceptIncomingConnection(
    00164       const PString & connectionToken
    00165     );
    00166
    00171     virtual PBoolean RejectIncomingConnection(
    00172       const PString & connectionToken
    00173     );
    00174
    00180     virtual PBoolean OnShowOutgoing(
    00181       const OpalPCSSConnection & connection
    00182     ) = 0;
    00183
    00189     virtual PBoolean OnShowUserInput(
    00190       const OpalPCSSConnection & connection,
    00191       const PString & indication
    00192     );
    00193
    00194
    00199     virtual void OnPatchMediaStream(
    00200       const OpalPCSSConnection & connection,
    00201       PBoolean isSource,
    00202       OpalMediaPatch & patch
    00203     );
    00205
    00215     virtual PBoolean SetSoundChannelPlayDevice(const PString & name);
    00216
    00221     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
    00222
    00230     virtual PBoolean SetSoundChannelRecordDevice(const PString & name);
    00231
    00236     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
    00237
    00240     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
    00241
    00244     void SetSoundChannelBufferDepth(
    00245       unsigned depth
    00246     );
    00248
    00249     OpalMediaFormatList GetMediaFormats() const;
    00250
    00251   protected:
    00252     PString  soundChannelPlayDevice;
    00253     PString  soundChannelRecordDevice;
    00254     unsigned soundChannelBuffers;
    00255 };
    00256
    00257
    00260 class OpalPCSSConnection : public OpalConnection
    00261 {
    00262     PCLASSINFO(OpalPCSSConnection, OpalConnection);
    00263   public:
    00268     OpalPCSSConnection(
    00269       OpalCall & call,
    00270       OpalPCSSEndPoint & endpoint,
    00271       const PString & playDevice,
    00272       const PString & recordDevice
    00273     );
    00274
    00277     ~OpalPCSSConnection();
    00279
    00290     virtual bool IsNetworkConnection() const { return false; }
    00291
    00298     virtual PBoolean SetUpConnection();
    00299
    00310     virtual PBoolean SetAlerting(
    00311       const PString & calleeName,
    00312       PBoolean withMedia
    00313     );
    00314
    00329     virtual OpalMediaStream * CreateMediaStream(
    00330       const OpalMediaFormat & mediaFormat,
    00331       unsigned sessionID,
    00332       PBoolean isSource
    00333     );
    00334
    00342     virtual void OnPatchMediaStream(
    00343       PBoolean isSource,
    00344       OpalMediaPatch & patch
    00345     );
    00346
    00349     virtual OpalMediaStreamPtr OpenMediaStream(
    00350       const OpalMediaFormat & mediaFormat,
    00351       unsigned sessionID,
    00352       bool isSource
    00353     );
    00354
    00357     virtual PBoolean SetAudioVolume(
    00358       PBoolean source,
    00359       unsigned percentage
    00360     );
    00361
    00365     virtual unsigned GetAudioSignalLevel(
    00366       PBoolean source
    00367     );
    00368
    00376     virtual PBoolean SendUserInputString(
    00377       const PString & value
    00378     );
    00380
    00385     virtual void AcceptIncoming();
    00386
    00389     virtual PSoundChannel * CreateSoundChannel(
    00390       const OpalMediaFormat & mediaFormat,
    00391       PBoolean isSource
    00392     );
    00394
    00401     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
    00402
    00407     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
    00408
    00411     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
    00413
    00414
    00415   protected:
    00416     OpalPCSSEndPoint & endpoint;
    00417     PString            soundChannelPlayDevice;
    00418     PString            soundChannelRecordDevice;
    00419     unsigned           soundChannelBuffers;
    00420 };
    00421
    00422 #endif // OPAL_PTLIB_AUDIO
    00423
    00424 #endif // __OPAL_PCSS_H
    00425
    00426
    00427 // End of File ///////////////////////////////////////////////////////////////