pjmedia/pjsua: add on-demand stream keep-alive API - #15
Merged
darshan-verkada merged 2 commits intoJun 17, 2026
Merged
Conversation
Add pjmedia_stream_send_keep_alive(), pjsua_call_send_stream_keep_alive() and pjsua2 Call::sendStreamKeepAlive() to send an empty RTP + RTCP keep-alive on demand, independent of PJMEDIA_STREAM_ENABLE_KA (whose auto-KA only fires from within put_frame()). This lets an application keep the media path / NAT binding alive when the local sound device has been disconnected from the stream (parked audio) but the SIP/media session must stay up, without reaching into the raw pjmedia stream port and calling put_frame() from an app thread. The pjsua-lib entry point sends under PJSUA_LOCK and revalidates the stream, so it is mutually exclusive with pjsua_media_channel_deinit() and cannot use-after-free the stream during call teardown. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MattMacGregor
requested changes
Jun 15, 2026
Per review feedback: since PJMEDIA_STREAM_ENABLE_KA=1 in Verkada builds, send_keep_alive_packet is always compiled in. Replace the duplicated logic in pjmedia_stream_send_keep_alive with a direct call-through; return PJ_ENOTSUP as a fallback for builds with KA disabled. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MattMacGregor
approved these changes
Jun 16, 2026
darshan-verkada
merged commit Jun 17, 2026
b3f126f
into
intercom/release-2-15
20 of 31 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crash signature
Summary
pjmedia_stream_send_keep_alive()— a build-flag-independent public API that sends an empty RTP packet + RTCP to keep the media path / NAT binding alive whenput_frame()is not driving the stream (e.g. local audio device disconnected but SIP session must stay up).pjsua_call_send_stream_keep_alive(call_id, med_idx)— a pjsua-level wrapper that acquiresPJSUA_LOCKbefore touching the stream, making it mutually exclusive withpjmedia_channel_deinit(). This prevents a use-after-free where the caller's thread could race stream teardown.Call::sendStreamKeepAlive(med_idx)pjsua2 C++ binding.Test plan
Make intercom call using command, make sure it switches to
livekit. check SIP audio threads are closed, but call is still active for 2 minutes.🤖 Generated with Claude Code