Skip to content

Commit

Permalink
Merge upstream/master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CI Bot committed Nov 29, 2024
2 parents d9b4a53 + d2b0de1 commit b46314e
Show file tree
Hide file tree
Showing 32 changed files with 1,533 additions and 981 deletions.
2,219 changes: 1,328 additions & 891 deletions aconfigure

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion aconfigure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ AC_ARG_WITH(sdl,

dnl # Do not use default SDL installation if we are cross-compiling
if test "x$ac_cross_compile" != "x" -a "x$with_sdl" = "xno"; then
nable_sdl=no
enable_sdl=no
fi

dnl # SDL
Expand Down
2 changes: 1 addition & 1 deletion pjlib-util/src/pjlib-util-test/encryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ static void crc32_final(pj_crc32_context *ctx, pj_uint32_t *digest)
static void md5_update_wrapper(pj_md5_context *ctx,
unsigned char const *buf, pj_size_t len)
{
pj_md5_update(ctx, buf, len);
pj_md5_update(ctx, buf, (unsigned)len);
}

int encryption_benchmark()
Expand Down
6 changes: 4 additions & 2 deletions pjlib-util/src/pjlib-util-test/http_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ static int server_thread(void *p)
pkt_len = pj_ansi_snprintf(pkt, srv->buf_size,
"HTTP/1.0 200 OK\r\n");
PJ_ASSERT_ON_FAIL(pkt_len>0, {
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
PJ_LOG(2, (THIS_FILE, "Error creating response, pkt_len=%ld",
pkt_len));
pj_sock_close(newsock);
continue;
})
Expand All @@ -130,7 +131,8 @@ static int server_thread(void *p)
}
pkt_len = pj_ansi_strxcat(pkt, "\r\n", srv->buf_size);
if (pkt_len < 0) {
PJ_PERROR(2, (THIS_FILE, -pkt_len, "Error creating response"));
PJ_LOG(2, (THIS_FILE, "Error creating response 2, pkt_len=%ld",
pkt_len));
pj_sock_close(newsock);
continue;
}
Expand Down
2 changes: 0 additions & 2 deletions pjlib-util/src/pjlib-util/srv_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ struct common
pj_dns_type type; /**< Type of this structure.*/
};

#pragma pack(1)
struct srv_target
{
struct common common;
Expand All @@ -55,7 +54,6 @@ struct srv_target
unsigned addr_cnt;
pj_sockaddr addr[ADDR_MAX_COUNT];/**< Address family and IP.*/
};
#pragma pack()

struct pj_dns_srv_async_query
{
Expand Down
7 changes: 4 additions & 3 deletions pjlib/include/pj/unittest.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,17 @@ PJ_BEGIN_DECL
*/
#define PJ_TEST_BINARY_OP(expr0, op, expr1, err_reason, err_action) \
{ \
long tmp_value0_ = (long)(expr0); \
long tmp_value1_ = (long)(expr1); \
intptr_t tmp_value0_ = (intptr_t)(expr0); \
intptr_t tmp_value1_ = (intptr_t)(expr1); \
if (!(tmp_value0_ op tmp_value1_)) { \
const char *tmp_reason_ = err_reason; \
const char *sep0_ = (tmp_reason_ ? " (": ""); \
const char *sep1_ = (tmp_reason_ ? ")": ""); \
if (!tmp_reason_) tmp_reason_=""; \
PJ_LOG(1,(THIS_FILE, "Test \"%s\" (value=%ld) " #op \
" \"%s\" (value=%ld) fails in %s:%d%s%s%s", \
#expr0, tmp_value0_, #expr1, tmp_value1_, \
#expr0, (long)tmp_value0_, \
#expr1, (long)tmp_value1_, \
THIS_FILE, __LINE__, \
sep0_, tmp_reason_, sep1_)); \
err_action; \
Expand Down
3 changes: 2 additions & 1 deletion pjlib/src/pj/os_core_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ static void set_thread_display_name(const char *name)
PJ_LOG(5, (THIS_FILE, "SetThreadDescription:%p, name:%s", fn, name));
if (fn) {
wchar_t wname[PJ_MAX_OBJ_NAME];
pj_ansi_to_unicode(name, pj_ansi_strlen(name), wname, PJ_MAX_OBJ_NAME);
pj_ansi_to_unicode(name, (int)pj_ansi_strlen(name), wname,
PJ_MAX_OBJ_NAME);
fn(GetCurrentThread(), wname);
return;
}
Expand Down
8 changes: 4 additions & 4 deletions pjlib/src/pj/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,10 @@ PJ_DEF(int) pj_ansi_strxcpy(char *dst, const char *src,
}

if (!*dst && !*src) {
return dst-odst;
return (int)(dst-odst);
} else {
*dst = '\0';
return *src? -PJ_ETOOBIG : dst-odst;
return *src? -PJ_ETOOBIG : (int)(dst-odst);
}
}

Expand All @@ -665,7 +665,7 @@ PJ_DEF(int) pj_ansi_strxcpy2(char *dst, const pj_str_t *src,

*dst = '\0';
if (ssrc==esrc || !*ssrc) {
return dst-odst;
return (int)(dst-odst);
} else {
return -PJ_ETOOBIG;
}
Expand All @@ -685,7 +685,7 @@ PJ_DEF(int) pj_ansi_strxcat(char *dst, const char *src, pj_size_t dst_size)
int rc = pj_ansi_strxcpy(dst+dst_len, src, dst_size-dst_len);
if (rc < 0)
return rc;
return dst_len + rc;
return (int)dst_len + rc;
} else
return -PJ_ETOOBIG;
}
3 changes: 2 additions & 1 deletion pjlib/src/pj/unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ static const char *get_test_case_info(const pj_test_case *tc,
} else {
char arg_val[40];
/* treat argument as integer */
pj_ansi_snprintf(arg_val, sizeof(arg_val), "%ld", (long)tc->arg);
pj_ansi_snprintf(arg_val, sizeof(arg_val), "%ld",
(long)(intptr_t)tc->arg);

/* if arg value is too long (e.g. it's a pointer!), then just show
* a portion of it */
Expand Down
2 changes: 1 addition & 1 deletion pjlib/src/pjlib-test/fifobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int fifobuf_rolling_test()
int i, n;

/* Allocate random number of chunks */
n = N/2 + (pj_rand() % (N/2)) - pj_list_size(&chunks);
n = N/2 + (pj_rand() % (N/2)) - (int)pj_list_size(&chunks);
for (i=0; i<n; ++i) {
unsigned size = MIN_SIZE + (pj_rand() % (MAX_SIZE-MIN_SIZE));
chunk = (pj_list*)pj_fifobuf_alloc(&fifo, size);
Expand Down
3 changes: 3 additions & 0 deletions pjlib/src/pjlib-test/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ static char test_large_msg[PJ_LOG_MAX_SIZE];

static void log_write(int level, const char *buffer, int len)
{
PJ_UNUSED_ARG(level);
PJ_UNUSED_ARG(buffer);

log_written = len;
//printf("%s", buffer);
}
Expand Down
6 changes: 4 additions & 2 deletions pjlib/src/pjlib-test/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ static int do_sockpair_tst(int family, int type, int proto)
goto on_error;

/* sv[0] send text to sv[1] */
len = pj_ansi_snprintf(buf, sizeof(buf), "hello, %ld->%ld", sv[0], sv[1]);
len = pj_ansi_snprintf(buf, sizeof(buf), "hello, %ld->%ld",
(long)sv[0], (long)sv[1]);
rc = pj_sock_send(sv[0], buf, &len, 0);
if (rc != PJ_SUCCESS)
goto on_error;
Expand All @@ -879,7 +880,8 @@ static int do_sockpair_tst(int family, int type, int proto)
PJ_LOG(3, ("test", "recv: %.*s", (int)len, buf));

/* sv[1] send text to sv[0] */
len = pj_ansi_snprintf(buf, sizeof(buf), "hello, %ld->%ld", sv[1], sv[0]);
len = pj_ansi_snprintf(buf, sizeof(buf), "hello, %ld->%ld",
(long)sv[1], (long)sv[0]);
rc = pj_sock_send(sv[1], buf, &len, 0);
if (rc != PJ_SUCCESS)
goto on_error;
Expand Down
4 changes: 2 additions & 2 deletions pjlib/src/pjlib-test/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static int verify_strxcpy(const char *src, int dst_size, int exp_ret,
}

/* verify not writing pass buffer */
for (i=exp_dst?strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
for (i=exp_dst?(int)strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
if (dst[i] != GUARD) {
PJ_LOG(3,("", " strxcpy \"%s\", dst_size=%d: overflow at %d",
src, dst_size, i));
Expand Down Expand Up @@ -561,7 +561,7 @@ static int verify_strxcat(const char *cdst, const char *src, int dst_size,
}

/* verify not writing past buffer */
for (i=exp_dst?strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
for (i=exp_dst?(int)strlen(exp_dst)+1:0; i<(int)sizeof(dst); ++i) {
if (dst[i] != GUARD) {
PJ_LOG(3,("", " strxcat \"%s\", \"%s\", dst_size=%d: "
"overflow at %d",
Expand Down
22 changes: 11 additions & 11 deletions pjlib/src/pjlib-test/unittest_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ static void print_log_buffer(char *title)
/* This log callback appends the log to the log_buffer */
static void log_callback(int level, const char *data, int len)
{
int max_len = (log_buffer+sizeof(log_buffer))-log_buffer_ptr-1;
int max_len = (int)((log_buffer+sizeof(log_buffer))-log_buffer_ptr-1);

PJ_UNUSED_ARG(level);

/* make sure len is correct */
len = strlen(data);
len = (int)strlen(data);
if (len > max_len)
len = max_len;

Expand Down Expand Up @@ -237,7 +237,7 @@ enum test_flags
/** Dummy test */
static int func_to_test(void *arg)
{
unsigned flags = (unsigned)(long)arg;
unsigned flags = (unsigned)(intptr_t)arg;
unsigned test_id = (flags & 31);

/* Note that for simplicity, make the length of log messages the same
Expand Down Expand Up @@ -452,7 +452,7 @@ static int shuffle_test()
for (i=0; i<N; ++i) {
pj_ansi_snprintf(test_names[i], sizeof(test_names[i]), "test%02d", i);
pj_test_case_init(&tcs[i], test_names[i], 0,
&func_to_test, (void*)(long)i, NULL, 0, NULL);
&func_to_test, (void*)(intptr_t)i, NULL, 0, NULL);
}

/* Shuffle empty suite */
Expand Down Expand Up @@ -494,19 +494,19 @@ static int shuffle_test()
PJ_TEST_EQ(pj_list_size(&suite.tests), 6, seed_info, return -30);

tc = suite.tests.next;
PJ_TEST_EQ((long)tc->arg, 2, seed_info, return -40);
PJ_TEST_EQ(tc->arg, 2, seed_info, return -40);
tc = tc->next;
PJ_TEST_EQ((long)tc->arg, 5, seed_info, return -41);
PJ_TEST_EQ(tc->arg, 5, seed_info, return -41);
tc = tc->next;
PJ_TEST_TRUE((long)tc->arg==0 || (long)tc->arg==3, seed_info,
PJ_TEST_TRUE(tc->arg==0 || (intptr_t)tc->arg==3, seed_info,
return -42);
tc = tc->next;
PJ_TEST_TRUE((long)tc->arg==0 || (long)tc->arg==3, seed_info,
PJ_TEST_TRUE(tc->arg==0 || (intptr_t)tc->arg==3, seed_info,
return -43);
tc = tc->next;
PJ_TEST_EQ((long)tc->arg, 1, seed_info, return -44);
PJ_TEST_EQ(tc->arg, 1, seed_info, return -44);
tc = tc->next;
PJ_TEST_EQ((long)tc->arg, 4, seed_info, return -45);
PJ_TEST_EQ(tc->arg, 4, seed_info, return -45);
}

return 0;
Expand Down Expand Up @@ -638,7 +638,7 @@ int unittest_parallel_test()

int unittest_test(void)
{
int ret, log_level = pj_log_get_level();
int ret = 0, log_level = pj_log_get_level();
unsigned j;

if (pj_test_is_under_test()) {
Expand Down
2 changes: 1 addition & 1 deletion pjmedia/src/pjmedia/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ PJ_DEF(int) pjmedia_sdp_media_print(const pjmedia_sdp_media *media,
PJ_DEF(int) pjmedia_sdp_attr_print(const pjmedia_sdp_attr *attr,
char *buf, pj_size_t size)
{
return print_attr(attr, buf, size);
return (int)print_attr(attr, buf, size);
}

PJ_DEF(pjmedia_sdp_media*) pjmedia_sdp_media_clone(
Expand Down
35 changes: 27 additions & 8 deletions pjmedia/src/pjmedia/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,8 @@ static void create_dtmf_payload(pjmedia_stream *stream,
if (!pj_stricmp2(&stream->si.fmt.encoding_name, "opus")) {
ts_modifier = (float)48000 / stream->codec_param.info.clock_rate;
}
duration = ts_modifier * digit->send_duration * stream->codec_param.info.clock_rate / 1000;
duration = (unsigned)(ts_modifier * digit->send_duration *
stream->codec_param.info.clock_rate / 1000);
}
else
{
Expand Down Expand Up @@ -2003,7 +2004,11 @@ static void on_rx_rtp( pjmedia_tp_cb_param *param)
}
}

/* Add ref counter to avoid premature destroy from callbacks */
pj_grp_lock_add_ref(stream->grp_lock);

pj_bzero(&seq_st, sizeof(seq_st));

/* Ignore the packet if decoder is paused */
if (channel->paused) {
goto on_return;
Expand Down Expand Up @@ -2318,6 +2323,8 @@ static void on_rx_rtp( pjmedia_tp_cb_param *param)
stream->initial_rr = PJ_TRUE;
}
}

pj_grp_lock_dec_ref(stream->grp_lock);
}


Expand Down Expand Up @@ -2932,20 +2939,28 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
att_param.rtp_cb2 = &on_rx_rtp;
att_param.rtcp_cb = &on_rx_rtcp;

/* Attach handler to group lock from transport */
if (tp->grp_lock) {
stream->grp_lock = stream->port.grp_lock = tp->grp_lock;
pj_grp_lock_add_ref(stream->grp_lock);
pj_grp_lock_add_handler(stream->grp_lock, pool, stream,
&stream_on_destroy);
}
/* Create group lock & attach handler */
status = pj_grp_lock_create_w_handler(pool, NULL, stream,
&stream_on_destroy,
&stream->grp_lock);
if (status != PJ_SUCCESS)
goto err_cleanup;

/* Add ref */
pj_grp_lock_add_ref(stream->grp_lock);
stream->port.grp_lock = stream->grp_lock;

/* Only attach transport when stream is ready. */
stream->transport = tp;
status = pjmedia_transport_attach2(tp, &att_param);
if (status != PJ_SUCCESS)
goto err_cleanup;

/* Also add ref the transport group lock */
if (stream->transport->grp_lock)
pj_grp_lock_add_ref(stream->transport->grp_lock);


#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
/* Enable RTCP XR and update stream info/config to RTCP XR */
if (info->rtcp_xr_enabled) {
Expand Down Expand Up @@ -3109,6 +3124,10 @@ static void stream_on_destroy(void *arg)

/* This function may be called when stream is partly initialized. */

/* Release ref to transport */
if (stream->transport && stream->transport->grp_lock)
pj_grp_lock_dec_ref(stream->transport->grp_lock);

/* Free codec. */
if (stream->codec) {
pjmedia_codec_close(stream->codec);
Expand Down
13 changes: 13 additions & 0 deletions pjmedia/src/pjmedia/vid_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ static void on_rx_rtp( pjmedia_tp_cb_param *param)
return;
}

/* Add ref counter to avoid premature destroy from callbacks */
pj_grp_lock_add_ref(stream->grp_lock);

/* Ignore the packet if decoder is paused */
if (channel->paused)
goto on_return;
Expand Down Expand Up @@ -1042,6 +1045,8 @@ static void on_rx_rtp( pjmedia_tp_cb_param *param)
stream->initial_rr = PJ_TRUE;
}
}

pj_grp_lock_dec_ref(stream->grp_lock);
}


Expand Down Expand Up @@ -2058,6 +2063,10 @@ PJ_DEF(pj_status_t) pjmedia_vid_stream_create(

stream->transport = tp;

/* Also add ref the transport group lock */
if (stream->transport->grp_lock)
pj_grp_lock_add_ref(stream->transport->grp_lock);

/* Send RTCP SDES */
if (!stream->rtcp_sdes_bye_disabled) {
pjmedia_vid_stream_send_rtcp_sdes(stream);
Expand Down Expand Up @@ -2233,6 +2242,10 @@ static void on_destroy( void *arg )

PJ_LOG(4,(THIS_FILE, "Destroying %s..", stream->name.ptr));

/* Release ref to transport */
if (stream->transport && stream->transport->grp_lock)
pj_grp_lock_dec_ref(stream->transport->grp_lock);

/* Free codec. */
if (stream->codec) {
pjmedia_vid_codec_close(stream->codec);
Expand Down
9 changes: 5 additions & 4 deletions pjsip/src/pjsip-ua/sip_inv.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ static pj_status_t add_reason_warning_hdr(pjsip_tx_data *tdata,
pjsip_hdr *hdr;
const pj_str_t hname = { "Reason", 6 };
pj_str_t hvalue;
unsigned hval_len;
pj_size_t hval_len;

PJ_ASSERT_RETURN(tdata && reason && reason->slen >= 0, PJ_EINVAL);
PJ_ASSERT_RETURN(code < 1000, PJ_EINVAL);

hval_len = 3 + /* 'SIP' */
11 + /* ' ;cause=3-digit-code' */
reason->slen + 10; /* ' ;text=".."' */
hval_len = 3 + /* 'SIP' */
11 + /* ' ;cause=3-digit-code' */
(pj_size_t)reason->slen + 10; /* ' ;text=".."' */
hvalue.ptr = (char*)pj_pool_alloc(tdata->pool, hval_len);
if (!hvalue.ptr)
return PJ_ENOMEM;
Expand Down
Loading

0 comments on commit b46314e

Please sign in to comment.