Asterisk - The Open Source Telephony Project GIT-master-0644429
|
#include <pjlib.h>
#include "asterisk/linkedlists.h"
#include "asterisk/channel.h"
#include "asterisk/netsock2.h"
#include "asterisk/sdp_srtp.h"
#include "asterisk/codec.h"
#include <pjsip_ua.h>
#include "asterisk/res_pjsip.h"
Go to the source code of this file.
Data Structures | |
struct | ast_sip_channel_pvt |
A structure which contains a channel implementation and session. More... | |
struct | ast_sip_session |
A structure describing a SIP session. More... | |
struct | ast_sip_session_media |
A structure containing SIP session media information. More... | |
struct | ast_sip_session_media_read_callback_state |
Structure which contains read callback information. More... | |
struct | ast_sip_session_media_state |
Structure which contains media state information (streams, sessions) More... | |
struct | ast_sip_session_sdp_handler |
A handler for SDPs in SIP sessions. More... | |
struct | ast_sip_session_supplement |
A supplement to SIP message processing. More... | |
Macros | |
#define | ast_sip_session_register_supplement(supplement) ast_sip_session_register_supplement_with_module(AST_MODULE_SELF, supplement) |
Typedefs | |
typedef struct ast_frame *(* | ast_sip_session_media_read_cb) (struct ast_sip_session *session, struct ast_sip_session_media *session_media) |
typedef int(* | ast_sip_session_media_write_cb) (struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_frame *frame) |
typedef int(* | ast_sip_session_request_creation_cb) (struct ast_sip_session *session, pjsip_tx_data *tdata) |
typedef int(* | ast_sip_session_response_cb) (struct ast_sip_session *session, pjsip_rx_data *rdata) |
typedef int(* | ast_sip_session_sdp_creation_cb) (struct ast_sip_session *session, pjmedia_sdp_session *sdp) |
Enumerations | |
enum | ast_sip_session_call_direction { AST_SIP_SESSION_INCOMING_CALL = 0 , AST_SIP_SESSION_OUTGOING_CALL } |
Indicates the call direction respective to Asterisk. More... | |
enum | ast_sip_session_response_priority { AST_SIP_SESSION_BEFORE_REDIRECTING = (1 << 0) , AST_SIP_SESSION_BEFORE_MEDIA = (1 << 1) , AST_SIP_SESSION_AFTER_MEDIA = (1 << 2) } |
Describes when a supplement should be called into on incoming responses. More... | |
enum | ast_sip_session_sdp_stream_defer { AST_SIP_SESSION_SDP_DEFER_NOT_HANDLED , AST_SIP_SESSION_SDP_DEFER_ERROR , AST_SIP_SESSION_SDP_DEFER_NOT_NEEDED , AST_SIP_SESSION_SDP_DEFER_NEEDED } |
enum | ast_sip_session_t38state { T38_DISABLED = 0 , T38_LOCAL_REINVITE , T38_PEER_REINVITE , T38_ENABLED , T38_REJECTED , T38_MAX_ENUM } |
T.38 states for a session. More... | |
Functions | |
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. More... | |
struct ast_sip_channel_pvt * | ast_sip_channel_pvt_alloc (void *pvt, struct ast_sip_session *session) |
Allocate a new SIP channel pvt structure. More... | |
struct ast_sip_session * | ast_sip_dialog_get_session (pjsip_dialog *dlg) |
Retrieves a session from a dialog. More... | |
int | ast_sip_session_add_datastore (struct ast_sip_session *session, struct ast_datastore *datastore) |
Add a datastore to a SIP session. More... | |
int | ast_sip_session_add_reason_header (struct ast_sip_session *session, const char *protocol, int code, const char *text) |
Adds a Reason header in the next reponse to an incoming INVITE. More... | |
int | ast_sip_session_add_supplements (struct ast_sip_session *session) |
Add supplements to a SIP session. More... | |
struct ast_sip_session * | ast_sip_session_alloc (struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, pjsip_inv_session *inv, pjsip_rx_data *rdata) |
Allocate a new SIP session. More... | |
struct ast_datastore * | ast_sip_session_alloc_datastore (const struct ast_datastore_info *info, const char *uid) |
Alternative for ast_datastore_alloc() More... | |
int | ast_sip_session_create_invite (struct ast_sip_session *session, pjsip_tx_data **tdata) |
Creates an INVITE request. More... | |
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. More... | |
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. More... | |
void | ast_sip_session_defer_termination_cancel (struct ast_sip_session *session) |
Cancel a pending deferred termination. More... | |
void | ast_sip_session_end_if_deferred (struct ast_sip_session *session) |
End the session if it had been previously deferred. More... | |
struct ast_datastore * | ast_sip_session_get_datastore (struct ast_sip_session *session, const char *name) |
Retrieve a session datastore. More... | |
pjsip_dialog * | ast_sip_session_get_dialog (const struct ast_sip_session *session) |
Retrieves a dialog from a session. More... | |
const char * | ast_sip_session_get_name (const struct ast_sip_session *session) |
Get the channel or endpoint name associated with the session. More... | |
pjsip_inv_state | ast_sip_session_get_pjsip_inv_state (const struct ast_sip_session *session) |
Retrieves the pjsip_inv_state from a session. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
struct ast_sip_session_media_state * | ast_sip_session_media_state_alloc (void) |
Allocate a session media state structure. More... | |
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. More... | |
void | ast_sip_session_media_state_free (struct ast_sip_session_media_state *media_state) |
Free a session media state structure. More... | |
void | ast_sip_session_media_state_reset (struct ast_sip_session_media_state *media_state) |
Reset a media state to a clean state. More... | |
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. More... | |
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. More... | |
int | ast_sip_session_regenerate_answer (struct ast_sip_session *session, ast_sip_session_sdp_creation_cb on_sdp_creation) |
Regenerate SDP Answer. More... | |
int | ast_sip_session_register_sdp_handler (struct ast_sip_session_sdp_handler *handler, const char *stream_type) |
Register an SDP handler. More... | |
void | ast_sip_session_register_supplement_with_module (struct ast_module *module, struct ast_sip_session_supplement *supplement) |
Register a supplement to SIP session processing. More... | |
void | ast_sip_session_remove_datastore (struct ast_sip_session *session, const char *name) |
Remove a session datastore from the session. More... | |
void | ast_sip_session_remove_supplements (struct ast_sip_session *session) |
Remove supplements from a SIP session. More... | |
void | ast_sip_session_resume_reinvite (struct ast_sip_session *session) |
Resumes processing of a deferred incoming re-invite. More... | |
void | ast_sip_session_send_request (struct ast_sip_session *session, pjsip_tx_data *tdata) |
Send a SIP request. More... | |
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. More... | |
void | ast_sip_session_send_response (struct ast_sip_session *session, pjsip_tx_data *tdata) |
Send a SIP response. More... | |
void | ast_sip_session_suspend (struct ast_sip_session *session) |
Request and wait for the session serializer to be suspended. More... | |
void | ast_sip_session_terminate (struct ast_sip_session *session, int response) |
Terminate a session and, if possible, send the provided response code. More... | |
void | ast_sip_session_unregister_sdp_handler (struct ast_sip_session_sdp_handler *handler, const char *stream_type) |
Unregister an SDP handler. More... | |
void | ast_sip_session_unregister_supplement (struct ast_sip_session_supplement *supplement) |
Unregister a an supplement to SIP session processing. More... | |
void | ast_sip_session_unsuspend (struct ast_sip_session *session) |
Request the session serializer be unsuspended. More... | |
#define ast_sip_session_register_supplement | ( | supplement | ) | ast_sip_session_register_supplement_with_module(AST_MODULE_SELF, supplement) |
Definition at line 616 of file res_pjsip_session.h.
typedef struct ast_frame *(* ast_sip_session_media_read_cb) (struct ast_sip_session *session, struct ast_sip_session_media *session_media) |
Definition at line 1 of file res_pjsip_session.h.
typedef int(* ast_sip_session_media_write_cb) (struct ast_sip_session *session, struct ast_sip_session_media *session_media, struct ast_frame *frame) |
Definition at line 71 of file res_pjsip_session.h.
typedef int(* ast_sip_session_request_creation_cb) (struct ast_sip_session *session, pjsip_tx_data *tdata) |
Definition at line 250 of file res_pjsip_session.h.
typedef int(* ast_sip_session_response_cb) (struct ast_sip_session *session, pjsip_rx_data *rdata) |
Definition at line 251 of file res_pjsip_session.h.
typedef int(* ast_sip_session_sdp_creation_cb) (struct ast_sip_session *session, pjmedia_sdp_session *sdp) |
Definition at line 252 of file res_pjsip_session.h.
Indicates the call direction respective to Asterisk.
Enumerator | |
---|---|
AST_SIP_SESSION_INCOMING_CALL | |
AST_SIP_SESSION_OUTGOING_CALL |
Definition at line 168 of file res_pjsip_session.h.
Describes when a supplement should be called into on incoming responses.
In most cases, session supplements will not need to worry about this because in most cases, the correct value will be automatically applied. However, there are rare circumstances when a supplement will want to specify when it should be called.
The values below are listed in chronological order.
Definition at line 263 of file res_pjsip_session.h.
Definition at line 367 of file res_pjsip_session.h.
T.38 states for a session.
Definition at line 56 of file res_pjsip_session.h.
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.
session | The session |
id | The Connected Line info to evaluate |
1 | The Connected Line info can be presented |
0 | The Connected Line info cannot be presented |
Definition at line 131 of file res_pjsip_session.c.
References ast_party_id_presentation(), AST_PRES_ALLOWED, AST_PRES_RESTRICTION, and session.
Referenced by add_id_headers(), and stir_shaken_outgoing_request().
struct ast_sip_channel_pvt * ast_sip_channel_pvt_alloc | ( | void * | pvt, |
struct ast_sip_session * | session | ||
) |
Allocate a new SIP channel pvt structure.
pvt | Pointer to channel specific information |
session | Pointer to SIP session |
non-NULL | success |
NULL | failure |
Definition at line 2994 of file res_pjsip_session.c.
References ao2_alloc, ao2_ref, NULL, ast_sip_channel_pvt::pvt, ast_sip_channel_pvt::session, session, and sip_channel_destroy().
Referenced by chan_pjsip_new().
struct ast_sip_session * ast_sip_dialog_get_session | ( | pjsip_dialog * | dlg | ) |
Retrieves a session from a dialog.
dlg | The dialog to retrieve the session from |
non-NULL | if session exists |
NULL | if no session |
Definition at line 3648 of file res_pjsip_session.c.
References ao2_ref, ast_sip_session::inv_session, NULL, session, and session_module.
Referenced by assign_uuid(), ast_sip_session_send_response(), refer_incoming_attended_request(), refer_incoming_invite_request(), session_on_tx_response(), session_outgoing_nat_hook(), and session_reinvite_on_rx_request().
int ast_sip_session_add_datastore | ( | struct ast_sip_session * | session, |
struct ast_datastore * | datastore | ||
) |
Add a datastore to a SIP session.
Note that SIP uses reference counted datastores. The datastore passed into this function must have been allocated using ao2_alloc() or there will be serious problems.
session | The session to add the datastore to |
datastore | The datastore to be added to the session |
0 | Success |
-1 | Failure |
Definition at line 1284 of file res_pjsip_session.c.
References ao2_link, ast_assert, ast_strlen_zero(), ast_datastore::info, NULL, session, and ast_datastore::uid.
Referenced by add_header(), aoc_send_as_xml(), ast_sip_session_add_reason_header(), chan_pjsip_incoming_request(), chan_pjsip_session_begin(), handle_incoming_request(), incoming_request(), incoming_response(), rfc3329_incoming_response(), session_refresh_state_get_or_alloc(), and t38_state_get_or_alloc().
int ast_sip_session_add_reason_header | ( | struct ast_sip_session * | session, |
const char * | protocol, | ||
int | code, | ||
const char * | text | ||
) |
Adds a Reason header in the next reponse to an incoming INVITE.
session | The session |
protocol | Usually "SIP" but may be "STIR" for stir-shaken |
code | SIP response code |
text | Reason string |
0 | the header is accepted |
-1 | the header is rejected |
Definition at line 123 of file pjsip_session_reason_header.c.
References ao2_cleanup, ast_calloc, ast_sip_session_add_datastore(), ast_sip_session_alloc_datastore(), ast_sip_session_get_name(), ast_strdup, ast_strlen_zero(), NULL, return_reason_data::protocol, RAII_VAR, return_reason_data::response_code, return_reason_data::response_str, return_reason_info, S_OR, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, session, text, and ast_datastore_info::type.
Referenced by process_failure().
int ast_sip_session_add_supplements | ( | struct ast_sip_session * | session | ) |
Add supplements to a SIP session.
session | The session to initialize |
Definition at line 90 of file pjsip_session.c.
References AST_LIST_INSERT_TAIL, ast_module_ref, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, copy(), lock, ast_sip_session_supplement::next, SCOPED_LOCK, session, and supplement_dup().
Referenced by ast_sip_session_alloc().
struct ast_sip_session * ast_sip_session_alloc | ( | struct ast_sip_endpoint * | endpoint, |
struct ast_sip_contact * | contact, | ||
pjsip_inv_session * | inv, | ||
pjsip_rx_data * | rdata | ||
) |
Allocate a new SIP session.
This will take care of allocating the datastores container on the session as well as placing all registered supplements onto the session.
The endpoint that is passed in will have its reference count increased by one since the session will be keeping a reference to the endpoint. The session will relinquish this reference when the session is destroyed.
endpoint | The endpoint that this session communicates with |
contact | The contact associated with this session |
inv | The PJSIP INVITE session data |
rdata | INVITE request received (NULL if for outgoing allocation) |
Definition at line 3010 of file res_pjsip_session.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_bump, ao2_cleanup, ao2_container_alloc_hash, ao2_ref, ast_dsp_new(), ast_dsp_set_features(), ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, AST_LIST_HEAD_INIT, AST_LIST_HEAD_INIT_NOLOCK, ast_log, ast_party_id_init(), ast_sip_create_serializer(), ast_sip_dialog_set_endpoint(), ast_sip_dialog_set_serializer(), AST_SIP_DTMF_AUTO, AST_SIP_DTMF_INBAND, ast_sip_get_distributor_serializer(), ast_sip_session_add_supplements(), ast_sip_session_media_state_alloc(), ast_sorcery_object_get_id(), ast_taskprocessor_build_name(), AST_TASKPROCESSOR_MAX_NAME, AST_VECTOR_INIT, ast_sip_session::contact, DATASTORE_BUCKETS, datastore_cmp(), datastore_hash(), DSP_FEATURE_DIGIT_DETECT, DSP_FEATURE_FAX_DETECT, ast_sip_endpoint::dtmf, ast_sip_session::endpoint, ast_sip_endpoint::faxdetect, handle_session_begin(), ast_sip_session::inv_session, LOG_ERROR, ast_sip_endpoint::moh_passthrough, NULL, RAII_VAR, session, session_destructor(), and session_module.
Referenced by ast_sip_session_create_outgoing(), and handle_new_invite_request().
struct ast_datastore * ast_sip_session_alloc_datastore | ( | const struct ast_datastore_info * | info, |
const char * | uid | ||
) |
Alternative for ast_datastore_alloc()
There are two major differences between this and ast_datastore_alloc() 1) This allocates a refcounted object 2) This will fill in a uid if one is not provided
DO NOT call ast_datastore_free() on a datastore allocated in this way since that function will attempt to free the datastore rather than play nicely with its refcount.
info | Callbacks for datastore |
uid | Identifier for datastore |
NULL | Failed to allocate datastore |
non-NULL | Newly allocated datastore |
Definition at line 1254 of file res_pjsip_session.c.
References ao2_alloc, ao2_cleanup, ao2_ref, ast_strdup, ast_strlen_zero(), ast_uuid_generate_str(), AST_UUID_STR_LEN, sip_to_pjsip::info(), NULL, RAII_VAR, session_datastore_destroy(), and ast_datastore::uid.
Referenced by add_header(), aoc_send_as_xml(), ast_sip_session_add_reason_header(), chan_pjsip_incoming_request(), chan_pjsip_session_begin(), handle_incoming_request(), incoming_request(), incoming_response(), rfc3329_incoming_response(), session_refresh_state_get_or_alloc(), and t38_state_get_or_alloc().
int ast_sip_session_create_invite | ( | struct ast_sip_session * | session, |
pjsip_tx_data ** | tdata | ||
) |
Creates an INVITE request.
session | Starting session for the INVITE |
tdata | The created request. |
Definition at line 2867 of file res_pjsip_session.c.
References ast_sip_session_get_name(), create_local_sdp(), NULL, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, session, and set_from_header().
Referenced by call().
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.
The endpoint that is passed in will have its reference count increased by one since the session will be keeping a reference to the endpoint. The session will relinquish this reference when the session is destroyed.
endpoint | The endpoint that this session uses for settings |
contact | The contact that this session will communicate with |
location | Name of the location to call, be it named location or explicit URI. Overrides contact if present. |
request_user | Optional request user to place in the request URI if permitted |
req_topology | The requested capabilities |
Definition at line 3337 of file res_pjsip_session.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_sip_endpoint::aors, ast_log, ast_party_id_copy(), AST_SIP_CONTACT_FILTER_REACHABLE, ast_sip_create_dialog_uac(), ast_sip_location_retrieve_contact_and_aor_from_list_filtered(), ast_sip_session_alloc(), ast_sip_session_create_joint_call_stream(), AST_SIP_SESSION_OUTGOING_CALL, ast_sorcery_object_get_id(), ast_str_tmp, ast_stream_free(), ast_stream_get_format_count(), ast_stream_get_state(), AST_STREAM_STATE_REMOVED, ast_stream_topology_alloc(), ast_stream_topology_append_stream(), ast_stream_topology_clone(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_stream_topology_to_str(), ast_strlen_zero(), ast_sip_session::contact, ast_sip_session::endpoint, ast_sip_endpoint::extensions, ast_sip_endpoint_extensions::flags, ast_sip_endpoint::id, ast_sip_session::inv_session, LOG_ERROR, ast_sip_endpoint::media, ast_sip_timer_options::min_se, NULL, RAII_VAR, S_OR, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, ast_sip_endpoint_id_configuration::self, ast_sip_timer_options::sess_expires, session, session_module, setup_outbound_invite_auth(), timer, ast_sip_endpoint_extensions::timer, ast_sip_endpoint_media_configuration::topology, and ast_sip_contact::uri.
Referenced by request().
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.
session | The session to defer termination on |
0 | Success |
-1 | Failure |
Definition at line 3574 of file res_pjsip_session.c.
References ao2_ref, ast_assert, ast_sip_get_pjsip_endpoint(), session, and session_termination_cb().
Referenced by refer_incoming_attended_request(), and refer_incoming_blind_request().
void ast_sip_session_defer_termination_cancel | ( | struct ast_sip_session * | session | ) |
Cancel a pending deferred termination.
session | The session to cancel a deferred termination on. |
Definition at line 3614 of file res_pjsip_session.c.
References ast_sip_session_terminate(), session, and sip_session_defer_termination_stop_timer().
Referenced by defer_termination_cancel_task(), refer_incoming_attended_request(), and refer_incoming_blind_request().
void ast_sip_session_end_if_deferred | ( | struct ast_sip_session * | session | ) |
End the session if it had been previously deferred.
session | The session to end if it had been deferred |
Definition at line 3632 of file res_pjsip_session.c.
References ast_debug, ast_sip_session_get_name(), session, and session_end().
Referenced by defer_termination_cancel_task(), refer_attended_task(), refer_incoming_attended_request(), refer_incoming_blind_request(), and session_end_if_deferred_task().
struct ast_datastore * ast_sip_session_get_datastore | ( | struct ast_sip_session * | session, |
const char * | name | ||
) |
Retrieve a session datastore.
The datastore retrieved will have its reference count incremented. When the caller is done with the datastore, the reference counted needs to be decremented using ao2_ref().
session | The session from which to retrieve the datastore |
name | The name of the datastore to retrieve |
NULL | Failed to find the specified datastore |
non-NULL | The specified datastore |
Definition at line 1296 of file res_pjsip_session.c.
References ao2_find, name, OBJ_KEY, and session.
Referenced by add_header(), aoc_bye_outgoing_request(), aoc_bye_outgoing_response(), aoc_invite_outgoing_response(), aoc_send_as_xml(), chan_pjsip_get_rtp_peer(), channel_read_pjsip(), direct_media_mitigate_glare(), handle_outgoing_response(), incoming_request(), incoming_response(), outgoing_request(), read_header(), read_headers(), reason_header_outgoing_response(), remove_header(), rfc3329_incoming_response(), rfc3329_outgoing_request(), session_refresh_state_get_or_alloc(), t38_automatic_reject(), t38_state_get_or_alloc(), and update_header().
pjsip_dialog * ast_sip_session_get_dialog | ( | const struct ast_sip_session * | session | ) |
Retrieves a dialog from a session.
session | The session to retrieve the dialog from |
non-NULL | if dialog exists |
NULL | if no dialog |
Definition at line 3663 of file res_pjsip_session.c.
References ast_sip_session::inv_session, NULL, and session.
const char * ast_sip_session_get_name | ( | const struct ast_sip_session * | session | ) |
Get the channel or endpoint name associated with the session.
session |
Channel | name or endpoint name or "unknown" |
Definition at line 117 of file res_pjsip_session.c.
References ast_channel_name(), ast_sorcery_object_get_id(), and session.
Referenced by add_date_header(), add_eprofile_to_channel(), add_fingerprints_if_present(), add_sdp_streams(), answer(), apply_negotiated_sdp_stream(), ast_sip_session_add_reason_header(), ast_sip_session_create_invite(), ast_sip_session_end_if_deferred(), ast_sip_session_media_state_add(), ast_sip_session_regenerate_answer(), ast_sip_session_terminate(), call(), chan_pjsip_call(), chan_pjsip_incoming_ack(), chan_pjsip_incoming_prack(), chan_pjsip_incoming_request(), chan_pjsip_incoming_response(), chan_pjsip_incoming_response_update_cause(), chan_pjsip_new(), chan_pjsip_session_begin(), chan_pjsip_session_end(), create_local_sdp(), create_outgoing_sdp_stream(), delay_request(), generate_session_refresh_sdp(), get_codecs(), get_destination(), handle_incoming_before_media(), handle_incoming_request(), handle_incoming_response(), handle_incoming_sdp(), handle_negotiated_sdp(), handle_negotiated_sdp_session_media(), handle_new_invite_request(), handle_outgoing_request(), handle_outgoing_response(), invite_collision_timeout(), invite_proceeding(), invite_terminated(), negotiate_incoming_sdp_stream(), new_invite(), on_topology_change_response(), outbound_invite_auth(), pbx_start_incoming_request(), process_failure(), reason_header_outgoing_response(), reschedule_reinvite(), resend_reinvite(), sdp_requires_deferral(), send_delayed_request(), send_topology_change_refresh(), session_destructor(), session_inv_on_create_offer(), session_inv_on_media_update(), session_inv_on_rx_offer(), session_inv_on_state_changed(), session_inv_on_tsx_state_changed(), session_on_rx_request(), session_on_rx_response(), session_on_tsx_state(), session_outgoing_nat_hook(), set_caps(), set_from_header(), set_incoming_call_offer_cap(), sip_session_refresh(), stir_shaken_incoming_request(), and stir_shaken_outgoing_request().
pjsip_inv_state ast_sip_session_get_pjsip_inv_state | ( | const struct ast_sip_session * | session | ) |
Retrieves the pjsip_inv_state from a session.
session | The session to retrieve the state from |
state | if inv_session exists |
PJSIP_INV_STATE_NULL | if inv_session is NULL |
Definition at line 3674 of file res_pjsip_session.c.
References ast_sip_session::inv_session, and session.
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.
session | The session to check against |
stream | The pending stream |
1 | if stream will be default |
0 | if stream will NOT be the default |
Definition at line 368 of file res_pjsip_session.c.
References ast_channel_name(), ast_log, ast_stream_get_state(), ast_stream_get_type(), AST_STREAM_STATE_REMOVED, ast_stream_topology_get_count(), ast_stream_topology_get_stream(), LOG_WARNING, and session.
Referenced by create_outgoing_sdp_stream(), handle_incoming_sdp(), handle_negotiated_sdp_session_media(), sdp_requires_deferral(), set_caps(), and set_session_media_remotely_held().
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.
session | The session |
session_media | The media session |
fd | The file descriptor |
callback | The read callback |
0 | the read callback was successfully added |
-1 | the read callback could not be added |
Definition at line 394 of file res_pjsip_session.c.
References AST_VECTOR_APPEND, ast_sip_session_media_read_callback_state::fd, and session.
Referenced by apply_negotiated_sdp_stream().
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.
session | The session |
session_media | The media session to retrieve the transport for |
Definition at line 423 of file res_pjsip_session.c.
References ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_session_media::bundle_group, ast_sip_session_media::mid, and session.
Referenced by apply_negotiated_sdp_stream(), create_outgoing_sdp_stream(), and negotiate_incoming_sdp_stream().
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.
session | The session |
session_media | The media session |
callback | The write callback |
0 | the write callback was successfully add |
-1 | the write callback is already set to something different |
Definition at line 407 of file res_pjsip_session.c.
References ast_sip_session_media::write_callback.
Referenced by apply_negotiated_sdp_stream().
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.
This allocates a session media of the specified type. The position argument determines where in the vector that the new session media will be inserted.
session | Session on which to query active media state for |
media_state | Media state to place the session media into |
type | The type of the session media |
position | Position at which to insert the new session media. |
non-NULL | success |
NULL | failure |
Definition at line 499 of file res_pjsip_session.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_cleanup, ao2_ref, ast_asprintf, ast_codec_media_type2str(), ast_free, ast_sip_session_get_name(), ast_strdup, ast_stream_get_name(), ast_stream_get_state(), AST_STREAM_STATE_REMOVED, ast_stream_topology_get_stream(), ast_trace, AST_VECTOR_GET, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, ast_sip_session_media::bundle_group, ast_sip_session_media::bundled, ast_sip_session_media_state::default_session, ast_sip_session_media::encryption, ast_sip_session_media::keepalive_sched_id, ast_sip_session_media::mid, NULL, ast_sip_session_media::remote_ice, ast_sip_session_media::remote_rtcp_mux, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, session, session_media_dtor(), ast_sip_session_media_state::sessions, ast_sip_session_media::stream_name, ast_sip_session_media::stream_num, ast_sip_session_media::timeout_sched_id, ast_sip_session_media_state::topology, type, and ast_sip_session_media::type.
Referenced by create_local_sdp(), handle_incoming_sdp(), sdp_requires_deferral(), and t38_create_media_state().
struct ast_sip_session_media_state * ast_sip_session_media_state_alloc | ( | void | ) |
Allocate a session media state structure.
non-NULL | success |
NULL | failure |
Definition at line 247 of file res_pjsip_session.c.
References DEFAULT_NUM_SESSION_MEDIA, and internal_sip_session_media_state_alloc().
Referenced by ast_sip_session_alloc(), session_refresh_state_get_or_alloc(), t38_create_media_state(), and topology_change_refresh_data_alloc().
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.
media_state | The media state to clone |
non-NULL | success |
NULL | failure |
Definition at line 306 of file res_pjsip_session.c.
References ao2_bump, ao2_cleanup, ast_sip_session_media_state_free(), ast_stream_get_state(), ast_stream_get_type(), AST_STREAM_STATE_REMOVED, ast_stream_topology_clone(), ast_stream_topology_get_stream(), AST_VECTOR_GET, AST_VECTOR_GET_ADDR, AST_VECTOR_REPLACE, AST_VECTOR_SIZE, ast_sip_session_media_state::default_session, internal_sip_session_media_state_alloc(), NULL, ast_sip_session_media_read_callback_state::read_callback, ast_sip_session_media_state::read_callbacks, ast_sip_session_media_state::sessions, ast_sip_session_media_state::topology, and type.
Referenced by handle_negotiated_sdp(), reschedule_reinvite(), resolve_refresh_media_states(), sip_session_refresh(), and t38_reinvite_sdp_cb().
void ast_sip_session_media_state_free | ( | struct ast_sip_session_media_state * | media_state | ) |
Free a session media state structure.
Definition at line 353 of file res_pjsip_session.c.
References ast_free, ast_sip_session_media_state_reset(), AST_VECTOR_FREE, ast_sip_session_media_state::read_callbacks, and ast_sip_session_media_state::sessions.
Referenced by ast_sip_session_media_state_clone(), delay_request(), delayed_request_free(), handle_negotiated_sdp(), reschedule_reinvite(), resolve_refresh_media_states(), session_destructor(), session_refresh_state_destroy(), sip_session_refresh(), t38_create_media_state(), t38_reinvite_response_cb(), t38_state_destroy(), and topology_change_refresh_data_free().
void ast_sip_session_media_state_reset | ( | struct ast_sip_session_media_state * | media_state | ) |
Reset a media state to a clean state.
media_state | The media state to reset |
Definition at line 287 of file res_pjsip_session.c.
References ao2_cleanup, AST_MEDIA_TYPE_END, ast_stream_topology_free(), AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_RESET, ast_sip_session_media_state::default_session, NULL, ast_sip_session_media_state::read_callbacks, ast_sip_session_media_state::sessions, and ast_sip_session_media_state::topology.
Referenced by ast_sip_session_media_state_free(), ast_sip_session_terminate(), handle_negotiated_sdp(), on_topology_change_response(), session_inv_on_media_update(), session_inv_on_rx_offer(), session_reinvite_on_rx_request(), sip_session_refresh(), and t38_reinvite_response_cb().
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.
sip_session | Session on which to save active media state for |
media_state | The media state to save |
Definition at line 253 of file res_pjsip_session.c.
References ast_calloc, ast_free, ast_rtp_instance_get_stats(), AST_RTP_INSTANCE_STAT_ALL, AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_REMOVE_CMP_UNORDERED, AST_VECTOR_SIZE, ast_sip_session::media_stats, media_stats_local_ssrc_cmp(), NULL, ast_sip_session_media::rtp, and ast_sip_session_media_state::sessions.
Referenced by ast_sip_session_terminate(), and handle_negotiated_sdp().
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.
This method will inspect the session in order to construct an appropriate session refresh request. As with any outgoing request in res_pjsip_session, this will call into registered supplements in case they wish to add anything.
Note: The on_request_creation callback may or may not be called in the same thread where this function is called. Request creation may need to be delayed due to the current INVITE transaction state.
session | The session on which the reinvite will be sent |
on_request_creation | Callback called when request is created |
on_sdp_creation | Callback called when SDP is created |
on_response | Callback called when response for request is received |
method | The method that should be used when constructing the session refresh |
generate_new_sdp | Boolean to indicate if a new SDP should be created |
media_state | Optional requested media state for the SDP |
0 | Successfully sent refresh |
-1 | Failure to send refresh |
Definition at line 2536 of file res_pjsip_session.c.
References method, NULL, session, and sip_session_refresh().
Referenced by dtmf_mode_refresh_cb(), refresh_write_cb(), remote_send_hold_refresh(), send_direct_media_request(), send_topology_change_refresh(), t38_interpret_parameters(), and update_connected_line_information().
int ast_sip_session_regenerate_answer | ( | struct ast_sip_session * | session, |
ast_sip_session_sdp_creation_cb | on_sdp_creation | ||
) |
Regenerate SDP Answer.
This method is used when an SDP offer has been received but an SDP answer has not been sent yet. It requests that a new local SDP be created and set as the SDP answer. As with any outgoing request in res_pjsip_session, this will call into registered supplements in case they wish to add anything.
session | The session on which the answer will be updated |
on_sdp_creation | Callback called when SDP is created |
0 | Successfully updated the SDP answer |
-1 | Failure to updated the SDP answer |
Definition at line 2547 of file res_pjsip_session.c.
References ast_channel_name(), ast_log, ast_sip_session_get_name(), create_local_sdp(), LOG_WARNING, NULL, SCOPE_ENTER, SCOPE_EXIT_RTN_VALUE, and session.
Referenced by dtmf_mode_refresh_cb().
int ast_sip_session_register_sdp_handler | ( | struct ast_sip_session_sdp_handler * | handler, |
const char * | stream_type | ||
) |
Register an SDP handler.
An SDP handler is responsible for parsing incoming SDP streams and ensuring that Asterisk can cope with the contents. Similarly, the SDP handler will be responsible for constructing outgoing SDP streams.
Multiple handlers for the same stream type may be registered. They will be visited in the order they were registered. Handlers will be visited for each stream type until one claims to have handled the stream.
handler | The SDP handler to register |
stream_type | The type of media stream for which to call the handler |
0 | Success |
-1 | Failure |
Definition at line 147 of file res_pjsip_session.c.
References ao2_alloc, ao2_cleanup, ao2_find, ao2_link, ast_debug, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log, handler(), ast_sip_session_sdp_handler::id, lock, LOG_WARNING, ast_sip_session_sdp_handler::next, NULL, OBJ_KEY, RAII_VAR, SCOPED_AO2LOCK, sdp_handlers, and sdp_handler_list::stream_type.
Referenced by load_module().
void ast_sip_session_register_supplement_with_module | ( | struct ast_module * | module, |
struct ast_sip_session_supplement * | supplement | ||
) |
Register a supplement to SIP session processing.
This allows for someone to insert themselves in the processing of SIP requests and responses. This, for example could allow for a module to set channel data based on headers in an incoming message. Similarly, a module could reject an incoming request if desired.
module | Referenced module(NULL safe) |
supplement | The supplement to register |
Definition at line 35 of file pjsip_session.c.
References ast_assert, AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, AST_SIP_SESSION_BEFORE_MEDIA, lock, ast_sip_session_supplement::module, ast_sip_session_supplement::next, NULL, ast_sip_session_supplement::priority, ast_sip_session_supplement::response_priority, and SCOPED_LOCK.
void ast_sip_session_remove_datastore | ( | struct ast_sip_session * | session, |
const char * | name | ||
) |
Remove a session datastore from the session.
This operation may cause the datastore's free() callback to be called if the reference count reaches zero.
session | The session to remove the datastore from |
name | The name of the datastore to remove |
Definition at line 1301 of file res_pjsip_session.c.
References ao2_callback, name, NULL, OBJ_KEY, OBJ_NODATA, OBJ_UNLINK, and session.
Referenced by direct_media_mitigate_glare(), handle_outgoing_response(), outgoing_request(), reason_header_outgoing_response(), refresh_write_cb(), and session_refresh_state_get_or_alloc().
void ast_sip_session_remove_supplements | ( | struct ast_sip_session * | session | ) |
Remove supplements from a SIP session.
session | The session to remove |
Definition at line 111 of file pjsip_session.c.
References ast_free, AST_LIST_REMOVE_HEAD, ast_module_unref, ast_sip_session_supplement::module, ast_sip_session_supplement::next, and session.
Referenced by session_destructor().
void ast_sip_session_resume_reinvite | ( | struct ast_sip_session * | session | ) |
Resumes processing of a deferred incoming re-invite.
session | The session which has a pending incoming re-invite |
Definition at line 2818 of file res_pjsip_session.c.
References ast_sip_get_pjsip_endpoint(), NULL, and session.
Referenced by t38_automatic_reject(), and t38_interpret_parameters().
void ast_sip_session_send_request | ( | struct ast_sip_session * | session, |
pjsip_tx_data * | tdata | ||
) |
Send a SIP request.
This will send the SIP request specified in tdata and call into any registered supplements' outgoing_request callback.
session | The session to which to send the request |
tdata | The request to send |
Definition at line 2862 of file res_pjsip_session.c.
References ast_sip_session_send_request_with_cb(), NULL, and session.
Referenced by aoc_send_as_xml(), ast_sip_session_terminate(), call(), check_request_status(), handle_incoming_before_media(), outbound_invite_auth(), session_inv_on_tsx_state_changed(), transmit_info_dtmf(), and transmit_info_with_vidupdate().
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.
This will send the request out exactly the same as ast_sip_send_request() does. The difference is that when a response arrives, the specified callback will be called into
session | The session on which to send the request |
tdata | The request to send |
on_response | Callback to be called when a response is received |
Definition at line 2838 of file res_pjsip_session.c.
References ast_sip_mod_data_set, handle_outgoing_request(), MOD_DATA_ON_RESPONSE, session, and session_module.
Referenced by ast_sip_session_send_request(), session_inv_on_tsx_state_changed(), and sip_session_refresh().
void ast_sip_session_send_response | ( | struct ast_sip_session * | session, |
pjsip_tx_data * | tdata | ||
) |
Send a SIP response.
This will send the SIP response specified in tdata and call into any registered supplements' outgoing_response callback.
session | The session on which to send the response. |
tdata | The response to send |
Definition at line 2588 of file res_pjsip_session.c.
References ao2_cleanup, ast_sip_dialog_get_session(), handle_outgoing_response(), NULL, RAII_VAR, and session.
Referenced by answer(), ast_sip_session_terminate(), chan_pjsip_incoming_request(), indicate(), new_invite(), pjsip_hangup(), refer_incoming_invite_request(), transfer_redirect(), and update_connected_line_information().
void ast_sip_session_suspend | ( | struct ast_sip_session * | session | ) |
Request and wait for the session serializer to be suspended.
session | Which session to suspend the serializer. |
Definition at line 3175 of file res_pjsip_session.c.
References ao2_alloc, ao2_lock, ao2_object_get_lockaddr(), ao2_ref, ao2_unlock, ast_assert, ast_cond_init, ast_cond_wait, ast_sip_push_task(), ast_taskprocessor_is_suspended(), ast_taskprocessor_is_task(), ast_taskprocessor_suspend(), ast_sip_session_suspender::cond_complete, ast_sip_session_suspender::cond_suspended, NULL, session, sip_session_suspend_task(), sip_session_suspender_dtor(), and ast_sip_session_suspender::suspended.
Referenced by chan_pjsip_indicate().
void ast_sip_session_terminate | ( | struct ast_sip_session * | session, |
int | response | ||
) |
Terminate a session and, if possible, send the provided response code.
session | The session to terminate |
response | The response code to use for termination if possible |
Definition at line 3471 of file res_pjsip_session.c.
References ast_debug, AST_LIST_REMOVE_HEAD, ast_sip_session_get_name(), ast_sip_session_media_state_reset(), ast_sip_session_media_stats_save(), ast_sip_session_send_request(), ast_sip_session_send_response(), delay_request(), DELAYED_METHOD_BYE, delayed_request_free(), ast_sip_session_delayed_request::next, NULL, SCOPE_ENTER, SCOPE_EXIT_RTN, session, session_end(), session_end_completion(), session_module, status, and SWAP.
Referenced by ast_sip_session_defer_termination_cancel(), chan_pjsip_incoming_request(), hangup(), reject_incoming_call(), send_delayed_request(), and session_termination_task().
void ast_sip_session_unregister_sdp_handler | ( | struct ast_sip_session_sdp_handler * | handler, |
const char * | stream_type | ||
) |
Unregister an SDP handler.
handler | The SDP handler to unregister |
stream_type | Stream type for which the SDP handler was registered |
Definition at line 208 of file res_pjsip_session.c.
References ao2_callback_data, handler(), OBJ_KEY, OBJ_NODATA, OBJ_UNLINK, remove_handler(), and sdp_handlers.
Referenced by unload_module().
void ast_sip_session_unregister_supplement | ( | struct ast_sip_session_supplement * | supplement | ) |
Unregister a an supplement to SIP session processing.
supplement | The supplement to unregister |
Definition at line 63 of file pjsip_session.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, lock, ast_sip_session_supplement::next, and SCOPED_LOCK.
Referenced by ast_res_pjsip_cleanup_message_filter(), load_module(), pjsip_reason_header_unload(), and unload_module().
void ast_sip_session_unsuspend | ( | struct ast_sip_session * | session | ) |
Request the session serializer be unsuspended.
session | Which session to unsuspend the serializer. |
Definition at line 3220 of file res_pjsip_session.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_cond_signal, ast_taskprocessor_unsuspend(), ast_sip_session_suspender::complete, ast_sip_session_suspender::cond_complete, NULL, and session.
Referenced by chan_pjsip_indicate().