Package com.castlabs.sdk.broadpeak
Class SessionWrapper
java.lang.Object
com.castlabs.sdk.broadpeak.SessionWrapper
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
FieldsModifier and TypeFieldDescriptionstatic final intThe Wrapper is IDLE.static final intThe Wrapper is ready.static final intThe Wrapper is starting or renewing a session. -
Method Summary
Modifier and TypeMethodDescriptionThe config for the current sessionThe redirected url for the current sessionintgetState()getToken()The token for the current sessionvoidvoidnotifyLayerSwitch(int bitrate) voidvoidvoidnotifySeek(long from, long to) voidnotifyStallEnd(boolean isPlaying) voidvoidRenew a session.voidsetActive(boolean active) Set whether this wrapper is active or not.voidstartSession(Handler handler) Start the session.voidstopStreamingSession(Integer statusCode) Stops the ongoing sessionvoidwaitForState(int targetState, int timeoutMs) Block execution until the desired state is reached
-
Field Details
-
STATE_IDLE
public static final int STATE_IDLEThe Wrapper is IDLE. This is the state after creation- See Also:
-
STATE_STARTING
public static final int STATE_STARTINGThe Wrapper is starting or renewing a session.- See Also:
-
STATE_READY
public static final int STATE_READYThe Wrapper is ready. This means that there's an ongoing session with a token.- See Also:
-
-
Method Details
-
getState
public int getState()- Returns:
- the state of the wrapper. One of the SessionWrapper.STATE_* constants.
-
startSession
Start the session. This is an async operation.- Parameters:
handler- the handler in which to post the initialization job
-
renew
Renew a session. This is an async operation.- Parameters:
handler- the handler in which to post the renew job
-
stopStreamingSession
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 fortimeoutMs- time to wait- Throws:
BroadpeakSessionException- if the state couldn't be reached within the specified amount of timeIOException- if the thread is interrupted while waiting
-
getToken
The token for the current session- Returns:
- the token for the current session
-
getSessionUrl
The redirected url for the current session- Returns:
- the redirected url for the current session
-
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)
-