varvideoElement=document.getElementsByTagName('video')[0];varchannel=phenix.Channels.createChannel({videoElement: videoElement,token: token,});channel.authorized.subscribe(function (authorized) {if (!authorized) {// Channel is unauthorized, skipping retry of start. Please provide a new token and invoke channel.start() }});channel.autoMuted.subscribe(function (autoMuted) {if (autoMuted) {// Show unmute button so a user-triggered action triggers channel.unmute() }});channel.autoPaused.subscribe(function (autoPaused) {if (autoPaused) {// Show play button so a user-triggered action triggers channel.play() }});
MediaStreamTrack API audio transform callback function. See Insertable Streams.
Creating an EdgeToken
To generate an EdgeToken you must have a channel ID or an alias.
Check out our EdgeAuth libraries and documentation for information on how to generate edge tokens on your backend. This is the recommended way to issue authentication tokens.
EdgeToken used to connect and authenticate to the platform and subscribe to a stream.
tokenExpiring
Observable(boolean)
Observable that returns tokenExpiring state.
videoElement
VideoElement
Video element that will show the stream.
Channel State
Role
Value
Description
Offline
1
Channel is in Offline state.
Starting
2
Channel is already starting, skipping retry of start.
Paused
3
Channel is paused, skipping retry of start. Please invoke play().
Playing
4
Channel is playing, skipping retry of start.
Recovering
5
Channel tries to recover from some state will retry to reconnect.
Reconnecting
6
Channel is reconnecting after being disconnected.
StandBy
7
Channel will try to connect to the stream in StandBy interval (15000ms).
Stopped
8
Channel is stopped, skipping retry of start.
Unauthorized
9
Channel is unauthorized, skipping retry of start. Please provide a new token and invoke start().
GeoRestricted
10
Channel is geo restricted, skipping retry of start. Please provide a new token and invoke start().
GeoBlocked
11
Channel is geo blocked, skipping retry of start. Please provide a new token and invoke start().
Error
12
Channel is not able to subscribe to stream due to a general failed subscription.
UnsupportedFeature
13
Channel is not supporting the requested feature on this browser. This can be due to browser limitations or missing configuration for a player for the requested capability.
letpublisher;navigator.mediaDevices.getUserMedia({video: true,audio: true}) .then(mediaStream=> {publisher=phenix.Publishers.createPublisher({mediaStream,token });publisherStateObservable=publisher.state.subscribe(function(state) {// Subscribe to publisher state to observe }); });
Options to publish to use when publishing to the channel
Create Publisher Options
Name
Type
Default Value
Description
mediaStream (required)
MediaStream
A stream of media content.
token (required)
String
PublishToken used to connect and authenticate to the platform and publish a stream.
name (optional)
String
randomly-generated value
The name of the stream.
Creating a PublishToken
To generate a PublishToken you must have a channel ID or an alias.
Check out our EdgeAuth libraries and documentation for information on how to generate edge tokens on your backend.
This is the recommended way to issue authentication tokens.
UNIX timestamp of the last known packet sent described by the candidate pair, not including STUN packets.
ssrc
Number
An integer which uniquely identifies the source of the RTP stream.
mediaType
String
Kind/Media type of the stream.
timestamp
Number
UNIX time stamp of when the statistics is captured.
bitrate
Number
The number of bits per second that can be transmitted.
bytesSent
Number
Bytes sent.
packetsSent
Number
Packets sent.
retransmittedBytesSent
Number
Total number of frames decoded successfully for this media source.
codec
String
Codec used to decode data.
roundTripTime
Number
Round Trip Time of the webRTC connection.
RtcPublishStatistic Video Object
Property
Type
Description
lastPacketSentTimestamp
Number
UNIX timestamp of the last known packet sent described by the candidate pair, not including STUN packets.
ssrc
Number
An integer which uniquely identifies the source of the RTP stream.
mediaType
String
Kind/Media type of the stream.
timestamp
Number
UNIX time stamp of when the statistics is captured.
bitrate
Number
The number of bits per second that can be transmitted.
bytesSent
Number
Bytes sent.
packetsSent
Number
Packets sent.
retransmittedBytesSent
Number
Total number of frames decoded successfully for this media source.
firCount
Number
The number of Full Intra Request (FIR) packets sent from the receiver to the sender.
frameHeight
Number
Frame height.
frameWidth
Number
Frame width.
framesEncoded
Number
Frames encoded.
framesSent
Number
Frames sent.
headerBytesSent
Number
Total number of RTP header and padding bytes sent for this SSRC.
hugeFramesSent
Number
The total number of huge frames sent by this RTP stream.
pliCount
Number
Total number of Picture Loss Indication (PLI) packets.
qpSum
Number
The sum of the QP values of frames decoded by this receiver.
totalEncodeTime
Number
Total number of seconds spent encoding this stream's framesEncoded frames.
totalEncodedBytesTarget
Number
This value is increased by the target frame size in bytes every time a frame has been encoded. The actual frame size may be bigger or smaller than this number.