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
00224 virtual bool IsNetworkConnection() const { return false; }
00225
00232 virtual PBoolean SetUpConnection();
00233
00244 virtual PBoolean SetAlerting(
00245 const PString & calleeName,
00246 PBoolean withMedia
00247 );
00248
00253 virtual PBoolean SetConnected();
00254
00260 void OnEstablished();
00261
00269 virtual OpalMediaFormatList GetMediaFormats() const;
00270
00285 virtual OpalMediaStream * CreateMediaStream(
00286 const OpalMediaFormat & mediaFormat,
00287 unsigned sessionID,
00288 PBoolean isSource
00289 );
00290
00298 virtual PBoolean SendUserInputString(
00299 const PString & value
00300 );
00302
00306 virtual PBoolean StartVXML();
00307
00308 void OnMediaPatchStop(unsigned, bool);
00309
00310 PTextToSpeech * SetTextToSpeech(PTextToSpeech * _tts, PBoolean autoDelete = PFalse)
00311 { return vxmlSession.SetTextToSpeech(_tts, autoDelete); }
00312
00313 PTextToSpeech * SetTextToSpeech(const PString & ttsName)
00314 { return vxmlSession.SetTextToSpeech(ttsName); }
00315
00316 PTextToSpeech * GetTextToSpeech()
00317 { return vxmlSession.GetTextToSpeech(); }
00318
00319
00320 protected:
00321 OpalIVREndPoint & endpoint;
00322 PString vxmlToLoad;
00323 OpalMediaFormatList vxmlMediaFormats;
00324 OpalVXMLSession vxmlSession;
00325 };
00326
00327
00331 class OpalIVRMediaStream : public OpalRawMediaStream
00332 {
00333 PCLASSINFO(OpalIVRMediaStream, OpalRawMediaStream);
00334 public:
00339 OpalIVRMediaStream(
00340 OpalIVRConnection & conn,
00341 const OpalMediaFormat & mediaFormat,
00342 unsigned sessionID,
00343 PBoolean isSource,
00344 PVXMLSession & vxml
00345 );
00347
00355 virtual PBoolean Open();
00356
00360 virtual PBoolean IsSynchronous() const;
00361
00362 PBoolean ReadPacket(RTP_DataFrame & packet);
00364
00365 protected:
00366 OpalConnection & conn;
00367 PVXMLSession & vxmlSession;
00368 };
00369
00370
00371 #endif // OPAL_IVR
00372
00373 #endif // __OPAL_IVR_H
00374
00375
00376