86 ast_debug_rtp(3,
"(%p) RTP not sending keepalive since direct media is in use\n", rtp);
87 return keepalive * 1000;
93 ast_debug_rtp(3,
"(%p) RTP it has been %d seconds since RTP was last sent. %sending keepalive\n",
94 rtp, (
int) interval, send_keepalive ?
"S" :
"Not s");
98 return keepalive * 1000;
101 return (keepalive - interval) * 1000;
132 if (elapsed < timeout) {
135 return (timeout - elapsed) * 1000;
142 ast_debug_rtp(3,
"(%p) RTP not disconnecting channel '%s' for lack of %s RTP activity in %d seconds " 147 return timeout * 1000;
150 ast_log(
LOG_NOTICE,
"Disconnecting channel '%s' for lack of %s RTP activity in %d seconds\n",
166 const struct pjmedia_sdp_media *remote_media)
184 const pjmedia_sdp_session *sdp)
194 for (index = 0; index < sdp->media_count; ++index) {
208 if (other_id == -1) {
229 const pjmedia_sdp_session *sdp)
240 media_address = &temp_media_address;
242 ast_debug_rtp(1,
"Endpoint %s: RTP media address invalid: %s\n",
256 char hoststr[PJ_INET6_ADDRSTRLEN];
258 pj_sockaddr_print(&trans_state->
host, hoststr,
sizeof(hoststr), 0);
260 ast_debug_rtp(1,
"Transport %s bound to %s: Using it for RTP media.\n",
262 media_address = &temp_media_address;
264 ast_debug_rtp(1,
"Transport %s bound to %s: Invalid for RTP media.\n",
318 pjmedia_sdp_attr *attr;
319 pjmedia_sdp_rtpmap *rtpmap;
320 pjmedia_sdp_fmtp fmtp;
322 int i, num = 0, tel_event = 0;
333 for (i = 0; i < stream->desc.fmt_count; ++i) {
337 if (!(attr = pjmedia_sdp_media_find_attr2(stream,
"rtpmap", &stream->desc.fmt[i]))) {
342 if ((pjmedia_sdp_attr_to_rtpmap(session->
inv_session->pool_prov, attr, &rtpmap)) != PJ_SUCCESS) {
347 if (strcmp(name,
"telephone-event") == 0) {
353 pj_strtoul(&stream->desc.fmt[i]), media, name, options, rtpmap->clock_rate);
355 if (!(attr = pjmedia_sdp_media_find_attr2(stream,
"fmtp", &rtpmap->pt))) {
359 if ((pjmedia_sdp_attr_get_fmtp(attr, &fmtp)) == PJ_SUCCESS) {
361 if (sscanf(fmt_param,
"%30d", &num) != 1) {
397 if ((attr = pjmedia_sdp_media_find_attr2(stream,
"ptime",
NULL))) {
398 unsigned long framing = pj_strtoul(pj_strltrim(&attr->value));
418 if (session_media_transport != session_media && session_media->
bundled) {
440 const struct pjmedia_sdp_media *stream)
457 get_codecs(session, stream, &codecs, session_media);
461 session, session_media->
type, remote);
488 const struct pjmedia_sdp_media *stream,
489 int is_offer,
struct ast_stream *asterisk_stream)
499 int dsp_features = 0;
512 if (direct_media_enabled) {
519 get_codecs(session, stream, &codecs, session_media);
529 ast_log(
LOG_NOTICE,
"No joint capabilities for '%s' media stream between our configuration(%s) and incoming SDP(%s)\n",
533 SCOPE_EXIT_RTN_VALUE(-1,
"No joint capabilities for '%s' media stream between our configuration(%s) and incoming SDP(%s)\n",
617 #ifndef HAVE_PJSIP_ENDPOINT_COMPACT_FORM 618 extern pj_bool_t pjsip_use_compact_form;
620 pj_bool_t pjsip_use_compact_form = pjsip_cfg()->endpt.use_compact_form;
622 pjmedia_sdp_rtpmap rtpmap;
623 pjmedia_sdp_attr *attr =
NULL;
628 snprintf(tmp,
sizeof(tmp),
"%d", rtp_code);
629 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++], tmp);
635 rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
638 if (!pj_stricmp2(&rtpmap.enc_name,
"opus")) {
639 pj_cstr(&rtpmap.param,
"2");
641 pj_cstr(&rtpmap.param,
NULL);
644 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
653 pjmedia_sdp_attr *attr =
NULL;
660 while (*tmp ==
'\r' || *tmp ==
'\n') --
tmp;
664 if (tmp && tmp[1] !=
'\0') {
665 fmtp1 = pj_str(tmp + 1);
669 attr = pjmedia_sdp_attr_create(pool,
"fmtp", &fmtp1);
676 unsigned int include_candidates)
682 pjmedia_sdp_attr *attr;
696 attr = pjmedia_sdp_attr_create(pool,
"ice-ufrag", pj_cstr(&stmp, username));
697 media->attr[media->attr_count++] = attr;
701 attr = pjmedia_sdp_attr_create(pool,
"ice-pwd", pj_cstr(&stmp, password));
702 media->attr[media->attr_count++] = attr;
705 if (!include_candidates) {
722 switch (candidate->
type) {
739 attr = pjmedia_sdp_attr_create(pool,
"candidate", pj_cstr(&stmp,
ast_str_buffer(attr_candidate)));
740 media->attr[media->attr_count++] = attr;
751 const struct pjmedia_sdp_media *remote_stream)
754 const pjmedia_sdp_attr *attr;
763 for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
764 attr = remote_stream->attr[attr_i];
765 if (!pj_strcmp2(&attr->name,
"candidate")) {
771 if (attr_i == remote_stream->attr_count) {
777 const struct pjmedia_sdp_session *remote,
const struct pjmedia_sdp_media *remote_stream)
780 const pjmedia_sdp_attr *ufrag_attr, *passwd_attr;
781 char ufrag_attr_value[256];
782 char passwd_attr_value[256];
789 ufrag_attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-ufrag",
NULL);
791 ufrag_attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-ufrag",
NULL);
794 ast_copy_pj_str(ufrag_attr_value, (pj_str_t*)&ufrag_attr->value,
sizeof(ufrag_attr_value));
798 passwd_attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-pwd",
NULL);
800 passwd_attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-pwd",
NULL);
803 ast_copy_pj_str(passwd_attr_value, (pj_str_t*)&passwd_attr->value,
sizeof(passwd_attr_value));
808 if (ufrag_attr && passwd_attr) {
815 const struct pjmedia_sdp_session *remote,
const struct pjmedia_sdp_media *remote_stream)
818 const pjmedia_sdp_attr *attr;
819 char attr_value[256];
829 attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-ufrag",
NULL);
831 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-ufrag",
NULL);
834 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
837 ast_debug_ice(2,
"(%p) ICE no, or invalid ice-ufrag\n", session_media->
rtp);
841 attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-pwd",
NULL);
843 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-pwd",
NULL);
846 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
853 if (pjmedia_sdp_media_find_attr2(remote_stream,
"ice-lite",
NULL)) {
858 for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
859 char foundation[33], transport[32],
address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] =
"";
860 unsigned int port, relay_port = 0;
863 attr = remote_stream->attr[attr_i];
866 if (pj_strcmp2(&attr->name,
"candidate")) {
870 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
872 if (sscanf(attr_value,
"%32s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u", foundation, &candidate.
id, transport,
873 (
unsigned *)&candidate.
priority, address, &port, cand_type, relay_address, &relay_port) < 7) {
891 if (!strcasecmp(cand_type,
"host")) {
893 }
else if (!strcasecmp(cand_type,
"srflx")) {
895 }
else if (!strcasecmp(cand_type,
"relay")) {
912 ice->
set_role(session_media->
rtp, pjmedia_sdp_neg_was_answer_remote(session->
inv_session->neg) == PJ_TRUE ?
922 for (i = 0; i < stream->attr_count; i++) {
923 pjmedia_sdp_attr *attr;
926 attr = stream->attr[i];
927 if (pj_strcmp2(&attr->name,
"crypto")) {
939 const struct pjmedia_sdp_media *stream,
unsigned int *optimistic)
945 if (!transport_str) {
948 if (strstr(transport_str,
"UDP/TLS")) {
950 }
else if (strstr(transport_str,
"SAVP")) {
972 const struct pjmedia_sdp_media *stream)
975 char transport_end = stream->desc.transport.ptr[stream->desc.transport.slen - 1];
976 unsigned int optimistic;
986 return incoming_encryption;
991 return incoming_encryption;
1006 if (!session_media->
srtp) {
1008 if (!session_media->
srtp) {
1039 ast_log(
LOG_ERROR,
"Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
1040 session_media->
rtp);
1051 pjmedia_sdp_attr *attr)
1056 if (!attr->value.ptr || !dtls) {
1060 value = pj_strtrim(&attr->value);
1062 if (!pj_strcmp2(&attr->name,
"setup")) {
1063 if (!pj_stricmp2(value,
"active")) {
1065 }
else if (!pj_stricmp2(value,
"passive")) {
1067 }
else if (!pj_stricmp2(value,
"actpass")) {
1069 }
else if (!pj_stricmp2(value,
"holdconn")) {
1072 ast_log(
LOG_WARNING,
"Unsupported setup attribute value '%*s'\n", (
int)value->slen, value->ptr);
1074 }
else if (!pj_strcmp2(&attr->name,
"connection")) {
1075 if (!pj_stricmp2(value,
"new")) {
1077 }
else if (!pj_stricmp2(value,
"existing")) {
1080 ast_log(
LOG_WARNING,
"Unsupported connection attribute value '%*s'\n", (
int)value->slen, value->ptr);
1082 }
else if (!pj_strcmp2(&attr->name,
"fingerprint")) {
1083 char hash_value[256], hash[32];
1084 char fingerprint_text[value->slen + 1];
1086 if (sscanf(fingerprint_text,
"%31s %255s", hash, hash_value) == 2) {
1087 if (!strcasecmp(hash,
"sha-1")) {
1089 }
else if (!strcasecmp(hash,
"sha-256")) {
1100 const struct pjmedia_sdp_session *sdp,
1101 const struct pjmedia_sdp_media *stream)
1105 for (i = 0; i < sdp->attr_count; i++) {
1109 for (i = 0; i < stream->attr_count; i++) {
1119 const struct pjmedia_sdp_media *stream)
1123 for (i = 0; i < stream->attr_count; i++) {
1124 pjmedia_sdp_attr *attr;
1128 attr = stream->attr[i];
1129 if (pj_strcmp2(&attr->name,
"crypto")) {
1133 crypto_str =
ast_strndup(attr->value.ptr, attr->value.slen);
1147 ast_log(
LOG_WARNING,
"Ignoring crypto offer with unsupported parameters: %s\n", crypto_str);
1156 const struct pjmedia_sdp_session *sdp,
1157 const struct pjmedia_sdp_media *stream)
1205 pjmedia_sdp_attr *attr;
1213 attr = pjmedia_sdp_attr_create(pool,
"ssrc", pj_cstr(&stmp, tmp));
1214 media->attr[media->attr_count++] = attr;
1219 const struct pjmedia_sdp_media *remote_stream)
1227 for (index = 0; index < remote_stream->attr_count; ++index) {
1228 pjmedia_sdp_attr *attr = remote_stream->attr[index];
1229 char attr_value[pj_strlen(&attr->value) + 1];
1230 char *ssrc_attribute_name, *ssrc_attribute_value =
NULL;
1234 if (pj_strcmp2(&attr->name,
"ssrc")) {
1240 if ((ssrc_attribute_name = strchr(attr_value,
' '))) {
1242 *ssrc_attribute_name++ =
'\0';
1243 ssrc_attribute_value = strchr(ssrc_attribute_name,
':');
1244 if (ssrc_attribute_value) {
1246 *ssrc_attribute_value++ =
'\0';
1250 if (sscanf(attr_value,
"%30u", &ssrc) < 1) {
1257 if (pjmedia_sdp_neg_get_state(session->
inv_session->neg) == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER &&
1277 pjmedia_sdp_attr *attr;
1304 snprintf(msid,
sizeof(msid),
"%s %s", session_media->
mslabel, session_media->
label);
1305 ast_debug(3,
"Stream msid: %p %s %s\n", stream,
1307 attr = pjmedia_sdp_attr_create(pool,
"msid", pj_cstr(&stmp, msid));
1308 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1312 ast_debug(3,
"Stream Label: %p %s %s\n", stream,
1314 attr = pjmedia_sdp_attr_create(pool,
"label", pj_cstr(&stmp, stream_label));
1315 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1323 pjmedia_sdp_attr *attr;
1333 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* transport-cc"));
1334 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1344 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* ccm fir"));
1345 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1347 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* goog-remb"));
1348 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1350 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* nack"));
1351 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1358 char extmap_value[256];
1367 const char *direction_str =
"";
1369 pjmedia_sdp_attr *attr;
1382 direction_str =
"/sendonly";
1385 direction_str =
"/recvonly";
1392 direction_str =
"/inactive";
1396 snprintf(extmap_value,
sizeof(extmap_value),
"%d%s %s", idx, direction_str,
1398 attr = pjmedia_sdp_attr_create(pool,
"extmap", pj_cstr(&stmp, extmap_value));
1399 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1405 const struct pjmedia_sdp_media *remote_stream)
1415 for (index = 0; index < remote_stream->attr_count; ++index) {
1416 pjmedia_sdp_attr *attr = remote_stream->attr[index];
1417 char attr_value[pj_strlen(&attr->value) + 1];
1420 char direction_str[10] =
"";
1425 if (pj_strcmp2(&attr->name,
"extmap")) {
1432 uri = strchr(attr_value,
' ');
1438 if ((sscanf(attr_value,
"%30d%9s", &
id, direction_str) < 1) || (
id < 1)) {
1444 if (!strcasecmp(direction_str,
"/sendonly")) {
1446 }
else if (!strcasecmp(direction_str,
"/recvonly")) {
1448 }
else if (!strcasecmp(direction_str,
"/inactive")) {
1452 attributes = strchr(uri,
' ');
1454 *attributes++ =
'\0';
1464 int index,
struct ast_stream *asterisk_stream)
1466 char host[NI_MAXHOST];
1468 pjmedia_sdp_media *stream = sdp->media[index];
1478 ast_debug(3,
"Endpoint has no codecs for media type '%s', declining stream\n",
1492 ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr,
sizeof(host));
1501 if (!session_media->
rtp &&
create_rtp(session, session_media, sdp)) {
1509 if (session_media_transport == session_media || !session_media->
bundled) {
1519 !pj_strncmp2(&stream->desc.transport,
"RTP/SAVP", 8)) {
1558 pjmedia_sdp_media_find_attr2(stream,
"sendonly",
NULL) ||
1559 pjmedia_sdp_media_find_attr2(stream,
"inactive",
NULL)) {
1582 pj_pool_t *
pool, pjmedia_sdp_media *media)
1585 pjmedia_sdp_attr *attr;
1587 const char *crypto_attribute;
1590 static const pj_str_t STR_NEW = {
"new", 3 };
1591 static const pj_str_t STR_EXISTING = {
"existing", 8 };
1592 static const pj_str_t STR_ACTIVE = {
"active", 6 };
1593 static const pj_str_t STR_PASSIVE = {
"passive", 7 };
1594 static const pj_str_t STR_ACTPASS = {
"actpass", 7 };
1595 static const pj_str_t STR_HOLDCONN = {
"holdconn", 8 };
1603 if (!session_media->
srtp) {
1605 if (!session_media->
srtp) {
1610 tmp = session_media->
srtp;
1616 if (!crypto_attribute) {
1621 attr = pjmedia_sdp_attr_create(pool,
"crypto",
1622 pj_cstr(&stmp, crypto_attribute));
1623 media->attr[media->attr_count++] = attr;
1639 attr = pjmedia_sdp_attr_create(pool,
"connection", &STR_NEW);
1640 media->attr[media->attr_count++] = attr;
1643 attr = pjmedia_sdp_attr_create(pool,
"connection", &STR_EXISTING);
1644 media->attr[media->attr_count++] = attr;
1654 && pjmedia_sdp_neg_get_state(session->
inv_session->neg) != PJMEDIA_SDP_NEG_STATE_DONE) {
1662 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_ACTIVE);
1663 media->attr[media->attr_count++] = attr;
1666 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_PASSIVE);
1667 media->attr[media->attr_count++] = attr;
1670 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_ACTPASS);
1671 media->attr[media->attr_count++] = attr;
1674 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_HOLDCONN);
1689 ast_str_set(&fingerprint, 0,
"SHA-1 %s", crypto_attribute);
1691 ast_str_set(&fingerprint, 0,
"SHA-256 %s", crypto_attribute);
1694 attr = pjmedia_sdp_attr_create(pool,
"fingerprint", pj_cstr(&stmp,
ast_str_buffer(fingerprint)));
1695 media->attr[media->attr_count++] = attr;
1705 struct pjmedia_sdp_session *sdp,
const struct pjmedia_sdp_session *remote,
struct ast_stream *stream)
1708 static const pj_str_t STR_RTP_AVP = {
"RTP/AVP", 7 };
1709 static const pj_str_t STR_IN = {
"IN", 2 };
1710 static const pj_str_t STR_IP4 = {
"IP4", 3};
1711 static const pj_str_t STR_IP6 = {
"IP6", 3};
1712 static const pj_str_t STR_SENDRECV = {
"sendrecv", 8 };
1713 static const pj_str_t STR_SENDONLY = {
"sendonly", 8 };
1714 static const pj_str_t STR_INACTIVE = {
"inactive", 8 };
1715 static const pj_str_t STR_RECVONLY = {
"recvonly", 8 };
1716 pjmedia_sdp_media *media;
1717 const char *hostip =
NULL;
1721 pjmedia_sdp_attr *attr;
1724 int min_packet_size = 0, max_packet_size = 0;
1735 media = pj_pool_zalloc(pool,
sizeof(
struct pjmedia_sdp_media));
1744 media->desc.port = 0;
1745 media->desc.port_count = 1;
1751 media->desc.transport = remote_media->desc.transport;
1754 for (index = 0; index < remote_media->desc.fmt_count; ++index) {
1755 media->desc.fmt[index] = remote_media->desc.fmt[index];
1757 media->desc.fmt_count = remote_media->desc.fmt_count;
1760 media->desc.transport = STR_RTP_AVP;
1761 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++],
"32");
1764 sdp->media[sdp->media_count++] = media;
1770 if (!session_media->
rtp &&
create_rtp(session, session_media, sdp)) {
1776 for (index = 0; index < sdp->media_count; ++index) {
1795 if (session_media_transport == session_media || !session_media->
bundled) {
1806 if (pj_strlen(&session_media->
transport)) {
1808 media->desc.transport = session_media->
transport;
1818 media->conn = pj_pool_zalloc(pool,
sizeof(
struct pjmedia_sdp_conn));
1824 if (direct_media_enabled) {
1838 media->conn->net_type = STR_IN;
1840 media->conn->addr_type = STR_IP4;
1841 pj_strdup2(pool, &media->conn->addr, hostip);
1843 if ((pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &media->conn->addr, &ip) == PJ_SUCCESS) &&
1844 (ip.addr.sa_family == pj_AF_INET6())) {
1845 media->conn->addr_type = STR_IP6;
1853 media->desc.port_count = 1;
1855 pjmedia_sdp_media *bundle_group_stream = sdp->media[session_media_transport->
stream_num];
1858 media->desc.transport = bundle_group_stream->desc.transport;
1859 media->conn = bundle_group_stream->conn;
1860 media->desc.port = bundle_group_stream->desc.port;
1877 if (direct_media_enabled) {
1894 if (session_media_transport != session_media) {
1911 media->attr[media->attr_count++] = attr;
1915 media->attr[media->attr_count++] = attr;
1924 if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
1931 && media->desc.fmt_count < PJMEDIA_MAX_SDP_FMT) {
1932 for (index = 1LL; index <=
AST_RTP_MAX; index <<= 1) {
1933 if (!(noncodec & index)) {
1938 if (rtp_code == -1) {
1943 media->attr[media->attr_count++] = attr;
1947 snprintf(tmp,
sizeof(tmp),
"%d 0-16", rtp_code);
1948 attr = pjmedia_sdp_attr_create(pool,
"fmtp", pj_cstr(&stmp, tmp));
1949 media->attr[media->attr_count++] = attr;
1952 if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
1960 if (!media->desc.fmt_count) {
1966 if (!min_packet_size) {
1969 if (min_packet_size) {
1970 snprintf(tmp,
sizeof(tmp),
"%d", min_packet_size);
1971 attr = pjmedia_sdp_attr_create(pool,
"ptime", pj_cstr(&stmp, tmp));
1972 media->attr[media->attr_count++] = attr;
1975 if (max_packet_size) {
1976 snprintf(tmp,
sizeof(tmp),
"%d", max_packet_size);
1977 attr = pjmedia_sdp_attr_create(pool,
"maxptime", pj_cstr(&stmp, tmp));
1978 media->attr[media->attr_count++] = attr;
1981 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
1984 attr->name = STR_INACTIVE;
1986 attr->name = STR_SENDONLY;
1990 attr->name = STR_RECVONLY;
1992 attr->name = STR_SENDONLY;
1994 attr->name = STR_RECVONLY;
1996 attr->name = STR_INACTIVE;
1998 attr->name = STR_SENDRECV;
2001 media->attr[media->attr_count++] = attr;
2005 attr = pjmedia_sdp_attr_create(pool,
"rtcp-mux",
NULL);
2006 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
2015 sdp->media[sdp->media_count++] = media;
2024 if (!session_media->
rtp) {
2042 if (!session_media->
rtp) {
2058 if (!session_media->
rtp) {
2067 const struct pjmedia_sdp_session *remote,
int index,
struct ast_stream *asterisk_stream)
2070 struct pjmedia_sdp_media *remote_stream = remote->media[index];
2072 char host[NI_MAXHOST];
2089 if (!session_media->
rtp &&
create_rtp(session, session_media, local)) {
2098 if (session_media_transport == session_media || !session_media->
bundled) {
2102 enable_rtcp(session, session_media, remote_stream);
2112 if (!remote_stream->conn && !remote->conn) {
2116 ast_copy_pj_str(host, remote_stream->conn ? &remote_stream->conn->addr : &remote->conn->addr,
sizeof(host));
2142 enable_rtcp(session, session_media, remote_stream);
2145 if (
set_caps(session, session_media, session_media_transport, remote_stream, 0, asterisk_stream)) {
2160 if ((pjmedia_sdp_neg_was_answer_remote(session->
inv_session->neg) == PJ_FALSE)
2161 && (session->
inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
2180 }
else if ((pjmedia_sdp_neg_was_answer_remote(session->
inv_session->neg) == PJ_FALSE)
2181 && (session->
inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
2229 char host[NI_MAXHOST];
2233 if (!stream->conn || !transport_state) {
2254 if (!session_media->
rtp) {
2266 if (session_media->
rtp) {
2297 struct pjsip_transaction *tsx;
2298 pjsip_tx_data *tdata;
2303 "media_control+xml")) {
2307 tsx = pjsip_rdata_get_tsx(rdata);
2311 if (pjsip_dlg_create_response(session->
inv_session->dlg, rdata, 200,
NULL, &tdata) == PJ_SUCCESS) {
2312 pjsip_dlg_send_response(session->
inv_session->dlg, tsx, tdata);
2389 .requires =
"res_pjsip,res_pjsip_session",
void ast_rtp_codecs_payload_formats(struct ast_rtp_codecs *codecs, struct ast_format_cap *astformats, int *nonastformats)
Retrieve all formats that were found.
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
static int apply_cap_to_bundled(struct ast_sip_session_media *session_media, struct ast_sip_session_media *session_media_transport, struct ast_stream *asterisk_stream, struct ast_format_cap *joint)
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance...
structure for secure RTP audio
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
struct ast_sip_endpoint * endpoint
const char * ast_stream_to_str(const struct ast_stream *stream, struct ast_str **buf)
Get a string representing the stream for debugging/display purposes.
static int video_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
int(* set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg)
static void enable_rtcp(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *remote_media)
Enable RTCP on an RTP session.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_sip_transport_is_nonlocal(transport_state, addr)
static char * ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
int ast_rtp_instance_extmap_get_id(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Retrieve the id for an RTP extension.
int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
Update the format associated with a tx payload type in a codecs structure.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
struct ast_sip_session_media_state * pending_media_state
struct ast_format_cap * ast_sip_session_create_joint_call_cap(const struct ast_sip_session *session, enum ast_media_type media_type, const struct ast_format_cap *remote)
Create joint capabilities.
ast_sip_session_media_encryption
int ast_rtp_instance_dtmf_mode_set(struct ast_rtp_instance *instance, enum ast_rtp_dtmf_mode dtmf_mode)
Set the DTMF mode that should be used.
static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const pjmedia_sdp_session *sdp)
Internal function which creates an RTP instance.
void ast_rtp_instance_change_source(struct ast_rtp_instance *instance)
Indicate a new source of audio has dropped in and the ssrc should change.
const char *(* get_password)(struct ast_rtp_instance *instance)
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
const char *(* get_fingerprint)(struct ast_rtp_instance *instance)
media_type
Media types generate different "dummy answers" for not accepting the offer of a media stream...
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static void get_codecs(struct ast_sip_session *session, const struct pjmedia_sdp_media *stream, struct ast_rtp_codecs *codecs, struct ast_sip_session_media *session_media)
int ast_stream_get_group(const struct ast_stream *stream)
Get the stream group that a stream is part of.
static uint32_t keepalive
struct ast_sip_session_media * ast_sip_session_media_get_transport(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
Retrieve the underlying media session that is acting as transport for a media session.
#define ast_channel_unref(c)
Decrease channel reference count.
int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Request that an RTP instance be bundled with another.
const ast_string_field transport
static int parse_dtls_attrib(struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance)
Get the number of known unique identifiers.
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
static struct ast_format_cap * set_incoming_call_offer_cap(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *stream)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
Convenient Signal Processing routines.
static struct ast_frame * media_session_rtcp_read_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
static void apply_dtls_attrib(struct ast_sip_session_media *session_media, pjmedia_sdp_attr *attr)
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
#define ast_set_flag(p, flag)
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
static int setup_sdes_srtp(struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *stream)
#define AST_RTP_PT_LAST_STATIC
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static void check_ice_support(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *remote_stream)
Function which checks for ice attributes in an audio stream.
A handler for SDPs in SIP sessions.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
static struct ast_sched_context * sched
Scheduler for RTCP purposes.
static int load_module(void)
Load the module.
static pj_pool_t * pool
Global memory pool for configuration and timers.
int ast_rtp_instance_set_qos(struct ast_rtp_instance *instance, int tos, int cos, const char *desc)
Set QoS parameters on an RTP session.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
unsigned int asymmetric_rtp_codec
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
Set when the stream has been removed/declined.
int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr)
Parse the a=crypto line from SDP and set appropriate values on the ast_sdp_crypto struct...
int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable) attribute_warn_unused_result
Adds a scheduled event with rescheduling support.
struct ast_rtp_engine_ice * ast_rtp_instance_get_ice(struct ast_rtp_instance *instance)
Obtain a pointer to the ICE support present on an RTP instance.
void(* change_components)(struct ast_rtp_instance *instance, int num_components)
void(* add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
static int add_crypto_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance)
Clear negotiated RTP extension information.
static const char STR_VIDEO[]
char * ast_sdp_get_rtp_profile(unsigned int sdes_active, struct ast_rtp_instance *instance, unsigned int using_avpf, unsigned int force_avp)
Get the RTP profile in use by a media session.
static int setup_dtls_srtp(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
ast_rtp_extension
Known RTP extensions.
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
Set when the stream is not sending OR receiving media.
#define ast_str_alloca(init_len)
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
#define AST_RTP_CODECS_NULL_INIT
static void stream_destroy(struct ast_sip_session_media *session_media)
Function which destroys the RTP instance when session ends.
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
static int setup_media_encryption(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
void(* stop)(struct ast_rtp_instance *instance)
struct pjsip_inv_session * inv_session
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
Structure for an ICE candidate.
Socket address structure.
static struct ast_str * password
void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num)
Set the stream number for an RTP instance.
A structure describing a SIP session.
enum ast_rtp_dtls_hash(* get_fingerprint_hash)(struct ast_rtp_instance *instance)
static struct ast_sockaddr address_rtp
Address for RTP.
static void enable_rtp_extension(struct ast_sip_session *session, struct ast_sip_session_media *session_media, enum ast_rtp_extension extension, enum ast_rtp_extension_direction direction, const pjmedia_sdp_session *sdp)
Enable an RTP extension on an RTP session.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
enum ast_rtp_dtls_setup(* get_setup)(struct ast_rtp_instance *instance)
struct ast_format_cap * direct_media_cap
static int unload_module(void)
Unloads the sdp RTP/AVP module from Asterisk.
static void process_ice_auth_attrb(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
const char * ast_rtp_instance_get_channel_id(struct ast_rtp_instance *instance)
Get the unique ID of the channel that owns this RTP instance.
#define ast_strlen_zero(foo)
struct ast_sip_session_media_state * active_media_state
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int ast_rtp_instance_extmap_enable(struct ast_rtp_instance *instance, int id, enum ast_rtp_extension extension, enum ast_rtp_extension_direction direction)
Enable support for an RTP extension on an instance.
struct ast_sip_endpoint_media_configuration media
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
enum ast_rtp_ice_candidate_type type
static struct ast_sip_session_sdp_handler video_sdp_handler
SDP handler for 'video' media stream.
enum ast_rtp_dtls_connection(* get_connection)(struct ast_rtp_instance *instance)
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
static struct ast_sockaddr media_address
static int apply_negotiated_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *local, const struct pjmedia_sdp_session *remote, int index, struct ast_stream *asterisk_stream)
#define ast_str_tmp(init_len, __expr)
#define ast_debug(level,...)
Log a DEBUG message.
static pjmedia_sdp_attr * generate_fmtp_attr(pj_pool_t *pool, struct ast_format *format, int rtp_code)
int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
Determine if the address type is unspecified, or "any" address.
struct ast_format * ast_rtp_codecs_get_payload_format(struct ast_rtp_codecs *codecs, int payload)
Retrieve the actual ast_format stored on the codecs structure for a specific tx payload type...
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
Structure for SIP transport information.
static int rtp_check_timeout(const void *data)
Check whether RTP is being received or not.
General Asterisk PBX channel definitions.
int ast_sip_session_register_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Register an SDP handler.
const char * ast_rtp_lookup_mime_subtype2(const int asterisk_format, const struct ast_format *format, int code, enum ast_rtp_options options)
Retrieve mime subtype information on a payload.
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
int ast_sip_session_is_pending_stream_default(const struct ast_sip_session *session, const struct ast_stream *stream)
Determines if a provided pending stream will be the default stream or not.
SRTP and SDP Security descriptions.
int ast_check_ipv6(void)
Test that an OS supports IPv6 Networking.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_rtp_codecs_payload_code(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code)
Retrieve a rx mapped payload type based on whether it is an Asterisk format and the code...
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
#define ast_debug_rtp(sublevel,...)
Log debug level RTP information.
static struct ast_mansession session
void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc)
Set the remote SSRC for an RTP instance.
Access Control of various sorts.
static struct ao2_container * codecs
Registered codecs.
static int media_session_rtp_write_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_frame *frame)
void(* set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint)
Scheduler Routines (derived from cheops)
structure to hold extensions
#define ao2_ref(o, delta)
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
static struct ast_sip_session_supplement video_info_supplement
#define AST_SRTP_CRYPTO_OFFER_OK
static void process_extmap_attributes(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *remote_stream)
Function which processes extmap attributes in a stream.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
struct ast_channel * channel
struct ast_sdp_crypto * crypto
A set of macros to manage forward-linked lists.
int ast_rtp_instance_extmap_negotiate(struct ast_rtp_instance *instance, int id, enum ast_rtp_extension_direction direction, const char *uri, const char *attributes)
Negotiate received RTP extension information.
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
void ast_channel_set_unbridged_nolock(struct ast_channel *chan, int value)
Variant of ast_channel_set_unbridged. Use this if the channel is already locked prior to calling...
static void add_ssrc_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
Function which adds ssrc attributes to a media stream.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
An entity with which Asterisk communicates.
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
void ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Unregister an SDP handler.
static int negotiate_incoming_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const pjmedia_sdp_session *sdp, int index, struct ast_stream *asterisk_stream)
Function which negotiates an incoming media stream.
struct ast_sockaddr relay_address
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Structure that represents the optional DTLS SRTP support within an RTP engine.
static pjmedia_sdp_attr * generate_rtpmap_attr(struct ast_sip_session *session, pjmedia_sdp_media *media, pj_pool_t *pool, int rtp_code, int asterisk_format, struct ast_format *format, int code)
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
Checks if the given content type matches type/subtype.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
ast_rtp_dtls_setup
DTLS setup types.
const char *(* get_ufrag)(struct ast_rtp_instance *instance)
enum ast_rtp_dtls_setup default_setup
time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp)
Get the last RTP transmission time.
void(* set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password)
const char * ast_sip_session_get_name(const struct ast_sip_session *session)
Get the channel or endpoint name associated with the session.
struct ao2_container *(* get_local_candidates)(struct ast_rtp_instance *instance)
static void stream_stop(struct ast_sip_session_media *session_media)
Function which stops the RTP instance.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_rtp_engine_dtls * ast_rtp_instance_get_dtls(struct ast_rtp_instance *instance)
Obtain a pointer to the DTLS support present on an RTP instance.
ast_rtp_extension_direction
Directions for RTP extensions.
enum ast_rtp_extension_direction ast_rtp_instance_extmap_get_direction(struct ast_rtp_instance *instance, int id)
Retrieve the negotiated direction for an RTP extension id.
void(* set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role)
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
static struct ast_sip_session_sdp_handler audio_sdp_handler
SDP handler for 'audio' media stream.
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
enum ast_sip_dtmf_mode dtmf
enum ast_rtp_ice_component_type id
unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp)
Retrieve the local SSRC value that we will be using.
static void change_outgoing_sdp_stream_media_address(pjsip_tx_data *tdata, struct pjmedia_sdp_media *stream, struct ast_sip_transport *transport)
Function which updates the media stream with external media address, if applicable.
#define ast_strndup(str, len)
A wrapper for strndup()
static enum ast_sip_session_media_encryption get_media_encryption_type(pj_str_t transport, const struct pjmedia_sdp_media *stream, unsigned int *optimistic)
figure out media transport encryption type from the media transport string
#define ao2_iterator_next(iter)
char * ast_sockaddr_stringify_fmt(const struct ast_sockaddr *addr, int format)
Convert a socket address to a string.
static void process_ssrc_attributes(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *remote_stream)
Function which processes ssrc attributes in a stream.
void(* reset)(struct ast_rtp_instance *instance)
ast_rtp_dtls_hash
DTLS fingerprint hashes.
#define SCOPE_EXIT_RTN(...)
Scope Exit with return.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
unsigned int preferred_codec_only
#define ast_channel_unlock(chan)
#define ast_debug_ice(sublevel,...)
Log debug level ICE information.
Set when the stream is sending media only.
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
unsigned int ast_rtp_lookup_sample_rate2(int asterisk_format, const struct ast_format *format, int code)
Get the sample rate associated with known RTP payload types.
static struct ast_frame * media_session_rtp_read_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
void(* start)(struct ast_rtp_instance *instance)
static int setup_srtp(struct ast_sip_session_media *session_media)
int ast_sip_session_media_add_read_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media, int fd, ast_sip_session_media_read_cb callback)
Set a read callback for a media session with a specific file descriptor.
time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp)
static void add_ice_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media, unsigned int include_candidates)
Function which adds ICE attributes to a media stream.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
void(* set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup)
struct ast_sdp_srtp * ast_sdp_srtp_alloc(void)
allocate a ast_sdp_srtp structure
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
#define SCOPE_ENTER(level,...)
Non RAII_VAR Scope Trace macros The advantage of these macros is that the EXITs will have the actual ...
struct ast_sdp_crypto * ast_sdp_crypto_alloc(void)
Initialize an return an ast_sdp_crypto struct.
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
const char * ast_rtp_instance_extmap_get_uri(struct ast_rtp_instance *instance, int id)
Retrieve the URI for an RTP extension id.
Module has failed to load, may be in an inconsistent state.
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
struct ast_sdp_srtp::@318 sdp_srtp_list
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
static int send_keepalive(const void *data)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_session *remote, struct ast_stream *stream)
Function which creates an outgoing stream.
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
A supplement to SIP message processing.
struct ast_frame ast_null_frame
void ast_rtp_codecs_payloads_copy(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Copy payload information from one RTP instance to another.
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
Scope Exit with return value.
static enum ast_sip_session_media_encryption check_endpoint_media_transport(struct ast_sip_endpoint *endpoint, const struct pjmedia_sdp_media *stream)
Checks whether the encryption offered in SDP is compatible with the endpoint's configuration.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
const char * ast_channel_name(const struct ast_channel *chan)
#define AST_SOCKADDR_STR_ADDR
static void set_ice_components(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
const ast_string_field mohsuggest
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
int ast_rtp_codecs_payloads_set_rtpmap_type_rate(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int pt, char *mimetype, char *mimesubtype, enum ast_rtp_options options, unsigned int sample_rate)
Set tx payload type to a known MIME media type for a codec with a specific sample rate...
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
static void add_msid_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media, struct ast_stream *stream)
Data structure associated with a single frame of data.
int ast_sip_session_media_set_write_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media, ast_sip_session_media_write_cb callback)
Set a write callback for a media session.
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
Internal Asterisk hangup causes.
enum ast_srtp_suite suite
Structure that represents the optional ICE support within an RTP engine.
int ast_rtp_codecs_payload_set_rx(struct ast_rtp_codecs *codecs, int code, struct ast_format *format)
Set a payload code for use with a specific Asterisk format.
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
ast_media_type
Types of media.
struct ast_sockaddr address
const char * ast_sdp_srtp_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32)
Get the crypto attribute line for the srtp structure.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
#define ASTERISK_GPL_KEY
The text the key() function should return.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Pluggable RTP Architecture.
Asterisk module definitions.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
static const char STR_AUDIO[]
const char * ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp)
Retrieve the CNAME used in RTCP SDES items.
static snd_pcm_format_t format
enum ast_rtp_extension ast_rtp_instance_extmap_get_extension(struct ast_rtp_instance *instance, int id)
Retrieve the extension for an RTP extension id.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record tx payload type information that was seen in an m= SDP line.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Set when the stream is receiving media only.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP reception time.
static int set_caps(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_sip_session_media *session_media_transport, const struct pjmedia_sdp_media *stream, int is_offer, struct ast_stream *asterisk_stream)
static void add_rtcp_fb_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str, int flags, int family)
Parses a string with an IPv4 or IPv6 address and place results into an array.
#define ast_sip_session_register_supplement(supplement)
void(* ice_lite)(struct ast_rtp_instance *instance)
static int media_stream_has_crypto(const struct pjmedia_sdp_media *stream)
figure out if media stream has crypto lines for sdes
static void add_extmap_to_stream(struct ast_sip_session *session, struct ast_sip_session_media *session_media, pj_pool_t *pool, pjmedia_sdp_media *media)
static void process_ice_attributes(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *remote, const struct pjmedia_sdp_media *remote_stream)
Function which processes ICE attributes in an audio stream.