Squashed 'external/toxcore/c-toxcore/' changes from 11ab1d2a723..d9b8fa6098d

d9b8fa6098d fix: Fake broadcast address for 127.x.x.x
aa649165a57 chore: Add code for future netprof TCP testing
9e5693de5ac chore: add to_string functions for netprof enums
52d915e6a90 cleanup: Heap allocate network profile objects
80fabd4a729 feat: Implement Tox network profiler
05abe083cb6 cleanup: Some random cleanups, mostly related to mem.
5cca24513b8 cleanup: Check that onion IP/Port packing worked.
e092ecd1244 cleanup: Use tox memory allocator in some more places.
3cfe41c7587 fix: Avoid `memcpy`-ing structs into onion ping id data.
e32ac001938 fix: Add more information on why the frame was not sent.
ab887003687 fix: Allow TCP connections to fail `connect` calls.
7603170e663 refactor: Use tox memory in group connection allocations.
5bd8a85eb89 cleanup: Align internal logger with external on type of source line.
e9bf524d9e1 cleanup: Add missing `#include` to sort_test.cc.
d10c966b998 feat: Add `to_string` functions for toxencryptsave errors.
7bfd0dc8003 docs: Update the docs for group join functions
380dde9f2ae test: Add more logging to TCP connection constructor.
0f12f384c8c cleanup: Reduce stack frame sizes to below 4096 bytes.
bc43cec0626 chore: Happy new year!
fbe78f1702e cleanup: Add a `TOX_HIDE_DEPRECATED` check to hide deprecated symbols.
44d9da07e77 refactor: Use tox memory for group moderation/pack allocations.
7f26d520168 refactor: Use tox memory in group chats allocations.
2f62f3d0e77 refactor: Use tox Memory for group allocations.
8a968162041 chore: Add dispatch/events headers to bazel export.
2bbfb35abf6 docs: Output the error code string instead of int. in toxav logging
d55d0e4eaef cleanup: Remove redundant code for checking if group exists
2a6dc643338 chore: Upgrade dependencies for websockify.
fc0650601c1 fix: Allow peers to reconnect to group chats using a password

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: d9b8fa6098de6c074038b6664d2572627540b148
This commit is contained in:
Green Sky
2025-01-18 15:53:06 +01:00
parent 261d2e53b7
commit 3b6bb15e86
213 changed files with 2341 additions and 758 deletions

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "audio.h"
@ -195,7 +195,7 @@ void ac_iterate(ACSession *ac)
free(temp_audio_buffer);
}
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
int ac_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
{
ACSession *ac = (ACSession *)cs;

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_AUDIO_H
@ -67,7 +67,7 @@ ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t f
toxav_audio_receive_frame_cb *cb, void *cb_data);
void ac_kill(ACSession *ac);
void ac_iterate(ACSession *ac);
int ac_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int ac_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int ac_reconfigure_encoder(ACSession *ac, uint32_t bit_rate, uint32_t sampling_rate, uint8_t channels);
#endif /* C_TOXCORE_TOXAV_AUDIO_H */

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "bwcontroller.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_BWCONTROLLER_H

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2014 Tox project.
*/
#include "groupav.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2014 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_GROUPAV_H

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "msi.h"

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_MSI_H

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013 Tox project.
* Copyright © 2013 plutooo
*/

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013 Tox project.
* Copyright © 2013 plutooo
*/

View File

@ -1,11 +1,10 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "rtp.h"
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -768,22 +767,35 @@ void rtp_stop_receiving(Tox *tox)
tox_callback_friend_lossy_packet_per_pktid(tox, nullptr, RTP_TYPE_VIDEO);
}
/**
* Log the neterror error if any.
*
* @param error the error from rtp_send_custom_lossy_packet.
* @param rdata_size The package length to be shown in the log.
*/
static void rtp_report_error_maybe(const Logger *log, Tox_Err_Friend_Custom_Packet error, uint16_t rdata_size)
{
if (error != TOX_ERR_FRIEND_CUSTOM_PACKET_OK) {
char *netstrerror = net_new_strerror(net_error());
const char *toxerror = tox_err_friend_custom_packet_to_string(error);
LOGGER_WARNING(log, "RTP send failed (len: %u)! tox error: %s net error: %s",
rdata_size, toxerror, netstrerror);
net_kill_strerror(netstrerror);
}
}
static void rtp_send_piece(const Logger *log, Tox *tox, uint32_t friend_number, const struct RTPHeader *header,
const uint8_t *data, uint8_t *rdata, uint16_t length)
{
rtp_header_pack(rdata + 1, header);
memcpy(rdata + 1 + RTP_HEADER_SIZE, data, length);
Tox_Err_Friend_Custom_Packet error;
tox_friend_send_lossy_packet(tox, friend_number,
rdata, length + RTP_HEADER_SIZE + 1, &error);
const uint16_t rdata_size = length + RTP_HEADER_SIZE + 1;
if (error != TOX_ERR_FRIEND_CUSTOM_PACKET_OK) {
char *netstrerror = net_new_strerror(net_error());
LOGGER_WARNING(log, "RTP send failed (len: %d)! tox error: %d, net error: %s",
length + RTP_HEADER_SIZE + 1, error, netstrerror);
net_kill_strerror(netstrerror);
}
Tox_Err_Friend_Custom_Packet error;
tox_friend_send_lossy_packet(tox, friend_number, rdata, rdata_size, &error);
rtp_report_error_maybe(log, error, rdata_size);
}
static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t length, bool is_keyframe)
@ -811,7 +823,7 @@ static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t l
header.ma = 0;
header.pt = session->payload_type % 128;
header.sequnum = session->sequnum;
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
const Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
if (mt != nullptr) {
header.timestamp = current_time_monotonic(mt);
} else {

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_RTP_H
@ -147,7 +147,7 @@ struct RTPWorkBufferList {
#define DISMISS_FIRST_LOST_VIDEO_PACKET_COUNT 10
typedef int rtp_m_cb(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
typedef int rtp_m_cb(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
/**
* RTP control session.

View File

@ -1,11 +1,10 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "toxav.h"
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
@ -21,7 +20,7 @@
#include "../toxcore/network.h"
#include "../toxcore/tox.h"
#include "../toxcore/tox_private.h"
#include "../toxcore/tox_struct.h"
#include "../toxcore/tox_struct.h" // IWYU pragma: keep
#include "../toxcore/util.h"
// TODO(zoff99): don't hardcode this, let the application choose it
@ -342,7 +341,7 @@ uint32_t toxav_iteration_interval(const ToxAV *av)
* @param frame_time the duration of the current frame in ms
* @param start_time the timestamp when decoding of this frame started
*/
static void calc_interval(ToxAV *av, DecodeTimeStats *stats, int32_t frame_time, uint64_t start_time)
static void calc_interval(const ToxAV *av, DecodeTimeStats *stats, int32_t frame_time, uint64_t start_time)
{
stats->interval = frame_time < stats->average ? 0 : (frame_time - stats->average);
stats->total += current_time_monotonic(av->toxav_mono_time) - start_time;

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2024 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_HACKS_H

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#include "video.h"
@ -8,14 +8,12 @@
#include <stdlib.h>
#include <string.h>
#include "msi.h"
#include "ring_buffer.h"
#include "rtp.h"
#include "../toxcore/ccompat.h"
#include "../toxcore/logger.h"
#include "../toxcore/mono_time.h"
#include "../toxcore/network.h"
/**
* Soft deadline the decoder should attempt to meet, in "us" (microseconds).
@ -143,7 +141,7 @@ static void vc_init_encoder_cfg(const Logger *log, vpx_codec_enc_cfg_t *cfg, int
#endif /* 0 */
}
VCSession *vc_new(const Logger *log, Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
VCSession *vc_new(const Logger *log, const Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
toxav_video_receive_frame_cb *cb, void *cb_data)
{
VCSession *vc = (VCSession *)calloc(1, sizeof(VCSession));
@ -346,7 +344,7 @@ void vc_iterate(VCSession *vc)
}
}
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
int vc_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg)
{
VCSession *vc = (VCSession *)cs;

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2016-2018 The TokTok team.
* Copyright © 2016-2025 The TokTok team.
* Copyright © 2013-2015 Tox project.
*/
#ifndef C_TOXCORE_TOXAV_VIDEO_H
@ -44,11 +44,11 @@ typedef struct VCSession {
const Logger *log;
} VCSession;
VCSession *vc_new(const Logger *log, Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
VCSession *vc_new(const Logger *log, const Mono_Time *mono_time, ToxAV *av, uint32_t friend_number,
toxav_video_receive_frame_cb *cb, void *cb_data);
void vc_kill(VCSession *vc);
void vc_iterate(VCSession *vc);
int vc_queue_message(Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int vc_queue_message(const Mono_Time *mono_time, void *cs, struct RTPMessage *msg);
int vc_reconfigure_encoder(VCSession *vc, uint32_t bit_rate, uint16_t width, uint16_t height, int16_t kf_max_dist);
#endif /* C_TOXCORE_TOXAV_VIDEO_H */