org.mitre.jdas
Class Controller

java.lang.Object
  |
  +--org.mitre.jdas.Controller
All Implemented Interfaces:
EventGenerator

public class Controller
extends java.lang.Object
implements EventGenerator

The Controller class keeps track of the operating mode and state of JDAS, processes requests for mode and state changes, and dispatches events indicating those changes to listeners implementing the ControllerListener interface or extending the ControllerAdapter adapter class.

In the context of JDAS, "states" refer to inherently dynamic operating conditions. States currently supported by JDAS include

To track event timing in situations where latency exists between "start/stop" requests dispatched to other objects and activation of requests by those objects, many states are tracked by "started" and "active" fields. "started" fields are typically (ultimately universally) manipulated through "start/stop" methods invoked by an object requesting a particular operation, whereas "active" fields are typically manipulated through "activate/deactivate" methods invoked by the object responsible for implementing the request.

By contrast, "modes" are quasi-stationary conditions related to the general operation of JDAS. Currently supported modes include

Modes in JDAS are manipulated through "enable/disable" methods invoked by objects requesting mode changes.

See Also:
ControllerListener, ControllerAdapter

Constructor Summary
Controller(galaxy.server.ServerArgParser argParser)
          The Controller class constructor processes command line arguments to set mode parameters and default audio format settings.
 
Method Summary
 void activateMute()
          Activate VAD mute.
 boolean activateVoice()
          Set voice state to active if possible.
 void addEventListener(java.util.EventListener l)
          Adds the specified ControllerListener to the collection of current listeners.
 boolean bargeIn()
          Activates a barge-in event if barge-in enabled and playback has started.
 void deactivateMute()
          Deactivate VAD mute.
 void deactivateVoice()
          Set voice state to inactive.
 void disableBargeIn()
          Disables barge-in mode.
 void disableDebug()
          Disables debugging output mode.
 void disableGUI()
          Disables controller GUI.
 void disableHalfDuplex()
          Disables half-duplex mode.
 void disableKeypad()
          Disables keypad GUI.
 void disablePlaybox()
          Disables MIT audio playbox brokering mode.
 void disablePTT()
          Disables push-to-talk mode.
 boolean disableStreaming()
          Disables streaming mode if not currently recording.
 void enableBargeIn()
          Enables barge-in mode.
 void enableDebug()
          Enables debugging output mode.
 void enableGUI()
          Enables controller GUI.
 void enableHalfDuplex()
          Enables half-duplex mode.
 void enableKeypad()
          Enables keypad GUI.
 void enablePlaybox()
          Disables MIT audio playbox brokering mode.
 void enablePTT()
          Enables push-to-talk mode.
 boolean enableStreaming()
          Enables streaming mode if not currently recording.
 void flash()
          Perform on-hook immediately followed by off-hook.
 AudioBroker getAudioBroker()
          Returns object implementing the AudioBroker interface to handle audio brokering.
 javax.sound.sampled.AudioFormat getDefaultPlaybackAudioFormat()
          Return the default playback audio format determined from defaults overridden by command line arguments.
 javax.sound.sampled.AudioFormat getDefaultRecordAudioFormat()
          Return the default recording audio format determined from defaults overridden by command line arguments.
 float getDefaultVadLowerFactor()
          Return the default factor used to adaptively lower the VAD threshold.
 float getDefaultVadRaiseFactor()
          Return the default factor used to adaptively raise the VAD threshold.
 int getLockoutDelay()
          Returns delay used by the lockout timer.
 boolean guiInvisible()
          Sets GUI state to invisible if the GUI is enabled and currently visible.
 boolean guiVisible()
          Sets GUI state to visible if the GUI is enabled and currently invisible.
 boolean isBargeInEnabled()
          Indicates whether barge-in is enabled.
 boolean isCaptureActive()
           
 boolean isCaptureLineOpen()
           
 boolean isCaptureStartable()
           
 boolean isDebugEnabled()
          Indicates whether debugging output is enabled.
 boolean isGUIEnabled()
          Indicates whether the JDAS controller GUI is enabled.
 boolean isGUIVisible()
          Indicates whether the controller GUI is visible.
 boolean isHalfDuplexEnabled()
          Indicates whether half-duplex operation is enabled.
 boolean isKeypadEnabled()
          Indicates whether the JDAS telephony keypad GUI is enabled.
 boolean isKeypadVisible()
          Indicates whether the keypad GUI is visible.
 boolean isMuteActive()
          Indicates whether VAD mute is active.
 boolean isOnHook()
          Indicates whether JDAS is in an on-hook state.
 boolean isPlaybackActive()
           
 boolean isPlaybackLineOpen()
           
 boolean isPlaybackStartable()
          Indicates whether playback may be started.
 boolean isPlaybackStarted()
          Indicates whether a start playback request is in force.
 boolean isPlayboxEnabled()
          Indicates whether the MIT audio playbox audio brokering protocol is enabled.
 boolean isPTTEnabled()
          Indicates whether push-to-talk operation is enabled.
 boolean isRecordStartable()
          Indicates whether recording may be started.
 boolean isRecordStarted()
          Indicates whether a start recording request is in force.
 boolean isResendable()
           
 boolean isStreamingEnabled()
          Indicates whether streaming audio brokering is enabled.
 boolean isVADStartable()
          Indicates whether voice activity detection may be started.
 boolean isVADStarted()
          Indicates whether VAD has been started.
 boolean isVoiceActivateable()
          Indicates whether the voice state may be set active.
 boolean isVoiceActive()
          Indicates whether the voice state is active.
 boolean keypadInvisible()
          Sets keypad GUI state to invisible if the keypad is enabled and currently visible.
 boolean keypadVisible()
          Sets keypad GUI state to visible if the keypad is enabled and currently invisible.
 void notifySubscribers(java.lang.Object source, java.util.EventObject e)
          Send a ControllerEvent to the subscribers.
 void offHook()
          Take JDAS off-hook.
 void onHook()
          Put JDAS on-hook.
 void removeEventListener(java.util.EventListener l)
          Removes the specified ControllerListener from the collection of current listeners.
 boolean resend()
          Activate resend state if not recording and there is audio data to send.
 void setAudioBroker(AudioBroker audioBroker)
          Sets object implementing the AudioBroker interface to handle audio brokering.
 void setBargeInEnabled(boolean bargeInEnabled)
          Sets debugging output mode to specified value.
 void setCaptureLineOpen(boolean captureLineOpen)
           
 void setDebugEnabled(boolean debugEnabled)
          Sets debugging output mode to specified value.
 void setDefaultPlaybackAudioFormat(javax.sound.sampled.AudioFormat defaultPlaybackAudioFormat)
          Set default playback audio format.
 void setDefaultRecordAudioFormat(javax.sound.sampled.AudioFormat defaultRecordAudioFormat)
          Set default recording audio format.
 void setDefaultVadLowerFactor(float defaultVadLowerFactor)
          Set the default factor used to adaptively lower the VAD threshold.
 void setDefaultVadRaiseFactor(float defaultVadRaiseFactor)
          Set the default factor used to adaptively raise the VAD threshold.
 void setGUIEnabled(boolean guiEnabled)
          Sets controller GUI mode to specified value.
 boolean setGUIVisible(boolean guiVisible)
          Sets GUI state to specified value if possible.
 void setHalfDuplexEnabled(boolean halfDuplexEnabled)
          Sets half-duplex mode to specified value.
 void setHook(boolean onHook)
          Set hook state to specified value.
 void setKeypadEnabled(boolean keypadEnabled)
          Sets keypad GUI mode to specified value.
 boolean setKeypadVisible(boolean keypadVisible)
          Sets keypad GUI state to specified value if possible.
 void setMuteActive(boolean muteActive)
          Set VAD mute to specified value.
 void setPlaybackLineOpen(boolean playbackLineOpen)
           
 boolean setPlaybackStarted(boolean playbackStarted)
          Set playback start to specified value if possible.
 void setPlayboxEnabled(boolean playboxEnabled)
          Sets MIT audio playbox brokering mode to specified value.
 void setPTTEnabled(boolean pttEnabled)
          Sets push-to-talk mode to specified value.
 boolean setRecordStarted(boolean recordStarted)
          Set record start to specified value if possible.
 boolean setStreaming(boolean streamingEnabled)
          Sets streaming mode if not currently recording.
 boolean setVADStarted(boolean vadStarted)
          Set VAD start to specified value if possible.
 boolean setVoiceActive(boolean voiceActive)
          Set voice activity state to specified value if possible.
 void sleep()
          Sleeps invoking thread for default number of msec (125 to be exact)
 boolean startPlayback()
          Start playback if possible.
 boolean startRecord()
          Start recording if possible.
 boolean startVAD()
          Start VAD monitoring if possible.
 void stopPlayback()
          Stop playback.
 void stopRecord()
          Stop recording.
 void stopVAD()
          Stop VAD monitoring.
 java.lang.String toString()
           
 boolean touchtone(int id)
          Generate KeypadEvent event with specified id value, provided JDAS is not on-hook at the time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Controller

public Controller(galaxy.server.ServerArgParser argParser)
The Controller class constructor processes command line arguments to set mode parameters and default audio format settings. Upon completion, the constructor generates an InitializationEvent handled by listener objects.
Parameters:
argParser - Parsed command line argument object passed from MainServer
Method Detail

isBargeInEnabled

public boolean isBargeInEnabled()
Indicates whether barge-in is enabled.

isDebugEnabled

public boolean isDebugEnabled()
Indicates whether debugging output is enabled.

isGUIEnabled

public boolean isGUIEnabled()
Indicates whether the JDAS controller GUI is enabled.

isHalfDuplexEnabled

public boolean isHalfDuplexEnabled()
Indicates whether half-duplex operation is enabled.

isKeypadEnabled

public boolean isKeypadEnabled()
Indicates whether the JDAS telephony keypad GUI is enabled.

isPlayboxEnabled

public boolean isPlayboxEnabled()
Indicates whether the MIT audio playbox audio brokering protocol is enabled.

isPTTEnabled

public boolean isPTTEnabled()
Indicates whether push-to-talk operation is enabled.

isStreamingEnabled

public boolean isStreamingEnabled()
Indicates whether streaming audio brokering is enabled. Currently, this implies that audio is brokered out in .125 second chunks, but will ultimately be configurable.

isCaptureActive

public boolean isCaptureActive()

isCaptureLineOpen

public boolean isCaptureLineOpen()

isCaptureStartable

public boolean isCaptureStartable()

isGUIVisible

public boolean isGUIVisible()
Indicates whether the controller GUI is visible.

isKeypadVisible

public boolean isKeypadVisible()
Indicates whether the keypad GUI is visible.

isMuteActive

public boolean isMuteActive()
Indicates whether VAD mute is active.

isOnHook

public boolean isOnHook()
Indicates whether JDAS is in an on-hook state.

isPlaybackActive

public boolean isPlaybackActive()

isPlaybackLineOpen

public boolean isPlaybackLineOpen()

isPlaybackStartable

public boolean isPlaybackStartable()
Indicates whether playback may be started. The current logic is that playback may not be started if JDAS is on hook, half-duplex is enabled and recording has been requested or is still active, or if capture is in an unstable state.

isPlaybackStarted

public boolean isPlaybackStarted()
Indicates whether a start playback request is in force.

isRecordStartable

public boolean isRecordStartable()
Indicates whether recording may be started. The current logic is that recording may not be started if JDAS is on hook, half-duplex is enabled and playback has been requested or is still active, or if playback is in an unstable state.

isRecordStarted

public boolean isRecordStarted()
Indicates whether a start recording request is in force.

isResendable

public boolean isResendable()

isVADStartable

public boolean isVADStartable()
Indicates whether voice activity detection may be started. Current logic is that VAD may not be started if VAD has already been started, push-to-talk is enabled, VAD mute is active, half-duplex mode is enabled and playback is on, or if playback is in an unstable state.

isVADStarted

public boolean isVADStarted()
Indicates whether VAD has been started.

isVoiceActivateable

public boolean isVoiceActivateable()
Indicates whether the voice state may be set active. Current logic is that the voice state may be set active if VAD has not been stopped and, if barge-in in enabled, playback is not on.

isVoiceActive

public boolean isVoiceActive()
Indicates whether the voice state is active.

getDefaultRecordAudioFormat

public javax.sound.sampled.AudioFormat getDefaultRecordAudioFormat()
Return the default recording audio format determined from defaults overridden by command line arguments.

getDefaultPlaybackAudioFormat

public javax.sound.sampled.AudioFormat getDefaultPlaybackAudioFormat()
Return the default playback audio format determined from defaults overridden by command line arguments.

getDefaultVadRaiseFactor

public float getDefaultVadRaiseFactor()
Return the default factor used to adaptively raise the VAD threshold.

getDefaultVadLowerFactor

public float getDefaultVadLowerFactor()
Return the default factor used to adaptively lower the VAD threshold.

getLockoutDelay

public int getLockoutDelay()
Returns delay used by the lockout timer.
See Also:
LockoutTimer

getAudioBroker

public AudioBroker getAudioBroker()
Returns object implementing the AudioBroker interface to handle audio brokering.
See Also:
AudioBroker

setDefaultPlaybackAudioFormat

public void setDefaultPlaybackAudioFormat(javax.sound.sampled.AudioFormat defaultPlaybackAudioFormat)
Set default playback audio format.

setDefaultRecordAudioFormat

public void setDefaultRecordAudioFormat(javax.sound.sampled.AudioFormat defaultRecordAudioFormat)
Set default recording audio format.

setDefaultVadRaiseFactor

public void setDefaultVadRaiseFactor(float defaultVadRaiseFactor)
Set the default factor used to adaptively raise the VAD threshold.

setDefaultVadLowerFactor

public void setDefaultVadLowerFactor(float defaultVadLowerFactor)
Set the default factor used to adaptively lower the VAD threshold.

setAudioBroker

public void setAudioBroker(AudioBroker audioBroker)
Sets object implementing the AudioBroker interface to handle audio brokering.
See Also:
AudioBroker

disableBargeIn

public void disableBargeIn()
Disables barge-in mode. Generates a ModeEvent event with a BARGE_IN_DISABLED id.

enableBargeIn

public void enableBargeIn()
Enables barge-in mode. Generates a ModeEvent event with a BARGE_IN_ENABLED id.

setBargeInEnabled

public void setBargeInEnabled(boolean bargeInEnabled)
Sets debugging output mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disableDebug

public void disableDebug()
Disables debugging output mode. Generates a ModeEvent event with a DEBUG_DISABLED id.

enableDebug

public void enableDebug()
Enables debugging output mode. Generates a ModeEvent event with a DEBUG_ENABLED id.

setDebugEnabled

public void setDebugEnabled(boolean debugEnabled)
Sets debugging output mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disableGUI

public void disableGUI()
Disables controller GUI. Generates a ModeEvent event with a GUI_DISABLED id.

enableGUI

public void enableGUI()
Enables controller GUI. Generates a ModeEvent event with a GUI_ENABLED id.

setGUIEnabled

public void setGUIEnabled(boolean guiEnabled)
Sets controller GUI mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disableKeypad

public void disableKeypad()
Disables keypad GUI. Generates a ModeEvent event with a KEYPAD_DISABLED id.

enableKeypad

public void enableKeypad()
Enables keypad GUI. Generates a ModeEvent event with a KEYPAD_ENABLED id.

setKeypadEnabled

public void setKeypadEnabled(boolean keypadEnabled)
Sets keypad GUI mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disableHalfDuplex

public void disableHalfDuplex()
Disables half-duplex mode. Generates a ModeEvent event with a HALF_DUPLEX_DISABLED id.

enableHalfDuplex

public void enableHalfDuplex()
Enables half-duplex mode. Generates a ModeEvent event with a HALF_DUPLEX_ENABLED id.

setHalfDuplexEnabled

public void setHalfDuplexEnabled(boolean halfDuplexEnabled)
Sets half-duplex mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disablePlaybox

public void disablePlaybox()
Disables MIT audio playbox brokering mode. Generates a ModeEvent event with a PLAYBOX_DISABLED id.

enablePlaybox

public void enablePlaybox()
Disables MIT audio playbox brokering mode. Generates a ModeEvent event with a PLAYBOX_ENABLED id.

setPlayboxEnabled

public void setPlayboxEnabled(boolean playboxEnabled)
Sets MIT audio playbox brokering mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disablePTT

public void disablePTT()
Disables push-to-talk mode. Generates a ModeEvent event with a PTT_DISABLED id.

enablePTT

public void enablePTT()
Enables push-to-talk mode. Generates a ModeEvent event with a PTT_ENABLED id.

setPTTEnabled

public void setPTTEnabled(boolean pttEnabled)
Sets push-to-talk mode to specified value. Generates a corresponding ModeEvent event with an appropriate id.

disableStreaming

public boolean disableStreaming()
Disables streaming mode if not currently recording. Generates a ModeEvent event with a STREAMING_DISABLED id.
Returns:
true if operation successful.
See Also:
isRecordStarted()

enableStreaming

public boolean enableStreaming()
Enables streaming mode if not currently recording. Generates a ModeEvent event with a STREAMING_ENABLED id.
Returns:
true if operation successful.
See Also:
isRecordStarted()

setStreaming

public boolean setStreaming(boolean streamingEnabled)
Sets streaming mode if not currently recording. If successful, generates a ModeEvent event an appropriate id.
Returns:
true if operation successful.

guiInvisible

public boolean guiInvisible()
Sets GUI state to invisible if the GUI is enabled and currently visible. Generates a GUIEvent event with a GUI_INVISIBLE id.
Returns:
true if operation successful.
See Also:
isGUIEnabled(), isGUIVisible()

guiVisible

public boolean guiVisible()
Sets GUI state to visible if the GUI is enabled and currently invisible. Generates a GUIEvent event with a GUI_VISIBLE id.
Returns:
true if operation successful.
See Also:
isGUIEnabled(), isGUIVisible()

setGUIVisible

public boolean setGUIVisible(boolean guiVisible)
Sets GUI state to specified value if possible. Generates a GUIEvent event with an appropriate id.
Returns:
true if operation successful.

keypadInvisible

public boolean keypadInvisible()
Sets keypad GUI state to invisible if the keypad is enabled and currently visible. Generates a GUIEvent event with a KEYPAD_INVISIBLE id.
Returns:
true if operation successful.
See Also:
isKeypadEnabled(), isKeypadVisible()

keypadVisible

public boolean keypadVisible()
Sets keypad GUI state to visible if the keypad is enabled and currently invisible. Generates a GUIEvent event with a KEYPAD_VISIBLE id.
Returns:
true if operation successful.
See Also:
isKeypadEnabled(), isKeypadVisible()

setKeypadVisible

public boolean setKeypadVisible(boolean keypadVisible)
Sets keypad GUI state to specified value if possible. Generates a GUIEvent event with an appropriate id.
Returns:
true if operation successful.

activateMute

public void activateMute()
Activate VAD mute. Generates a VADEvent event with MUTE_ACTIVE id.

deactivateMute

public void deactivateMute()
Deactivate VAD mute. Generates a VADEvent event with MUTE_INACTIVE id.

setMuteActive

public void setMuteActive(boolean muteActive)
Set VAD mute to specified value. Generates a VADEvent event with an appropriate id.

offHook

public void offHook()
Take JDAS off-hook. Generates a KeypadEvent event with OFF_HOOK id.

onHook

public void onHook()
Put JDAS on-hook. Generates a KeypadEvent event with ON_HOOK id.

setHook

public void setHook(boolean onHook)
Set hook state to specified value. Generates a KeypadEvent event with an appropriate id.

flash

public void flash()
Perform on-hook immediately followed by off-hook.

touchtone

public boolean touchtone(int id)
Generate KeypadEvent event with specified id value, provided JDAS is not on-hook at the time.
Returns:
true if not on hook.
See Also:
isOnHook()

startPlayback

public boolean startPlayback()
Start playback if possible. Generates a PlaybackEvent event with a PLAYBACK_STARTED id.
Returns:
true if playback start successful.
See Also:
isPlaybackStartable()

stopPlayback

public void stopPlayback()
Stop playback. Generates a PlaybackEvent event with a PLAYBACK_STOPPED id.

setPlaybackStarted

public boolean setPlaybackStarted(boolean playbackStarted)
Set playback start to specified value if possible. Generates a PlaybackEvent event with an appropriate id.
Returns:
true if operation successful.

bargeIn

public boolean bargeIn()
Activates a barge-in event if barge-in enabled and playback has started.
Returns:
true if activation successful.
See Also:
isBargeInEnabled(), isPlaybackStarted()

setPlaybackLineOpen

public void setPlaybackLineOpen(boolean playbackLineOpen)

startRecord

public boolean startRecord()
Start recording if possible. Generates a CaptureEvent event with a RECORD_STARTED id.
Returns:
true if playback start successful.
See Also:
isRecordStartable()

stopRecord

public void stopRecord()
Stop recording. Generates a CaptureEvent event with a RECORD_STOPPED id.

setRecordStarted

public boolean setRecordStarted(boolean recordStarted)
Set record start to specified value if possible. Generates a CaptureEvent event with an appropriate id.
Returns:
true if operation successful.

resend

public boolean resend()
Activate resend state if not recording and there is audio data to send. If successful, generates a CaptureEvent event with a RESEND_ACTIVE id.
Returns:
true if resend successful.
See Also:
isRecordStarted()

setCaptureLineOpen

public void setCaptureLineOpen(boolean captureLineOpen)

startVAD

public boolean startVAD()
Start VAD monitoring if possible. Once monitoring is activated, the VoiceActivityDetector will adapt its threshold and detect voice activity on the basis of each captured buffer.
Returns:
true if VAD start successful.
See Also:
isVadStartable()

stopVAD

public void stopVAD()
Stop VAD monitoring. Generates a VADEvent event with a VAD_STOPPED id.

setVADStarted

public boolean setVADStarted(boolean vadStarted)
Set VAD start to specified value if possible. Generates a VADEvent event with an appropriate id.
Returns:
true if operation successful.

activateVoice

public boolean activateVoice()
Set voice state to active if possible. If successful, generates a VADEvent event with a VOICE_ACTIVE id.
Returns:
true if voice activation successful.
See Also:
isVoiceActivateable()

deactivateVoice

public void deactivateVoice()
Set voice state to inactive. Generates a VADEvent event with a VOICE_INACTIVE id.

setVoiceActive

public boolean setVoiceActive(boolean voiceActive)
Set voice activity state to specified value if possible. Generates a VADEvent event with an appropriate id.
Returns:
true if operation successful.
See Also:
isVoiceActivateable()

addEventListener

public void addEventListener(java.util.EventListener l)
Adds the specified ControllerListener to the collection of current listeners.
Specified by:
addEventListener in interface EventGenerator

removeEventListener

public void removeEventListener(java.util.EventListener l)
Removes the specified ControllerListener from the collection of current listeners.
Specified by:
removeEventListener in interface EventGenerator

notifySubscribers

public void notifySubscribers(java.lang.Object source,
                              java.util.EventObject e)
Send a ControllerEvent to the subscribers.
Specified by:
notifySubscribers in interface EventGenerator

sleep

public void sleep()
Sleeps invoking thread for default number of msec (125 to be exact)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object