[Asterisk-code-review] app_dial: Flip stream direction of outgoing channel. (asterisk[master])

Maximilian Fridrich asteriskteam at digium.com
Thu Apr 14 06:25:33 CDT 2022


Maximilian Fridrich has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18387 )


Change subject: app_dial: Flip stream direction of outgoing channel.
......................................................................

app_dial: Flip stream direction of outgoing channel.

When executing dial, the topology of the incoming channel is cloned and
used for the outgoing channel. This creates issues when an incoming
stream is sendonly or recvonly as the stream state of the outgoing
channel will be the same as the stream state of the incoming channel.

Now the stream state is flipped for the outgoing stream in
dial_exec_full if the incoming stream topology is recvonly or sendonly.

ASTERISK-29655
Reported by: Michael Auracher

ASTERISK-29638
Reported by: Michael Auracher

Change-Id: I294dc834ac9a5f048b101b691669959e9df630e1
---
M apps/app_dial.c
1 file changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/18387/1

diff --git a/apps/app_dial.c b/apps/app_dial.c
index 8be6eff..7ea23f3 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -2607,9 +2607,11 @@
 		struct ast_channel *tc; /* channel for this destination */
 		char *number;
 		char *tech;
+		int i;
 		size_t tech_len;
 		size_t number_len;
 		struct ast_stream_topology *topology;
+		struct ast_stream *stream;
 
 		cur = ast_strip(cur);
 		if (ast_strlen_zero(cur)) {
@@ -2675,6 +2677,21 @@
 
 		ast_channel_unlock(chan);
 
+		for (i = 0; i < ast_stream_topology_get_count(topology); ++i) {
+			stream = ast_stream_topology_get_stream(topology, i);
+			/* For both recvonly and sendonly the stream state reflects our state, that is we
+			 * are receiving only and we are sending only. Since we are requesting a
+			 * channel for the peer, we need to swap this to reflect what we will be doing.
+			 * That is, if we are receiving from Alice then we want to be sending to Bob,
+			 * so swap recvonly to sendonly and vice versa.
+			 */
+			if (ast_stream_get_state(stream) == AST_STREAM_STATE_RECVONLY) {
+				ast_stream_set_state(stream, AST_STREAM_STATE_SENDONLY);
+			} else if (ast_stream_get_state(stream) == AST_STREAM_STATE_SENDONLY) {
+				ast_stream_set_state(stream, AST_STREAM_STATE_RECVONLY);
+			}
+		}
+
 		tc = ast_request_with_stream_topology(tmp->tech, topology, NULL, chan, tmp->number, &cause);
 
 		ast_stream_topology_free(topology);

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18387
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I294dc834ac9a5f048b101b691669959e9df630e1
Gerrit-Change-Number: 18387
Gerrit-PatchSet: 1
Gerrit-Owner: Maximilian Fridrich <m.fridrich at commend.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220414/1af753fb/attachment.html>


More information about the asterisk-code-review mailing list