Class: Punchblock::Translator::Freeswitch::Component::Record
- Inherits:
-
Component
show all
- Defined in:
- lib/punchblock/translator/freeswitch/component/record.rb
Constant Summary
collapse
- RECORDING_BASE_PATH =
'/var/punchblock/record'
Instance Attribute Summary
Attributes inherited from Component
#call, #call_id, #id
Instance Method Summary
collapse
Methods inherited from Component
#application, #call_ended, #handle_es_event, #initialize, #logger_id, #send_event
#safe_from_dead_actors
Instance Method Details
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
|
# File 'lib/punchblock/translator/freeswitch/component/record.rb', line 14
def execute
max_duration = @component_node.max_duration || -1
raise OptionError, 'A start-beep value of true is unsupported.' if @component_node.start_beep
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'
component = current_actor
call.register_handler :es, :event_name => 'RECORD_STOP', [:[], :record_file_path] => filename do |event|
component.finished
end
record_args = ['start', filename]
record_args << max_duration/1000 unless max_duration == -1
case @component_node.direction
when :send
call.uuid_foo :setvar, "RECORD_WRITE_ONLY true"
when :recv
call.uuid_foo :setvar, "RECORD_READ_ONLY true"
else
call.uuid_foo :setvar, "RECORD_STEREO true"
end
call.uuid_foo :record, record_args.join(' ')
send_ref
rescue OptionError => e
with_error 'option error', e.message
end
|
#execute_command(command) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/punchblock/translator/freeswitch/component/record.rb', line 47
def execute_command(command)
case command
when Punchblock::Component::Stop
call.uuid_foo :record, "stop #{filename}"
@complete_reason = stop_reason
command.response = true
else
super
end
end
|
58
59
60
|
# File 'lib/punchblock/translator/freeswitch/component/record.rb', line 58
def finished
send_complete_event(@complete_reason || success_reason)
end
|
10
11
12
|
# File 'lib/punchblock/translator/freeswitch/component/record.rb', line 10
def setup
@complete_reason = nil
end
|