Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: Create matching joint topology #344

Closed
wants to merge 1 commit into from

Conversation

btriller
Copy link
Contributor

When creating joint topologies, resolved topologies have to have equal stream counts. Currently this only happens if first of the two given topologies has equal or more streams.
This change adds remaining streams of second topology to the joint topology.

@btriller
Copy link
Contributor Author

cherry-pick-to: 21
cherry-pick-to: 20
cherry-pick-to: 18

@maximilianfridrich
Copy link
Contributor

maximilianfridrich commented Sep 22, 2023

While developing, I recommend building Asterisk with the --enable-dev-mode flag (./configure --enable-dev-mode).

@maximilianfridrich
Copy link
Contributor

maximilianfridrich commented Sep 22, 2023

This change adds remaining streams of second topology to the joint topology.

Isn't that what operation: union does? Have you tried doing codec_prefs_* = ..., operation: union, ...?

main/stream.c Outdated Show resolved Hide resolved
When creating joint topologies, resolved topologies have to have equal
stream counts. Currently this only happens if first of the two given
topologies has equal or more streams.
This change adds remaining streams of second topology to the joint
topology.
@btriller
Copy link
Contributor Author

This change adds remaining streams of second topology to the joint topology.

Isn't that what operation: union does? Have you tried doing codec_prefs_* = ..., operation: union, ...?

This is about streams (m=audio/video lines) in SDP. union operation works on codecs/formats in these streams.

@maximilianfridrich
Copy link
Contributor

maximilianfridrich commented Sep 22, 2023

That makes sense, sorry for the confusion.

@maximilianfridrich
Copy link
Contributor

Looks good to me. I also ran the ACN testsuite PR with it and there's no issues.

@btriller Could you describe a scenario (with configured endpoint settings, SDP offers and answers) that failed before this change and now works? Then I can add it to the testsuite to ensure it works and will continue to work.

@btriller
Copy link
Contributor Author

btriller commented Nov 3, 2023

Looks good to me. I also ran the ACN testsuite PR with it and there's no issues.

@btriller Could you describe a scenario (with configured endpoint settings, SDP offers and answers) that failed before this change and now works? Then I can add it to the testsuite to ensure it works and will continue to work.

Attached scenario fails. Without this PR's change, Asterisk emits a reINVITE after answering to alice (caller). Asterisk logs following:

[Nov  3 14:09:32] WARNING[3743379] res_pjsip_session.c: PJSIP/alice-00000000: Local SDP contains 1 media streams while we expected it to contain 2

testsuite.txt

@maximilianfridrich
Copy link
Contributor

Thank you for providing the test case!

Without this PR's change, Asterisk emits a reINVITE after answering to alice (caller)

You're right, I can reproduce that. With your change the reINVITE is gone. Unfortunately, the SIPP scenario still fails for me - the caller receives all codecs on the SDP answer and I am not sure yet why. I don't think this has anything to do with this PR though.

@btriller
Copy link
Contributor Author

btriller commented Nov 7, 2023

Thank you for providing the test case!

Without this PR's change, Asterisk emits a reINVITE after answering to alice (caller)

You're right, I can reproduce that. With your change the reINVITE is gone. Unfortunately, the SIPP scenario still fails for me - the caller receives all codecs on the SDP answer and I am not sure yet why. I don't think this has anything to do with this PR though.

I get No common codecs between channels and transcoding allowed. Still answering call. for the video stream.

@maximilianfridrich Maybe like that?

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 706d19bf09..03095d5911 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -775,6 +775,9 @@ static int chan_pjsip_answer_with_stream_topology(struct ast_channel *ast, struc
 		}
 
 		for (index = 0; index < ast_stream_topology_get_count(resolved_top); ++index) {
+			if (ast_stream_get_state(ast_stream_topology_get_stream(resolved_top, index)) == AST_STREAM_STATE_REMOVED) {
+				continue;
+			}
 			if (ast_format_cap_empty(ast_stream_get_formats(ast_stream_topology_get_stream(resolved_top, index)))) {
 				if (prefs->transcode == CODEC_NEGOTIATION_TRANSCODE_ALLOW) {
 					ast_log(LOG_DEBUG, "%s No common codecs between channels and transcoding allowed. Still answering call.\n",

@btriller
Copy link
Contributor Author

diff --git a/channels/chan_pjsip.c b/channels/chan_pjsip.c
index 706d19bf09..03095d5911 100644
--- a/channels/chan_pjsip.c
+++ b/channels/chan_pjsip.c
@@ -775,6 +775,9 @@ static int chan_pjsip_answer_with_stream_topology(struct ast_channel *ast, struc
 		}
 
 		for (index = 0; index < ast_stream_topology_get_count(resolved_top); ++index) {
+			if (ast_stream_get_state(ast_stream_topology_get_stream(resolved_top, index)) == AST_STREAM_STATE_REMOVED) {
+				continue;
+			}
 			if (ast_format_cap_empty(ast_stream_get_formats(ast_stream_topology_get_stream(resolved_top, index)))) {
 				if (prefs->transcode == CODEC_NEGOTIATION_TRANSCODE_ALLOW) {
 					ast_log(LOG_DEBUG, "%s No common codecs between channels and transcoding allowed. Still answering call.\n",

You added this patch here https://github.com/asterisk/asterisk/compare/b85addb8d96ac646dbe26ccd79fe3fd9708d2b38..317a31e6bf2ea679a7bacab46d3b6d5cfabc5dd0 but removed it https://github.com/asterisk/asterisk/compare/317a31e6bf2ea679a7bacab46d3b6d5cfabc5dd0..eb5b500f70ed85d6f177e8b44c1d7455c2167c5a.
Was removal intended? @maximilianfridrich

@maximilianfridrich
Copy link
Contributor

Was removal intended?

Yes, that was intended. This change broke many test cases of channels/pjsip/codec_negotiation while your provided test case was still failing. I haven't managed to make that test pass yet. Have you managed to make it pass?

@asteriskteam
Copy link
Contributor

This PR has been marked stale because it has been in "Changes Requested" or "submitter-action-required" state for 28 days or more. Please make the requested changes within 14 days or the PR will be closed.

@asteriskteam
Copy link
Contributor

This PR has been closed because it has been in "Changes Requested" or "submitter-action-required" state for more than 42 days.

@btriller
Copy link
Contributor Author

btriller commented Jun 3, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants