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_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 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
00231 virtual PBoolean SetUpConnection();
00232
00243 virtual PBoolean SetAlerting(
00244 const PString & calleeName,
00245 PBoolean withMedia
00246 );
00247
00252 virtual PBoolean SetConnected();
00253
00259 void OnEstablished();
00260
00268 virtual OpalMediaFormatList GetMediaFormats() const;
00269
00284 virtual OpalMediaStream * CreateMediaStream(
00285 const OpalMediaFormat & mediaFormat,
00286 unsigned sessionID,
00287 PBoolean isSource
00288 );
00289
00297 virtual PBoolean SendUserInputString(
00298 const PString & value
00299 );
00301
00305 virtual PBoolean StartVXML();
00306
00307 void OnMediaPatchStop(unsigned, bool);
00308
00309 PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00310 { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00311
00312 PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00313 { return vxmlSession.SetTextToSpeech(ttsName); }
00314
00315 PTextToSpeech * GetTextToSpeech()
00316 { return vxmlSession.GetTextToSpeech(); }
00317
00318
00319 protected:
00320 OpalIVREndPoint & endpoint;
00321 PString vxmlToLoad;
00322 OpalMediaFormatList vxmlMediaFormats;
00323 OpalVXMLSession vxmlSession;
00324 };
00325
00326
00330 class OpalIVRMediaStream : public OpalRawMediaStream
00331 {
00332 PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00333 public:
00338 OpalIVRMediaStream(
00339 OpalIVRConnection & conn,
00340 const OpalMediaFormat & mediaFormat,
00341 unsigned sessionID,
00342 PBoolean isSource,
00343 PVXMLSession & vxml
00344 );
00346
00354 virtual PBoolean Open();
00355
00359 virtual PBoolean IsSynchronous() const;
00360
00361 PBoolean ReadPacket(RTP_DataFrame & packet);
00363
00364 protected:
00365 OpalConnection & conn;
00366 PVXMLSession & vxmlSession;
00367 };
00368
00369
00370 #endif // OPAL_IVR
00371
00372 #endif // __OPAL_IVR_H
00373
00374
00375