2023-07-25 11:53:09 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
* Copyright © 2016-2018 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>
|
|
|
|
|
|
|
|
#include "msi.h"
|
|
|
|
#include "rtp.h"
|
2024-11-09 13:44:30 +01:00
|
|
|
#include "toxav_hacks.h"
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
#include "../toxcore/ccompat.h"
|
|
|
|
#include "../toxcore/logger.h"
|
|
|
|
#include "../toxcore/mono_time.h"
|
2024-11-09 13:44:30 +01:00
|
|
|
#include "../toxcore/net_crypto.h"
|
|
|
|
#include "../toxcore/network.h"
|
|
|
|
#include "../toxcore/tox.h"
|
|
|
|
#include "../toxcore/tox_private.h"
|
2023-07-25 11:53:09 +02:00
|
|
|
#include "../toxcore/tox_struct.h"
|
|
|
|
#include "../toxcore/util.h"
|
|
|
|
|
|
|
|
// TODO(zoff99): don't hardcode this, let the application choose it
|
|
|
|
// VPX Info: Time to spend encoding, in microseconds (it's a *soft* deadline)
|
|
|
|
#define WANTED_MAX_ENCODER_FPS 40
|
|
|
|
#define MAX_ENCODE_TIME_US (1000000 / WANTED_MAX_ENCODER_FPS) // to allow x fps
|
|
|
|
|
|
|
|
#define VIDEO_SEND_X_KEYFRAMES_FIRST 7 // force the first n frames to be keyframes!
|
|
|
|
|
|
|
|
/*
|
|
|
|
* VPX_DL_REALTIME (1) deadline parameter analogous to VPx REALTIME mode.
|
|
|
|
* VPX_DL_GOOD_QUALITY (1000000) deadline parameter analogous to VPx GOOD QUALITY mode.
|
|
|
|
* VPX_DL_BEST_QUALITY (0) deadline parameter analogous to VPx BEST QUALITY mode.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// iteration interval that is used when no call is active
|
|
|
|
#define IDLE_ITERATION_INTERVAL_MS 200
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
#ifndef TOXAV_CALL_DEFINED
|
|
|
|
#define TOXAV_CALL_DEFINED
|
|
|
|
typedef struct ToxAVCall ToxAVCall;
|
|
|
|
#endif /* TOXAV_CALL_DEFINED */
|
|
|
|
|
|
|
|
struct ToxAVCall {
|
2023-07-25 11:53:09 +02:00
|
|
|
ToxAV *av;
|
|
|
|
|
|
|
|
pthread_mutex_t mutex_audio[1];
|
|
|
|
RTPSession *audio_rtp;
|
|
|
|
ACSession *audio;
|
|
|
|
|
|
|
|
pthread_mutex_t mutex_video[1];
|
|
|
|
RTPSession *video_rtp;
|
|
|
|
VCSession *video;
|
|
|
|
|
|
|
|
BWController *bwc;
|
|
|
|
|
|
|
|
bool active;
|
|
|
|
MSICall *msi_call;
|
|
|
|
uint32_t friend_number;
|
|
|
|
|
|
|
|
uint32_t audio_bit_rate; /* Sending audio bit rate */
|
|
|
|
uint32_t video_bit_rate; /* Sending video bit rate */
|
|
|
|
|
|
|
|
/** Required for monitoring changes in states */
|
|
|
|
uint8_t previous_self_capabilities;
|
|
|
|
|
|
|
|
pthread_mutex_t toxav_call_mutex[1];
|
|
|
|
|
|
|
|
struct ToxAVCall *prev;
|
|
|
|
struct ToxAVCall *next;
|
2024-11-09 13:44:30 +01:00
|
|
|
};
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
/** Decode time statistics */
|
|
|
|
typedef struct DecodeTimeStats {
|
|
|
|
/** Measure count */
|
|
|
|
int32_t count;
|
|
|
|
/** Last cycle total */
|
|
|
|
int32_t total;
|
|
|
|
/** Average decoding time in ms */
|
|
|
|
int32_t average;
|
|
|
|
|
|
|
|
/** Calculated iteration interval */
|
|
|
|
uint32_t interval;
|
|
|
|
} DecodeTimeStats;
|
|
|
|
|
|
|
|
struct ToxAV {
|
2024-11-09 13:44:30 +01:00
|
|
|
Logger *log;
|
2023-07-25 11:53:09 +02:00
|
|
|
Tox *tox;
|
|
|
|
MSISession *msi;
|
|
|
|
|
|
|
|
/* Two-way storage: first is array of calls and second is list of calls with head and tail */
|
|
|
|
ToxAVCall **calls;
|
|
|
|
uint32_t calls_tail;
|
|
|
|
uint32_t calls_head;
|
|
|
|
pthread_mutex_t mutex[1];
|
|
|
|
|
|
|
|
/* Call callback */
|
|
|
|
toxav_call_cb *ccb;
|
|
|
|
void *ccb_user_data;
|
|
|
|
/* Call state callback */
|
|
|
|
toxav_call_state_cb *scb;
|
|
|
|
void *scb_user_data;
|
|
|
|
/* Audio frame receive callback */
|
|
|
|
toxav_audio_receive_frame_cb *acb;
|
|
|
|
void *acb_user_data;
|
|
|
|
/* Video frame receive callback */
|
|
|
|
toxav_video_receive_frame_cb *vcb;
|
|
|
|
void *vcb_user_data;
|
|
|
|
/* Bit rate control callback */
|
|
|
|
toxav_audio_bit_rate_cb *abcb;
|
|
|
|
void *abcb_user_data;
|
|
|
|
/* Bit rate control callback */
|
|
|
|
toxav_video_bit_rate_cb *vbcb;
|
|
|
|
void *vbcb_user_data;
|
|
|
|
|
|
|
|
/* keep track of decode times for audio and video */
|
|
|
|
DecodeTimeStats audio_stats;
|
|
|
|
DecodeTimeStats video_stats;
|
2024-11-09 13:44:30 +01:00
|
|
|
|
|
|
|
Mono_Time *toxav_mono_time; // ToxAV's own mono_time instance
|
2023-07-25 11:53:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data);
|
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_invite(void *object, MSICall *call);
|
|
|
|
static int callback_start(void *object, MSICall *call);
|
|
|
|
static int callback_end(void *object, MSICall *call);
|
|
|
|
static int callback_error(void *object, MSICall *call);
|
|
|
|
static int callback_capabilites(void *object, MSICall *call);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
static bool audio_bit_rate_invalid(uint32_t bit_rate);
|
|
|
|
static bool video_bit_rate_invalid(uint32_t bit_rate);
|
|
|
|
static bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t state);
|
|
|
|
static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error);
|
|
|
|
static ToxAVCall *call_remove(ToxAVCall *call);
|
|
|
|
static bool call_prepare_transmission(ToxAVCall *call);
|
|
|
|
static void call_kill_transmission(ToxAVCall *call);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
MSISession *tox_av_msi_get(const ToxAV *av)
|
|
|
|
{
|
|
|
|
if (av == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return av->msi;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToxAVCall *call_get(ToxAV *av, uint32_t friend_number)
|
|
|
|
{
|
|
|
|
if (av == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Assumes mutex locked */
|
|
|
|
if (av->calls == nullptr || av->calls_tail < friend_number) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return av->calls[friend_number];
|
|
|
|
}
|
|
|
|
|
|
|
|
RTPSession *rtp_session_get(ToxAVCall *call, int payload_type)
|
|
|
|
{
|
|
|
|
if (call == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (payload_type == RTP_TYPE_VIDEO) {
|
|
|
|
return call->video_rtp;
|
|
|
|
} else {
|
|
|
|
return call->audio_rtp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BWController *bwc_controller_get(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if (call == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return call->bwc;
|
|
|
|
}
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
/**
|
|
|
|
* @brief initialize d with default values
|
|
|
|
* @param d struct to be initialized, must not be nullptr
|
|
|
|
*/
|
|
|
|
static void init_decode_time_stats(DecodeTimeStats *d)
|
|
|
|
{
|
|
|
|
assert(d != nullptr);
|
|
|
|
d->count = 0;
|
|
|
|
d->total = 0;
|
|
|
|
d->average = 0;
|
|
|
|
d->interval = IDLE_ITERATION_INTERVAL_MS;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToxAV *toxav_new(Tox *tox, Toxav_Err_New *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_New rc = TOXAV_ERR_NEW_OK;
|
|
|
|
ToxAV *av = nullptr;
|
|
|
|
|
|
|
|
if (tox == nullptr) {
|
|
|
|
rc = TOXAV_ERR_NEW_NULL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
av = (ToxAV *)calloc(1, sizeof(ToxAV));
|
|
|
|
|
|
|
|
if (av == nullptr) {
|
|
|
|
rc = TOXAV_ERR_NEW_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create_recursive_mutex(av->mutex) != 0) {
|
|
|
|
rc = TOXAV_ERR_NEW_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
av->log = tox->m->log;
|
2023-07-25 11:53:09 +02:00
|
|
|
av->tox = tox;
|
2024-11-09 13:44:30 +01:00
|
|
|
av->msi = msi_new(av->log, av->tox);
|
|
|
|
|
|
|
|
rtp_allow_receiving(av->tox);
|
|
|
|
bwc_allow_receiving(av->tox);
|
|
|
|
|
2023-10-10 19:37:39 +02:00
|
|
|
av->toxav_mono_time = mono_time_new(tox->sys.mem, nullptr, nullptr);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (av->msi == nullptr) {
|
|
|
|
pthread_mutex_destroy(av->mutex);
|
|
|
|
rc = TOXAV_ERR_NEW_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_decode_time_stats(&av->audio_stats);
|
|
|
|
init_decode_time_stats(&av->video_stats);
|
|
|
|
av->msi->av = av;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
// save ToxAV object into toxcore
|
|
|
|
tox_set_av_object(av->tox, av);
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_callback_invite(av->msi, callback_invite);
|
|
|
|
msi_callback_start(av->msi, callback_start);
|
|
|
|
msi_callback_end(av->msi, callback_end);
|
|
|
|
msi_callback_error(av->msi, callback_error);
|
|
|
|
msi_callback_peertimeout(av->msi, callback_error);
|
|
|
|
msi_callback_capabilities(av->msi, callback_capabilites);
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc != TOXAV_ERR_NEW_OK) {
|
2024-11-09 13:44:30 +01:00
|
|
|
if (av != nullptr) {
|
|
|
|
free(av);
|
|
|
|
av = nullptr;
|
|
|
|
}
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return av;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_kill(ToxAV *av)
|
|
|
|
{
|
|
|
|
if (av == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
// unregister callbacks
|
|
|
|
for (uint8_t i = PACKET_ID_RANGE_LOSSY_AV_START; i <= PACKET_ID_RANGE_LOSSY_AV_END; ++i) {
|
|
|
|
tox_callback_friend_lossy_packet_per_pktid(av->tox, nullptr, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
rtp_stop_receiving(av->tox);
|
|
|
|
bwc_stop_receiving(av->tox);
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
/* To avoid possible deadlocks */
|
2024-11-09 13:44:30 +01:00
|
|
|
while (av->msi != nullptr && msi_kill(av->log, av->tox, av->msi) != 0) {
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Msi kill will hang up all calls so just clean these calls */
|
|
|
|
if (av->calls != nullptr) {
|
|
|
|
ToxAVCall *it = call_get(av, av->calls_head);
|
|
|
|
|
|
|
|
while (it != nullptr) {
|
|
|
|
call_kill_transmission(it);
|
|
|
|
it->msi_call = nullptr; /* msi_kill() frees the call's msi_call handle; which causes #278 */
|
|
|
|
it = call_remove(it); /* This will eventually free av->calls */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-10 19:37:39 +02:00
|
|
|
mono_time_free(av->tox->sys.mem, av->toxav_mono_time);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
pthread_mutex_destroy(av->mutex);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
// set ToxAV object to NULL in toxcore, to signal ToxAV has been shutdown
|
|
|
|
tox_set_av_object(av->tox, nullptr);
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
free(av);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
Tox *toxav_get_tox(const ToxAV *av)
|
|
|
|
{
|
|
|
|
return av->tox;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
const Logger *toxav_get_logger(const ToxAV *av)
|
|
|
|
{
|
|
|
|
return av->log;
|
|
|
|
}
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
uint32_t toxav_audio_iteration_interval(const ToxAV *av)
|
|
|
|
{
|
|
|
|
return av->calls != nullptr ? av->audio_stats.interval : IDLE_ITERATION_INTERVAL_MS;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t toxav_video_iteration_interval(const ToxAV *av)
|
|
|
|
{
|
|
|
|
return av->calls != nullptr ? av->video_stats.interval : IDLE_ITERATION_INTERVAL_MS;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t toxav_iteration_interval(const ToxAV *av)
|
|
|
|
{
|
|
|
|
return min_u32(toxav_audio_iteration_interval(av),
|
|
|
|
toxav_video_iteration_interval(av));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief calc_interval Calculates the needed iteration interval based on previous decode times
|
|
|
|
* @param av ToxAV struct to work on
|
|
|
|
* @param stats Statistics to update
|
|
|
|
* @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)
|
|
|
|
{
|
|
|
|
stats->interval = frame_time < stats->average ? 0 : (frame_time - stats->average);
|
2024-11-09 13:44:30 +01:00
|
|
|
stats->total += current_time_monotonic(av->toxav_mono_time) - start_time;
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (++stats->count == 3) {
|
2024-11-09 13:44:30 +01:00
|
|
|
/* NOTE: Magic Offset for precision */
|
|
|
|
stats->average = stats->total / 3 + 5;
|
2023-07-25 11:53:09 +02:00
|
|
|
stats->count = 0;
|
|
|
|
stats->total = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief common iterator function for audio and video calls
|
|
|
|
* @param av pointer to ToxAV structure of current instance
|
|
|
|
* @param audio if true, iterate audio, video else
|
|
|
|
*/
|
|
|
|
static void iterate_common(ToxAV *av, bool audio)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
|
|
|
if (av->calls == nullptr) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint64_t start = current_time_monotonic(av->toxav_mono_time);
|
|
|
|
int32_t frame_time = IDLE_ITERATION_INTERVAL_MS;
|
|
|
|
|
|
|
|
for (ToxAVCall *i = av->calls[av->calls_head]; i != nullptr; i = i->next) {
|
|
|
|
if (!i->active) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(i->toxav_call_mutex);
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
const uint32_t fid = i->friend_number;
|
|
|
|
const bool is_offline = check_peer_offline_status(av->log, av->tox, i->msi_call->session, fid);
|
|
|
|
|
|
|
|
if (is_offline) {
|
|
|
|
pthread_mutex_unlock(i->toxav_call_mutex);
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
if (audio) {
|
|
|
|
ac_iterate(i->audio);
|
|
|
|
|
|
|
|
if ((i->msi_call->self_capabilities & MSI_CAP_R_AUDIO) != 0 &&
|
|
|
|
(i->msi_call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {
|
|
|
|
frame_time = min_s32(i->audio->lp_frame_duration, frame_time);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vc_iterate(i->video);
|
|
|
|
|
|
|
|
if ((i->msi_call->self_capabilities & MSI_CAP_R_VIDEO) != 0 &&
|
|
|
|
(i->msi_call->peer_capabilities & MSI_CAP_S_VIDEO) != 0) {
|
|
|
|
pthread_mutex_lock(i->video->queue_mutex);
|
|
|
|
frame_time = min_s32(i->video->lcfd, frame_time);
|
|
|
|
pthread_mutex_unlock(i->video->queue_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(i->toxav_call_mutex);
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
|
|
|
/* In case this call is popped from container stop iteration */
|
|
|
|
if (call_get(av, fid) != i) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DecodeTimeStats *stats = audio ? &av->audio_stats : &av->video_stats;
|
|
|
|
calc_interval(av, stats, frame_time, start);
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_audio_iterate(ToxAV *av)
|
|
|
|
{
|
|
|
|
iterate_common(av, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void toxav_video_iterate(ToxAV *av)
|
|
|
|
{
|
|
|
|
iterate_common(av, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void toxav_iterate(ToxAV *av)
|
|
|
|
{
|
|
|
|
toxav_audio_iterate(av);
|
|
|
|
toxav_video_iterate(av);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
|
|
|
|
Toxav_Err_Call *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_Call rc = TOXAV_ERR_CALL_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
|
|
|
if ((audio_bit_rate != 0 && audio_bit_rate_invalid(audio_bit_rate))
|
|
|
|
|| (video_bit_rate != 0 && video_bit_rate_invalid(video_bit_rate))) {
|
|
|
|
rc = TOXAV_ERR_CALL_INVALID_BIT_RATE;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = call_new(av, friend_number, &rc);
|
|
|
|
|
|
|
|
if (call == nullptr) {
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->audio_bit_rate = audio_bit_rate;
|
|
|
|
call->video_bit_rate = video_bit_rate;
|
|
|
|
|
|
|
|
call->previous_self_capabilities = MSI_CAP_R_AUDIO | MSI_CAP_R_VIDEO;
|
|
|
|
|
|
|
|
call->previous_self_capabilities |= audio_bit_rate > 0 ? MSI_CAP_S_AUDIO : 0;
|
|
|
|
call->previous_self_capabilities |= video_bit_rate > 0 ? MSI_CAP_S_VIDEO : 0;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_invite(av->log, av->msi, &call->msi_call, friend_number, call->previous_self_capabilities) != 0) {
|
2023-07-25 11:53:09 +02:00
|
|
|
call_remove(call);
|
|
|
|
rc = TOXAV_ERR_CALL_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->msi_call->av_call = call;
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_CALL_OK;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_callback_call(ToxAV *av, toxav_call_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->ccb = callback;
|
|
|
|
av->ccb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
|
|
|
|
Toxav_Err_Answer *error)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
|
|
|
Toxav_Err_Answer rc = TOXAV_ERR_ANSWER_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((audio_bit_rate != 0 && audio_bit_rate_invalid(audio_bit_rate))
|
|
|
|
|| (video_bit_rate != 0 && video_bit_rate_invalid(video_bit_rate))
|
|
|
|
) {
|
|
|
|
rc = TOXAV_ERR_ANSWER_INVALID_BIT_RATE;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr) {
|
|
|
|
rc = TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!call_prepare_transmission(call)) {
|
|
|
|
rc = TOXAV_ERR_ANSWER_CODEC_INITIALIZATION;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->audio_bit_rate = audio_bit_rate;
|
|
|
|
call->video_bit_rate = video_bit_rate;
|
|
|
|
|
|
|
|
call->previous_self_capabilities = MSI_CAP_R_AUDIO | MSI_CAP_R_VIDEO;
|
|
|
|
|
|
|
|
call->previous_self_capabilities |= audio_bit_rate > 0 ? MSI_CAP_S_AUDIO : 0;
|
|
|
|
call->previous_self_capabilities |= video_bit_rate > 0 ? MSI_CAP_S_VIDEO : 0;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_answer(av->log, call->msi_call, call->previous_self_capabilities) != 0) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_ANSWER_SYNC;
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_ANSWER_OK;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_callback_call_state(ToxAV *av, toxav_call_state_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->scb = callback;
|
|
|
|
av->scb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
static Toxav_Err_Call_Control call_control_handle_resume(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
/* Only act if paused and had media transfer active before */
|
|
|
|
if (call->msi_call->self_capabilities != 0 || call->previous_self_capabilities == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call,
|
|
|
|
call->previous_self_capabilities) == -1) {
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_allow_receiving_mark(call->audio_rtp);
|
|
|
|
rtp_allow_receiving_mark(call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_pause(ToxAVCall *call)
|
|
|
|
{
|
|
|
|
/* Only act if not already paused */
|
|
|
|
if (call->msi_call->self_capabilities == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->previous_self_capabilities = call->msi_call->self_capabilities;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call, 0) == -1) {
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_stop_receiving_mark(call->audio_rtp);
|
|
|
|
rtp_stop_receiving_mark(call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_cancel(ToxAVCall *call)
|
|
|
|
{
|
|
|
|
/* Hang up */
|
|
|
|
pthread_mutex_lock(call->toxav_call_mutex);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_hangup(call->av->log, call->msi_call) != 0) {
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->msi_call = nullptr;
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
|
|
|
|
/* No matter the case, terminate the call */
|
|
|
|
call_kill_transmission(call);
|
|
|
|
call_remove(call);
|
|
|
|
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_mute_audio(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if ((call->msi_call->self_capabilities & MSI_CAP_R_AUDIO) == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities ^ MSI_CAP_R_AUDIO) == -1) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_stop_receiving_mark(call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_unmute_audio(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if ((call->msi_call->self_capabilities ^ MSI_CAP_R_AUDIO) == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities | MSI_CAP_R_AUDIO) == -1) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_allow_receiving_mark(call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_hide_video(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if ((call->msi_call->self_capabilities & MSI_CAP_R_VIDEO) == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities ^ MSI_CAP_R_VIDEO) == -1) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_stop_receiving_mark(call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle_show_video(const ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if ((call->msi_call->self_capabilities ^ MSI_CAP_R_VIDEO) == 0) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(call->av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities | MSI_CAP_R_VIDEO) == -1) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_SYNC;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_allow_receiving_mark(call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control_handle(ToxAVCall *call, Toxav_Call_Control control)
|
|
|
|
{
|
|
|
|
switch (control) {
|
|
|
|
case TOXAV_CALL_CONTROL_RESUME:
|
|
|
|
return call_control_handle_resume(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_PAUSE:
|
|
|
|
return call_control_handle_pause(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_CANCEL:
|
|
|
|
return call_control_handle_cancel(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_MUTE_AUDIO:
|
|
|
|
return call_control_handle_mute_audio(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_UNMUTE_AUDIO:
|
|
|
|
return call_control_handle_unmute_audio(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_HIDE_VIDEO:
|
|
|
|
return call_control_handle_hide_video(call);
|
|
|
|
|
|
|
|
case TOXAV_CALL_CONTROL_SHOW_VIDEO:
|
|
|
|
return call_control_handle_show_video(call);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION;
|
|
|
|
}
|
|
|
|
static Toxav_Err_Call_Control call_control(ToxAV *av, uint32_t friend_number, Toxav_Call_Control control)
|
|
|
|
{
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
return TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToxAVCall *call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr || (!call->active && control != TOXAV_CALL_CONTROL_CANCEL)) {
|
|
|
|
return TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return call_control_handle(call, control);
|
|
|
|
}
|
|
|
|
bool toxav_call_control(ToxAV *av, uint32_t friend_number, Toxav_Call_Control control, Toxav_Err_Call_Control *error)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
|
|
|
|
const Toxav_Err_Call_Control rc = call_control(av, friend_number, control);
|
|
|
|
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_CALL_CONTROL_OK;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate,
|
|
|
|
Toxav_Err_Bit_Rate_Set *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_Bit_Rate_Set rc = TOXAV_ERR_BIT_RATE_SET_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bit_rate > 0 && audio_bit_rate_invalid(bit_rate)) {
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_INVALID_BIT_RATE;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Setting new audio bitrate to: %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (call->audio_bit_rate == bit_rate) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Audio bitrate already set to: %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
} else if (bit_rate == 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Turned off audio sending");
|
2023-07-25 11:53:09 +02:00
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(av->log, call->msi_call, call->msi_call->
|
2023-07-25 11:53:09 +02:00
|
|
|
self_capabilities ^ MSI_CAP_S_AUDIO) != 0) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Audio sending is turned off; notify peer */
|
|
|
|
call->audio_bit_rate = 0;
|
|
|
|
} else {
|
|
|
|
pthread_mutex_lock(call->toxav_call_mutex);
|
|
|
|
|
|
|
|
if (call->audio_bit_rate == 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Turned on audio sending");
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
/* The audio has been turned off before this */
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities | MSI_CAP_S_AUDIO) != 0) {
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
} else {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Set new audio bit rate %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
call->audio_bit_rate = bit_rate;
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_BIT_RATE_SET_OK;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t bit_rate,
|
|
|
|
Toxav_Err_Bit_Rate_Set *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_Bit_Rate_Set rc = TOXAV_ERR_BIT_RATE_SET_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bit_rate > 0 && video_bit_rate_invalid(bit_rate)) {
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_INVALID_BIT_RATE;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Setting new video bitrate to: %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (call->video_bit_rate == bit_rate) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Video bitrate already set to: %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
} else if (bit_rate == 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Turned off video sending");
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
/* Video sending is turned off; notify peer */
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(av->log, call->msi_call, call->msi_call->
|
2023-07-25 11:53:09 +02:00
|
|
|
self_capabilities ^ MSI_CAP_S_VIDEO) != 0) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->video_bit_rate = 0;
|
|
|
|
} else {
|
|
|
|
pthread_mutex_lock(call->toxav_call_mutex);
|
|
|
|
|
|
|
|
if (call->video_bit_rate == 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Turned on video sending");
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
/* The video has been turned off before this */
|
2024-11-09 13:44:30 +01:00
|
|
|
if (msi_change_capabilities(av->log, call->msi_call, call->
|
2023-07-25 11:53:09 +02:00
|
|
|
msi_call->self_capabilities | MSI_CAP_S_VIDEO) != 0) {
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
} else {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "Set new video bit rate %d", bit_rate);
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
call->video_bit_rate = bit_rate;
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_BIT_RATE_SET_OK;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_callback_audio_bit_rate(ToxAV *av, toxav_audio_bit_rate_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->abcb = callback;
|
|
|
|
av->abcb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
void toxav_callback_video_bit_rate(ToxAV *av, toxav_video_bit_rate_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->vbcb = callback;
|
|
|
|
av->vbcb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pcm, size_t sample_count,
|
|
|
|
uint8_t channels, uint32_t sampling_rate, Toxav_Err_Send_Frame *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_Send_Frame rc = TOXAV_ERR_SEND_FRAME_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pthread_mutex_trylock(av->mutex) != 0) {
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call->audio_bit_rate == 0 ||
|
|
|
|
(call->msi_call->self_capabilities & MSI_CAP_S_AUDIO) == 0 ||
|
|
|
|
(call->msi_call->peer_capabilities & MSI_CAP_R_AUDIO) == 0) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(call->mutex_audio);
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
|
|
|
if (pcm == nullptr) {
|
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_NULL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (channels > 2) {
|
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_INVALID;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
{ /* Encode and send */
|
|
|
|
if (ac_reconfigure_encoder(call->audio, call->audio_bit_rate * 1000, sampling_rate, channels) != 0) {
|
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_INVALID;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
/* This is more than enough always */
|
|
|
|
const uint16_t dest_size = sample_count + sizeof(sampling_rate);
|
|
|
|
VLA(uint8_t, dest, dest_size);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
sampling_rate = net_htonl(sampling_rate);
|
|
|
|
memcpy(dest, &sampling_rate, sizeof(sampling_rate));
|
|
|
|
const int vrc = opus_encode(call->audio->encoder, pcm, sample_count,
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
dest + sizeof(sampling_rate), dest_size - sizeof(sampling_rate));
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (vrc < 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(av->log, "Failed to encode frame %s", opus_strerror(vrc));
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_INVALID;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (rtp_send_data(av->log, call->audio_rtp, dest, vrc + sizeof(sampling_rate), false) != 0) {
|
|
|
|
LOGGER_WARNING(av->log, "Failed to send audio packet");
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_SEND_FRAME_OK;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
static Toxav_Err_Send_Frame send_frames(const ToxAV *av, ToxAVCall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
|
|
|
vpx_codec_iter_t iter = nullptr;
|
|
|
|
|
|
|
|
for (const vpx_codec_cx_pkt_t *pkt = vpx_codec_get_cx_data(call->video->encoder, &iter);
|
|
|
|
pkt != nullptr;
|
|
|
|
pkt = vpx_codec_get_cx_data(call->video->encoder, &iter)) {
|
|
|
|
if (pkt->kind != VPX_CODEC_CX_FRAME_PKT) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool is_keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
|
|
|
|
|
|
|
|
// https://www.webmproject.org/docs/webm-sdk/structvpx__codec__cx__pkt.html
|
|
|
|
// pkt->data.frame.sz -> size_t
|
|
|
|
const uint32_t frame_length_in_bytes = pkt->data.frame.sz;
|
|
|
|
|
|
|
|
const int res = rtp_send_data(
|
2024-11-09 13:44:30 +01:00
|
|
|
av->log,
|
2023-07-25 11:53:09 +02:00
|
|
|
call->video_rtp,
|
|
|
|
(const uint8_t *)pkt->data.frame.buf,
|
|
|
|
frame_length_in_bytes,
|
2024-11-09 13:44:30 +01:00
|
|
|
is_keyframe);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (res < 0) {
|
|
|
|
char *netstrerror = net_new_strerror(net_error());
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(av->log, "Could not send video frame: %s", netstrerror);
|
2023-07-25 11:53:09 +02:00
|
|
|
net_kill_strerror(netstrerror);
|
|
|
|
return TOXAV_ERR_SEND_FRAME_RTP_FAILED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TOXAV_ERR_SEND_FRAME_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, uint16_t height, const uint8_t *y,
|
|
|
|
const uint8_t *u, const uint8_t *v, Toxav_Err_Send_Frame *error)
|
|
|
|
{
|
|
|
|
Toxav_Err_Send_Frame rc = TOXAV_ERR_SEND_FRAME_OK;
|
|
|
|
ToxAVCall *call;
|
|
|
|
|
|
|
|
int vpx_encode_flags = 0;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pthread_mutex_trylock(av->mutex) != 0) {
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_SYNC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = call_get(av, friend_number);
|
|
|
|
|
|
|
|
if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call->video_bit_rate == 0 ||
|
|
|
|
(call->msi_call->self_capabilities & MSI_CAP_S_VIDEO) == 0 ||
|
|
|
|
(call->msi_call->peer_capabilities & MSI_CAP_R_VIDEO) == 0) {
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(call->mutex_video);
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
|
|
|
|
if (y == nullptr || u == nullptr || v == nullptr) {
|
|
|
|
pthread_mutex_unlock(call->mutex_video);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_NULL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
if (vc_reconfigure_encoder(call->video, call->video_bit_rate, width, height, -1) != 0) {
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(call->mutex_video);
|
|
|
|
rc = TOXAV_ERR_SEND_FRAME_INVALID;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call->video_rtp->ssrc < VIDEO_SEND_X_KEYFRAMES_FIRST) {
|
|
|
|
// Key frame flag for first frames
|
|
|
|
vpx_encode_flags = VPX_EFLAG_FORCE_KF;
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "I_FRAME_FLAG:%d only-i-frame mode", call->video_rtp->ssrc);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
++call->video_rtp->ssrc;
|
|
|
|
} else if (call->video_rtp->ssrc == VIDEO_SEND_X_KEYFRAMES_FIRST) {
|
|
|
|
// normal keyframe placement
|
|
|
|
vpx_encode_flags = 0;
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(av->log, "I_FRAME_FLAG:%d normal mode", call->video_rtp->ssrc);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
++call->video_rtp->ssrc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we start with I-frames (full frames) and then switch to normal mode later
|
|
|
|
|
|
|
|
{ /* Encode */
|
|
|
|
vpx_image_t img;
|
|
|
|
img.w = 0;
|
|
|
|
img.h = 0;
|
|
|
|
img.d_w = 0;
|
|
|
|
img.d_h = 0;
|
|
|
|
vpx_img_alloc(&img, VPX_IMG_FMT_I420, width, height, 0);
|
|
|
|
|
|
|
|
/* I420 "It comprises an NxM Y plane followed by (N/2)x(M/2) V and U planes."
|
|
|
|
* http://fourcc.org/yuv.php#IYUV
|
|
|
|
*/
|
|
|
|
memcpy(img.planes[VPX_PLANE_Y], y, width * height);
|
|
|
|
memcpy(img.planes[VPX_PLANE_U], u, (width / 2) * (height / 2));
|
|
|
|
memcpy(img.planes[VPX_PLANE_V], v, (width / 2) * (height / 2));
|
|
|
|
|
|
|
|
const vpx_codec_err_t vrc = vpx_codec_encode(call->video->encoder, &img,
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
call->video->frame_counter, 1, vpx_encode_flags, MAX_ENCODE_TIME_US);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
vpx_img_free(&img);
|
|
|
|
|
|
|
|
if (vrc != VPX_CODEC_OK) {
|
|
|
|
pthread_mutex_unlock(call->mutex_video);
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_ERROR(av->log, "Could not encode video frame: %s", vpx_codec_err_to_string(vrc));
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_SEND_FRAME_INVALID;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
++call->video->frame_counter;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rc = send_frames(av, call);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
pthread_mutex_unlock(call->mutex_video);
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc == TOXAV_ERR_SEND_FRAME_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void toxav_callback_audio_receive_frame(ToxAV *av, toxav_audio_receive_frame_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->acb = callback;
|
|
|
|
av->acb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb *callback, void *user_data)
|
|
|
|
{
|
|
|
|
pthread_mutex_lock(av->mutex);
|
|
|
|
av->vcb = callback;
|
|
|
|
av->vcb_user_data = user_data;
|
|
|
|
pthread_mutex_unlock(av->mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* :: Internal
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data)
|
|
|
|
{
|
|
|
|
/* Callback which is called when the internal measure mechanism reported packet loss.
|
|
|
|
* We report suggested lowered bitrate to an app. If app is sending both audio and video,
|
|
|
|
* we will report lowered bitrate for video only because in that case video probably
|
|
|
|
* takes more than 90% bandwidth. Otherwise, we report lowered bitrate on audio.
|
|
|
|
* The application may choose to disable video totally if the stream is too bad.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ToxAVCall *call = (ToxAVCall *)user_data;
|
|
|
|
assert(call != nullptr);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_DEBUG(call->av->log, "Reported loss of %f%%", (double)loss * 100);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
/* if less than 10% data loss we do nothing! */
|
|
|
|
if (loss < 0.1F) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(call->av->mutex);
|
|
|
|
|
|
|
|
if (call->video_bit_rate != 0) {
|
|
|
|
if (call->av->vbcb == nullptr) {
|
|
|
|
pthread_mutex_unlock(call->av->mutex);
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(call->av->log, "No callback to report loss on");
|
2023-07-25 11:53:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->av->vbcb(call->av, friend_number,
|
|
|
|
call->video_bit_rate - (call->video_bit_rate * loss),
|
|
|
|
call->av->vbcb_user_data);
|
|
|
|
} else if (call->audio_bit_rate != 0) {
|
|
|
|
if (call->av->abcb == nullptr) {
|
|
|
|
pthread_mutex_unlock(call->av->mutex);
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(call->av->log, "No callback to report loss on");
|
2023-07-25 11:53:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->av->abcb(call->av, friend_number,
|
|
|
|
call->audio_bit_rate - (call->audio_bit_rate * loss),
|
|
|
|
call->av->abcb_user_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(call->av->mutex);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_invite(void *object, MSICall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
ToxAV *toxav = (ToxAV *)object;
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_lock(toxav->mutex);
|
|
|
|
|
|
|
|
ToxAVCall *av_call = call_new(toxav, call->friend_number, nullptr);
|
|
|
|
|
|
|
|
if (av_call == nullptr) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(toxav->log, "Failed to initialize call...");
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->av_call = av_call;
|
|
|
|
av_call->msi_call = call;
|
|
|
|
|
|
|
|
if (toxav->ccb != nullptr) {
|
|
|
|
toxav->ccb(toxav, call->friend_number, call->peer_capabilities & MSI_CAP_S_AUDIO,
|
|
|
|
call->peer_capabilities & MSI_CAP_S_VIDEO, toxav->ccb_user_data);
|
|
|
|
} else {
|
|
|
|
/* No handler to capture the call request, send failure */
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_start(void *object, MSICall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
ToxAV *toxav = (ToxAV *)object;
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_lock(toxav->mutex);
|
|
|
|
|
|
|
|
ToxAVCall *av_call = call_get(toxav, call->friend_number);
|
|
|
|
|
|
|
|
if (av_call == nullptr) {
|
|
|
|
/* Should this ever happen? */
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!call_prepare_transmission(av_call)) {
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
callback_error(toxav, call);
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!invoke_call_state_callback(toxav, call->friend_number, call->peer_capabilities)) {
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
callback_error(toxav, call);
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_end(void *object, MSICall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
ToxAV *toxav = (ToxAV *)object;
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_lock(toxav->mutex);
|
|
|
|
|
|
|
|
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_FINISHED);
|
|
|
|
|
|
|
|
if (call->av_call != nullptr) {
|
|
|
|
call_kill_transmission(call->av_call);
|
|
|
|
call_remove(call->av_call);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_error(void *object, MSICall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
ToxAV *toxav = (ToxAV *)object;
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_lock(toxav->mutex);
|
|
|
|
|
|
|
|
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_ERROR);
|
|
|
|
|
|
|
|
if (call->av_call != nullptr) {
|
|
|
|
call_kill_transmission(call->av_call);
|
|
|
|
call_remove(call->av_call);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
static int callback_capabilites(void *object, MSICall *call)
|
2023-07-25 11:53:09 +02:00
|
|
|
{
|
Squashed 'external/toxcore/c-toxcore/' changes from e2c01e457b..b03b571272
b03b571272 fix: flaky tcp test This only fixes the symptoms, not the real problem. Sometimes or consistently on some platforms a socket might need a moment before it can be written to.
32e67ab4c2 cleanup: use typedef for private message ID's in callback
7b1db6adc1 feat: add message IDs to private group messages
99e0bcc27d refactor: Observers/ignored peers can now send and receive custom packets
b3c3c49d26 fix: Disable IPv6 in Windows cross-compilation tests
e742deddff feat: Check hashes of Windows dependencies when cross-compiling
dfb9a0b02b fix: Test the current Windows Dockerfile, not an old Dockerhub image
14de93ccec chore: Use WineHQ's Wine as Debian Bookworm's crashes
ed37616249 docs: Update the Windows cross-compilation section
9bb79c174f cleanup: Remove a couple of unnecessary misc_tools dependencies
19475adb70 chore: Statically link OpenMP into the cracker fun util on Windows
1be311e51f feat: Build the fun utils when cross-compiling to Windows
88133f8446 chore: Strip Windows binaries
3cc0ae7535 refactor: Copy over all of the required static dependencies
c4fa8f7fb1 feat: Generate .def, .exp and .lib files when building for Windows
74bbac5363 feat: Let CMake create the dll instead of doing so ourselves
246642e9ae feat: Harden Windows cross-compilation
8d431c0d11 chore: Bump Windows build dependency versions
e519f7998b fix: Remove unnecessary wsock32 dependency on Windows
ed2b60c217 chore: Use a specific non-broken slimcc version.
d7f21010a1 chore: Update github actions.
e71a68b7f2 docs: Update the list of CMake options
77e08876ff chore: Remove mod and founder from group API naming scheme
12bc042767 docs: add the experimental api build option to INSTALL.md
e1fa5cae96 refactor: Rename Queries to Query to align with other enums.
be82a3ea30 fix: Correct type for conference offline peer numbers.
0627c36716 test: Add pkgsrc build.
92578afe4b test: Add FreeBSD VM action on GitHub.
52ece0f57b test: Build toxcore on NetBSD (VM).
3fe8ee2c11 chore: Only install tox_private.h on request.
9a8dfa06ab fix: save_compatibility_test failing on big-endian systems
86f5e55578 fix: Don't serve files from websockify.
710eb674a5 fix: Correctly pass extended public keys to group moderation code.
021db7031c refactor: Use `struct`s for extended public/secret keys.
a1e999fd80 chore: Compile libsodium reference implementation with compcert.
fbe3c19cf5 cleanup: correct a few nullable annotations
623e3ee5c3 cleanup: Don't use `memcpy` to cast arbitrary `struct`s to `uint8_t[]`.
c71567dc18 fix: Pass array, not array pointer, to `memcmp`.
9b46a08144 cleanup: Never pass `void*` directly to `memcpy`.
5d7b7a7bbc refactor: Use tox rng to seed the keypair generation.
961891d568 cleanup: Small improvements found by PVS Studio.
8201019f0d chore: Disable NGC saving by default, enable through Tox_Options.
5dd9ee3f65 cleanup: Replace pointer arithmetic with explicit `&arr[i]`.
ca4606d49d refactor: Use strong typedef for NGC peer id.
442213b722 cleanup: Simplify custom packet length check in NGC.
08d3393def fix: Correct a few potential null derefs in bootstrap daemon.
b9877b32b0 fix: Add missing memunlock of local variable when it goes out of scope.
dab5fe44b9 fix: Zero out stack-allocated secret key before return.
f058103299 refactor: Make prune_gc_sanctions_list more obviously correct.
3ba7a0dec9 docs: Add static analysis tool list to README.
8d0811a0f3 docs: Run prettier-markdown on markdown files.
969e3a2bfc refactor: Fix network test not using the strong typedef
93c83fbc7c refactor: Use strong typedef instead of struct for `Socket`.
9fe18b176f fix: Fix some false positive from PVS Studio.
7c44379ccb cleanup: Check that WINXP macro exists before comparing it.
5c93231bef refactor: Make tox mutex non-recursive.
aacff73939 docs: Fix up doxyfile.
d55fc85ff5 docs: Add more documentation to crypto_core.
5bdaaaedb6 refactor: Remove `Tox *` from `tox_dispatch`.
e202341e76 refactor: Don't rely on tox_dispatch passing tox in tests.
34df938f52 chore: Use C++ mode for clang-tidy.
8b05296a78 chore: Check that both gtest and gmock exist for tests.
42010660e1 test: Add slimcc compiler compatibility test.
b473630321 chore: Add some comments to the astyle config.
b7404f24f6 cleanup: Remove implicit bool conversions.
4e2dba4d9f chore: Reformat sources with astyle.
4359e3a6bc chore: Rename C++ headers to .hh suffixes.
0c05566e58 cleanup: Further `#include` cleanups.
8d29935b7a chore: Only check the bootstrap daemon checksum on release.
f70e588bc6 cleanup: Add more `const` where possible.
511bfe39c8 cleanup: Use Bazel modules to enforce proper `#include` hygiene.
1710a0d091 refactor: Move pack/unpack `IP_Port` from DHT into network module.
a975943564 chore: Really fix coverage docker image build.
c08409390f chore: Fix post-submit coverage image.
39aadf8922 fix: Don't use `memcmp` to compare `IP_Port`s.
d94246a906 fix: partially fix a bug that prevented group part messages from sending.
eeaa039222 chore: Fix rpm build; add a CI check for it.
8328449c1a chore: Speed up docker builds a bit by reducing layer count.
d6d67d56f3 cleanup: Add `const` where possible in auto tests.
6aa9e6850d cleanup: Minor cleanup of event unpack code.
bdf460a3a9 refactor: Rename `system_{memory,...}` to `os_{memory,...}`.
203e1af81e fix: a few off by one errors in group autotests
5c093c4888 cleanup: Remove all uses of `SIZEOF_VLA`.
662c2140f3 test: Add goblint static analyser.
8f07755834 cleanup: Use `memzero(x, s)` instead of `memset(x, 0, s)`.
a7258e40cf cleanup: Use explicit 0 instead of `PACKET_ID_PADDING`.
6370d0f15d cleanup: Expand the `Tox_Options` accessor macros.
14a1a0b9bd cleanup: Remove plan9 support.
a05dccad13 test: Add a simple new/delete test for Tox.
1cdcf938b9 cleanup: Add comment after every `#endif`.
ba99d4dc4b test: Fix comment I broke in the events test PR.
e07248debb refactor: Migrate auto_tests to new events API.
bdd42b5452 refactor: Add common msgpack array packer with callback.
3c659f5288 cleanup: Rename group to conference in groupav documentation.
89957be230 cleanup: Ensure handler params are named after callback params.
c650d9d345 refactor: Pass `this` pointer as first param to s11n callbacks.
e7fb91ddb8 refactor: Allow NULL pointers for byte arrays in events.
5e2c8cabc1 cleanup: make some improvements to group moderation test
259de4867e cleanup: Remove `bin_pack_{new,free}`.
21a8ff5895 cleanup: skip a do_gc iteration before removing peers marked for deletion
16809dc36e feat: Add dht_get_nodes_response event to the events system.
git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: b03b5712720de9a9901ea12fd741f177327a7021
2024-03-07 23:12:55 +01:00
|
|
|
ToxAV *toxav = (ToxAV *)object;
|
2023-07-25 11:53:09 +02:00
|
|
|
pthread_mutex_lock(toxav->mutex);
|
|
|
|
|
|
|
|
if ((call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_allow_receiving_mark(call->av_call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
} else {
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_stop_receiving_mark(call->av_call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((call->peer_capabilities & MSI_CAP_S_VIDEO) != 0) {
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_allow_receiving_mark(call->av_call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
} else {
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_stop_receiving_mark(call->av_call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
invoke_call_state_callback(toxav, call->friend_number, call->peer_capabilities);
|
|
|
|
|
|
|
|
pthread_mutex_unlock(toxav->mutex);
|
|
|
|
return 0;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
static bool audio_bit_rate_invalid(uint32_t bit_rate)
|
|
|
|
{
|
|
|
|
/* Opus RFC 6716 section-2.1.1 dictates the following:
|
|
|
|
* Opus supports all bit rates from 6 kbit/s to 510 kbit/s.
|
|
|
|
*/
|
|
|
|
return bit_rate < 6 || bit_rate > 510;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
static bool video_bit_rate_invalid(uint32_t bit_rate)
|
|
|
|
{
|
|
|
|
/* https://www.webmproject.org/docs/webm-sdk/structvpx__codec__enc__cfg.html shows the following:
|
|
|
|
* unsigned int rc_target_bitrate
|
|
|
|
* the range of uint varies from platform to platform
|
|
|
|
* though, uint32_t should be large enough to store bitrates,
|
|
|
|
* we may want to prevent from passing overflowed bitrates to libvpx
|
|
|
|
* more in detail, it's the case where bit_rate is larger than uint, but smaller than uint32_t
|
|
|
|
*/
|
|
|
|
return bit_rate > UINT32_MAX;
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
2023-07-25 11:53:09 +02:00
|
|
|
static bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t state)
|
|
|
|
{
|
|
|
|
if (av->scb != nullptr) {
|
|
|
|
av->scb(av, friend_number, state, av->scb_user_data);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error)
|
|
|
|
{
|
|
|
|
/* Assumes mutex locked */
|
|
|
|
Toxav_Err_Call rc = TOXAV_ERR_CALL_OK;
|
|
|
|
ToxAVCall *call = nullptr;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
Tox_Err_Friend_Query f_con_query_error;
|
|
|
|
Tox_Connection f_con_status = TOX_CONNECTION_NONE;
|
|
|
|
|
|
|
|
if (!tox_friend_exists(av->tox, friend_number)) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_CALL_FRIEND_NOT_FOUND;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
f_con_status = tox_friend_get_connection_status(av->tox, friend_number, &f_con_query_error);
|
|
|
|
|
|
|
|
if (f_con_status == TOX_CONNECTION_NONE) {
|
2023-07-25 11:53:09 +02:00
|
|
|
rc = TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call_get(av, friend_number) != nullptr) {
|
|
|
|
rc = TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = (ToxAVCall *)calloc(1, sizeof(ToxAVCall));
|
|
|
|
|
|
|
|
if (call == nullptr) {
|
|
|
|
rc = TOXAV_ERR_CALL_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->av = av;
|
|
|
|
call->friend_number = friend_number;
|
|
|
|
|
|
|
|
if (create_recursive_mutex(call->toxav_call_mutex) != 0) {
|
|
|
|
free(call);
|
|
|
|
call = nullptr;
|
|
|
|
rc = TOXAV_ERR_CALL_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (av->calls == nullptr) { /* Creating */
|
|
|
|
av->calls = (ToxAVCall **)calloc(friend_number + 1, sizeof(ToxAVCall *));
|
|
|
|
|
|
|
|
if (av->calls == nullptr) {
|
|
|
|
pthread_mutex_destroy(call->toxav_call_mutex);
|
|
|
|
free(call);
|
|
|
|
call = nullptr;
|
|
|
|
rc = TOXAV_ERR_CALL_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
av->calls_tail = friend_number;
|
|
|
|
av->calls_head = friend_number;
|
|
|
|
} else if (av->calls_tail < friend_number) { /* Appending */
|
2024-01-12 21:30:48 +01:00
|
|
|
ToxAVCall **tmp = (ToxAVCall **)realloc(av->calls, (friend_number + 1) * sizeof(ToxAVCall *));
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (tmp == nullptr) {
|
|
|
|
pthread_mutex_destroy(call->toxav_call_mutex);
|
|
|
|
free(call);
|
|
|
|
call = nullptr;
|
|
|
|
rc = TOXAV_ERR_CALL_MALLOC;
|
|
|
|
goto RETURN;
|
|
|
|
}
|
|
|
|
|
|
|
|
av->calls = tmp;
|
|
|
|
|
|
|
|
/* Set fields in between to null */
|
|
|
|
for (uint32_t i = av->calls_tail + 1; i < friend_number; ++i) {
|
|
|
|
av->calls[i] = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->prev = av->calls[av->calls_tail];
|
|
|
|
av->calls[av->calls_tail]->next = call;
|
|
|
|
|
|
|
|
av->calls_tail = friend_number;
|
|
|
|
} else if (av->calls_head > friend_number) { /* Inserting at front */
|
|
|
|
call->next = av->calls[av->calls_head];
|
|
|
|
av->calls[av->calls_head]->prev = call;
|
|
|
|
av->calls_head = friend_number;
|
|
|
|
}
|
|
|
|
|
|
|
|
av->calls[friend_number] = call;
|
|
|
|
|
|
|
|
RETURN:
|
|
|
|
|
|
|
|
if (error != nullptr) {
|
|
|
|
*error = rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return call;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ToxAVCall *call_remove(ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if (call == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint32_t friend_number = call->friend_number;
|
|
|
|
ToxAV *av = call->av;
|
|
|
|
|
|
|
|
ToxAVCall *prev = call->prev;
|
|
|
|
ToxAVCall *next = call->next;
|
|
|
|
|
|
|
|
/* Set av call in msi to NULL in order to know if call if ToxAVCall is
|
|
|
|
* removed from the msi call.
|
|
|
|
*/
|
|
|
|
if (call->msi_call != nullptr) {
|
|
|
|
call->msi_call->av_call = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_destroy(call->toxav_call_mutex);
|
|
|
|
free(call);
|
|
|
|
|
|
|
|
if (prev != nullptr) {
|
|
|
|
prev->next = next;
|
|
|
|
} else if (next != nullptr) {
|
|
|
|
av->calls_head = next->friend_number;
|
|
|
|
} else {
|
|
|
|
goto CLEAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (next != nullptr) {
|
|
|
|
next->prev = prev;
|
|
|
|
} else if (prev != nullptr) {
|
|
|
|
av->calls_tail = prev->friend_number;
|
|
|
|
} else {
|
|
|
|
goto CLEAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
av->calls[friend_number] = nullptr;
|
|
|
|
return next;
|
|
|
|
|
|
|
|
CLEAR:
|
|
|
|
av->calls_head = 0;
|
|
|
|
av->calls_tail = 0;
|
|
|
|
free(av->calls);
|
|
|
|
av->calls = nullptr;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool call_prepare_transmission(ToxAVCall *call)
|
|
|
|
{
|
|
|
|
/* Assumes mutex locked */
|
|
|
|
|
|
|
|
if (call == nullptr) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
ToxAV *av = call->av;
|
|
|
|
|
|
|
|
if (av->acb == nullptr && av->vcb == nullptr) {
|
|
|
|
/* It makes no sense to have CSession without callbacks */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (call->active) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_WARNING(av->log, "Call already active!");
|
2023-07-25 11:53:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create_recursive_mutex(call->mutex_audio) != 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (create_recursive_mutex(call->mutex_video) != 0) {
|
|
|
|
goto FAILURE_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prepare bwc */
|
2024-11-09 13:44:30 +01:00
|
|
|
call->bwc = bwc_new(av->log, av->tox, call->friend_number, callback_bwc, call, av->toxav_mono_time);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
{ /* Prepare audio */
|
|
|
|
call->audio = ac_new(av->toxav_mono_time, av->log, av, call->friend_number, av->acb, av->acb_user_data);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (call->audio == nullptr) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_ERROR(av->log, "Failed to create audio codec session");
|
2023-07-25 11:53:09 +02:00
|
|
|
goto FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
call->audio_rtp = rtp_new(av->log, RTP_TYPE_AUDIO, av->tox, av, call->friend_number, call->bwc,
|
2023-07-25 11:53:09 +02:00
|
|
|
call->audio, ac_queue_message);
|
|
|
|
|
|
|
|
if (call->audio_rtp == nullptr) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_ERROR(av->log, "Failed to create audio rtp session");
|
2023-07-25 11:53:09 +02:00
|
|
|
goto FAILURE;
|
|
|
|
}
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
{ /* Prepare video */
|
|
|
|
call->video = vc_new(av->log, av->toxav_mono_time, av, call->friend_number, av->vcb, av->vcb_user_data);
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
if (call->video == nullptr) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_ERROR(av->log, "Failed to create video codec session");
|
2023-07-25 11:53:09 +02:00
|
|
|
goto FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
call->video_rtp = rtp_new(av->log, RTP_TYPE_VIDEO, av->tox, av, call->friend_number, call->bwc,
|
2023-07-25 11:53:09 +02:00
|
|
|
call->video, vc_queue_message);
|
|
|
|
|
|
|
|
if (call->video_rtp == nullptr) {
|
2024-11-09 13:44:30 +01:00
|
|
|
LOGGER_ERROR(av->log, "Failed to create video rtp session");
|
2023-07-25 11:53:09 +02:00
|
|
|
goto FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
call->active = true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
FAILURE:
|
|
|
|
bwc_kill(call->bwc);
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_kill(av->log, call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
ac_kill(call->audio);
|
|
|
|
call->audio_rtp = nullptr;
|
|
|
|
call->audio = nullptr;
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_kill(av->log, call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
vc_kill(call->video);
|
|
|
|
call->video_rtp = nullptr;
|
|
|
|
call->video = nullptr;
|
|
|
|
pthread_mutex_destroy(call->mutex_video);
|
|
|
|
FAILURE_2:
|
|
|
|
pthread_mutex_destroy(call->mutex_audio);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void call_kill_transmission(ToxAVCall *call)
|
|
|
|
{
|
|
|
|
if (call == nullptr || !call->active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
call->active = false;
|
|
|
|
|
|
|
|
pthread_mutex_lock(call->mutex_audio);
|
|
|
|
pthread_mutex_unlock(call->mutex_audio);
|
|
|
|
pthread_mutex_lock(call->mutex_video);
|
|
|
|
pthread_mutex_unlock(call->mutex_video);
|
|
|
|
pthread_mutex_lock(call->toxav_call_mutex);
|
|
|
|
pthread_mutex_unlock(call->toxav_call_mutex);
|
|
|
|
|
|
|
|
bwc_kill(call->bwc);
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
const ToxAV *av = call->av;
|
|
|
|
|
|
|
|
rtp_kill(av->log, call->audio_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
ac_kill(call->audio);
|
|
|
|
call->audio_rtp = nullptr;
|
|
|
|
call->audio = nullptr;
|
|
|
|
|
2024-11-09 13:44:30 +01:00
|
|
|
rtp_kill(av->log, call->video_rtp);
|
2023-07-25 11:53:09 +02:00
|
|
|
vc_kill(call->video);
|
|
|
|
call->video_rtp = nullptr;
|
|
|
|
call->video = nullptr;
|
|
|
|
|
|
|
|
pthread_mutex_destroy(call->mutex_audio);
|
|
|
|
pthread_mutex_destroy(call->mutex_video);
|
|
|
|
}
|
2024-11-09 13:44:30 +01:00
|
|
|
|
|
|
|
Mono_Time *toxav_get_av_mono_time(const ToxAV *av)
|
|
|
|
{
|
|
|
|
if (av == nullptr) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return av->toxav_mono_time;
|
|
|
|
}
|