summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-04-24 15:59:44 +0000
committerJoshua Colp <jcolp@digium.com>2017-04-27 10:39:46 +0000
commit2b22c3c84b8894c5663fec8655b0670b6bca4078 (patch)
tree119cd5ee07ec1d1ca60ff7c5765f6fd21cce1a28 /tests
parentdc6654d969224129bdd7b4080eda6e027c6454b9 (diff)
channel: Add ability to request an outgoing channel with stream topology.
This change extends the ast_request functionality by adding another function and callback to create an outgoing channel with a requested stream topology. Fallback is provided by either converting the requested stream topology into a format capabilities structure if the channel driver does not support streams or by converting the requested format capabilities into a stream topology if the channel driver does support streams. The Dial application has also been updated to request an outgoing channel with the stream topology of the calling channel. ASTERISK-26959 Change-Id: Ifa9037a672ac21d42dd7125aa09816dc879a70e6
Diffstat (limited to 'tests')
-rw-r--r--tests/test_stream.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test_stream.c b/tests/test_stream.c
index 3bab67c2c..7eecf373b 100644
--- a/tests/test_stream.c
+++ b/tests/test_stream.c
@@ -1773,6 +1773,63 @@ done:
return res;
}
+AST_TEST_DEFINE(format_cap_from_stream_topology)
+{
+ RAII_VAR(struct ast_format_cap *, caps, NULL, ao2_cleanup);
+ RAII_VAR(struct ast_format_cap *, stream_caps, NULL, ao2_cleanup);
+ struct ast_stream_topology *topology;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "format_cap_from_stream_topology";
+ info->category = "/main/stream/";
+ info->summary = "stream topology to format capabilities conversion test";
+ info->description =
+ "Test that converting a stream topology to format capabilities results in expected formats";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ caps = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
+ if (!caps) {
+ ast_test_status_update(test, "Could not allocate an empty format capabilities structure\n");
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_format_cap_append(caps, ast_format_ulaw, 0)) {
+ ast_test_status_update(test, "Failed to append a ulaw format to capabilities for channel nativeformats\n");
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_format_cap_append(caps, ast_format_h264, 0)) {
+ ast_test_status_update(test, "Failed to append an h264 format to capabilities for channel nativeformats\n");
+ return AST_TEST_FAIL;
+ }
+
+ topology = ast_stream_topology_create_from_format_cap(caps);
+ if (!topology) {
+ ast_test_status_update(test, "Failed to create a stream topology from format capabilities of ulaw and h264\n");
+ return AST_TEST_FAIL;
+ }
+
+ stream_caps = ast_format_cap_from_stream_topology(topology);
+ if (!stream_caps) {
+ ast_test_status_update(test, "Failed to create a format capabilities from a stream topology\n");
+ ast_stream_topology_free(topology);
+ return AST_TEST_FAIL;
+ }
+
+ ast_stream_topology_free(topology);
+
+ if (!ast_format_cap_identical(caps, stream_caps)) {
+ ast_test_status_update(test, "Converting format capabilities into topology and back resulted in different formats\n");
+ return AST_TEST_FAIL;
+ }
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(stream_create);
@@ -1797,6 +1854,7 @@ static int unload_module(void)
AST_TEST_UNREGISTER(stream_topology_change_request_from_channel_non_multistream);
AST_TEST_UNREGISTER(stream_topology_change_request_from_application);
AST_TEST_UNREGISTER(stream_topology_change_request_from_channel);
+ AST_TEST_UNREGISTER(format_cap_from_stream_topology);
return 0;
}
@@ -1823,6 +1881,7 @@ static int load_module(void)
AST_TEST_REGISTER(stream_topology_change_request_from_channel_non_multistream);
AST_TEST_REGISTER(stream_topology_change_request_from_application);
AST_TEST_REGISTER(stream_topology_change_request_from_channel);
+ AST_TEST_REGISTER(format_cap_from_stream_topology);
return AST_MODULE_LOAD_SUCCESS;
}