• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

ToiMediaSession

Class Summary

Extends:
  • ToiEventTarget
See also:
  • ToiMediaService
  • ToiMediaPlayer

Each media player generates a media session which can be accessed by any application through the ToiMediaService#openSession function. This allows other applications than the actual owner to get stream information, extract stream data, etc.

Sessions are created for calls to ToiMediaPlayer#open .

  • Methods
  • Members
  • Types
  • Events

Method Summary

getId ( )  → id

Get the session identifier.

getParameters ( names )  → Array.<ToiMediaSession.ToiParameterInfo>

Get the values of several parameters.

getState ( )  → state

Returns the current state of the media session.

getStreamInfo ( )  → info

Returns information about the stream handled by the session.

getType ( )  → type

Get the session type bitmask. Note that a session can combine the different type constants.

getUrl ( )  → url

Get the source URL of the session.

releaseInstance ( )

This method releases the resources used by this object and removes all registered observers. Upon return this object will no longer be available and must not be called.

Note that this method does not close the associated session.

This can only be done by calling ToiMediaPlayer#close .

setParameters ( parameters )

Set the values of multiple parameters at once. If an exception is raised, no parameters will be set.

Inherited Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Type Definitions

ToiParameterName (Type: string)

Parameter nems

ToiSessionId (Type: number)

The media session identifier type.

  • INVALID_SESSION_ID
ToiSessionType (Type: number)

Data type used for identifying media session types. This type should be used as a bitmask as defined below.

  • TYPE_CONSUMER
  • TYPE_PLAYER
  • TYPE_PRODUCER
  • TYPE_RECORDER
ToiState (Type: enum)

State identifier used to identify the media session state.

  • STATE_CLOSED
  • STATE_CONNECTING
  • STATE_FAILED
  • STATE_RUNNING
ToiStatus (Type: enum)

The status of a parameter.

  • STATUS_NO_PARAMETER
  • STATUS_OK
ToiStreamId (Type: number)

Data type used to identify a stream.

Events

  • ON_PARAMETER_CHANGED

Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

Inherited From:

  • ToiEventTarget#addEventListener

Parameters:

Name Type Description
type number

The event type of the event to subscribe to.

listener ToiEventListener

The JavaScript function that will receive events.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the application calls addEventListener with the same combination of type and listener twice.

getId ( )  → id

Get the session identifier.

Returns:

The session identifier.

Type: ToiMediaSession.ToiSessionId
getParameters ( names )  → Array.<ToiMediaSession.ToiParameterInfo>

Get the values of several parameters.

Parameters:

Name Type Description
names Array.<ToiMediaSession.ToiParameterName> (Or a single ToiMediaSession.ToiParameterName.)

A list of parameter names. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiSessionViolationException

Raised if the session is not open or is being closed.

Returns:

A list of the returned parameters. If a parameter does not exist (is not set), the status of the corresponding parameter is set to ToiMediaSession.STATUS_NO_PARAMETER.

Type: Array.<ToiMediaSession.ToiParameterInfo>
getState ( )  → state

Returns the current state of the media session.

Throws:

ToiSessionViolationException

If the session no longer exist a session violation exception is raised.

Returns:

The current session state.

Type: ToiMediaSession.ToiState
getStreamInfo ( )  → info

Returns information about the stream handled by the session.

Throws:

ToiNoDataException

If no information is yet available a no data exception is raised.

ToiSessionViolationException

If the session no longer exist a session violation exception is raised.

Returns:

Information about the stream.

Type: ToiMediaSession.ToiStreamInfo
getType ( )  → type

Get the session type bitmask. Note that a session can combine the different type constants.

Throws:

ToiSessionViolationException

If the session no longer exist a session violation exception is raised.

Returns:

The type of the session, e.g. ToiMediaSession.TYPE_PLAYER. This field is a bitmask.

Type: ToiMediaSession.ToiSessionType
getUrl ( )  → url

Get the source URL of the session.

Throws:

ToiSessionViolationException

If the session no longer exist a session violation exception is raised.

Returns:

The source URL of the session.

Type: string
releaseInstance ( )

This method releases the resources used by this object and removes all registered observers. Upon return this object will no longer be available and must not be called.

Note that this method does not close the associated session.

This can only be done by calling ToiMediaPlayer#close .

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Inherited From:

  • ToiEventTarget#removeEventListener

Parameters:

Name Type Description
type number

The event type of the event to remove the listener from.

listener ToiEventListener

The JavaScript function that was previously added as an event listener.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the listener has not previously been added.

setParameters ( parameters )

Set the values of multiple parameters at once. If an exception is raised, no parameters will be set.

Parameters:

Name Type Description
parameters Array.<ToiMediaSession.ToiParameter> (Or a single ToiMediaSession.ToiParameter.)

A list of parameters with name and value. A single element can be passed directly and does not need to be passed in an array.

Throws:

ToiInvalidArgumentException

Raised if an empty string is used as parameter name or a parameter value exceeds the maximum size.

ToiPermissionDeniedException

Raised if attempting to set an internal parameter.

ToiSessionViolationException

Raised if the session is not open or is being closed.

Members

ON_PARAMETER_CHANGED (Type: ToiMediaSession.ToiParameterChangedEvent) (value = 1900) (static, constant)

This is an Event identifier for ToiMediaSession.ToiParameterChangedEvent.

This constant can also be accessed from toi.consts.ToiMediaSession.ON_PARAMETER_CHANGED.
INVALID_SESSION_ID (Type: ToiMediaSession.ToiSessionId) (value = -1) (static, constant)

The invalid media session identifier definition.

This constant can also be accessed from toi.consts.ToiMediaSession.INVALID_SESSION_ID.
STATE_CLOSED (Type: ToiMediaSession.ToiState) (value = 3) (static, constant)

In ToiMediaSession.STATE_CLOSED the media session has been closed and will not be opened again.

This constant can also be accessed from toi.consts.ToiMediaSession.STATE_CLOSED.
STATE_CONNECTING (Type: ToiMediaSession.ToiState) (value = 0) (static, constant)

In ToiMediaSession.STATE_CONNECTING the media session is trying to connect to a media source. The session will not leave this state until it has received enough data to start playback, producing or recording. It is possible for a session to later return to this state if the source becomes temporarily unavailable, for instance due to network congestion.

This constant can also be accessed from toi.consts.ToiMediaSession.STATE_CONNECTING.
STATE_FAILED (Type: ToiMediaSession.ToiState) (value = 2) (static, constant)

In ToiMediaSession.STATE_FAILED the media session has permanently failed.

This constant can also be accessed from toi.consts.ToiMediaSession.STATE_FAILED.
STATE_RUNNING (Type: ToiMediaSession.ToiState) (value = 1) (static, constant)

In ToiMediaSession.STATE_RUNNING the media session is fully connected and has received enough data. Note that this state does not reveal any information about the playback position or pace.

This constant can also be accessed from toi.consts.ToiMediaSession.STATE_RUNNING.
STATUS_NO_PARAMETER (Type: ToiMediaSession.ToiStatus) (value = 1) (static, constant)

Parameter doesn't exists.

This constant can also be accessed from toi.consts.ToiMediaSession.STATUS_NO_PARAMETER.
STATUS_OK (Type: ToiMediaSession.ToiStatus) (value = 0) (static, constant)

Parameter exists and has value.

This constant can also be accessed from toi.consts.ToiMediaSession.STATUS_OK.
TYPE_CONSUMER (Type: ToiMediaSession.ToiSessionType) (value = 4) (static, constant)

Session is used for consuming a stream.

This constant can also be accessed from toi.consts.ToiMediaSession.TYPE_CONSUMER.
TYPE_PLAYER (Type: ToiMediaSession.ToiSessionType) (value = 1) (static, constant)

Session is used for playing a stream.

This constant can also be accessed from toi.consts.ToiMediaSession.TYPE_PLAYER.
TYPE_PRODUCER (Type: ToiMediaSession.ToiSessionType) (value = 8) (static, constant)

Session is used for producing a stream or local asset.

This constant can also be accessed from toi.consts.ToiMediaSession.TYPE_PRODUCER.
TYPE_RECORDER (Type: ToiMediaSession.ToiSessionType) (value = 2) (static, constant)

Session is used for recording a stream.

This constant can also be accessed from toi.consts.ToiMediaSession.TYPE_RECORDER.
ToiParameter (Type: struct) (static)

Data structure with parameter name and value.

Struct fields

Name Description
name

The parameter name.

Type: string
value

The parameter value.

Type: string

ToiParameterInfo (Type: struct) (static)

Data structure with parameter and its status.

Struct fields

Name Description
parameter

The parameter.

Type: ToiMediaSession.ToiParameter
status

The parameter status.

Type: ToiMediaSession.ToiStatus

ToiStreamInfo (Type: struct) (static)

Data structure with information about the stream handled by the session.

Struct fields

Name Description
programNumber

The selected program number. It can be non-zero even for single-program streams.

Type: number
transportStreamId

The Transport Stream Id; possible values are 0 - 65535.

Type: ToiMediaSession.ToiStreamId

Events

ON_PARAMETER_CHANGED ( )

This is an Event identifier for ToiMediaSession.ToiParameterChangedEvent.

Value: 1900

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.