Class: SippyCup::Media::DTMFPayload
Constant Summary
collapse
- RTP_PAYLOAD_ID =
101
- PTIME =
20
- TIMESTAMP_INTERVAL =
160
- END_OF_EVENT =
1 << 7
- DTMF =
%w{0 1 2 3 4 5 6 7 8 9 * # A B C D}.freeze
Instance Attribute Summary collapse
Attributes inherited from RTPPayload
#header
Instance Method Summary
collapse
Methods inherited from RTPPayload
#method_missing, #to_bytes
Constructor Details
#initialize(digit, opts = {}) ⇒ DTMFPayload
Returns a new instance of DTMFPayload.
14
15
16
17
18
19
20
21
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 14
def initialize(digit, opts = {})
super RTP_PAYLOAD_ID
@flags = 0
@digit = atoi digit
@ptime = opts[:ptime] || PTIME
volume opts[:volume] || 10
end
|
Instance Attribute Details
#ptime ⇒ Object
Returns the value of attribute ptime.
12
13
14
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 12
def ptime
@ptime
end
|
Instance Method Details
#atoi(digit) ⇒ Object
31
32
33
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 31
def atoi(digit)
DTMF.index digit.to_s
end
|
#end_of_event ⇒ Object
41
42
43
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 41
def end_of_event
@flags & END_OF_EVENT
end
|
#end_of_event=(bool) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 23
def end_of_event=(bool)
if bool
@flags |= END_OF_EVENT
else
@flags &= (0xf - END_OF_EVENT)
end
end
|
45
46
47
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 45
def media
[@digit, @flags, timestamp_interval].pack 'CCn'
end
|
#timestamp_interval ⇒ Object
49
50
51
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 49
def timestamp_interval
TIMESTAMP_INTERVAL
end
|
#volume(value) ⇒ Object
35
36
37
38
39
|
# File 'lib/sippy_cup/media/dtmf_payload.rb', line 35
def volume(value)
value = [value, 0x3f].min @flags &= 0xc0 @flags += value
end
|