public class DtmfEvent extends ManagerEvent
To support variable-length DTMF Asterisk (since 1.4.0) interally uses two different frames
for DTMF releated events (AST_FRAME_DTMF_BEGIN
and AST_FRAME_DTMF_END
).
Before 1.4.0 Asterisk only used one frame (AST_FRAME_DTMF
) which is now an alias for
AST_FRAME_DTMF_END
.
Many other systems and devices (like mobile phone providers) do not support variable-length DTMF.
In these cases you will only see AST_FRAME_DTMF_END
frames in Asterisk.
When building DTMF aware applications you should not rely on AST_FRAME_DTMF_BEGIN
.
Generally it is safe to just ignore them and only react on AST_FRAME_DTMF_END
frames.
To check whether an DtmfEvent represents an AST_FRAME_DTMF_BEGIN
or
AST_FRAME_DTMF_END
frame use the isBegin()
and isEnd()
methods.
You can find more information on how Asterisk handles DTMF in the
DTMF article at voip-info.org
It is implemented in main/channel.c
.
Available since Asterisk 1.6
Modifier and Type | Field and Description |
---|---|
static String |
DIRECTION_RECEIVED |
static String |
DIRECTION_SENT |
source
Constructor and Description |
---|
DtmfEvent(Object source)
Creates a new DtmfEvent.
|
Modifier and Type | Method and Description |
---|---|
String |
getChannel()
Returns the name of the channel the DTMF digit was sent or received on.
|
String |
getDigit()
Returns the DTMF digit that was sent or received.
|
String |
getDirection()
Returns whether the DTMF digit was sent or received.
|
String |
getUniqueId()
Returns the unique id of the the channel the DTMF digit was sent or received on.
|
Boolean |
isBegin()
Returns whether this event represents an
AST_FRAME_DTMF_BEGIN frame. |
boolean |
isEnd()
Returns whether this event represents an
AST_FRAME_DTMF_END frame. |
boolean |
isReceived()
Returns whether the DTMF digit was received by Asterisk (sent from the device to Asterisk).
|
boolean |
isSent()
Returns whether the DTMF digit was sent from Asterisk to the device.
|
void |
setBegin(Boolean begin)
Sets whether this event represents an
AST_FRAME_DTMF_BEGIN frame. |
void |
setChannel(String channel)
Sets the name of the channel.
|
void |
setDigit(String digit)
Sets the DTMF digit that was sent or received.
|
void |
setDirection(String direction)
Sets whether the DTMF digit was sent or received.
|
void |
setEnd(Boolean end)
Sets whether this event represents an
AST_FRAME_DTMF_END frame. |
void |
setUniqueId(String uniqueId)
Sets the unique id of the the channel.
|
appendPropertyIfNotNull, getDateReceived, getFile, getFunc, getLine, getPrivilege, getSequenceNumber, getServer, getTimestamp, setDateReceived, setFile, setFunc, setLine, setPrivilege, setSequenceNumber, setServer, setTimestamp, toString
getSource
public static final String DIRECTION_RECEIVED
public static final String DIRECTION_SENT
public DtmfEvent(Object source)
source
- public String getChannel()
public void setChannel(String channel)
channel
- the channel name.public String getUniqueId()
public void setUniqueId(String uniqueId)
uniqueId
- the unique id of the the channel.public String getDigit()
public void setDigit(String digit)
digit
- the DTMF digit that was sent or received.public String getDirection()
Possible values are:
DIRECTION_RECEIVED
,
DIRECTION_SENT
public void setDirection(String direction)
direction
- "Received" or "Sent".public Boolean isBegin()
AST_FRAME_DTMF_BEGIN
frame.Gerally your application will want to ignore begin events. You will only need them if you want to make use of the duration a DTMF key was pressed.
Note that there will be DTMF end events without a corresponding begin event as not all systems (including Asterisk prior to 1.4.0) support variable-length DTMF.
true
if this is a DTMF begin event (key pressed),
false
otherwise.public void setBegin(Boolean begin)
AST_FRAME_DTMF_BEGIN
frame.begin
- true
if this is a DTMF begin event (key pressed),
false
otherwise.public boolean isEnd()
AST_FRAME_DTMF_END
frame.DTMF information received from systems that do not support variable-length DTMF you will only see DTMF end events.
true
if this is a DTMF end event (key released),
false
otherwise.public void setEnd(Boolean end)
AST_FRAME_DTMF_END
frame.end
- true
if this is a DTMF end event (key released),
false
otherwise.public boolean isReceived()
true
if the DTMF digit was received by Asterisk,
false
otherwise.getDirection()
public boolean isSent()
true
if the DTMF digit was sent from Asterisk to the device,
false
otherwise.getDirection()
Copyright © 2004–2016. All rights reserved.