Skip to content

Latest commit

 

History

History
2749 lines (1522 loc) · 65.4 KB

api.md

File metadata and controls

2749 lines (1522 loc) · 65.4 KB

MediaServer

setCertificate

Set new DTLS certificates. Should be called before any Endpoint is established.

Parameters

  • cert String path of the certificate file
  • key String path of the key file

getDTLSFingerprint

Get local DTLS fingerprint for this Media Server.

Returns String

terminate

Close async handlers so nodejs can exit nicely Only call it once!

enableLog

Enable or disable log level traces

Parameters

enableDebug

Enable or disable debug level traces

Parameters

setPortRange

Set UDP port range for encpoints

Parameters

  • minPort Integer Min UDP port
  • maxPort Integer Max UDP port [Optional]

setAffinity

Set node uv loop cpu affinity

Parameters

  • cpu Integer CPU core number

Returns boolean true if operation was successful

setThreadName

Set node uv loop thread name.

Useful for debugging or tracing. Currently only supported on Linux, fails on other platforms. Length is limited to 16 bytes.

Parameters

  • name String thread name to set

Returns boolean true if operation was successful

enableUltraDebug

Enable or disable ultra debug level traces

Parameters

createEndpoint

Create a new endpoint object

Parameters

  • ip String External IP address of server, to be used when announcing the local ICE candidate

  • params Object Creation parameters

    • params.packetPoolSize Number Packet pool size

Returns Endpoint The new created endpoing

createOffer

Helper that creates an offer from capabilities It generates a random ICE username and password and gets media server dtls fingerprint

Parameters

  • capabilities Object Media capabilities as required by SDPInfo.create

Returns SDPInfo SDP offer

createRecorder

Create a new MP4 recorder

Parameters

  • filename String Path and filename of the recorded mp4 file

  • params Object Recording parameters (Optional)

    • params.refresh Number Periodically refresh an intra on all video tracks (in ms)
    • params.waitForIntra Boolean Wait until first video iframe is received to start recording media
    • params.timeShift Number Buffer time in ms. Recording must be splicity started with flush() call
    • params.disableHints Boolean Disable recording hint tracks. Note that this file won't be playable with the Player object;

Returns Recorder

createPlayer

Create a new MP4 player

Parameters

  • filename String Path and filename of the mp4 file

Returns Player

createStreamer

Create a new RTP streamer

Returns Streamer

createActiveSpeakerDetector

Create a new Active Speaker Detecrtor

createRefresher

Create a new stream refresher

Parameters

  • period type Intra refresh period

createIncomingStreamTrackReader

Create a new incoming track reader

Parameters

  • intraOnly type Intra frames only
  • minPeriod type Minimum period between frames

createEmulatedTransport

Create a new emulated transport from pcap file

Parameters

  • pcap
  • filename String PCAP filename and path

getDefaultCapabilities

Get the default media server capabilities for each supported media type

Returns Object Object containing the capabilities by media ("audio","video")

SDPManager

Extends Emitter

SDPManager

getState

Get current SDP offer/answer state

Returns String one of "initial","local-offer","remote-offer","stabable".

getTransport

Returns the Transport object created by the SDP O/A

Returns Transport

stop

Stop manager and associated tranports

stopped

SDPManager stopped event

Parameters

ActiveSpeakerMultiplexer

Extends Emitter

ActiveSpeakerMultiplexer multiplex multiple incoming audio tracks into fewer outgoing tracks based on voice activity.

setMinChangePeriod

Set minimum period between active speaker changes

Parameters

setMaxAccumulatedScore

Maximux activity score accumulated by an speaker

Parameters

setNoiseGatingThreshold

Minimum db level to not be considered as muted

Parameters

setMinActivationScore

Set minimum activation score to be electible as active speaker

Parameters

addSpeaker

Add incoming track for speaker detection

Parameters

removeSpeaker

Remove track from speaker detection

Parameters

stop

Stop this transponder, will dettach the OutgoingStreamTrack

activespeakerchanged

ActiveSpeakerMultiplexer new active speaker detected event

Parameters

noactivespeaker

ActiveSpeakerMultiplexer active speaker removed event

Parameters

stopped

ActiveSpeakerMultiplexer stopped event

Parameters

RecorderTrack

Extends Emitter

Track of the recorder associated to an incoming strem track

getId

Get recorder track id

getTrack

Get incoming stream track

Returns IncomingStreamTrack

isMuted

Check if the track is muted or not

Returns boolean muted

mute

Mute/Unmute track This operation will not change the muted state of the stream this track belongs too.

Parameters

  • muting boolean if we want to mute or unmute

stop

Stop recording this track

stopped

RecorderTrack stopped event

Parameters

Refresher

Extends Emitter

Periodically request an I frame on all incoming stream or tracks

restart

Restart refreshing interval

Parameters

  • period
  • timeout Number Refresh pedior in ms

add

Add stream or track to request

Parameters

remove

Remove stream or track to request

Parameters

stop

Stop refresher

refreshing

Refresher event to indicate that refesh is taking place

Parameters

stopped

Refresher stopped event

Parameters

Streamer

Extends Emitter

An streamer allows to send and receive plain RTP over udp sockets. This allows both to bridge legacy enpoints or integrate streaming/broadcasting services.

createSession

Creates a new streaming session from a media description

Parameters

  • media MediaInfo Media codec description info

  • params Object Network parameters [Optional]

    • params.local Object Local parameters

      • params.local.port Number receiving port
    • params.remote Object Remote parameters

      • params.remote.ip String Sending ip address
      • params.remote.port Number Sending port
    • params.noRTCP Number Disable sending rtcp

Returns StreamerSession The new streaming session

stop

Stop all streaming sessions and frees resources

stopped

Streamer stopped event

Parameters

ActiveSpeakerDetector

Extends Emitter

ActiveSpeakerDetector accumulate received voice activity and fires an event when it changes

setMinChangePeriod

Set minimum period between active speaker changes

Parameters

setMaxAccumulatedScore

Maximux activity score accumulated by an speaker

Parameters

setNoiseGatingThreshold

Minimum db level to not be considered as muted

Parameters

setMinActivationScore

Set minimum activation score to be electible as active speaker

Parameters

addSpeaker

Add incoming track for speaker detection

Parameters

removeSpeaker

Remove track from speaker detection

Parameters

  • track IncomingStreamTrakc

stop

Stop this transponder, will dettach the OutgoingStreamTrack

activespeakerchanged

ActiveSpeakerDetector new active speaker detected event

Parameters

stopped

ActiveSpeakerDetector stopped event

Parameters

Transponder

Extends Emitter

Transponder copies data from an incoming track to an outgoing track and allows stream modifications

setIncomingTrack

Set incoming track

Parameters

  • track IncomingStreamTrack Incoming track to attach to

  • layers Object [Optional] Only applicable to video tracks

    • layers.encodingId String rid value of the simulcast encoding of the track (default: first encoding available)
    • layers.spatialLayerId Number The spatial layer id to send to the outgoing stream (default: max layer available)
    • layers.temporalLayerId Number The temporaral layer id to send to the outgoing stream (default: max layer available)
    • layers.maxSpatialLayerId Number Max spatial layer id (default: unlimited)
    • layers.maxTemporalLayerId Number Max temporal layer id (default: unlimited)
  • smooth Boolean Wait until next valid frame before switching to the new encoding

appendH264ParameterSets

Set out of band negotiated H264 parameter sets

Parameters

  • sprop String H264 parameters sets

getMedia

Get Transponder media type

Returns String "audio"|"video"

getIncomingTrack

Get attached track

Returns IncomingStreamTrack track

getAvailableLayers

Get available encodings and layers

Returns Object

getAvailableLayersAsync

Get available encodings and layers

Returns Object

isMuted

Check if the track is muted or not

Returns boolean muted

mute

Mute/Unmute track This operation will not change the muted state of the stream this track belongs too.

Parameters

  • muting boolean if we want to mute or unmute

setIntraOnlyForwarding

Set intra frame forwarding mode

Parameters

  • intraOnlyForwarding boolean true if you want to forward only intra frames, false otherwise

setTargetBitrate

Select encoding and temporal and spatial layers based on the desired bitrate. This operation will unmute the transponder if it was mutted and it is possible to select an encoding and layer based on the target bitrate and options.

Parameters

  • target

  • options Object Options for configuring algorithm to select best encoding/layers [Optional]

    • options.traversal Object Traversal algorithm "default", "spatial-temporal", "zig-zag-spatial-temporal", "temporal-spatial", "zig-zag-temporal-spatial" [Default: "default"]
    • options.strict Object If there is not a layer with a bitrate lower thatn target, stop sending media [Default: false]
    • options.smooth Object When going to a lower simulcast layer, keep the higher one visible [Default: true]
  • bitrate Number

Returns Number Current bitrate of the selected encoding and layers, it aslo incudes the selected layer indexes and available layers as properties of the Number object.

setTargetBitrateAsync

Select encoding and temporal and spatial layers based on the desired bitrate. This operation will unmute the transponder if it was mutted and it is possible to select an encoding and layer based on the target bitrate and options.

Parameters

  • target

  • options Object Options for configuring algorithm to select best encoding/layers [Optional]

    • options.traversal Object Traversal algorithm "default", "spatial-temporal", "zig-zag-spatial-temporal", "temporal-spatial", "zig-zag-temporal-spatial" [Default: "default"]
    • options.strict Object If there is not a layer with a bitrate lower thatn target, stop sending media [Default: false]
    • options.smooth Object When going to a lower simulcast layer, keep the higher one visible [Default: true]
  • bitrate Number

Returns any Promise<{Number}> Current bitrate of the selected encoding and layers, it aslo incudes the selected layer indexes and available layers as properties of the Number object.

select

Select the simulcast encoding layer and svc layers

Parameters

  • layers Object [Optional] Only applicable to video tracks

    • layers.encodingId String rid value of the simulcast encoding of the track (default: the current one)
    • layers.spatialLayerId Number The spatial layer id to send to the outgoing stream (default: max layer available)
    • layers.temporalLayerId Number The temporaral layer id to send to the outgoing stream (default: max layer available)
    • layers.maxSpatialLayerId Number Max spatial layer id (default: unlimited)
    • layers.maxTemporalLayerId Number Max temporal layer id (default: unlimited)
  • smooth Boolean Wait until next valid frame before switching to the new encoding

getSelectedEncoding

Return the encoding that is being forwarded

Returns String encodingId

getSelectedSpatialLayerId

Return the spatial layer id that is being forwarded

Returns Number spatial layer id

getSelectedTemporalLayerId

Return the temporal layer id that is being forwarded

Returns Number temporal layer id

getSelectedLayer

Get current selected layer info

Returns Object

getSelectedLayerAsync

Get current selected layer info

Returns Object

selectLayer

Select SVC temporatl and spatial layers. Only available for VP9 media.

Parameters

  • spatialLayerId Number The spatial layer id to send to the outgoing stream
  • temporalLayerId Number The temporaral layer id to send to the outgoing stream

setMaximumLayers

Set maximum statial and temporal layers to be forwrarded. Base layer is always enabled.

Parameters

  • maxSpatialLayerId Number Max spatial layer id
  • maxTemporalLayerId Number Max temporal layer id

stop

Stop this transponder, will dettach the OutgoingStreamTrack

muted

Transponder muted event

Parameters

muted

Transponder muted event

Parameters

stopped

Transponder stopped event

Parameters

Recorder

Extends Emitter

MP4 recorder that allows to record several streams/tracks on a single mp4 file

getFilename

Get recording filename

Returns String

getStartTime

Get recording filename

Returns Date

isTimeShifted

Is the recording time shifted?

Returns Boolean

flush

Start recording time shiftt buffer.

Parameters

  • filename String Override filename [Optional]

record

Start recording and incoming

Parameters

Returns Array<RecorderTrack>

mute

Mute/Unmute all tracks This operation will not change the muted state of the stream this track belongs too.

Parameters

  • muting boolean if we want to mute or unmute

stop

Stop recording and close file. NOTE: File will be flsuh async,

Returns undefined TODO: return promise when flush is ended

started

Recorder started event. This event will be triggered when the first media frame is being recorded.

Parameters

  • recorder Recorder
  • timestamp Number Timestamp of the first frame in milliseconds

stopped

Recorder stopped event

Parameters

Player

Extends Emitter

MP4 recorder that allows to record several streams/tracks on a single mp4 file

getTracks

Get all the tracks

Returns Array<IncomingStreamTrack> Array of tracks

getAudioTracks

Get an array of the media stream audio tracks

Returns Array<IncomingStreamTrack> Array of tracks

getVideoTracks

Get an array of the media stream video tracks

Returns Array<IncomingStreamTrack> Array of tracks

play

Starts playback

Parameters

  • params Object

    • params.repeat Object Repeat playback when file is ended

resume

Resume playback

pause

Pause playback

seek

Start playback from given time

Parameters

stop

Stop playing and close file

ended

Playback ended event

Parameters

stopped

Player stopped event

Parameters

StreamerSession

Extends Emitter

Represent the connection between a local udp port and a remote one. It sends and/or receive plain RTP data.

getLocalPort

Get the local rtp/udp port

Returns Number port number

setRemote

Set the rempte rtp/udp ip and port

Parameters

  • ip
  • port

getIncomingStreamTrack

Returns the incoming stream track associated with this streaming session

Returns IncomingStreamTrack

getOutgoingStreamTrack

Returns the outgoing stream track associated with this streaming session

Returns OutgoingStreamTrack

stop

Closes udp socket and frees resources

stopped

StreamerSession stopped event

Parameters

on

Add event listener

Parameters

Returns Transport

once

Add event listener once

Parameters

Returns IncomingStream

off

Remove event listener

Parameters

Returns Transport

IncomingStream

Extends Emitter

The incoming streams represent the recived media stream from a remote peer.

getId

The media stream id as announced on the SDP

Returns String

getStreamInfo

Get the stream info object for signaling the ssrcs and stream info on the SDP from the remote peer

Returns StreamInfo The stream info object

getStats

Get statistics for all tracks in the stream

See IncomingStreamTrack.getStats for information about the stats returned by each track.

getStatsAsync

Get statistics for all tracks in the stream

See IncomingStreamTrack.getStats for information about the stats returned by each track.

Returns any Promise<{Map,Object}> Map with stats by trackId

isMuted

Check if the stream is muted or not

Returns boolean muted

getTrack

Get track by id

Parameters

Returns IncomingStreamTrack requested track or null

getTracks

Get all the tracks

Parameters

  • type String The media type (Optional)

Returns Array<IncomingStreamTrack> Array of tracks

getAudioTracks

Get an array of the media stream audio tracks

Returns Array<IncomingStreamTrack> Array of tracks

getVideoTracks

Get an array of the media stream video tracks

Returns Array<IncomingStreamTrack> Array of tracks

createTrack

Create new track from a TrackInfo object and add it to this stream

Parameters

  • trackInfo TrackInfo Track info object

Returns IncomingStreamTrack

reset

Reset ssrc state of all tracks

isAttached

Return if the stream is attached or not

stop

Removes the media strem from the transport and also detaches from any attached incoming stream

muted

IncomingStream stopped event

Parameters

attached

IncomingStream attached event

Parameters

attached

IncomingStream attached event

Parameters

detached

IncomingStream detached event

Parameters

track

IncomingStreamTrack added to stream

Parameters

stopped

IncomingStream stopped event

Parameters

IncomingStreamTrackMirrored

Extends Emitter

Mirror incoming stream from another endpoint. Used to avoid inter-thread synchronization when attaching multiple output streams.

getStats

Get stats for all encodings from the original track

Returns Map<String, Object> Map with stats by encodingId

getStatsAsync

Get stats for all encodings from the original track

Returns Map<String, Object> Map with stats by encodingId

getActiveLayers

Get active encodings and layers ordered by bitrate of the original track

Returns Object Active layers object containing an array of active and inactive encodings and an array of all available layer info

getActiveLayersAsync

Get active encodings and layers ordered by bitrate of the original track

Returns Object Active layers object containing an array of active and inactive encodings and an array of all available layer info

getId

Get track id as signaled on the SDP

getMediaId

Get track media id (mid)

getTrackInfo

Get track info object

Returns TrackInfo Track info

getSSRCs

Return ssrcs associated to this track

Returns Object

getMedia

Get track media type

Returns String "audio"|"video"

getEncodings

Get all track encodings Internal use, you'd beter know what you are doing before calling this method

Returns Array<Object> encodings *

getEncoding

Get encoding by id Internal use, you'd beter know what you are doing before calling this method

Parameters

  • encodingId String encoding Id,

Returns Object encoding *

getDefaultEncoding

Get default encoding Internal use, you'd beter know what you are doing before calling this method

Returns Object encoding *

isAttached

Return if the track is attached or not

attached

Signal that this track has been attached. Internal use, you'd beter know what you are doing before calling this method

refresh

Request an intra refres on all sources

detached

Signal that this track has been detached. Internal use, you'd beter know what you are doing before calling this method

isMuted

Check if the track is muted or not

Returns boolean muted

stop

Removes the track from the incoming stream and also detaches any attached outgoing track or recorder

attached

IncomingStreamTrackMirrored attached event

Parameters

attached

IncomingStreamTrackMirrored attached event

Parameters

detached

IncomingStreamTrackMirrored dettached event

Parameters

detached

IncomingStreamTrackMirrored dettached event

Parameters

stopped

IncomingStreamTrack stopped event

Parameters

stopped

IncomingStreamTrack stopped event

Parameters

OutgoingStream

Extends Emitter

The incoming streams represent the media stream sent to a remote peer.

getStats

Get statistics for all tracks in the stream

See OutgoingStreamTrack.getStats for information about the stats returned by each track.

getStatsAsync

Get statistics for all tracks in the stream

See OutgoingStreamTrack.getStats for information about the stats returned by each track.

isMuted

Check if the stream is muted or not

Returns boolean muted

attachTo

Listen media from the incoming stream and send it to the remote peer of the associated transport.

Parameters

  • incomingStream IncomingStream The incoming stream to listen media for

  • layers Object [Optional] Only applicable to video tracks

    • layers.encodingId String rid value of the simulcast encoding of the track (default: first encoding available)
    • layers.spatialLayerId Number The spatial layer id to send to the outgoing stream (default: max layer available)
    • layers.temporalLayerId Number The temporaral layer id to send to the outgoing stream (default: max layer available)
    • layers.maxSpatialLayerId Number Max spatial layer id (default: unlimited)
    • layers.maxTemporalLayerId Number Max temporal layer id (default: unlimited)

Returns Array<Transponder> Track transponders array

detach

Stop listening for media

getStreamInfo

Get the stream info object for signaling the ssrcs and stream info on the SDP to the remote peer

Returns StreamInfo The stream info object

getId

The media stream id as announced on the SDP

Returns String

getTracks

Get all the tracks

Parameters

  • type String The media type (Optional)

Returns Array<OutgoingStreamTrack> Array of tracks

getTrack

Get track by id

Parameters

Returns IncomingStreamTrack requested track or null

getAudioTracks

Get an array of the media stream audio tracks

Returns (Array | OutgoingStreamTracks) Array of tracks

getVideoTracks

Get an array of the media stream video tracks

Returns (Array | OutgoingStreamTrack) Array of tracks

createTrack

Create new track from a TrackInfo object and add it to this stream

Parameters

  • params (Object | TrackInfo | String) Params plain object, StreamInfo object or media type

    • params.id String? Stream track id

    • params.mediaId String? Stream track media id (mid)

    • params.media String? Media type ("audio" or "video")

    • params.ssrcs Object? Override the generated ssrcs for this track

      • params.ssrcs.media Number? ssrc for the track
      • params.ssrcs.rtx Number? ssrc for the rtx video track
  • trackInfo TrackInfo Track info object

Returns OutgoingStream The new outgoing stream

Returns OugoingStreamTrack

muted

OutgoingStreamTrack stopped event

Parameters

track

OutgingStreamTrack created

Parameters

  • outgoingStreamTrack OutgingStreamTrack

stopped

OutgoingStream stopped event

Parameters

PeerConnectionServer

Extends Emitter

Manager of remote peer connecion clients

stop

Stop the peerconnection server, will not stop the transport created by it

transport

New managed transport has been created by a remote peer connection client

Parameters

  • transport Transport An initialized transport

stopped

PeerConnectionServer stopped event

Parameters

EmulatedTransport

Extends Emitter

An emulated transport reads data from a unencrypted pcap file (typically from a transport dump), and acts like if it was a live transport from a remote peer. You must create the incoming streams as signaled on the remote SDP as any incoming RTP with an unknown ssrc will be ignored. The emulated transport does not allow creating outgoing streams.

setRemoteProperties

Set remote RTP properties

Parameters

  • rtp (Object | SDPInfo) Object param containing media information for audio and video

    • rtp.audio MediaInfo Audio media info
    • rtp.video MediaInfo Video media info

createIncomingStream

Create an incoming stream object from the media stream info objet

Parameters

  • info StreamInfo Contains the ids and ssrcs of the stream to be created

Returns IncomingStream The newly created incoming stream object

play

Starts playback

Parameters

resume

Resume playback

pause

Pause playback

seek

Start playback from given time

Parameters

stop

Stop transport and all the associated incoming and outgoing streams

stopped

Transport stopped event

Parameters

Endpoint

Extends Emitter

An endpoint represent an UDP server socket. The endpoint will process STUN requests in order to be able to associate the remote ip:port with the registered transport and forward any further data comming from that transport. Being a server it is ICE-lite.

setAffinity

Set cpu affinity for udp send/recv thread.

Parameters

  • cpu Number CPU core or -1 to reset affinity.

Returns boolean true if operation was successful

setDefaultSRTProtectionProfiles

setDefaultSRTProtectionProfiles

Parameters

  • srtpProtectionProfiles
  • profiles String Colon delimited list of SRTP protection profile names

setRawTx

[EXPERIMENTAL] See TypeScript typings for usage.

Parameters

  • options

setThreadName

Set name for udp send/recv thread.

Useful for debugging or tracing. Currently only supported on Linux, fails on other platforms. Length is limited to 16 bytes.

Parameters

  • name String thread name to set

Returns boolean true if operation was successful

setPriority

Set thread priority for udp send/recv thread. NOTE: User needs to have the appropiate rights to increase the thread priority in ulimit

Parameters

  • priority Number 0:Normal -19:RealTime

Returns boolean true if operation was successful

setIceTimeout

Set ICE timeout for outgoing ICE binding requests

Parameters

  • timeout Number Ammount of time in milliseconds between ICE binding requests

getLocalPort

Get port at which UDP socket is bound

createTransport

Create a new transport object and register it with the remote ICE username and password

Parameters

  • remoteInfo (Object | SDPInfo) Remote ICE and DTLS properties

    • remoteInfo.ice (Object | ICEInfo) Remote ICE info, containing the username and password.
    • remoteInfo.dtls (Object | DTLSInfo) Remote DTLS info
    • remoteInfo.candidates (Array.CandidateInfo | Array.Object) Remote ICE candidate info
  • localInfo Object Local ICE and DTLS properties (optional)

    • localInfo.ice ICEInfo Local ICE info, containing the username and password. Local ICE candidates list is not really used at all.
    • localInfo.dtls DTLSInfo Local DTLS info
    • localInfo.candidates Array.CandidateInfo Local candidate info
  • options Object Dictionary with transport properties

    • options.disableSTUNKeepAlive boolean Disable ICE/STUN keep alives, required for server to server transports
    • options.srtpProtectionProfiles String Colon delimited list of SRTP protection profile names
    • options.overrideBWE boolean Override BWE reported by REMB
    • options.disableREMB boolean Disable REMB BWE calculation.
    • options.prefferDTLSSetupActive boolean Preffer setting local DTLS setup to 'active' if remote is 'actpass'.

Returns Transport New transport object

getLocalCandidates

Get local ICE candidates for this endpoint. It will be shared by all the transport associated to this endpoint.

Returns Array.CandidateInfo

getDTLSFingerprint

Get local DTLS fingerprint for this endpoint. It will be shared by all the transport associated to this endpoint.

Returns String

createOffer

Helper that creates an offer from capabilities It generates a random ICE username and password and gets endpoint fingerprint

Parameters

  • capabilities Object Media capabilities as required by SDPInfo.create

Returns SDPInfo SDP offer

createPeerConnectionServer

Create new peer connection server to manage remote peer connection clients

Parameters

  • tm TransactionManager
  • capabilities Object Same as SDPInfo.answer capabilites

Returns PeerConnectionServer

createActiveSpeakerMultiplexer

Create new active speaker multiplexer for given outgoing tracks

Parameters

  • streamOrTracks (OutgoingStream | Array.OutgoingStreamTrack) Outgoing stream or outgoing stream track array to be multiplexed

Returns ActiveSpeakerMultiplexer

mirrorIncomingStream

Mirror incoming stream from another endpoint. Used to avoid inter-thread synchronization when attaching multiple output streams. The endpoint will cache the cucrrent mirrored streams and return an already existing object if calling this method twice with same stream.

Parameters

Returns IncomingStream mirrored stream.

mirrorIncomingStreamTrack

Mirror incoming stream track from another endpoint. Used to avoid inter-thread synchronization when attaching multiple output tracks. The endpoint will cache the cucrrent mirrored tracks and return an already existing object if calling this method twice with same track.

Parameters

Returns IncomingStreamTrackMirrored mirrored track.

createSDPManager

Create new SDP manager, this object will manage the SDP O/A for you and produce a suitable trasnport.

Parameters

  • sdpSemantics String Type of sdp plan "unified-plan" or "plan-b"
  • capabilities Object Capabilities objects

Returns SDPManager

stop

Stop the endpoint UDP server and terminate any associated transport

stopped

Endpoint stopped event

Parameters

Transport

Extends Emitter

A transport represent a connection between a local ICE candidate and a remote set of ICE candidates over a single DTLS session. The transport object will internally allocate the ICE and DTLS information of the local side in order to signal it to the remote side and establish the connection. Each transport has a set of incoming and outgoing streams that allow to send or receive RTP streams to the remote peer. You must create the incoming streams as signaled on the remote SDP as any incoming RTP with an unknown ssrc will be ignored. When you create an outgoing stream, the transport will allocate internally the ssrcs for the different RTP streams in order to avoid collision. You will be able to retrieve that information from the streams object in order to be able to announce them on the SDP sent to the remote side. In order to decide how to route your streams you must attach the outgoing streams from one transport to the incoming streams of other (or same) transport.

dump

Dump incoming and outgoint rtp and rtcp packets into a pcap file

Parameters

  • filename String Filename of the pcap file

  • options Object Dump parameters (optional)

    • options.incoming Boolean Dump incomoning RTP data
    • options.outgoing Boolean Dump outgoing RTP data
    • options.rtcp Boolean Dump rtcp RTP data
    • options.rtpHeadersOnly Boolean Dump only rtp headers and first 16 bytes of payload for rtp packets
    • options.bwe Boolean Dump bwe stats to a different file (.pcap->.csv)

stopDump

Stop dumping transport rtp and rtcp packets

getStats

Get transport stats

  • senderSideEstimationBitrate : Sneder side estimation bitrate (if available)
  • ice : ICE related stats
  • requestsSent : Number of ice requests sent
  • requestsReceived : Number of ice requests received
  • responsesSent : Number of ice responses sent
  • responsesReceived : Number of ice responses received

Returns Object stats

restartICE

Restart ICE on transport object

Parameters

  • remoteICE (Object | ICEInfo) Remote ICE info, containing the username and password.
  • localICE (Object | ICEInfo) Local ICE info, containing the username and password [Optional]

Returns ICEInfo Local ICE info

getAvailableOutgoingBitrate

Get available outgoing bitrate in bps.

Returns Nummber

getEstimatedBitrate

Get bandwidth estimation in bps.

Returns Nummber

getTotalSentBitrate

Get current sent bitrate

Returns Nummber

setBandwidthProbing

Enable bitrate probing. This will send padding only RTX packets to allow bandwidth estimation algortithm to probe bitrate beyonf current sent values. The ammoung of probing bitrate would be limited by the sender bitrate estimation and the limit set on the setMaxProbing Bitrate. Note that this will only work on browsers that supports RTX and transport wide cc.

Parameters

  • probe Boolen

setMaxProbingBitrate

Set the maximum bitrate to be used if probing is enabled.

Parameters

enableSenderSideEstimation

Enable or disable calculation of sender side estimation if transport wide cc has been negotiated

Parameters

setRemoteOverrideBitrate

Override the bitrate sent by REMB to the remote sender. The transport must be constructed with teh override bwe option, and transport wide cc must not be offered.

Parameters

setProbingBitrateLimit

Do not allow probing to increase sent bitrate above certain limit

Parameters

setLocalProperties

Set local RTP properties

Parameters

  • rtp (Object | SDPInfo) Object param containing media information for audio and video

    • rtp.audio MediaInfo Audio media info
    • rtp.video MediaInfo Video media info

setRemoteProperties

Set remote RTP properties

Parameters

  • rtp (Object | SDPInfo) Object param containing media information for audio and video

    • rtp.audio MediaInfo Audio media info
    • rtp.video MediaInfo Video media info

getDTLSState

Get current dtls state for transport

Returns String DTLS connection state as per the w3c spec "new", "connecting", "connected", "closed", "failed"

getLocalDTLSInfo

Get transport local DTLS info

Returns DTLSInfo DTLS info object

getLocalICEInfo

Get transport local ICE info

Returns ICEInfo ICE info object

getLocalCandidates

Get local ICE candidates for this transport

Returns Array.CandidateInfo

getRemoteDTLSInfo

Get transport remote DTLS info

Returns DTLSInfo DTLS info object

getRemoteICEInfo

Get transport remote ICE info

Returns ICEInfo ICE info object

getRemoteCandidates

Get remote ICE candidates for this transport

Returns Array.CandidateInfo

addRemoteCandidate

Register a remote candidate info. Only needed for ice-lite to ice-lite endpoints

Parameters

  • candidate CandidateInfo

Returns boolean Wheter the remote ice candidate was alrady presnet or not

addRemoteCandidates

Register an array remote candidate info. Only needed for ice-lite to ice-lite endpoints

Parameters

  • candidates Array.CandidateInfo

createOutgoingStream

Create new outgoing stream in this transport

Parameters

  • params (Object | StreamInfo | String) Params plain object, StreamInfo object or stream id

    • params.audio (Array<Object> | Object | boolean) Add audio track to the new stream

      • params.audio.id Object? Stream track id (default: "audio")

      • params.audio.ssrcs Number? Override the generated ssrcs for this track

        • params.audio.ssrcs.media Number? ssrc for the audio track
    • params.id Object? Stream id, an UUID will be generated if not provided

    • params.video (Array<Object> | Object | boolean) Add video track to the new stream

      • params.video.id Object? Stream track id (default: "video")

      • params.video.ssrcs Object? Override the generated ssrcs for this track

        • params.video.ssrcs.media Number? ssrc for the video track
        • params.video.ssrcs.rtx Number? ssrc for the rtx video track

Returns OutgoingStream The new outgoing stream

createOutgoingStreamTrack

Create new outgoing stream in this transport

Parameters

  • media String Track media type "audio" or "video"

  • params Object? Track parameters

    • params.id Object? Stream track id

    • params.mediaId Object? Stream track media id (mid)

    • params.ssrcs Number? Override the generated ssrcs for this track

      • params.ssrcs.media Number? ssrc for the media track
      • params.ssrcs.rtx Number? ssrc for the rtx track

Returns OutgoingStreamTrack The new outgoing stream track

createIncomingStream

Create an incoming stream object from the media stream info objet

Parameters

  • info (StreamInfo | Object | String) Contains the ids and ssrcs of the stream to be created

Returns IncomingStream The newly created incoming stream object

getIncomingStreams

Get all the incoming streams in the transport

Returns Array<IncomingStreams>

getIncomingStream

Get incoming stream

Parameters

  • streamId String the stream ID

Returns IncomingStream

getOutgoingStreams

Get all the outgoing streams in the transport

Returns Array<OutgoingStreams>

getOutgoingStream

Get incoming stream

Parameters

  • streamId String the stream ID

Returns IncomingStream

createIncomingStreamTrack

Create new incoming stream in this transport. TODO: Simulcast is still not supported

Parameters

  • media String Track media type "audio" or "video"

  • params Object? Track parameters

    • params.id Object? Stream track id

    • params.mediaId Object? Stream track media id (mid)

    • params.ssrcs Number? Override the generated ssrcs for this track

      • params.ssrcs.media Number? ssrc for the media track
      • params.ssrcs.rtx Number? ssrc for the rtx track

Returns IncomingStreamTrack The new incoming stream track

publish

Create new outgoing stream and attach to the incoming stream

Parameters

  • incomingStream IncomingStream the incoming stream to be published in this transport

Returns OutgoingStream The new outgoing stream

stop

Stop transport and all the associated incoming and outgoing streams

icetimeout

ICE timoute event. Fired when no ICE request ar received for 30 seconds.

Parameters

dtlsstate

DTLS State change event

Parameters

  • dtlsstate String DTLS connection state as per the w3c spec "new", "connecting", "connected", "closed", "failed"
  • transport Transport

remoteicecandidate

ICE remote candidate activation event. This event fires when ICE candidate has correctly being checked out and we start using it for sending.

Parameters

  • candidate CandidateInfo The ip and port of the remote ICE candidate that is in use by the transport
  • transport Transport

targetbitrate

Transport sender side estimation bitrate target udpate

Parameters

  • targetBitrate Integer
  • bandwidthEstimation Integer
  • totalBitrate Integer
  • transport Transport

outgoingtrack

New outgoing stream track added to transport

Parameters

incomingtrack

New incoming stream track added to transport

Parameters

stopped

Transport stopped event

Parameters

parseIPv4

parse a dot-separated IPv4 into a normalized address as u32be

Parameters

  • ip

stopped

AudioDecoder stopped event

Parameters

  • frame Object
  • reader IncomingStreamTrackReader

stopped

AudioDecoder stopped event

Parameters

  • reader IncomingStreamTrackReader

parseCIDR

parse a CIDR into a normalized [address as u32be, prefix length] tuple

Parameters

  • cidr

OutgoingStreamTrack

Extends Emitter

Audio or Video track of a media stream sent to a remote peer

getId

Get track id as signaled on the SDP

getMediaId

Get track media id (mid)

getMedia

Get track media type

Returns String "audio"|"video"

getTrackInfo

Get track info object

Returns TrackInfo Track info

getStats

Get stats for all encodings

You will get stats for media and rtx sources (if used):

  • timestmap : timestamp on when this stats where created
  • media : mediaStats,
  • rtx : rtxStats,
  • remb : remote estimated bitate (if remb is in use)
  • numPackets : number of rtp packets sent
  • numPacketsDelta : number of rtp packets sent during last second
  • bitrate : Bitrate for media stream only in bps
  • total : Accumulated bitrate for media and rtx streams in bps

The stats objects will privide the follwing info for each source

  • numFrames : total recevied frames
  • numFramesDelta : recevied frames during last second
  • numPackets : number of rtp packets sent
  • numPacketsDelta : number of rtp packets sent during last second
  • numRTCPPackets : number of rtcp packsets sent
  • totalBytes : total rtp sent bytes
  • totalRTCPBytes : total rtp sent bytes
  • bitrate : average bitrate sent during last second in bps
  • reportCount : number of RTCP receiver reports received
  • reportCountDelta : number of RTCP receiver reports received during last second
  • reportedLostCount : total packet loses reported
  • reportedLostCountDelta : packet losses reported in last second
  • reportedFractionLost : fraction loss media reported during last second
  • reportedJitter : last reported jitter buffer value

Returns Map<String, Object> Map with stats by encodingId

getStatsAsync

Get stats for all encodings

You will get stats for media and rtx sources (if used):

  • timestmap : timestamp on when this stats where created
  • media : mediaStats,
  • rtx : rtxStats,
  • remb : remote estimated bitate (if remb is in use)
  • numPackets : number of rtp packets sent
  • numPacketsDelta : number of rtp packets sent during last second
  • bitrate : Bitrate for media stream only in bps
  • total : Accumulated bitrate for media and rtx streams in bps

The stats objects will privide the follwing info for each source

  • numFrames : total recevied frames
  • numFramesDelta : recevied frames during last second
  • numPackets : number of rtp packets sent
  • numPacketsDelta : number of rtp packets sent during last second
  • numRTCPPackets : number of rtcp packsets sent
  • totalBytes : total rtp sent bytes
  • totalRTCPBytes : total rtp sent bytes
  • bitrate : average bitrate sent during last second in bps
  • reportCount : number of RTCP receiver reports received
  • reportCountDelta : number of RTCP receiver reports received during last second
  • reportedLostCount : total packet loses reported
  • reportedLostCountDelta : packet losses reported in last second
  • reportedFractionLost : fraction loss media reported during last second
  • reportedJitter : last reported jitter buffer value

Returns Map<String, Object> Map with stats by encodingId

getSSRCs

Return ssrcs associated to this track

Returns Object

isMuted

Check if the track is muted or not

Returns boolean muted

isAttached

Check if this outgoing stream track is alredy attached to an incoming stream track.

Returns Boolean true if attached, false otherwise

createTransponder

Create a transponder if not already attached or return current one.

Returns Transponder Track transponder object

attachTo

Listen media from the incoming stream track and send it to the remote peer of the associated transport. This will stop any previous transpoder created by a previous attach.

Parameters

  • incomingStreamTrack IncomingStreamTrack The incoming stream to listen media for

  • layers Object [Optional] Only applicable to video tracks

    • layers.encodingId String rid value of the simulcast encoding of the track (default: first encoding available)
    • layers.spatialLayerId Number The spatial layer id to send to the outgoing stream (default: max layer available)
    • layers.temporalLayerId Number The temporaral layer id to send to the outgoing stream (default: max layer available)
    • layers.maxSpatialLayerId Number Max spatial layer id (default: unlimited)
    • layers.maxTemporalLayerId Number Max temporal layer id (default: unlimited)

Returns Transponder Track transponder object

detach

Stop forwarding any previous attached track. This will set the transponder inconming track to null

getTransponder

Get attached transpoder for this track

Returns Transponder Attached transpoder or null if not attached

stop

Removes the track from the outgoing stream and also detaches from any attached incoming track

remb

OutgoingStreamTrack remb event

Parameters

muted

OutgoingStreamTrack stopped event

Parameters

muted

IncomingStreamTrack stopped event

Parameters

muted

IncomingStreamTrack stopped event

Parameters

muted

IncomingStreamTrack stopped event

Parameters

stopped

OutgoingStreamTrack stopped event

Parameters

IncomingStreamTrack

Extends Emitter

Audio or Video track of a remote media stream

getStatsAsync

Get stats for all encodings

For each encoding you will get stats for media and rtx sources (if used):

  • media : Stats for the media stream
  • rtx : Stats for the rtx retransmission stream
  • rtt : Round Trip Time in ms
  • waitTime : "min","max" and "avg" packet waiting times in rtp buffer before delivering them
  • bitrate : Bitrate for media stream only in bps
  • total : Accumulated bitrate for media and rtx streams in bps
  • remb : Estimated avialable bitrate for receving (only avaailable if not using tranport wide cc)
  • timestamp: When this stats was generated, in order to save workload, stats are cached for 200ms
  • simulcastIdx : Simulcast layer index based on bitrate received (-1 if it is inactive).
  • lostPackets : Accumulated lost packets for media and rtx strems
  • numPackets : Accumulated packets for media and rtx strems
  • lostPacketsRatio : Lost packets ratio

The stats objects will provide the following info for each source

  • numFrames : total recevied frames
  • numFramesDelta : recevied frames during last second
  • lostPackets : total lost packkets
  • lostPacketsDelta : Lost/out of order packets during last second
  • lostPacketsMaxGap : max total consecutieve packets lossed during last second
  • lostPacketsGapCount : number of packet looses bursts during last second
  • dropPackets : droppted packets by media server
  • numPackets : number of rtp packets received
  • numPacketsDelta : number of rtp packets received during last seconds
  • numRTCPPackets : number of rtcp packsets received
  • totalBytes : total rtp received bytes
  • totalRTCPBytes : total rtp received bytes
  • totalPLIs : total PLIs sent
  • totalNACKs : total NACk packets sent
  • bitrate : average bitrate received during last second in bps
  • skew : difference between NTP timestamp and RTP timestamps at sender (from RTCP SR)
  • drift : ratio between RTP timestamps and the NTP timestamp and at sender (from RTCP SR)
  • clockRate : RTP clockrate
  • frameDelay : Average frame delay during the last second
  • frameDelayMax : Max frame delay during the last second
  • frameCaptureDelay : Average bewtween local reception time and sender capture one (Absolute capture time must be negotiated)
  • frameCaptureDelayMax : Max bewtween local reception time and sender capture one (Absolute capture time must be negotiated)
  • width : video width
  • height : video height
  • layers : Information about each spatial/temporal layer (if present)
    • spatialLayerId : Spatial layer id
    • temporalLayerId : Temporatl layer id
    • totalBytes : total rtp received bytes for this layer
    • numPackets : number of rtp packets received for this layer
    • bitrate : average bitrate received during last second for this layer
    • targetBitrate : Signaled target bitrate on the VideoLayersAllocation header
    • targetWidth : Signaled target width on the VideoLayersAllocation header
    • targetHeight : Signaled target height on the VideoLayersAllocation header
    • targetFps : Signaled target fps on the VideoLayersAllocation header

Returns any Promise<{Map<String,Object>}> Promise resolving to a map with stats by encodingId

getStats

Get stats for all encodings

For each encoding you will get stats for media and rtx sources (if used):

  • media : Stats for the media stream
  • rtx : Stats for the rtx retransmission stream
  • rtt : Round Trip Time in ms
  • waitTime : "min","max" and "avg" packet waiting times in rtp buffer before delivering them
  • bitrate : Bitrate for media stream only in bps
  • total : Accumulated bitrate for media and rtx streams in bps
  • remb : Estimated avialable bitrate for receving (only avaailable if not using tranport wide cc)
  • timestamp: When this stats was generated, in order to save workload, stats are cached for 200ms
  • simulcastIdx : Simulcast layer index based on bitrate received (-1 if it is inactive).
  • lostPackets : Accumulated lost packets for media and rtx strems
  • numPackets : Accumulated packets for media and rtx strems
  • lostPacketsRatio : Lost packets ratio

The stats objects will provide the following info for each source

  • numFrames : total recevied frames
  • numFramesDelta : recevied frames during last second
  • lostPackets : total lost packkets
  • lostPacketsDelta : Lost/out of order packets during last second
  • lostPacketsMaxGap : max total consecutieve packets lossed during last second
  • lostPacketsGapCount : number of packet looses bursts during last second
  • dropPackets : droppted packets by media server
  • numPackets : number of rtp packets received
  • numPacketsDelta : number of rtp packets received during last seconds
  • numRTCPPackets : number of rtcp packsets received
  • totalBytes : total rtp received bytes
  • totalRTCPBytes : total rtp received bytes
  • totalPLIs : total PLIs sent
  • totalNACKs : total NACk packets sent
  • bitrate : average bitrate received during last second in bps
  • skew : difference between NTP timestamp and RTP timestamps at sender (from RTCP SR)
  • drift : ratio between RTP timestamps and the NTP timestamp and at sender (from RTCP SR)
  • clockRate : RTP clockrate
  • frameDelay : Average frame delay during the last second
  • frameDelayMax : Max frame delay during the last second
  • frameCaptureDelay : Average bewtween local reception time and sender capture one (Absolute capture time must be negotiated)
  • frameCaptureDelayMax : Max bewtween local reception time and sender capture one (Absolute capture time must be negotiated)
  • width : video width
  • height : video height
  • layers : Information about each spatial/temporal layer (if present)
    • spatialLayerId : Spatial layer id
    • temporalLayerId : Temporatl layer id
    • totalBytes : total rtp received bytes for this layer
    • numPackets : number of rtp packets received for this layer
    • bitrate : average bitrate received during last second for this layer

Returns Map<String, Object> Map with stats by encodingId

getActiveLayers

Get active encodings and layers ordered by bitrate

Returns Object Active layers object containing an array of active and inactive encodings and an array of all available layer info

getActiveLayersAsync

Get active encodings and layers ordered by bitrate

Returns any Promise<{Object}> Active layers object containing an array of active and inactive encodings and an array of all available layer info

getId

Get track id as signaled on the SDP

getMediaId

Get track media id

getTrackInfo

Get track info object

Returns TrackInfo Track info

getSSRCs

Return ssrcs associated to this track

Returns Object

getMedia

Get track media type

Returns String "audio"|"video"

getEncodings

Get all track encodings Internal use, you'd beter know what you are doing before calling this method

Returns Array<Object> encodings *

getEncoding

Get encoding by id Internal use, you'd beter know what you are doing before calling this method

Parameters

  • encodingId String encoding Id,

Returns Object encoding *

getDefaultEncoding

Get default encoding Internal use, you'd beter know what you are doing before calling this method

Returns Object encoding *

attached

Signal that this track has been attached. Internal use, you'd beter know what you are doing before calling this method

refresh

Request an intra refres on all sources

reset

Reset state of incoming sources

isMuted

Check if the track is muted or not

Returns boolean muted

isAttached

Return if the track is attached or not

detached

Signal that this track has been detached. Internal use, you'd beter know what you are doing before calling this method

setH264ParameterSets

Store out of band h264 properties for this track

Parameters

  • sprop String Base64 encoded parameters from SDP

hasH264ParameterSets

Check if track has out of band h264 properties

Returns Boolean

getH264ParameterSets

Get out of band h264 parameters from this track

Returns Boolean

setMaxWaitTime

Override the maximum period of time to wait for an out of order or rtx packet

Parameters

  • maxWaitTime Number max wait time in ms (default: 0 if rtx is not supported or rtt based)

resetMaxWaitTime

Remove override for the maximum period of time to wait for an out of order or rtx packet

stop

Removes the track from the incoming stream and also detaches any attached outgoing track or recorder

encoding

IncomingStreamTrack new encoding event

Parameters

encoding

IncomingStreamTrack new encoding event

Parameters

attached

IncomingStreamTrack attached event

Parameters

detached

IncomingStreamTrack detached event

Parameters

stopped

IncomingStreamTrack stopped event

Parameters

withSocket

Create a dedicated socket on each query, no caching... it's inefficient but more robust, we don't need to give user a way to invalidate the cache, we don't need to be careful when managing refs, subscriptions...

Parameters

  • callback

IncomingStreamTrackSimulcastAdapter

Extends Emitter

Bundle multiple video track as if they were a single simulcast video track

addTrack

Add video track to the simulcast adapter

Parameters

removeTrack

Remove video track to the simulcast adapter

Parameters

getStats

Get stats for all encodings from the original track

Returns Map<String, Object> Map with stats by encodingId

getStatsAsync

Get stats for all encodings from the original track

Returns any Promise<{Map<String,Object>}> Map with stats by encodingId

getActiveLayers

Get active encodings and layers ordered by bitrate of the original track

Returns Object Active layers object containing an array of active and inactive encodings and an array of all available layer info

getActiveLayersAsync

Get active encodings and layers ordered by bitrate of the original track

Returns Object Active layers object containing an array of active and inactive encodings and an array of all available layer info

getId

Get track id as signaled on the SDP

getMediaId

Get track media id (mid)

getTrackInfo

Get track info object

Returns TrackInfo Track info

getSSRCs

Return ssrcs associated to this track

Returns Object

getMedia

Get track media type

Returns String "audio"|"video"

getEncodings

Get all track encodings Internal use, you'd beter know what you are doing before calling this method

Returns Array<Object> encodings *

getEncoding

Get encoding by id Internal use, you'd beter know what you are doing before calling this method

Parameters

  • encodingId String encoding Id,

Returns Object encoding *

getDefaultEncoding

Get default encoding Internal use, you'd beter know what you are doing before calling this method

Returns Object encoding *

isMuted

Check if the track is muted or not

Returns boolean muted

isAttached

Return if the track is attached or not

attached

Signal that this track has been attached. Internal use, you'd beter know what you are doing before calling this method

refresh

Request an intra refres on all sources

detached

Signal that this track has been detached. Internal use, you'd beter know what you are doing before calling this method

stop

Removes the track from the incoming stream and also detaches any attached outgoing track or recorder

extractOne

Parameters

  • list
  • name

collectRoutingInfoWithRoute

Continuation of collectRoutingInfo once a route has been selected (split to allow reusal from getInterfaceRawConfig).

Parameters

  • rtNetlink
  • ifindex number Interface
  • route
  • dst number Resolved next hop address for route