Squashed 'external/toxcore/c-toxcore/' changes from 1701691d5..640e6cace

640e6cace fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff.
6f7f51554 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...)
5047ae5a2 chore: make the source tarball exhibit the old behavior
14804a4b8 chore: Fix sonar-scan CI action.
e2db7d946 cleanup: Exclude lan_discovery test from running on macos, instead of excluding it from the project.
3accade67 chore: Fix CI, disabling some tests that no longer run on CI.
ef8d767e6 cleanup: Fix comment formatting errors.
34ec822da cleanup: Fix some clang-19 format warnings.
40b3f0b46 refactor: Use clang's nullability qualifiers instead of attributes.
f81e30679 refactor: Use per-parameter nullability annotations.
REVERT: 1701691d5 chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...)
REVERT: a87505867 fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff.

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 640e6cace81b4412c45977b94eb9c41e53c54035
This commit is contained in:
Green Sky
2025-10-08 12:03:02 +02:00
parent ab12fbe820
commit 54c0a3c874
195 changed files with 3148 additions and 5495 deletions

View File

@@ -18,24 +18,24 @@
#include "network.h"
#include "shared_key_cache.h"
typedef int onion_recv_1_cb(void *object, const IP_Port *dest, const uint8_t *data, uint16_t length);
typedef int onion_recv_1_cb(void *_Nullable object, const IP_Port *_Nonnull dest, const uint8_t *_Nonnull data, uint16_t length);
typedef struct Onion {
const Logger *log;
const Mono_Time *mono_time;
const Random *rng;
const Memory *mem;
DHT *dht;
Networking_Core *net;
const Logger *_Nonnull log;
const Mono_Time *_Nonnull mono_time;
const Random *_Nonnull rng;
const Memory *_Nonnull mem;
DHT *_Nonnull dht;
Networking_Core *_Nonnull net;
uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE];
uint64_t timestamp;
Shared_Key_Cache *shared_keys_1;
Shared_Key_Cache *shared_keys_2;
Shared_Key_Cache *shared_keys_3;
Shared_Key_Cache *_Nonnull shared_keys_1;
Shared_Key_Cache *_Nonnull shared_keys_2;
Shared_Key_Cache *_Nonnull shared_keys_3;
onion_recv_1_cb *recv_1_function;
void *callback_object;
onion_recv_1_cb *_Nullable recv_1_function;
void *_Nullable callback_object;
} Onion;
#define ONION_MAX_PACKET_SIZE 1400
@@ -84,16 +84,14 @@ typedef struct Onion_Path {
* return -1 on failure.
* return 0 on success.
*/
non_null()
int create_onion_path(const Random *rng, const DHT *dht, Onion_Path *new_path, const Node_format *nodes);
int create_onion_path(const Random *_Nonnull rng, const DHT *_Nonnull dht, Onion_Path *_Nonnull new_path, const Node_format *_Nonnull nodes);
/** @brief Dump nodes in onion path to nodes of length num_nodes.
*
* return -1 on failure.
* return 0 on success.
*/
non_null()
int onion_path_to_nodes(Node_format *nodes, unsigned int num_nodes, const Onion_Path *path);
int onion_path_to_nodes(Node_format *_Nonnull nodes, unsigned int num_nodes, const Onion_Path *_Nonnull path);
/** @brief Create a onion packet.
*
@@ -104,10 +102,8 @@ int onion_path_to_nodes(Node_format *nodes, unsigned int num_nodes, const Onion_
* return -1 on failure.
* return length of created packet on success.
*/
non_null()
int create_onion_packet(const Memory *mem, const Random *rng, uint8_t *packet, uint16_t max_packet_length,
const Onion_Path *path, const IP_Port *dest,
const uint8_t *data, uint16_t length);
int create_onion_packet(const Memory *_Nonnull mem, const Random *_Nonnull rng, uint8_t *_Nonnull packet, uint16_t max_packet_length, const Onion_Path *_Nonnull path,
const IP_Port *_Nonnull dest, const uint8_t *_Nonnull data, uint16_t length);
/** @brief Create a onion packet to be sent over tcp.
*
@@ -118,10 +114,8 @@ int create_onion_packet(const Memory *mem, const Random *rng, uint8_t *packet, u
* return -1 on failure.
* return length of created packet on success.
*/
non_null()
int create_onion_packet_tcp(const Memory *mem, const Random *rng, uint8_t *packet, uint16_t max_packet_length,
const Onion_Path *path, const IP_Port *dest,
const uint8_t *data, uint16_t length);
int create_onion_packet_tcp(const Memory *_Nonnull mem, const Random *_Nonnull rng, uint8_t *_Nonnull packet, uint16_t max_packet_length, const Onion_Path *_Nonnull path,
const IP_Port *_Nonnull dest, const uint8_t *_Nonnull data, uint16_t length);
/** @brief Create and send a onion response sent initially to dest with.
* Maximum length of data is ONION_RESPONSE_MAX_DATA_SIZE.
@@ -129,10 +123,8 @@ int create_onion_packet_tcp(const Memory *mem, const Random *rng, uint8_t *packe
* return -1 on failure.
* return 0 on success.
*/
non_null()
int send_onion_response(const Logger *log, const Networking_Core *net,
const IP_Port *dest, const uint8_t *data, uint16_t length,
const uint8_t *ret);
int send_onion_response(const Logger *_Nonnull log, const Networking_Core *_Nonnull net, const IP_Port *_Nonnull dest, const uint8_t *_Nonnull data, uint16_t length,
const uint8_t *_Nonnull ret);
/** @brief Function to handle/send received decrypted versions of the packet created by create_onion_packet.
*
@@ -144,17 +136,11 @@ int send_onion_response(const Logger *log, const Networking_Core *net,
* Source family must be set to something else than TOX_AF_INET6 or TOX_AF_INET so that the callback gets called
* when the response is received.
*/
non_null()
int onion_send_1(const Onion *onion, const uint8_t *plain, uint16_t len, const IP_Port *source, const uint8_t *nonce);
int onion_send_1(const Onion *_Nonnull onion, const uint8_t *_Nonnull plain, uint16_t len, const IP_Port *_Nonnull source, const uint8_t *_Nonnull nonce);
/** Set the callback to be called when the dest ip_port doesn't have TOX_AF_INET6 or TOX_AF_INET as the family. */
non_null(1) nullable(2, 3)
void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object);
non_null()
Onion *new_onion(const Logger *log, const Memory *mem, const Mono_Time *mono_time, const Random *rng, DHT *dht);
nullable(1)
void kill_onion(Onion *onion);
void set_callback_handle_recv_1(Onion *_Nonnull onion, onion_recv_1_cb *_Nullable function, void *_Nullable object);
Onion *_Nullable new_onion(const Logger *_Nonnull log, const Memory *_Nonnull mem, const Mono_Time *_Nonnull mono_time, const Random *_Nonnull rng, DHT *_Nonnull dht);
void kill_onion(Onion *_Nullable onion);
#endif /* C_TOXCORE_TOXCORE_ONION_H */