melodic-vegetable-78787
02/25/2025, 8:16 AMgray-monkey-83525
02/25/2025, 8:16 AMtrack_subscribed
event to trigger the start of your recording. This event is fired when a track is successfully subscribed to, indicating that the participant is ready to communicate.
To ensure that the recording starts only when the participant joins, you should wait for the track_subscribed
event for the audio track of the SIP participant. This will ensure that the recording does not start during the ringing phase. You can modify your code to check for the track_subscribed
event and start the recording only when this event is triggered for the audio track of the SIP participant.
Would you like more detailed guidance on implementing this approach?
Sources:
- LiveKit documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.melodic-vegetable-78787
02/25/2025, 8:18 AMgray-monkey-83525
02/25/2025, 8:18 AMtrack_subscribed
event might not be triggered as expected. In such cases, you can use the sip.callStatus
attribute to determine when the call is active. According to the LiveKit SIP documentation, the sip.callStatus
changes to active
when the SIP participant subscribes to any remote audio tracks, indicating that the call is connected.
You can listen for changes in the sip.callStatus
attribute to start the recording. This approach ensures that the recording begins only when the call is active, avoiding the ringing phase. Here's a conceptual approach:
1. Monitor sip.callStatus
: Use the participant_attributes_changed
event to monitor changes in the sip.callStatus
attribute.
2. Start Recording: When sip.callStatus
changes to active
, initiate the recording process.
Would you like more detailed guidance on implementing this approach?
Sources:
- LiveKit SIP documentation 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.melodic-vegetable-78787
02/25/2025, 8:19 AMgray-monkey-83525
02/25/2025, 8:19 AMsip.callStatus
changes to `active`:
async def entrypoint(ctx: JobContext):
call_active_event = asyncio.Event()
@ctx.room.on("participant_attributes_changed")
def on_attributes_changed(changed_attributes: dict[str, str], participant):
if changed_attributes.get("sip.callStatus") == "active":
call_active_event.set()
await ctx.connect(auto_subscribe=AutoSubscribe.AUDIO_ONLY)
participant = await ctx.wait_for_participant()
# Wait for the call to become active
await call_active_event.wait()
# Start recording once the call is active
egress_id = await record_call(ctx, participant.identity)
logger.info(f"Recording started with egress ID: {egress_id}")
async def record_call(ctx, participant_identity):
# Implement your recording logic here
pass
This snippet sets up a listener for the participant_attributes_changed
event to detect when the sip.callStatus
becomes active
, indicating that the call is connected. Once the status is active, it starts the recording.
Would you like more details on any part of this code?
Sources:
- https://livekit-users.slack.com/archives/C07FRP66XGE/p1733253226.914509
- https://docs.livekit.io/sip/quickstarts/making-calls/ 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.