can Local participant control remote participant's...
# ask-ai
n
can Local participant control remote participant's track subscription control ?
t
Thanks for reaching out, Darshak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Regarding controlling another participant's subscriptions: no — a local participant cannot directly subscribe or unsubscribe a remote participant's tracks. What a local participant can do: • Use track subscription permissions (
setTrackSubscriptionPermissions()
) on their own published tracks to allow or deny specific participants (or all participants) from subscribing to those tracks. • Disable global subscriptions and selectively permit identities to subscribe to camera/mic tracks. Summary: • ❌ You cannot control another participant's subscriptions for tracks they receive. • ✅ You can control who is permitted to subscribe to your own published tracks. Sources: Subscribing to tracks | LiveKit docs | Camera & microphone | LiveKit docs
n
consider a senario where two sip participant present in the room and i want one sip participant subscribe only which i select how can i achive this ?
t
You're asking how to make one SIP participant in a room subscribe only to the specific tracks you choose. You can enforce that by using track subscription permissions on the publishers whose tracks you want to restrict. Solution (server-side enforcement) 1. On each publisher you want to control, call setTrackSubscriptionPermissions / set_track_subscription_permissions. 2. Set allParticipantsAllowed = false to block everyone by default. 3. Add an allow rule for only the SIP participant's identity (the SIP participant's identity value). ◦ If you want them to access all tracks from that publisher, allow all tracks for that participant. ◦ Or list specific track IDs if you want per-track granularity. Notes • SIP participants are treated like other participants (SIP identities work the same way). • This enforces subscriptions server-side (secure). Client-side approaches like disabling autoSubscribe on the SIP client are not enforcement — they rely on the client cooperating. If you want, tell me: • which server SDK you’re using (Node/Python/Go/Java/Kotlin) and • whether you need per-publisher or per-track rules, and I’ll provide the exact code snippet. Sources: Camera & microphone | LiveKit docs | server-sdk-kotlin | livekit/livekit_composite | DeepWiki
n
how track subscription works for sip participant how they subscribe any track in the room ?
t
You're asking how SIP participants subscribe to tracks in a LiveKit room and what controls apply. Here’s how it works: • SIP participants behave like regular participants in the room and can receive published tracks the same way other participants do. • By default, participants auto-subscribe to available tracks (so a SIP participant will receive tracks they are allowed to see). • Publishers control who is allowed to subscribe to their tracks via track subscription permissions (
setTrackSubscriptionPermissions
/
set_track_subscription_permissions
): ◦ Set
allParticipantsAllowed = false
to block everyone by default. ◦ Add allow-rules for specific participant identities (including SIP identities) or for specific tracks. ◦ Permissions are enforced server-side, so SIP participants cannot bypass them. • If you control the SIP client behavior, you can disable
autoSubscribe
for the SIP participant and programmatically subscribe only to chosen tracks — but this is client-side and not enforcement. Use server-side permissions for guaranteed restrictions. If you want, tell me: • which server SDK you use (Node/Python/Go/Java), and • whether you need per-publisher or per-track rules, and I’ll provide the exact code snippet.
n
how can i do server side so that i can control sip participant's to subscribe only i want
t
You can enforce which tracks a SIP participant may subscribe to from the server by using track subscription permissions on the publishers. This is a server-side, authoritative control that SIP participants cannot bypass. What to do (high level) 1. Identify the SIP participant's identity (the identity used when the SIP participant joined). 2. For each publisher whose tracks you want to restrict, call setTrackSubscriptionPermissions on that publisher. 3. Set allParticipantsAllowed = false to deny subscriptions by default. 4. Add allow rules for the SIP participant identity: ◦ To allow all that publisher's tracks: allow all tracks for that participant. ◦ To allow only specific tracks: list the specific track IDs in the permission for that participant. Node.js example (Server API / Room service)
Copy code
await roomServiceClient.setTrackSubscriptionPermissions('room-name', 'publisher-identity', {
  allParticipantsAllowed: false,
  trackPermissions: [
    {
      participantIdentity: 'sip-participant-identity',
      allTracksAllowed: true, // or false + trackSids: ['trackSid1','trackSid2']
    },
  ],
});
Python (server SDK)
Copy code
await publisher.set_track_subscription_permissions(
  all_participants_allowed=False,
  participant_permissions=[
    ParticipantTrackPermission(
      participant_identity='sip-participant-identity',
      allow_all=True,  # or set specific track_sids
    ),
  ],
)
Granularity options • Per-publisher allow-all: permit the SIP participant to subscribe to every track published by that publisher. • Per-track: permit only specified track SIDs. • Mixed: different publishers can have different rules. Notes • Apply permissions for each publisher whose tracks you want to control. • SIP participants are treated like normal participants; use their identity in permissions. • This enforces subscriptions server-side; client-side
autoSubscribe
changes are not enforcement. If you tell me which server SDK you use (Node/Python/Go/Java) and whether you need per-publisher or per-track rules, I’ll provide the exact code snippet tailored to your stack.
n
how can i call the sip participant publisher track
t
You want to access a SIP participant’s published tracks (the publisher tracks) so you can, for example, set subscription permissions or reference specific track SIDs. Here’s how to do that server-side. Brief summary of steps 1. Get the Room object or use the RoomService to fetch the room state. 2. Locate the SIP participant by their identity or SID. 3. Read the participant’s published tracks (each track has a track SID and metadata). 4. Use those track SIDs or the participant identity when calling setTrackSubscriptionPermissions (or RoomService setTrackSubscriptionPermissions). Examples Node (RoomService + room state) 1. Fetch room participants (or use an event when participant joins). 2. Find publisher:
Copy code
const room = await roomServiceClient.getRoom({ room: 'room-name' });
const pub = room.participants.find(p => p.identity === 'sip-identity');
// published tracks are in pub.tracks
const trackSids = pub.tracks.map(t => t.sid);
1. Use
roomServiceClient.setTrackSubscriptionPermissions
with
trackSids
or
participantIdentity
. Python (Server SDK / participant object)
Copy code
room = await room_service.get_room('room-name')
pub = next(p for p in room.participants if p.identity == 'sip-identity')
track_sids = [t.sid for t in pub.tracks]

# then call set_track_subscription_permissions or room service equivalent
await room_service.set_track_subscription_permissions(
    room='room-name',
    publisher='publisher-identity',
    all_participants_allowed=False,
    track_permissions=[{
        'participant_identity': 'sip-identity',
        'track_sids': track_sids
    }]
)
Go (RoomService) • Fetch room via RoomService, find participant via
participant.Identity
, inspect
participant.Tracks
for SIDs, then call
SetTrackSubscriptionPermissions
with either
AllTracksAllowed
or explicit
TrackSids
. Key points • SIP participants are regular participants; their published tracks appear in the participant object. • You can reference either the publisher’s identity (to allow all their tracks) or specific `trackSid`s (for per-track rules). • Use server-side
setTrackSubscriptionPermissions
(RoomService or participant API) to enforce which SIP participant may subscribe. If you tell me which server SDK you’re using (Node/Python/Go/Java) and whether you want per-publisher or per-track rules, I’ll provide the exact code snippet for that SDK.
n
i am using python sdk
t
Responding to your request about the Python SDK: below are concise steps and example code to (A) fetch a SIP participant’s published tracks, and (B) enforce server-side subscription rules so that only the SIP participant can subscribe to specific tracks. 1) Fetch the SIP participant and their published track SIDs
Copy code
from livekit import RoomServiceClient

room_name = "your-room-name"
sip_identity = "sip-participant-identity"  # the SIP participant's identity

room_service = RoomServiceClient()  # assume configured with API key/URL

room = room_service.get_room(room=room_name)
participant = next((p for p in room.participants if p.identity == sip_identity), None)
if participant is None:
    raise RuntimeError("SIP participant not found in room")

# published track SIDs for this SIP participant
track_sids = [t.sid for t in participant.tracks]
2) Enforce subscription permissions (allow only this SIP participant to subscribe to a publisher's tracks) • If you want one publisher to allow only that SIP participant to subscribe to their tracks, call
set_track_subscription_permissions
on the publisher (publisher_identity is the publisher's identity). Example: allow only a specific SIP participant to subscribe to all tracks from a publisher:
Copy code
publisher_identity = "publisher-identity"

await room_service.set_track_subscription_permissions(
    room=room_name,
    publisher=publisher_identity,
    all_participants_allowed=False,
    participant_permissions=[
        {
            "participant_identity": sip_identity,
            "all_tracks_allowed": True,   # allow this SIP participant to subscribe to all publisher tracks
        }
    ],
)
Example: allow only specific track SIDs from a publisher to the SIP participant:
Copy code
await room_service.set_track_subscription_permissions(
    room=room_name,
    publisher=publisher_identity,
    all_participants_allowed=False,
    participant_permissions=[
        {
            "participant_identity": sip_identity,
            "all_tracks_allowed": False,
            "track_sids": ["trackSid1", "trackSid2"],  # replace with actual SIDs
        }
    ],
)
Notes • Apply these permissions for each publisher whose tracks you want to control. • Use the publisher identity to grant access to all that publisher’s tracks, or use
track_sids
for per-track rules. • These permissions are enforced server-side and apply to SIP participants just like any other participant. Would you like a full runnable example (including authentication/config) for the Python SDK, or help listing publishers in the room so you can apply permissions to each?
n
Cannot find reference 'RoomServiceClient' in 'imported module livekit'
t
You're right — the Python server SDK uses
LiveKitAPI
, not
RoomServiceClient
. Below are concise, working steps and example code to: • list participants in a room and find the SIP participant, • read that participant's published track SIDs, • enforce server-side subscription permissions so only selected SIP participants may subscribe. Make sure you have the package:
Copy code
pip install livekit-api
Example (async Python)
Copy code
from livekit.api import LiveKitAPI, ListParticipantsRequest, UpdateSubscriptionsRequest
from livekit.protocol.livekit import ParticipantInfo

async def restrict_subscriptions(api_key, api_secret, endpoint, room_name, publisher_identity, allowed_sip_identity, allowed_track_sids=None):
    async with LiveKitAPI(api_key, api_secret, endpoint) as lkapi:
        # list participants
        resp = await lkapi.room.list_participants(ListParticipantsRequest(room=room_name))
        participants = resp.participants

        # find SIP participant (by identity or kind)
        sip = next((p for p in participants if p.identity == allowed_sip_identity or p.kind == ParticipantInfo.Kind.KIND_SIP), None)
        if sip is None:
            raise RuntimeError("SIP participant not found")

        # find publisher to control (by identity)
        publisher = next((p for p in participants if p.identity == publisher_identity), None)
        if publisher is None:
            raise RuntimeError("Publisher not found")

        # collect track SIDs from publisher if needed
        publisher_track_sids = [t.sid for t in publisher.tracks]

        # Decide which tracks to allow for the SIP participant
        allowed = allowed_track_sids if allowed_track_sids is not None else publisher_track_sids

        # Update subscriptions for the SIP participant (server-side enforcement)
        # This example sets subscriptions so the SIP participant receives only `allowed` track SIDs.
        await lkapi.room.update_subscriptions(
            UpdateSubscriptionsRequest(
                room=room_name,
                identity=sip.identity,
                track_sids=allowed
            )
        )
Notes • Use
list_participants
to inspect participants and their
tracks
(each has a
sid
). • Use
update_subscriptions
to set exactly which track SIDs a given participant will receive (this enforces server-side). • If you prefer publisher-centric permissions (allow/deny per-publisher), you can implement equivalent logic by iterating publishers and calling the appropriate Room API methods; the Python SDK exposes room/participant management via
LiveKitAPI
. Tell me if you want: • a non-async (sync) variant, • a snippet that uses publisher allow-lists instead of
update_subscriptions
, or • a full runnable example including authentication setup. Sources: Subscribing to tracks | LiveKit docs | Creating SIP Inbound Trunks and Dispatch Rules with Python SDK