Daily.co calls default to everyone in the call seeing and hearing everyone else in the call. In this mode, if your camera and microphone are on, other participants in the call are receiving your camera and microphone tracks.

But you can now also configure a Daily.co client to only "subscribe" to a subset of available camera, microphone, and screen tracks.

Notes on daily-js library version and testing track subscriptions

Please note that track subscriptions are implemented only for "media server" mode calls. By default, calls start off in peer-to-peer mode and switch to media server mode when the 5th person joins the call. For testing, please force the call to switch to media server mode, and ensure that at least three participants are in the call.

callObject.setNetworkTopology({ topology: 'sfu' })

How track subscriptions work

The default client behavior — receiving all available audio video and screen tracks — is equivalent to creating a call object like this:

window.callObject = DailyIframe.createCallObject({
  subscribeToTracksAutomatically: true,
  ...

For the opposite behavior — not receiving any tracks unless you specifically subscribe to them — create the call object like this:

window.callObject = DailyIframe.createCallObject({
  subscribeToTracksAutomatically: false,
  ...

You can also switch modes during a call.

If you change from automatically subscribing to all tracks, to not automatically subscribing to all tracks, all the current tracks you are receiving will stop. (You will receive a track-stopped event, the track will be removed from its parent participant's data structure, and the underlying track will become muted.)

If you change from not automatically subscribing to all tracks, to automatically subscribing to all tracks, you'll get new tracks and track-started events for all available tracks for all participants in the call.

// stop receiving all tracks. after calling this, you can selectively subscribe
// to tracks
callObject.setSubscribeToTracksAutomatically(false);

// start receiving all tracks. you will get new tracks and track-started events
// for all available tracks
callObject.setSubscribeToTracksAutomatically(true);

You cannot call setSubscribedTracksAutomatically() unless you are in a call. To start off not subscribing to all tracks, use to constructor property subscribeToTracksAutomatically.

To subscribe to individual tracks, call updateParticipant() with a setSubscribedTracks argument.

setSubscribedTracks expects to be set to either true, or to an object that specifies the subscription state for each kind of track that a participant could send. If you use the setSubscribedTracks argument and you're in subscribeToAllTracksAutomatically mode, the updateParticipant() method throws an error.

// subscribe to all tracks from the participant with session_id 
// b95ec8cc-499f-480c-f68c-3373c8553693
callObject.updateParticipant(
  "b95ec8cc-499f-480c-f68c-3373c8553693", 
  { setSubscribedTracks: true }
);

// receive only audio from the participant with session_id
// b95ec8cc-499f-480c-f68c-3373c8553693. you don't have to set every
// track type in one call. if a track type is not specified, its previous
// value remains unchanged.
callObject.updateParticipant(
  "b95ec8cc-499f-480c-f68c-3373c8553693", 
  { setSubscribedTracks: { audio: true, video: false, screenVideo: false } }
);