Package com.castlabs.sdk.broadpeak

# 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.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `STATE_IDLE`
  The Wrapper is IDLE.
  `static final int`
  `STATE_READY`
  The Wrapper is ready.
  `static final int`
  `STATE_STARTING`
  The Wrapper is starting or renewing a session.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `PlayerConfig`
  `getConfig()`
  The config for the current session
  `String`
  `getSessionUrl()`
  The redirected url for the current session
  `int`
  `getState()`
  `String`
  `getToken()`
  The token for the current session
  `void`
  `notifyFirstImage()`
  `void`
  `notifyLayerSwitch(int bitrate)`
  `void`
  `notifyPause()`
  `void`
  `notifyResume()`
  `void`
  `notifySeek(long from, long to)`
  `void`
  `notifyStallEnd(boolean isPlaying)`
  `void`
  `notifyStallStart()`
  `void`
  `renew(Handler handler)`
  Renew a session.
  `void`
  `setActive(boolean active)`
  Set whether this wrapper is active or not.
  `void`
  `startSession(Handler handler)`
  Start the session.
  `void`
  `stopStreamingSession(Integer statusCode)`
  Stops the ongoing session
  `void`
  `waitForState(int targetState, int timeoutMs)`
  Block execution until the desired state is reached

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### STATE_IDLE

    public static final int STATE_IDLE
    The Wrapper is IDLE. This is the state after creation
    See Also:
      - Constant Field Values

  - ### STATE_STARTING

    public static final int STATE_STARTING
    The Wrapper is starting or renewing a session.
    See Also:
      - Constant Field Values

  - ### 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:
      - Constant Field Values

- ## Method Details

  - ### getState

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

  - ### startSession

    public void startSession(Handler handler)
    Start the session. This is an async operation.
    Parameters:
      `handler` - the handler in which to post the initialization job

  - ### renew

    public void renew(Handler handler)
    Renew a session. This is an async operation.
    Parameters:
      `handler` - the handler in which to post the renew job

  - ### stopStreamingSession

    public void stopStreamingSession(@Nullable Integer statusCode)
    Stops the ongoing session
    Parameters:
      `statusCode` - the status code to use for stopping the session

  - ### waitForState

    public void waitForState(int targetState, int timeoutMs) throws BroadpeakSessionException, IOException
    Block execution until the desired state is reached
    Parameters:
      `targetState` - the state to wait for
      `timeoutMs` - time to wait
    Throws:
      `BroadpeakSessionException` - if the state couldn't be reached within the specified amount of time
      `IOException` - if the thread is interrupted while waiting

  - ### getToken

    @Nullable public String getToken()
    The token for the current session
    Returns:
      the token for the current session

  - ### getSessionUrl

    @Nullable public String getSessionUrl()
    The redirected url for the current session
    Returns:
      the redirected url for the current session

  - ### getConfig

    public PlayerConfig getConfig()
    The config for the current session
    Returns:
      the config for the current session

  - ### setActive

    public void setActive(boolean active)
    Set whether this wrapper is active or not. This is relevant for analytics reporting.
    Parameters:
      `active` - whether the wrapper shall be considered active

  - ### 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)