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: 19671 $
00028  * $Author: rjongbloed $
00029  * $Date: 2008-03-05 02:48:22 +0000 (Wed, 05 Mar 2008) $
00030  */
00031 
00032 #ifndef __OPAL_IVR_H
00033 #define __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/endpoint.h>
00045 
00046 
00047 class OpalIVRConnection;
00048 
00049 
00052 class OpalIVREndPoint : public OpalEndPoint
00053 {
00054     PCLASSINFO(OpalIVREndPoint, OpalEndPoint);
00055   public:
00060     OpalIVREndPoint(
00061       OpalManager & manager,  
00062       const char * prefix = "ivr" 
00063     );
00064 
00067     ~OpalIVREndPoint();
00069 
00101     virtual PBoolean MakeConnection(
00102       OpalCall & call,          
00103       const PString & party,    
00104       void * userData = NULL,   
00105       unsigned int options = 0, 
00106       OpalConnection::StringOptions * stringOptions = NULL
00107 
00108     );
00109 
00119     virtual OpalMediaFormatList GetMediaFormats() const;
00121 
00127     virtual OpalIVRConnection * CreateConnection(
00128       OpalCall & call,        
00129       const PString & token,  
00130       void * userData,        
00131       const PString & vxml,   
00132       OpalConnection::StringOptions * stringOptions = NULL
00133     );
00134 
00137     virtual PString CreateConnectionToken();
00139 
00146     PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
00147       const PString & token,     
00148       PSafetyMode mode = PSafeReadWrite
00149     ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
00150 
00153     const PString & GetDefaultVXML() const { return defaultVXML; }
00154 
00157     void SetDefaultVXML(
00158       const PString & vxml
00159     );
00160 
00163     void SetDefaultMediaFormats(
00164       const OpalMediaFormatList & formats
00165     );
00166 
00170     virtual PBoolean StartVXML();
00171 
00174     void SetDefaultTextToSpeech(const PString & tts)
00175     { defaultTts = tts; }
00176 
00177     PString GetDefaultTextToSpeech() const
00178     { return defaultTts; }
00179 
00181 
00182   protected:
00183     unsigned            nextTokenNumber;
00184     PString             defaultVXML;
00185     OpalMediaFormatList defaultMediaFormats;
00186     PString             defaultTts;
00187 };
00188 
00189 
00192 class OpalIVRConnection : public OpalConnection
00193 {
00194     PCLASSINFO(OpalIVRConnection, OpalConnection);
00195   public:
00200     OpalIVRConnection(
00201       OpalCall & call,            
00202       OpalIVREndPoint & endpoint, 
00203       const PString & token,      
00204       void * userData,            
00205       const PString & vxml,       
00206       OpalConnection::StringOptions * stringOptions = NULL
00207     );
00208 
00211     ~OpalIVRConnection();
00213 
00222     virtual PBoolean SetUpConnection();
00223 
00234     virtual PBoolean SetAlerting(
00235       const PString & calleeName,   
00236       PBoolean withMedia                
00237     );
00238 
00243     virtual PBoolean SetConnected();
00244 
00250     void OnEstablished();
00251 
00259     virtual OpalMediaFormatList GetMediaFormats() const;
00260 
00275     virtual OpalMediaStream * CreateMediaStream(
00276       const OpalMediaFormat & mediaFormat, 
00277       unsigned sessionID,                  
00278       PBoolean isSource                        
00279     );
00280 
00288     virtual PBoolean SendUserInputString(
00289       const PString & value                   
00290     );
00292 
00296     virtual PBoolean StartVXML();
00297 
00298     void OnMediaPatchStop(unsigned, bool);
00299 
00300     PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00301     { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00302 
00303     PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00304     { return vxmlSession.SetTextToSpeech(ttsName); }
00305 
00306     PTextToSpeech * GetTextToSpeech()
00307     { return vxmlSession.GetTextToSpeech(); }
00308 
00309 
00310   protected:
00311     OpalIVREndPoint   & endpoint;
00312     PString             vxmlToLoad;
00313     OpalMediaFormatList vxmlMediaFormats;
00314     OpalVXMLSession     vxmlSession;
00315 };
00316 
00317 
00321 class OpalIVRMediaStream : public OpalRawMediaStream
00322 {
00323     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00324   public:
00329     OpalIVRMediaStream(
00330       OpalIVRConnection & conn,
00331       const OpalMediaFormat & mediaFormat, 
00332       unsigned sessionID,                  
00333       PBoolean isSource,                       
00334       PVXMLSession & vxml                  
00335     );
00337 
00345     virtual PBoolean Open();
00346 
00350     virtual PBoolean IsSynchronous() const;
00351 
00352     PBoolean ReadPacket(RTP_DataFrame & packet);
00354 
00355   protected:
00356     OpalConnection & conn;
00357     PVXMLSession & vxmlSession;
00358 };
00359 
00360 
00361 #endif // OPAL_IVR
00362 
00363 #endif // __OPAL_IVR_H
00364 
00365 
00366 // End of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 07:36:36 2008 for OPAL by  doxygen 1.5.1