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: 23008 $
00028  * $Author: rjongbloed $
00029  * $Date: 2009-06-29 04:24:23 +0000 (Mon, 29 Jun 2009) $
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 
00165     virtual PBoolean StartVXML();
00166 
00169     void SetDefaultTextToSpeech(const PString & tts)
00170     { defaultTts = tts; }
00171 
00172     PString GetDefaultTextToSpeech() const
00173     { return defaultTts; }
00174 
00176 
00177   protected:
00178     PString             defaultVXML;
00179     OpalMediaFormatList defaultMediaFormats;
00180     PString             defaultTts;
00181 
00182   private:
00183     P_REMOVE_VIRTUAL(OpalIVRConnection *, CreateConnection(OpalCall &,const PString &,void *,const PString &,OpalConnection::StringOptions *),0);
00184 };
00185 
00186 
00189 class OpalIVRConnection : public OpalLocalConnection
00190 {
00191     PCLASSINFO(OpalIVRConnection, OpalLocalConnection);
00192   public:
00197     OpalIVRConnection(
00198       OpalCall & call,            
00199       OpalIVREndPoint & endpoint, 
00200       void * userData,            
00201       const PString & vxml,       
00202       unsigned int options,
00203       OpalConnection::StringOptions * stringOptions = NULL
00204     );
00205 
00208     ~OpalIVRConnection();
00210 
00221     virtual bool IsNetworkConnection() const { return false; }
00222 
00225     virtual PString GetLocalPartyURL() const;
00226 
00232     void OnEstablished();
00233 
00241     virtual OpalMediaFormatList GetMediaFormats() const;
00242 
00257     virtual OpalMediaStream * CreateMediaStream(
00258       const OpalMediaFormat & mediaFormat, 
00259       unsigned sessionID,                  
00260       PBoolean isSource                        
00261     );
00262 
00270     virtual PBoolean SendUserInputString(
00271       const PString & value                   
00272     );
00274 
00278     virtual PBoolean StartVXML();
00279 
00280     void OnMediaPatchStop(unsigned, bool);
00281 
00282     PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00283     { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00284 
00285     PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00286     { return vxmlSession.SetTextToSpeech(ttsName); }
00287 
00288     PTextToSpeech * GetTextToSpeech()
00289     { return vxmlSession.GetTextToSpeech(); }
00290 
00291 
00292   protected:
00293     OpalIVREndPoint   & endpoint;
00294     PString             vxmlToLoad;
00295     OpalMediaFormatList vxmlMediaFormats;
00296     OpalVXMLSession     vxmlSession;
00297 };
00298 
00299 
00303 class OpalIVRMediaStream : public OpalRawMediaStream
00304 {
00305     PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00306   public:
00311     OpalIVRMediaStream(
00312       OpalIVRConnection & conn,
00313       const OpalMediaFormat & mediaFormat, 
00314       unsigned sessionID,                  
00315       PBoolean isSource,                       
00316       PVXMLSession & vxml                  
00317     );
00319 
00327     virtual PBoolean Open();
00328 
00332     virtual PBoolean IsSynchronous() const;
00334 
00335   protected:
00336     OpalConnection & conn;
00337     PVXMLSession & vxmlSession;
00338 };
00339 
00340 
00341 #endif // OPAL_IVR
00342 
00343 #endif // OPAL_OPAL_IVR_H
00344 
00345 
00346 // End of File ///////////////////////////////////////////////////////////////

Generated on Mon Aug 3 20:50:21 2009 for OPAL by  doxygen 1.5.1