Skip to content

Commit

Permalink
Fix incorrect type names and format.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Apr 10, 2024
1 parent 2e6cfd5 commit 7668f5f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 32 deletions.
42 changes: 21 additions & 21 deletions livekit-api/livekit/api/sip_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,78 @@ def __init__(
super().__init__(session, url, api_key, api_secret)

async def create_sip_trunk(
self, create: proto_sip.CreateSipTrunkRequest
) -> proto_sip.SipTrunkInfo:
self, create: proto_sip.CreateSIPTrunkRequest
) -> proto_sip.SIPTrunkInfo:
return await self._client.request(
SVC,
"CreateSIPTrunk",
create,
self._auth_header(VideoGrants()),
proto_sip.SipTrunkInfo,
proto_sip.SIPTrunkInfo,
)

async def list_sip_trunk(
self, list: proto_sip.ListSipTrunkRequest
) -> proto_sip.ListSipTrunkResponse:
self, list: proto_sip.ListSIPTrunkRequest
) -> proto_sip.ListSIPTrunkResponse:
return await self._client.request(
SVC,
"ListSIPTrunk",
list,
self._auth_header(VideoGrants()),
proto_sip.ListSipTrunkResponse,
proto_sip.ListSIPTrunkResponse,
)

async def delete_sip_trunk(
self, delete: proto_sip.DeleteSipTrunkRequest
) -> proto_sip.SipTrunkInfo:
self, delete: proto_sip.DeleteSIPTrunkRequest
) -> proto_sip.SIPTrunkInfo:
return await self._client.request(
SVC,
"DeleteSIPTrunk",
delete,
self._auth_header(VideoGrants()),
proto_sip.SipTrunkInfo,
proto_sip.SIPTrunkInfo,
)

async def create_sip_dispatch_rule(
self, create: proto_sip.CreateSipDispatchRuleRequest
) -> proto_sip.SipDispatchRuleInfo:
self, create: proto_sip.CreateSIPDispatchRuleRequest
) -> proto_sip.SIPDispatchRuleInfo:
return await self._client.request(
SVC,
"CreateSIPDispatchRule",
create,
self._auth_header(VideoGrants()),
proto_sip.SipDispatchRuleInfo,
proto_sip.SIPDispatchRuleInfo,
)

async def list_sip_dispatch_rule(
self, list: proto_sip.ListSipDispatchRuleRequest
) -> proto_sip.ListSipDispatchRuleResponse:
self, list: proto_sip.ListSIPDispatchRuleRequest
) -> proto_sip.ListSIPDispatchRuleResponse:
return await self._client.request(
SVC,
"ListSIPDispatchRule",
list,
self._auth_header(VideoGrants()),
proto_sip.ListSipDispatchRuleResponse,
proto_sip.ListSIPDispatchRuleResponse,
)

async def delete_sip_dispatch_rule(
self, delete: proto_sip.DeleteSipDispatchRuleRequest
) -> proto_sip.SipDispatchRuleInfo:
self, delete: proto_sip.DeleteSIPDispatchRuleRequest
) -> proto_sip.SIPDispatchRuleInfo:
return await self._client.request(
SVC,
"DeleteSIPDispatchRule",
delete,
self._auth_header(VideoGrants()),
proto_sip.SipDispatchRuleInfo,
proto_sip.SIPDispatchRuleInfo,
)

async def create_sip_participant(
self, create: proto_sip.CreateSipParticipantRequest
) -> proto_sip.SipParticipantInfo:
self, create: proto_sip.CreateSIPParticipantRequest
) -> proto_sip.SIPParticipantInfo:
return await self._client.request(
SVC,
"CreateSIPParticipant",
create,
self._auth_header(VideoGrants()),
proto_sip.SipParticipantInfo,
proto_sip.SIPParticipantInfo,
)
35 changes: 25 additions & 10 deletions livekit-rtc/livekit/rtc/room.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class DataPacket:
)
topic: Optional[str] = None


@dataclass
class SipDTMF:
code: int
Expand All @@ -95,6 +96,7 @@ class SipDTMF:
None # None when the data has been sent by a server SDK
)


class ConnectError(Exception):
def __init__(self, message: str):
self.message = message
Expand Down Expand Up @@ -325,7 +327,8 @@ def _on_room_event(self, event: proto_room.RoomEvent):
)
elif which == "track_muted":
sid = event.track_muted.participant_sid
participant = self._retrieve_participant(sid)
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
publication = participant.tracks[event.track_muted.track_sid]
publication._info.muted = True
if publication.track:
Expand All @@ -334,7 +337,8 @@ def _on_room_event(self, event: proto_room.RoomEvent):
self.emit("track_muted", participant, publication)
elif which == "track_unmuted":
sid = event.track_unmuted.participant_sid
participant = self._retrieve_participant(sid)
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
publication = participant.tracks[event.track_unmuted.track_sid]
publication._info.muted = False
if publication.track:
Expand All @@ -343,8 +347,9 @@ def _on_room_event(self, event: proto_room.RoomEvent):
self.emit("track_unmuted", participant, publication)
elif which == "active_speakers_changed":
speakers: list[Participant] = []
# TODO: pass participant identity
for sid in event.active_speakers_changed.participant_sids:
speakers.append(self._retrieve_participant(sid))
speakers.append(self._retrieve_participant(sid, ""))

self.emit("active_speakers_changed", speakers)
elif which == "room_metadata_changed":
Expand All @@ -353,7 +358,8 @@ def _on_room_event(self, event: proto_room.RoomEvent):
self.emit("room_metadata_changed", old_metadata, self.metadata)
elif which == "participant_metadata_changed":
sid = event.participant_metadata_changed.participant_sid
participant = self._retrieve_participant(sid)
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
old_metadata = participant.metadata
participant._info.metadata = event.participant_metadata_changed.metadata
self.emit(
Expand All @@ -364,15 +370,17 @@ def _on_room_event(self, event: proto_room.RoomEvent):
)
elif which == "participant_name_changed":
sid = event.participant_name_changed.participant_sid
participant = self._retrieve_participant(sid)
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
old_name = participant.name
participant._info.name = event.participant_name_changed.name
self.emit(
"participant_name_changed", participant, old_name, participant.name
)
elif which == "connection_quality_changed":
sid = event.connection_quality_changed.participant_sid
participant = self._retrieve_participant(sid)
# TODO: pass participant identity
participant = self._retrieve_participant(sid, "")
self.emit(
"connection_quality_changed",
participant,
Expand All @@ -391,7 +399,9 @@ def _on_room_event(self, event: proto_room.RoomEvent):

data = bytes(native_data)
FfiHandle(owned_buffer_info.handle.id)
rparticipant = self._retrieve_remote_participant(packet.participant_sid, packet.participant_identity)
rparticipant = self._retrieve_remote_participant(
packet.participant_sid, packet.participant_identity
)
self.emit(
"data_received",
DataPacket(
Expand All @@ -402,7 +412,9 @@ def _on_room_event(self, event: proto_room.RoomEvent):
),
)
elif which_val == "sip_dtmf":
rparticipant = self._retrieve_remote_participant(packet.participant_sid, packet.participant_identity)
rparticipant = self._retrieve_remote_participant(
packet.participant_sid, packet.participant_identity
)
self.emit(
"sip_dtmf_received",
SipDTMF(
Expand All @@ -415,7 +427,8 @@ def _on_room_event(self, event: proto_room.RoomEvent):
elif which == "e2ee_state_changed":
sid = event.e2ee_state_changed.participant_sid
e2ee_state = event.e2ee_state_changed.state
self.emit("e2ee_state_changed", self._retrieve_participant(sid), e2ee_state)
# TODO: pass participant identity
self.emit("e2ee_state_changed", self._retrieve_participant(sid, ""), e2ee_state)
elif which == "connection_state_changed":
connection_state = event.connection_state_changed.state
self.connection_state = connection_state
Expand All @@ -429,7 +442,9 @@ def _on_room_event(self, event: proto_room.RoomEvent):
elif which == "reconnected":
self.emit("reconnected")

def _retrieve_remote_participant(self, sid: str, identity: str) -> RemoteParticipant:
def _retrieve_remote_participant(
self, sid: str, identity: str
) -> RemoteParticipant:
"""Retrieve a remote participant by sid or identity"""
participant = None
if identity:
Expand Down
2 changes: 1 addition & 1 deletion livekit-rtc/rust-sdks

0 comments on commit 7668f5f

Please sign in to comment.