32 #include "asterisk/res_pjsip.h"
33 #include "asterisk/res_pjsip_session.h"
35 #include "asterisk/features_config.h"
37 static void send_response(
struct ast_sip_session *session,
int code,
struct pjsip_rx_data *rdata)
41 if (pjsip_dlg_create_response(session->
inv_session->dlg, rdata, code, NULL, &tdata) == PJ_SUCCESS) {
42 struct pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata);
44 pjsip_dlg_send_response(session->
inv_session->dlg, tsx, tdata);
48 static int handle_incoming_request(
struct ast_sip_session *session,
struct pjsip_rx_data *rdata)
50 static const pj_str_t rec_str = {
"Record", 6 };
51 pjsip_generic_string_hdr *record;
53 char feature_code[AST_FEATURE_MAX_LEN];
57 record = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &rec_str, NULL);
64 if (!pj_stricmp2(&record->hvalue,
"on")) {
66 }
else if (!pj_stricmp2(&record->hvalue,
"off")) {
74 send_response(session, 481, rdata);
80 send_response(session, 403, rdata);
84 ast_channel_lock(session->
channel);
85 feature_res = ast_get_feature(session->
channel, feature, feature_code,
sizeof(feature_code));
86 ast_channel_unlock(session->
channel);
88 if (feature_res || ast_strlen_zero(feature_code)) {
89 send_response(session, 403, rdata);
93 for (digit = feature_code; *digit; ++digit) {
94 struct ast_frame f = { AST_FRAME_DTMF, .subclass.integer = *digit, .len = 100 };
98 send_response(session, 200, rdata);
105 .priority = AST_SIP_SUPPLEMENT_PRIORITY_FIRST,
106 .incoming_request = handle_incoming_request,
109 static int load_module(
void)
111 ast_sip_session_register_supplement(&info_supplement);
116 static int unload_module(
void)
118 ast_sip_session_unregister_supplement(&info_supplement);
122 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"PJSIP INFO One Touch Recording Support",
123 .support_level = AST_MODULE_SUPPORT_CORE,
125 .unload = unload_module,
127 .requires =
"res_pjsip,res_pjsip_session",
struct ast_sip_endpoint * endpoint
Asterisk main include file. File version handling, generic pbx functions.
struct ast_sip_info_recording_configuration recording
struct pjsip_inv_session * inv_session
A structure describing a SIP session.
const ast_string_field offfeature
struct ast_channel * channel
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
struct ast_sip_endpoint_info_configuration info
A supplement to SIP message processing.
const ast_string_field onfeature
Data structure associated with a single frame of data.
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.