public class DefaultVantageAudioDeviceHandler extends java.lang.Object implements AudioDeviceHandler, com.avaya.clientservices.client.ClientListener, HandsetHookListener
This class is designed that it can be used as-is in third-party clients that want to behave identically to Equinox on Vantage.
Modifier and Type | Method and Description |
---|---|
void |
addAudioDeviceChangeListener(AudioDeviceChangeListener listener)
Add a listener to be notified when the active audio device changes.
|
static DefaultVantageAudioDeviceHandler |
createDefaultVantageAudioDeviceHandler(android.content.Context applicationContext,
com.avaya.clientservices.client.Client client,
DeskPhoneService deskPhoneService)
Create an object to provide default audio device handling.
|
java.util.Collection<com.avaya.clientservices.media.AudioDevice> |
getAvailableAudioDevices()
Get the available audio devices.
|
com.avaya.clientservices.media.AudioDevice |
getLastUsedHeadsetDevice() |
void |
onAudioDeviceChanged(com.avaya.clientservices.media.AudioDevice newDevice)
Called when the active audio device has changed via the AudioInterface API.
|
void |
onAudioDeviceError(com.avaya.clientservices.media.AudioDeviceError error)
Audio state error occured.
|
void |
onAudioDeviceListChanged(java.util.List<com.avaya.clientservices.media.AudioDevice> newDeviceList,
boolean activeDeviceChanged)
Audio device(s) have been added or removed by the system.
|
void |
onClientShutdown(com.avaya.clientservices.client.Client client)
Called when the client has shut down.
|
void |
onClientUserCreated(com.avaya.clientservices.client.Client client,
com.avaya.clientservices.user.User user)
Notifies the listener that the specified user has been created.
|
void |
onClientUserRemoved(com.avaya.clientservices.client.Client client,
com.avaya.clientservices.user.User user)
Notifies the listener that the specified user has been removed.
|
void |
onHandsetOffHook(HandsetType handset)
Called when a connected handset has gone off-hook (removed from its
cradle).
|
void |
onHandsetOnHook(HandsetType handset)
Called when a connected handset has gone on-hook (returned to its
cradle).
|
void |
onIdentityCertificateEnrollmentFailed(com.avaya.clientservices.client.Client client,
int errorCode,
java.lang.String errorType,
java.lang.String message)
Notifies the listener that the SCEP conection/enrollment failed.
|
com.avaya.clientservices.media.AudioDevice |
pickAudioDeviceForCallStart(HandsetType handset)
Choose the audio device to use at the beginning of a new VoIP call.
|
void |
removeAudioDeviceChangeListener(AudioDeviceChangeListener listener)
Remove a listener from being notified when the active audio device changes.
|
void |
setRJ9HeadsetDefaultAudioDevice(boolean enabled)
Set the flag controlling if the RJ9 jack is the default audio device used
for new calls.
|
void |
setUserRequestedDevice(com.avaya.clientservices.media.AudioDevice device)
Set the currently active audio device to the specified device.
|
@NonNull public static DefaultVantageAudioDeviceHandler createDefaultVantageAudioDeviceHandler(@NonNull android.content.Context applicationContext, @NonNull com.avaya.clientservices.client.Client client, @NonNull DeskPhoneService deskPhoneService)
The returned object is only valid for the lifetime of the Client
object, and can not be used anymore after that Client
's
shutdown()
method has been called.
There's no need to register the returned object as a listener with the media engine - that's handled by this factory method.
applicationContext
- The application's context.client
- The active Client object from the Communications Package.deskPhoneService
- The Desk Phone Service instance.DefaultVantageAudioDeviceHandler
instance to use.@NonNull public java.util.Collection<com.avaya.clientservices.media.AudioDevice> getAvailableAudioDevices()
AudioDeviceHandler
The advantage of using this over calling AudioInterface.getDevices()
is that this version will filter out any handset devices that aren't
off-hook.
getAvailableAudioDevices
in interface AudioDeviceHandler
public void addAudioDeviceChangeListener(@NonNull AudioDeviceChangeListener listener)
AudioDeviceChangeNotifier
addAudioDeviceChangeListener
in interface AudioDeviceChangeNotifier
listener
- The listener for audio device change events.public void removeAudioDeviceChangeListener(@NonNull AudioDeviceChangeListener listener)
AudioDeviceChangeNotifier
removeAudioDeviceChangeListener
in interface AudioDeviceChangeNotifier
listener
- The listener for audio device change events.public void onClientUserCreated(@NonNull com.avaya.clientservices.client.Client client, @NonNull com.avaya.clientservices.user.User user)
com.avaya.clientservices.client.ClientListener
onClientUserCreated
in interface com.avaya.clientservices.client.ClientListener
client
- The client from which the event came from.user
- The created User.public void onClientUserRemoved(@NonNull com.avaya.clientservices.client.Client client, @NonNull com.avaya.clientservices.user.User user)
com.avaya.clientservices.client.ClientListener
onClientUserRemoved
in interface com.avaya.clientservices.client.ClientListener
client
- The client from which the event came from.user
- The removed User.public void onIdentityCertificateEnrollmentFailed(com.avaya.clientservices.client.Client client, int errorCode, java.lang.String errorType, java.lang.String message)
com.avaya.clientservices.client.ClientListener
onIdentityCertificateEnrollmentFailed
in interface com.avaya.clientservices.client.ClientListener
client
- The client from which the event came from.errorCode
- The error code.errorType
- The type of error.message
- The error description.public void onClientShutdown(@Nullable com.avaya.clientservices.client.Client client)
com.avaya.clientservices.client.ClientListener
At this point the client is idle and all references to it can be removed.
onClientShutdown
in interface com.avaya.clientservices.client.ClientListener
client
- The client that has been shut down.public void onHandsetOffHook(@NonNull HandsetType handset)
HandsetHookListener
This usually means that the user wishes to answer or start a new call.
onHandsetOffHook
in interface HandsetHookListener
handset
- Which handset went off-hook.public void onHandsetOnHook(@NonNull HandsetType handset)
HandsetHookListener
This usually means that the user wishes to end a call.
onHandsetOnHook
in interface HandsetHookListener
handset
- Which handset went on-hook.public void setRJ9HeadsetDefaultAudioDevice(boolean enabled)
AudioDeviceHandler
This is needed because the Vantage hardware is unable to detect when a headset is actually plugged into the RJ9 jack on the back, so the media engine always reports it as available.
The default is false
, which means to use the speakerphone as the
default audio device.
setRJ9HeadsetDefaultAudioDevice
in interface AudioDeviceHandler
enabled
- Set true
to use the headset plugged into the RJ9
jack as the default audio device, false
to use
the speakerphone as the default audio device.AudioDeviceHandler.pickAudioDeviceForCallStart(HandsetType)
@NonNull public com.avaya.clientservices.media.AudioDevice pickAudioDeviceForCallStart(@Nullable HandsetType handset)
AudioDeviceHandler
pickAudioDeviceForCallStart
in interface AudioDeviceHandler
handset
- If non-null
, the device that went off-hook to
originate this call.public com.avaya.clientservices.media.AudioDevice getLastUsedHeadsetDevice()
public void setUserRequestedDevice(@NonNull com.avaya.clientservices.media.AudioDevice device)
AudioDeviceHandler
Use this to implement device selection inside your application's logic and user interface, for cases where the user changes the active audio device without a physical action like plugging/unplugging a device or a handset going on or off hook.
setUserRequestedDevice
in interface AudioDeviceHandler
device
- The audio device to use.public void onAudioDeviceListChanged(@NonNull java.util.List<com.avaya.clientservices.media.AudioDevice> newDeviceList, boolean activeDeviceChanged)
com.avaya.clientservices.media.AudioDeviceListener
onAudioDeviceListChanged
in interface com.avaya.clientservices.media.AudioDeviceListener
newDeviceList
- updated device list with new device(s) added or removed.activeDeviceChanged
- true if the current active device has changed. If this is true
then the audio has moved to a safe state and is muted. A calling setUserRequestedDevice
will cause the audio to be restored on the new device. gatActiveDevice() can be called
to see what is the currently active device.public void onAudioDeviceChanged(com.avaya.clientservices.media.AudioDevice newDevice)
com.avaya.clientservices.media.AudioDeviceListener
onAudioDeviceChanged
in interface com.avaya.clientservices.media.AudioDeviceListener
newDevice
- new active device.public void onAudioDeviceError(@NonNull com.avaya.clientservices.media.AudioDeviceError error)
com.avaya.clientservices.media.AudioDeviceListener
onAudioDeviceError
in interface com.avaya.clientservices.media.AudioDeviceListener
error
- see AudioError enum.