sdp: Add support for T.38

This change adds a T.38 format which can be used in a stream
topology to specify that a UDPTL stream needs to be created.
The SDP API has been changed to understand T.38 and create
the UDPTL session, add the attributes, and parse the attributes.

This change does not change the boundary of the T.38 state
machine. It is still up to the channel driver to implement and
act on it (such as queueing control frames or reacting to them).

ASTERISK-26949

Change-Id: If28956762ccb8ead562ac6c03d162d3d6014f2c7
This commit is contained in:
Joshua Colp
2017-04-14 10:21:13 +00:00
committed by Richard Mudgett
parent 32b3e36c68
commit 19a79ae12c
10 changed files with 623 additions and 47 deletions

View File

@@ -130,6 +130,22 @@ static int validate_rtpmap(struct ast_test *test, const struct ast_sdp_m_line *m
return -1;
}
static enum ast_test_result_state validate_t38(struct ast_test *test, const struct ast_sdp_m_line *m_line)
{
struct ast_sdp_a_line *a_line;
a_line = ast_sdp_m_find_attribute(m_line, "T38FaxVersion", -1);
ast_test_validate(test, a_line && !strcmp(a_line->value, "0"));
a_line = ast_sdp_m_find_attribute(m_line, "T38FaxMaxBitRate", -1);
ast_test_validate(test, a_line && !strcmp(a_line->value, "14400"));
a_line = ast_sdp_m_find_attribute(m_line, "T38FaxRateManagement", -1);
ast_test_validate(test, a_line && !strcmp(a_line->value, "transferredTCF"));
return AST_TEST_PASS;
}
AST_TEST_DEFINE(invalid_rtpmap)
{
/* a=rtpmap: is already assumed. This is the part after that */
@@ -405,6 +421,7 @@ AST_TEST_DEFINE(topology_to_sdp)
struct sdp_format formats[] = {
{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
{ AST_MEDIA_TYPE_IMAGE, "t38" },
};
switch(cmd) {
@@ -437,7 +454,7 @@ AST_TEST_DEFINE(topology_to_sdp)
goto end;
}
if (ast_sdp_get_m_count(sdp) != 2) {
if (ast_sdp_get_m_count(sdp) != 3) {
ast_test_status_update(test, "Unexpected number of streams in generated SDP: %d\n",
ast_sdp_get_m_count(sdp));
goto end;
@@ -478,6 +495,14 @@ AST_TEST_DEFINE(topology_to_sdp)
goto end;
}
m_line = ast_sdp_get_m(sdp, 2);
if (validate_m_line(test, m_line, "image", 1)) {
goto end;
}
if (validate_t38(test, m_line) != AST_TEST_PASS) {
goto end;
}
res = AST_TEST_PASS;
end:
@@ -527,6 +552,7 @@ AST_TEST_DEFINE(sdp_to_topology)
struct sdp_format sdp_formats[] = {
{ AST_MEDIA_TYPE_AUDIO, "ulaw,alaw,g722,opus" },
{ AST_MEDIA_TYPE_VIDEO, "h264,vp8" },
{ AST_MEDIA_TYPE_IMAGE, "t38" },
};
static const char *expected_audio_formats[] = {
"ulaw",
@@ -538,6 +564,9 @@ AST_TEST_DEFINE(sdp_to_topology)
"h264",
"vp8",
};
static const char *expected_image_formats[] = {
"t38",
};
switch(cmd) {
case TEST_INIT:
@@ -565,7 +594,7 @@ AST_TEST_DEFINE(sdp_to_topology)
topology = ast_get_topology_from_sdp(sdp);
if (ast_stream_topology_get_count(topology) != 2) {
if (ast_stream_topology_get_count(topology) != 3) {
ast_test_status_update(test, "Unexpected topology count '%d'. Expecting 2\n",
ast_stream_topology_get_count(topology));
res = AST_TEST_FAIL;
@@ -584,6 +613,12 @@ AST_TEST_DEFINE(sdp_to_topology)
goto end;
}
if (validate_formats(test, topology, 2, AST_MEDIA_TYPE_IMAGE,
ARRAY_LEN(expected_image_formats), expected_image_formats)) {
res = AST_TEST_FAIL;
goto end;
}
end:
ast_sdp_state_free(sdp_state);
ast_stream_topology_free(topology);