Skip to main content

What is an SFU App, Session and Track

Metered Global SFU allows you to build any type to real-time application, and it is very flexible to fit any use-case. We do not limit you in any way and the aritecture is very simple so that it does not come in your way when you are building something and you can design your application however you want.

At the core of the Metered Global SFU aritecture in an SFU APP, Session and Tracks.

SFU Application

You can create as many SFU application you like from the dashboard or through the REST API, each SFU application has an SFU_APP_ID and SFU_APP_SECRET which are used when calling the REST API.

You can create Sessions inside an SFU Application, and all the Sessions will be scoped to that application.

You can create the SFU App through the dashboard or through the REST API, and you can create multiple SFU Applications, SFU Applications can be used to scope the DEV / Staging / Production environments or if you are building multi-tenant application you can create a unique SFU App for each of your customers.

Session

A Sessions represents a peer-connection, the sessions are scoped within the SFU Application, and using the SFU APP_ID and SECRET you can query the active sessions inside an SFU Application using the HTTP API.

When you want to publish a media like Audio Track or Video Track to the SFU you will create a peerConnection using native WebRTC API as per your platform (JavaScript, iOS, Android etc.) and the send a http request to create a new session, in the request you will send the SFU_APP_ID and SFU_APP_SECRET along with the SDP of the peerConnection, and in the response you will get the unique session_id that represents this peerConnection and the remote sdp that you will add to your local peerConnection to establish a peer-to-peer connection with the SFU.

Tracks

Tracks represents the audio or video tracks you are publishing to the Metered Cloud SFU. Using one peer-connection you can add multiple tracks to that peer-connection.

You can add audio track, video track or multiple audio or video tracks to the peerConnection using native webrtc api's addTrack method.

Once the tracks are added to the peerConnection you generate the sdp of the peerConnection and call the publish track http api, in the http api you send the trackIds of all the tracks that you have added to the peerConnection and the sdp and in the response you get the remote sdp from the sfu.

Subscribing to Tracks

Using the HTTP API you can query the active sessions i.e the peerConnection in an SFU Application, and also the tracks published by those sessions.

You can then call the subscribe track api, and in the subscribe track api send the trackId and sessionId of the tracks you want to subscribe to.

In the response you will get an SDP that you can add to your peerConnection and the ontrack method will be triggered on your peerConnection with the remote track.

What about Rooms?

In the Metered Cloud SFU there is no concept of Rooms, thus it is very flexible in terms of what kind of application you can build with it.

There is an SFU Application, inside the SFU Application you can create sessions, which represents a peerConnection and publish tracks through those sessions.

Any session inside an SFU Application can subscribe to the tracks of any other session, and the active sessions and tracks can be queried through the http api.

So you are just publishing tracks (audio and video) and can subscribe to those published tracks, and using this you can build any type of application wether real-time livestreaming where one user is publishing and thousands are subscribing to the published track or multi-party video conference, breakout rooms or sending the video or audio tracks in real-time to AI.