Open
Conversation
The alt_pjsua demo uses alt_pjsua_aud.c and alt_pjsua_vid.c to replace the standard PJMEDIA audio/video backend, demonstrating how a third-party media stack integrates with pjsua-lib. Without a way to inject arbitrary SDP, there was no automated way to verify that the custom media layer correctly produces well-formed session descriptions in outgoing INVITEs and 200 OK answers. A --custom-sdp command-line option is added to pjsua_app (compiled with PJSUA_MEDIA_HAS_PJMEDIA=0) and wired to an on_call_sdp_created callback so the application can supply its own SDP. Two SIPp-based test pairs exercise this in both call directions: - UAC test: alt_pjsua sends an INVITE with custom audio SDP (PCMU); SIPp verifies the codec appears and answers with a matching 200 OK. Audio-only is used here because pjsua provisions only one media channel by default for outgoing calls, so a two-section custom SDP would trigger an assertion in pjsua_media_channel_update. - UAS test: SIPp sends an INVITE with audio+video (PCMU + H263-1998/96); alt_pjsua auto-answers with the custom SDP and logs the incoming SDP. The UAS direction naturally supports two media sections because med_prov_cnt is derived from the remote INVITE's media count. alt_pjsua_vid.c gains stub mocks for AVI player/recorder functions and pjsua_call_get_vid_conf_port. These symbols are normally compiled in pjsua_vid.c behind PJSUA_MEDIA_HAS_PJMEDIA guards; without the stubs the linker cannot resolve them when the whole project is built with PJSUA_MEDIA_HAS_PJMEDIA=0. A dedicated alt-pjsua CI job copies pjsip-apps/src/3rdparty_media_sample/config_site.h (which sets PJSUA_MEDIA_HAS_PJMEDIA=0, PJMEDIA_HAS_VIDEO=1, and disables all standard codecs) into pjlib/include/pj/, builds only the libraries (make lib), then compiles alt_pjsua and runs the SIPp tests. A dedicated job is used rather than appending to an existing one so the test environment exactly matches the third-party media configuration without inheriting unrelated defines.
1a13781 to
81ab3cb
Compare
Contributor
Author
|
Still UAC has to be fixed (Video does not work). |
The UAC test was audio-only because on_call_sdp_created_cb replaces the
generated SDP after pjsua_media_channel_init has already provisioned
call->med_prov_cnt from call->opt (aud_cnt + vid_cnt + txt_cnt). The
provisioned count may be larger than the two-section custom SDP, but it
can also be smaller when fewer transports were actually allocated; e.g.
only one RTP socket appears in the log (port 4000) even when vid_cnt=1.
In that situation pjsua_media_channel_update's assertion
call->med_prov_cnt >= local_sdp->media_count
fires: med_prov_cnt=1 < custom_sdp->media_count=2.
For UAS the assertion never fires because med_prov_cnt is set directly
from rem_sdp->media_count (the incoming INVITE already carries 2 media
sections), which is always >= the local answer.
Fix: after the on_call_sdp_created callback in pjsua_media_channel_create_sdp,
sync med_prov_cnt upward to match sdp->media_count if the callback added media
sections. This mirrors the existing pattern for the rem_sdp (UAS) path
(lines 2539-2541: "this media count must never decrease").
The other SDP callbacks (on_call_rx_offer, on_call_tx_offer) are invoked
*before* pjsua_media_channel_create_sdp and let apply_call_setting() re-
provision transports, so med_prov_cnt is already correct when they return.
on_call_sdp_created is unique in being invoked at the end of SDP creation,
bypassing re-provisioning, so an explicit sync is needed there.
The fix lives in pjsua_media.c (not in the application callback) so that any
on_call_sdp_created implementation that adds media sections automatically
gets correct behaviour, without reaching into pjsua_internal.h.
The UAC and UAS XML/PY test scripts are updated to carry both
m=audio (PCMU/0) and m=video (H263-1998/96) in every SDP, and to
verify via ereg/CLI-expect that both codec lines appear.
944cb3c to
c22c361
Compare
|
|
||
| /* Sync med_prov_cnt with the final SDP media count in case the callback | ||
| * added or replaced media sections (e.g. custom SDP with more m= lines). | ||
| * Mirrors the same invariant maintained for the rem_sdp (UAS) path above: |
Contributor
Author
There was a problem hiding this comment.
This is my proposed fix to fix alt-pjsua-uac-custom-sdp.
Now the test cases should be green.
Contributor
Author
|
PTAL @sauwming, @nanangizz How I would approach this PR:
|
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.
The alt_pjsua demo lacked a way to supply application-defined SDP, making it impossible to verify that third-party media stacks can inject arbitrary session descriptions into outgoing INVITEs and 200 OK answers.
This PR adds tests for UAS and UAC that are using 3rd-party media.