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
This commit is contained in:
Maximilian Fridrich 2022-04-13 15:12:03 +02:00 committed by Friendly Automation
parent f565982e0e
commit 5d3125fa71
1 changed files with 17 additions and 0 deletions

View File

@ -2607,9 +2607,11 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
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 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
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);