/ fm / liveswitch / Stream
Class: Stream
fm.liveswitch.Stream
Hierarchy
-
↳ Stream
↳↳ MediaStream
↳↳ DataStream
Implements
Table of contents
Constructors
Methods
- addOnDirectionChange
- addOnStateChange
- changeDirection
- getDirection
- getDynamicProperties
- getDynamicValue
- getEncryptionPolicy
- getExternalId
- getId
- getLabel
- getLocalDirection
- getLocalReceive
- getLocalSend
- getMediaDescriptionId
- getRemoteDirection
- getRemoteReceive
- getRemoteSend
- getState
- getTag
- getTransportInfo
- getType
- getTypeString
- removeOnDirectionChange
- removeOnStateChange
- setDynamicValue
- setExternalId
- setLocalDirection
- setLocalReceive
- setLocalSend
- setRemoteDirection
- setTag
- unsetDynamicValue
Constructors
constructor
+ new Stream(): Stream
Returns: Stream
Inherited from: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:17
Methods
addOnDirectionChange
▸ addOnDirectionChange(value
: IAction0): void
Registers a handler to be called when the stream direction changes.
Stream direction indicates the direction of media flow. For example:
- A stream in an SFU upstream connection has a direction of
SendOnly
. - A stream in an SFU downstream connection has a direction of
ReceiveOnly
. - A stream in an MCU connection has a direction of
SendReceive
if it is attached to both local and remote media. If it is only attached to local media, it has a direction ofSendOnly
. If it is only attached to remote media, it has a direction ofReceiveOnly
.
The direction of a stream can change over its lifecycle. For example: - An update to an SFU upstream connection might instruct the stream to stop sending audio or video frames. In this case, the direction of the stream will change to
Inactive
. - An update to an SFU downstream connection might cause it to stop receiving audio or video frames. In this case, the direction of the stream will change to
Inactive
. - An update to an MCU upstream connection might instruct the stream to stop sending audio or video frames. In this case, the following occurs:
- If the direction of the stream was
SendOnly
, then the direction changes toInactive
. - If the direction of the stream was
ReceiveOnly
, then the direction changes toSendReceive
.
- If the direction of the stream was
- An update to an MCU upstream connection might instruct it to stop receiving audio or video frames. In this case, the following occurs:
- If the direction of the stream was
ReceiveOnly
, then the direction changes toInactive
. - If the direction of the stream was
SendReceive
, then the direction changes toSendOnly
.
An event handler bound to the change in direction can be used to update the UI accordingly so the user is aware of the change in the state of the application.
- If the direction of the stream was
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:159
addOnStateChange
▸ addOnStateChange(value
: IAction0): void
Registers a handler to be called once the connection state changes.
This method can track the state of the connection and can be used to display the current status of the connection to the user, add or remove media views in the UI, and handle retry logic if the connection fails.
The connection object passes to the handler which allows access to the current connection state through the connection.getState()
method. This returns a ConnectionState
enum.
Possible connection states are the following:
New
: The connection object has been created, but open has not yet been called.Initializing
: The connection is initializing, but no connection attempts have been made.Connecting
: The connection is being established.Connected
: The connection has been successfully established.Failing
: The connection has encountered an error and is cleaning up.Failed
: The connection encountered an error and has cleaned up.Closing
: The connection has been instructed to close and is cleaning up.Closed
: The connection has been instructed to close and has cleaned up.
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:29
changeDirection
▸ changeDirection(newDirection
: StreamDirection): Error
Parameters:
Name | Type |
---|---|
newDirection |
StreamDirection |
Returns: Error
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:37
getDirection
▸ getDirection(): StreamDirection
Gets the Media Direction of a stream as a StreamDirection
enumerator. The following stream direction values are defined:
SendReceive
: A stream that can send and can receive.SendOnly
: A stream that can send.ReceiveOnly
: A stream that can receive.Inactive
: A stream that cannot send or receive.Unset
: A stream direction has not been set.
Returns: StreamDirection
The Media Direction as a StreamDirection
enumerator.
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:54
getDynamicProperties
▸ getDynamicProperties(): Hash<string, Object>
Gets all dynamic properties on this instance.
Returns: Hash<string, Object>
Inherited from: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:37
getDynamicValue
▸ getDynamicValue(key
: string): Object
Gets a property value from the local cache.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The property key. This key is used internally only, but should be namespaced to avoid conflict with third-party extensions. |
Returns: Object
The stored value, if found; otherwise null.
Inherited from: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:58
getEncryptionPolicy
▸ getEncryptionPolicy(): EncryptionPolicy
Returns: EncryptionPolicy
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:41
getExternalId
▸ getExternalId(): string
Returns: string
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:98
getId
▸ getId(): string
Returns: string
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:94
getLabel
▸ getLabel(): string
Returns: string
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:102
getLocalDirection
▸ getLocalDirection(): StreamDirection
Returns: StreamDirection
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:106
getLocalReceive
▸ getLocalReceive(): boolean
Checks whether the local peer supports receiving media on this stream. Returns true if the local peer supports receiving media on this stream and false otherwise.
Use this method to determine if a stream is used for receiving media.
Returns: boolean
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:62
getLocalSend
▸ getLocalSend(): boolean
Checks whether the local peer on this stream supports sending media on this stream. Returns true if the local peer supports sending media and false otherwise.
Use this method to determine if a stream is used for sending media or only receiving media.
Returns: boolean
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:74
getMediaDescriptionId
▸ getMediaDescriptionId(): string
Gets the media description ID of this stream.
The media description ID is only available once a connection is opened with this stream, because it is obtained from the local SDP description of this stream.
Returns: string
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:114
getRemoteDirection
▸ getRemoteDirection(): StreamDirection
Returns: StreamDirection
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:90
getRemoteReceive
▸ getRemoteReceive(): boolean
Returns: boolean
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:82
getRemoteSend
▸ getRemoteSend(): boolean
Returns: boolean
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:86
getState
▸ getState(): StreamState
Returns: StreamState
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:11
getTag
▸ getTag(): string
Returns: string
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:118
getTransportInfo
▸ getTransportInfo(): TransportInfo
Returns: TransportInfo
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:183
getType
▸ getType(): StreamType
Returns: StreamType
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:122
getTypeString
▸ getTypeString(): string
Returns: string
Overrides: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:4
removeOnDirectionChange
▸ removeOnDirectionChange(value
: IAction0): void
Removes a handler to be called when the stream direction changes.
Stream direction indicates the direction of media flow. For example:
- A stream in an SFU upstream connection has a direction of
SendOnly
. - A stream in an SFU downstream connection has a direction of
ReceiveOnly
. - A stream in an MCU connection has a direction of
SendReceive
if it is attached to both local and remote media. If it is only attached to local media, it has a direction ofSendOnly
. If it is only attached to remote media, it has a direction ofReceiveOnly
.
The direction of a stream can change over its lifecycle. For example: - An update to an SFU upstream connection might instruct the stream to stop sending audio or video frames. In this case, the direction of the stream will change to
Inactive
. - An update to an SFU downstream connection might cause it to stop receiving audio or video frames. In this case, the direction of the stream will change to
Inactive
. - An update to an MCU upstream connection might instruct the stream to stop sending audio or video frames. In this case, the following occurs:
- If the direction of the stream was
SendOnly
, then the direction changes toInactive
. - If the direction of the stream was
ReceiveOnly
, then the direction changes toSendReceive
.
- If the direction of the stream was
- An update to an MCU upstream connection might instruct it to stop receiving audio or video frames. In this case, the following occurs:
- If the direction of the stream was
ReceiveOnly
, then the direction changes toInactive
. - If the direction of the stream was
SendReceive
, then the direction changes toSendOnly
.
- If the direction of the stream was
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:179
removeOnStateChange
▸ removeOnStateChange(value
: IAction0): void
Parameters:
Name | Type |
---|---|
value |
IAction0 |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:33
setDynamicValue
▸ setDynamicValue(key
: string, value
: Object): void
Sets a property value in the local cache.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The property key. This key is used internally only, but should be namespaced to avoid conflict with third-party extensions. |
value |
Object | The property value. This can be any object that needs to be stored for future use. |
Returns: void
Inherited from: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:95
setExternalId
▸ setExternalId(value
: string): void
Parameters:
Name | Type |
---|---|
value |
string |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:126
setLocalDirection
▸ setLocalDirection(value
: StreamDirection): void
Parameters:
Name | Type |
---|---|
value |
StreamDirection |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:130
setLocalReceive
▸ setLocalReceive(receiveEnabled
: boolean): void
Parameters:
Name | Type |
---|---|
receiveEnabled |
boolean |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:66
setLocalSend
▸ setLocalSend(sendEnabled
: boolean): void
Parameters:
Name | Type |
---|---|
sendEnabled |
boolean |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:78
setRemoteDirection
▸ setRemoteDirection(value
: StreamDirection): void
Parameters:
Name | Type |
---|---|
value |
StreamDirection |
Returns: void
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:134
setTag
▸ setTag(value
: string): void
Parameters:
Name | Type |
---|---|
value |
string |
Returns: void
Implementation of: IExternalStream
Defined in: Generated/TypeScript/fm.liveswitch/Stream.ts:138
unsetDynamicValue
▸ unsetDynamicValue(key
: string): boolean
Removes a property value from the local cache. Returns true if the value was removed and returns false otherwise.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The property key. This key is used internally only, but should be namespaced to avoid conflict with third-party extensions. |
Returns: boolean
true
if the value was removed; otherwise, false
.
Inherited from: Dynamic
Defined in: Generated/TypeScript/fm.liveswitch/Dynamic.ts:122