# 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: 28481 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2012-10-05 03:13:17 -0500 (Fri, 05 Oct 2012) $
    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 <ep/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
    00362     virtual PBoolean SetAudioVolume(
    00363       PBoolean source,
    00364       unsigned percentage
    00365     );
    00366
    00370     virtual PBoolean GetAudioVolume(
    00371       PBoolean source,
    00372       unsigned & percentage
    00373     );
    00374
    00377     virtual bool SetAudioMute(
    00378       bool source,
    00379       bool mute
    00380     );
    00381
    00384     virtual bool GetAudioMute(
    00385       bool source,
    00386       bool & mute
    00387     );
    00388
    00392     virtual unsigned GetAudioSignalLevel(
    00393       PBoolean source
    00394     );
    00396
    00401     virtual PSoundChannel * CreateSoundChannel(
    00402       const OpalMediaFormat & mediaFormat,
    00403       PBoolean isSource
    00404     );
    00406
    00413     const PString & GetSoundChannelPlayDevice() const { return soundChannelPlayDevice; }
    00414
    00419     const PString & GetSoundChannelRecordDevice() const { return soundChannelRecordDevice; }
    00420
    00425     unsigned GetSoundChannelBufferDepth() const { return soundChannelBuffers; }
    00426
    00431     unsigned GetSoundChannelBufferTime() const { return m_soundChannelBufferTime; }
    00433
    00434
    00435   protected:
    00436     OpalPCSSEndPoint & endpoint;
    00437     PString            soundChannelPlayDevice;
    00438     PString            soundChannelRecordDevice;
    00439     unsigned           soundChannelBuffers;
    00440     unsigned           m_soundChannelBufferTime;
    00441 };
    00442
    00443 #else
    00444
    00445 #ifdef _MSC_VER
    00446 #pragma message("PTLib soundcard support not available")
    00447 #else
    00448 #warning "PTLib soundcard support not available"
    00449 #endif
    00450
    00451
    00452 #endif // OPAL_HAS_PCSS
    00453
    00454 #endif // OPAL_OPAL_PCSS_H
    00455
    00456
    00457 // End of File ///////////////////////////////////////////////////////////////