4 * VXML engine for pwlib library
6 * Copyright (C) 2002 Equivalence Pty. Ltd.
8 * The contents of this file are subject to the Mozilla Public License
9 * Version 1.0 (the "License"); you may not use this file except in
10 * compliance with the License. You may obtain a copy of the License at
11 * http://www.mozilla.org/MPL/
13 * Software distributed under the License is distributed on an "AS IS"
14 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15 * the License for the specific language governing rights and limitations
18 * The Original Code is Portable Windows Library.
20 * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
22 * Contributor(s): ______________________________________.
25 * Revision 1.42 2005/10/30 23:25:51 csoutheren
27 * Removed throw() declarations (PWLib does not do exceptions)
28 * Removed duplicate destructor declarations and definitions
30 * Revision 1.41 2005/10/30 19:41:53 dominance
31 * fixed most of the warnings occuring during compilation
33 * Revision 1.40 2005/05/12 13:40:45 csoutheren
34 * Fixed locking problems with currentPLayItem optimisation
36 * Revision 1.39 2005/05/12 05:28:35 csoutheren
37 * Optimised read loop and fixed problems with playing repeated continuous tones
39 * Revision 1.38 2005/04/21 05:27:58 csoutheren
40 * Changed default value for OnFrame
42 * Revision 1.37 2005/03/19 02:52:53 csoutheren
43 * Fix warnings from gcc 4.1-20050313 shapshot
45 * Revision 1.36 2004/12/08 00:52:06 csoutheren
46 * Added GetSampleFrequency function
48 * Revision 1.35 2004/11/11 07:34:50 csoutheren
49 * Added #include <ptlib.h>
51 * Revision 1.34 2004/08/09 11:10:34 csoutheren
52 * Changed SetTextToSpeech to return ptr to new engine
54 * Revision 1.33 2004/07/26 00:40:41 csoutheren
55 * Fixed thread starvation problem under Linux by splitting channelMutex
56 * into seperate read and write mutexes
58 * Revision 1.32 2004/07/23 00:59:26 csoutheren
59 * Check in latest changes
61 * Revision 1.31 2004/07/15 03:12:41 csoutheren
62 * Migrated changes from crs_vxnml_devel branch into main trunk
64 * Revision 1.30.2.7 2004/07/13 08:13:05 csoutheren
65 * Lots of implementation of factory-based PWAVFile
67 * Revision 1.30.2.6 2004/07/12 08:30:16 csoutheren
68 * More fixes for abstract factory implementation of PWAVFile
70 * Revision 1.30.2.5 2004/07/08 04:58:11 csoutheren
71 * Exposed VXML playable classes to allow descendants
73 * Revision 1.30.2.4 2004/07/07 07:07:41 csoutheren
74 * Changed PWAVFile to use abstract factories (extensively)
75 * Removed redundant blocking/unblocking when using G.723.1
76 * More support for call transfer
78 * Revision 1.30.2.3 2004/07/06 01:38:57 csoutheren
79 * Changed PVXMLChannel to use PDelayChannel
80 * Fixed bug where played files were deleted after playing
82 * Revision 1.30.2.2 2004/07/02 07:22:37 csoutheren
83 * Updated for latest factory changes
85 * Revision 1.30.2.1 2004/06/20 11:18:03 csoutheren
86 * Rewrite of resource cacheing to cache text-to-speech output
88 * Revision 1.30 2004/06/19 07:21:08 csoutheren
89 * Change TTS engine registration to use abstract factory code
90 * Started disentanglement of PVXMLChannel from PVXMLSession
91 * Fixed problem with VXML session closing if played data file is not exact frame size multiple
92 * Allowed PVXMLSession to be used without a VXML script
93 * Changed PVXMLChannel to handle "file:" URLs
94 * Numerous other small improvements and optimisations
96 * Revision 1.29 2004/06/02 08:29:28 csoutheren
97 * Added new code from Andreas Sikkema to implement various VXML features
99 * Revision 1.28 2004/06/02 06:17:21 csoutheren
100 * Removed unnecessary buffer copying and removed potential busy loop
102 * Revision 1.27 2004/03/23 04:48:42 csoutheren
103 * Improved ability to start VXML scripts as needed
105 * Revision 1.26 2003/04/23 11:55:13 craigs
106 * Added ability to record audio
108 * Revision 1.25 2003/04/08 05:09:41 craigs
109 * Added ability to use commands as an audio source
111 * Revision 1.24 2003/03/18 00:45:36 robertj
112 * Fixed missing return in previous patch.
114 * Revision 1.23 2003/03/18 00:40:28 robertj
115 * Added back the IsMediaPCM() function for backward compatibility.
117 * Revision 1.22 2003/03/17 08:02:54 robertj
118 * Combined to the separate incoming and outgoing substream classes into
119 * a single class to make it easier to produce codec aware descendents.
120 * Added G.729 substream class.
122 * Revision 1.21 2002/11/08 03:38:34 craigs
123 * Fixed problem with G.723.1 files
125 * Revision 1.20 2002/09/18 06:37:13 robertj
126 * Added functions to load vxml directly, via file or URL. Old function
127 * intelligently picks which one to use.
129 * Revision 1.19 2002/09/16 01:08:59 robertj
130 * Added #define so can select if #pragma interface/implementation is used on
131 * platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
133 * Revision 1.18 2002/09/03 04:11:14 craigs
136 * Revision 1.17 2002/08/30 05:06:13 craigs
137 * Added changes for PVXMLGrammar
139 * Revision 1.16 2002/08/28 08:04:31 craigs
140 * Reorganised VXMLSession class as per contributed code
142 * Revision 1.15 2002/08/28 05:10:27 craigs
143 * Added ability to load resources via URI
146 * Revision 1.14 2002/08/27 02:19:13 craigs
147 * Added <break> command in prompt blocks
148 * Fixed potential deadlock
150 * Revision 1.13 2002/08/15 04:11:16 robertj
151 * Fixed shutdown problems with closing vxml session, leaks a thread.
152 * Fixed potential problems with indirect channel Close() function.
154 * Revision 1.12 2002/08/08 01:03:19 craigs
155 * Added function to re-enable automatic call clearing on script end
157 * Revision 1.11 2002/08/06 07:44:56 craigs
158 * Added lots of stuff from OpalVXML
160 * Revision 1.10 2002/07/29 15:08:34 craigs
161 * Added autodelete option to PlayFile
163 * Revision 1.9 2002/07/29 15:03:58 craigs
164 * Added access to queue functions
165 * Added autodelete option to AddFile
167 * Revision 1.8 2002/07/29 14:15:47 craigs
168 * Added asynchronous VXML execution
170 * Revision 1.7 2002/07/17 08:34:12 craigs
171 * Fixed deadlock problems
173 * Revision 1.6 2002/07/17 06:08:43 craigs
174 * Added additional "sayas" classes
176 * Revision 1.5 2002/07/10 13:14:55 craigs
177 * Moved some VXML classes from Opal back into PTCLib
179 * Revision 1.4 2002/07/05 06:27:26 craigs
180 * Removed unused member variables
181 * Added OnEmptyAction callback
183 * Revision 1.3 2002/07/02 06:23:51 craigs
184 * Added recording functions
186 * Revision 1.2 2002/06/27 05:39:18 craigs
187 * Fixed Linux warning
189 * Revision 1.1 2002/06/27 05:28:17 craigs
202 #include <ptlib/pipechan.h>
204 #include <ptclib/pxml.h>
205 #include <ptclib/delaychan.h>
206 #include <ptclib/pwavfile.h>
207 #include <ptclib/ptts.h>
208 #include <ptclib/url.h>
217 class PVXMLTransferOptions
;
218 class PVXMLTransferResult
;
220 // these are the same strings as the Opal equivalents, but as this is PWLib, we can't use Opal contants
221 #define VXML_PCM16 "PCM-16"
222 #define VXML_G7231 "G.723.1"
223 #define VXML_G729 "G.729"
225 #define PVXML_HAS_FACTORY 1
227 class PVXMLGrammar
: public PObject
229 PCLASSINFO(PVXMLGrammar
, PObject
);
231 PVXMLGrammar(PXMLElement
* field
);
232 virtual BOOL
OnUserInput(const char /*ch*/) { return TRUE
; }
233 virtual void Stop() { }
235 PString
GetValue() const { return value
; }
236 PXMLElement
* GetField() { return field
; }
239 FILLED
, // got something that matched the grammar
240 NOINPUT
, // timeout or still waiting to match
241 NOMATCH
, // recognized something but didn't match the grammar
242 HELP
}; // help keyword
244 GrammarState
GetState() const { return state
; }
253 //////////////////////////////////////////////////////////////////
255 class PVXMLMenuGrammar
: public PVXMLGrammar
257 PCLASSINFO(PVXMLMenuGrammar
, PVXMLGrammar
);
259 PVXMLMenuGrammar(PXMLElement
* field
);
263 //////////////////////////////////////////////////////////////////
265 class PVXMLDigitsGrammar
: public PVXMLGrammar
267 PCLASSINFO(PVXMLDigitsGrammar
, PVXMLGrammar
);
269 PVXMLDigitsGrammar(PXMLElement
* field
, PINDEX minDigits
, PINDEX maxDigits
, PString terminators
);
270 BOOL
OnUserInput(const char ch
);
280 //////////////////////////////////////////////////////////////////
282 class PVXMLCache
: public PMutex
285 PVXMLCache(const PDirectory
& _directory
);
287 PFilePath
CreateFilename(const PString
& prefix
, const PString
& key
, const PString
& fileType
);
289 void Put(const PString
& prefix
,
291 const PString
& fileType
,
292 const PString
& contentType
,
293 const PFilePath
& fn
,
296 BOOL
Get(const PString
& prefix
,
298 const PString
& fileType
,
299 PString
& contentType
,
302 PFilePath
GetCacheDir() const
303 { return directory
; }
305 PFilePath
GetRandomFilename(const PString
& prefix
, const PString
& fileType
);
307 static PVXMLCache
& GetResourceCache();
310 PDirectory directory
;
313 //////////////////////////////////////////////////////////////////
317 class PVXMLChannelInterface
{
319 virtual ~PVXMLChannelInterface() { }
320 virtual PWAVFile
* CreateWAVFile(const PFilePath
& fn
, PFile::OpenMode mode
, int opts
, unsigned fmt
) = 0;
321 virtual void RecordEnd() = 0;
322 virtual void OnEndRecording(const PString
& channelName
) = 0;
323 virtual void Trigger() = 0;
326 //////////////////////////////////////////////////////////////////
328 class PVXMLSession
: public PIndirectChannel
, public PVXMLChannelInterface
330 PCLASSINFO(PVXMLSession
, PIndirectChannel
);
332 PVXMLSession(PTextToSpeech
* tts
= NULL
, BOOL autoDelete
= FALSE
);
333 virtual ~PVXMLSession();
335 void SetFinishWhenEmpty(BOOL v
)
336 { finishWhenEmpty
= v
; }
339 PTextToSpeech
* SetTextToSpeech(PTextToSpeech
* _tts
, BOOL autoDelete
= FALSE
);
340 PTextToSpeech
* SetTextToSpeech(const PString
& ttsName
);
341 PTextToSpeech
* GetTextToSpeech() { return textToSpeech
; }
343 virtual BOOL
Load(const PString
& source
);
344 virtual BOOL
LoadFile(const PFilePath
& file
);
345 virtual BOOL
LoadURL(const PURL
& url
);
346 virtual BOOL
LoadVXML(const PString
& xml
);
347 virtual BOOL
IsLoaded() const { return loaded
; }
349 virtual BOOL
Open(BOOL isPCM
); // For backward compatibility FALSE=G.723.1
350 virtual BOOL
Open(const PString
& mediaFormat
);
351 virtual BOOL
Close();
355 PVXMLChannel
* GetAndLockVXMLChannel()
358 if (vxmlChannel
!= NULL
)
360 sessionMutex
.Signal();
363 void UnLockVXMLChannel() { sessionMutex
.Signal(); }
364 PMutex
& GetSessionMutex() { return sessionMutex
; }
366 BOOL
LoadGrammar(PVXMLGrammar
* grammar
);
368 virtual BOOL
PlayText(const PString
& text
, PTextToSpeech::TextType type
= PTextToSpeech::Default
, PINDEX repeat
= 1, PINDEX delay
= 0);
369 BOOL
ConvertTextToFilenameList(const PString
& _text
, PTextToSpeech::TextType type
, PStringArray
& list
, BOOL useCacheing
);
371 virtual BOOL
PlayFile(const PString
& fn
, PINDEX repeat
= 1, PINDEX delay
= 0, BOOL autoDelete
= FALSE
);
372 virtual BOOL
PlayData(const PBYTEArray
& data
, PINDEX repeat
= 1, PINDEX delay
= 0);
373 virtual BOOL
PlayCommand(const PString
& data
, PINDEX repeat
= 1, PINDEX delay
= 0);
374 virtual BOOL
PlayResource(const PURL
& url
, PINDEX repeat
= 1, PINDEX delay
= 0);
376 //virtual BOOL PlayMedia(const PURL & url, PINDEX repeat = 1, PINDEX delay = 0);
377 virtual BOOL
PlaySilence(PINDEX msecs
= 0);
378 virtual BOOL
PlaySilence(const PTimeInterval
& timeout
);
380 virtual void SetPause(BOOL pause
);
381 virtual void GetBeepData(PBYTEArray
& data
, unsigned ms
);
383 virtual BOOL
StartRecording(const PFilePath
& fn
, BOOL recordDTMFTerm
, const PTimeInterval
& recordMaxTime
, const PTimeInterval
& recordFinalSilence
);
384 virtual BOOL
EndRecording();
385 virtual BOOL
IsPlaying() const;
386 virtual BOOL
IsRecording() const;
388 virtual BOOL
OnUserInput(const PString
& str
);
390 PString
GetXMLError() const;
392 virtual void OnEndSession() { }
394 virtual PString
GetVar(const PString
& str
) const;
395 virtual void SetVar(const PString
& ostr
, const PString
& val
);
396 virtual PString
PVXMLSession::EvaluateExpr(const PString
& oexpr
);
398 virtual BOOL
RetreiveResource(const PURL
& url
, PString
& contentType
, PFilePath
& fn
, BOOL useCache
= TRUE
);
400 PDECLARE_NOTIFIER(PThread
, PVXMLSession
, VXMLExecute
);
402 virtual BOOL
DoTransfer(const PVXMLTransferOptions
&) { return TRUE
; }
403 virtual void OnTransfer(const PVXMLTransferResult
&);
405 void SetCallingToken( PString
& token
) { callingCallToken
= token
; }
407 PXMLElement
* FindHandler(const PString
& event
);
409 // overrides from VXMLChannelInterface
410 PWAVFile
* CreateWAVFile(const PFilePath
& fn
, PFile::OpenMode mode
, int opts
, unsigned fmt
);
411 void OnEndRecording(const PString
& channelName
);
418 void AllowClearCall();
419 void ProcessUserInput();
421 void ProcessGrammar();
423 BOOL
TraverseAudio();
425 BOOL
TraverseGrammar();
426 BOOL
TraverseRecord();
431 BOOL
TraverseSubmit();
433 BOOL
TraverseChoice(const PString
& grammarResult
);
434 BOOL
TraverseProperty();
436 void SayAs(const PString
& className
, const PString
& text
);
437 static PTimeInterval
StringToTime(const PString
& str
);
439 PURL
NormaliseResourceName(const PString
& src
);
441 PXMLElement
* FindForm(const PString
& id
);
443 virtual BOOL
TraverseTransfer();
445 //friend class PVXMLChannel;
447 PSyncPoint waitForEvent
;
453 PVXMLGrammar
* activeGrammar
;
454 BOOL listening
; // TRUE if waiting for recognition events
455 int timeout
; // timeout in msecs for the current recognition
457 PStringToString sessionVars
;
458 PStringToString documentVars
;
460 PMutex userInputMutex
;
461 std::queue
<char> userInputQueue
;
466 PTimeInterval recordMaxTime
;
467 PTimeInterval recordFinalSilence
;
468 PSyncPoint recordSync
;
471 BOOL finishWhenEmpty
;
476 PThread
* vxmlThread
;
481 PVXMLChannel
* vxmlChannel
;
483 PTextToSpeech
* textToSpeech
;
484 BOOL autoDeleteTextToSpeech
;
486 PXMLElement
* currentForm
;
487 PXMLElement
* currentField
;
488 PXMLObject
* currentNode
;
491 void ExecuteDialog();
493 PString callingCallToken
;
494 PSyncPoint transferSync
;
495 PSyncPoint answerSync
;
496 PString grammarResult
;
502 //////////////////////////////////////////////////////////////////
504 class PVXMLRecordable
: public PObject
506 PCLASSINFO(PVXMLRecordable
, PObject
);
509 { consecutiveSilence
= 0; finalSilence
= 3000; maxDuration
= 30000; }
511 virtual BOOL
Open(const PString
& _arg
) = 0;
513 virtual void Record(PVXMLChannel
& incomingChannel
) = 0;
515 virtual void OnStart() { }
517 virtual BOOL
OnFrame(BOOL
/*isSilence*/) { return FALSE
; }
519 virtual void OnStop() { }
521 void SetFinalSilence(unsigned v
)
522 { finalSilence
= v
; }
524 unsigned GetFinalSilence()
525 { return finalSilence
; }
527 void SetMaxDuration(unsigned v
)
530 unsigned GetMaxDuration()
531 { return maxDuration
; }
536 unsigned finalSilence
;
537 unsigned maxDuration
;
538 unsigned consecutiveSilence
;
541 //////////////////////////////////////////////////////////////////
543 class PVXMLPlayable
: public PObject
545 PCLASSINFO(PVXMLPlayable
, PObject
);
548 { repeat
= 1; delay
= 0; sampleFrequency
= 8000; autoDelete
= FALSE
; delayDone
= FALSE
; }
550 virtual BOOL
Open(PVXMLChannel
& /*chan*/, PINDEX _delay
, PINDEX _repeat
, BOOL _autoDelete
)
551 { delay
= _delay
; repeat
= _repeat
; autoDelete
= _autoDelete
; return TRUE
; }
553 virtual BOOL
Open(PVXMLChannel
& chan
, const PString
& _arg
, PINDEX _delay
, PINDEX _repeat
, BOOL v
)
554 { arg
= _arg
; return Open(chan
, _delay
, _repeat
, v
); }
556 virtual void Play(PVXMLChannel
& outgoingChannel
) = 0;
558 virtual void OnRepeat(PVXMLChannel
& /*outgoingChannel*/)
561 virtual void OnStart() { }
563 virtual void OnStop() { }
565 virtual void SetRepeat(PINDEX v
)
568 virtual PINDEX
GetRepeat() const
571 virtual PINDEX
GetDelay() const
574 void SetFormat(const PString
& _fmt
)
577 void SetSampleFrequency(unsigned _rate
)
578 { sampleFrequency
= _rate
; }
580 virtual BOOL
ReadFrame(PVXMLChannel
& channel
, void * buf
, PINDEX len
);
582 virtual BOOL
Rewind(PChannel
*)
585 friend class PVXMLChannel
;
592 unsigned sampleFrequency
;
594 BOOL delayDone
; // very tacky flag used to indicate when the post-play delay has been done
597 //////////////////////////////////////////////////////////////////
599 class PVXMLPlayableURL
: public PVXMLPlayable
601 PCLASSINFO(PVXMLPlayableURL
, PVXMLPlayable
);
603 BOOL
Open(PVXMLChannel
& chan
, const PString
& _url
, PINDEX _delay
, PINDEX _repeat
, BOOL v
);
604 void Play(PVXMLChannel
& outgoingChannel
);
609 //////////////////////////////////////////////////////////////////
611 class PVXMLPlayableData
: public PVXMLPlayable
613 PCLASSINFO(PVXMLPlayableData
, PVXMLPlayable
);
615 BOOL
Open(PVXMLChannel
& chan
, const PString
& /*_fn*/, PINDEX _delay
, PINDEX _repeat
, BOOL v
);
616 void SetData(const PBYTEArray
& _data
);
617 void Play(PVXMLChannel
& outgoingChannel
);
618 BOOL
Rewind(PChannel
* chan
);
623 //////////////////////////////////////////////////////////////////
625 class PVXMLPlayableCommand
: public PVXMLPlayable
627 PCLASSINFO(PVXMLPlayableCommand
, PVXMLPlayable
);
629 PVXMLPlayableCommand();
630 void Play(PVXMLChannel
& outgoingChannel
);
634 PPipeChannel
* pipeCmd
;
637 //////////////////////////////////////////////////////////////////
639 class PVXMLPlayableFilename
: public PVXMLPlayable
641 PCLASSINFO(PVXMLPlayableFilename
, PVXMLPlayable
);
643 BOOL
Open(PVXMLChannel
& chan
, const PString
& _fn
, PINDEX _delay
, PINDEX _repeat
, BOOL _autoDelete
);
644 void Play(PVXMLChannel
& outgoingChannel
);
646 virtual BOOL
Rewind(PChannel
* chan
);
651 //////////////////////////////////////////////////////////////////
653 class PVXMLPlayableFilenameList
: public PVXMLPlayable
655 PCLASSINFO(PVXMLPlayableFilenameList
, PVXMLPlayable
);
657 BOOL
Open(PVXMLChannel
& chan
, const PStringArray
& _filenames
, PINDEX _delay
, PINDEX _repeat
, BOOL _autoDelete
);
658 void Play(PVXMLChannel
& outgoingChannel
)
659 { OnRepeat(outgoingChannel
); }
660 void OnRepeat(PVXMLChannel
& outgoingChannel
);
664 PStringArray filenames
;
667 //////////////////////////////////////////////////////////////////
669 class PVXMLRecordableFilename
: public PVXMLRecordable
671 PCLASSINFO(PVXMLRecordableFilename
, PVXMLRecordable
);
673 BOOL
Open(const PString
& _arg
);
674 void Record(PVXMLChannel
& incomingChannel
);
675 BOOL
OnFrame(BOOL isSilence
);
681 //////////////////////////////////////////////////////////////////
683 PQUEUE(PVXMLQueue
, PVXMLPlayable
);
685 //////////////////////////////////////////////////////////////////
687 class PVXMLChannel
: public PDelayChannel
689 PCLASSINFO(PVXMLChannel
, PDelayChannel
);
691 PVXMLChannel(unsigned frameDelay
, PINDEX frameSize
);
694 virtual BOOL
Open(PVXMLChannelInterface
* _vxml
);
696 // overrides from PIndirectChannel
697 virtual BOOL
IsOpen() const;
698 virtual BOOL
Close();
699 virtual BOOL
Read(void * buffer
, PINDEX amount
);
700 virtual BOOL
Write(const void * buf
, PINDEX len
);
703 virtual PWAVFile
* CreateWAVFile(const PFilePath
& fn
, BOOL recording
= FALSE
);
705 const PString
& GetMediaFormat() const { return mediaFormat
; }
706 BOOL
IsMediaPCM() const { return mediaFormat
== "PCM-16"; }
707 virtual PString
AdjustWavFilename(const PString
& fn
);
709 // Incoming channel functions
710 virtual BOOL
WriteFrame(const void * buf
, PINDEX len
) = 0;
711 virtual BOOL
IsSilenceFrame(const void * buf
, PINDEX len
) const = 0;
713 virtual BOOL
QueueRecordable(PVXMLRecordable
* newItem
);
715 BOOL
StartRecording(const PFilePath
& fn
, unsigned finalSilence
= 3000, unsigned maxDuration
= 30000);
717 BOOL
IsRecording() const { return recording
; }
719 // Outgoing channel functions
720 virtual BOOL
ReadFrame(void * buffer
, PINDEX amount
) = 0;
721 virtual PINDEX
CreateSilenceFrame(void * buffer
, PINDEX amount
) = 0;
722 virtual void GetBeepData(PBYTEArray
&, unsigned) { }
724 virtual BOOL
QueueResource(const PURL
& url
, PINDEX repeat
= 1, PINDEX delay
= 0);
726 virtual BOOL
QueuePlayable(const PString
& type
, const PString
& str
, PINDEX repeat
= 1, PINDEX delay
= 0, BOOL autoDelete
= FALSE
);
727 virtual BOOL
QueuePlayable(PVXMLPlayable
* newItem
);
728 virtual BOOL
QueueData(const PBYTEArray
& data
, PINDEX repeat
= 1, PINDEX delay
= 0);
730 virtual BOOL
QueueFile(const PString
& fn
, PINDEX repeat
= 1, PINDEX delay
= 0, BOOL autoDelete
= FALSE
)
731 { return QueuePlayable("File", fn
, repeat
, delay
, autoDelete
); }
733 virtual BOOL
QueueCommand(const PString
& cmd
, PINDEX repeat
= 1, PINDEX delay
= 0)
734 { return QueuePlayable("Command", cmd
, repeat
, delay
, TRUE
); }
736 virtual void FlushQueue();
737 virtual BOOL
IsPlaying() const { return (playQueue
.GetSize() > 0) || playing
; }
739 void SetPause(BOOL _pause
) { paused
= _pause
; }
741 void SetName(const PString
& name
) { channelName
= name
; }
743 unsigned GetSampleFrequency() const
744 { return sampleFrequency
; }
747 PVXMLChannelInterface
* vxmlInterface
;
749 unsigned sampleFrequency
;
751 PString wavFilePrefix
;
753 PMutex channelWriteMutex
;
754 PMutex channelReadMutex
;
757 // Incoming audio variables
759 PVXMLRecordable
* recordable
;
760 unsigned finalSilence
;
763 // Outgoing audio variables
766 PVXMLQueue playQueue
;
767 PVXMLPlayable
* currentPlayItem
;
774 // "channelname" (which is the name of the <record> tag) so
775 // results can be saved in vxml session variable
780 //////////////////////////////////////////////////////////////////
782 class PVXMLTransferOptions
: public PObject
784 PCLASSINFO(PVXMLTransferOptions
, PObject
);
786 PVXMLTransferOptions() { }
788 void SetCallingToken(const PString
& calling
) { callingToken
= calling
; }
789 PString
GetCallingToken() const { return callingToken
; }
791 void SetCalledToken(const PString
& called
) { calledToken
= called
; }
792 PString
GetCalledToken( ) const { return calledToken
; }
794 void SetSourceDNR(const PString
& src
) { source
= src
; }
795 PString
GetSourceDNR() const { return source
; }
797 void SetDestinationDNR(const PString
& dest
) { destination
= dest
; }
798 PString
GetDestinationDNR() const { return destination
; }
800 void SetTimeout(unsigned int time
) { timeout
= time
; }
801 unsigned int GetTimeout() const { return timeout
; }
803 void SetBridge(BOOL brdg
) { bridge
= brdg
; }
804 BOOL
GetBridge() const { return bridge
; }
807 PString callingToken
;
811 unsigned int timeout
;
815 class PVXMLTransferResult
: public PString
817 PCLASSINFO(PVXMLTransferResult
, PString
);
819 PVXMLTransferResult()
822 PVXMLTransferResult(char * cstr
)
826 PVXMLTransferResult(const PString
& str
)
830 void SetName(const PString
& n
)
833 PString
GetName() const
843 // End of file ////////////////////////////////////////////////////////////////