red-insurance-72205
07/27/2025, 7:54 PMtall-airline-16756
07/27/2025, 7:54 PMtall-airline-16756
07/27/2025, 7:55 PMallParticipantsAllowed
to false
to enable restrictions.
• Define permissions for specific participants using their identity or SID.
• Grant access to all tracks or specific tracks for each participant.
For example, in the JavaScript SDK:
// Allow only specific participants to subscribe
localParticipant.setTrackSubscriptionPermissions(
false, // allParticipantsAllowed: false to enable restrictions
[
{
participantIdentity: "allowed-participant-1",
allowAll: true // Allow this participant to subscribe to all tracks
},
{
participantIdentity: "allowed-participant-2",
allowedTrackSids: ["specific-track-id"] // Allow only specific tracks
}
]
);
For other SDKs like Swift or Go, similar methods are available to set these permissions.
To list the current tracks in a LiveKit room, you can use the following approaches:
• Using the useTracks Hook (React/React Native): import { useTracks } from '@livekit/react-native';
import { Track } from 'livekit-client';
const tracks = useTracks([Track.Source.Camera]); // Get all camera tracks
• Accessing Tracks Directly from Participants: // For local participant
const localTracks = Array.from(room.localParticipant.tracks.values());
// For remote participants
Array.from(room.participants.values()).forEach((participant) => {
const participantTracks = Array.from(participant.tracks.values());
});
These methods allow you to manage and list tracks effectively in your LiveKit room.
Sources: localparticipant.go | pkg/rtc/room.go | src/room/participant/LocalParticipant.ts | Sources/LiveKit/Types/ParticipantTrackPermission.swift | docs/interfaces/RoomState.htmlred-insurance-72205
07/27/2025, 7:59 PMtall-airline-16756
07/27/2025, 8:00 PMroom.local_participant.set_track_subscription_permissions(
allow_all_participants=True
)
• Restrict All Participants: room.local_participant.set_track_subscription_permissions(
allow_all_participants=False
)
• Grant Specific Permissions: from livekit import rtc
room.local_participant.set_track_subscription_permissions(
allow_all_participants=False,
participant_permissions=[
rtc.ParticipantTrackPermission(
participant_identity="allowed-user-identity",
allow_all=True,
)
],
)
• Grant Permissions to Specific Tracks: room.local_participant.set_track_subscription_permissions(
allow_all_participants=False,
participant_permissions=[
# Allow one participant to subscribe to all tracks
rtc.ParticipantTrackPermission(
participant_identity="user1",
allow_all=True,
),
# Allow another participant to subscribe only to specific tracks
rtc.ParticipantTrackPermission(
participant_identity="user2",
allowed_track_sids=["track_sid_1", "track_sid_2"],
)
],
)
Let me break down the ParticipantTrackPermission
class for you:
• `participant_identity`: Who this permission is for
• `allow_all`: Give access to all tracks (this is the big boss setting)
• `allowed_track_sids`: Specific tracks you want to share
By default, everyone can tune into your tracks. But with these settings, you can be super selective about who sees or hears what. Pretty neat, right? Now you can control your room like a pro! 😊
Sources: livekit-rtc/livekit/rtc/track_publication.py | Publishing tracks | LiveKit Docs