OPAL  Version 3.12.5
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  * $Revision: 29431 $
28  * $Author: rjongbloed $
29  * $Date: 2013-04-03 21:28:12 -0500 (Wed, 03 Apr 2013) $
30  */
31 
32 #ifndef OPAL_OPAL_IVR_H
33 #define OPAL_OPAL_IVR_H
34 
35 #ifdef P_USE_PRAGMA
36 #pragma interface
37 #endif
38 
39 #include <opal/buildopts.h>
40 
41 #if OPAL_IVR
42 
43 #include <ep/opalvxml.h>
44 #include <ep/localep.h>
45 
46 class OpalIVRConnection;
47 
48 
52 {
54  public:
61  const char * prefix = "ivr"
62  );
63 
68 
100  virtual PSafePtr<OpalConnection> MakeConnection(
101  OpalCall & call,
102  const PString & party,
103  void * userData = NULL,
104  unsigned int options = 0,
105  OpalConnection::StringOptions * stringOptions = NULL
106 
107  );
108 
118  virtual OpalMediaFormatList GetMediaFormats() const;
120 
127  OpalCall & call,
128  void * userData,
129  const PString & vxml,
130  unsigned int options,
131  OpalConnection::StringOptions * stringOptions = NULL
132  );
134 
141  PSafePtr<OpalIVRConnection> GetIVRConnectionWithLock(
142  const PString & token,
143  PSafetyMode mode = PSafeReadWrite
144  ) { return PSafePtrCast<OpalConnection, OpalIVRConnection>(GetConnectionWithLock(token, mode)); }
145 
148  const PString & GetDefaultVXML() const { return m_defaultVXML; }
149 
152  void SetDefaultVXML(
153  const PString & vxml
154  );
155 
159  const OpalMediaFormatList & formats
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;
201  PString m_defaultTTS;
203  PVXMLCache m_ttsCache;
204  PDirectory m_recordDirectory;
205 
206  private:
207  P_REMOVE_VIRTUAL(OpalIVRConnection *, CreateConnection(OpalCall &,const PString &,void *,const PString &,OpalConnection::StringOptions *),0);
208 };
209 
210 
214 {
216  public:
222  OpalCall & call,
224  void * userData,
225  const PString & vxml,
226  unsigned int options,
227  OpalConnection::StringOptions * stringOptions = NULL
228  );
229 
234 
245  virtual bool IsNetworkConnection() const { return false; }
246 
249  virtual PString GetLocalPartyURL() const;
250 
256  void OnEstablished();
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  const PString & GetVXML() const { return m_vxmlScript; }
327  const OpalVXMLSession & GetVXMLSession() const { return m_vxmlSession; }
328  OpalVXMLSession & GetVXMLSession() { return m_vxmlSession; }
329 
330  PTextToSpeech * GetTextToSpeech() const { return m_vxmlSession.GetTextToSpeech(); }
331  PTextToSpeech * SetTextToSpeech(const PString & ttsName) { return m_vxmlSession.SetTextToSpeech(ttsName); }
332  PTextToSpeech * SetTextToSpeech(PTextToSpeech * tts, PBoolean autoDelete = false) { return m_vxmlSession.SetTextToSpeech(tts, autoDelete); }
333 
334  protected:
335  virtual bool StartVXML(const PString & vxml);
336  virtual bool StartScript(const PString & script);
337 
339  PString m_vxmlScript;
341  OpalVXMLSession m_vxmlSession;
342 };
343 
344 
349 {
351  public:
357  OpalIVRConnection & conn,
358  const OpalMediaFormat & mediaFormat,
359  unsigned sessionID,
360  PBoolean isSource,
361  PVXMLSession & vxml
362  );
364 
372  virtual PBoolean Open();
373 
377  virtual PBoolean IsSynchronous() const;
379 
380  protected:
381  virtual void InternalClose();
382 
383  PVXMLSession & m_vxmlSession;
384 };
385 
386 
387 #endif // OPAL_IVR
388 
389 #endif // OPAL_OPAL_IVR_H
390 
391 
392 // End of File ///////////////////////////////////////////////////////////////