86 ast_debug_rtp(3,
"(%p) RTP not sending keepalive since direct media is in use\n", rtp);
93 ast_debug_rtp(3,
"(%p) RTP it has been %d seconds since RTP was last sent. %sending keepalive\n",
137 return timeout * 500;
141 if (elapsed < timeout) {
143 return (timeout - elapsed) * 1000;
146 ast_log(
LOG_NOTICE,
"Disconnecting channel '%s' for lack of %s RTP activity in %d seconds\n",
163 const struct pjmedia_sdp_media *remote_media)
181 const pjmedia_sdp_session *sdp)
191 for (index = 0; index < sdp->media_count; ++index) {
205 if (other_id == -1) {
226 const pjmedia_sdp_session *sdp)
236 session->endpoint->media.address);
237 media_address = &temp_media_address;
239 ast_debug_rtp(1,
"Endpoint %s: RTP media address invalid: %s\n",
241 session->endpoint->media.address);
253 char hoststr[PJ_INET6_ADDRSTRLEN];
255 pj_sockaddr_print(&trans_state->
host, hoststr,
sizeof(hoststr), 0);
257 ast_debug_rtp(1,
"Transport %s bound to %s: Using it for RTP media.\n",
258 session->endpoint->transport, hoststr);
259 media_address = &temp_media_address;
261 ast_debug_rtp(1,
"Transport %s bound to %s: Invalid for RTP media.\n",
262 session->endpoint->transport, hoststr);
271 ast_log(
LOG_ERROR,
"Unable to create RTP instance using RTP engine '%s'\n",
session->endpoint->media.rtp.engine);
290 (
session->endpoint->media.tos_audio ||
session->endpoint->media.cos_audio)) {
292 session->endpoint->media.cos_audio,
"SIP RTP Audio");
297 if (
session->endpoint->media.webrtc) {
301 if (
session->endpoint->media.tos_video ||
session->endpoint->media.cos_video) {
303 session->endpoint->media.cos_video,
"SIP RTP Video");
315 pjmedia_sdp_attr *attr;
316 pjmedia_sdp_rtpmap *rtpmap;
317 pjmedia_sdp_fmtp fmtp;
319 int i, num = 0, tel_event = 0;
332 for (i = 0; i < stream->desc.fmt_count; ++i) {
336 if (!(attr = pjmedia_sdp_media_find_attr2(stream,
"rtpmap", &stream->desc.fmt[i]))) {
341 if ((pjmedia_sdp_attr_to_rtpmap(
session->inv_session->pool_prov, attr, &rtpmap)) != PJ_SUCCESS) {
346 if (strcmp(
name,
"telephone-event") == 0) {
347 if (tel_event == 0) {
348 int dtmf_rate = 0, dtmf_code = 0;
351 dtmf_code = atoi(dtmf_pt);
352 dtmf_rate = rtpmap->clock_rate;
360 pj_strtoul(&stream->desc.fmt[i]), media,
name,
options, rtpmap->clock_rate);
362 if (!(attr = pjmedia_sdp_media_find_attr2(stream,
"fmtp", &rtpmap->pt))) {
366 if ((pjmedia_sdp_attr_get_fmtp(attr, &fmtp)) == PJ_SUCCESS) {
368 if (sscanf(fmt_param,
"%30d", &num) != 1) {
388 for (i = 0; i < stream->desc.fmt_count; ++i) {
417 if ((attr = pjmedia_sdp_media_find_attr2(stream,
"ptime",
NULL))) {
418 unsigned long framing = pj_strtoul(pj_strltrim(&attr->value));
419 if (framing &&
session->endpoint->media.rtp.use_ptime) {
439 if (session_media_transport != session_media && session_media->
bundled) {
461 const struct pjmedia_sdp_media *stream)
507 const struct pjmedia_sdp_media *stream,
508 int is_offer,
struct ast_stream *asterisk_stream)
517 int dsp_features = 0;
530 if (direct_media_enabled) {
546 ast_log(
LOG_NOTICE,
"No joint capabilities for '%s' media stream between our configuration(%s) and incoming SDP(%s)\n",
550 SCOPE_EXIT_RTN_VALUE(-1,
"No joint capabilities for '%s' media stream between our configuration(%s) and incoming SDP(%s)\n",
580 if (
session->endpoint->preferred_codec_only) {
584 }
else if (!
session->endpoint->asymmetric_rtp_codec) {
616 dsp_features &= ~DSP_FEATURE_DIGIT_DETECT;
637 int rtp_code,
int asterisk_format,
struct ast_format *format,
int code)
639#ifndef HAVE_PJSIP_ENDPOINT_COMPACT_FORM
640 extern pj_bool_t pjsip_use_compact_form;
642 pj_bool_t pjsip_use_compact_form = pjsip_cfg()->endpt.use_compact_form;
644 pjmedia_sdp_rtpmap rtpmap;
645 pjmedia_sdp_attr *attr =
NULL;
650 snprintf(
tmp,
sizeof(
tmp),
"%d", rtp_code);
651 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++],
tmp);
657 rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
660 if (!pj_stricmp2(&rtpmap.enc_name,
"opus")) {
661 pj_cstr(&rtpmap.param,
"2");
663 pj_cstr(&rtpmap.param,
NULL);
666 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
673 int rtp_code,
int asterisk_format,
struct ast_format *format,
int code,
int sample_rate)
675#ifndef HAVE_PJSIP_ENDPOINT_COMPACT_FORM
676 extern pj_bool_t pjsip_use_compact_form;
678 pj_bool_t pjsip_use_compact_form = pjsip_cfg()->endpt.use_compact_form;
680 pjmedia_sdp_rtpmap rtpmap;
681 pjmedia_sdp_attr *attr =
NULL;
686 snprintf(
tmp,
sizeof(
tmp),
"%d", rtp_code);
687 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++],
tmp);
693 rtpmap.pt = media->desc.fmt[media->desc.fmt_count - 1];
694 rtpmap.clock_rate = sample_rate;
696 if (!pj_stricmp2(&rtpmap.enc_name,
"opus")) {
697 pj_cstr(&rtpmap.param,
"2");
699 pj_cstr(&rtpmap.param,
NULL);
702 pjmedia_sdp_rtpmap_to_attr(pool, &rtpmap, &attr);
711 pjmedia_sdp_attr *attr =
NULL;
718 while (*
tmp ==
'\r' || *
tmp ==
'\n') --
tmp;
722 if (
tmp &&
tmp[1] !=
'\0') {
723 fmtp1 = pj_str(
tmp + 1);
727 attr = pjmedia_sdp_attr_create(pool,
"fmtp", &fmtp1);
734 unsigned int include_candidates)
738 const char *username, *password;
740 pjmedia_sdp_attr *attr;
754 attr = pjmedia_sdp_attr_create(pool,
"ice-ufrag", pj_cstr(&stmp, username));
755 media->attr[media->attr_count++] = attr;
759 attr = pjmedia_sdp_attr_create(pool,
"ice-pwd", pj_cstr(&stmp, password));
760 media->attr[media->attr_count++] = attr;
763 if (!include_candidates) {
780 switch (candidate->
type) {
797 attr = pjmedia_sdp_attr_create(pool,
"candidate", pj_cstr(&stmp,
ast_str_buffer(attr_candidate)));
798 media->attr[media->attr_count++] = attr;
809 const struct pjmedia_sdp_media *remote_stream)
812 const pjmedia_sdp_attr *attr;
821 for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
822 attr = remote_stream->attr[attr_i];
823 if (!pj_strcmp2(&attr->name,
"candidate")) {
829 if (attr_i == remote_stream->attr_count) {
835 const struct pjmedia_sdp_session *remote,
const struct pjmedia_sdp_media *remote_stream)
838 const pjmedia_sdp_attr *ufrag_attr, *passwd_attr;
839 char ufrag_attr_value[256];
840 char passwd_attr_value[256];
847 ufrag_attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-ufrag",
NULL);
849 ufrag_attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-ufrag",
NULL);
852 ast_copy_pj_str(ufrag_attr_value, (pj_str_t*)&ufrag_attr->value,
sizeof(ufrag_attr_value));
856 passwd_attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-pwd",
NULL);
858 passwd_attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-pwd",
NULL);
861 ast_copy_pj_str(passwd_attr_value, (pj_str_t*)&passwd_attr->value,
sizeof(passwd_attr_value));
866 if (ufrag_attr && passwd_attr) {
873 const struct pjmedia_sdp_session *remote,
const struct pjmedia_sdp_media *remote_stream)
876 const pjmedia_sdp_attr *attr;
877 char attr_value[256];
887 attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-ufrag",
NULL);
889 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-ufrag",
NULL);
892 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
895 ast_debug_ice(2,
"(%p) ICE no, or invalid ice-ufrag\n", session_media->
rtp);
899 attr = pjmedia_sdp_media_find_attr2(remote_stream,
"ice-pwd",
NULL);
901 attr = pjmedia_sdp_attr_find2(remote->attr_count, remote->attr,
"ice-pwd",
NULL);
904 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
911 if (pjmedia_sdp_media_find_attr2(remote_stream,
"ice-lite",
NULL)) {
916 for (attr_i = 0; attr_i < remote_stream->attr_count; ++attr_i) {
917 char foundation[33], transport[32],
address[PJ_INET6_ADDRSTRLEN + 1], cand_type[6], relay_address[PJ_INET6_ADDRSTRLEN + 1] =
"";
918 unsigned int port, relay_port = 0;
921 attr = remote_stream->attr[attr_i];
924 if (pj_strcmp2(&attr->name,
"candidate")) {
928 ast_copy_pj_str(attr_value, (pj_str_t*)&attr->value,
sizeof(attr_value));
930 if (sscanf(attr_value,
"%32s %30u %31s %30u %46s %30u typ %5s %*s %23s %*s %30u",
foundation, &candidate.
id,
transport,
949 if (!strcasecmp(cand_type,
"host")) {
951 }
else if (!strcasecmp(cand_type,
"srflx")) {
953 }
else if (!strcasecmp(cand_type,
"relay")) {
970 ice->
set_role(session_media->
rtp, pjmedia_sdp_neg_was_answer_remote(
session->inv_session->neg) == PJ_TRUE ?
980 for (i = 0; i < stream->attr_count; i++) {
981 pjmedia_sdp_attr *attr;
984 attr = stream->attr[i];
985 if (pj_strcmp2(&attr->name,
"crypto")) {
997 const struct pjmedia_sdp_media *stream,
unsigned int *optimistic)
1003 if (!transport_str) {
1006 if (strstr(transport_str,
"UDP/TLS")) {
1008 }
else if (strstr(transport_str,
"SAVP")) {
1030 const struct pjmedia_sdp_media *stream)
1033 char transport_end = stream->desc.transport.ptr[stream->desc.transport.slen - 1];
1034 unsigned int optimistic;
1044 return incoming_encryption;
1049 return incoming_encryption;
1064 if (!session_media->
srtp) {
1066 if (!session_media->
srtp) {
1086 if (!
session->endpoint->media.rtp.dtls_cfg.enabled || !session_media->
rtp) {
1097 ast_log(
LOG_ERROR,
"Attempted to set an invalid DTLS-SRTP configuration on RTP instance '%p'\n",
1098 session_media->
rtp);
1109 pjmedia_sdp_attr *attr)
1114 if (!attr->value.ptr || !dtls) {
1118 value = pj_strtrim(&attr->value);
1120 if (!pj_strcmp2(&attr->name,
"setup")) {
1121 if (!pj_stricmp2(
value,
"active")) {
1123 }
else if (!pj_stricmp2(
value,
"passive")) {
1125 }
else if (!pj_stricmp2(
value,
"actpass")) {
1127 }
else if (!pj_stricmp2(
value,
"holdconn")) {
1132 }
else if (!pj_strcmp2(&attr->name,
"connection")) {
1133 if (!pj_stricmp2(
value,
"new")) {
1135 }
else if (!pj_stricmp2(
value,
"existing")) {
1140 }
else if (!pj_strcmp2(&attr->name,
"fingerprint")) {
1141 char hash_value[256], hash[32];
1142 char fingerprint_text[
value->slen + 1];
1144 if (sscanf(fingerprint_text,
"%31s %255s", hash, hash_value) == 2) {
1145 if (!strcasecmp(hash,
"sha-1")) {
1147 }
else if (!strcasecmp(hash,
"sha-256")) {
1158 const struct pjmedia_sdp_session *sdp,
1159 const struct pjmedia_sdp_media *stream)
1163 for (i = 0; i < sdp->attr_count; i++) {
1167 for (i = 0; i < stream->attr_count; i++) {
1177 const struct pjmedia_sdp_media *stream)
1181 for (i = 0; i < stream->attr_count; i++) {
1182 pjmedia_sdp_attr *attr;
1186 attr = stream->attr[i];
1187 if (pj_strcmp2(&attr->name,
"crypto")) {
1191 crypto_str =
ast_strndup(attr->value.ptr, attr->value.slen);
1205 ast_debug(1,
"Ignoring crypto offer with unsupported parameters: %s\n", crypto_str);
1214 const struct pjmedia_sdp_session *sdp,
1215 const struct pjmedia_sdp_media *stream)
1246 if (!
session->endpoint->media.rtp.ice_support || !ice) {
1263 pjmedia_sdp_attr *attr;
1271 attr = pjmedia_sdp_attr_create(pool,
"ssrc", pj_cstr(&stmp,
tmp));
1272 media->attr[media->attr_count++] = attr;
1277 const struct pjmedia_sdp_media *remote_stream)
1281 if (!
session->endpoint->media.bundle) {
1285 for (index = 0; index < remote_stream->attr_count; ++index) {
1286 pjmedia_sdp_attr *attr = remote_stream->attr[index];
1287 char attr_value[pj_strlen(&attr->value) + 1];
1288 char *ssrc_attribute_name, *ssrc_attribute_value =
NULL;
1292 if (pj_strcmp2(&attr->name,
"ssrc")) {
1298 if ((ssrc_attribute_name = strchr(attr_value,
' '))) {
1300 *ssrc_attribute_name++ =
'\0';
1301 ssrc_attribute_value = strchr(ssrc_attribute_name,
':');
1302 if (ssrc_attribute_value) {
1304 *ssrc_attribute_value++ =
'\0';
1308 if (sscanf(attr_value,
"%30u", &ssrc) < 1) {
1315 if (pjmedia_sdp_neg_get_state(
session->inv_session->neg) == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER &&
1316 session->active_media_state) {
1335 pjmedia_sdp_attr *attr;
1339 if (!
session->endpoint->media.webrtc) {
1362 snprintf(msid,
sizeof(msid),
"%s %s", session_media->
mslabel, session_media->
label);
1363 ast_debug(3,
"Stream msid: %p %s %s\n", stream,
1365 attr = pjmedia_sdp_attr_create(pool,
"msid", pj_cstr(&stmp, msid));
1366 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1370 ast_debug(3,
"Stream Label: %p %s %s\n", stream,
1372 attr = pjmedia_sdp_attr_create(pool,
"label", pj_cstr(&stmp, stream_label));
1373 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1381 pjmedia_sdp_attr *attr;
1383 if (!
session->endpoint->media.webrtc) {
1391 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* transport-cc"));
1392 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1402 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* ccm fir"));
1403 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1405 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* goog-remb"));
1406 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1408 attr = pjmedia_sdp_attr_create(pool,
"rtcp-fb", pj_cstr(&stmp,
"* nack"));
1409 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1416 char extmap_value[256];
1425 const char *direction_str =
"";
1427 pjmedia_sdp_attr *attr;
1440 direction_str =
"/sendonly";
1443 direction_str =
"/recvonly";
1450 direction_str =
"/inactive";
1454 snprintf(extmap_value,
sizeof(extmap_value),
"%d%s %s", idx, direction_str,
1456 attr = pjmedia_sdp_attr_create(pool,
"extmap", pj_cstr(&stmp, extmap_value));
1457 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
1463 const struct pjmedia_sdp_media *remote_stream)
1473 for (index = 0; index < remote_stream->attr_count; ++index) {
1474 pjmedia_sdp_attr *attr = remote_stream->attr[index];
1475 char attr_value[pj_strlen(&attr->value) + 1];
1478 char direction_str[10] =
"";
1483 if (pj_strcmp2(&attr->name,
"extmap")) {
1490 uri = strchr(attr_value,
' ');
1496 if ((sscanf(attr_value,
"%30d%9s", &
id, direction_str) < 1) || (
id < 1)) {
1502 if (!strcasecmp(direction_str,
"/sendonly")) {
1504 }
else if (!strcasecmp(direction_str,
"/recvonly")) {
1506 }
else if (!strcasecmp(direction_str,
"/inactive")) {
1510 attributes = strchr(uri,
' ');
1512 *attributes++ =
'\0';
1521 const pjmedia_sdp_media *media,
1529 pjmedia_sdp_media_find_attr2(media,
"sendonly",
NULL) ||
1530 pjmedia_sdp_media_find_attr2(media,
"inactive",
NULL)) {
1545 int index,
struct ast_stream *asterisk_stream)
1547 char host[NI_MAXHOST];
1549 pjmedia_sdp_media *stream = sdp->media[index];
1559 ast_debug(3,
"Endpoint has no codecs for media type '%s', declining stream\n",
1565 if (!
session->endpoint->media.rtp.use_received_transport) {
1573 ast_copy_pj_str(host, stream->conn ? &stream->conn->addr : &sdp->conn->addr,
sizeof(host));
1590 if (session_media_transport == session_media || !session_media->
bundled) {
1599 if (!
session->endpoint->media.rtp.encryption_optimistic ||
1600 !pj_strncmp2(&stream->desc.transport,
"RTP/SAVP", 8)) {
1616 if ((
session->endpoint->media.rtp.use_received_transport) ||
1618 pj_strdup(
session->inv_session->pool, &session_media->
transport, &stream->desc.transport);
1650 pj_pool_t *pool, pjmedia_sdp_media *media)
1653 pjmedia_sdp_attr *attr;
1655 const char *crypto_attribute;
1658 static const pj_str_t STR_NEW = {
"new", 3 };
1659 static const pj_str_t STR_EXISTING = {
"existing", 8 };
1660 static const pj_str_t STR_ACTIVE = {
"active", 6 };
1661 static const pj_str_t STR_PASSIVE = {
"passive", 7 };
1662 static const pj_str_t STR_ACTPASS = {
"actpass", 7 };
1663 static const pj_str_t STR_HOLDCONN = {
"holdconn", 8 };
1664 static const pj_str_t STR_MEDSECREQ = {
"requested", 9 };
1672 if (!session_media->
srtp) {
1674 if (!session_media->
srtp) {
1684 session->endpoint->media.rtp.srtp_tag_32 );
1685 if (!crypto_attribute) {
1690 attr = pjmedia_sdp_attr_create(pool,
"crypto",
1691 pj_cstr(&stmp, crypto_attribute));
1692 media->attr[media->attr_count++] = attr;
1696 attr = pjmedia_sdp_attr_create(pool,
"3ge2ae", &STR_MEDSECREQ);
1697 media->attr[media->attr_count++] = attr;
1713 attr = pjmedia_sdp_attr_create(pool,
"connection", &STR_NEW);
1714 media->attr[media->attr_count++] = attr;
1717 attr = pjmedia_sdp_attr_create(pool,
"connection", &STR_EXISTING);
1718 media->attr[media->attr_count++] = attr;
1728 && pjmedia_sdp_neg_get_state(
session->inv_session->neg) != PJMEDIA_SDP_NEG_STATE_DONE) {
1731 setup =
session->endpoint->media.rtp.dtls_cfg.default_setup;
1736 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_ACTIVE);
1737 media->attr[media->attr_count++] = attr;
1740 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_PASSIVE);
1741 media->attr[media->attr_count++] = attr;
1744 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_ACTPASS);
1745 media->attr[media->attr_count++] = attr;
1748 attr = pjmedia_sdp_attr_create(pool,
"setup", &STR_HOLDCONN);
1763 ast_str_set(&fingerprint, 0,
"SHA-1 %s", crypto_attribute);
1765 ast_str_set(&fingerprint, 0,
"SHA-256 %s", crypto_attribute);
1768 attr = pjmedia_sdp_attr_create(pool,
"fingerprint", pj_cstr(&stmp,
ast_str_buffer(fingerprint)));
1769 media->attr[media->attr_count++] = attr;
1779 struct pjmedia_sdp_session *sdp,
const struct pjmedia_sdp_session *remote,
struct ast_stream *stream)
1781 pj_pool_t *pool =
session->inv_session->pool_prov;
1782 static const pj_str_t STR_RTP_AVP = {
"RTP/AVP", 7 };
1783 static const pj_str_t STR_IN = {
"IN", 2 };
1784 static const pj_str_t STR_IP4 = {
"IP4", 3};
1785 static const pj_str_t STR_IP6 = {
"IP6", 3};
1786 static const pj_str_t STR_SENDRECV = {
"sendrecv", 8 };
1787 static const pj_str_t STR_SENDONLY = {
"sendonly", 8 };
1788 static const pj_str_t STR_INACTIVE = {
"inactive", 8 };
1789 static const pj_str_t STR_RECVONLY = {
"recvonly", 8 };
1790 pjmedia_sdp_media *media;
1791 const char *hostip =
NULL;
1795 pjmedia_sdp_attr *attr;
1798 int min_packet_size = 0, max_packet_size = 0;
1811 int build_dtmf_sample_rates = 1;
1816 media = pj_pool_zalloc(pool,
sizeof(
struct pjmedia_sdp_media));
1825 media->desc.port = 0;
1826 media->desc.port_count = 1;
1832 media->desc.transport = remote_media->desc.transport;
1835 for (index = 0; index < remote_media->desc.fmt_count; ++index) {
1836 media->desc.fmt[index] = remote_media->desc.fmt[index];
1838 media->desc.fmt_count = remote_media->desc.fmt_count;
1841 media->desc.transport = STR_RTP_AVP;
1842 pj_strdup2(pool, &media->desc.fmt[media->desc.fmt_count++],
"32");
1845 sdp->media[sdp->media_count++] = media;
1857 for (index = 0; index < sdp->media_count; ++index) {
1876 if (session_media_transport == session_media || !session_media->
bundled) {
1887 if (pj_strlen(&session_media->
transport)) {
1889 media->desc.transport = session_media->
transport;
1893 !
session->endpoint->media.rtp.encryption_optimistic &&
1895 session_media->
rtp,
session->endpoint->media.rtp.use_avpf,
1896 session->endpoint->media.rtp.force_avp));
1899 media->conn = pj_pool_zalloc(pool,
sizeof(
struct pjmedia_sdp_conn));
1905 if (direct_media_enabled) {
1910 hostip =
session->endpoint->media.address;
1919 media->conn->net_type = STR_IN;
1921 media->conn->addr_type = STR_IP4;
1922 pj_strdup2(pool, &media->conn->addr, hostip);
1924 if ((pj_sockaddr_parse(pj_AF_UNSPEC(), 0, &media->conn->addr, &ip) == PJ_SUCCESS) &&
1925 (ip.addr.sa_family == pj_AF_INET6())) {
1926 media->conn->addr_type = STR_IP6;
1934 media->desc.port_count = 1;
1936 pjmedia_sdp_media *bundle_group_stream = sdp->media[session_media_transport->
stream_num];
1939 media->desc.transport = bundle_group_stream->desc.transport;
1940 media->conn = bundle_group_stream->conn;
1941 media->desc.port = bundle_group_stream->desc.port;
1958 if (direct_media_enabled) {
1967 build_dtmf_sample_rates = 0;
1982 ast_log(
LOG_WARNING,
"Format '%s' can not be added to SDP, consider disallowing it on endpoint '%s'\n",
1991 if (session_media_transport != session_media) {
2010 if (build_dtmf_sample_rates) {
2024 media->attr[media->attr_count++] = attr;
2028 media->attr[media->attr_count++] = attr;
2037 if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
2044 && media->desc.fmt_count < PJMEDIA_MAX_SDP_FMT) {
2045 for (index = 1LL; index <=
AST_RTP_MAX; index <<= 1) {
2046 if (!(noncodec & index)) {
2053 if (rtp_code == -1) {
2056 media->attr[media->attr_count++] = attr;
2058 }
else if (build_dtmf_sample_rates) {
2063 int i, found_default_offer = 0;
2068 if (rtp_code == -1) {
2074 found_default_offer = 1;
2078 media->attr[media->attr_count++] = attr;
2079 snprintf(
tmp,
sizeof(
tmp),
"%d 0-16", (rtp_code));
2080 attr = pjmedia_sdp_attr_create(pool,
"fmtp", pj_cstr(&stmp,
tmp));
2081 media->attr[media->attr_count++] = attr;
2088 if (!found_default_offer) {
2093 media->attr[media->attr_count++] = attr;
2094 snprintf(
tmp,
sizeof(
tmp),
"%d 0-16", (rtp_code));
2095 attr = pjmedia_sdp_attr_create(pool,
"fmtp", pj_cstr(&stmp,
tmp));
2096 media->attr[media->attr_count++] = attr;
2101 if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
2111 if (!media->desc.fmt_count) {
2117 if (!min_packet_size) {
2120 if (min_packet_size) {
2121 snprintf(
tmp,
sizeof(
tmp),
"%d", min_packet_size);
2122 attr = pjmedia_sdp_attr_create(pool,
"ptime", pj_cstr(&stmp,
tmp));
2123 media->attr[media->attr_count++] = attr;
2126 if (max_packet_size) {
2127 snprintf(
tmp,
sizeof(
tmp),
"%d", max_packet_size);
2128 attr = pjmedia_sdp_attr_create(pool,
"maxptime", pj_cstr(&stmp,
tmp));
2129 media->attr[media->attr_count++] = attr;
2132 attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
2135 attr->name = STR_INACTIVE;
2137 attr->name = STR_SENDONLY;
2141 attr->name = STR_RECVONLY;
2143 attr->name = STR_SENDONLY;
2145 attr->name = STR_RECVONLY;
2147 attr->name = STR_INACTIVE;
2149 attr->name = STR_SENDRECV;
2152 media->attr[media->attr_count++] = attr;
2156 attr = pjmedia_sdp_attr_create(pool,
"rtcp-mux",
NULL);
2157 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
2166 sdp->media[sdp->media_count++] = media;
2175 if (!session_media->
rtp) {
2193 if (!session_media->
rtp) {
2209 if (!session_media->
rtp) {
2218 const struct pjmedia_sdp_session *remote,
int index,
struct ast_stream *asterisk_stream)
2221 struct pjmedia_sdp_media *remote_stream = remote->media[index];
2223 char host[NI_MAXHOST];
2235 if (!
session->endpoint->media.rtp.use_received_transport &&
2250 if (session_media_transport == session_media || !session_media->
bundled) {
2257 if (!
session->endpoint->media.rtp.encryption_optimistic && res) {
2264 if (!remote_stream->conn && !remote->conn) {
2268 ast_copy_pj_str(host, remote_stream->conn ? &remote_stream->conn->addr : &remote->conn->addr,
sizeof(host));
2297 if (
set_caps(
session, session_media, session_media_transport, remote_stream, 0, asterisk_stream)) {
2312 if ((pjmedia_sdp_neg_was_answer_remote(
session->inv_session->neg) == PJ_FALSE)
2313 && (
session->inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
2334 }
else if ((pjmedia_sdp_neg_was_answer_remote(
session->inv_session->neg) == PJ_FALSE)
2335 && (
session->inv_session->state == PJSIP_INV_STATE_CONFIRMED)) {
2342 if (
session->endpoint->media.rtp.keepalive > 0 &&
2385 char host[NI_MAXHOST];
2389 if (!stream->conn || !transport_state) {
2410 if (!session_media->
rtp) {
2422 if (session_media->
rtp) {
2453 struct pjsip_transaction *tsx;
2454 pjsip_tx_data *tdata;
2462 tsx = pjsip_rdata_get_tsx(rdata);
2466 if (pjsip_dlg_create_response(
session->inv_session->dlg, rdata, 200,
NULL, &tdata) == PJ_SUCCESS) {
2467 pjsip_dlg_send_response(
session->inv_session->dlg, tsx, tdata);
2544 .
requires =
"res_pjsip,res_pjsip_session",
Access Control of various sorts.
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_mansession session
#define ast_strndup(str, len)
A wrapper for strndup()
#define ao2_iterator_next(iter)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
Internal Asterisk hangup causes.
#define AST_CAUSE_REQUESTED_CHAN_UNAVAIL
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_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.
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
const char * ast_channel_uniqueid(const struct ast_channel *chan)
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
int ast_queue_hold(struct ast_channel *chan, const char *musicclass)
Queue a hold frame.
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
#define ast_channel_unlock(chan)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
static struct ao2_container * codecs
Registered codecs.
ast_media_type
Types of media.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
Convenient Signal Processing routines.
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
#define SCOPE_EXIT_RTN(...)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define SCOPE_ENTER(level,...)
@ AST_CONTROL_UPDATE_RTP_PEER
struct ast_frame ast_null_frame
#define ast_debug(level,...)
Log a DEBUG message.
A set of macros to manage forward-linked lists.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DRIVER
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
char * ast_sockaddr_stringify_fmt(const struct ast_sockaddr *addr, int format)
Convert a socket address to a string.
#define AST_SOCKADDR_STR_ADDR
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
int ast_sockaddr_is_any(const struct ast_sockaddr *addr)
Determine if the address type is unspecified, or "any" address.
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.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static char * ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
pjsip_media_type pjsip_media_type_application_media_control_xml
ast_sip_session_media_encryption
@ AST_SIP_MEDIA_ENCRYPT_SDES
@ AST_SIP_MEDIA_TRANSPORT_INVALID
@ AST_SIP_MEDIA_ENCRYPT_NONE
@ AST_SIP_MEDIA_ENCRYPT_DTLS
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.
int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b)
Compare pjsip media types.
#define ast_sip_transport_is_nonlocal(transport_state, addr)
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
@ AST_SIP_SECURITY_NEG_MEDIASEC
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
static int send_keepalive(const void *data)
static pjmedia_sdp_attr * generate_rtpmap_attr2(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, int sample_rate)
static void apply_dtls_attrib(struct ast_sip_session_media *session_media, pjmedia_sdp_attr *attr)
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.
static void set_session_media_remotely_held(struct ast_sip_session_media *session_media, const struct ast_sip_session *session, const pjmedia_sdp_media *media, const struct ast_stream *stream, const struct ast_sockaddr *addrs)
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.
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.
static struct ast_sched_context * sched
Scheduler for RTCP purposes.
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)
static struct ast_frame * media_session_rtcp_read_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_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.
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 int media_session_rtp_write_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_frame *frame)
static int rtp_check_timeout(const void *data)
Check whether RTP is being received or not.
static const char STR_AUDIO[]
static struct ast_sip_session_sdp_handler audio_sdp_handler
SDP handler for 'audio' media stream.
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)
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.
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 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)
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, struct ast_format_cap *astformats)
static void stream_stop(struct ast_sip_session_media *session_media)
Function which stops the RTP instance.
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)
static int setup_srtp(struct ast_sip_session_media *session_media)
static void stream_destroy(struct ast_sip_session_media *session_media)
Function which destroys the RTP instance when session ends.
static int parse_dtls_attrib(struct ast_sip_session_media *session_media, const struct pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
static const char STR_VIDEO[]
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.
static int media_stream_has_crypto(const struct pjmedia_sdp_media *stream)
figure out if media stream has crypto lines for sdes
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.
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.
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)
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)
static struct ast_sockaddr address_rtp
Address for RTP.
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)
static struct ast_sip_session_sdp_handler video_sdp_handler
SDP handler for 'video' media stream.
static int load_module(void)
Load the module.
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)
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
static int unload_module(void)
Unloads the sdp RTP/AVP module from Asterisk.
static int video_info_incoming_request(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
static struct ast_sip_session_supplement video_info_supplement
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)
static struct ast_frame * media_session_rtp_read_callback(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
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.
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.
static pjmedia_sdp_attr * generate_fmtp_attr(pj_pool_t *pool, struct ast_format *format, int rtp_code)
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.
static int setup_sdes_srtp(struct ast_sip_session_media *session_media, const struct pjmedia_sdp_media *stream)
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.
static int setup_dtls_srtp(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
static void set_ice_components(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
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 ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Unregister an SDP handler.
int ast_sip_session_register_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Register an SDP handler.
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.
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.
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_sip_session_register_supplement(supplement)
void ast_sip_session_unregister_supplement(struct ast_sip_session_supplement *supplement)
Unregister a an supplement to SIP session processing.
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.
const char * ast_sip_session_get_name(const struct ast_sip_session *session)
Get the channel or endpoint name associated with the session.
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_AES_CM_128_HMAC_SHA1_80
@ AST_AES_CM_128_HMAC_SHA1_32
Pluggable RTP Architecture.
ast_rtp_dtls_setup
DTLS setup types.
@ AST_RTP_DTLS_SETUP_PASSIVE
@ AST_RTP_DTLS_SETUP_HOLDCONN
@ AST_RTP_DTLS_SETUP_ACTPASS
@ AST_RTP_DTLS_SETUP_ACTIVE
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.
@ AST_RTP_ICE_ROLE_CONTROLLING
@ AST_RTP_ICE_ROLE_CONTROLLED
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.
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
enum ast_rtp_dtmf_mode ast_rtp_instance_dtmf_mode_get(struct ast_rtp_instance *instance)
Get the DTMF mode of an RTP instance.
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.
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.
void ast_rtp_instance_set_last_rx(struct ast_rtp_instance *rtp, time_t time)
Set the last RTP reception time.
ast_rtp_dtls_hash
DTLS fingerprint hashes.
@ AST_RTP_DTLS_HASH_SHA256
@ AST_RTP_DTMF_MODE_RFC2833
@ AST_RTP_DTMF_MODE_INBAND
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.
void ast_rtp_instance_stop(struct ast_rtp_instance *instance)
Stop an RTP instance.
@ AST_RTP_INSTANCE_RTCP_MUX
@ AST_RTP_INSTANCE_RTCP_STANDARD
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.
size_t ast_rtp_instance_extmap_count(struct ast_rtp_instance *instance)
Get the number of known unique identifiers.
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.
@ AST_RTP_INSTANCE_STAT_REMOTE_SSRC
void ast_rtp_instance_set_stream_num(struct ast_rtp_instance *instance, int stream_num)
Set the stream number for an RTP instance.
int ast_rtp_instance_get_keepalive(struct ast_rtp_instance *instance)
Get the RTP keepalive interval.
const char * ast_rtp_instance_get_cname(struct ast_rtp_instance *rtp)
Retrieve the CNAME used in RTCP SDES items.
int ast_rtp_instance_get_timeout(struct ast_rtp_instance *instance)
Get the RTP timeout value.
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.
#define ast_debug_rtp(sublevel,...)
Log debug level RTP information.
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
int ast_rtp_instance_bundle(struct ast_rtp_instance *child, struct ast_rtp_instance *parent)
Request that an RTP instance be bundled with another.
void ast_rtp_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
time_t ast_rtp_instance_get_last_tx(const struct ast_rtp_instance *rtp)
Get the last RTP transmission time.
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_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
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.
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.
@ AST_RTP_ICE_CANDIDATE_TYPE_RELAYED
@ AST_RTP_ICE_CANDIDATE_TYPE_SRFLX
@ AST_RTP_ICE_CANDIDATE_TYPE_HOST
int ast_rtp_codecs_payload_code_sample_rate(struct ast_rtp_codecs *codecs, int asterisk_format, struct ast_format *format, int code, unsigned int sample_rate)
Retrieve a rx mapped payload type based on whether it is an Asterisk format, the code and the sample ...
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.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
ast_rtp_extension
Known RTP extensions.
@ AST_RTP_EXTENSION_TRANSPORT_WIDE_CC
@ AST_RTP_EXTENSION_ABS_SEND_TIME
@ AST_RTP_EXTENSION_UNSUPPORTED
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
int ast_rtp_instance_sendcng(struct ast_rtp_instance *instance, int level)
Send a comfort noise packet to the RTP instance.
void ast_rtp_instance_set_remote_ssrc(struct ast_rtp_instance *rtp, unsigned int ssrc)
Set the remote SSRC for an RTP instance.
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.
@ AST_RTP_OPT_G726_NONSTANDARD
@ AST_RTP_DTLS_CONNECTION_NEW
@ AST_RTP_DTLS_CONNECTION_EXISTING
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
@ AST_RTP_PROPERTY_RETRANS_RECV
@ AST_RTP_PROPERTY_RETRANS_SEND
@ AST_RTP_PROPERTY_ASYMMETRIC_CODEC
#define AST_RTP_PT_LAST_STATIC
#define ast_debug_ice(sublevel,...)
Log debug level ICE information.
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.
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.
time_t ast_rtp_instance_get_last_rx(const struct ast_rtp_instance *rtp)
Get the last RTP reception time.
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.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
ast_rtp_extension_direction
Directions for RTP extensions.
@ AST_RTP_EXTENSION_DIRECTION_SENDRECV
@ AST_RTP_EXTENSION_DIRECTION_NONE
@ AST_RTP_EXTENSION_DIRECTION_INACTIVE
@ AST_RTP_EXTENSION_DIRECTION_RECVONLY
@ AST_RTP_EXTENSION_DIRECTION_SENDONLY
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.
const char * ast_rtp_instance_extmap_get_uri(struct ast_rtp_instance *instance, int id)
Retrieve the URI for an RTP extension id.
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.
int ast_rtp_codecs_set_preferred_dtmf_format(struct ast_rtp_codecs *codecs, int pt, int rate)
Set the preferred dtmf format pt and sample rate.
#define AST_RTP_CODECS_NULL_INIT
int ast_rtp_instance_extmap_get_id(struct ast_rtp_instance *instance, enum ast_rtp_extension extension)
Retrieve the id for an RTP extension.
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.
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.
void ast_rtp_instance_extmap_clear(struct ast_rtp_instance *instance)
Clear negotiated RTP extension information.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
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.
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
void ast_rtp_instance_set_keepalive(struct ast_rtp_instance *instance, int timeout)
Set the RTP keepalive interval.
unsigned int ast_rtp_instance_get_ssrc(struct ast_rtp_instance *rtp)
Retrieve the local SSRC value that we will be using.
#define DEFAULT_DTMF_SAMPLE_RATE_MS
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.
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 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.
void ast_rtp_instance_set_timeout(struct ast_rtp_instance *instance, int timeout)
Set the RTP timeout value.
int ast_rtp_codecs_set_preferred_format(struct ast_rtp_codecs *codecs, struct ast_format *format)
Set the preferred format.
Scheduler Routines (derived from cheops)
#define AST_SCHED_DEL(sched, id)
Remove a scheduler entry.
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
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_sched_context * ast_sched_context_create(void)
Create a scheduler context.
SRTP and SDP Security descriptions.
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_sdp_crypto * ast_sdp_crypto_alloc(void)
Initialize an return an ast_sdp_crypto struct.
struct ast_sdp_srtp * ast_sdp_srtp_alloc(void)
allocate a ast_sdp_srtp structure
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.
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.
#define AST_SRTP_CRYPTO_OFFER_OK
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
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_stream_to_str(const struct ast_stream *stream, struct ast_str **buf)
Get a string representing the stream for debugging/display purposes.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
@ AST_STREAM_STATE_RECVONLY
Set when the stream is receiving media only.
@ AST_STREAM_STATE_INACTIVE
Set when the stream is not sending OR receiving media.
@ AST_STREAM_STATE_REMOVED
Set when the stream has been removed/declined.
@ AST_STREAM_STATE_SENDONLY
Set when the stream is sending media only.
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
int ast_stream_get_group(const struct ast_stream *stream)
Get the stream group that a stream is part of.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
#define ast_str_alloca(init_len)
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Main Channel structure associated with a channel.
Data structure associated with a single frame of data.
Structure that represents the optional DTLS SRTP support within an RTP engine.
int(* set_configuration)(struct ast_rtp_instance *instance, const struct ast_rtp_dtls_cfg *dtls_cfg)
enum ast_rtp_dtls_setup(* get_setup)(struct ast_rtp_instance *instance)
enum ast_rtp_dtls_hash(* get_fingerprint_hash)(struct ast_rtp_instance *instance)
const char *(* get_fingerprint)(struct ast_rtp_instance *instance)
void(* reset)(struct ast_rtp_instance *instance)
void(* set_fingerprint)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_hash hash, const char *fingerprint)
enum ast_rtp_dtls_connection(* get_connection)(struct ast_rtp_instance *instance)
void(* set_setup)(struct ast_rtp_instance *instance, enum ast_rtp_dtls_setup setup)
Structure for an ICE candidate.
struct ast_sockaddr address
enum ast_rtp_ice_component_type id
struct ast_sockaddr relay_address
enum ast_rtp_ice_candidate_type type
Structure that represents the optional ICE support within an RTP engine.
void(* ice_lite)(struct ast_rtp_instance *instance)
void(* stop)(struct ast_rtp_instance *instance)
void(* change_components)(struct ast_rtp_instance *instance, int num_components)
void(* set_authentication)(struct ast_rtp_instance *instance, const char *ufrag, const char *password)
void(* start)(struct ast_rtp_instance *instance)
const char *(* get_ufrag)(struct ast_rtp_instance *instance)
void(* add_remote_candidate)(struct ast_rtp_instance *instance, const struct ast_rtp_engine_ice_candidate *candidate)
const char *(* get_password)(struct ast_rtp_instance *instance)
void(* set_role)(struct ast_rtp_instance *instance, enum ast_rtp_ice_role role)
struct ao2_container *(* get_local_candidates)(struct ast_rtp_instance *instance)
structure for secure RTP audio
struct ast_sdp_srtp::@278 sdp_srtp_list
struct ast_sdp_crypto * crypto
An entity with which Asterisk communicates.
struct ast_sip_endpoint_media_configuration media
A handler for SDPs in SIP sessions.
A supplement to SIP message processing.
A structure describing a SIP session.
Structure for SIP transport information.
struct pjsip_transport * transport
Transport itself.
Socket address structure.
Support for dynamic strings.
structure to hold extensions
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_set_flag(p, flag)
int ast_check_ipv6(void)
Test that an OS supports IPv6 Networking.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR(name, type)
Define a vector structure.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.