Skip to content

Commit

Permalink
Merge branch 'pjsip:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anikitin-intermedia authored Nov 3, 2023
2 parents 736693d + cf4f2d8 commit 9336b96
Show file tree
Hide file tree
Showing 29 changed files with 304 additions and 109 deletions.
47 changes: 27 additions & 20 deletions pjlib-util/src/pjlib-util/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@ PJ_DEF(void) pj_scan_skip_whitespace( pj_scanner *scanner )
{
register char *s = scanner->curptr;

while (PJ_SCAN_IS_SPACE(*s)) {
while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
++s;
}

if (PJ_SCAN_IS_NEWLINE(*s) && (scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE)) {
for (;;) {
if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
(scanner->skip_ws & PJ_SCAN_AUTOSKIP_NEWLINE))
{
for (; PJ_SCAN_CHECK_EOF(s); ) {
if (*s == '\r') {
++s;
if (!PJ_SCAN_CHECK_EOF(s)) break;
if (*s == '\n') ++s;
++scanner->line;
scanner->curptr = scanner->start_line = s;
Expand All @@ -160,30 +163,33 @@ PJ_DEF(void) pj_scan_skip_whitespace( pj_scanner *scanner )
} else if (PJ_SCAN_IS_SPACE(*s)) {
do {
++s;
} while (PJ_SCAN_IS_SPACE(*s));
} while (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s));
} else {
break;
}
}
}

if (PJ_SCAN_IS_NEWLINE(*s) && (scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==PJ_SCAN_AUTOSKIP_WS_HEADER) {
if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_NEWLINE(*s) &&
(scanner->skip_ws & PJ_SCAN_AUTOSKIP_WS_HEADER)==
PJ_SCAN_AUTOSKIP_WS_HEADER)
{
/* Check for header continuation. */
scanner->curptr = s;

if (*s == '\r') {
++s;
}
if (*s == '\n') {
if (PJ_SCAN_CHECK_EOF(s) && *s == '\n') {
++s;
}
scanner->start_line = s;

if (PJ_SCAN_IS_SPACE(*s)) {
if (PJ_SCAN_CHECK_EOF(s) && PJ_SCAN_IS_SPACE(*s)) {
register char *t = s;
do {
++t;
} while (PJ_SCAN_IS_SPACE(*t));
} while (PJ_SCAN_CHECK_EOF(t) && PJ_SCAN_IS_SPACE(*t));

++scanner->line;
scanner->curptr = t;
Expand Down Expand Up @@ -220,8 +226,7 @@ PJ_DEF(int) pj_scan_peek( pj_scanner *scanner,
return -1;
}

/* Don't need to check EOF with PJ_SCAN_CHECK_EOF(s) */
while (pj_cis_match(spec, *s))
while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s))
++s;

pj_strset3(out, scanner->curptr, s);
Expand Down Expand Up @@ -277,17 +282,15 @@ PJ_DEF(void) pj_scan_get( pj_scanner *scanner,

do {
++s;
} while (pj_cis_match(spec, *s));
/* No need to check EOF here (PJ_SCAN_CHECK_EOF(s)) because
* buffer is NULL terminated and pj_cis_match(spec,0) should be
* false.
*/
} while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s));

pj_strset3(out, scanner->curptr, s);

scanner->curptr = s;

if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
if (!pj_scan_is_eof(scanner) &&
PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
{
pj_scan_skip_whitespace(scanner);
}
}
Expand Down Expand Up @@ -330,18 +333,20 @@ PJ_DEF(void) pj_scan_get_unescape( pj_scanner *scanner,
char *start = s;
do {
++s;
} while (pj_cis_match(spec, *s));
} while (PJ_SCAN_CHECK_EOF(s) && pj_cis_match(spec, *s));

if (dst != start) pj_memmove(dst, start, s-start);
dst += (s-start);
}

} while (*s == '%');
} while (PJ_SCAN_CHECK_EOF(s) && (*s == '%'));

scanner->curptr = s;
out->slen = (dst - out->ptr);

if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
if (!pj_scan_is_eof(scanner) &&
PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
{
pj_scan_skip_whitespace(scanner);
}
}
Expand Down Expand Up @@ -422,7 +427,9 @@ PJ_DEF(void) pj_scan_get_quotes(pj_scanner *scanner,

scanner->curptr = s;

if (PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws) {
if (!pj_scan_is_eof(scanner) &&
PJ_SCAN_IS_PROBABLY_SPACE(*s) && scanner->skip_ws)
{
pj_scan_skip_whitespace(scanner);
}
}
Expand Down
2 changes: 1 addition & 1 deletion pjlib/include/pj/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ PJ_BEGIN_DECL
#define PJ_VERSION_NUM_MAJOR 2

/** PJLIB version minor number. */
#define PJ_VERSION_NUM_MINOR 13
#define PJ_VERSION_NUM_MINOR 14

/** PJLIB version revision number. */
#define PJ_VERSION_NUM_REV 0
Expand Down
2 changes: 1 addition & 1 deletion pjlib/src/pj/ssl_sock_imp_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ static pj_bool_t ssock_on_accept_complete (pj_ssl_sock_t *ssock_parent,
int src_addr_len,
pj_status_t accept_status)
{
pj_ssl_sock_t *ssock;
pj_ssl_sock_t *ssock = NULL;
#ifndef SSL_SOCK_IMP_USE_OWN_NETWORK
pj_activesock_cb asock_cb;
pj_activesock_cfg asock_cfg;
Expand Down
2 changes: 2 additions & 0 deletions pjmedia/src/pjmedia-codec/and_vid_mediacodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,8 @@ static pj_status_t decode_h264(pjmedia_vid_codec *codec,
buf_pos += frm_size;
}

PJ_UNUSED_ARG(frm_cnt);

return PJ_SUCCESS;
}

Expand Down
7 changes: 4 additions & 3 deletions pjnath/src/pjnath/nat_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,8 @@ static void end_session(nat_detect_session *sess,
delay.sec = 0;
delay.msec = 0;

sess->timer.id = TIMER_DESTROY;
pj_timer_heap_schedule(sess->timer_heap, &sess->timer, &delay);
pj_timer_heap_schedule_w_grp_lock(sess->timer_heap, &sess->timer, &delay,
TIMER_DESTROY, sess->grp_lock);
}


Expand Down Expand Up @@ -934,7 +934,8 @@ static void on_sess_timer(pj_timer_heap_t *th,

if (next_timer) {
pj_time_val delay = {0, TEST_INTERVAL};
pj_timer_heap_schedule(th, te, &delay);
pj_timer_heap_schedule_w_grp_lock(th, te, &delay,
TIMER_TEST, sess->grp_lock);
} else {
te->id = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions pjsip-apps/src/pjsua/ios/ipjsua.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_STRICT_PROTOTYPES = NO;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -473,7 +473,7 @@
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_STRICT_PROTOTYPES = NO;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
1 change: 1 addition & 0 deletions pjsip-apps/src/samples/pjsua2_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class MyAudioMediaPort: public AudioMediaPort

virtual void onFrameReceived(MediaFrame &frame)
{
PJ_UNUSED_ARG(frame);
// Process the incoming frame here
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.Android">
<activity android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
33 changes: 32 additions & 1 deletion pjsip/include/pjsip-ua/sip_inv.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,39 @@ PJ_DECL(pj_status_t) pjsip_inv_invite( pjsip_inv_session *inv,

/**
* Create the initial response message for the incoming INVITE request in
* rdata with status code st_code and optional status text st_text. Use
* rdata with status code st_code and optional status text st_text. Use
* #pjsip_inv_answer() to create subsequent response message.
*
* When this function returning non-PJ_SUCCESS, it may be caused by an
* unacceptable INVITE request. In such cases the function will generate
* an appropriate answer in p_tdata,
* e.g: when session timer header Session-Expires is too low,
* the generated answer will include Min-SE header.
* If the generated answer is not sent, it must be destroyed.
* i.e: using #pjsip_tx_data_dec_ref(), to avoid resource leak.
*
* @param inv The UAS invite session.
* @param rdata The incoming request message.
* @param st_code The st_code contains the status code to be sent,
* which may be a provisional or final response.
* @param st_text If custom status text is desired, application can
* specify the text in st_text; otherwise if this
* argument is NULL, default status text will be used.
* @param sdp If application has specified its media capability
* during creation of UAS invite session, the sdp
* argument MUST be NULL. This is because application
* can not perform more than one SDP offer/answer session
* in a single INVITE transaction.
* If application has not specified its media capability
* during creation of UAS invite session, it MAY or MUST
* specify its capability in sdp argument,
* depending whether st_code indicates a 2xx final
* response.
* @param p_tdata Pointer to receive the response message created by
* this function.
*
* @return PJ_SUCCESS if response message was created
* successfully.
*/
PJ_DECL(pj_status_t) pjsip_inv_initial_answer( pjsip_inv_session *inv,
pjsip_rx_data *rdata,
Expand Down
35 changes: 30 additions & 5 deletions pjsip/include/pjsip/sip_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,25 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
#endif


/**
* The initial timeout interval for incoming TCP/TLS transports
* (i.e. server side) in the event that no valid SIP message is received
* following a successful connection. The value is in seconds.
* Disable the timeout by setting it to 0.
*
* Note that even if this is disabled, the connection might still get closed
* when it is idle or not referred anymore. Have a look at \a
* PJSIP_TRANSPORT_SERVER_IDLE_TIME.
*
* Notes:
* - keep-alive packet is not considered as a valid message.
*
* Default: 0
*/
#ifndef PJSIP_TRANSPORT_SERVER_IDLE_TIME_FIRST
# define PJSIP_TRANSPORT_SERVER_IDLE_TIME_FIRST 0
#endif

/**
* Maximum number of usages for a transport before a new transport is
* created. This only applies for ephemeral transports such as TCP.
Expand Down Expand Up @@ -786,14 +805,20 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)


/**
* Initial timeout interval to be applied to incoming transports (i.e. server
* side) when no data received after a successful connection. Value is in
* seconds. Disable the timeout by setting it to 0.
* The initial timeout interval for incoming TCP transports
* (i.e. server side) in the event that no valid SIP message is received
* following a successful connection. The value is in seconds.
* Disable the timeout by setting it to 0.
*
* Note that even when this is disable, the connection might still get closed
* Note that even if this is disabled, the connection might still get closed
* when it is idle or not referred anymore. Have a look at \a
* PJSIP_TRANSPORT_SERVER_IDLE_TIME
* PJSIP_TRANSPORT_SERVER_IDLE_TIME.
*
* Notes:
* - keep-alive packet is not considered as a valid message.
* - This macro is specific to TCP usage and takes precedence over
* a\ PJSIP_TRANSPORT_SERVER_IDLE_TIME_FIRST when both are set.
*
* Default: 0 (disabled)
*/
#ifndef PJSIP_TCP_INITIAL_TIMEOUT
Expand Down
3 changes: 2 additions & 1 deletion pjsip/include/pjsip/sip_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ PJ_DECL(pj_status_t) pjsip_dlg_create_response( pjsip_dialog *dlg,
*
* @param dlg The dialog.
* @param tdata The transmit data buffer containing response
* message to be modified.
* message to be modified. Upon successful return,
* the reference count will be incremented.
* @param st_code New status code to be set.
* @param st_text Optional string for custom status reason text.
*
Expand Down
15 changes: 15 additions & 0 deletions pjsip/include/pjsip/sip_transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,11 +410,26 @@ PJ_DECL(pj_status_t) pjsip_tsx_create_key( pj_pool_t *pool,
*
* @param tsx The transaction.
* @param code The status code to report.
*
* @return PJ_SUCCESS or the appropriate error code.
*/
PJ_DECL(pj_status_t) pjsip_tsx_terminate( pjsip_transaction *tsx,
int code );


/**
* Force terminate transaction asynchronously, using the transaction
* internal timer.
*
* @param tsx The transaction.
* @param code The status code to report.
*
* @return PJ_SUCCESS or the appropriate error code.
*/
PJ_DECL(pj_status_t) pjsip_tsx_terminate_async(pjsip_transaction *tsx,
int code );


/**
* Cease retransmission on the UAC transaction. The UAC transaction is
* still considered running, and it will complete when either final
Expand Down
5 changes: 5 additions & 0 deletions pjsip/include/pjsip/sip_transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,11 @@ struct pjsip_transport
pj_size_t last_recv_len; /**< Last received data length. */

void *data; /**< Internal transport data. */
unsigned initial_timeout;/**< Initial timeout interval
to be applied to incoming
TCP/TLS transports when no
valid data received after
a successful connection. */

/**
* Function to be called by transport manager to send SIP message.
Expand Down
3 changes: 2 additions & 1 deletion pjsip/include/pjsip/sip_transport_tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ typedef struct pjsip_tcp_transport_cfg

/**
* Intial timeout interval to be applied to incoming transports
* (i.e. server side) when no data received after a successful connection.
* (i.e. server side) when no valid data received after a successful
* connection.
*
* Default: PJSIP_TCP_INITIAL_TIMEOUT
*/
Expand Down
10 changes: 10 additions & 0 deletions pjsip/include/pjsip/sip_transport_tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,15 @@ typedef struct pjsip_tls_setting
*/
pj_time_val timeout;

/**
* Intial timeout interval to be applied to incoming transports
* (i.e. server side) when no valid data received after a successful
* connection.
*
* Default: PJSIP_TRANSPORT_SERVER_IDLE_TIME_FIRST
*/
unsigned initial_timeout;

/**
* Should SO_REUSEADDR be used for the listener socket.
* Default value is PJSIP_TLS_TRANSPORT_REUSEADDR.
Expand Down Expand Up @@ -437,6 +446,7 @@ PJ_INLINE(void) pjsip_tls_setting_default(pjsip_tls_setting *tls_opt)
tls_opt->sockopt_ignore_error = PJ_TRUE;
tls_opt->proto = PJSIP_SSL_DEFAULT_PROTO;
tls_opt->enable_renegotiation = PJ_TRUE;
tls_opt->initial_timeout = PJSIP_TRANSPORT_SERVER_IDLE_TIME_FIRST;
}


Expand Down
2 changes: 2 additions & 0 deletions pjsip/include/pjsua2/call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@ struct StreamInfo
dir(PJMEDIA_DIR_NONE),
txPt(0),
rxPt(0),
audTxEventPt(0),
audRxEventPt(0),
codecClockRate(0),
jbInit(-1),
jbMinPre(-1),
Expand Down
Loading

0 comments on commit 9336b96

Please sign in to comment.