summaryrefslogtreecommitdiff
path: root/main/channel_internal_api.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_internal_api.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_internal_api.c')
-rw-r--r--main/channel_internal_api.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 362bd1a3d..d7ae8f9c1 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -867,7 +867,7 @@ void ast_channel_nativeformats_set(struct ast_channel *chan,
return;
}
- if (!chan->tech || !(chan->tech->properties & AST_CHAN_TP_MULTISTREAM) || !value) {
+ if ((!ast_channel_is_multistream(chan)) || !value) {
struct ast_stream_topology *new_topology;
if (!value) {
@@ -949,6 +949,10 @@ const struct ast_channel_tech *ast_channel_tech(const struct ast_channel *chan)
}
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
{
+ if (value->read_stream || value->write_stream) {
+ ast_assert(value->read_stream && value->write_stream);
+ }
+
chan->tech = value;
}
enum ast_channel_adsicpe ast_channel_adsicpe(const struct ast_channel *chan)
@@ -1798,7 +1802,7 @@ struct ast_stream_topology *ast_channel_set_stream_topology(struct ast_channel *
ast_assert(chan != NULL);
/* A non-MULTISTREAM channel can't manipulate topology directly */
- ast_assert(chan->tech != NULL && (chan->tech->properties & AST_CHAN_TP_MULTISTREAM));
+ ast_assert(ast_channel_is_multistream(chan));
/* Unless the channel is being destroyed, we always want a topology on
* it even if its empty.
@@ -1839,3 +1843,8 @@ void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1,
channel_set_default_streams(chan1);
channel_set_default_streams(chan2);
}
+
+int ast_channel_is_multistream(struct ast_channel *chan)
+{
+ return (chan->tech && chan->tech->read_stream && chan->tech->write_stream);
+}