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: 21283 $
00028  * $Author: rjongbloed $
00029  * $Date: 2008-10-11 07:10:58 +0000 (Sat, 11 Oct 2008) $
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/endpoint.h>
00045 
00046 class OpalIVRConnection;
00047 
00048 
00051 class OpalIVREndPoint : public OpalEndPoint
00052 {
00053     PCLASSINFO(OpalIVREndPoint, OpalEndPoint);
00054   public:
00059     OpalIVREndPoint(
00060       OpalManager & manager,  
00061       const char * prefix = "ivr" 
00062     );
00063 
00066     ~OpalIVREndPoint();
00068 
00100     virtual PBoolean 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       const PString & token,  
00129       void * userData,        
00130       const PString & vxml,   
00131       OpalConnection::StringOptions * stringOptions = NULL
00132     );
00133 
00136     virtual PString CreateConnectionToken();
00138 
00145     PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
00146       const PString & token,     
00147       PSafetyMode mode = PSafeReadWrite
00148     ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
00149 
00152     const PString & GetDefaultVXML() const { return defaultVXML; }
00153 
00156     void SetDefaultVXML(
00157       const PString & vxml
00158     );
00159 
00162     void SetDefaultMediaFormats(
00163       const OpalMediaFormatList & formats
00164     );
00165 
00169     virtual PBoolean StartVXML();
00170 
00173     void SetDefaultTextToSpeech(const PString & tts)
00174     { defaultTts = tts; }
00175 
00176     PString GetDefaultTextToSpeech() const
00177     { return defaultTts; }
00178 
00180 
00181   protected:
00182     unsigned            nextTokenNumber;
00183     PString             defaultVXML;
00184     OpalMediaFormatList defaultMediaFormats;
00185     PString             defaultTts;
00186 };
00187 
00188 
00191 class OpalIVRConnection : public OpalConnection
00192 {
00193     PCLASSINFO(OpalIVRConnection, OpalConnection);
00194   public:
00199     OpalIVRConnection(
00200       OpalCall & call,            
00201       OpalIVREndPoint & endpoint, 
00202       const PString & token,      
00203       void * userData,            
00204       const PString & vxml,       
00205       OpalConnection::StringOptions * stringOptions = NULL
00206     );
00207 
00210     ~OpalIVRConnection();
00212 
00223     virtual bool IsNetworkConnection() const { return false; }
00224 
00227     virtual PString GetLocalPartyURL() const;
00228 
00235     virtual PBoolean SetUpConnection();
00236 
00247     virtual PBoolean SetAlerting(
00248       const PString & calleeName,   
00249       PBoolean withMedia                
00250     );
00251 
00256     virtual PBoolean SetConnected();
00257 
00263     void OnEstablished();
00264 
00272     virtual OpalMediaFormatList GetMediaFormats() const;
00273 
00288     virtual OpalMediaStream * CreateMediaStream(
00289       const OpalMediaFormat & mediaFormat, 
00290       unsigned sessionID,                  
00291       PBoolean isSource                        
00292     );
00293 
00301     virtual PBoolean SendUserInputString(
00302       const PString & value                   
00303     );
00305 
00309     virtual PBoolean StartVXML();
00310 
00311     void OnMediaPatchStop(unsigned, bool);
00312 
00313     PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00314     { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00315 
00316     PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00317     { return vxmlSession.SetTextToSpeech(ttsName); }
00318 
00319     PTextToSpeech * GetTextToSpeech()
00320     { return vxmlSession.GetTextToSpeech(); }
00321 
00322 
00323   protected:
00324     OpalIVREndPoint   & endpoint;
00325     PString             vxmlToLoad;
00326     OpalMediaFormatList vxmlMediaFormats;
00327     OpalVXMLSession     vxmlSession;
00328 };
00329 
00330 
00334 class OpalIVRMediaStream : public OpalRawMediaStream
00335 {
00336     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00337   public:
00342     OpalIVRMediaStream(
00343       OpalIVRConnection & conn,
00344       const OpalMediaFormat & mediaFormat, 
00345       unsigned sessionID,                  
00346       PBoolean isSource,                       
00347       PVXMLSession & vxml                  
00348     );
00350 
00358     virtual PBoolean Open();
00359 
00363     virtual PBoolean IsSynchronous() const;
00364 
00365     PBoolean ReadPacket(RTP_DataFrame & packet);
00367 
00368   protected:
00369     OpalConnection & conn;
00370     PVXMLSession & vxmlSession;
00371 };
00372 
00373 
00374 #endif // OPAL_IVR
00375 
00376 #endif // OPAL_OPAL_IVR_H
00377 
00378 
00379 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Feb 23 02:01:36 2009 for OPAL by  doxygen 1.5.1