00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
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;
00365 
00366   protected:
00367     OpalConnection & conn;
00368     PVXMLSession & vxmlSession;
00369 };
00370 
00371 
00372 #endif // OPAL_IVR
00373 
00374 #endif // OPAL_OPAL_IVR_H
00375 
00376 
00377