diff options
author | Kevin Harwell <kharwell@digium.com> | 2017-06-29 15:06:21 -0500 |
---|---|---|
committer | Kevin Harwell <kharwell@digium.com> | 2017-06-30 10:57:34 -0500 |
commit | e7d41050e0672a1cf670957dd0b13a7a1e2131ff (patch) | |
tree | e168a0206748ad9becd1e2717eb37be60eff09b6 /apps/app_stream_echo.c | |
parent | 7df7b8a90c42068d0e9badee974a7efb065c741b (diff) |
app_stream_echo: misc bug fixes
Fixed the following bugs:
* calls to stream_echo_write had the last two parameters swapped
* ast_read should have been ast_read_stream
* added a null check on the frame's subclass format
This also resets the update_sent flag upon receiving SRRCHANGE control frame.
This will then force a video update.
ASTERISK-26997
Change-Id: I6ad7c8253559b800800433c52339e7f5aa583566
Diffstat (limited to 'apps/app_stream_echo.c')
-rw-r--r-- | apps/app_stream_echo.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/apps/app_stream_echo.c b/apps/app_stream_echo.c index 79d15917b..9695dcc87 100644 --- a/apps/app_stream_echo.c +++ b/apps/app_stream_echo.c @@ -108,7 +108,6 @@ static int stream_echo_write(struct ast_channel *chan, struct ast_frame *frame, * we simply want to echo it back out onto the same stream number. */ num = ast_channel_is_multistream(chan) ? frame->stream_num : -1; - if (ast_write_stream(chan, num, frame)) { return stream_echo_write_error(chan, frame, num); } @@ -120,7 +119,8 @@ static int stream_echo_write(struct ast_channel *chan, struct ast_frame *frame, * Note, if the channel is not multi-stream capable then one_to_one will * always be true, so it is safe to also not check for that here too. */ - if (one_to_one || ast_format_get_type(frame->subclass.format) != type) { + if (one_to_one || !frame->subclass.format || + ast_format_get_type(frame->subclass.format) != type) { return 0; } @@ -141,7 +141,6 @@ static int stream_echo_write(struct ast_channel *chan, struct ast_frame *frame, for (i = 0; i < ast_stream_topology_get_count(topology); ++i) { struct ast_stream *stream = ast_stream_topology_get_stream(topology, i); - if (num != i && ast_stream_get_type(stream) == type) { if (ast_write_stream(chan, i, frame)) { return stream_echo_write_error(chan, frame, i); @@ -171,7 +170,7 @@ static int stream_echo_perform(struct ast_channel *chan, request_change = 0; } - f = ast_read(chan); + f = ast_read_stream(chan); if (!f) { return -1; } @@ -186,11 +185,13 @@ static int stream_echo_perform(struct ast_channel *chan, if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass.integer == AST_CONTROL_VIDUPDATE && !update_sent) { - if (stream_echo_write(chan, f, one_to_one, type)) { + if (stream_echo_write(chan, f, type, one_to_one)) { ast_frfree(f); return -1; } update_sent = 1; + } else if (f->subclass.integer == AST_CONTROL_SRCCHANGE) { + update_sent = 0; } else if (f->subclass.integer == AST_CONTROL_STREAM_TOPOLOGY_CHANGED) { update_sent = 0; one_to_one = 0; /* Switch writing to one to many */ @@ -200,14 +201,14 @@ static int stream_echo_perform(struct ast_channel *chan, .frametype = AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_VIDUPDATE, }; - stream_echo_write(chan, &frame, one_to_one, type); + stream_echo_write(chan, &frame, type, one_to_one); update_sent = 1; } if (f->frametype != AST_FRAME_CONTROL && f->frametype != AST_FRAME_MODEM && f->frametype != AST_FRAME_NULL && - stream_echo_write(chan, f, one_to_one, type)) { + stream_echo_write(chan, f, type, one_to_one)) { ast_frfree(f); return -1; } |