Class SessionWrapper

java.lang.Object
com.castlabs.sdk.broadpeak.SessionWrapper

public class SessionWrapper extends Object
Wrapper around SessionApi. The Wrapper outlives the internal SessionApi. In case a renewal is required, the internal SessionApi will be replaced with a new one.

All SmartLib calls that may block (starting, renewing and stopping a session) run as jobs on the Handler the caller provides, one job at a time, and additionally hold SMARTLIB_LOCK while they block, so that no two of them run at the same time anywhere in the process, not even for different players. Quick SmartLib calls that only post to its worker (listeners, ad activation, playback notifications) are not serialized that way: they may run on the main thread, which must never wait behind another player's session creation.

A stop cancels the jobs scheduled before it: a start that has not run yet does not run, and a start that is in flight leaves the wrapper idle and lets the stop job queued behind it tear the session down. The wrapper's own state, and the waits on it, are guarded by the per-instance stateLock; nothing blocking runs under it.

SmartLib does not null-check its ad listeners while a session runs. The wrapper therefore registers proxies with SmartLib once and forwards to whatever listeners are set at the time an event arrives, so that detaching a listener never hands SmartLib a null.

  • Field Details

    • STATE_IDLE

      public static final int STATE_IDLE
      The Wrapper is IDLE. This is the state after creation
      See Also:
    • STATE_STARTING

      public static final int STATE_STARTING
      The Wrapper is starting or renewing a session.
      See Also:
    • STATE_READY

      public static final int STATE_READY
      The Wrapper is ready. This means that there's an ongoing session with a token.
      See Also:
  • Method Details

    • getState

      public int getState()
      Get the current state of the wrapper.
      Returns:
      the state of the wrapper. One of the SessionWrapper.STATE_* constants.
    • notifyLayerSwitch

      public void notifyLayerSwitch(int bitrate)
    • notifyStallStart

      public void notifyStallStart()
    • notifyFirstImage

      public void notifyFirstImage()
    • notifyResume

      public void notifyResume()
    • notifyPause

      public void notifyPause()
    • notifySeek

      public void notifySeek(long from, long to)
    • notifyStallEnd

      public void notifyStallEnd(boolean isPlaying)