Class: Stream

Specifies a stream. A stream is a representation of a published stream in a session. When a client calls the Session.publish() method, a new stream is created. Properties of the Stream object provide information about the stream.

When a stream is added to a session, the Session object dispatches a streamCreatedEvent. When a stream is destroyed, the Session object dispatches a streamDestroyed event. The StreamEvent object, which defines these event objects, has a stream property, which is an array of Stream object. For details and a code example, see StreamEvent.

When a connection to a session is made, the Session object dispatches a sessionConnected event, defined by the SessionConnectEvent object. The SessionConnectEvent object has a streams property, which is an array of Stream objects pertaining to the streams in the session at that time. For details and a code example, see SessionConnectEvent.

Properties

Name Type Description
connection Connection The Connection object corresponding to the connection that is publishing the stream. You can compare this to the connection property of the Session object to see if the stream is being published by the local web page.
creationTime Number The timestamp for the creation of the stream. This value is calculated in milliseconds. You can convert this value to a Date object by calling new Date(creationTime), where creationTime is the creationTime property of the Stream object.
frameRate Number The publisher's capture target frame rate. Initially derived from the frameRate property passed to OT.initPublisher(). This property is only set if the publisher explicitly specifies a frame rate; otherwise, it is undefined. This value is updated when the publisher calls Publisher.setPreferredFrameRate().

Note: This value represents the publisher's current target capture frame rate, not the frame rate actually encoded or received by a subscriber. The encoded frame rate may still be lower due to bandwidth or CPU constraints, and the received frame rate can vary further based on network conditions. To get the real decoded frame rate for a subscriber, use the video.decodedFrameRate property returned by Subscriber.getStats().

hasCaptions Boolean Whether the stream has captions. This property can change if the publisher turns captions on or off (by calling the Publisher.publishCaptions() method). When this occurs, the Session object dispatches a streamPropertyChanged event (see StreamPropertyChangedEvent).
hasAudio Boolean Whether the stream has audio. This property can change if the publisher turns on or off audio (by calling Publisher.publishAudio()). When this occurs, the Session object dispatches a streamPropertyChanged event (see StreamPropertyChangedEvent).
hasVideo Boolean Whether the stream has video. This property can change if the publisher turns on or off video (by calling Publisher.publishVideo()). When this occurs, the Session object dispatches a streamPropertyChanged event (see StreamPropertyChangedEvent).
initials String The initials for the stream. Publishers can specify the initials to be displayed when the video is disabled. (See the initials property of the properties parameter passed into the OT.initPublisher() method.)
name String The name of the stream. Publishers can specify a name when publishing a stream (using the publish() method of the publisher's Session object).
streamId String The unique ID of the stream.
videoDimensions Object This object has two properties: width and height (both numbers). These represent the publisher's capture target resolution last signaled to the session. The value is broadcast to all participants via the signaling layer and is readable on both the publishing and subscribing clients.

The value is set initially from the resolution property passed to OT.initPublisher(). It is updated at runtime when the publisher's local <video> element detects a dimension change (for example, after a call to Publisher.setPreferredResolution(), a screen-sharing window resize, or a mobile device rotation).

Note: These values represent the publisher's capture target resolution, not the resolution actually encoded or received by a subscriber. The publisher may encode at a lower resolution due to bandwidth or CPU constraints, and subscribers using scalable video may receive an even lower resolution layer. To get the actual decoded resolution on the subscribing client, use Subscriber.videoWidth() and Subscriber.videoHeight().

When this property changes, the Session object dispatches a streamPropertyChanged event (see StreamPropertyChangedEvent).

videoType String The type of video — either "camera", "screen", or "custom". A "screen" video uses screen sharing on the publisher as the video source; for other videos, this property is set to "camera". A "custom" video uses a VideoTrack element as the video source on the publisher. (See the videoSource property of the options parameter passed into the OT.initPublisher() method.) The videoType is undefined when a stream is voice-only (see the Voice-only guide). This property can change if a stream published from a mobile device changes from a camera to a screen-sharing video type. When the video type changes, the Session object dispatches a streamPropertyChanged event (see StreamPropertyChangedEvent).