Unleash real-time audio/video, live streaming, cloud recording, transcriptions, language translation, and more in your web and mobile apps with the versatile Sariska Media JavaScript APIs.
Key Features:
Seamlessly integrate with various JavaScript frameworks (Vanilla, React, Angular, Vue, Electron, NW, React Native, and more).
Access a rich set of features for audio/video conferencing, live streaming, cloud recording, transcriptions, language translation, virtual backgrounds, and more.
Maintain persistent, low-latency connections for real-time data exchange.
Purpose: Sets the preferred resolution for the local video stream.
cameraDeviceId
Type: String
Purpose: Specifies the device ID of the camera to use.
micDeviceId
Type: String
Purpose: Specifies the device ID of the microphone to use.
minFps
Type: Integer
Purpose: Sets the minimum frame rate for the video stream.
maxFps
Type: Integer
Purpose: Sets the maximum frame rate for the video stream.
desktopSharingFrameRate
Type: Object
Properties:
min: Minimum frame rate for desktop sharing
max: Maximum frame rate for desktop sharing
desktopSharingSourceDevice
Type: String
Purpose: Specifies the device ID or label of the video input source to use for screen sharing.
facingMode
Type: String
Values: "user", "environment"
Purpose: Sets the camera's facing mode (front-facing or back-facing).
firePermissionPromptIsShownEvent
Type: Boolean
Purpose: If set to true, fires a JitsiMediaDevicesEvents.PERMISSION_PROMPT_IS_SHOWN event when the browser displays the GUM permission prompt.
fireSlowPromiseEvent
Type: Boolean
Purpose: If set to true, fires a JitsiMediaDevicesEvents.USER_MEDIA_SLOW_PROMISE_TIMEOUT event if the browser takes too long to resolve the GUM promise. Cannot be used with firePermissionPromptIsShownEvent
Determines whether the track is local or remote. Returns a boolean value true for local tracks, false for remote tracks.
track.isMuted()
Checks if the track is currently muted. Returns true if muted, false if not.
track.stream.toURL
Retrieves the URL of the stream, allowing access to the media content.
Retrieve Track Information:
track.getType()
Identifies the track type, which can be "audio", "video", or "desktop".
track.getId()
Obtains the unique identifier assigned to the track.
track.getDeviceId()
Determines the device ID associated with the track, providing information about the physical source of the media.
track.getParticipantId()
Returns the ID of the participant to whom the track belongs.
Manage Track State:
track.switchCamera()
Switches the camera source between the front and back cameras (for video tracks).
track.mute()
Mutes the track, preventing its audio or video from being transmitted.
track.unmute()
Unmutes a previously muted track, resuming transmission.
Attach & Detach Tracks:
track.attach()
Pairs the track with an HTML audio or video element, enabling playback within a web page.
track.detach()
Disconnects the track from its associated audio or video element.
Track Disposal:
track.dispose()
Releases the track's resources, effectively ending its use and freeing up memory.
Step 6 : Play Local Stream
// Access local media tracksconstaudioTrack=localTracks.find(track=>track.getType()==="audio");constvideoTrack=localTracks.find(track=>track.getType()==="video");// Play videovideoTrack.attach(document.getElementById("videoElement"))// Play audioaudioTrack.attach(document.getElementById("audioElement"))
// Install webRTC librarynpm i react-native-webrtc// Import RTCView from react-native-webrtc to render the live video streamimport {RTCView} from'react-native-webrtc';// Access local video trackconstvideoTrack=localTracks.find(track=>track.getType()==="video");;// Render videoreturn {videoTrack.getType() === "video" && <RTCView streamURL={videoTrack.stream?.toURL()}/>}
Step 7 : Handle User Joined Event
This event is triggered when a new user joins the conference. Moderators have exclusive control over meetings and can manage participants. To assign a moderator, set the moderator value to true when generating the token.
Moderator permissions
Password Protection:
Ability to add a password to the meeting room, restricting access.
Role Assignment:
Ability to grant moderator privileges to other participants.
Participant Removal:
Ability to kick non-moderators or even other moderators from the meeting.
Audio Control:
Ability to mute individual participants or all participants at once.
Video Focus:
Ability to make everyone's video view follow the moderator's video.
Joining Settings: Ability to:
Set participants to join with audio muted by default.
Set participants to join with video disabled by default.
Lobby Management:
Ability to enable or disable the lobby room, requiring approval for participants to join.
Join Approval:
Ability to approve or deny join requests when the lobby is enabled.
Encryption (Beta):
Ability to enable end-to-end encryption (where available).
Moderator Transfer:
If the current moderator leaves the meeting, a new moderator is automatically selected.
getType(): Returns the track type (audio, video, or desktop)
getStreamURL(): Returns the URL of the stream
getId(): Returns the ID of the track
isMuted(): Checks if the track is muted
getParticipantId(): Returns the ID of the participant who owns the track
isLocal(): Checks if the track is local
Additional RTCView properties for styling:
mirror: Mirrors the video horizontally (true or false)
cover: Controls how the video fills the view ("contain" or "cover")
zOrder: Sets the stacking order of the view (0 or 1)
Analytics
Sariska-media-transport offers pre-configured events to help you track and analyze user interactions, media usage, and overall performance. This data can be used to enhance your product, improve user experience, and make informed decisions.
action: The action associated with the event (string)
actionSubject: The subject of the action (string)
source: The source of the event (string)
attributes: Additional attributes of the event (JSON)
Features
Sariska offers powerful features to enhance your application's capabilities. Find your desired feature using the search bar or explore below!
Active/Dominant Speaker
Identify the main speaker: Easily detect the active or dominant speaker in a conference. Choose to stream only their video for improved resolution and reduced bandwidth usage. Ideal for one-way streaming scenarios like virtual concerts.
// Listen for changes in the dominant speakerconference.addEventListener(SariskaMediaTransport.events.conference.DOMINANT_SPEAKER_CHANGED, id=> {console.log(id) // Dominant speaker ID});
Last N Speakers
Dynamically showcase recent speakers: Focus on the active conversation by displaying video only for the last N participants who spoke. This automatically adjusts based on speech activity, offering a more efficient and relevant view.
// Track changes in the "last N" speakersconference.addEventListener(SariskaMediaTransport.events.conference.LAST_N_ENDPOINTS_CHANGED, (leavingEndpointIds, enteringEndpointIds)=> {
console.log(leavingEndpointIds) //Array of ID's of users leaving lastNconsole.log(enteringEndpointIds) //Array of ID's of users entering lastN});
Participant Information
Set local participant properties: Define additional information about participants beyond the default settings. This can include screen-sharing status, custom roles, or any other relevant attributes.
// Set a local participant propertyconference.setLocalParticipantProperty(key, value);// Remove a local participant propertyconference.rempveLocalParticipantProperty(key)// Get the value of a local participant property conference.getLocalParticipantProperty(key)// Listen for changes in participant propertiesconference.addEventListener(SariskaMediaTransport.events.conference.PARTICIPANT_PROPERTY_CHANGED, (participant, key,oldValue, newValue) => {
});
Participant Count
Get the total number of participants: Retrieve the complete participant count, including both visible and hidden members.
conference.getParticipantCount();// Pass true to include hidden participants
Some conferences may include hidden participants besides attendees, such as bots assisting with recording, transcription, or pricing.
Participant Lists
Access all participants: Obtain a list of all participants, including their IDs and detailed information.
// Get all participantsconference.getParticipants(); // Array of {participantId: details} objects// Get participants without hidden usersconference.getParticipantsWithoutHidden(); // Array of {participantId: details} objects
All Participants as an Object
Advanced manipulation: You can directly access the conference object for more granular control over conference behavior.
Pin a single participant: Pin a specific participant to always receive their video, even when "last n" is enabled.
conference.pinParticipant(participantId)
Pin multiple participants: Pin an array of participants to always receive their videos.
conference.pinParticipant(participantIds)
Access Local User Details
Retrieve the local user's ID: Get the ID of the local user.
conference.myUserId();
Retrieve the local user's information: Get comprehensive details about the local user, including name, email, ID, and avatar.
conference.getLocalUser();
Retrieve the local user's role: Get the role of the local user (For example, participant, moderator, owner).
conference.getRole();
Manage Tracks
Get all remote tracks: Retrieve a list of all remote tracks (audio and video) in the conference.
conference.getRemoteTracks();
Get all local tracks: Retrieve a list of all local tracks (audio and video)
conference.getLocalTracks();
Breakout Rooms
Split your conference meeting into smaller, focused groups with unique audio and video. Moderators can create rooms, assign participants, and reunite everyone seamlessly.
Access breakout rooms: Get an instance to manage breakout rooms.
constbreakoutRooms=conference.getBreakoutRooms();
Create a breakout room: Create a new breakout room with the specified subject.
breakoutRooms.createBreakoutRoom("room subject");
Remove a breakout room: Remove the current breakout room (if applicable).
breakoutRooms.removeBreakoutRoom();
Check for breakout room status: Determine if the current room is a breakout room.
breakoutRooms.isBreakoutRoom();
Send a participant to a breakout room: Move a participant to a specific breakout room.
conference.addEventListener(SariskaMediaTransport.events.conference.KICKED, (id)=> { // Handle a participant being kicked by a moderator
// The kicked participant's ID is available in the `id` variable});conference.addEventListener(SariskaMediaTransport.events.conference.PARTICIPANT_KICKED, (actorParticipant, kickedParticipant, reason) => { // Handle a moderator being kicked by another moderator
// Information about the actor, kicked participant, and reason is available in the event arguments});
Kick a participant
confernece.kickParticipant(id)
Kick a moderator
confernece.kickParticipant(id, reason) // Kick a moderator, providing a reason for the kick
Manage Owner Roles
The room creator has a moderator role, while other users have a participatory role.
Grant owner rights
conference.grantOwner(id) // Grant owner rights to a participant
Listen for role changes
conference.addEventListener(SariskaMediaTransport.events.conference.USER_ROLE_CHANGED, (id, role) => {if (cofenerece.user.id === id ) {console.log(`My role changed, new role: ${role}`); } else {console.log(`Participant role changed: ${role}`); } });
Revoke owner rights:
conference.revokeOwner(id) // Revoke owner rights from a participant
Change Display Names
Setting a new display name
conference.setDisplayName(name); // Change the local user's display name
Listen for display name changes
conference.addEventListener(SariskaMediaTransport.events.conference.DISPLAY_NAME_CHANGED, (id, displayName)=> { // Handle display name changes for other participants
// Access the participant ID});
Lock/Unlock Room
Lock room: Moderators can restrict access to the room with a password.
conference.lock(password); // Lock the room with the specified password
Unlock room: Removes any existing password restriction.
conference.unlock();
Subtitles
Request subtitles: Enable subtitles for spoken content.
Sariska offers robust messaging capabilities for both private and group communication scenarios.
Send and Receive Private Text Messages
// Send a private text message to a specific participant
conference.sendMessage("message", participantId);
// Listen for incoming private text messages
conference.addEventListener(SariskaMediaTransport.events.conference.PRIVATE_MESSAGE_RECEIVED, (participantId, message)=>{
});
Send and Receive Private Payload
// Send a private payload to a specific participant
conference.sendEndpointMessage(to, payload);
// Listen for incoming private payloads
conference.addEventListener(SariskaMediaTransport.events.conference.ENDPOINT_MESSAGE_RECEIVED, (participant, payload)=>{
});
Send and Receive Group Text Messages
// Send a group text message to all participants
conference.sendMessage("message", participantId);
// Listen for incoming group text messages
conference.addEventListener(SariskaMediaTransport.events.conference.MESSAGE_RECEIVED, (participantId, message)=>{
});
Send and Receive Group Payload
// Send a group payload to all participants
conference.sendEndpointMessage('', payload);
// Listen for incoming group payloads
conference.addEventListener(SariskaMediaTransport.events.conference.ENDPOINT_MESSAGE_RECEIVED, (participant, payload)=>{
});
Transcription
Start Transcription: Initiate transcription for the ongoing conference.
conference.startTranscriber();
Stop Transcription: Stop transcription and get a download link for the transcript.
conference.stopTranscriber();
Mute/Unmute Participants
Mute Remote Participant
conference.muteParticipant(participantId, mediaType)
// participantId: ID of the participant to be muted
// mediaType: Type of media to mute ('audio' or 'video')
The moderator has the ability to temporarily silence the microphone of any participant who is not physically present in the meeting room.
Mute/Unmute Local Participant
// Mute a local track (audio or video)
track.mute()
// Unmute a previously muted local track
track.unmute()
// Check if a local track is currently muted
track.isMuted()
Connection Quality
Local Connection Statistics Received
conference.addEventListener(SariskaMediaTransport.events.conference.LOCAL_STATS_UPDATED, (stats)=>{
// Handle local connection statistics
});
// Triggered when the conference audio input loses signal
conference.addEventListener(SariskaMediaTransport.events.conference.NO_AUDIO_INPUT, () => {
// Handle the absence of audio input
});
Audio Input State Changed
// Triggered when the audio input state switches between having or not having audio input
conference.addEventListener(SariskaMediaTransport.events.conference.AUDIO_INPUT_STATE_CHANGE, hasAudioInput => {
// Handle changes in audio input state
});
Detect excessive noise from the microphone used in the conference.
conference.addEventListener(SariskaMediaTransport.events.conference.NOISY_MIC, function () {
// Handle noisy mic events, such as notifying the user or adjusting settings
});
Talk While Muted Detection
conference.addEventListener(SariskaMediaTransport.events.conference.TALK_WHILE_MUTED, function () {
// Handle talk while muted events, such as providing a visual indicator
});
Noise Suppression/Cancellation
Reduces background noise from audio signals using a recurrent neural network (RNN).
This ensures seamless connectivity even in the face of fluctuating internet connections. It automatically manages connections and disconnections as needed.
// Update network status and notify Sariska Media Transport
function updateNetwork() {
// Communicate the current online status to SariskaMediaTransport
SariskaMediaTransport.setNetworkInfo({isOnline: window.navigator.onLine});
}
// When the browser goes offline, updateNetwork() is called to inform SariskaMediaTransport
window.addEventListener("offline", updateNetwork);
// When the browser comes back online, updateNetwork() is called again to update the status
window.addEventListener("online", updateNetwork);
npm i @react-native-community/netinfo
import NetInfo from "@react-native-community/netinfo";
// Add an event listener to detect connectivity changes
const unsubscribe = NetInfo.addEventListener(state => {
// Log the current connection status
console.log("Is connected?", state.isConnected);
// Update SariskaMediaTransport with the latest connectivity information
SariskaMediaTransport.setNetworkInfo({isOnline: state.isConnected});
});
Speaker Stats
Get valuable insights into the current conversation, specifically focusing on speaker dominance. It analyzes the interaction and estimates how long each participant has held the dominant speaker role.
conference.getSpeakerStats();
Connection Stats
Gain insights into the connection quality of conference participants.
The audio SSRC (Synchronization Source identifier)
bandwidth
The estimated available bandwidth in bits per second
bitrate
The current media bitrate in bits per second
bridgeCount
The number of bridges in use
codec
The codec being used for media transmission
connectionSummary
A brief summary of the connection quality (e.g., "Good", "Fair", "Poor")
e2eRtt
The estimated end-to-end round-trip time in milliseconds
participantId
The ID of the participant
framerate
The current media framerate in frames per second
isLocalVideo
Indicates whether the stats are for the local participant's video
maxEnabledResolution
The maximum resolution enabled for the participant
packetLoss
The percentage of packet loss
region
The region where the participant is located
resolution
The current resolution of the media stream
serverRegion
The region of the server handling the connection
shouldShowMore
Indicates whether more detailed connection stats are available
videoSsrc
The video SSRC
transport
The transport protocol being used (e.g., "UDP", "TCP")
Web Audio Mixer
Combine multiple audio tracks into a single, unified audio stream.
// Obtain the audio tracks to be mixed
const audioTrack1 = getTracks()[0];
const audioTrack2 = getTracks()[1];
// Create an audio mixer instance
const audioMixer = SariskaMediaTransport.createAudioMixer();
// Add individual audio streams to the mixer
audioMixer.addMediaStream(audioTrack1.getOriginalStream());
audioMixer.addMediaStream(audioTrack2.getOriginalStream());
// Initiate the mixing process and retrieve the resulting mixed stream
const mixedMediaStream = audioMixer.start();
// Extract the mixed audio track from the mixed stream
const mixedMediaTrack = mixedMediaStream.getTracks()[0];
// Maintain synchronization between the mixed track's enabled state and the track using the effect
End-to-End Encryption
Empower your application with robust end-to-end encryption, ensuring secure communication for your users.
Enable End-to-End Encryption
// Initialize Olm early for E2EE readiness
window.Olm.init().catch(e => {
console.error('Failed to initialize Olm, E2EE will be disabled', e);
delete window.Olm; // Remove Olm if initialization fails
});
// Activate E2EE:
conference.toggleE2EE(true); // Enable end-to-end encryption
// Verify E2EE support
conference.isE2EESupported() // Check if E2EE is available
Join conferences with audio and video already muted, or in a silent mode where no audio is transmitted or received. This ensures a seamless experience and respects participant preferences.
Join with Muted Audio and Video
// Join the conference with both audio and video muted initially
const conference = connection.initJitsiConference({
startAudioMuted: true, // Mute audio upon joining
startVideoMuted: true // Mute video upon joining
});
Join in Silent Mode
// Join the conference in silent mode, disabling both audio input and output
const conference = connection.initJitsiConference({
startSilent: true // Enter the conference in silent mode
});
Live Stream
Broadcast your conference to multiple platforms simultaneously. Embed live streams directly into your app or website using various formats.
// Define streaming destinations and settings
const appData = {
// Keys for platforms to stream
streamKeys: [
{streamKey: "youtube", streamValue: "youtube-stream-key"},
{streamKey: "facebook", streamValue: "facebook-stream-key"},
{streamKey: "twitch", streamValue: "twitch-stream-key"},
{streamKey: "vimeo", streamValue: "vimeo-stream-key"},
{streamKey: "periscope", streamValue: "periscope-stream-key"},
{streamKey: "instagram",streamValue: "instagram-stream-key"}
// Add keys for other platforms as needed
],
// Optional list of additional RTMP URLs for streaming
streamUrls: ["rtmp://test-rtmp-url-1", "rtmp://test-rtmp-url-2", "rtmp://test-rtmp-url-n"],
isRecording: false,
// Specify "live" for embedding the stream
app: "live",
stream: "livestream"
}
// app and stream: If you want to embed live streaming to your app or website just pass app and stream then you can embed and play live streaming in your platform for HTTP-FLV, HLS, DASH and HDS, mp3, aac
* Play HTTP-FLV: https://edge.sariska.io/http-flv/live/livestream.flv
* Play HLS: https://edge.sariska.io/hls/live/livestream.m3u8
* Play DASH: https://edge.sariska.io/dash/live/livestream.mpd
* Play MP3: https://edge.sariska.io/mp3/live/livestream.mp3
* Play AAC: https://edge.sariska.io/acc/live/livestream.aac
// Start live recording with configuration data
conference.startRecording({
mode: SariskaMediaTransport.constants.recording.mode.STREAM, // Set mode to "stream"
appData: JSON.stringify(appData) // Pass app data as JSON string
});
// Listen for RECORDER_STATE_CHANGED event to track streaming status
conference.addEventListener("RECORDER_STATE_CHANGED", (payload)=>{
// Verify mode is "stream" again
const mode = payload._mode;
// Get the live streaming session ID
const sessionId = payload._sessionID;
// Check the streaming status: on, off, or pending
const status = payload._status;
});
// Stop live streaming using the session ID
conference.stopRecording(sessionId);
Cloud Recording
Store your recordings and transcriptions in various cloud storage services.
Supported storage providers
Object-based storage: Amazon S3, Google Cloud Storage, Azure Blob Storage, other S3-compatible cloud providers.
Dropbox
Set credentials
Object-based storage
Access your Sariska dashboard
Locate the storage credentials section
Enter the required credentials for your chosen provider
Dropbox
Obtain a Dropbox OAuth token
// Configure for Object-based storage
const appData = {
file_recording_metadata : {
'share': true // Enable sharing
}
}
// Configure for Dropbox
const appData = {
file_recording_metadata: {
upload_credentials: {
service_name: "dropbox",
token: "your_dropbox_oauth_token"
}
}
}
// Start recording
conference.startRecording({
mode: SariskaMediaTransport.constants.recording.mode.FILE,
appData: JSON.stringify(appData)
});
// Monitor recording state
conference.addEventListener("RECORDER_STATE_CHANGED", (payload)=>{
const mode = payload._mode; // Recording mode (e.g., "file")
const sessionId = payload._sessionID; // Unique identifier for the cloud recording session
const status = payload._status; // Current recording status ("on", "off", or "pending")
// Handle recording state changes based on mode, sessionId, and status
});
// Stop recording
conference.stopRecording(sessionId); // Provide the session ID
PSTN
Dial-in(PSTN)
// Retrieve the phone pin and number for users to join via PSTN:
const phonePin = conference.getPhonePin(); // Get the phone pin for PSTN access
const phoneNumber = conference.getPhoneNumber() // Get the phone number for PSTN access
Share this phone number and pin with users to enable PSTN conference call participation.
Dial-out(PSTN)
// Dial a phone number to invite a participant to the conference
conference.dial(phoneNumber)
This initiates a call to the provided phone number, inviting them to join the conference.
Lobby/Waiting Room
// Join the lobby
conference.joinLobby(displayName, email); // Request to join the conference lobby
// Event listeners for lobby-related actions:
conference.addEventListener(SariskaMediaTransport.events.conference.LOBBY_USER_JOINED, (id, name) => {
// Handle events when a user joins the lobby
})
conference.addEventListener(SariskaMediaTransport.events.conference.LOBBY_USER_UPDATED, (id, participant)=> {
// Handle events when a user's information in the lobby is updated
})
// Additional event listeners for lobby actions:
conference.addEventListener(SariskaMediaTransport.events.conference.LOBBY_USER_LEFT, id=> {
})
conference.addEventListener(SariskaMediaTransport.events.conference.MEMBERS_ONLY_CHANGED, enabled=> {
})
// Moderator actions for lobby access:
conference.lobbyDenyAccess(participantId); // Deny access to a participant in the lobby
conference.lobbyApproveAccess(participantId); // Approve access to a participant in the lobby
// Lobby management methods:
conference.enableLobby() // Enable lobby mode for the conference (moderator only)
conference.disableLobby(); // Disable lobby mode for the conference (moderator only)
conference.isMembersOnly(); // Check if the conference is in members-only mode (lobby disabled)
SIP Video Gateway
// Initiate a SIP video call
conference.startSIPVideoCall("address@sip.domain.com", "display name"); // Start a SIP video call with the specified address and display name
// Terminate a SIP video call
conference.stopSIPVideoCall('address@sip.domain.com'); // End the SIP video call with the specified address
// Event listeners for SIP gateway state changes
conference.addEventListener("VIDEO_SIP_GW_SESSION_STATE_CHANGED", (state)=>{
// Handle events when the SIP gateway session state changes (on, off, pending, retrying, failed)
console.log("state", state);
})
// Event listener for SIP gateway availability changes
conference.addEventListener("VIDEO_SIP_GW_AVAILABILITY_CHANGED", (status)=>{
// Handle events when the SIP gateway availability changes (busy or available)
console.log("status", status);
})
Peer-to-Peer Mode
Designed for efficient communication between two participants.
Start Peer-to-Peer Mode
Sariska automatically activates Peer-to-Peer mode when your conference has exactly two participants. This mode bypasses the central server and directly connects participants, maximizing bandwidth efficiency and reducing latency. However, even with more than two participants, you can forcefully start Peer-to-Peer mode.
conference.startP2PSession();
Starting Peer-to-Peer mode eliminates server charges as long as the central turn server remains unused.
Stop Peer-to-Peer Mode
If you need to revert to server-mediated communication, you can easily stop Peer-to-Peer mode.
conference.stopP2PSession();
One-to-One Calling (React Native Only)
This allows synchronous phone calls, similar to WhatsApp, even if the receiver's app is closed or in the background.
Initiating Calls:
Make a call even if the callee's app is closed or in the background.
Play a busy tone if the callee is on another call or disconnects your call.
Play ringtone/ringback/DTMF tones.
Step 1 : Caller Initiates Call
HTTP Call to Sariska Server
{API Method}
Push Notification to callee using Firebase or APNS
This notifies the receiver even if their app is closed or in the background.