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

ToiResourceService

Class Summary

Extends:
  • ToiEventTarget

This service expose the free system resources. This service is just for tracking the resources and notifying the application as and when there is any change in free resources through ToiResourceObserver.

Technical Preview:

This interface is a TECHNICAL PREVIEW, it may change.

Service:

This is a service and can be accessed through toi.resourceService
  • Methods
  • Members
  • Types
  • Events

Method Summary

denyActivity ( id )

This method gets called if the application is not able to grant an activity for whatever reason.

getActivities ( )  → Array.<ToiResourceService.ToiActivityInfo>

Get all the active activities.

getResources ( )  → Array.<ToiResourceService.ToiResourceInfo>

Get the information of all the system resources.

getSessionActivities ( sessionId )  → Array.<ToiResourceService.ToiActivityInfo>

Get list of activities in a session.

grantActivity ( id )

This method notifies the resource service that a requested activity can proceed.

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

ToiActivityId (Type: number)

Activity identifier.

  • INVALID_ACTIVITY_ID
ToiActivityState (Type: enum)

State identifier used to identify the activity state.

  • STATE_ACTIVE
  • STATE_INACTIVE
  • STATE_PENDING
ToiActivityType (Type: enum)
  • ACTIVITY_CONSUMER
  • ACTIVITY_PLAYER
  • ACTIVITY_PRODUCER
  • ACTIVITY_RECORDER
ToiAvailability (Type: enum)

Indicates the availability/Status of a resource.

  • AVAILABILITY_ALLOCATED
  • AVAILABILITY_FREE
  • AVAILABILITY_PARTLY_ALLOCATED
ToiResource (Type: enum)

Different kind of system resources.

  • RESOURCE_DECRYPTOR
  • RESOURCE_DISK_READER
  • RESOURCE_DISK_WRITER
  • RESOURCE_NETWORK_INPUT
  • RESOURCE_NETWORK_OUTPUT
  • RESOURCE_TRANSCODER
  • RESOURCE_TUNER
ToiResourceName (Type: string)

Name of the resource.

ToiResourceType (Type: enum)

Different types of resources.

  • RESOURCE_TYPE_DYNAMIC_ALLOCATION
  • RESOURCE_TYPE_DYNAMIC_POOL
  • RESOURCE_TYPE_ENUMERABLE

Events

  • ON_ACTIVITIES_ADDED
  • ON_ACTIVITIES_CHANGED
  • ON_ACTIVITIES_REMOVED
  • ON_RESOURCES_ADDED
  • ON_RESOURCES_CHANGED
  • ON_RESOURCES_REMOVED

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.

denyActivity ( id )

This method gets called if the application is not able to grant an activity for whatever reason.

Parameters:

Name Type Description
id ToiResourceService.ToiActivityId

Pending Activity that is denied by the application.

Throws:

ToiInvalidArgumentException

Raised if Activity Id is not valid.

ToiInvalidPreconditionException

Raised if current state of activity is not pending.

getActivities ( )  → Array.<ToiResourceService.ToiActivityInfo>

Get all the active activities.

Returns:

Information of all the active activities.

Type: Array.<ToiResourceService.ToiActivityInfo>
getResources ( )  → Array.<ToiResourceService.ToiResourceInfo>

Get the information of all the system resources.

Returns:

All available and allocated resources.

Type: Array.<ToiResourceService.ToiResourceInfo>
getSessionActivities ( sessionId )  → Array.<ToiResourceService.ToiActivityInfo>

Get list of activities in a session.

Parameters:

Name Type Description
sessionId ToiMediaSession.ToiSessionId

SessionId of the session of which activity info is required.

Throws:

ToiInvalidArgumentException

Raised if SessionId is not valid.

Returns:

Information of all the active activities.

Type: Array.<ToiResourceService.ToiActivityInfo>
grantActivity ( id )

This method notifies the resource service that a requested activity can proceed.

Parameters:

Name Type Description
id ToiResourceService.ToiActivityId

Activity that is being granted.

Throws:

ToiInvalidArgumentException

Raised if Activity Id is not valid.

ToiInvalidPreconditionException

Raised if current state of activity is not pending.

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.

Members

ON_ACTIVITIES_ADDED (Type: ToiResourceActivitiesAddedEvent) (value = 1503) (static, constant)

This is an Event identifier for ToiResourceActivitiesAddedEvent.

Tells the observer that a set of activities is added.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_ACTIVITIES_ADDED.
ON_ACTIVITIES_CHANGED (Type: ToiResourceActivitiesChangedEvent) (value = 1505) (static, constant)

This is an Event identifier for ToiResourceActivitiesChangedEvent.

Tells the observer that an activity has changed state.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_ACTIVITIES_CHANGED.
ON_ACTIVITIES_REMOVED (Type: ToiResourceActivitiesRemovedEvent) (value = 1504) (static, constant)

This is an Event identifier for ToiResourceActivitiesRemovedEvent.

Tells the observer that a set of activities is removed.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_ACTIVITIES_REMOVED.
ON_RESOURCES_ADDED (Type: ToiResourceResourcesAddedEvent) (value = 1500) (static, constant)

This is an Event identifier for ToiResourceResourcesAddedEvent.

Tells the observer that a set of available resources is added. Considering that generally resources of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL and ToiResourceService.RESOURCE_TYPE_ENUMERABLE are added to the list of resources maintained by resource manager during the box bootup, before any observer is registered to get the event notifications from resource manager, OnResourcesAdded event notification may not be received for the resources of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL and ToiResourceService.RESOURCE_TYPE_ENUMERABLE. Resources of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION are instantiated and added to resource manager much later so observers will get notification of this event only for the resources ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_RESOURCES_ADDED.
ON_RESOURCES_CHANGED (Type: ToiResourceResourcesChangedEvent) (value = 1502) (static, constant)

This is an Event identifier for ToiResourceResourcesChangedEvent.

Tells the observer that a set of available resources has changed.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_RESOURCES_CHANGED.
ON_RESOURCES_REMOVED (Type: ToiResourceResourcesRemovedEvent) (value = 1501) (static, constant)

This is an Event identifier for ToiResourceResourcesRemovedEvent.

Tells the observer that a set of available resources is removed. Once added to resource manager, resources of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL and ToiResourceService.RESOURCE_TYPE_ENUMERABLE will never get removed, so this event is not applicable for the resources of type ToiResourceService.RESOURCE_TYPE_ENUMERABLE and ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL. This notification will be received by the observers only for the resources of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION, when these resources are destroyed and in turn removed from the list of resources manintained by resource manager.

This constant can be also be accessed from toi.consts.ToiResourceService.ON_RESOURCES_REMOVED.
ACTIVITY_CONSUMER (Type: ToiResourceService.ToiActivityType) (value = 3) (static, constant)

Consumer activity.

This constant can be also be accessed from toi.consts.ToiResourceService.ACTIVITY_CONSUMER.
ACTIVITY_PLAYER (Type: ToiResourceService.ToiActivityType) (value = 0) (static, constant)

Player activity.

This constant can be also be accessed from toi.consts.ToiResourceService.ACTIVITY_PLAYER.
ACTIVITY_PRODUCER (Type: ToiResourceService.ToiActivityType) (value = 2) (static, constant)

Producer activity.

This constant can be also be accessed from toi.consts.ToiResourceService.ACTIVITY_PRODUCER.
ACTIVITY_RECORDER (Type: ToiResourceService.ToiActivityType) (value = 1) (static, constant)

Recorder activity.

This constant can be also be accessed from toi.consts.ToiResourceService.ACTIVITY_RECORDER.
AVAILABILITY_ALLOCATED (Type: ToiResourceService.ToiAvailability) (value = 0) (static, constant)

The resource is allocated. This state is currently used for resources of type ToiResourceService.RESOURCE_TYPE_ENUMERABLE and ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION, or when the resource can't be instantiated any more for resource of ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL.

This constant can be also be accessed from toi.consts.ToiResourceService.AVAILABILITY_ALLOCATED.
AVAILABILITY_FREE (Type: ToiResourceService.ToiAvailability) (value = 2) (static, constant)

The resource is free.

This constant can be also be accessed from toi.consts.ToiResourceService.AVAILABILITY_FREE.
AVAILABILITY_PARTLY_ALLOCATED (Type: ToiResourceService.ToiAvailability) (value = 1) (static, constant)

This state is only for the resource of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL to indicate that the resource is partly allocated. It means part of resource of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL is instantiated to type ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION, but quota is still available to permit more instantiations. When it is not possible to instantiate more, state of ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL changes to ToiResourceService.AVAILABILITY_ALLOCATED.

This constant can be also be accessed from toi.consts.ToiResourceService.AVAILABILITY_PARTLY_ALLOCATED.
INVALID_ACTIVITY_ID (Type: ToiResourceService.ToiActivityId) (value = -1) (static, constant)

Invalid activity id definition.

This constant can be also be accessed from toi.consts.ToiResourceService.INVALID_ACTIVITY_ID.
RESOURCE_DECRYPTOR (Type: ToiResourceService.ToiResource) (value = 2) (static, constant)

Decryptor resources.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_DECRYPTOR.
RESOURCE_DISK_READER (Type: ToiResourceService.ToiResource) (value = 3) (static, constant)

Disk reader resources.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_DISK_READER.
RESOURCE_DISK_WRITER (Type: ToiResourceService.ToiResource) (value = 4) (static, constant)

Disk writer resources.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_DISK_WRITER.
RESOURCE_NETWORK_INPUT (Type: ToiResourceService.ToiResource) (value = 1) (static, constant)

Network input resource.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_NETWORK_INPUT.
RESOURCE_NETWORK_OUTPUT (Type: ToiResourceService.ToiResource) (value = 5) (static, constant)

Network output resource.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_NETWORK_OUTPUT.
RESOURCE_TRANSCODER (Type: ToiResourceService.ToiResource) (value = 6) (static, constant)

Transcoder resources.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_TRANSCODER.
RESOURCE_TUNER (Type: ToiResourceService.ToiResource) (value = 0) (static, constant)

Tuner resource.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_TUNER.
RESOURCE_TYPE_DYNAMIC_ALLOCATION (Type: ToiResourceService.ToiResourceType) (value = 2) (static, constant)

A dynamic resource that is instantiated when a resource of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL is allocated.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION.
RESOURCE_TYPE_DYNAMIC_POOL (Type: ToiResourceService.ToiResourceType) (value = 1) (static, constant)

A non enumerable or dynamic resource pool. When a resource is allocated from this pool it will cause instantiation of dynamic resource of type ToiResourceService.RESOURCE_TYPE_DYNAMIC_ALLOCATION.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_TYPE_DYNAMIC_POOL.
RESOURCE_TYPE_ENUMERABLE (Type: ToiResourceService.ToiResourceType) (value = 0) (static, constant)

Normal enumerable resource.

This constant can be also be accessed from toi.consts.ToiResourceService.RESOURCE_TYPE_ENUMERABLE.
STATE_ACTIVE (Type: ToiResourceService.ToiActivityState) (value = 0) (static, constant)

The activity has been granted resources and is active.

This constant can be also be accessed from toi.consts.ToiResourceService.STATE_ACTIVE.
STATE_INACTIVE (Type: ToiResourceService.ToiActivityState) (value = 1) (static, constant)

The activity has released all resources and is inactive.

This constant can be also be accessed from toi.consts.ToiResourceService.STATE_INACTIVE.
STATE_PENDING (Type: ToiResourceService.ToiActivityState) (value = 2) (static, constant)

The activity is pending grant from the application.

This constant can be also be accessed from toi.consts.ToiResourceService.STATE_PENDING.
ToiActivityInfo (Type: struct) (static)

Information about an activity such as current state and resources used.

Struct fields

Name Description
id

The activity identifier.

Type: ToiResourceService.ToiActivityId
resources

Required resources.

Type: Array.<ToiResourceService.ToiResourceInfo>
sessionId

The session the activity is using, -1 if not applicable.

Type: ToiMediaSession.ToiSessionId
state

The activity state.

Type: ToiResourceService.ToiActivityState
type

The activity type.

Type: ToiResourceService.ToiActivityType
url

The URL use for the activity. Empty string if not applicable.

Type: string

ToiResourceInfo (Type: struct) (static)

Information about a system resource.

Struct fields

Name Description
availability

The availability status of the resource.

Type: ToiResourceService.ToiAvailability
name

The Name of the resource. For eg, the resource ToiResourceService.RESOURCE_TUNER& can have Name that is tuner Number. Like "0", "1", "2", etc.

Type: ToiResourceService.ToiResourceName
resource

The system resource.

Type: ToiResourceService.ToiResource
sharedActivities

All the activities sharing this resource.

Type: Array.<ToiResourceService.ToiActivityId>
type

The system resource type.

Type: ToiResourceService.ToiResourceType

5.0.1

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