early-afternoon-97327
09/22/2025, 11:14 AMtall-airline-16756
09/22/2025, 11:14 AMtall-airline-16756
09/22/2025, 11:14 AMSIPCallDirection enum. This enum clearly defines the call direction with these values:
• SCD_INBOUND for inbound calls
• SCD_OUTBOUND for outbound calls
This approach is the most straightforward and reliable way to identify the call direction. If you have any questions or need more help, please don’t hesitate to ask—I’m here for you!
Sources: livekit/livekit_sip.pb.go | SIP participant | LiveKit Docs | livekit-protocol/livekit/protocol/sip.pyiearly-afternoon-97327
09/22/2025, 11:15 AMtall-airline-16756
09/22/2025, 11:16 AMfrom livekit import rtc
def check_sip_call_direction(participant):
"""
Check if a SIP participant represents an inbound or outbound call
by examining the participant attributes.
Args:
participant: LiveKit participant object
Returns:
str: "inbound" or "outbound"
"""
if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
# Inbound calls have a ruleID attribute, outbound calls do not
if 'sip.ruleID' in participant.attributes:
return "inbound"
else:
return "outbound"
return None
# Example usage in a participant connected handler:
async def on_participant_connected(participant: rtc.RemoteParticipant):
if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
direction = check_sip_call_direction(participant)
print(f"SIP participant connected: {participant.identity}")
print(f"Call direction: {direction}")
This snippet works by checking the sip.ruleID attribute to figure out the call direction. Typically, inbound calls have this attribute, while outbound calls don’t. If anything feels unclear or if you want me to walk you through it step-by-step, just let me know—I’m here to help!
Sources: SIP participant | LiveKit Docs | telephony/sip_lifecycle.py