OPAL  Version 3.18.8
ivr.h
Go to the documentation of this file.
1 /*
2  * ivr.h
3  *
4  * Interactive Voice Response support.
5  *
6  * Open Phone Abstraction Library (OPAL)
7  * Formally known as the Open H323 project.
8  *
9  * Copyright (c) 2001 Equivalence Pty. Ltd.
10  *
11  * The contents of this file are subject to the Mozilla Public License
12  * Version 1.0 (the "License"); you may not use this file except in
13  * compliance with the License. You may obtain a copy of the License at
14  * http://www.mozilla.org/MPL/
15  *
16  * Software distributed under the License is distributed on an "AS IS"
17  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18  * the License for the specific language governing rights and limitations
19  * under the License.
20  *
21  * The Original Code is Open Phone Abstraction Library.
22  *
23  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
24  *
25  * Contributor(s): ______________________________________.
26  */
27 
28 #ifndef OPAL_OPAL_IVR_H
29 #define OPAL_OPAL_IVR_H
30 
31 #ifdef P_USE_PRAGMA
32 #pragma interface
33 #endif
34 
35 #include <opal_config.h>
36 
37 #if OPAL_IVR
38 
39 #include <ep/opalvxml.h>
40 #include <ep/localep.h>
41 
42 class OpalIVRConnection;
43 
44 
45 #define OPAL_IVR_PREFIX "ivr"
46 
48 #define OPAL_OPT_IVR_NATIVE_CODEC "IVR-Native-Codec"
49 
50 
54 {
56  public:
62  OpalManager & manager,
63  const char * prefix = OPAL_IVR_PREFIX
64  );
65 
70 
102  virtual PSafePtr<OpalConnection> MakeConnection(
103  OpalCall & call,
104  const PString & party,
105  void * userData = NULL,
106  unsigned int options = 0,
107  OpalConnection::StringOptions * stringOptions = NULL
108 
109  );
110 
120  virtual OpalMediaFormatList GetMediaFormats() const;
121 
124  virtual PStringList GetAvailableStringOptions() const;
126 
133  OpalCall & call,
134  void * userData,
135  const PString & vxml,
136  unsigned int options,
137  OpalConnection::StringOptions * stringOptions = NULL
138  );
140 
147  PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
148  const PString & token,
149  PSafetyMode mode = PSafeReadWrite
150  ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
151 
154  const PString & GetDefaultVXML() const { return m_defaultVXML; }
155 
158  void SetDefaultVXML(
159  const PString & vxml
160  );
161 
169  virtual void OnEndDialog(
170  OpalIVRConnection & connection
171  );
172 
175  void SetDefaultTextToSpeech(const PString & tts)
176  { m_defaultTTS = tts; }
177 
178  PString GetDefaultTextToSpeech() const
179  { return m_defaultTTS; }
180 
183  const PDirectory & GetCacheDir() const { return m_ttsCache.GetDirectory(); }
184 
188  const PDirectory & dir
189  ) { m_ttsCache.SetDirectory(dir); }
190 
191  void SetRecordDirectory(const PDirectory & dir) { m_recordDirectory = dir; }
192  const PDirectory & GetRecordDirectory() const { return m_recordDirectory; }
194 
195  // Allow users to override cache algorithm
196  virtual PVXMLCache & GetTextToSpeechCache() { return m_ttsCache; }
197 
198  protected:
199  PString m_defaultVXML;
200  PString m_defaultTTS;
201  PDECLARE_MUTEX(m_defaultsMutex);
202  PVXMLCache m_ttsCache;
203  PDirectory m_recordDirectory;
204 
205  private:
206  P_REMOVE_VIRTUAL(OpalIVRConnection *, CreateConnection(OpalCall &,const PString &,void *,const PString &,OpalConnection::StringOptions *),0);
207 };
208 
209 
213 {
215  public:
221  OpalCall & call,
223  void * userData,
224  const PString & vxml,
225  unsigned int options,
226  OpalConnection::StringOptions * stringOptions = NULL
227  );
228 
233 
244  virtual bool IsNetworkConnection() const { return false; }
245 
248  virtual PString GetLocalPartyURL() const;
249 
254  virtual void OnStartMediaPatch(
255  OpalMediaPatch & patch
256  );
257 
264  virtual bool OnTransferNotify(
265  const PStringToString & info,
266  const OpalConnection * transferringConnection
268  );
269 
276  virtual bool TransferConnection(
277  const PString & remoteParty
278  );
279 
287  virtual OpalMediaFormatList GetMediaFormats() const;
288 
304  const OpalMediaFormat & mediaFormat,
305  unsigned sessionID,
306  PBoolean isSource
307  );
308 
316  virtual PBoolean SendUserInputString(
317  const PString & value
318  );
320 
324  virtual void OnEndDialog();
325 
326  void SetVXML(const PString & vxml);
327  const PString & GetVXML() const { return m_vxmlScript; }
328  const OpalVXMLSession & GetVXMLSession() const { return m_vxmlSession; }
329  OpalVXMLSession & GetVXMLSession() { return m_vxmlSession; }
330 
331  PTextToSpeech * GetTextToSpeech() const { return m_vxmlSession.GetTextToSpeech(); }
332  PTextToSpeech * SetTextToSpeech(const PString & ttsName) { return m_vxmlSession.SetTextToSpeech(ttsName); }
333  PTextToSpeech * SetTextToSpeech(PTextToSpeech * tts, PBoolean autoDelete = false) { return m_vxmlSession.SetTextToSpeech(tts, autoDelete); }
334 
335  protected:
336  virtual bool StartVXML();
337  virtual bool StartScript();
338 
340  PString m_vxmlScript;
341  OpalVXMLSession m_vxmlSession;
342  atomic<bool> m_vxmlStarted;
343 };
344 
345 
350 {
352  public:
358  OpalIVRConnection & conn,
359  const OpalMediaFormat & mediaFormat,
360  unsigned sessionID,
361  PBoolean isSource,
362  PVXMLSession & vxml
363  );
365 
373  virtual PBoolean Open();
374 
378  virtual PBoolean IsSynchronous() const;
380 
381  protected:
382  virtual void InternalClose();
383 
384  PVXMLSession & m_vxmlSession;
385 };
386 
387 
388 #endif // OPAL_IVR
389 
390 #endif // OPAL_OPAL_IVR_H
391 
392 
393 // End of File ///////////////////////////////////////////////////////////////
virtual bool StartVXML()
const PString & GetDefaultVXML() const
Definition: ivr.h:154
Definition: manager.h:150
void SetCacheDir(const PDirectory &dir)
Definition: ivr.h:187
const OpalVXMLSession & GetVXMLSession() const
Definition: ivr.h:328
PString m_defaultTTS
Definition: ivr.h:200
virtual void OnStartMediaPatch(OpalMediaPatch &patch)
const PString & GetVXML() const
Definition: ivr.h:327
const PDirectory & GetCacheDir() const
Definition: ivr.h:183
virtual OpalMediaStream * CreateMediaStream(const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource)
OpalVXMLSession m_vxmlSession
Definition: ivr.h:341
Definition: localep.h:469
void SetDefaultVXML(const PString &vxml)
PDirectory m_recordDirectory
Definition: ivr.h:203
PVXMLSession & m_vxmlSession
Definition: ivr.h:384
virtual bool TransferConnection(const PString &remoteParty)
virtual void OnEndDialog()
void SetDefaultTextToSpeech(const PString &tts)
Definition: ivr.h:175
virtual PStringList GetAvailableStringOptions() const
virtual void OnEndDialog(OpalIVRConnection &connection)
OpalIVRMediaStream(OpalIVRConnection &conn, const OpalMediaFormat &mediaFormat, unsigned sessionID, PBoolean isSource, PVXMLSession &vxml)
virtual bool StartScript()
virtual PBoolean SendUserInputString(const PString &value)
PVXMLCache m_ttsCache
Definition: ivr.h:202
PDECLARE_MUTEX(m_defaultsMutex)
PSafePtr< OpalConnection > GetConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite) const
virtual PBoolean Open()
Definition: mediafmt.h:112
OpalIVREndPoint(OpalManager &manager, const char *prefix=OPAL_IVR_PREFIX)
Definition: connection.h:530
OpalIVRConnection(OpalCall &call, OpalIVREndPoint &endpoint, void *userData, const PString &vxml, unsigned int options, OpalConnection::StringOptions *stringOptions=NULL)
#define OPAL_IVR_PREFIX
Definition: ivr.h:45
Definition: localep.h:63
virtual PBoolean IsSynchronous() const
Definition: patch.h:56
PSafePtr< OpalIVRConnection > GetIVRConnectionWithLock(const PString &token, PSafetyMode mode=PSafeReadWrite)
Definition: ivr.h:147
Definition: mediafmt.h:806
Definition: call.h:62
Definition: mediastrm.h:598
virtual void InternalClose()
void SetRecordDirectory(const PDirectory &dir)
Definition: ivr.h:191
PString m_vxmlScript
Definition: ivr.h:340
OpalVXMLSession & GetVXMLSession()
Definition: ivr.h:329
virtual OpalMediaFormatList GetMediaFormats() const
const PDirectory & GetRecordDirectory() const
Definition: ivr.h:192
virtual PString GetLocalPartyURL() const
virtual PSafePtr< OpalConnection > MakeConnection(OpalCall &call, const PString &party, void *userData=NULL, unsigned int options=0, OpalConnection::StringOptions *stringOptions=NULL)
Definition: ivr.h:212
PString m_defaultVXML
Definition: ivr.h:199
virtual bool OnTransferNotify(const PStringToString &info, const OpalConnection *transferringConnection)
Definition: ivr.h:349
Definition: mediastrm.h:110
virtual bool IsNetworkConnection() const
Definition: ivr.h:244
virtual OpalIVRConnection * CreateConnection(OpalCall &call, void *userData, const PString &vxml, unsigned int options, OpalConnection::StringOptions *stringOptions=NULL)
atomic< bool > m_vxmlStarted
Definition: ivr.h:342
Definition: connection.h:415
PTextToSpeech * GetTextToSpeech() const
Definition: ivr.h:331
OpalIVREndPoint & endpoint
Definition: ivr.h:339
PTextToSpeech * SetTextToSpeech(const PString &ttsName)
Definition: ivr.h:332
PString GetDefaultTextToSpeech() const
Definition: ivr.h:178
void SetVXML(const PString &vxml)
virtual PVXMLCache & GetTextToSpeechCache()
Definition: ivr.h:196
PTextToSpeech * SetTextToSpeech(PTextToSpeech *tts, PBoolean autoDelete=false)
Definition: ivr.h:333
virtual OpalMediaFormatList GetMediaFormats() const
Definition: ivr.h:53