Updated 'RECORD FILE' syntax, included silence detection value

master
poing 2016-09-06 18:47:21 +09:00
parent aa47075e30
commit 080bb6d627
1 changed files with 11 additions and 8 deletions

View File

@ -493,17 +493,20 @@ class AGI:
self.set_extension(extension) self.set_extension(extension)
self.set_priority(priority) self.set_priority(priority)
def record_file(self, filename, format='gsm', escape_digits='#', timeout=DEFAULT_RECORD, offset=0, beep='beep'): def record_file(self, filename, format='gsm', escape_digits='#', timeout=DEFAULT_RECORD, offset=0, beep='beep', silence=0):
"""agi.record_file(filename, format, escape_digits, timeout=DEFAULT_TIMEOUT, offset=0, beep='beep') --> None """agi.record_file(filename, format, escape_digits, timeout=DEFAULT_TIMEOUT, offset=0, beep='beep', silence=0) --> None
Record to a file until a given dtmf digit in the sequence is received Record to a file until a given dtmf digit in the sequence is received. Returns
The format will specify what kind of file will be recorded. The timeout '-1' on hangup or error. The format will specify what kind of file will be
is the maximum record time in milliseconds, or -1 for no timeout. Offset recorded. The <timeout> is the maximum record time in milliseconds, or '-1'
samples is optional, and if provided will seek to the offset without for no <timeout>. <offset samples> is optional, and, if provided, will seek
exceeding the end of the file to the offset without exceeding the end of the file. <silence> is the number
of seconds of silence allowed before the function returns despite the lack
of dtmf digits or reaching <timeout>. <silence> value must be preceded by
's=' and is also optional.
""" """
escape_digits = self._process_digit_list(escape_digits) escape_digits = self._process_digit_list(escape_digits)
res = self.execute('RECORD FILE', self._quote(filename), format, res = self.execute('RECORD FILE', self._quote(filename), format,
escape_digits, timeout, offset, beep)['result'][0] escape_digits, timeout, offset, beep, ('s=%s' % silence))['result'][0]
try: try:
return chr(int(res)) return chr(int(res))
except: except: