Merge commit 'aae086cc650e42eec1eea8db28cd01fa868d7f90'
This commit is contained in:
43
external/toxcore/c-toxcore/toxav/toxav.c
vendored
43
external/toxcore/c-toxcore/toxav/toxav.c
vendored
@ -65,7 +65,6 @@ typedef struct ToxAVCall {
|
||||
struct ToxAVCall *next;
|
||||
} ToxAVCall;
|
||||
|
||||
|
||||
/** Decode time statistics */
|
||||
typedef struct DecodeTimeStats {
|
||||
/** Measure count */
|
||||
@ -118,11 +117,11 @@ struct ToxAV {
|
||||
|
||||
static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data);
|
||||
|
||||
static int callback_invite(void *toxav_inst, MSICall *call);
|
||||
static int callback_start(void *toxav_inst, MSICall *call);
|
||||
static int callback_end(void *toxav_inst, MSICall *call);
|
||||
static int callback_error(void *toxav_inst, MSICall *call);
|
||||
static int callback_capabilites(void *toxav_inst, MSICall *call);
|
||||
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);
|
||||
|
||||
static bool audio_bit_rate_invalid(uint32_t bit_rate);
|
||||
static bool video_bit_rate_invalid(uint32_t bit_rate);
|
||||
@ -850,12 +849,14 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
|
||||
goto RETURN;
|
||||
}
|
||||
|
||||
VLA(uint8_t, dest, sample_count + sizeof(sampling_rate)); /* This is more than enough always */
|
||||
/* This is more than enough always */
|
||||
const uint16_t dest_size = sample_count + sizeof(sampling_rate);
|
||||
VLA(uint8_t, dest, dest_size);
|
||||
|
||||
sampling_rate = net_htonl(sampling_rate);
|
||||
memcpy(dest, &sampling_rate, sizeof(sampling_rate));
|
||||
const int vrc = opus_encode(call->audio->encoder, pcm, sample_count,
|
||||
dest + sizeof(sampling_rate), SIZEOF_VLA(dest) - sizeof(sampling_rate));
|
||||
dest + sizeof(sampling_rate), dest_size - sizeof(sampling_rate));
|
||||
|
||||
if (vrc < 0) {
|
||||
LOGGER_WARNING(av->m->log, "Failed to encode frame %s", opus_strerror(vrc));
|
||||
@ -1002,7 +1003,7 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
|
||||
memcpy(img.planes[VPX_PLANE_V], v, (width / 2) * (height / 2));
|
||||
|
||||
const vpx_codec_err_t vrc = vpx_codec_encode(call->video->encoder, &img,
|
||||
call->video->frame_counter, 1, vpx_encode_flags, MAX_ENCODE_TIME_US);
|
||||
call->video->frame_counter, 1, vpx_encode_flags, MAX_ENCODE_TIME_US);
|
||||
|
||||
vpx_img_free(&img);
|
||||
|
||||
@ -1095,9 +1096,9 @@ static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss,
|
||||
|
||||
pthread_mutex_unlock(call->av->mutex);
|
||||
}
|
||||
static int callback_invite(void *toxav_inst, MSICall *call)
|
||||
static int callback_invite(void *object, MSICall *call)
|
||||
{
|
||||
ToxAV *toxav = (ToxAV *)toxav_inst;
|
||||
ToxAV *toxav = (ToxAV *)object;
|
||||
pthread_mutex_lock(toxav->mutex);
|
||||
|
||||
ToxAVCall *av_call = call_new(toxav, call->friend_number, nullptr);
|
||||
@ -1123,9 +1124,9 @@ static int callback_invite(void *toxav_inst, MSICall *call)
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return 0;
|
||||
}
|
||||
static int callback_start(void *toxav_inst, MSICall *call)
|
||||
static int callback_start(void *object, MSICall *call)
|
||||
{
|
||||
ToxAV *toxav = (ToxAV *)toxav_inst;
|
||||
ToxAV *toxav = (ToxAV *)object;
|
||||
pthread_mutex_lock(toxav->mutex);
|
||||
|
||||
ToxAVCall *av_call = call_get(toxav, call->friend_number);
|
||||
@ -1137,13 +1138,13 @@ static int callback_start(void *toxav_inst, MSICall *call)
|
||||
}
|
||||
|
||||
if (!call_prepare_transmission(av_call)) {
|
||||
callback_error(toxav_inst, call);
|
||||
callback_error(toxav, call);
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!invoke_call_state_callback(toxav, call->friend_number, call->peer_capabilities)) {
|
||||
callback_error(toxav_inst, call);
|
||||
callback_error(toxav, call);
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return -1;
|
||||
}
|
||||
@ -1151,9 +1152,9 @@ static int callback_start(void *toxav_inst, MSICall *call)
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return 0;
|
||||
}
|
||||
static int callback_end(void *toxav_inst, MSICall *call)
|
||||
static int callback_end(void *object, MSICall *call)
|
||||
{
|
||||
ToxAV *toxav = (ToxAV *)toxav_inst;
|
||||
ToxAV *toxav = (ToxAV *)object;
|
||||
pthread_mutex_lock(toxav->mutex);
|
||||
|
||||
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_FINISHED);
|
||||
@ -1166,9 +1167,9 @@ static int callback_end(void *toxav_inst, MSICall *call)
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return 0;
|
||||
}
|
||||
static int callback_error(void *toxav_inst, MSICall *call)
|
||||
static int callback_error(void *object, MSICall *call)
|
||||
{
|
||||
ToxAV *toxav = (ToxAV *)toxav_inst;
|
||||
ToxAV *toxav = (ToxAV *)object;
|
||||
pthread_mutex_lock(toxav->mutex);
|
||||
|
||||
invoke_call_state_callback(toxav, call->friend_number, TOXAV_FRIEND_CALL_STATE_ERROR);
|
||||
@ -1181,9 +1182,9 @@ static int callback_error(void *toxav_inst, MSICall *call)
|
||||
pthread_mutex_unlock(toxav->mutex);
|
||||
return 0;
|
||||
}
|
||||
static int callback_capabilites(void *toxav_inst, MSICall *call)
|
||||
static int callback_capabilites(void *object, MSICall *call)
|
||||
{
|
||||
ToxAV *toxav = (ToxAV *)toxav_inst;
|
||||
ToxAV *toxav = (ToxAV *)object;
|
||||
pthread_mutex_lock(toxav->mutex);
|
||||
|
||||
if ((call->peer_capabilities & MSI_CAP_S_AUDIO) != 0) {
|
||||
|
Reference in New Issue
Block a user