summaryrefslogtreecommitdiff
path: root/main/channel.c
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-02-24 14:30:33 -0700
committerGeorge Joseph <gjoseph@digium.com>2017-03-01 07:30:49 -0700
commit0560c32375a5edd110d544f5762edb6f1fb0f005 (patch)
tree33897ad2d781ccdc0c2959a1cf11291770f6eea0 /main/channel.c
parent6d3c1a4a2129c7a673b43ca21950f8fe6ff7f92d (diff)
stream: Unit tests for stream read and tweaks framework
* Removed the AST_CHAN_TP_MULTISTREAM tech property. We now rely on read_stream being set to indicate a multi stream channel. * Added ast_channel_is_multistream convenience function. * Fixed issue where stream and default_stream weren't being set on a frame retrieved from the queue. * Now testing for NULL being returned from the driver's read or read_stream callback. * Fixed issue where the dropnondefault code was crashing on a NULL f. * Now enforcing that if either read_stream or write_stream are set when ast_channel_tech_set is called that BOTH are set. * Added the unit tests. ASTERISK-26816 Change-Id: If7792b20d782e71e823dabd3124572cf0a4caab2
Diffstat (limited to 'main/channel.c')
-rw-r--r--main/channel.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/main/channel.c b/main/channel.c
index e3e9561fe..12a30e048 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3944,13 +3944,17 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
default:
break;
}
- } else if (!(ast_channel_tech(chan)->properties & AST_CHAN_TP_MULTISTREAM) && (
- f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
- /* Since this channel driver does not support multistream determine the default stream this frame
- * originated from and update the frame to include it.
- */
- stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
- f->stream_num = ast_stream_get_position(stream);
+ } else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
+ if (ast_channel_tech(chan) && ast_channel_tech(chan)->read_stream) {
+ stream = ast_stream_topology_get_stream(ast_channel_get_stream_topology(chan), f->stream_num);
+ default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
+ } else {
+ /* Since this channel driver does not support multistream determine the default stream this frame
+ * originated from and update the frame to include it.
+ */
+ stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
+ f->stream_num = ast_stream_get_position(stream);
+ }
}
} else {
ast_channel_blocker_set(chan, pthread_self());
@@ -3970,7 +3974,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
* thing different is that we need to find the default stream so we know whether to invoke the
* default stream logic or not (such as transcoding).
*/
- if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
+ if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
stream = ast_stream_topology_get_stream(ast_channel_get_stream_topology(chan), f->stream_num);
default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
}
@@ -3980,7 +3984,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
/* Since this channel driver does not support multistream determine the default stream this frame
* originated from and update the frame to include it.
*/
- if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
+ if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
f->stream_num = ast_stream_get_position(stream);
}
@@ -3989,13 +3993,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
}
- if (dropnondefault && stream != default_stream) {
- /* If the frame originates from a non-default stream and the caller can not handle other streams
- * absord the frame and replace it with a null one instead.
- */
- ast_frfree(f);
- f = &ast_null_frame;
- } else if (stream == default_stream) {
+ if (stream == default_stream) {
/* Perform the framehook read event here. After the frame enters the framehook list
* there is no telling what will happen, <insert mad scientist laugh here>!!! */
f = ast_framehook_list_read_event(ast_channel_framehooks(chan), f);
@@ -4022,6 +4020,14 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio, int
AST_LIST_NEXT(f, frame_list) = NULL;
}
+ if (dropnondefault && stream != default_stream) {
+ /* If the frame originates from a non-default stream and the caller can not handle other streams
+ * absorb the frame and replace it with a null one instead.
+ */
+ ast_frfree(f);
+ f = &ast_null_frame;
+ }
+
switch (f->frametype) {
case AST_FRAME_CONTROL:
if (f->subclass.integer == AST_CONTROL_ANSWER) {