From 0ef493b93dca8d72bcc1493b6af2e019c65856e3 Mon Sep 17 00:00:00 2001 From: zoff99 <6833516+zoff99@users.noreply.github.com> Date: Tue, 17 Sep 2024 01:13:52 +0000 Subject: [PATCH] toxcore amalgamation --- toxcore/toxcore_amalgamation.c | 41 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/toxcore/toxcore_amalgamation.c b/toxcore/toxcore_amalgamation.c index d21632e..b3daba6 100644 --- a/toxcore/toxcore_amalgamation.c +++ b/toxcore/toxcore_amalgamation.c @@ -18078,8 +18078,8 @@ deadline parameter analogous to VPx BEST QUALITY mode. */ // initialize encoder with this value. Target bandwidth to use for this stream, in kilobits per second. -#define VIDEO_BITRATE_INITIAL_VALUE 1000 -#define VIDEO_BITRATE_INITIAL_VALUE_VP9 1000 +#define VIDEO_BITRATE_INITIAL_VALUE 180 +#define VIDEO_BITRATE_INITIAL_VALUE_VP9 180 struct vpx_frame_user_data { uint64_t record_timestamp; @@ -75459,22 +75459,24 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length, boo header.flags |= RTP_KEY_FRAME; } - VLA(uint8_t, rdata, length + RTP_HEADER_SIZE + 1); - memset(rdata, 0, SIZEOF_VLA(rdata)); - rdata[0] = session->payload_type; // packet id == payload_type + uint8_t rdata_buf[MAX_CRYPTO_DATA_SIZE]; + memset(rdata_buf, 0, MAX_CRYPTO_DATA_SIZE); - if (MAX_CRYPTO_DATA_SIZE > (length + RTP_HEADER_SIZE + 1)) { + rdata_buf[0] = session->payload_type; // packet id == payload_type + LOGGER_API_DEBUG(session->tox, "check encoded video packet:length=%d MAX_CRYPTO_DATA_SIZE=%d", length, MAX_CRYPTO_DATA_SIZE); + + if ((length + RTP_HEADER_SIZE + 1) <= MAX_CRYPTO_DATA_SIZE) { /** - * The length is less than the maximum allowed length (including header) + * The length is less or equal than the maximum allowed length (including header) * Send the packet in single piece. */ header.rtp_packet_number = session->rtp_packet_num; session->rtp_packet_num++; - rtp_header_pack(rdata + 1, &header); - memcpy(rdata + 1 + RTP_HEADER_SIZE, data, length); + rtp_header_pack(rdata_buf + 1, &header); + memcpy(rdata_buf + 1 + RTP_HEADER_SIZE, data, length); - if (rtp_send_custom_lossy_packet(session->tox, session->friend_number, rdata, SIZEOF_VLA(rdata)) == -1) { - LOGGER_API_DEBUG(session->tox, "RTP send failed (len: %zu)! std error: %s", SIZEOF_VLA(rdata), strerror(errno)); + if (rtp_send_custom_lossy_packet(session->tox, session->friend_number, rdata_buf, length + RTP_HEADER_SIZE + 1) == -1) { + LOGGER_API_DEBUG(session->tox, "RTP send failed (len: %d)! std error: %s", (length + RTP_HEADER_SIZE + 1), strerror(errno)); } } else { /** @@ -75484,14 +75486,14 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length, boo uint32_t sent = 0; uint16_t piece = MAX_CRYPTO_DATA_SIZE - (RTP_HEADER_SIZE + 1); - while ((length - sent) + RTP_HEADER_SIZE + 1 > MAX_CRYPTO_DATA_SIZE) { + while (((length - sent) + RTP_HEADER_SIZE + 1) > MAX_CRYPTO_DATA_SIZE) { header.rtp_packet_number = session->rtp_packet_num; session->rtp_packet_num++; - rtp_header_pack(rdata + 1, &header); - memcpy(rdata + 1 + RTP_HEADER_SIZE, data + sent, piece); + rtp_header_pack(rdata_buf + 1, &header); + memcpy(rdata_buf + 1 + RTP_HEADER_SIZE, data + sent, piece); if (rtp_send_custom_lossy_packet(session->tox, session->friend_number, - rdata, piece + RTP_HEADER_SIZE + 1) == -1) { + rdata_buf, piece + RTP_HEADER_SIZE + 1) == -1) { LOGGER_API_DEBUG(session->tox, "RTP send failed (len: %d)! std error: %s", piece + RTP_HEADER_SIZE + 1, strerror(errno)); } @@ -75504,12 +75506,13 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length, boo piece = length - sent; if (piece) { + memset(rdata_buf, 0, MAX_CRYPTO_DATA_SIZE); header.rtp_packet_number = session->rtp_packet_num; session->rtp_packet_num++; - rtp_header_pack(rdata + 1, &header); - memcpy(rdata + 1 + RTP_HEADER_SIZE, data + sent, piece); + rtp_header_pack(rdata_buf + 1, &header); + memcpy(rdata_buf + 1 + RTP_HEADER_SIZE, data + sent, piece); - if (rtp_send_custom_lossy_packet(session->tox, session->friend_number, rdata, + if (rtp_send_custom_lossy_packet(session->tox, session->friend_number, rdata_buf, piece + RTP_HEADER_SIZE + 1) == -1) { LOGGER_API_DEBUG(session->tox, "RTP send failed (len: %d)! std error: %s", piece + RTP_HEADER_SIZE + 1, strerror(errno)); @@ -83761,6 +83764,7 @@ int vc_reconfigure_encoder_vpx(Logger *log, VCSession *vc, uint32_t bit_rate, // LOGGER_DEBUG(vc->log, "bitrate change from: %u to: %u", (uint32_t)(cfg2.rc_target_bitrate / 1000), // (uint32_t)(bit_rate / 1000)); + // VP8 needs this in kilobits per second! cfg2.rc_target_bitrate = (bit_rate / 1000); rc = vpx_codec_enc_config_set(vc->encoder, &cfg2); @@ -83794,6 +83798,7 @@ int vc_reconfigure_encoder_vpx(Logger *log, VCSession *vc, uint32_t bit_rate, vc->video_rc_min_quantizer_prev = vc->video_rc_min_quantizer; vc->video_keyframe_method_prev = vc->video_keyframe_method; + // VP8 needs this in kilobits per second! cfg.rc_target_bitrate = (bit_rate / 1000); cfg.g_w = width; cfg.g_h = height;