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

Friendly Automation asteriskteam at digium.com
Tue Apr 26 12:22:47 CDT 2022


Friendly Automation has submitted this change. ( 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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



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: 2
Gerrit-Owner: Maximilian Fridrich <m.fridrich at commend.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220426/182809bb/attachment.html>


More information about the asterisk-code-review mailing list