This guides explains you on how to build interactive live streaming apps via conferencing SDK.
Last updated
Generate an API Key for your project
Generate a Bearer Token
Creating a Conference Room
Alternative to Creating a Conference Room
Start Live Streaming
Stop Live Streaming
Streaming to Multiple Outlets
Generate API Key
You can generate your API key for your project by visiting and signing up.
The full instruction on how to do it can be found here:
Generate a Bearer Token
We generate these authentication tokens on our own servers. You can use the same token for all the services offered by Sariska.
To generate a token, follow the instruction on the page
“user” data in the above curl command is optional and the bearer token is generated regardless of it.
Creating a Conference Room for Your Live Stream
In order to start a multi host live stream, all the hosts need to join a common room. The name for this common room can be anything the hosts choose to. This part details on how to create a simple conference for your hosts to live stream.
Installation:
The first step is to install the sariska-media-transport library by running the following command in your project directory using NPM.
npm i sariska-media-transport
Initialise SDK:
After installing the SDK, perform initial setup tasks by running initialize().
import SariskaMediaTransport from "sariska-media-transport";
SariskaMediaTransport.initialize();
Create Connection:
To establish a connection, you would need to generate a token. You’d also need to specify a room name, this is the room your hosts will join to live stream together.
const token = {your-bearer-token};
const connection = new SariskaMediaTransport.new SariskaMediaTransport.JitsiConnection(token, "{room-name}", isNightly);
connection.addEventListener(SariskaMediaTransport.events.connection.CONNECTION_ESTABLISHED, () => {
console.log('connection successful!!!');
});
connection.addEventListener(SariskaMediaTransport.events.connection.CONNECTION_FAILED, (error) => {
if (error === SariskaMediaTransport.events.connection.PASSWORD_REQUIRED) { // token expired set again
connection.setToken(token) // set a new token
console.log('connection disconnect!!!', error);
}
});
connection.addEventListener(SariskaMediaTransport.events.connection.CONNECTION_DISCONNECTED, (error) => {
console.log('connection disconnect!!!', error);
});
connection.connect();
Create Conference:
Once you have your connection established, the next step is to create a conference.
const conference = connection.initJitsiConference(options);
conference.join();
//Additional options initJitsiConference accepts to enable more features
// startAudioMuted: true // to join with audio muted
// startVideoMuted: true // to join with video muted
// startSilent : true // to join with startSilent no audio receive/send
// rtcstatsServer: “” // to send enable rtcstats tracking
// callStatsID: “” // callstatsid
// callStatsSecret: “” // callstatssecet
// channelLastN: 10 // last n speakers
Now, the conferenceobject will have all events and methods that you would possibly need for any feature that you wish to supplement your application with.
Capture local streams:
A MediaStream consists of zero or more MediaStreamTrack objects, representing various audio or video tracks. Each MediaStreamTrack may have one or more channels. The channel represents the smallest unit of a media stream, such as an audio signal associated with a given speaker, like left or right in a stereo audio track. Here we mostly talk about track.
const audioTrack = localTracks.find(track=>track.getType()==="audio");
const videoTrack = localTracks.find(track=>track.getType()==="video");
// to play audio
audioTrack.attach(document.getElementById("audioElement"))
// to play video
videoTrack.attach(document.getElementById("videoElement"))
User Joined:
The moderator of the meeting controls and gate keeps the participants. The moderator has exclusive control of the meeting.