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  * $Log: ivr.h,v $
00028  * Revision 2.18  2007/09/04 07:46:24  csoutheren
00029  * Fixed tts
00030  *
00031  * Revision 2.17  2007/09/04 04:48:13  csoutheren
00032  * Fix state machine problems
00033  *
00034  * Revision 2.16  2007/03/29 05:15:48  csoutheren
00035  * Pass OpalConnection to OpalMediaSream constructor
00036  * Add ID to OpalMediaStreams so that transcoders can match incoming and outgoing codecs
00037  *
00038  * Revision 2.15  2007/03/13 00:32:16  csoutheren
00039  * Simple but messy changes to allow compile time removal of protocol
00040  * options such as H.450 and H.460
00041  * Fix MakeConnection overrides
00042  *
00043  * Revision 2.14  2007/03/01 05:51:04  rjongbloed
00044  * Fixed backward compatibility of OnIncomingConnection() virtual
00045  *   functions on various classes. If an old override returned FALSE
00046  *   then it will now abort the call as it used to.
00047  *
00048  * Revision 2.13  2007/01/24 04:00:56  csoutheren
00049  * Arrrghh. Changing OnIncomingConnection turned out to have a lot of side-effects
00050  * Added some pure viritual functions to prevent old code from breaking silently
00051  * New OpalEndpoint and OpalConnection descendants will need to re-implement
00052  * OnIncomingConnection. Sorry :)
00053  *
00054  * Revision 2.12  2006/12/18 03:18:41  csoutheren
00055  * Messy but simple fixes
00056  *   - Add access to SIP REGISTER timeout
00057  *   - Ensure OpalConnection options are correctly progagated
00058  *
00059  * Revision 2.11  2006/10/15 06:23:35  rjongbloed
00060  * Fixed the mechanism where both A-party and B-party are indicated by the application. This now works
00061  *   for LIDs as well as PC endpoint, wheich is the only one that was used before.
00062  *
00063  * Revision 2.10  2006/04/30 14:34:42  csoutheren
00064  * Backport of IVR updates from PluginBranch
00065  *
00066  * Revision 2.9.4.1  2006/04/30 13:49:34  csoutheren
00067  * Add ability to set TextToSpeech driver
00068  * Add useful defaults for VXML handling
00069  *
00070  * Revision 2.9  2005/11/30 13:35:26  csoutheren
00071  * Changed tags for Doxygen
00072  *
00073  * Revision 2.8  2004/08/14 07:56:29  rjongbloed
00074  * Major revision to utilise the PSafeCollection classes for the connections and calls.
00075  *
00076  * Revision 2.7  2004/07/15 12:32:29  rjongbloed
00077  * Various enhancements to the VXML code
00078  *
00079  * Revision 2.6  2004/07/11 12:42:10  rjongbloed
00080  * Added function on endpoints to get the list of all media formats any
00081  *   connection the endpoint may create can support.
00082  *
00083  * Revision 2.5  2004/04/18 13:35:27  rjongbloed
00084  * Fixed ability to make calls where both endpoints are specified a priori. In particular
00085  *   fixing the VXML support for an outgoing sip/h323 call.
00086  *
00087  * Revision 2.4  2003/03/19 02:30:45  robertj
00088  * Added removal of IVR stuff if EXPAT is not installed on system.
00089  *
00090  * Revision 2.3  2003/03/17 10:26:59  robertj
00091  * Added video support.
00092  *
00093  * Revision 2.2  2003/03/07 05:49:54  robertj
00094  * Use OpalVXMLSession so OnEndSession() to automatically closes connection.
00095  *
00096  * Revision 2.1  2003/03/06 03:57:47  robertj
00097  * IVR support (work in progress) requiring large changes everywhere.
00098  *
00099  */
00100 
00101 #ifndef __OPAL_IVR_H
00102 #define __OPAL_IVR_H
00103 
00104 #ifdef P_USE_PRAGMA
00105 #pragma interface
00106 #endif
00107 
00108 
00109 #if P_EXPAT
00110 
00111 #include <opal/opalvxml.h>
00112 #include <opal/endpoint.h>
00113 
00114 
00115 class OpalIVRConnection;
00116 
00117 
00120 class OpalIVREndPoint : public OpalEndPoint
00121 {
00122     PCLASSINFO(OpalIVREndPoint, OpalEndPoint);
00123   public:
00128     OpalIVREndPoint(
00129       OpalManager & manager,  
00130       const char * prefix = "ivr" 
00131     );
00132 
00135     ~OpalIVREndPoint();
00137 
00169     virtual BOOL MakeConnection(
00170       OpalCall & call,          
00171       const PString & party,    
00172       void * userData = NULL,   
00173       unsigned int options = 0, 
00174       OpalConnection::StringOptions * stringOptions = NULL
00175 
00176     );
00177 
00187     virtual OpalMediaFormatList GetMediaFormats() const;
00189 
00195     virtual OpalIVRConnection * CreateConnection(
00196       OpalCall & call,        
00197       const PString & token,  
00198       void * userData,        
00199       const PString & vxml,   
00200       OpalConnection::StringOptions * stringOptions = NULL
00201     );
00202 
00205     virtual PString CreateConnectionToken();
00207 
00214     PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
00215       const PString & token,     
00216       PSafetyMode mode = PSafeReadWrite
00217     ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
00218 
00221     const PString & GetDefaultVXML() const { return defaultVXML; }
00222 
00225     void SetDefaultVXML(
00226       const PString & vxml
00227     );
00228 
00231     void SetDefaultMediaFormats(
00232       const OpalMediaFormatList & formats
00233     );
00234 
00238     virtual BOOL StartVXML();
00239 
00242     void SetDefaultTextToSpeech(const PString & tts)
00243     { defaultTts = tts; }
00244 
00245     PString GetDefaultTextToSpeech() const
00246     { return defaultTts; }
00247 
00249 
00250   protected:
00251     unsigned            nextTokenNumber;
00252     PString             defaultVXML;
00253     OpalMediaFormatList defaultMediaFormats;
00254     PString             defaultTts;
00255 };
00256 
00257 
00260 class OpalIVRConnection : public OpalConnection
00261 {
00262     PCLASSINFO(OpalIVRConnection, OpalConnection);
00263   public:
00268     OpalIVRConnection(
00269       OpalCall & call,            
00270       OpalIVREndPoint & endpoint, 
00271       const PString & token,      
00272       void * userData,            
00273       const PString & vxml,       
00274       OpalConnection::StringOptions * stringOptions = NULL
00275     );
00276 
00279     ~OpalIVRConnection();
00281 
00290     virtual BOOL SetUpConnection();
00291 
00302     virtual BOOL SetAlerting(
00303       const PString & calleeName,   
00304       BOOL withMedia                
00305     );
00306 
00311     virtual BOOL SetConnected();
00312 
00313     void OnEstablished();
00314 
00322     virtual OpalMediaFormatList GetMediaFormats() const;
00323 
00338     virtual OpalMediaStream * CreateMediaStream(
00339       const OpalMediaFormat & mediaFormat, 
00340       unsigned sessionID,                  
00341       BOOL isSource                        
00342     );
00343 
00351     virtual BOOL SendUserInputString(
00352       const PString & value                   
00353     );
00355 
00359     virtual BOOL StartVXML();
00360 
00361     PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, BOOL autoDelete = FALSE)
00362     { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00363 
00364     PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00365     { return vxmlSession.SetTextToSpeech(ttsName); }
00366 
00367     PTextToSpeech * GetTextToSpeech()
00368     { return vxmlSession.GetTextToSpeech(); }
00369 
00370 
00371   protected:
00372     OpalIVREndPoint   & endpoint;
00373     PString             vxmlToLoad;
00374     OpalMediaFormatList vxmlMediaFormats;
00375     OpalVXMLSession     vxmlSession;
00376 };
00377 
00378 
00382 class OpalIVRMediaStream : public OpalRawMediaStream
00383 {
00384     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00385   public:
00390     OpalIVRMediaStream(
00391       OpalIVRConnection & conn,
00392       const OpalMediaFormat & mediaFormat, 
00393       unsigned sessionID,                  
00394       BOOL isSource,                       
00395       PVXMLSession & vxml                  
00396     );
00398 
00406     virtual BOOL Open();
00407 
00411     virtual BOOL IsSynchronous() const;
00413 
00414   protected:
00415     PVXMLSession & vxmlSession;
00416 };
00417 
00418 
00419 #endif // P_EXPAT
00420 
00421 #endif // __OPAL_IVR_H
00422 
00423 
00424 // End of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:33:38 2008 for OPAL by  doxygen 1.5.1