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
00047 class OpalIVRConnection;
00048
00049
00052 class OpalIVREndPoint : public OpalEndPoint
00053 {
00054 PCLASSINFO(OpalIVREndPoint, OpalEndPoint);
00055 public:
00060 OpalIVREndPoint(
00061 OpalManager & manager,
00062 const char * prefix = "ivr"
00063 );
00064
00067 ~OpalIVREndPoint();
00069
00101 virtual PBoolean MakeConnection(
00102 OpalCall & call,
00103 const PString & party,
00104 void * userData = NULL,
00105 unsigned int options = 0,
00106 OpalConnection::StringOptions * stringOptions = NULL
00107
00108 );
00109
00119 virtual OpalMediaFormatList GetMediaFormats() const;
00121
00127 virtual OpalIVRConnection * CreateConnection(
00128 OpalCall & call,
00129 const PString & token,
00130 void * userData,
00131 const PString & vxml,
00132 OpalConnection::StringOptions * stringOptions = NULL
00133 );
00134
00137 virtual PString CreateConnectionToken();
00139
00146 PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
00147 const PString & token,
00148 PSafetyMode mode = PSafeReadWrite
00149 ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
00150
00153 const PString & GetDefaultVXML() const { return defaultVXML; }
00154
00157 void SetDefaultVXML(
00158 const PString & vxml
00159 );
00160
00163 void SetDefaultMediaFormats(
00164 const OpalMediaFormatList & formats
00165 );
00166
00170 virtual PBoolean StartVXML();
00171
00174 void SetDefaultTextToSpeech(const PString & tts)
00175 { defaultTts = tts; }
00176
00177 PString GetDefaultTextToSpeech() const
00178 { return defaultTts; }
00179
00181
00182 protected:
00183 unsigned nextTokenNumber;
00184 PString defaultVXML;
00185 OpalMediaFormatList defaultMediaFormats;
00186 PString defaultTts;
00187 };
00188
00189
00192 class OpalIVRConnection : public OpalConnection
00193 {
00194 PCLASSINFO(OpalIVRConnection, OpalConnection);
00195 public:
00200 OpalIVRConnection(
00201 OpalCall & call,
00202 OpalIVREndPoint & endpoint,
00203 const PString & token,
00204 void * userData,
00205 const PString & vxml,
00206 OpalConnection::StringOptions * stringOptions = NULL
00207 );
00208
00211 ~OpalIVRConnection();
00213
00222 virtual PBoolean SetUpConnection();
00223
00234 virtual PBoolean SetAlerting(
00235 const PString & calleeName,
00236 PBoolean withMedia
00237 );
00238
00243 virtual PBoolean SetConnected();
00244
00250 void OnEstablished();
00251
00259 virtual OpalMediaFormatList GetMediaFormats() const;
00260
00275 virtual OpalMediaStream * CreateMediaStream(
00276 const OpalMediaFormat & mediaFormat,
00277 unsigned sessionID,
00278 PBoolean isSource
00279 );
00280
00288 virtual PBoolean SendUserInputString(
00289 const PString & value
00290 );
00292
00296 virtual PBoolean StartVXML();
00297
00298 void OnMediaPatchStop(unsigned, bool);
00299
00300 PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00301 { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00302
00303 PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00304 { return vxmlSession.SetTextToSpeech(ttsName); }
00305
00306 PTextToSpeech * GetTextToSpeech()
00307 { return vxmlSession.GetTextToSpeech(); }
00308
00309
00310 protected:
00311 OpalIVREndPoint & endpoint;
00312 PString vxmlToLoad;
00313 OpalMediaFormatList vxmlMediaFormats;
00314 OpalVXMLSession vxmlSession;
00315 };
00316
00317
00321 class OpalIVRMediaStream : public OpalRawMediaStream
00322 {
00323 PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00324 public:
00329 OpalIVRMediaStream(
00330 OpalIVRConnection & conn,
00331 const OpalMediaFormat & mediaFormat,
00332 unsigned sessionID,
00333 PBoolean isSource,
00334 PVXMLSession & vxml
00335 );
00337
00345 virtual PBoolean Open();
00346
00350 virtual PBoolean IsSynchronous() const;
00351
00352 PBoolean ReadPacket(RTP_DataFrame & packet);
00354
00355 protected:
00356 OpalConnection & conn;
00357 PVXMLSession & vxmlSession;
00358 };
00359
00360
00361 #endif // OPAL_IVR
00362
00363 #endif // __OPAL_IVR_H
00364
00365
00366