OPAL  Version 3.10.4
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: 26927 $
00028  * $Author: rjongbloed $
00029  * $Date: 2012-02-01 16:09:34 -0600 (Wed, 01 Feb 2012) $
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 <opal/opalvxml.h>
00044 #include <opal/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 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     { defaultTts = tts; }
00177 
00178     PString GetDefaultTextToSpeech() const
00179     { return defaultTts; }
00180 
00182 
00183   protected:
00184     PString             defaultVXML;
00185     OpalMediaFormatList defaultMediaFormats;
00186     PString             defaultTts;
00187 
00188   private:
00189     P_REMOVE_VIRTUAL(OpalIVRConnection *, CreateConnection(OpalCall &,const PString &,void *,const PString &,OpalConnection::StringOptions *),0);
00190 };
00191 
00192 
00195 class OpalIVRConnection : public OpalLocalConnection
00196 {
00197     PCLASSINFO(OpalIVRConnection, OpalLocalConnection);
00198   public:
00203     OpalIVRConnection(
00204       OpalCall & call,            
00205       OpalIVREndPoint & endpoint, 
00206       void * userData,            
00207       const PString & vxml,       
00208       unsigned int options,
00209       OpalConnection::StringOptions * stringOptions = NULL
00210     );
00211 
00214     ~OpalIVRConnection();
00216 
00227     virtual bool IsNetworkConnection() const { return false; }
00228 
00231     virtual PString GetLocalPartyURL() const;
00232 
00238     void OnEstablished();
00239     
00246     virtual bool OnTransferNotify(
00247       const PStringToString & info, 
00248       const OpalConnection * transferringConnection
00250     );
00251 
00258     virtual bool TransferConnection(
00259       const PString & remoteParty   
00260     );
00261 
00269     virtual OpalMediaFormatList GetMediaFormats() const;
00270 
00285     virtual OpalMediaStream * CreateMediaStream(
00286       const OpalMediaFormat & mediaFormat, 
00287       unsigned sessionID,                  
00288       PBoolean isSource                        
00289     );
00290 
00298     virtual PBoolean SendUserInputString(
00299       const PString & value                   
00300     );
00302 
00306     virtual void OnEndDialog();
00307 
00308     const PString & GetVXML() const { return m_vxmlScript; }
00309     const OpalVXMLSession & GetVXMLSession() const { return m_vxmlSession; }
00310     OpalVXMLSession & GetVXMLSession() { return m_vxmlSession; }
00311 
00312     PTextToSpeech * GetTextToSpeech() const { return m_vxmlSession.GetTextToSpeech(); }
00313     PTextToSpeech * SetTextToSpeech(const PString & ttsName) { return m_vxmlSession.SetTextToSpeech(ttsName); }
00314     PTextToSpeech * SetTextToSpeech(PTextToSpeech * tts, PBoolean autoDelete = false) { return m_vxmlSession.SetTextToSpeech(tts, autoDelete); }
00315 
00316   protected:
00317     virtual bool StartVXML(const PString & vxml);
00318     virtual bool StartScript(const PString & script);
00319 
00320     OpalIVREndPoint   & endpoint;
00321     PString             m_vxmlScript;
00322     OpalMediaFormatList m_vxmlMediaFormats;
00323     OpalVXMLSession     m_vxmlSession;
00324 };
00325 
00326 
00330 class OpalIVRMediaStream : public OpalRawMediaStream
00331 {
00332     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00333   public:
00338     OpalIVRMediaStream(
00339       OpalIVRConnection & conn,
00340       const OpalMediaFormat & mediaFormat, 
00341       unsigned sessionID,                  
00342       PBoolean isSource,                       
00343       PVXMLSession & vxml                  
00344     );
00346 
00354     virtual PBoolean Open();
00355 
00360     virtual PBoolean Close();
00361 
00365     virtual PBoolean IsSynchronous() const;
00367 
00368   protected:
00369     PVXMLSession & m_vxmlSession;
00370 };
00371 
00372 
00373 #endif // OPAL_IVR
00374 
00375 #endif // OPAL_OPAL_IVR_H
00376 
00377 
00378 // End of File ///////////////////////////////////////////////////////////////