Class: Punchblock::Translator::Asterisk::Component::Record
- Defined in:
- lib/punchblock/translator/asterisk/component/record.rb
Constant Summary collapse
- RECORDING_BASE_PATH =
'/var/punchblock/record'
Instance Attribute Summary
Attributes inherited from Component
Instance Method Summary collapse
Methods inherited from Component
#call_ended, #initialize, #logger_id, #send_event
Constructor Details
This class inherits a constructor from Punchblock::Translator::Asterisk::Component::Component
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/punchblock/translator/asterisk/component/record.rb', line 14 def execute max_duration = @component_node.max_duration || -1 raise OptionError, 'Record cannot be used on a call that is not answered.' unless @call.answered? raise OptionError, 'A start-paused value of true is unsupported.' if @component_node.start_paused raise OptionError, 'An initial-timeout value is unsupported.' if @component_node.initial_timeout && @component_node.initial_timeout != -1 raise OptionError, 'A final-timeout value is unsupported.' if @component_node.final_timeout && @component_node.final_timeout != -1 raise OptionError, 'A max-duration value that is negative (and not -1) is invalid.' unless max_duration >= -1 @format = @component_node.format || 'wav' call.register_tmp_handler :ami, :name => 'MonitorStop' do |event| finished end if @component_node.start_beep @call.execute_agi_command 'STREAM FILE', 'beep', '""' end ami_client.send_action 'Monitor', 'Channel' => call.channel, 'File' => filename, 'Format' => @format, 'Mix' => true unless max_duration == -1 call.after max_duration/1000 do stop end end send_ref rescue ChannelGoneError set_node_response ProtocolError.new.setup(:item_not_found, "Could not find a call with ID #{call_id}", call_id) rescue RubyAMI::Error => e with_error :platform_error, "Terminated due to AMI error '#{e.}'" rescue OptionError => e with_error 'option error', e. end |
#execute_command(command) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/punchblock/translator/asterisk/component/record.rb', line 49 def execute_command(command) case command when Punchblock::Component::Stop command.response = true ami_client.send_action 'StopMonitor', 'Channel' => call.channel @complete_reason = stop_reason when Punchblock::Component::Record::Pause ami_client.send_action 'PauseMonitor', 'Channel' => call.channel command.response = true when Punchblock::Component::Record::Resume ami_client.send_action 'ResumeMonitor', 'Channel' => call.channel command.response = true else super end end |
#finished ⇒ Object
66 67 68 |
# File 'lib/punchblock/translator/asterisk/component/record.rb', line 66 def finished send_complete_event(@complete_reason || max_duration_reason) end |
#setup ⇒ Object
10 11 12 |
# File 'lib/punchblock/translator/asterisk/component/record.rb', line 10 def setup @complete_reason = nil end |