| 1 | /* |
| 2 | * Copyright (C) 2024 Teluu Inc. (http://www.teluu.com) |
| 3 | * Copyright (C) 2024 Green and Silver Leaves. (https://github.com/BSVN) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJSIP_SIPREC_H__ |
| 20 | #define __PJSIP_SIPREC_H__ |
| 21 | |
| 22 | /** |
| 23 | * @file sip_siprec.h |
| 24 | * @brief SIP Session Recording Protocol (siprec) |
| 25 | * support (RFC 7866 - Session Recording Protocol in SIP) |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #include <pjsip-ua/sip_inv.h> |
| 30 | #include <pjsip/sip_msg.h> |
| 31 | |
| 32 | /** |
| 33 | * @defgroup PJSIP_SIPREC SIP Session Recording Protocol (siprec) |
| 34 | * support (RFC 7866 - Session Recording Protocol in SIP) |
| 35 | * @brief SIP Session Recording Protocol support |
| 36 | * (RFC 7866 - Session Recording Protocol in SIP) |
| 37 | * @{ |
| 38 | * |
| 39 | * \section PJSIP_SIPREC_REFERENCE References |
| 40 | * |
| 41 | * References: |
| 42 | * - <A HREF="http://www.ietf.org/rfc/rfc7866.txt"> |
| 43 | * RFC 7866: Session Recording Protocol (siprec) |
| 44 | * in the Session Initiation Protocol (SIP)</A> |
| 45 | */ |
| 46 | PJ_BEGIN_DECL |
| 47 | |
| 48 | /** |
| 49 | * Initialize siprec module. This function must be called once during |
| 50 | * application initialization, to register siprec module to SIP endpoint. |
| 51 | * |
| 52 | * @param endpt The SIP endpoint instance. |
| 53 | * |
| 54 | * @return PJ_SUCCESS if module is successfully initialized. |
| 55 | */ |
| 56 | PJ_DECL(pj_status_t) pjsip_siprec_init_module(pjsip_endpoint *endpt); |
| 57 | |
| 58 | |
| 59 | /** |
| 60 | * Check if the value of Require header is equal to siprec. |
| 61 | * |
| 62 | * @param req_hdr Require header. |
| 63 | * |
| 64 | * @return PJ_TRUE if value of Require header is equal to siprec. |
| 65 | */ |
| 66 | PJ_DECL(pj_status_t) |
| 67 | pjsip_siprec_verify_require_hdr(pjsip_require_hdr *req_hdr); |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * Verifies that the incoming request has the siprec value |
| 72 | * in the Require header and "+sip.src" parameter exist in the Contact header. |
| 73 | * If both conditions are met, according to RFC 7866, |
| 74 | * the INVITE request is a siprec. Otherwise, |
| 75 | * no changes are made to the request. if INVITE request is a siprec |
| 76 | * must have media attribute label exist in the SDP |
| 77 | * |
| 78 | * @param rdata The incoming request to be verified. |
| 79 | * @param metadata The siprec metadata information |
| 80 | * @param sdp_offer The SDP media. |
| 81 | * @param options The options argument is bitmask combination of SIP |
| 82 | * features in pjsip_inv_option enumeration |
| 83 | * @param dlg The dialog instance. |
| 84 | * @param endpt Media endpoint instance. |
| 85 | * @param p_tdata Upon error, it will be filled with the final response |
| 86 | * to be sent to the request sender. |
| 87 | * |
| 88 | * @return The function returns the following: |
| 89 | * - If the request includes the value siprec in the Require header |
| 90 | * and also includes "+sip.src" in the Contact header. |
| 91 | * PJ_SUCCESS and set PJSIP_INV_REQUIRE_SIPREC to options |
| 92 | * - Upon error condition (as described by RFC 7866), the |
| 93 | * function returns non-PJ_SUCCESS, and \a p_tdata |
| 94 | * parameter SHOULD be set with a final response message |
| 95 | * to be sent to the sender of the request. |
| 96 | */ |
| 97 | PJ_DECL(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata, |
| 98 | pj_str_t *metadata, |
| 99 | pjmedia_sdp_session *sdp_offer, |
| 100 | unsigned *options, |
| 101 | pjsip_dialog *dlg, |
| 102 | pjsip_endpoint *endpt, |
| 103 | pjsip_tx_data **p_tdata); |
| 104 | |
| 105 | |
| 106 | /** |
| 107 | * Find siprec metadata information from the message body |
| 108 | * with "rs-metadata" Content-Type. |
| 109 | * |
| 110 | * @param pool Pool to allocate memory. |
| 111 | * @param body The message body. |
| 112 | * @param metadata If metadata is found, this variable will be |
| 113 | * populated with the extracted data. |
| 114 | * |
| 115 | * @return Return PJ_SUCCESS if metadata is found, |
| 116 | * otherwise return PJ_ENOTFOUND. |
| 117 | */ |
| 118 | PJ_DECL(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool, |
| 119 | pjsip_msg_body *body, |
| 120 | pj_str_t* metadata); |
| 121 | |
| 122 | |
| 123 | PJ_END_DECL |
| 124 | |
| 125 | |
| 126 | /** |
| 127 | * @} |
| 128 | */ |
| 129 | |
| 130 | |
| 131 | #endif /* __PJSIP_SIPREC_H__ */ |