The call channel settings and states are accessed through the following exposed properties:
The call states can be used to track the progress of a particular call. Once a call has hung up, the call cause can be checked to find the reason why.
Call states:
Usage example:
state = channel.call('sip:1234@127.0.0.1:5060;user=phone')
if state != channel.State.ANSWERED:
# might be busy
pass
Once a call has hung up the call state will return to IDLE and the clearing cause will be one of these.
If an incoming call is rejected, a subset of these causes can be given as the cause for the rejection in the reject function.
Call clearing causes:
Usage example:
state = channel.call('sip:3301@127.0.0.1:5060;user=phone')
if state != channel.State.ANSWERED:
if channel.cause() == channel.Cause.BUSY:
print("Busy, try again")
Calling any of the transfer functions results in one of these transfer causes being set.
Transfer causes:
Usage example:
ret = channel.managed_transfer('sip:3301@127.0.0.1:5060;user=phone')
if res is False:
if channel.transfer_cause() == channel.TransferCause.TARGETREJECT:
print("Busy, try again later")
The call connection type indicates whether the connection is probably to a live speaker or to a machine. The far end type is returned in the call details.
Call connection types:
Usage example:
state = channel.call('sip:1234@127.0.0.1:5060;user=phone'
live_speaker_detect=channel.LiveSpeakerDetectionSettings.DEFAULT)
if state == channel.State.ANSWERED:
# might be a fax machine
if channel.Details.far_end_type == channel.CallFarEndType.FAX_MACHINE:
pass
The type of live speaker detection to use, used when placing and outbound call. The default option is DEFAULT. Live speaker detection is used in conjuntion with a timeout, lsd_timeout_milliseconds, which determines how long to wait for the live speaker detection algorithm to categorise the call.
Live speaker detection types:
The value below determines the point in the call at which live speaker detection is carried out, and hence from what point the lsd_timeout_milliseconds argument is measured.
Usage example:
state = channel.call('sip:1234@127.0.0.1:5060;user=phone'
live_speaker_detect=channel.LiveSpeakerDetectionSettings.DEFAULT)
if state == channel.State.ANSWERED:
# might be a fax machine
if channel.Details.far_end_type == channel.CallFarEndType.FAX_MACHINE:
pass
Conference lifetime control. The options are to start the conference when the caller enters the conference room, and to destroy the conference room when the caller exits the room.
whether the conference should start when this party enters the room. Default is True.
whether the conference room should be destroyed when this party exits the room. Default is False.
The argument start_on_entry indicates whether the conference should start when this party enters the room. All other callers will hear a ring tone until the conference has started. So, if only one participant can cause the conference to start, all others will hear ringing (and not be able to talk to each other) until he enters the room.
Usage example:
conf_media_settings = channel.ConferencePartyMediaSettings(exit_on_dtmf_digit='#')
conf_media_settings.MuteOnDTMFDigits.set_digits(mute='0', unmute='1')
conf_media_settings.PrefixMedia.text_to_say('george')
conf_media_settings.OnEntryMedia.text_to_say('has joined')
conf_media_settings.OnExitMedia.text_to_say('has left')
conf_lifetime_settings = channel.ConferenceLifetimeControl(start_on_entry=True, destroy_on_exit=True)
if channel.transfer_to_conference_room(other_call, conference_room_name,
conference_lifetime_control=conf_lifetime_settings,
conference_party_media_settings=conf_media_settings) != channel.State.TRANSFERRED:
print("could not transfer the call to the conference")
Conference media control. This class defines several parameters that let you fine-tune the behaviour of your conference.
to play a tone to the party while waiting to enter the conference room. Default is RINGBACK.
on the party entering a conference room, play a file (in an endless loop) until the conference has started.
option to play a beep to the conference when this party enters. Default is True.
option to leave the conference by hitting a DTMF digit. Default is None which disables this option.
If True, indicates that the conference room that this party is entering should be optimised for two talking parties. If the conference room will not have more than two talkers, then having optimisation turned on will enhance the quality of the audio. Other parties can enter as listeners without affecting the optimisation. This option should not be used if more than two talking parties will be entering the conference room as this can have adverse affects on the audio quality. Default is False.
The argument ringback_tone defines the audio played to the party while waiting to enter the conference room. Valid options for ringback_tone are listed in the ToneManager resource; or the argument can be left at its default value.
This class exposes the public properties OnEntryMedia, OnExitMedia and PrefixMedia which are classes of the type PlayableMedia. Use the functions provided by PlayableMedia to set some audio to play on entering and leaving the conference room. The audio can be either some text to say as TTS or the name of a file. The audio provided by PrefixMedia will be played before OnEntryMedia and after OnExitMedia.
This class exposes the public propery MuteOnDTMFDigits to optionally set DTMF digits for muting and unmuting a party when the corresponding digit is pressed.
Usage example:
conf_media_settings = channel.ConferencePartyMediaSettings(exit_on_dtmf_digit='#')
conf_media_settings.MuteOnDTMFDigits.set_digits(mute='0', unmute='1')
conf_media_settings.PrefixMedia.text_to_say('george')
conf_media_settings.OnEntryMedia.text_to_say('has joined')
conf_media_settings.OnExitMedia.text_to_say('has left')
conf_lifetime_settings = channel.ConferenceLifetimeControl(start_on_entry=True, destroy_on_exit=True)
if channel.transfer_to_conference_room(other_call, conference_room_name,
conference_lifetime_control=conf_lifetime_settings,
conference_party_media_settings=conf_media_settings) != channel.State.TRANSFERRED:
print("could not transfer the call to the conference")
Conference mute control. Allows the user to set the DTMF digits that will mute or unmute the party.
Two DTMF characters can be supplied. The set of individual DTMF digits permitted is: 1234567890*#. If unmute is not supplied, it will be the same digit as mute.
Conference media parameters. The options are to set the name of a file to play, or to set some text to speak using TTS.
The public properties OnEntryMedia, OnExitMedia and PrefixMedia are of this type.
Set a file name to play.
Setting this option will replace any options that may have been previously set by text_to_say.
Set some text to say as TTS. The | (pipe) character is not permitted.
Setting this option will replace any options that may have been previously set by file_to_play.