57#define SDP_HANDLER_BUCKETS 11
59#define MOD_DATA_ON_RESPONSE "on_response"
60#define MOD_DATA_NAT_HOOK "nat_hook"
63#define DEFAULT_NUM_SESSION_MEDIA 2
107static struct pjmedia_sdp_session *
create_local_sdp(pjsip_inv_session *inv,
struct ast_sip_session *
session,
const pjmedia_sdp_session *offer,
const unsigned int ignore_active_stream_topology);
120 return "(null session)";
124 }
else if (
session->endpoint) {
133 return id->number.valid
134 && (
session->endpoint->id.trust_outbound
163 ast_debug(1,
"Registered SDP stream handler '%s' for stream type '%s'\n",
handler->id, stream_type);
169 handler_list =
ao2_alloc(
sizeof(*handler_list) + strlen(stream_type),
NULL);
174 strcpy(handler_list->stream_type, stream_type);
180 ast_debug(1,
"Registered SDP stream handler '%s' for stream type '%s'\n",
handler->id, stream_type);
190 const char *stream_type = arg;
195 ast_debug(1,
"Unregistered SDP stream handler '%s' for stream type '%s'\n",
handler->id, stream_type);
201 ast_debug(3,
"No more handlers exist for stream type '%s'\n", stream_type);
228 media_state =
ast_calloc(1,
sizeof(*media_state));
258 if (!media_state || !sip_session) {
265 if (!media || !media->
rtp) {
372 if (!
session->pending_media_state->topology) {
399 .read_callback = callback,
400 .session = session_media,
428 return session_media;
438 return bundle_group_session_media;
442 return session_media;
472 handler->stream_destroy(session_media);
489 if (session_media->
srtp) {
511 if (current_session_media && current_session_media->
type ==
type) {
522 ast_trace(1,
"Reusing existing media session\n");
538 ast_trace(1,
"Can't reuse existing media session because the types are different. %s <> %s\n",
540 session_media =
NULL;
544 if (!session_media) {
547 if (!session_media) {
550 ast_trace(1,
"Creating new media session\n");
560 if (
session->endpoint->media.bundle) {
610 return (type_streams[
type] > 0);
626 for (index = 0; index < sdp->attr_count; ++index) {
627 pjmedia_sdp_attr *attr = sdp->attr[index];
628 char value[pj_strlen(&attr->value) + 1], *mids =
value, *attr_mid;
630 if (pj_strcmp2(&attr->name,
"group") || pj_strncmp2(&attr->value,
"BUNDLE", 6)) {
639 while ((attr_mid =
strsep(&mids,
" "))) {
640 if (!strcmp(attr_mid,
mid)) {
657 const pjmedia_sdp_session *sdp,
658 const struct pjmedia_sdp_media *stream)
660 pjmedia_sdp_attr *attr;
662 if (!
session->endpoint->media.bundle) {
673 attr = pjmedia_sdp_media_find_attr2(stream,
"mid",
NULL);
679 if (!session_media->
mid) {
695 const pjmedia_sdp_session *sdp,
696 const struct pjmedia_sdp_media *stream,
706 for (index = 0; index < stream->attr_count; ++index) {
707 pjmedia_sdp_attr *attr = stream->attr[index];
708 char attr_value[pj_strlen(&attr->value) + 1];
709 char *ssrc_attribute_name, *ssrc_attribute_value =
NULL;
710 char *msid, *
tmp = attr_value;
711 static const pj_str_t STR_msid = {
"msid", 4 };
712 static const pj_str_t STR_ssrc = {
"ssrc", 4 };
713 static const pj_str_t STR_label = {
"label", 5 };
715 if (!pj_strcmp(&attr->name, &STR_label)) {
718 }
else if (!pj_strcmp(&attr->name, &STR_msid)) {
723 }
else if (!pj_strcmp(&attr->name, &STR_ssrc)) {
726 if ((ssrc_attribute_name = strchr(attr_value,
' '))) {
728 *ssrc_attribute_name++ =
'\0';
729 ssrc_attribute_value = strchr(ssrc_attribute_name,
':');
730 if (ssrc_attribute_value) {
732 *ssrc_attribute_value++ =
'\0';
735 if (!strcasecmp(ssrc_attribute_name,
"mslabel") && !
ast_strlen_zero(ssrc_attribute_value)) {
780 if (
session->inv_session &&
session->inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
786 if (!
session->pending_media_state->topology) {
788 if (!
session->pending_media_state->topology) {
794 for (i = 0; i < sdp->media_count; ++i) {
803 pjmedia_sdp_media *remote_stream = sdp->media[i];
818 char *stream_name =
NULL, *stream_name_allocated =
NULL;
819 const char *stream_label =
NULL;
821 if (
session->active_media_state->topology &&
840 stream_name = stream_name_allocated;
869 if (pjmedia_sdp_media_find_attr2(remote_stream,
"sendonly",
NULL)) {
875 }
else if (pjmedia_sdp_media_find_attr2(remote_stream,
"recvonly",
NULL)) {
877 }
else if (pjmedia_sdp_media_find_attr2(remote_stream,
"inactive",
NULL)) {
890 if (!session_media) {
898 SCOPE_EXIT_EXPR(
continue,
"%s: Declining incoming SDP media stream %s'\n",
907 ast_trace(-1,
"%s: Negotiating incoming SDP media stream %s using %s SDP handler\n",
910 res =
handler->negotiate_incoming_sdp_stream(
session, session_media, sdp, i, stream);
915 }
else if (res == 0) {
917 SCOPE_EXIT_EXPR(
continue,
"%s: Declining incoming SDP media stream %s\n",
919 }
else if (res > 0) {
921 ++type_streams[
type];
931 SCOPE_EXIT_EXPR(
continue,
"%s: Media stream %s has no registered handlers\n",
938 ast_trace(-1,
"%s: Negotiating incoming SDP media stream %s using %s SDP handler\n",
942 res =
handler->negotiate_incoming_sdp_stream(
session, session_media, sdp, i, stream);
948 }
else if (res == 0) {
950 ast_trace(-1,
"%s: Declining incoming SDP media stream %s\n",
953 }
else if (res > 0) {
956 ++type_streams[
type];
957 ast_trace(-1,
"%s: Media stream %s handled by %s\n",
970 handled ?
"yes" :
"no");
975 const pjmedia_sdp_session *remote,
int index,
struct ast_stream *asterisk_stream)
978 struct pjmedia_sdp_media *local_stream = local->media[index];
986 ast_copy_pj_str(media, &local->media[index]->desc.media,
sizeof(media));
996 if (pjmedia_sdp_media_find_attr2(local_stream,
"sendonly",
NULL)) {
998 }
else if (pjmedia_sdp_media_find_attr2(local_stream,
"recvonly",
NULL)) {
1000 }
else if (pjmedia_sdp_media_find_attr2(local_stream,
"inactive",
NULL)) {
1014 ast_debug(4,
"%s: Applying negotiated SDP media stream '%s' using %s SDP handler\n",
1017 res =
handler->apply_negotiated_sdp_stream(
session, session_media, local, remote, index, asterisk_stream);
1019 ast_debug(4,
"%s: Applied negotiated SDP media stream '%s' using %s SDP handler\n",
1026 SCOPE_EXIT_RTN_VALUE(-1,
"%s: Failed to apply negotiated SDP media stream '%s' using %s SDP handler\n",
1032 if (!handler_list) {
1040 ast_debug(4,
"%s: Applying negotiated SDP media stream '%s' using %s SDP handler\n",
1043 res =
handler->apply_negotiated_sdp_stream(
session, session_media, local, remote, index, asterisk_stream);
1050 ast_debug(4,
"%s: Applied negotiated SDP media stream '%s' using %s SDP handler\n",
1062 ast_debug(4,
"%s: Stopping SDP media stream '%s' as it is not currently negotiated\n",
1069 res ?
"not negotiated. Stopped" :
"handled");
1076 unsigned int changed = 0;
1079 if (!
session->pending_media_state->topology) {
1080 if (
session->active_media_state->topology) {
1088 active_media_state_clone =
1090 if (!active_media_state_clone) {
1097 session->pending_media_state = active_media_state_clone;
1112 ast_log(
LOG_WARNING,
"%s: Local SDP contains %d media streams while we expected it to contain %u\n",
1120 for (i = 0; i < local->media_count; ++i) {
1124 if (!remote->media[i]) {
1135 if (!remote->media[i]->desc.port) {
1157 changed |= session_media->
changed;
1165 for (i = 0; i < local->media_count; ++i) {
1169 if (!remote->media[i]) {
1195 if (pjmedia_sdp_neg_was_answer_remote(
session->inv_session->neg) == PJ_FALSE &&
1196 session->active_media_state &&
session->active_media_state->topology &&
1228 }
else if (changed == 2) {
1237#define DATASTORE_BUCKETS 53
1238#define MEDIA_BUCKETS 7
1258 const char *uid_ptr =
uid;
1269 datastore->info =
info;
1276 if (!datastore->uid) {
1323 const char *
str =
"<unknown>";
1408 SCOPE_ENTER(3,
"%s: sending delayed %s request\n",
1508 timer_running = pj_timer_entry_running(&
session->rescheduled_reinvite);
1513 if (!timer_running) {
1555 if (
session->inv_session->invite_tsx) {
1584 if (
session->inv_session->invite_tsx) {
1594 int (*cb)(
void *vsession))
1606 int generate_new_sdp,
1634 pjsip_inv_session *inv_session =
session->inv_session;
1635 const pjmedia_sdp_session *previous_sdp =
NULL;
1638 if (inv_session->neg) {
1639 if (pjmedia_sdp_neg_was_answer_remote(inv_session->neg)) {
1640 pjmedia_sdp_neg_get_active_remote(inv_session->neg, &previous_sdp);
1642 pjmedia_sdp_neg_get_active_local(inv_session->neg, &previous_sdp);
1652 pj_pool_t *dlg_pool;
1653 pjsip_fromto_hdr *dlg_info;
1654 pjsip_contact_hdr *dlg_contact;
1655 pjsip_name_addr *dlg_info_name_addr;
1656 pjsip_sip_uri *dlg_info_uri;
1657 pjsip_sip_uri *dlg_contact_uri;
1659 const char *pjsip_from_domain;
1677 dlg_pool =
session->inv_session->dlg->pool;
1678 dlg_info =
session->inv_session->dlg->local.info;
1679 dlg_contact =
session->inv_session->dlg->local.contact;
1680 dlg_info_name_addr = (pjsip_name_addr *) dlg_info->uri;
1681 dlg_info_uri = pjsip_uri_get_uri(dlg_info_name_addr);
1682 dlg_contact_uri = (pjsip_sip_uri*)pjsip_uri_get_uri(dlg_contact->uri);
1684 if (
session->endpoint->id.trust_outbound || !restricted) {
1694 dlg_info_name_addr->display.ptr =
NULL;
1695 dlg_info_name_addr->display.slen = 0;
1696 pj_strdup2(dlg_pool, &dlg_info_uri->user,
session->endpoint->fromuser);
1700 pj_strdup2(dlg_pool, &dlg_info_uri->host,
session->endpoint->fromdomain);
1709 ast_debug(3,
"%s: From header domain reset by channel variable SIPFROMDOMAIN (%s)\n",
1711 pj_strdup2(dlg_pool, &dlg_info_uri->host, pjsip_from_domain);
1716 session->saved_from_hdr = pjsip_hdr_clone(dlg_pool, dlg_info);
1724 pj_strdup2(dlg_pool, &dlg_info_name_addr->display,
"Anonymous");
1727 pj_strdup2(dlg_pool, &dlg_info_uri->user,
"anonymous");
1731 pj_strdup2(dlg_pool, &dlg_contact_uri->user,
"anonymous");
1735 pj_strdup2(dlg_pool, &dlg_info_uri->host,
"anonymous.invalid");
1745#define STREAM_REMOVED(_stream) (ast_stream_get_state(_stream) == AST_STREAM_STATE_REMOVED)
1746#define STATE_REMOVED(_stream_state) (_stream_state == AST_STREAM_STATE_REMOVED)
1747#define STATE_NONE(_stream_state) (_stream_state == AST_STREAM_STATE_END)
1748#define GET_STREAM_SAFE(_topology, _i) (_i < ast_stream_topology_get_count(_topology) ? ast_stream_topology_get_stream(_topology, _i) : NULL)
1749#define GET_STREAM_STATE_SAFE(_stream) (_stream ? ast_stream_get_state(_stream) : AST_STREAM_STATE_END)
1750#define GET_STREAM_NAME_SAFE(_stream) (_stream ? ast_stream_get_name(_stream) : "")
1769 SCOPE_ENTER(3,
"%s: Topology: %s\n", session_name,
1777 for (i = 0; i < stream_count; i++) {
1780 const char *stream_name =
NULL;
1789 for (j = 0; j < stream_count; j++) {
1791 if (j == i || !possible_dup) {
1807 if (j == i || !possible_dup) {
1813 i, media->
label, j);
1848 const char *session_name,
1852 int run_post_validation)
1861 int max_stream_count;
1863 SCOPE_ENTER(2,
"%s: DP: %s DA: %s CA: %s\n", session_name,
1878 if (!new_pending_state) {
1881 new_pending = new_pending_state->topology;
1883 for (i = 0; i < max_stream_count; i++) {
1900 const char *found_da_name __attribute__((unused)) =
"";
1901 const char *found_np_name __attribute__((unused)) =
"";
1902 int found_da_slot __attribute__((unused)) = -1;
1903 int found_np_slot = -1;
1904 int removed_np_slot = -1;
1906 SCOPE_ENTER(3,
"%s: slot: %d DP: %s DA: %s CA: %s\n", session_name, i,
1936 SCOPE_EXIT_EXPR(
continue,
"%s: No DP stream so use CA stream as is\n", session_name);
1944 ast_trace(-1,
"%s: Same stream in all 3 states\n", session_name);
1945 if (dp_state == da_state && da_state == ca_state) {
1947 SCOPE_EXIT_EXPR(
continue,
"%s: All in the same state so nothing to do\n", session_name);
1949 if (da_state != ca_state) {
1954 SCOPE_EXIT_EXPR(
continue,
"%s: Ignoring request to change state from %s to %s\n",
1957 if (dp_state != da_state) {
1960 SCOPE_EXIT_EXPR(
continue,
"%s: Changed NP stream state from %s to %s\n",
1985 ast_trace(-1,
"%s: Checking if DP is already in NP somewhere\n", session_name);
1990 ast_trace(-1,
"%s: Checking %s against %s\n", session_name, dp_name, possible_existing_name);
1991 if (found_np_slot == -1 &&
ast_strings_equal(dp_name, possible_existing_name)) {
1992 ast_trace(-1,
"%s: Pending stream %s slot %d is in NP slot %d\n", session_name,
1995 found_np_stream = possible_existing;
1999 if (
STREAM_REMOVED(possible_existing) && removed_np_slot == -1) {
2000 removed_np_slot = j;
2002 if (removed_np_slot >= 0 && found_np_slot >= 0) {
2009 found_np_stream = np_stream;
2010 found_np_state = np_state;
2011 found_np_name = np_name;
2022 ast_trace(-1,
"%s: Checking if DP is already in DA somewhere\n", session_name);
2027 ast_trace(-1,
"%s: Checking %s against %s\n", session_name, dp_name, possible_existing_name);
2029 ast_trace(-1,
"%s: Pending stream %s slot %d is already in delayed active slot %d\n",
2030 session_name, dp_name, i, j);
2032 found_da_stream = possible_existing;
2041 found_da_stream = da_stream;
2042 found_da_state = da_state;
2043 found_da_name = da_name;
2046 ast_trace(-1,
"%s: Found NP slot: %d Found removed NP slot: %d Found DA slot: %d\n",
2047 session_name, found_np_slot, removed_np_slot, found_da_slot);
2054 if (!found_da_stream) {
2061 ast_trace(-1,
"%s: There was no corresponding DA stream so the request was to add a stream\n", session_name);
2063 if (found_np_stream) {
2068 SCOPE_EXIT_EXPR(
continue,
"%s: New stream requested but it's already in CA\n", session_name);
2073 ast_trace(-1,
"%s: There was no corresponding NP stream\n", session_name);
2082 "%s: Attempting to remove stream %d:%s but it doesn't exist anywhere.\n", session_name, i, dp_name);
2089 ast_trace(-1,
"%s: Checking for open slot\n", session_name);
2090 if (removed_np_slot >= 0) {
2108 session_name, removed_np_slot);
2120 session_name, new_slot);
2128 ast_trace(-1,
"%s: There was a corresponding DA stream so the request was to change/remove a stream\n", session_name);
2129 if (dp_state == found_da_state) {
2131 if (!found_np_stream) {
2139 SCOPE_EXIT_EXPR(
continue,
"%s: Stream doesn't exist in CA so nothing to do\n", session_name);
2140 }
else if (dp_state == found_np_state) {
2141 SCOPE_EXIT_EXPR(
continue,
"%s: States are the same all around so nothing to do\n", session_name);
2143 SCOPE_EXIT_EXPR(
continue,
"%s: Something changed the CA state so we're going to leave it as is\n", session_name);
2148 if (!found_np_stream) {
2149 SCOPE_EXIT_EXPR(
continue,
"%s: Stream doesn't exist in CA so nothing to do\n", session_name);
2150 }
else if (da_state == found_np_state) {
2152 SCOPE_EXIT_EXPR(
continue,
"%s: Changed NP stream state from %s to %s\n",
2155 SCOPE_EXIT_EXPR(
continue,
"%s: Something changed the CA state so we're going to leave it as is\n",
2161 SCOPE_EXIT(
"%s: Done with slot %d\n", session_name, i);
2164 ast_trace(-1,
"%s: Resetting default media states\n", session_name);
2167 new_pending_state->default_session[i] =
NULL;
2173 new_pending_state->default_session[i] = media;
2179 if (run_post_validation) {
2180 ast_trace(-1,
"%s: Running post-validation\n", session_name);
2190 returned_media_state = new_pending_state;
2191 new_pending_state =
NULL;
2205 pjsip_inv_session *inv_session =
session->inv_session;
2206 pjmedia_sdp_session *new_sdp =
NULL;
2207 pjsip_tx_data *tdata;
2210 generate_new_sdp ?
"yes" :
"no", queued ?
"yes" :
"no",
2214 if (pending_media_state && (!pending_media_state->
topology || !generate_new_sdp)) {
2219 pending_media_state->
topology ==
NULL ?
"pending topology is null " :
"",
2220 !generate_new_sdp ?
"generate_new_sdp is false" :
"");
2223 if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED) {
2232 if (inv_session->dlg->state != PJSIP_DIALOG_STATE_ESTABLISHED) {
2238 SCOPE_EXIT_RTN_VALUE(res,
"%s: Delay sending reinvite because dialog has not been established\n",
2243 if (inv_session->invite_tsx) {
2250 }
else if (inv_session->state != PJSIP_INV_STATE_CONFIRMED) {
2261 if (generate_new_sdp) {
2263 if (inv_session->neg
2264 && pjmedia_sdp_neg_get_state(inv_session->neg)
2265 != PJMEDIA_SDP_NEG_STATE_DONE) {
2267 on_response, generate_new_sdp,
2271 SCOPE_EXIT_RTN_VALUE(res,
"%s: Delay session refresh with new SDP because SDP negotiation is not yet done\n",
2276 if (pending_media_state) {
2289 on_response, generate_new_sdp,
2301 if (active_media_state && active_media_state->
topology &&
2315 pending_media_state, active_media_state,
session->active_media_state, 1);
2316 if (new_pending_state) {
2319 pending_media_state = new_pending_state;
2340 if (
session->active_media_state->topology &&
2367 if (!existing_stream) {
2393 if (!existing_stream) {
2428 if (
session->active_media_state->topology) {
2462 SCOPE_EXIT(
"%s: Appended empty stream in position %d to make counts match\n",
2485 session->pending_media_state = pending_media_state;
2495 if (on_sdp_creation) {
2496 if (on_sdp_creation(
session, new_sdp)) {
2505 if (pjsip_inv_reinvite(inv_session,
NULL, new_sdp, &tdata)) {
2506 if (generate_new_sdp) {
2512 }
else if (pjsip_inv_update(inv_session,
NULL, new_sdp, &tdata)) {
2513 if (generate_new_sdp) {
2519 if (on_request_creation) {
2520 if (on_request_creation(
session, tdata)) {
2521 if (generate_new_sdp) {
2544 on_response,
method, generate_new_sdp, media_state,
NULL, 0);
2550 pjsip_inv_session *inv_session =
session->inv_session;
2551 pjmedia_sdp_session *new_answer =
NULL;
2552 const pjmedia_sdp_session *previous_offer =
NULL;
2556 if (!inv_session->neg || (pjmedia_sdp_neg_get_state(inv_session->neg) != PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER &&
2557 pjmedia_sdp_neg_get_state(inv_session->neg) != PJMEDIA_SDP_NEG_STATE_WAIT_NEGO)) {
2558 ast_log(
LOG_WARNING,
"Requested to regenerate local SDP answer for channel '%s' but negotiation in state '%s'\n",
2563 pjmedia_sdp_neg_get_neg_remote(inv_session->neg, &previous_offer);
2564 if (pjmedia_sdp_neg_get_state(inv_session->neg) == PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) {
2566 pjmedia_sdp_neg_negotiate(inv_session->pool, inv_session->neg, 0);
2567 pjmedia_sdp_neg_set_remote_offer(inv_session->pool, inv_session->neg, previous_offer);
2577 if (on_sdp_creation) {
2578 if (on_sdp_creation(
session, new_answer)) {
2583 pjsip_inv_set_sdp_answer(inv_session, new_answer);
2590 pjsip_dialog *dlg = pjsip_tdata_get_dlg(tdata);
2597 pjsip_inv_send_msg(
session->inv_session, tdata);
2607 .name = {
"Session Module", 14},
2608 .priority = PJSIP_MOD_PRIORITY_APPLICATION,
2624 if (!
session->pending_media_state->topology) {
2626 if (!
session->pending_media_state->topology) {
2631 for (i = 0; i < sdp->media_count; ++i) {
2641 pjmedia_sdp_media *remote_stream = sdp->media[i];
2646 if (
session->active_media_state->topology &&
2665 if (existing_stream) {
2674 if (!session_media) {
2680 if (pjmedia_sdp_media_find_attr2(remote_stream,
"sendonly",
NULL)) {
2686 }
else if (pjmedia_sdp_media_find_attr2(remote_stream,
"recvonly",
NULL)) {
2688 }
else if (pjmedia_sdp_media_find_attr2(remote_stream,
"inactive",
NULL)) {
2699 if (
handler->defer_incoming_sdp_stream) {
2700 res =
handler->defer_incoming_sdp_stream(
session, session_media, sdp,
2718 if (!handler_list) {
2726 if (!
handler->defer_incoming_sdp_stream) {
2729 res =
handler->defer_incoming_sdp_stream(
session, session_media, sdp,
2757 pjsip_rdata_sdp_info *sdp_info;
2760 if (rdata->msg_info.msg->line.req.method.id != PJSIP_INVITE_METHOD ||
2761 !(dlg = pjsip_ua_find_dialog(&rdata->msg_info.cid->id, &rdata->msg_info.to->tag, &rdata->msg_info.from->tag, PJ_FALSE)) ||
2767 if (
session->inv_session->invite_tsx) {
2772 if (
session->deferred_reinvite) {
2773 pj_str_t key, deferred_key;
2774 pjsip_tx_data *tdata;
2777 pjsip_tsx_create_key(rdata->tp_info.pool, &key, PJSIP_ROLE_UAS, &rdata->msg_info.cseq->method, rdata);
2778 pjsip_tsx_create_key(rdata->tp_info.pool, &deferred_key, PJSIP_ROLE_UAS, &
session->deferred_reinvite->msg_info.cseq->method,
2782 if (!pj_strcmp(&key, &deferred_key)) {
2787 if (pjsip_dlg_create_response(dlg, rdata, 491,
NULL, &tdata) == PJ_SUCCESS) {
2789 pjsip_tx_data_dec_ref(tdata);
2796 if (!(sdp_info = pjsip_rdata_get_sdp_info(rdata)) ||
2797 (sdp_info->sdp_err != PJ_SUCCESS)) {
2801 if (!sdp_info->sdp) {
2806 if (deferred == -1) {
2809 }
else if (!deferred) {
2813 pjsip_rx_data_clone(rdata, 0, &
session->deferred_reinvite);
2820 if (!
session->deferred_reinvite) {
2828 pjsip_rx_data_free_cloned(
session->deferred_reinvite);
2833 .name = {
"Session Re-Invite Module", 24 },
2834 .priority = PJSIP_MOD_PRIORITY_UA_PROXY_LAYER - 1,
2841 pjsip_inv_session *inv_session =
session->inv_session;
2848 if (inv_session->state == PJSIP_INV_STATE_DISCONNECTED &&
2849 tdata->msg->line.req.method.id != PJSIP_BYE_METHOD) {
2857 pjsip_inv_send_msg(
session->inv_session, tdata);
2869 pjmedia_sdp_session *offer;
2873 pjsip_inv_terminate(
session->inv_session, 500, PJ_FALSE);
2877 pjsip_inv_set_local_sdp(
session->inv_session, offer);
2878 pjmedia_sdp_neg_set_prefer_remote_codec_order(
session->inv_session->neg, PJ_FALSE);
2879#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
2880 if (!
session->endpoint->preferred_codec_only) {
2881 pjmedia_sdp_neg_set_answer_multiple_codecs(
session->inv_session->neg, PJ_TRUE);
2891 if (pjsip_inv_invite(
session->inv_session, tdata) != PJ_SUCCESS) {
2912 const char *uid2 = flags &
OBJ_KEY ? arg : datastore2->
uid;
2925#ifdef TEST_FRAMEWORK
2927 const char *endpoint_name =
session->endpoint ?
2970 struct pjsip_dialog *dlg =
session->inv_session->dlg;
2976#ifdef HAVE_PJSIP_INV_SESSION_REF
2977 pjsip_inv_dec_ref(
session->inv_session);
3015 int dsp_features = 0;
3027 if (!
session->direct_media_cap) {
3036 if (!
session->active_media_state) {
3040 if (!
session->pending_media_state) {
3098#ifdef HAVE_PJSIP_INV_SESSION_REF
3099 if (pjsip_inv_add_ref(
inv_session) != PJ_SUCCESS) {
3119 session->authentication_challenge_count = 0;
3208 session->suspended = suspender;
3253 pjsip_transaction *tsx;
3255 pjsip_inv_session *inv;
3256 pjsip_tx_data *tdata;
3259 if (rdata->msg_info.msg->line.status.code != 401
3260 && rdata->msg_info.msg->line.status.code != 407) {
3265 tsx = pjsip_rdata_get_tsx(rdata);
3266 dlg = pjsip_rdata_get_dlg(rdata);
3271 if (tsx->method.id != PJSIP_INVITE_METHOD) {
3276 inv = pjsip_dlg_get_inv_session(dlg);
3279 if (PJSIP_INV_STATE_CONFIRMED <= inv->
state) {
3296 tsx->last_tx, &tdata)) {
3304 pjsip_inv_uac_restart(inv, PJ_FALSE);
3311 .name = {
"Outbound INVITE Auth", 20},
3312 .priority = PJSIP_MOD_PRIORITY_DIALOG_USAGE,
3334 return status != PJ_SUCCESS ? -1 : 0;
3341 const char *uri =
NULL;
3344 pjsip_timer_setting
timer;
3346 struct pjsip_inv_session *inv_session;
3357 &found_aor, &found_contact);
3361 uri = found_contact->uri;
3369 ast_log(
LOG_ERROR,
"Endpoint '%s': No URI available. Is endpoint registered?\n",
3379 pjsip_dlg_terminate(dlg);
3384 pjsip_dlg_terminate(dlg);
3387#if defined(HAVE_PJSIP_REPLACE_MEDIA_STREAM) || defined(PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE)
3388 inv_session->sdp_neg_flags = PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE;
3391 pjsip_timer_setting_default(&
timer);
3427 if (!
session->pending_media_state->topology) {
3429 if (!
session->pending_media_state->topology) {
3430 pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
3443 if (!
session->pending_media_state->topology) {
3446 if (!
session->pending_media_state->topology) {
3447 pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
3454 pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
3474 pjsip_tx_data *packet =
NULL;
3477 if (
session->defer_terminate) {
3478 session->terminate_while_deferred = 1;
3496 switch (
session->inv_session->state) {
3497 case PJSIP_INV_STATE_NULL:
3498 if (!
session->inv_session->invite_tsx) {
3507 pjsip_inv_terminate(
session->inv_session, response, PJ_TRUE);
3515 pjsip_inv_terminate(
session->inv_session, response, PJ_TRUE);
3518 case PJSIP_INV_STATE_CONFIRMED:
3519 if (
session->inv_session->invite_tsx) {
3520 ast_debug(3,
"%s: Delay sending BYE because of outstanding transaction...\n",
3531 if (
status == PJ_SUCCESS && packet) {
3539 if (packet->msg->type == PJSIP_RESPONSE_MSG) {
3554 if (
session->defer_terminate) {
3576 pj_time_val delay = { .sec = 60, };
3585 session->ended_while_deferred = 0;
3591 &
session->scheduled_termination, &delay) != PJ_SUCCESS) ? -1 : 0;
3609 &
session->scheduled_termination,
session->scheduled_termination.id)) {
3616 if (!
session->defer_terminate) {
3623 if (
session->terminate_while_deferred) {
3640 if (
session->ended_while_deferred) {
3643 session->ended_while_deferred = 0;
3650 pjsip_inv_session *
inv_session = pjsip_dlg_get_inv_session(dlg);
3679 return PJSIP_INV_STATE_NULL;
3724 pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
3735 ast_debug(1,
"RURI contains no user portion: defaulting to extension 's'\n");
3747 ast_log(
LOG_ERROR,
"%s: Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n",
3765 session->request_uri = pjsip_uri_clone(
session->inv_session->pool, ruri);
3773 if (
session->endpoint->allow_overlap && (
3806 int answer_code,
int terminate_code, pj_bool_t notify)
3808 pjsip_tx_data *tdata =
NULL;
3811 if (inv_session->state != PJSIP_INV_STATE_DISCONNECTED) {
3812 if (pjsip_inv_initial_answer(
3813 inv_session, rdata, answer_code,
NULL,
NULL, &tdata) != PJ_SUCCESS) {
3815 pjsip_inv_terminate(inv_session, terminate_code ? terminate_code : answer_code, notify);
3818 pjsip_inv_send_msg(inv_session, tdata);
3822 if (answer_code >= 300) {
3827 pjsip_dlg_dec_lock(inv_session->dlg);
3854 pjsip_tx_data *tdata;
3856 pjsip_inv_session *inv_session;
3858 const pj_str_t STR_100REL = {
"100rel", 6};
3860 pj_status_t dlg_status = PJ_EUNKNOWN;
3867 for (i = 0; i < rdata->msg_info.supported->count; ++i) {
3868 if (pj_stricmp(&rdata->msg_info.supported->values[i], &STR_100REL) == 0) {
3869 options |= PJSIP_INV_REQUIRE_100REL;
3878 pjsip_tx_data_dec_ref(tdata);
3888 if (dlg_status != PJ_EEXISTS) {
3899 if (pjsip_inv_create_uas(dlg, rdata,
NULL,
options, &inv_session) != PJ_SUCCESS) {
3906 pjsip_dlg_dec_lock(dlg);
3907 pjsip_dlg_terminate(dlg);
3911#if defined(HAVE_PJSIP_REPLACE_MEDIA_STREAM) || defined(PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE)
3912 inv_session->sdp_neg_flags = PJMEDIA_SDP_NEG_ALLOW_MEDIA_CHANGE;
3935 pjsip_media_type app_sdp;
3936 pjsip_media_type_init2(&app_sdp,
"application",
"sdp");
3938 if (!pjsip_media_type_cmp(content_type, &app_sdp, 0)) {
3947 pjsip_hdr *hdr = part->hdr.next;
3948 static const pj_str_t str_handling_required = {
"handling=required", 16};
3950 while (hdr != &part->hdr) {
3951 if (hdr->type == PJSIP_H_OTHER) {
3952 pjsip_generic_string_hdr *generic_hdr = (pjsip_generic_string_hdr*)hdr;
3954 if (!pj_stricmp2(&hdr->name,
"Content-Disposition") &&
3955 pj_stristr(&generic_hdr->hvalue, &str_handling_required) &&
3971 pjsip_msg_body *body = rdata->msg_info.msg->body;
3972 pjsip_ctype_hdr *ctype_hdr = rdata->msg_info.ctype;
3974 if (body && ctype_hdr &&
3977 pjsip_multipart_part *part = pjsip_multipart_get_first_part(body);
3978 while (part !=
NULL) {
3982 part = pjsip_multipart_get_next_part(body, part);
3990 pjsip_tx_data *tdata =
NULL;
3991 pjsip_timer_setting
timer;
3992 pjsip_rdata_sdp_info *sdp_info;
3993 pjmedia_sdp_session *local =
NULL;
4015 ast_trace(-1,
"%s: Call (%s:%s) to extension '%s' - unsupported uri\n",
4017 invite->
rdata->tp_info.transport->type_name,
4018 pj_sockaddr_print(&invite->
rdata->pkt_info.src_addr, buffer,
sizeof(buffer), 3),
4027 ast_trace(-1,
"%s: Call (%s:%s) to extension '%s' - partial match\n",
4029 invite->
rdata->tp_info.transport->type_name,
4030 pj_sockaddr_print(&invite->
rdata->pkt_info.src_addr, buffer,
sizeof(buffer), 3),
4041 ast_trace_log(-1,
LOG_NOTICE,
"%s: Call (%s:%s) to extension '%s' rejected because extension not found in context '%s'.\n",
4043 invite->
rdata->tp_info.transport->type_name,
4044 pj_sockaddr_print(&invite->
rdata->pkt_info.src_addr, buffer,
sizeof(buffer), 3),
4065 pjsip_timer_setting_default(&
timer);
4084 ast_trace(-1,
"%s: Call (%s:%s) to extension '%s' sending 100 Trying\n",
4086 invite->
rdata->tp_info.transport->type_name,
4087 pj_sockaddr_print(&invite->
rdata->pkt_info.src_addr, buffer,
sizeof(buffer), 3),
4091 sdp_info = pjsip_rdata_get_sdp_info(invite->
rdata);
4092 if (sdp_info && (sdp_info->sdp_err == PJ_SUCCESS) && sdp_info->sdp) {
4119 pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->
session->
inv_session->neg, PJ_FALSE);
4120#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
4122 pjmedia_sdp_neg_set_answer_multiple_codecs(invite->
session->
inv_session->neg, PJ_TRUE);
4140 int res =
TRACE_ATLEAST(1) ? pjsip_uri_print(PJSIP_URI_IN_REQ_URI,
rdata->msg_info.msg->line.req.uri, req_uri, 256) : 0;
4141 SCOPE_ENTER(1,
"Request: %s\n", res ? req_uri :
"");
4179 pjsip_inv_terminate(inv_session, 500, PJ_FALSE);
4205 pjsip_dlg_dec_lock(inv_session->dlg);
4219 pj_cstr(&
method, supplement_method);
4227 struct pjsip_method *
method = &rdata->msg_info.msg->line.req.method;
4248 pjsip_dialog *dlg = pjsip_tsx_get_dlg(tsx);
4249 pjsip_inv_session *inv_session = (dlg ? pjsip_dlg_get_inv_session(dlg) :
NULL);
4255 ast_trace(2,
"Topology: Pending: %s Active: %s\n",
4270 struct pjsip_status_line
status = rdata->msg_info.msg->line.status;
4271 pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
4272 pjsip_inv_session *inv_session = dlg ? pjsip_dlg_get_inv_session(dlg) :
NULL;
4275 (
int)rdata->msg_info.cseq->method.name.slen, rdata->msg_info.cseq->method.name.ptr,
status.code);
4299 pj_status_t handled = PJ_FALSE;
4300 struct pjsip_request_line req = rdata->msg_info.msg->line.req;
4301 pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata);
4302 pjsip_inv_session *inv_session = (dlg ? pjsip_dlg_get_inv_session(dlg) :
NULL);
4305 int res =
TRACE_ATLEAST(1) ? pjsip_uri_print(PJSIP_URI_IN_REQ_URI, rdata->msg_info.msg->line.req.uri, req_uri, 256) : 0;
4307 (
int) pj_strlen(&req.method.name), pj_strbuf(&req.method.name), res ? req_uri :
"");
4309 switch (req.method.id) {
4310 case PJSIP_INVITE_METHOD:
4320 handled = dlg && (
inv_session = pjsip_dlg_get_inv_session(dlg)) &&
4326 (
int) pj_strlen(&req.method.name), pj_strbuf(&req.method.name), req_uri,
4327 handled == PJ_TRUE ?
"yes" :
"no");
4333 pjsip_dialog *dlg = pjsip_tdata_get_dlg(tdata);
4346 ast_debug(3,
"%s: re-INVITE collision timer expired.\n",
4365 pjsip_inv_session *inv =
session->inv_session;
4370 int use_pending = 0;
4384 use_pending =
session->pending_media_state->topology !=
NULL;
4385 use_active =
session->active_media_state->topology !=
NULL;
4398 if (!pending_media_state) {
4405 if (!active_media_state) {
4412 active_media_state, 1)) {
4418 if (pj_timer_entry_running(&
session->rescheduled_reinvite)) {
4424 if (inv->role == PJSIP_ROLE_UAC) {
4433 &
session->rescheduled_reinvite, &tv) != PJ_SUCCESS) {
4452 function, pjsip_event_str(e->type));
4454 ast_log(
LOG_DEBUG,
"Transaction %p does not belong to an inv_session?\n", tsx);
4456 pjsip_tsx_state_str(tsx->state));
4469 if (inv->invite_tsx) {
4476 ast_log(
LOG_DEBUG,
"The %s %.*s transaction involved in this state change is %p\n",
4477 pjsip_role_name(tsx->role),
4478 (
int) pj_strlen(&tsx->method.name), pj_strbuf(&tsx->method.name),
4481 pjsip_tsx_state_str(tsx->state));
4483 pjsip_event_str(e->body.tsx_state.type));
4485 ast_log(
LOG_DEBUG,
"There is no transaction involved in this state change\n");
4487 ast_log(
LOG_DEBUG,
"The current inv state is %s\n", pjsip_inv_state_name(inv->state));
4490#define print_debug_details(inv, tsx, e) __print_debug_details(__PRETTY_FUNCTION__, (inv), (tsx), (e))
4495 struct pjsip_request_line req = rdata->msg_info.msg->line.req;
4547 struct pjsip_status_line
status = rdata->msg_info.msg->line.status;
4566 if (rdata->msg_info.msg->type == PJSIP_REQUEST_MSG) {
4578 struct pjsip_request_line req = tdata->msg->line.req;
4580 (
int) pj_strlen(&req.method.name), pj_strbuf(&req.method.name));
4595 struct pjsip_status_line
status = tdata->msg->line.status;
4596 pjsip_cseq_hdr *cseq = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CSEQ,
NULL);
4598 (
int) pj_strlen(&cseq->method.name),
4599 pj_strbuf(&cseq->method.name),
status.code, (
int) pj_strlen(&
status.reason),
4600 pj_strbuf(&
status.reason));
4657 pjsip_transaction *tsx = e->body.tsx_state.tsx;
4659 if (tsx->status_code != 503 && tsx->status_code != 408) {
4667 pjsip_inv_uac_restart(inv, PJ_FALSE);
4672 pjsip_tx_data_add_ref(tsx->last_tx);
4682 "request" :
"response");
4686 msg = rdata->msg_info.msg;
4687 if (msg->type == PJSIP_REQUEST_MSG
4688 && msg->line.req.method.id == PJSIP_ACK_METHOD
4689 && pjmedia_sdp_neg_get_state(inv->neg) != PJMEDIA_SDP_NEG_STATE_DONE) {
4690 pjsip_tx_data *tdata;
4699 "%s: Ending session due to incomplete SDP negotiation. %s\n",
4701 pjsip_rx_data_get_info(rdata));
4702 if (pjsip_inv_end_session(inv, 400,
NULL, &tdata) == PJ_SUCCESS
4711 pjsip_event_id_e
type;
4714 pjsip_event_str(e->type), pjsip_inv_state_name(inv->state));
4724 type = PJSIP_EVENT_UNKNOWN;
4733 case PJSIP_EVENT_TX_MSG:
4735 case PJSIP_EVENT_RX_MSG:
4738 case PJSIP_EVENT_TSX_STATE:
4740 pjsip_event_str(e->body.tsx_state.type));
4742 switch(e->body.tsx_state.type) {
4743 case PJSIP_EVENT_TX_MSG:
4745 case PJSIP_EVENT_RX_MSG:
4750 case PJSIP_EVENT_TRANSPORT_ERROR:
4751 case PJSIP_EVENT_TIMER:
4759 case PJSIP_EVENT_USER:
4760 case PJSIP_EVENT_UNKNOWN:
4761 case PJSIP_EVENT_TSX_STATE:
4766 case PJSIP_EVENT_TRANSPORT_ERROR:
4767 case PJSIP_EVENT_TIMER:
4768 case PJSIP_EVENT_UNKNOWN:
4769 case PJSIP_EVENT_USER:
4774 if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
4777 session->ended_while_deferred = 1;
4799 if (inv->state != PJSIP_INV_STATE_DISCONNECTED) {
4807 pjsip_dlg_inc_lock(inv->dlg);
4809 inv->mod_data[
id] =
NULL;
4810 pjsip_dlg_dec_lock(inv->dlg);
4829 pjsip_tx_data *tdata;
4832 pjsip_tsx_state_str(tsx->state), pjsip_inv_state_name(inv->state));
4856 switch (e->body.tsx_state.type) {
4857 case PJSIP_EVENT_TX_MSG:
4863 tsx->mod_data[
id] = e->body.tsx_state.src.tdata->mod_data[
id];
4865 case PJSIP_EVENT_RX_MSG:
4872 if ((e->body.tsx_state.src.rdata->msg_info.msg->type != PJSIP_REQUEST_MSG) ||
4873 (tsx->method.id != PJSIP_BYE_METHOD)) {
4877 if (tsx->method.id == PJSIP_INVITE_METHOD) {
4878 if (tsx->role == PJSIP_ROLE_UAC) {
4879 if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
4881 if (tsx->status_code == PJSIP_SC_REQUEST_PENDING) {
4885 if (inv->state == PJSIP_INV_STATE_CONFIRMED) {
4886 ast_debug(1,
"%s: reINVITE received final response code %d\n",
4889 if ((tsx->status_code == 401 || tsx->status_code == 407
4890 || (
session->endpoint->security_negotiation && tsx->status_code == 494))
4893 &
session->endpoint->outbound_auths,
4894 e->body.tsx_state.src.rdata, tsx->last_tx, &tdata)) {
4903 if (tsx->status_code == 481 || tsx->status_code == 408) {
4904 if (pjsip_inv_end_session(inv, 500,
NULL, &tdata) == PJ_SUCCESS
4910 }
else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
4911 if (!inv->cancelling
4912 && inv->role == PJSIP_ROLE_UAC
4913 && inv->state == PJSIP_INV_STATE_CONFIRMED
4914 && pjmedia_sdp_neg_was_answer_remote(inv->neg)
4915 && pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_DONE
4925 ast_debug(1,
"Endpoint '%s(%s)': Ending session due to 200 OK with incomplete SDP negotiation. %s\n",
4928 pjsip_rx_data_get_info(e->body.tsx_state.src.rdata));
4929 pjsip_inv_end_session(
session->inv_session, 503,
NULL, &tdata);
4933 if (inv->cancelling && tsx->status_code == PJSIP_SC_OK) {
4934 int sdp_negotiation_done =
4935 pjmedia_sdp_neg_get_state(inv->neg) == PJMEDIA_SDP_NEG_STATE_DONE;
4959 pjsip_rx_data_get_info(e->body.tsx_state.src.rdata),
4960 sdp_negotiation_done ?
"complete" :
"incomplete");
4961 if (!sdp_negotiation_done) {
4962 ast_debug(1,
"%s: Incomplete SDP negotiation cancelled session. %s\n",
4964 pjsip_rx_data_get_info(e->body.tsx_state.src.rdata));
4965 }
else if (pjsip_inv_end_session(inv, 500,
NULL, &tdata) == PJ_SUCCESS
4967 ast_debug(1,
"%s: Ending session due to RFC5407 race condition. %s\n",
4969 pjsip_rx_data_get_info(e->body.tsx_state.src.rdata));
4977 if (tsx->role == PJSIP_ROLE_UAC) {
4978 if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
4980 ast_debug(1,
"%s: %.*s received final response code %d\n",
4982 (
int) pj_strlen(&tsx->method.name), pj_strbuf(&tsx->method.name),
4984 if ((tsx->status_code == 401 || tsx->status_code == 407 || tsx->status_code == 494)
4987 &
session->endpoint->outbound_auths,
4988 e->body.tsx_state.src.rdata, tsx->last_tx, &tdata)) {
4992 (
int) pj_strlen(&tsx->method.name), pj_strbuf(&tsx->method.name));
4998 cb(
session, e->body.tsx_state.src.rdata);
5001 case PJSIP_EVENT_TRANSPORT_ERROR:
5002 case PJSIP_EVENT_TIMER:
5011 case PJSIP_EVENT_USER:
5012 case PJSIP_EVENT_UNKNOWN:
5013 case PJSIP_EVENT_TSX_STATE:
5023 if (tsx->method.id == PJSIP_INVITE_METHOD) {
5024 if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) {
5025 ast_debug(3,
"%s: INVITE delay check. tsx-state:%s\n",
5027 pjsip_tsx_state_str(tsx->state));
5029 }
else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
5035 ast_debug(3,
"%s: INVITE delay check. tsx-state:%s\n",
5037 pjsip_tsx_state_str(tsx->state));
5040 }
else if (tsx->role == PJSIP_ROLE_UAC
5041 && tsx->state == PJSIP_TSX_STATE_COMPLETED
5042 && !pj_strcmp2(&tsx->method.name,
"UPDATE")) {
5043 ast_debug(3,
"%s: UPDATE delay check. tsx-state:%s\n",
5045 pjsip_tsx_state_str(tsx->state));
5054 const struct pjmedia_sdp_session *remote,
5073 if (!handler_list) {
5109 pjmedia_sdp_attr *attr;
5114 if (
session->endpoint->media.webrtc) {
5115 attr = pjmedia_sdp_attr_create(pool,
"msid-semantic", pj_cstr(&stmp,
"WMS *"));
5116 pjmedia_sdp_attr_add(&
answer->attr_count,
answer->attr, attr);
5119 if (!
session->endpoint->media.bundle) {
5123 memset(bundle_groups, 0,
sizeof(bundle_groups));
5148 for (mid_id = 1; mid_id < PJMEDIA_MAX_SDP_MEDIA; ++mid_id) {
5160 for (index = 0; index < PJMEDIA_MAX_SDP_MEDIA; ++index) {
5168 pjmedia_sdp_attr_add(&
answer->attr_count,
answer->attr, attr);
5178 static const pj_str_t STR_IN = {
"IN", 2 };
5179 static const pj_str_t STR_IP4 = {
"IP4", 3 };
5180 static const pj_str_t STR_IP6 = {
"IP6", 3 };
5181 pjmedia_sdp_session *local;
5186 if (inv->state == PJSIP_INV_STATE_DISCONNECTED) {
5191 if (!inv->pool_prov || !(local = PJ_POOL_ZALLOC_T(inv->pool_prov, pjmedia_sdp_session))) {
5196 local->origin.version = local->origin.id = (pj_uint32_t)(
ast_random());
5198 local->origin.version = offer->origin.version + 1;
5199 local->origin.id = offer->origin.id;
5202 pj_strdup2(inv->pool_prov, &local->origin.user,
session->endpoint->media.sdpowner);
5203 pj_strdup2(inv->pool_prov, &local->name,
session->endpoint->media.sdpsession);
5211 ast_trace(-1,
"no information about stream topology received\n");
5213 if (
session->active_media_state->topology && !ignore_active_stream_topology) {
5214 ast_trace(-1,
"using existing topology\n");
5217 if (ignore_active_stream_topology) {
5218 ast_trace(-1,
"fall back to endpoint configuration - ignore active stream topolog\n");
5220 ast_trace(-1,
"fall back to endpoint configuration\n");
5224 if (!
session->pending_media_state->topology) {
5234 unsigned int streams = local->media_count;
5243 if (!session_media) {
5256 if (streams != local->media_count) {
5257 pjmedia_sdp_media *media = local->media[streams];
5259 pjmedia_sdp_attr *attr;
5263 attr = pjmedia_sdp_attr_create(inv->pool_prov,
"mid", pj_cstr(&stmp, session_media->
mid));
5264 pjmedia_sdp_attr_add(&media->attr_count, media->attr, attr);
5274 if (local->media_count == PJMEDIA_MAX_SDP_MEDIA) {
5275 SCOPE_EXIT_EXPR(
break,
"%s: Stream %s exceeded max pjmedia count of %d\n",
5277 PJMEDIA_MAX_SDP_MEDIA);
5294 for (stream = 0; stream < local->media_count; stream++) {
5296 if (!local->media[stream]->conn) {
5301 if (!pj_strcmp(&local->conn->net_type, &local->media[stream]->conn->net_type) &&
5302 !pj_strcmp(&local->conn->addr_type, &local->media[stream]->conn->addr_type) &&
5303 !pj_strcmp(&local->conn->addr, &local->media[stream]->conn->addr)) {
5304 local->media[stream]->conn =
NULL;
5310 local->conn = local->media[stream]->conn;
5311 local->media[stream]->conn =
NULL;
5320 local->conn = pj_pool_zalloc(inv->pool_prov,
sizeof(
struct pjmedia_sdp_conn));
5321 local->conn->net_type = STR_IN;
5322 local->conn->addr_type =
session->endpoint->media.rtp.ipv6 ? STR_IP6 : STR_IP4;
5325 pj_strdup2(inv->pool_prov, &local->conn->addr,
session->endpoint->media.address);
5331 pj_strassign(&local->origin.net_type, &local->conn->net_type);
5332 pj_strassign(&local->origin.addr_type, &local->conn->addr_type);
5333 pj_strassign(&local->origin.addr, &local->conn->addr);
5342 pjmedia_sdp_session *
answer;
5356 pjsip_inv_set_sdp_answer(inv,
answer);
5365 const pjmedia_sdp_session *previous_sdp =
NULL;
5366 pjmedia_sdp_session *offer;
5368 unsigned int ignore_active_stream_topology = 0;
5388 if (inv->invite_tsx && inv->state == PJSIP_INV_STATE_CONFIRMED
5389 && inv->invite_tsx->method.id == PJSIP_INVITE_METHOD) {
5391 if (inv->invite_tsx->role == PJSIP_ROLE_UAS
5393 ast_trace(-1,
"UAS role, include all codecs in the answer on empty SDP\n");
5394 ignore_active_stream_topology = 1;
5399 if (pjmedia_sdp_neg_was_answer_remote(inv->neg)) {
5400 pjmedia_sdp_neg_get_active_remote(inv->neg, &previous_sdp);
5402 pjmedia_sdp_neg_get_active_local(inv->neg, &previous_sdp);
5406 if (ignore_active_stream_topology) {
5437 for (i = 0; i < offer->media_count; ++i) {
5438 pjmedia_sdp_media *m = offer->media[i];
5439 pjmedia_sdp_attr *recvonly;
5440 pjmedia_sdp_attr *inactive;
5441 pjmedia_sdp_attr *sendonly;
5443 recvonly = pjmedia_sdp_attr_find2(m->attr_count, m->attr,
"recvonly",
NULL);
5444 inactive = pjmedia_sdp_attr_find2(m->attr_count, m->attr,
"inactive",
NULL);
5445 sendonly = pjmedia_sdp_attr_find2(m->attr_count, m->attr,
"sendonly",
NULL);
5446 if (recvonly || inactive || sendonly) {
5447 pjmedia_sdp_attr *to_remove = recvonly ?: inactive ?: sendonly;
5448 pjmedia_sdp_attr *sendrecv;
5450 pjmedia_sdp_attr_remove(&m->attr_count, m->attr, to_remove);
5452 sendrecv = pjmedia_sdp_attr_create(
session->inv_session->pool,
"sendrecv",
NULL);
5453 pjmedia_sdp_media_add_attr(m, sendrecv);
5464 const pjmedia_sdp_session *local, *remote;
5494 if (inv->following_fork) {
5495 if (
session->endpoint->media.rtp.follow_early_media_fork) {
5502#ifdef HAVE_PJSIP_INV_ACCEPT_MULTIPLE_SDP_ANSWERS
5503 else if (inv->updated_sdp_answer) {
5504 if (
session->endpoint->media.rtp.accept_multiple_sdp_answers) {
5517 if ((
status != PJ_SUCCESS) || (pjmedia_sdp_neg_get_active_local(inv->neg, &local) != PJ_SUCCESS) ||
5518 (pjmedia_sdp_neg_get_active_remote(inv->neg, &remote) != PJ_SUCCESS)) {
5535 const pjsip_sip_uri *uri;
5538 return PJSIP_REDIRECT_STOP;
5543 return PJSIP_REDIRECT_STOP;
5547 return PJSIP_REDIRECT_ACCEPT;
5550 if (!PJSIP_URI_SCHEME_IS_SIP(target) && !PJSIP_URI_SCHEME_IS_SIPS(target)) {
5551 return PJSIP_REDIRECT_STOP;
5556 uri = pjsip_uri_get_uri(target);
5571 char target_uri[PJSIP_MAX_URL_SIZE];
5575 pjsip_uri_print(PJSIP_URI_IN_REQ_URI, uri, target_uri,
sizeof(target_uri));
5577 ast_channel_call_forward_set(
session->channel, forward);
5580 return PJSIP_REDIRECT_STOP;
5599 pjsip_sdp_info *sdp_info;
5600 pjmedia_sdp_session *sdp;
5601 pjsip_dialog *dlg = pjsip_tdata_get_dlg(tdata);
5614 if (sdp_info->sdp_err != PJ_SUCCESS || !sdp_info->sdp) {
5617 sdp = sdp_info->sdp;
5620 char host[NI_MAXHOST];
5634 pj_strassign(&sdp->origin.addr, &sdp->conn->addr);
5638 for (stream = 0; stream < sdp->media_count; ++stream) {
5645 ast_copy_pj_str(media, &sdp->media[stream]->desc.media,
sizeof(media));
5648 if (!handler_list) {
5654 if (
handler->change_outgoing_sdp_stream_media_address) {
5655 handler->change_outgoing_sdp_stream_media_address(tdata, sdp->media[stream], transport);
5664#ifdef TEST_FRAMEWORK
5698 if (!session_media) {
5720 return session_media;
5725 if (left == right) {
5736 return memcmp(left, right,
sizeof(*left)) == 0;
5740 int assert_on_failure)
5745 if (left == right) {
5749 if (!(left && right)) {
5805#define FREE_STATE() \
5807 ast_sip_session_media_state_free(new_pending_state); \
5808 new_pending_state = NULL; \
5809 ast_sip_session_media_state_free(delayed_pending_state); \
5810 delayed_pending_state = NULL; \
5811 ast_sip_session_media_state_free(delayed_active_state); \
5812 delayed_active_state = NULL; \
5813 ast_sip_session_media_state_free(current_active_state); \
5814 current_active_state = NULL; \
5815 ast_sip_session_media_state_free(expected_pending_state); \
5816 expected_pending_state = NULL; \
5819#define RESET_STATE(__num) \
5822 ast_trace(-1, "Test %d\n", testnum); \
5824 delayed_pending_state = ast_sip_session_media_state_alloc(); \
5825 delayed_pending_state->topology = ast_stream_topology_alloc(); \
5826 delayed_active_state = ast_sip_session_media_state_alloc(); \
5827 delayed_active_state->topology = ast_stream_topology_alloc(); \
5828 current_active_state = ast_sip_session_media_state_alloc(); \
5829 current_active_state->topology = ast_stream_topology_alloc(); \
5830 expected_pending_state = ast_sip_session_media_state_alloc(); \
5831 expected_pending_state->topology = ast_stream_topology_alloc(); \
5836 new_pending_state = resolve_refresh_media_states("unittest", delayed_pending_state, delayed_active_state, current_active_state, 1); \
5837 if (!test_is_media_state_equal(new_pending_state, expected_pending_state, 0)) { \
5838 res = AST_TEST_FAIL; \
5840 ast_test_status_update(test, "da: %s\n", ast_str_tmp(256, ast_stream_topology_to_str(delayed_active_state->topology, &STR_TMP))); \
5841 ast_test_status_update(test, "dp: %s\n", ast_str_tmp(256, ast_stream_topology_to_str(delayed_pending_state->topology, &STR_TMP))); \
5842 ast_test_status_update(test, "ca: %s\n", ast_str_tmp(256, ast_stream_topology_to_str(current_active_state->topology, &STR_TMP))); \
5843 ast_test_status_update(test, "ep: %s\n", ast_str_tmp(256, ast_stream_topology_to_str(expected_pending_state->topology, &STR_TMP))); \
5844 ast_test_status_update(test, "np: %s\n", ast_str_tmp(256, ast_stream_topology_to_str(new_pending_state->topology, &STR_TMP))); \
5846 ast_test_status_update(test, "Test %d %s\n", testnum, test_failed ? "FAILED" : "passed"); \
5847 ast_trace(-1, "Test %d %s\n", testnum, test_failed ? "FAILED" : "passed"); \
5859 int test_failed = 0;
5865 info->name =
"merge_refresh_topologies";
5866 info->category =
"/res/res_pjsip_session/";
5867 info->summary =
"Test merging of delayed request topologies";
5868 info->description =
"Test merging of delayed request topologies";
6219 pjsip_endpoint *endpt;
6236 pjsip_100rel_init_module(endpt);
6237 pjsip_timer_init_module(endpt);
6247#ifdef TEST_FRAMEWORK
6257#ifdef TEST_FRAMEWORK
6274 .
requires =
"res_pjsip",
Access Control of various sorts.
Asterisk main include file. File version handling, generic pbx functions.
int ast_shutdown_final(void)
static struct ast_mansession session
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_link(container, obj)
Add an object to a container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
@ AO2_ALLOC_OPT_LOCK_MUTEX
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
#define ao2_callback_data(container, flags, cb_fn, arg, data)
#define ao2_find(container, arg, flags)
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc_options(data_size, destructor_fn, options)
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
#define ao2_alloc(data_size, destructor_fn)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
#define AST_PRES_RESTRICTION
Internal Asterisk hangup causes.
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
static struct ast_timer * timer
static int answer(void *data)
static struct unistimsession * sessions
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_stream_topology * ast_channel_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
Set the topology of streams on a channel.
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
#define ast_channel_lock(chan)
void ast_party_id_free(struct ast_party_id *doomed)
Destroy the party id contents.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
void ast_channel_internal_fd_set(struct ast_channel *chan, int which, int value)
int ast_channel_hangupcause(const struct ast_channel *chan)
void ast_set_hangupsource(struct ast_channel *chan, const char *source, int force)
Set the source of the hangup in this channel and it's bridge.
int ast_queue_unhold(struct ast_channel *chan)
Queue an unhold frame.
int ast_channel_stream_topology_changed_externally(struct ast_channel *chan)
Provide notice from a channel that the topology has changed on it as a result of the remote party ren...
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
struct ast_party_id ast_channel_connected_effective_id(struct ast_channel *chan)
void ast_channel_internal_fd_clear(struct ast_channel *chan, int which)
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
ast_media_type
Types of media.
enum ast_media_type ast_media_type_from_str(const char *media_type_str)
Conversion function to take a media string and convert it to a media type.
const char * ast_codec_media_type2str(enum ast_media_type type)
Conversion function to take a media type and turn it into a string.
Asterisk datastore objects.
Convenient Signal Processing routines.
void ast_dsp_free(struct ast_dsp *dsp)
#define DSP_FEATURE_DIGIT_DETECT
#define DSP_FEATURE_FAX_DETECT
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define SCOPE_EXIT_LOG_EXPR(__expr, __log_level,...)
#define SCOPE_EXIT_RTN(...)
#define TRACE_ATLEAST(level)
#define SCOPE_EXIT_RTN_VALUE(__return_value,...)
#define ast_trace_log(__level, __log_level,...)
#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level,...)
#define SCOPE_ENTER(level,...)
#define SCOPE_EXIT_EXPR(__expr,...)
#define SCOPE_EXIT_LOG_RTN(__log_level,...)
#define ast_trace(level,...)
struct ast_taskprocessor * ast_sip_get_distributor_serializer(pjsip_rx_data *rdata)
Determine the distributor serializer for the SIP message.
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer)
Set a serializer on a SIP dialog so requests and responses are automatically serialized.
char * strsep(char **str, const char *delims)
struct ast_features_pickup_config * ast_get_chan_features_pickup_config(struct ast_channel *chan)
Get the pickup configuration options for a channel.
@ AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED
struct ast_frame ast_null_frame
Support for logging to various files, console and syslog Configuration in file logger....
#define DEBUG_ATLEAST(level)
#define ast_debug(level,...)
Log a DEBUG message.
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_HEAD_DESTROY(head)
Destroys a list head structure.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_LIST_HEAD_INIT(head)
Initializes a list head structure.
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Asterisk locking-related definitions:
#define ast_cond_destroy(cond)
#define SCOPED_AO2LOCK(varname, obj)
scoped lock specialization for ao2 mutexes.
#define ast_cond_wait(cond, mutex)
#define ast_cond_init(cond, attr)
pthread_cond_t ast_cond_t
#define ast_cond_signal(cond)
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define ast_module_shutdown_ref(mod)
Prevent unload of the module before shutdown.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ 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.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
#define AST_SOCKADDR_BUFLEN
static char * ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Core PBX routines and definitions.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Looks for a valid matching extension.
void pjsip_reason_header_unload(void)
void pjsip_reason_header_load(void)
static const pjsip_method message_method
void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
Add 'user=phone' parameter to URI if enabled and user is a phone number.
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
void ast_sip_unregister_service(pjsip_module *module)
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
@ AST_SIP_REDIRECT_URI_CORE
@ AST_SIP_REDIRECT_URI_PJSIP
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
int ast_sip_is_allowed_uri(pjsip_uri *uri)
Check whether a pjsip_uri is allowed or not.
pjsip_dialog * ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user)
General purpose method for creating a UAC dialog with an endpoint.
int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_tx_data *tdata, pjsip_tx_data **new_request)
Create a response to an authentication challenge.
pjsip_media_type pjsip_media_type_application_sdp
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
int ast_sip_set_id_from_invite(struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound)
Set the ID from an INVITE.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
Truncate the URI user field options string if enabled.
struct ast_sip_endpoint * ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata)
Get the looked-up endpoint on an out-of dialog request or response.
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.
pjsip_dialog * ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
General purpose method for creating a UAS dialog with an endpoint.
int ast_sip_is_media_type_in(pjsip_media_type *a,...) attribute_sentinel
Check if a media type is in a list of others.
unsigned int ast_sip_get_use_callerid_contact(void)
Retrieve the global setting 'use_callerid_contact'.
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
#define ast_sip_mod_data_set(pool, mod_data, id, key, val)
Utilizing a mod_data array for a given id, set the value associated with the given key.
#define ast_sip_mod_data_get(mod_data, id, key)
Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the g...
pjsip_media_type pjsip_media_type_multipart_mixed
void ast_sip_location_retrieve_contact_and_aor_from_list_filtered(const char *aor_list, unsigned int flags, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags.
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
pjsip_media_type pjsip_media_type_multipart_alternative
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define MAX_RX_CHALLENGES
unsigned int ast_sip_get_all_codecs_on_empty_reinvite(void)
Retrieve the system setting 'all_codecs_on_empty_reinvite'.
@ AST_SIP_100REL_PEER_SUPPORTED
#define ast_sip_transport_is_local(transport_state, addr)
int ast_sip_failover_request(pjsip_tx_data *tdata)
Set a request to use the next value in the list of resolved addresses.
ast_sip_session_refresh_method
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
Set name and number information on an identity header.
static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status)
#define print_debug_details(inv, tsx, e)
static int remove_handler(void *obj, void *arg, void *data, int flags)
static int check_content_disposition(pjsip_rx_data *rdata)
static int invite_collision_timeout(void *vsession)
static int set_mid_and_bundle_group(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream)
static int new_invite(struct new_invite *invite)
static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
struct ast_sip_session * ast_sip_dialog_get_session(pjsip_dialog *dlg)
Retrieves a session from a dialog.
int ast_sip_session_regenerate_answer(struct ast_sip_session *session, ast_sip_session_sdp_creation_cb on_sdp_creation)
Regenerate SDP Answer.
static int handle_negotiated_sdp_session_media(struct ast_sip_session_media *session_media, struct ast_sip_session *session, const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote, int index, struct ast_stream *asterisk_stream)
static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sdp_session *sdp)
static int session_end_completion(void *vsession)
static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_sdp_session *local, const pjmedia_sdp_session *remote)
void ast_sip_session_unregister_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Unregister an SDP handler.
static pj_bool_t session_reinvite_on_rx_request(pjsip_rx_data *rdata)
static pjsip_module session_module
int ast_sip_can_present_connected_id(const struct ast_sip_session *session, const struct ast_party_id *id)
Determines if the Connected Line info can be presented for this session.
struct ast_sip_session * ast_sip_session_alloc(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_inv_session *inv_session, pjsip_rx_data *rdata)
Allocate a new SIP session.
static int media_stats_local_ssrc_cmp(const struct ast_rtp_instance_stats *vec_elem, const struct ast_rtp_instance_stats *srch)
static int check_content_disposition_in_multipart(pjsip_multipart_part *part)
#define GET_STREAM_NAME_SAFE(_stream)
static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)
static void handle_incoming_before_media(pjsip_inv_session *inv, struct ast_sip_session *session, pjsip_rx_data *rdata)
int ast_sip_session_register_sdp_handler(struct ast_sip_session_sdp_handler *handler, const char *stream_type)
Register an SDP handler.
static int session_termination_task(void *data)
static void handle_session_begin(struct ast_sip_session *session)
void ast_sip_session_send_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
Send a SIP request.
#define DATASTORE_BUCKETS
static int delay_request(struct ast_sip_session *session, ast_sip_session_request_creation_cb on_request, ast_sip_session_sdp_creation_cb on_sdp_creation, ast_sip_session_response_cb on_response, int generate_new_sdp, enum delayed_method method, struct ast_sip_session_media_state *pending_media_state, struct ast_sip_session_media_state *active_media_state, int queue_head)
static pj_bool_t outbound_invite_auth(pjsip_rx_data *rdata)
static void handle_session_destroy(struct ast_sip_session *session)
static pj_bool_t session_on_rx_request(pjsip_rx_data *rdata)
Called when a new SIP request comes into PJSIP.
pjsip_inv_state ast_sip_session_get_pjsip_inv_state(const struct ast_sip_session *session)
Retrieves the pjsip_inv_state from a session.
static int sdp_handler_list_cmp(void *obj, void *arg, int flags)
static pjsip_inv_session * pre_session_setup(pjsip_rx_data *rdata, const struct ast_sip_endpoint *endpoint)
static int sdp_requires_deferral(struct ast_sip_session *session, const pjmedia_sdp_session *sdp)
Determine whether the SDP provided requires deferral of negotiating or not.
static int setup_outbound_invite_auth(pjsip_dialog *dlg)
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.
static void handle_new_invite_request(pjsip_rx_data *rdata)
static int sip_session_suspend_task(void *data)
static void session_media_set_handler(struct ast_sip_session_media *session_media, struct ast_sip_session_sdp_handler *handler)
Set an SDP stream handler for a corresponding session media.
#define STREAM_REMOVED(_stream)
static int add_sdp_streams(struct ast_sip_session_media *session_media, struct ast_sip_session *session, pjmedia_sdp_session *answer, const struct pjmedia_sdp_session *remote, struct ast_stream *stream)
void ast_sip_session_defer_termination_cancel(struct ast_sip_session *session)
Cancel a pending deferred termination.
struct ast_datastore * ast_sip_session_get_datastore(struct ast_sip_session *session, const char *name)
Retrieve a session datastore.
static pjsip_module session_reinvite_module
#define DEFAULT_NUM_SESSION_MEDIA
struct ast_sip_session_media_state * ast_sip_session_media_state_clone(const struct ast_sip_session_media_state *media_state)
Clone a media state.
static void session_inv_on_create_offer(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer)
static enum sip_get_destination_result get_destination(struct ast_sip_session *session, pjsip_rx_data *rdata)
Determine where in the dialplan a call should go.
struct ast_sip_session_media_state * ast_sip_session_media_state_alloc(void)
Allocate a session media state structure.
#define STATE_REMOVED(_stream_state)
#define SDP_HANDLER_BUCKETS
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.
static void sip_session_suspender_dtor(void *vdoomed)
static void session_destructor(void *obj)
int ast_sip_session_add_datastore(struct ast_sip_session *session, struct ast_datastore *datastore)
Add a datastore to a SIP session.
static const char * delayed_method2str(enum delayed_method method)
void ast_sip_session_send_request_with_cb(struct ast_sip_session *session, pjsip_tx_data *tdata, ast_sip_session_response_cb on_response)
Send a SIP request and get called back when a response is received.
static void handle_session_end(struct ast_sip_session *session)
static int invite_terminated(void *vsession)
static void __print_debug_details(const char *function, pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
static pjsip_module outbound_invite_auth_module
static void set_from_header(struct ast_sip_session *session)
static pjsip_inv_callback inv_callback
#define STATE_NONE(_stream_state)
static struct ast_sip_nat_hook * nat_hook
NAT hook for modifying outgoing messages with SDP.
static int add_bundle_groups(struct ast_sip_session *session, pj_pool_t *pool, pjmedia_sdp_session *answer)
static void session_termination_cb(pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry)
static void session_media_dtor(void *obj)
static int send_delayed_request(struct ast_sip_session *session, struct ast_sip_session_delayed_request *delay)
void ast_sip_session_remove_datastore(struct ast_sip_session *session, const char *name)
Remove a session datastore from the session.
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.
pjsip_dialog * ast_sip_session_get_dialog(const struct ast_sip_session *session)
Retrieves a dialog from a session.
#define GET_STREAM_SAFE(_topology, _i)
void ast_sip_session_media_state_free(struct ast_sip_session_media_state *media_state)
Free a session media state structure.
static void sip_session_defer_termination_stop_timer(struct ast_sip_session *session)
static pj_status_t session_on_tx_response(pjsip_tx_data *tdata)
static void sip_channel_destroy(void *obj)
Destructor for SIP channel.
#define MOD_DATA_ON_RESPONSE
static int is_media_state_valid(const char *session_name, struct ast_sip_session_media_state *state)
static int get_mid_bundle_group(const pjmedia_sdp_session *sdp, const char *mid)
static int sdp_handler_list_hash(const void *obj, int flags)
static int sip_session_refresh(struct ast_sip_session *session, ast_sip_session_request_creation_cb on_request_creation, ast_sip_session_sdp_creation_cb on_sdp_creation, ast_sip_session_response_cb on_response, enum ast_sip_session_refresh_method method, int generate_new_sdp, struct ast_sip_session_media_state *pending_media_state, struct ast_sip_session_media_state *active_media_state, int queued)
static struct ao2_container * sdp_handlers
Registered SDP stream handlers.
struct ast_datastore * ast_sip_session_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
void ast_sip_session_end_if_deferred(struct ast_sip_session *session)
End the session if it had been previously deferred.
int ast_sip_session_create_invite(struct ast_sip_session *session, pjsip_tx_data **tdata)
Creates an INVITE request.
static struct ast_sip_session_media_state * internal_sip_session_media_state_alloc(size_t sessions, size_t read_callbacks)
int ast_sip_session_defer_termination(struct ast_sip_session *session)
Defer local termination of a session until remote side terminates, or an amount of time passes.
static struct ast_sip_session_media_state * resolve_refresh_media_states(const char *session_name, struct ast_sip_session_media_state *delayed_pending_state, struct ast_sip_session_media_state *delayed_active_state, struct ast_sip_session_media_state *current_active_state, int run_post_validation)
static void session_inv_on_tsx_state_changed(pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_event *e)
static int invite_proceeding(void *vsession)
static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)
static void session_inv_on_rx_offer(pjsip_inv_session *inv, const pjmedia_sdp_session *offer)
struct ast_sip_session_media * ast_sip_session_media_state_add(struct ast_sip_session *session, struct ast_sip_session_media_state *media_state, enum ast_media_type type, int position)
Allocate an ast_session_media and add it to the media state's vector.
static int check_request_status(pjsip_inv_session *inv, pjsip_event *e)
sip_get_destination_result
@ SIP_GET_DEST_EXTEN_FOUND
@ SIP_GET_DEST_EXTEN_PARTIAL
@ SIP_GET_DEST_UNSUPPORTED_URI
@ SIP_GET_DEST_EXTEN_NOT_FOUND
static void set_remote_mslabel_and_stream_group(struct ast_sip_session *session, struct ast_sip_session_media *session_media, const pjmedia_sdp_session *sdp, const struct pjmedia_sdp_media *stream, struct ast_stream *asterisk_stream)
struct ast_sip_channel_pvt * ast_sip_channel_pvt_alloc(void *pvt, struct ast_sip_session *session)
Allocate a new SIP channel pvt structure.
static void delayed_request_free(struct ast_sip_session_delayed_request *delay)
static void session_inv_on_new_session(pjsip_inv_session *inv, pjsip_event *e)
static void session_on_tsx_state(pjsip_transaction *tsx, pjsip_event *e)
static void remove_stream_from_bundle(struct ast_sip_session_media *session_media, struct ast_stream *stream)
static int load_module(void)
void ast_sip_session_unsuspend(struct ast_sip_session *session)
Request the session serializer be unsuspended.
void ast_sip_session_terminate(struct ast_sip_session *session, int response)
Terminate a session and, if possible, send the provided response code.
static int datastore_cmp(void *obj, void *arg, int flags)
static pjmedia_sdp_session * generate_session_refresh_sdp(struct ast_sip_session *session)
static int check_sdp_content_type_supported(pjsip_media_type *content_type)
static void handle_outgoing_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
static struct ast_sip_session_delayed_request * delayed_request_alloc(enum delayed_method method, ast_sip_session_request_creation_cb on_request_creation, ast_sip_session_sdp_creation_cb on_sdp_creation, ast_sip_session_response_cb on_response, int generate_new_sdp, struct ast_sip_session_media_state *pending_media_state, struct ast_sip_session_media_state *active_media_state)
static int update_completed(void *vsession)
static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata, enum ast_sip_session_response_priority response_priority)
static int unload_module(void)
static int session_end(void *vsession)
#define MOD_DATA_NAT_HOOK
static int fetch_callerid_num(struct ast_sip_session *session, pjsip_rx_data *rdata, char *buf, size_t len)
Fetch just the Caller ID number in order of PAI, RPID, From.
static int new_invite_initial_answer(pjsip_inv_session *inv_session, pjsip_rx_data *rdata, int answer_code, int terminate_code, pj_bool_t notify)
static int is_stream_limitation_reached(enum ast_media_type type, const struct ast_sip_endpoint *endpoint, int *type_streams)
static void session_datastore_destroy(void *obj)
void ast_sip_session_resume_reinvite(struct ast_sip_session *session)
Resumes processing of a deferred incoming re-invite.
static pj_bool_t has_supplement(const struct ast_sip_session *session, const pjsip_rx_data *rdata)
static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
void ast_sip_session_media_state_reset(struct ast_sip_session_media_state *media_state)
Reset a media state to a clean state.
static struct pjmedia_sdp_session * create_local_sdp(pjsip_inv_session *inv, struct ast_sip_session *session, const pjmedia_sdp_session *offer, const unsigned int ignore_active_stream_topology)
static pj_bool_t session_on_rx_response(pjsip_rx_data *rdata)
static void handle_outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata)
static void check_delayed_requests(struct ast_sip_session *session, int(*cb)(void *vsession))
int ast_sip_session_refresh(struct ast_sip_session *session, ast_sip_session_request_creation_cb on_request_creation, ast_sip_session_sdp_creation_cb on_sdp_creation, ast_sip_session_response_cb on_response, enum ast_sip_session_refresh_method method, int generate_new_sdp, struct ast_sip_session_media_state *media_state)
Send a reinvite or UPDATE on a session.
static int datastore_hash(const void *obj, int flags)
struct ast_sip_session * ast_sip_session_create_outgoing(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, const char *location, const char *request_user, struct ast_stream_topology *req_topology)
Create a new outgoing SIP session.
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.
static int handle_incoming(struct ast_sip_session *session, pjsip_rx_data *rdata, enum ast_sip_session_response_priority response_priority)
const char * ast_sip_session_get_name(const struct ast_sip_session *session)
Get the channel or endpoint name associated with the session.
void ast_sip_session_send_response(struct ast_sip_session *session, pjsip_tx_data *tdata)
Send a SIP response.
static void reschedule_reinvite(struct ast_sip_session *session, ast_sip_session_response_cb on_response)
static void resend_reinvite(pj_timer_heap_t *timer, pj_timer_entry *entry)
void ast_sip_session_suspend(struct ast_sip_session *session)
Request and wait for the session serializer to be suspended.
static void session_outgoing_nat_hook(pjsip_tx_data *tdata, struct ast_sip_transport *transport)
Hook for modifying outgoing messages with SDP to contain the proper address information.
void ast_sip_session_media_stats_save(struct ast_sip_session *sip_session, struct ast_sip_session_media_state *media_state)
Save a media stats.
static int stream_destroy(void *obj, void *arg, int flags)
#define GET_STREAM_STATE_SAFE(_stream)
static int session_end_if_disconnected(int id, pjsip_inv_session *inv)
int(* ast_sip_session_request_creation_cb)(struct ast_sip_session *session, pjsip_tx_data *tdata)
int(* ast_sip_session_sdp_creation_cb)(struct ast_sip_session *session, pjmedia_sdp_session *sdp)
void ast_sip_session_remove_supplements(struct ast_sip_session *session)
Remove supplements from a SIP session.
int ast_sip_session_add_supplements(struct ast_sip_session *session)
Add supplements to a SIP session.
ast_sip_session_response_priority
Describes when a supplement should be called into on incoming responses.
@ AST_SIP_SESSION_BEFORE_REDIRECTING
@ AST_SIP_SESSION_AFTER_MEDIA
@ AST_SIP_SESSION_BEFORE_MEDIA
int(* ast_sip_session_response_cb)(struct ast_sip_session *session, pjsip_rx_data *rdata)
struct ast_frame *(* ast_sip_session_media_read_cb)(struct ast_sip_session *session, struct ast_sip_session_media *session_media)
int(* ast_sip_session_media_write_cb)(struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_frame *frame)
@ AST_SIP_SESSION_OUTGOING_CALL
@ AST_SIP_SESSION_INCOMING_CALL
ast_sip_session_sdp_stream_defer
@ AST_SIP_SESSION_SDP_DEFER_NEEDED
@ AST_SIP_SESSION_SDP_DEFER_NOT_HANDLED
@ AST_SIP_SESSION_SDP_DEFER_NOT_NEEDED
@ AST_SIP_SESSION_SDP_DEFER_ERROR
struct ast_stream * ast_sip_session_create_joint_call_stream(const struct ast_sip_session *session, struct ast_stream *remote)
Create a new stream of joint capabilities.
@ AST_RTP_INSTANCE_STAT_ALL
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.
SRTP and SDP Security descriptions.
void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp)
free a ast_sdp_srtp structure
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
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.
struct ast_stream * ast_stream_alloc(const char *name, enum ast_media_type type)
Create a new media stream representation.
int ast_stream_topology_set_stream(struct ast_stream_topology *topology, unsigned int position, struct ast_stream *stream)
Set a specific position in a topology.
const char * ast_stream_get_metadata(const struct ast_stream *stream, const char *m_key)
Get a stream metadata value.
const char * ast_stream_get_name(const struct ast_stream *stream)
Get the name of a stream.
int ast_stream_set_metadata(struct ast_stream *stream, const char *m_key, const char *value)
Set a stream metadata value.
ast_stream_state
States that a stream may be in.
@ AST_STREAM_STATE_RECVONLY
Set when the stream is receiving media only.
@ AST_STREAM_STATE_END
Sentinel.
@ 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_SENDRECV
Set when the stream is sending and receiving media.
@ AST_STREAM_STATE_SENDONLY
Set when the stream is sending media only.
const char * ast_stream_state2str(enum ast_stream_state state)
Convert the state of a stream into a string.
void ast_stream_set_state(struct ast_stream *stream, enum ast_stream_state state)
Set the state of a stream.
int ast_stream_topology_append_stream(struct ast_stream_topology *topology, struct ast_stream *stream)
Append a stream to the topology.
const char * ast_stream_topology_to_str(const struct ast_stream_topology *topology, struct ast_str **buf)
Get a string representing the topology for debugging/display purposes.
struct ast_stream * ast_stream_clone(const struct ast_stream *stream, const char *name)
Create a deep clone of an existing stream.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
int ast_stream_get_format_count(const struct ast_stream *stream)
Get the count of the current negotiated formats 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_topology_del_stream(struct ast_stream_topology *topology, unsigned int position)
Delete a specified stream from the given topology.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
void ast_stream_free(struct ast_stream *stream)
Destroy a media stream representation.
void ast_stream_set_group(struct ast_stream *stream, int group)
Set the stream group for 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_stream_topology_equal(const struct ast_stream_topology *left, const struct ast_stream_topology *right)
Compare two stream topologies to see if they are equal.
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
int ast_strings_equal(const char *str1, const char *str2)
Compare strings for equality checking for NULL.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
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_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.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Structure for a data store type.
void(* destroy)(void *data)
Structure for a data store object.
const struct ast_datastore_info * info
Configuration relating to call pickup.
const ast_string_field pickupexten
Data structure associated with a single frame of data.
Information needed to identify an endpoint in a call.
struct ast_party_number number
Subscriber phone number.
unsigned char valid
TRUE if the number information is valid/present.
char * str
Subscriber phone number (Malloced)
A structure which contains a channel implementation and session.
struct ast_sip_session * session
Pointer to session.
void * pvt
Pointer to channel specific implementation information, must be ao2 object.
struct ast_sip_timer_options timer
An entity with which Asterisk communicates.
struct ast_sip_endpoint_id_configuration id
const ast_string_field aors
unsigned int moh_passthrough
unsigned int preferred_codec_only
struct ast_sip_endpoint_extensions extensions
const ast_string_field context
struct ast_sip_endpoint_media_configuration media
enum ast_sip_dtmf_mode dtmf
enum ast_sip_100rel_mode rel100
Structure for SIP nat hook information.
void(* outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport)
Structure used for sending delayed requests.
struct ast_sip_session_delayed_request * next
ast_sip_session_sdp_creation_cb on_sdp_creation
struct ast_sip_session_media_state * active_media_state
struct ast_sip_session_media_state * pending_media_state
ast_sip_session_request_creation_cb on_request_creation
enum delayed_method method
ast_sip_session_response_cb on_response
A handler for SDPs in SIP sessions.
void(* stream_destroy)(struct ast_sip_session_media *session_media)
Destroy a session_media created by this handler.
struct ast_sip_session_sdp_handler * next
void(* stream_stop)(struct ast_sip_session_media *session_media)
Stop a session_media created by this handler but do not destroy resources.
A supplement to SIP message processing.
void(* session_begin)(struct ast_sip_session *session)
Notification that the session has begun This method will always be called from a SIP servant thread.
void(* incoming_response)(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
Called on an incoming SIP response This method is always called from a SIP servant thread.
void(* session_destroy)(struct ast_sip_session *session)
Notification that the session is being destroyed.
void(* session_end)(struct ast_sip_session *session)
Notification that the session has ended.
int(* incoming_request)(struct ast_sip_session *session, struct pjsip_rx_data *rdata)
Called on incoming SIP request This method can indicate a failure in processing in its return....
struct ast_sip_session_supplement * next
enum ast_sip_session_response_priority response_priority
void(* outgoing_response)(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
Called on an outgoing SIP response This method is always called from a SIP servant thread.
void(* outgoing_request)(struct ast_sip_session *session, struct pjsip_tx_data *tdata)
Called on an outgoing SIP request This method is always called from a SIP servant thread.
struct controlling the suspension of the session's serializer.
ast_cond_t cond_suspended
A structure describing a SIP session.
struct ast_sip_contact * contact
struct ast_sip_endpoint * endpoint
char exten[AST_MAX_EXTENSION]
struct ast_sip_session_media_state * active_media_state
struct ast_sip_session_media_state * pending_media_state
struct pjsip_inv_session * inv_session
struct ast_sip_session::@267 media_stats
unsigned int sess_expires
Structure for SIP transport information.
const ast_string_field external_media_address
Socket address structure.
Support for dynamic strings.
unsigned int position
The position of the stream in the topology.
pjsip_rx_data * rdata
INVITE request itself.
struct ast_sip_session * session
Session created for the new INVITE.
struct sdp_handler_list::@465 list
An API for managing task processing threads that can be shared across modules.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
int ast_taskprocessor_is_suspended(struct ast_taskprocessor *tps)
Get the task processor suspend status.
int ast_taskprocessor_is_task(struct ast_taskprocessor *tps)
Am I the given taskprocessor's current task.
int ast_taskprocessor_unsuspend(struct ast_taskprocessor *tps)
Indicate the taskprocessor is unsuspended.
void ast_taskprocessor_build_name(char *buf, unsigned int size, const char *format,...)
Build a taskprocessor name with a sequence number on the end.
#define AST_TASKPROCESSOR_MAX_NAME
Suggested maximum taskprocessor name length (less null terminator).
int ast_taskprocessor_suspend(struct ast_taskprocessor *tps)
Indicate the taskprocessor is suspended.
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
#define ast_test_suite_event_notify(s, f,...)
#define AST_TEST_DEFINE(hdr)
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
long int ast_random(void)
Universally unique identifier support.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
Vector container support.
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
#define AST_VECTOR_ELEM_CLEANUP_NOOP(elem)
Vector element cleanup that does nothing.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
#define AST_VECTOR_REMOVE_CMP_UNORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison.
#define AST_VECTOR_REMOVE(vec, idx, preserve_ordered)
Remove an element from a vector by index.
#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_GET(vec, idx)
Get an element from a vector.
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.