public interface AsteriskChannel extends LiveObject
PropertyChangeEvents are fired for the following properties:
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_ACCOUNT |
static String |
PROPERTY_CALL_DETAIL_RECORD |
static String |
PROPERTY_CALLER_ID |
static String |
PROPERTY_CURRENT_EXTENSION |
static String |
PROPERTY_DIALED_CHANNEL |
static String |
PROPERTY_DIALING_CHANNEL |
static String |
PROPERTY_DTMF_RECEIVED |
static String |
PROPERTY_DTMF_SENT |
static String |
PROPERTY_ID |
static String |
PROPERTY_LINKED_CHANNEL |
static String |
PROPERTY_MEET_ME_USER |
static String |
PROPERTY_MONITORED |
static String |
PROPERTY_NAME |
static String |
PROPERTY_PARKED_AT |
static String |
PROPERTY_QUEUE_ENTRY |
static String |
PROPERTY_STATE |
static String |
VAR_AJ_DIAL_STATUS
Pseudo-variable to store
DialEvent.getDialStatus() |
static String |
VARIABLE_MONITOR_EXEC |
static String |
VARIABLE_MONITOR_EXEC_ARGS |
Modifier and Type | Method and Description |
---|---|
void |
changeMonitoring(String filename)
Changes the filename of a previously started monitoring.
|
String |
getAccount()
Returns the account code used to bill this channel.
|
CallDetailRecord |
getCallDetailRecord()
Returns the call detail record for this channel.
|
CallerId |
getCallerId()
Returns the caller id of this channel.
|
Extension |
getCurrentExtension()
Returns the last visited dialplan entry.
|
Date |
getDateOfCreation()
Returns the date this channel has been created.
|
Date |
getDateOfRemoval()
Returns the date this channel has left the Asterisk server for example by
a hangup.
|
AsteriskChannel |
getDialedChannel()
Returns the channel that has been dialed by this channel most recently,
this is the destination channel that was created because this channel
dialed it.
|
List<DialedChannelHistoryEntry> |
getDialedChannelHistory()
Returns a list of all channels that have been dialed by this channel.
|
AsteriskChannel |
getDialingChannel()
Returns the channel that was dialing this channel, this is the source
channel that created this channel by dialing it.
|
Character |
getDtmfReceived()
Returns the last DTMF digit received on this channels.
|
Character |
getDtmfSent()
Returns the last DTMF digit sent on this channels.
|
List<ExtensionHistoryEntry> |
getExtensionHistory()
Returns a list of all visited dialplan entries.
|
Extension |
getFirstExtension()
Returns the first visited dialplan entry.
|
HangupCause |
getHangupCause()
Returns the reason for hangup.
|
String |
getHangupCauseText()
Returns a textual representation of the reason for hangup.
|
String |
getId()
Returns the unique id of this channel, for example "1099015093.165".
|
AsteriskChannel |
getLinkedChannel()
Returns the channel this channel is currently bridged with, if any.
|
List<LinkedChannelHistoryEntry> |
getLinkedChannelHistory()
Returns a list of all channels this channel was briged with.
|
MeetMeUser |
getMeetMeUser()
Returns the MeetMeUser associated with this channel if this channel is
currently taking part in a MeetMe conference.
|
String |
getName()
Returns the name of this channel, for example "SIP/1310-20da".
|
Extension |
getParkedAt()
Return the extension to dial to pickup he channel of the parking if the channel is
currently parked.
|
AsteriskQueueEntry |
getQueueEntry()
Returns the queue entry associated with this channel.
|
ChannelState |
getState()
Returns the state of this channel.
|
String |
getVariable(String variable)
Returns the value of the given channel variable.
|
Map<String,String> |
getVariables()
Returns the channel variables as received by
VarSetEvents . |
void |
hangup()
Hangs up this channel.
|
void |
hangup(HangupCause cause)
Hangs up this channel using a given cause code.
|
boolean |
isMonitored()
Return the actual MONITOR state.
|
void |
pauseMixMonitor(MixMonitorDirection direction)
Temporarily stops monitoring this channel if this is monitored with MixMonitor.
|
void |
pauseMonitoring()
Temporarily stops monitoring this channel.
|
void |
playDtmf(String digit)
Plays the given DTMF digit on this channel.
|
void |
redirect(String context,
String exten,
int priority)
Redirects this channel to a new extension.
|
void |
redirectBothLegs(String context,
String exten,
int priority)
Redirects this channel and the channel this channel is linked to to a new
extension.
|
void |
setAbsoluteTimeout(int seconds)
Sets the absolute maximum amount of time permitted for a call on a given
channel, it hangs up the channel after this time.
|
void |
setVariable(String variable,
String value)
Sets the value of the given channel variable.
|
void |
startMonitoring(String filename)
Starts monitoring (recording) this channel.
|
void |
startMonitoring(String filename,
String format)
Starts monitoring (recording) this channel using the given audio format.
|
void |
startMonitoring(String filename,
String format,
boolean mix)
Starts monitoring (recording) this channel using the given audio format
and optionally mixing input and output data after recording is finished.
|
void |
stopMonitoring()
Stops monitoring this channel.
|
void |
unPauseMixMonitor(MixMonitorDirection direction)
Re-enables monitoring this channel after calling
pauseMixMonitor(org.asteriskjava.util.MixMonitorDirection) ()}
if this is monitored with MixMonitor |
void |
unpauseMonitoring()
Re-enables monitoring this channel after calling
pauseMonitoring() . |
boolean |
wasBusy()
Checks if this channel was busy.
|
boolean |
wasInState(ChannelState state)
Checks if this channel was at least once in the given state.
|
boolean |
wasLinked()
Indicates if this channel was linked to another channel at least once.
|
addPropertyChangeListener, addPropertyChangeListener, getServer, removePropertyChangeListener, removePropertyChangeListener
static final String PROPERTY_ID
static final String PROPERTY_NAME
static final String PROPERTY_CALLER_ID
static final String PROPERTY_STATE
static final String PROPERTY_ACCOUNT
static final String PROPERTY_CURRENT_EXTENSION
static final String PROPERTY_CALL_DETAIL_RECORD
static final String PROPERTY_DIALED_CHANNEL
static final String PROPERTY_DIALING_CHANNEL
static final String PROPERTY_LINKED_CHANNEL
static final String PROPERTY_MEET_ME_USER
static final String PROPERTY_QUEUE_ENTRY
static final String PROPERTY_PARKED_AT
static final String PROPERTY_DTMF_RECEIVED
static final String PROPERTY_DTMF_SENT
static final String PROPERTY_MONITORED
static final String VARIABLE_MONITOR_EXEC
static final String VARIABLE_MONITOR_EXEC_ARGS
static final String VAR_AJ_DIAL_STATUS
DialEvent.getDialStatus()
String getId()
String getName()
CallerId getCallerId()
ChannelState getState()
boolean wasInState(ChannelState state)
For example you can use this method the check if this channel had been answered:
boolean answered = channel.wasInState(ChannelState.UP);
state
- the state to look for.true
if this channel was at least once in the
given state; false
otherwise.boolean wasBusy()
true
if this channel was busy; false
otherwise.String getAccount()
Extension getCurrentExtension()
Extension getFirstExtension()
List<ExtensionHistoryEntry> getExtensionHistory()
Date getDateOfCreation()
This property is immutable.
Date getDateOfRemoval()
null
if this channel is still active.HangupCause getHangupCause()
null
if the channel has
not yet been hung up or no hangup cause is available for this
type of channel.String getHangupCauseText()
null
if the channel has not yet been hung up or no
hangup cause is available for this type of channel. If no hangup
cause is available an empty String may be returned, too.CallDetailRecord getCallDetailRecord()
null
if
none has (yet) been received.AsteriskChannel getDialedChannel()
null
if none has been dialed.List<DialedChannelHistoryEntry> getDialedChannelHistory()
AsteriskChannel getDialingChannel()
null
if none was dialing.AsteriskChannel getLinkedChannel()
null
if this channel is currently not bridged to another channel.List<LinkedChannelHistoryEntry> getLinkedChannelHistory()
boolean wasLinked()
true
if this channel was linked to another channel
at least once, false
otherwise.MeetMeUser getMeetMeUser()
null
if this channel is currently not taking part in a MeetMe
conference.AsteriskQueueEntry getQueueEntry()
null
otherwise.Extension getParkedAt()
null
if not currently parked.Map<String,String> getVariables()
VarSetEvents
.Available since Asterisk 1.6.
Character getDtmfReceived()
null
if none has yet been received.Character getDtmfSent()
null
if none has yet been sent.boolean isMonitored()
void hangup() throws ManagerCommunicationException, NoSuchChannelException
ManagerCommunicationException
- if the hangup action cannot be sent
to Asterisk.NoSuchChannelException
- if this channel had already been hung up
before the hangup was sent.void hangup(HangupCause cause) throws ManagerCommunicationException, NoSuchChannelException
cause
- the cause code to send.ManagerCommunicationException
- if the hangup action cannot be sent
to Asterisk.NoSuchChannelException
- if this channel had already been hung up
before the hangup was sent.void setAbsoluteTimeout(int seconds) throws ManagerCommunicationException, NoSuchChannelException
Time is counted from when you call setAbsoluteTimeout, not from the beginning of the call.
seconds
- maximum duration of the call in seconds, 0 for unlimited
call length.ManagerCommunicationException
- if the absolute timeout action
cannot be sent to Asterisk.NoSuchChannelException
- if this channel had already been hung up
before the absolute timeout was set.void redirect(String context, String exten, int priority) throws ManagerCommunicationException, NoSuchChannelException
If this channel is linked to another channel, the linked channel is hung up.
context
- the destination context.exten
- the destination extension.priority
- the destination priority.ManagerCommunicationException
- if the redirect action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
the redirect was sent.void redirectBothLegs(String context, String exten, int priority) throws ManagerCommunicationException, NoSuchChannelException
If this channel is not linked to another channel only this channel is redirected.
context
- the destination context.exten
- the destination extension.priority
- the destination priority.ManagerCommunicationException
- if the redirect action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
the redirect was sent.String getVariable(String variable) throws ManagerCommunicationException, NoSuchChannelException
Currently Asterisk does not support the retrieval of built-in variables
like EXTEN or CALLERIDNUM but only custom variables set via Asterisk's
Set command or via setVariable(String, String)
.
variable
- the name of the channel variable to return.null
if it is
not set.ManagerCommunicationException
- if the get variable action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
the variable was requested.void setVariable(String variable, String value) throws ManagerCommunicationException, NoSuchChannelException
variable
- the name of the channel variable to set.value
- the value of the channel variable to set.ManagerCommunicationException
- if the set variable action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
the variable was set.void playDtmf(String digit) throws ManagerCommunicationException, NoSuchChannelException, IllegalArgumentException
Available since Asterisk 1.2.8
digit
- the DTMF digit to play.ManagerCommunicationException
- if the play DTMF action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
the DTMF digit was set.IllegalArgumentException
- if the digit is null
.void startMonitoring(String filename) throws ManagerCommunicationException, NoSuchChannelException
The format of the files is "wav", they are not mixed.
The files are called filename-in.wav and filename-out.wav.
filename
- the basename of the files created in the monitor spool
directory. If null
the channel name (with
slashed replaced by dashes) is used.ManagerCommunicationException
- if the monitor action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
starting monitoring.stopMonitoring()
,
pauseMonitoring()
void startMonitoring(String filename, String format) throws ManagerCommunicationException, NoSuchChannelException
The files are not mixed.
The files are called filename-in.format and filename-out.format.
filename
- the basename of the files created in the monitor spool
directory. If null
the channel name (with
slashed replaced by dashes) is used.format
- the audio recording format. If null
wav is
used.ManagerCommunicationException
- if the monitor action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
starting monitoring.stopMonitoring()
,
pauseMonitoring()
void startMonitoring(String filename, String format, boolean mix) throws ManagerCommunicationException, NoSuchChannelException
Mixing is done by soxmix by default (which has to be installed on your
Asterisk server). You can use your own script by setting the variable
MONITOR_EXEC
to your custom script before starting
monitoring the channel. Your script is then called with 3 arguments, the
two leg files and a target mixed file name which is the same as the leg
file names without the in/out designator, i.e. filename.format.
The two leg files are only removed by Asterisk if
MONITOR_EXEC
is not set. If you use a custom script and
want to remove them, just let your script do this.
To pass additional arguments to your script you can set the variable
MONITOR_EXEC_ARGS
to a list of arguments (separated by
spaces).
Example:
AsteriskChannel c; [...] c.setVariable(AsteriskChannel.VARIABLE_MONITOR_EXEC, "/usr/local/bin/2wav2mp3"); c.startMonitoring("my-recording", "wav", true);Side note: 2wav2mp3 is a nice script by Dietmar Zlabinger to mix the two legs to a stero mp3 file, for details see voip-info.org.
filename
- the basename of the file(s) created in the monitor spool
directory. If null
the channel name (with
slashed replaced by dashes) is used.format
- the audio recording format. If null
wav is
used.mix
- true
to mix input and output data together
after recording is finished, false
to not mix
them.ManagerCommunicationException
- if the monitor action cannot be
sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
starting monitoring.VARIABLE_MONITOR_EXEC
,
VARIABLE_MONITOR_EXEC_ARGS
,
stopMonitoring()
,
pauseMonitoring()
void changeMonitoring(String filename) throws ManagerCommunicationException, NoSuchChannelException, IllegalArgumentException
If the channel exists but is not currently monitored your request is ignored and a warning message is written to Asterisk's CLI.
Use with care, this doesn't always seem to work.
filename
- the basename of the file(s) created in the monitor spool
directory.ManagerCommunicationException
- if the change monitor action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
changing monitoring.IllegalArgumentException
- if filename is null
.stopMonitoring()
,
pauseMonitoring()
void stopMonitoring() throws ManagerCommunicationException, NoSuchChannelException
If the channel exists but is not currently monitored your request is ignored.
ManagerCommunicationException
- if the stop monitor action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
stopping monitoring.startMonitoring(String)
,
startMonitoring(String, String)
,
startMonitoring(String, String, boolean)
void pauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException
If the channel exists but is not currently monitored your request is ignored.
This method is available since Asterisk 1.4.
ManagerCommunicationException
- if the pause monitor action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
temporarily stopping monitoring.unpauseMonitoring()
void unpauseMonitoring() throws ManagerCommunicationException, NoSuchChannelException
pauseMonitoring()
.
If the channel exists but monitoring has not been paused your request is ignored.
This method is available since Asterisk 1.4.
ManagerCommunicationException
- if the unpause monitor action
cannot be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
re-enabling monitoring.pauseMonitoring()
void pauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException
If the channel exists but is not currently monitored your request is ignored.
ManagerCommunicationException
- if the pause monitor action cannot
be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
temporarily stopping monitoring.unPauseMixMonitor(org.asteriskjava.util.MixMonitorDirection)
void unPauseMixMonitor(MixMonitorDirection direction) throws ManagerCommunicationException, NoSuchChannelException
pauseMixMonitor(org.asteriskjava.util.MixMonitorDirection)
()}
if this is monitored with MixMonitor
If the channel exists but monitoring has not been paused your request is ignored.
ManagerCommunicationException
- if the unpause monitor action
cannot be sent to Asterisk.NoSuchChannelException
- if this channel had been hung up before
re-enabling monitoring.pauseMixMonitor(org.asteriskjava.util.MixMonitorDirection)
Copyright © 2004–2016. All rights reserved.