Skip to content

Commit

Permalink
add transfer_sip_participant
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Nov 6, 2024
1 parent c3d8a9e commit 2b76ffe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 5 additions & 3 deletions livekit-api/livekit/api/_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ def __init__(
self.api_secret = api_secret

def _auth_header(
self, grants: VideoGrants, sip: SIPGrants | None = None
self, grants: VideoGrants | None, sip: SIPGrants | None = None
) -> Dict[str, str]:
tok = AccessToken(self.api_key, self.api_secret).with_grants(grants)
tok = AccessToken(self.api_key, self.api_secret)
if grants:
tok.with_grants(grants)
if sip is not None:
tok = tok.with_sip_grants(sip)
tok.with_sip_grants(sip)

token = tok.to_jwt()

Expand Down
17 changes: 17 additions & 0 deletions livekit-api/livekit/api/sip_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,20 @@ async def create_sip_participant(
self._auth_header(VideoGrants(), sip=SIPGrants(call=True)),
proto_sip.SIPParticipantInfo,
)

async def transfer_sip_participant(
self, transfer: proto_sip.TransferSIPParticipantRequest
) -> proto_sip.SIPParticipantInfo:
return await self._client.request(
SVC,
"TransferSIPParticipant",
transfer,
self._auth_header(
VideoGrants(
room_admin=True,
room=transfer.room_name,
),
sip=SIPGrants(call=True),
),
proto_sip.SIPParticipantInfo,
)

0 comments on commit 2b76ffe

Please sign in to comment.