# ivr.h

Go to the documentation of this file.

    00001 /*
    00002  * ivr.h
    00003  *
    00004  * Interactive Voice Response 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: 29431 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2013-04-03 21:28:12 -0500 (Wed, 03 Apr 2013) $
    00030  */
    00031
    00032 #ifndef OPAL_OPAL_IVR_H
    00033 #define OPAL_OPAL_IVR_H
    00034
    00035 #ifdef P_USE_PRAGMA
    00036 #pragma interface
    00037 #endif
    00038
    00039 #include <opal/buildopts.h>
    00040
    00041 #if OPAL_IVR
    00042
    00043 #include <ep/opalvxml.h>
    00044 #include <ep/localep.h>
    00045
    00046 class OpalIVRConnection;
    00047
    00048
    00051 class OpalIVREndPoint : public OpalLocalEndPoint
    00052 {
    00053     PCLASSINFO(OpalIVREndPoint, OpalLocalEndPoint);
    00054   public:
    00059     OpalIVREndPoint(
    00060       OpalManager & manager,
    00061       const char * prefix = "ivr"
    00062     );
    00063
    00066     ~OpalIVREndPoint();
    00068
    00100     virtual PSafePtr<OpalConnection> MakeConnection(
    00101       OpalCall & call,
    00102       const PString & party,
    00103       void * userData = NULL,
    00104       unsigned int options = 0,
    00105       OpalConnection::StringOptions * stringOptions = NULL
    00106
    00107     );
    00108
    00118     virtual OpalMediaFormatList GetMediaFormats() const;
    00120
    00126     virtual OpalIVRConnection * CreateConnection(
    00127       OpalCall & call,
    00128       void * userData,
    00129       const PString & vxml,
    00130       unsigned int options,
    00131       OpalConnection::StringOptions * stringOptions = NULL
    00132     );
    00134
    00141     PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
    00142       const PString & token,
    00143       PSafetyMode mode = PSafeReadWrite
    00144     ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
    00145
    00148     const PString & GetDefaultVXML() const { return m_defaultVXML; }
    00149
    00152     void SetDefaultVXML(
    00153       const PString & vxml
    00154     );
    00155
    00158     void SetDefaultMediaFormats(
    00159       const OpalMediaFormatList & formats
    00160     );
    00161
    00169     virtual void OnEndDialog(
    00170       OpalIVRConnection & connection
    00171     );
    00172
    00175     void SetDefaultTextToSpeech(const PString & tts)
    00176     { m_defaultTTS = tts; }
    00177
    00178     PString GetDefaultTextToSpeech() const
    00179     { return m_defaultTTS; }
    00180
    00183     const PDirectory & GetCacheDir() const { return m_ttsCache.GetDirectory(); }
    00184
    00187     void SetCacheDir(
    00188       const PDirectory & dir
    00189     ) { m_ttsCache.SetDirectory(dir); }
    00190
    00191     void SetRecordDirectory(const PDirectory & dir) { m_recordDirectory = dir; }
    00192     const PDirectory & GetRecordDirectory() const   { return m_recordDirectory; }
    00194
    00195     // Allow users to override cache algorithm
    00196     virtual PVXMLCache & GetTextToSpeechCache() { return m_ttsCache; }
    00197
    00198   protected:
    00199     PString             m_defaultVXML;
    00200     OpalMediaFormatList m_defaultMediaFormats;
    00201     PString             m_defaultTTS;
    00202     PMutex              m_defaultsMutex;
    00203     PVXMLCache          m_ttsCache;
    00204     PDirectory          m_recordDirectory;
    00205
    00206   private:
    00207     P_REMOVE_VIRTUAL(OpalIVRConnection *, CreateConnection(OpalCall &,const PString &,void *,const PString &,OpalConnection::StringOptions *),0);
    00208 };
    00209
    00210
    00213 class OpalIVRConnection : public OpalLocalConnection
    00214 {
    00215     PCLASSINFO(OpalIVRConnection, OpalLocalConnection);
    00216   public:
    00221     OpalIVRConnection(
    00222       OpalCall & call,
    00223       OpalIVREndPoint & endpoint,
    00224       void * userData,
    00225       const PString & vxml,
    00226       unsigned int options,
    00227       OpalConnection::StringOptions * stringOptions = NULL
    00228     );
    00229
    00232     ~OpalIVRConnection();
    00234
    00245     virtual bool IsNetworkConnection() const { return false; }
    00246
    00249     virtual PString GetLocalPartyURL() const;
    00250
    00256     void OnEstablished();
    00257
    00264     virtual bool OnTransferNotify(
    00265       const PStringToString & info,
    00266       const OpalConnection * transferringConnection
    00268     );
    00269
    00276     virtual bool TransferConnection(
    00277       const PString & remoteParty
    00278     );
    00279
    00287     virtual OpalMediaFormatList GetMediaFormats() const;
    00288
    00303     virtual OpalMediaStream * CreateMediaStream(
    00304       const OpalMediaFormat & mediaFormat,
    00305       unsigned sessionID,
    00306       PBoolean isSource
    00307     );
    00308
    00316     virtual PBoolean SendUserInputString(
    00317       const PString & value
    00318     );
    00320
    00324     virtual void OnEndDialog();
    00325
    00326     const PString & GetVXML() const { return m_vxmlScript; }
    00327     const OpalVXMLSession & GetVXMLSession() const { return m_vxmlSession; }
    00328     OpalVXMLSession & GetVXMLSession() { return m_vxmlSession; }
    00329
    00330     PTextToSpeech * GetTextToSpeech() const { return m_vxmlSession.GetTextToSpeech(); }
    00331     PTextToSpeech * SetTextToSpeech(const PString & ttsName) { return m_vxmlSession.SetTextToSpeech(ttsName); }
    00332     PTextToSpeech * SetTextToSpeech(PTextToSpeech * tts, PBoolean autoDelete = false) { return m_vxmlSession.SetTextToSpeech(tts, autoDelete); }
    00333
    00334   protected:
    00335     virtual bool StartVXML(const PString & vxml);
    00336     virtual bool StartScript(const PString & script);
    00337
    00338     OpalIVREndPoint   & endpoint;
    00339     PString             m_vxmlScript;
    00340     OpalMediaFormatList m_vxmlMediaFormats;
    00341     OpalVXMLSession     m_vxmlSession;
    00342 };
    00343
    00344
    00348 class OpalIVRMediaStream : public OpalRawMediaStream
    00349 {
    00350     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
    00351   public:
    00356     OpalIVRMediaStream(
    00357       OpalIVRConnection & conn,
    00358       const OpalMediaFormat & mediaFormat,
    00359       unsigned sessionID,
    00360       PBoolean isSource,
    00361       PVXMLSession & vxml
    00362     );
    00364
    00372     virtual PBoolean Open();
    00373
    00377     virtual PBoolean IsSynchronous() const;
    00379
    00380   protected:
    00381     virtual void InternalClose();
    00382
    00383     PVXMLSession & m_vxmlSession;
    00384 };
    00385
    00386
    00387 #endif // OPAL_IVR
    00388
    00389 #endif // OPAL_OPAL_IVR_H
    00390
    00391
    00392 // End of File ///////////////////////////////////////////////////////////////