Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add siprec extension: handle incoming INVITE with siprec #4132

Merged
merged 87 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
ec478f2
add siprec extension
sorooshm78 Nov 3, 2024
748ea35
add enableMultimedia
sorooshm78 Nov 3, 2024
d0aa099
add pjsip reference
sorooshm78 Nov 3, 2024
feff73b
add comment
sorooshm78 Nov 4, 2024
2712066
add comment
sorooshm78 Nov 4, 2024
7eb320b
add comment
sorooshm78 Nov 4, 2024
6743e75
add comment
sorooshm78 Nov 4, 2024
ef75332
add comment
sorooshm78 Nov 5, 2024
d6e41de
add comment
sorooshm78 Nov 5, 2024
282c14b
add comment
sorooshm78 Nov 5, 2024
74d400d
add comment
sorooshm78 Nov 5, 2024
f894272
add comment
sorooshm78 Nov 5, 2024
2853fc5
add comment
sorooshm78 Nov 5, 2024
5e00d55
add comment
sorooshm78 Nov 5, 2024
0b3e3e5
add comment
sorooshm78 Nov 5, 2024
adb6f7d
refactor
sorooshm78 Nov 5, 2024
b12eff8
refactor
sorooshm78 Nov 5, 2024
a861ad0
refactor
sorooshm78 Nov 5, 2024
6be8941
refactor
sorooshm78 Nov 5, 2024
434fd23
refactor
sorooshm78 Nov 5, 2024
8bbadff
refactor
sorooshm78 Nov 5, 2024
b4035cb
refactor
sorooshm78 Nov 5, 2024
085b0e5
refactor
sorooshm78 Nov 5, 2024
7514edd
add siprec extension reference
sorooshm78 Nov 7, 2024
9d5eee4
fix error
sorooshm78 Nov 10, 2024
2aca0ce
print metadata of siprec request
sorooshm78 Nov 12, 2024
4a8fd1c
remove mutimedia support
sorooshm78 Nov 17, 2024
2232f57
add more check for siprec request
sorooshm78 Nov 18, 2024
9cecec1
add comment
sorooshm78 Nov 19, 2024
8498bee
add comment
sorooshm78 Nov 19, 2024
6d54ca4
add comment
sorooshm78 Nov 20, 2024
a2a9b88
add SIPREC INVITE without SDP is not supported
sorooshm78 Nov 21, 2024
f74742c
add comment
sorooshm78 Nov 21, 2024
9e017b6
add metadata
sorooshm78 Nov 23, 2024
a403848
Merge branch 'Feature/siprec-extension' into Feature/siprec-metadata
sorooshm78 Nov 23, 2024
ad4b4f6
add comment
sorooshm78 Nov 23, 2024
6e90bbf
remove deprecated code
sorooshm78 Nov 24, 2024
2bad02f
add PJ_DECL for all functions
sorooshm78 Nov 24, 2024
ab02307
add video support
sorooshm78 Nov 25, 2024
636104c
use pjsua_call attribute for audio and video count
sorooshm78 Nov 25, 2024
72862e7
refactor code
sorooshm78 Dec 2, 2024
ff2fae0
fix error
sorooshm78 Dec 2, 2024
12583e6
refactor code
sorooshm78 Dec 2, 2024
d26b520
add comment
sorooshm78 Dec 2, 2024
5bb8144
Merge branch 'Feature/siprec-extension' into Feature/siprec-metadata
sorooshm78 Dec 2, 2024
b175948
add PJ_DECL for all functions
sorooshm78 Dec 2, 2024
86c1e85
remove extra line
sorooshm78 Dec 11, 2024
33cb7e4
remove file
sorooshm78 Dec 11, 2024
e2ca441
add file
sorooshm78 Dec 11, 2024
9f87d5e
remove change audio and video option call
sorooshm78 Dec 11, 2024
c1fd441
remove unuse api
sorooshm78 Dec 12, 2024
6db8946
add correct assertion and log message.
sorooshm78 Dec 12, 2024
1df71ba
fix error
sorooshm78 Dec 12, 2024
9a46400
Typo fix
sorooshm78 Dec 12, 2024
098d22a
remove pjmedia_sdp_attr_get_label function
sorooshm78 Dec 12, 2024
3853872
refactor code
sorooshm78 Dec 12, 2024
6196a15
refactor code
sorooshm78 Dec 14, 2024
26474cc
inline pjsip_siprec_verify_sdp_attr_label function
sorooshm78 Dec 14, 2024
3d20a8a
add copyright and licensing info
sorooshm78 Dec 14, 2024
afa2a1f
Merge branch 'pjsip:master' into Feature/siprec-extension
sorooshm78 Dec 14, 2024
a6c1414
fix error
sorooshm78 Dec 15, 2024
ad5aec9
refactor code
sorooshm78 Dec 16, 2024
1564bb5
add Teluu copyright
sorooshm78 Dec 17, 2024
92609cb
typo
sorooshm78 Dec 17, 2024
7e06894
add coment
sorooshm78 Dec 17, 2024
19239c3
Merge branch 'pjsip:master' into Feature/siprec-extension
sorooshm78 Dec 17, 2024
1bede37
add enable/disable siprec option
sorooshm78 Dec 22, 2024
e3248f4
clone label attr
sorooshm78 Dec 22, 2024
ff5be8b
refactor code
sorooshm78 Dec 22, 2024
f6cb5d7
Merge branch 'pjsip:master' into Feature/siprec-extension
sorooshm78 Dec 22, 2024
439eee6
Merge branch 'pjsip:master' into Feature/siprec-extension
sorooshm78 Dec 24, 2024
5014838
change parameter type
sorooshm78 Dec 24, 2024
81a10de
add siprecUse in readObject and writeObject
sorooshm78 Dec 24, 2024
7cc2ab1
add document
sorooshm78 Dec 24, 2024
add6352
refactor code
sorooshm78 Dec 24, 2024
d927818
fix no modification
sorooshm78 Dec 24, 2024
0ef4cb0
fix error
sorooshm78 Dec 24, 2024
b04175a
Normalize line endings
sorooshm78 Dec 24, 2024
186061f
fix error
sorooshm78 Dec 24, 2024
dd034df
fix error
sorooshm78 Dec 24, 2024
55d39ff
fix error
sorooshm78 Dec 24, 2024
aa097fd
fix line endings
sorooshm78 Dec 24, 2024
eea87d1
remove PJSIP_INV_NOT_SUPPORT_SIPREC
sorooshm78 Dec 26, 2024
adb7bd7
Merge branch 'pjsip:master' into Feature/siprec-extension
sorooshm78 Jan 2, 2025
f43218c
remove pjmedia_sdp_attr_get_label
sorooshm78 Jan 2, 2025
04b580e
fix line endings
sorooshm78 Jan 2, 2025
defa504
fix line endings
sorooshm78 Jan 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pjmedia/include/pjmedia/sdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_ssrc(pj_pool_t *pool,
const pj_str_t *cname);


/**
* Create a=label attribute.
*
* @param pool Pool to create the attribute.
* @param attr Attribute to create.
*
* @return SDP label attribute.
*/
PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_label(pj_pool_t *pool,
const pj_str_t *label_str);


/* **************************************************************************
* SDP CONNECTION INFO
****************************************************************************
Expand Down
15 changes: 15 additions & 0 deletions pjmedia/src/pjmedia/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,21 @@ PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_ssrc( pj_pool_t *pool,
}


PJ_DEF(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_label(pj_pool_t *pool,
const pj_str_t *label_str)
{
pjmedia_sdp_attr *attr;

attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr);
attr->name = pj_str("label");
attr->value.ptr = (char *)pj_pool_alloc(pool, label_str->slen);
pj_memcpy(attr->value.ptr, label_str->ptr, label_str->slen);
attr->value.slen = label_str->slen;

return attr;
}


PJ_DEF(pj_status_t) pjmedia_sdp_attr_to_rtpmap(pj_pool_t *pool,
const pjmedia_sdp_attr *attr,
pjmedia_sdp_rtpmap **p_rtpmap)
Expand Down
2 changes: 1 addition & 1 deletion pjsip/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export PJSIP_LDFLAGS += $(PJLIB_UTIL_LDLIB) \
export PJSIP_UA_SRCDIR = ../src/pjsip-ua
export PJSIP_UA_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
sip_inv.o sip_reg.o sip_replaces.o sip_xfer.o \
sip_100rel.o sip_timer.o
sip_100rel.o sip_timer.o sip_siprec.o
export PJSIP_UA_CFLAGS += $(_CFLAGS)
export PJSIP_UA_CXXFLAGS += $(_CXXFLAGS)
export PJSIP_UA_LDFLAGS += $(PJSIP_SIMPLE_LDLIB) \
Expand Down
8 changes: 8 additions & 0 deletions pjsip/build/pjsip_ua.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -3468,6 +3468,10 @@
RelativePath="..\src\pjsip-ua\sip_timer.c"
>
</File>
<File
RelativePath="..\src\pjsip-ua\sip_siprec.c"
>
</File>
<File
RelativePath="..\src\pjsip-ua\sip_xfer.c"
>
Expand Down Expand Up @@ -3609,6 +3613,10 @@
RelativePath="..\include\pjsip-ua\sip_timer.h"
>
</File>
<File
RelativePath="..\include\pjsip-ua\sip_siprec.h"
>
</File>
<File
RelativePath="..\include\pjsip-ua\sip_xfer.h"
>
Expand Down
2 changes: 2 additions & 0 deletions pjsip/build/pjsip_ua.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@
<ClCompile Include="..\src\pjsip-ua\sip_reg.c" />
<ClCompile Include="..\src\pjsip-ua\sip_replaces.c" />
<ClCompile Include="..\src\pjsip-ua\sip_timer.c" />
<ClCompile Include="..\src\pjsip-ua\sip_siprec.c" />
<ClCompile Include="..\src\pjsip-ua\sip_xfer.c" />
</ItemGroup>
<ItemGroup>
Expand All @@ -687,6 +688,7 @@
<ClInclude Include="..\include\pjsip-ua\sip_regc.h" />
<ClInclude Include="..\include\pjsip-ua\sip_replaces.h" />
<ClInclude Include="..\include\pjsip-ua\sip_timer.h" />
<ClInclude Include="..\include\pjsip-ua\sip_siprec.h" />
<ClInclude Include="..\include\pjsip-ua\sip_xfer.h" />
<ClInclude Include="..\include\pjsip_ua.h" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions pjsip/build/pjsip_ua.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<ClCompile Include="..\src\pjsip-ua\sip_timer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\pjsip-ua\sip_siprec.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\pjsip-ua\sip_xfer.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -49,6 +52,9 @@
<ClInclude Include="..\include\pjsip-ua\sip_timer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\pjsip-ua\sip_siprec.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\pjsip-ua\sip_xfer.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
10 changes: 10 additions & 0 deletions pjsip/include/pjsip-ua/sip_inv.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,17 @@ enum pjsip_inv_option
* Require trickle ICE support.
*/
PJSIP_INV_REQUIRE_TRICKLE_ICE = 512,

/**
* Require siprec support.
*/
PJSIP_INV_REQUIRE_SIPREC = 1024,

/**
* Indicate support for siprec
*/
PJSIP_INV_SUPPORT_SIPREC = 2048,

};

/* Forward declaration of Session Timers */
Expand Down
131 changes: 131 additions & 0 deletions pjsip/include/pjsip-ua/sip_siprec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
* Copyright (C) 2024 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2024 Green and Silver Leaves. (https://github.com/BSVN)
sorooshm78 marked this conversation as resolved.
Show resolved Hide resolved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJSIP_SIPREC_H__
#define __PJSIP_SIPREC_H__

/**
* @file sip_siprec.h
* @brief SIP Session Recording Protocol (siprec)
* support (RFC 7866 - Session Recording Protocol in SIP)
*/


#include <pjsip-ua/sip_inv.h>
#include <pjsip/sip_msg.h>

/**
* @defgroup PJSIP_SIPREC SIP Session Recording Protocol (siprec)
* support (RFC 7866 - Session Recording Protocol in SIP)
* @brief SIP Session Recording Protocol support
* (RFC 7866 - Session Recording Protocol in SIP)
* @{
*
* \section PJSIP_SIPREC_REFERENCE References
*
* References:
* - <A HREF="http://www.ietf.org/rfc/rfc7866.txt">
* RFC 7866: Session Recording Protocol (siprec)
* in the Session Initiation Protocol (SIP)</A>
*/
PJ_BEGIN_DECL

/**
* Initialize siprec module. This function must be called once during
* application initialization, to register siprec module to SIP endpoint.
*
* @param endpt The SIP endpoint instance.
*
* @return PJ_SUCCESS if module is successfully initialized.
*/
PJ_DECL(pj_status_t) pjsip_siprec_init_module(pjsip_endpoint *endpt);


/**
* Check if the value of Require header is equal to siprec.
*
* @param req_hdr Require header.
*
* @return PJ_TRUE if value of Require header is equal to siprec.
*/
PJ_DECL(pj_status_t)
pjsip_siprec_verify_require_hdr(pjsip_require_hdr *req_hdr);


/**
* Verifies that the incoming request has the siprec value
* in the Require header and "+sip.src" parameter exist in the Contact header.
* If both conditions are met, according to RFC 7866,
* the INVITE request is a siprec. Otherwise,
* no changes are made to the request. if INVITE request is a siprec
* must have media attribute label exist in the SDP
*
* @param rdata The incoming request to be verified.
* @param metadata The siprec metadata information
* @param sdp_offer The SDP media.
* @param options The options argument is bitmask combination of SIP
* features in pjsip_inv_option enumeration
* @param dlg The dialog instance.
* @param endpt Media endpoint instance.
* @param p_tdata Upon error, it will be filled with the final response
* to be sent to the request sender.
*
* @return The function returns the following:
* - If the request includes the value siprec in the Require header
* and also includes "+sip.src" in the Contact header.
* PJ_SUCCESS and set PJSIP_INV_REQUIRE_SIPREC to options
* - Upon error condition (as described by RFC 7866), the
* function returns non-PJ_SUCCESS, and \a p_tdata
* parameter SHOULD be set with a final response message
* to be sent to the sender of the request.
*/
PJ_DECL(pj_status_t) pjsip_siprec_verify_request(pjsip_rx_data *rdata,
pj_str_t *metadata,
pjmedia_sdp_session *sdp_offer,
unsigned *options,
pjsip_dialog *dlg,
pjsip_endpoint *endpt,
pjsip_tx_data **p_tdata);


/**
* Find siprec metadata information from the message body
* with "rs-metadata" Content-Type.
*
* @param pool Pool to allocate memory.
* @param body The message body.
* @param metadata If metadata is found, this variable will be
* populated with the extracted data.
*
* @return Return PJ_SUCCESS if metadata is found,
* otherwise return PJ_ENOTFOUND.
*/
PJ_DECL(pj_status_t) pjsip_siprec_get_metadata(pj_pool_t *pool,
pjsip_msg_body *body,
pj_str_t* metadata);


PJ_END_DECL


/**
* @}
*/


#endif /* __PJSIP_SIPREC_H__ */
1 change: 1 addition & 0 deletions pjsip/include/pjsip_ua.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <pjsip-ua/sip_xfer.h>
#include <pjsip-ua/sip_100rel.h>
#include <pjsip-ua/sip_timer.h>
#include <pjsip-ua/sip_siprec.h>


#endif /* __PJSIP_UA_H__ */
Expand Down
43 changes: 43 additions & 0 deletions pjsip/include/pjsua-lib/pjsua.h
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,32 @@ typedef enum pjsua_sip_timer_use
} pjsua_sip_timer_use;


/**
* This enumeration specifies the usage of SIPREC extension.
*/
typedef enum pjsua_sip_siprec_use
{
/**
* When this flag is specified, when a SIPREC request is received, it
* returns bad extension error. and SIPREC calls will not be established.
*/
PJSUA_SIP_SIPREC_INACTIVE,

/**
* When this flag is specified, when you want both regular calls and
* SIPREC calls to be established.
*/
PJSUA_SIP_SIPREC_OPTIONAL,

/**
* When this flag is specified, when you want only SIPREC calls to
* be established, and regular calls are rejected.
*/
PJSUA_SIP_SIPREC_MANDATORY,

} pjsua_sip_siprec_use;


/**
* This constants controls the use of 100rel extension.
*/
Expand Down Expand Up @@ -2343,6 +2369,15 @@ typedef struct pjsua_config
*/
pjsua_sip_timer_use use_timer;

/**
* Specify the usage of SIPREC sessions. See the
* #pjsua_sip_siprec_use for possible values. Note that this setting can be
* further customized in account configuration (#pjsua_acc_config).
*
* Default: PJSUA_SIP_SIPREC_INACTIVE
*/
pjsua_sip_siprec_use use_siprec;

/**
* Handle unsolicited NOTIFY requests containing message waiting
* indication (MWI) info. Unsolicited MWI is incoming NOTIFY requests
Expand Down Expand Up @@ -4065,6 +4100,14 @@ typedef struct pjsua_acc_config
*/
pjsua_sip_timer_use use_timer;

/**
* Specify the usage of SIPREC sessions. See the
* #pjsua_sip_siprec_use for possible values.
*
* Default: PJSUA_SIP_SIPREC_INACTIVE
*/
pjsua_sip_siprec_use use_siprec;

/**
* Specify Session Timer settings, see #pjsip_timer_setting.
*/
Expand Down
1 change: 1 addition & 0 deletions pjsip/include/pjsua-lib/pjsua_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ struct pjsua_call
unsigned hangup_code; /**< Hangup code. */
pj_str_t hangup_reason; /**< Hangup reason. */
pjsua_msg_data *hangup_msg_data;/**< Hangup message data. */
pj_str_t siprec_metadata;/** siprec metadata in body */
};


Expand Down
9 changes: 9 additions & 0 deletions pjsip/include/pjsua2/account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ struct AccountCallConfig : public PersistentObject
*/
pjsua_sip_timer_use timerUse;

/**
* Specify the usage of SIPREC INVITE request. See the
* pjsua_sip_siprec_use for possible values.
*
* Default: PJSUA_SIP_SIPREC_INACTIVE
*/
pjsua_sip_siprec_use siprecUse;

/**
* Specify minimum Session Timer expiration period, in seconds.
* Must not be lower than 90. Default is 90.
Expand All @@ -363,6 +371,7 @@ struct AccountCallConfig : public PersistentObject
AccountCallConfig() : holdType(PJSUA_CALL_HOLD_TYPE_DEFAULT),
prackUse(PJSUA_100REL_NOT_USED),
timerUse(PJSUA_SIP_TIMER_OPTIONAL),
siprecUse(PJSUA_SIP_SIPREC_INACTIVE),
timerMinSESec(90),
timerSessExpiresSec(PJSIP_SESS_TIMER_DEF_SE)
{}
Expand Down
Loading
Loading