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
This commit is contained in:
George Joseph
2017-02-24 14:30:33 -07:00
parent 6d3c1a4a21
commit 0560c32375
4 changed files with 350 additions and 50 deletions

View File

@@ -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);
}