Method: AGI#record_file

Defined in:
lib/AGI.rb

#record_file(filename, format, digits, timeout = -1,, beep = false, silence = nil) ⇒ Object

Signals Asterisk to query the channel to provide audio data to record into a file. Asterisk will record until certain digits are provided as DTMF, or the operation times out, or silence is detected for a second timeout. Can optionally cause asterisk to send a beep to the channel to signal the user the intention of recording sound. By default, there is no timeout,no silence detection, and no beep.

Returns an AGIResponse.



504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/AGI.rb', line 504

def record_file(filename, format, digits, timeout=-1, beep=false, silence=nil)
  beep_str = ''
  if ( beep == true ) then
    beep_str = "BEEP"
  end
  silence_str = ''
  unless silence.nil?
    silence_str = "s=#{silence}"
  end
  response = AGIResponse.new
  command_str = "RECORD FILE #{filename} #{format} #{digits} #{(timeout.to_i * 1000)} #{beep_str} #{silence_str}"
  begin
    response.native = execute(command_str)
  rescue AGITimeoutError, AGICommandError, AGIHangupError
    raise
  end
  if response.native == -1 then
    raise AGIChannelError.new(@last_response, "Channel Failure in (#{command_str})")
  elsif response.native > 0
    response.success = true
    response.data = response.native.chr
  else
    response.success = true
  end
  return response
end