mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Astyle.
This commit is contained in:
parent
f435e94397
commit
6a494e2cbd
|
@ -153,7 +153,8 @@ void test_addto_lists_bad(DHT *dht,
|
||||||
{
|
{
|
||||||
// check "bad" clients replacement
|
// check "bad" clients replacement
|
||||||
int used, test1, test2, test3;
|
int used, test1, test2, test3;
|
||||||
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES], test_id3[crypto_box_PUBLICKEYBYTES];
|
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES],
|
||||||
|
test_id3[crypto_box_PUBLICKEYBYTES];
|
||||||
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
|
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
|
||||||
|
|
||||||
randombytes(public_key, sizeof(public_key));
|
randombytes(public_key, sizeof(public_key));
|
||||||
|
@ -196,7 +197,8 @@ void test_addto_lists_possible_bad(DHT *dht,
|
||||||
{
|
{
|
||||||
// check "possibly bad" clients replacement
|
// check "possibly bad" clients replacement
|
||||||
int used, test1, test2, test3;
|
int used, test1, test2, test3;
|
||||||
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES], test_id3[crypto_box_PUBLICKEYBYTES];
|
uint8_t public_key[crypto_box_PUBLICKEYBYTES], test_id1[crypto_box_PUBLICKEYBYTES], test_id2[crypto_box_PUBLICKEYBYTES],
|
||||||
|
test_id3[crypto_box_PUBLICKEYBYTES];
|
||||||
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
|
uint8_t ipv6 = ip_port->ip.family == AF_INET6 ? 1 : 0;
|
||||||
|
|
||||||
randombytes(public_key, sizeof(public_key));
|
randombytes(public_key, sizeof(public_key));
|
||||||
|
|
|
@ -102,6 +102,7 @@ void t_toxav_receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
|
||||||
void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
|
||||||
{
|
{
|
||||||
(void) userdata;
|
(void) userdata;
|
||||||
|
|
||||||
if (length == 7 && memcmp("gentoo", data, 7) == 0) {
|
if (length == 7 && memcmp("gentoo", data, 7) == 0) {
|
||||||
ck_assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0);
|
ck_assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0);
|
||||||
}
|
}
|
||||||
|
@ -173,6 +174,7 @@ void* call_thread(void* pd)
|
||||||
memset(video_v, 0, sizeof(video_v));
|
memset(video_v, 0, sizeof(video_v));
|
||||||
|
|
||||||
time_t start_time = time(NULL);
|
time_t start_time = time(NULL);
|
||||||
|
|
||||||
while (time(NULL) - start_time < 4) {
|
while (time(NULL) - start_time < 4) {
|
||||||
toxav_iterate(AliceAV);
|
toxav_iterate(AliceAV);
|
||||||
toxav_iterate(BobAV);
|
toxav_iterate(BobAV);
|
||||||
|
@ -309,6 +311,7 @@ START_TEST(test_AV_three_calls)
|
||||||
(void) pthread_detach(tids[2]);
|
(void) pthread_detach(tids[2]);
|
||||||
|
|
||||||
time_t start_time = time(NULL);
|
time_t start_time = time(NULL);
|
||||||
|
|
||||||
while (time(NULL) - start_time < 5) {
|
while (time(NULL) - start_time < 5) {
|
||||||
tox_iterate(Alice);
|
tox_iterate(Alice);
|
||||||
tox_iterate(Bobs[0]);
|
tox_iterate(Bobs[0]);
|
||||||
|
|
|
@ -103,6 +103,7 @@ void* pa_write_thread (void* d)
|
||||||
while (Pa_IsStreamActive(adout)) {
|
while (Pa_IsStreamActive(adout)) {
|
||||||
frame *f;
|
frame *f;
|
||||||
pthread_mutex_lock(cc->arb_mutex);
|
pthread_mutex_lock(cc->arb_mutex);
|
||||||
|
|
||||||
if (rb_read(cc->arb, (void **)&f)) {
|
if (rb_read(cc->arb, (void **)&f)) {
|
||||||
pthread_mutex_unlock(cc->arb_mutex);
|
pthread_mutex_unlock(cc->arb_mutex);
|
||||||
Pa_WriteStream(adout, f->data, f->size);
|
Pa_WriteStream(adout, f->data, f->size);
|
||||||
|
@ -140,6 +141,7 @@ void t_toxav_receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
|
||||||
uint16_t *img_data = malloc(height * width * 6);
|
uint16_t *img_data = malloc(height * width * 6);
|
||||||
|
|
||||||
unsigned long int i, j;
|
unsigned long int i, j;
|
||||||
|
|
||||||
for (i = 0; i < height; ++i) {
|
for (i = 0; i < height; ++i) {
|
||||||
for (j = 0; j < width; ++j) {
|
for (j = 0; j < width; ++j) {
|
||||||
uint8_t *point = (uint8_t *) img_data + 3 * ((i * width) + j);
|
uint8_t *point = (uint8_t *) img_data + 3 * ((i * width) + j);
|
||||||
|
@ -306,6 +308,7 @@ void* iterate_toxav (void * data)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
#if defined TEST_TRANSFER_V && TEST_TRANSFER_V == 1
|
#if defined TEST_TRANSFER_V && TEST_TRANSFER_V == 1
|
||||||
|
|
||||||
if (!rc)
|
if (!rc)
|
||||||
rc = 1;
|
rc = 1;
|
||||||
|
|
||||||
|
@ -337,6 +340,7 @@ int send_opencv_img(ToxAV* av, uint32_t friend_number, const IplImage* img)
|
||||||
int y_chroma_shift = 1;
|
int y_chroma_shift = 1;
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
for (y = 0; y < img->height; ++y) {
|
for (y = 0; y < img->height; ++y) {
|
||||||
for (x = 0; x < img->width; ++x) {
|
for (x = 0; x < img->width; ++x) {
|
||||||
uint8_t r = img->imageData[(x + y * img->width) * 3 + 0];
|
uint8_t r = img->imageData[(x + y * img->width) * 3 + 0];
|
||||||
|
@ -344,6 +348,7 @@ int send_opencv_img(ToxAV* av, uint32_t friend_number, const IplImage* img)
|
||||||
uint8_t b = img->imageData[(x + y * img->width) * 3 + 2];
|
uint8_t b = img->imageData[(x + y * img->width) * 3 + 2];
|
||||||
|
|
||||||
planes[0][x + y * strides[0]] = RGB2Y(r, g, b);
|
planes[0][x + y * strides[0]] = RGB2Y(r, g, b);
|
||||||
|
|
||||||
if (!(x % (1 << x_chroma_shift)) && !(y % (1 << y_chroma_shift))) {
|
if (!(x % (1 << x_chroma_shift)) && !(y % (1 << y_chroma_shift))) {
|
||||||
const int i = x / (1 << x_chroma_shift);
|
const int i = x / (1 << x_chroma_shift);
|
||||||
const int j = y / (1 << y_chroma_shift);
|
const int j = y / (1 << y_chroma_shift);
|
||||||
|
@ -363,8 +368,10 @@ int send_opencv_img(ToxAV* av, uint32_t friend_number, const IplImage* img)
|
||||||
int print_audio_devices()
|
int print_audio_devices()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < Pa_GetDeviceCount(); ++i) {
|
for (i = 0; i < Pa_GetDeviceCount(); ++i) {
|
||||||
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
|
const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
|
||||||
|
|
||||||
if (info)
|
if (info)
|
||||||
printf("%d) %s\n", i, info->name);
|
printf("%d) %s\n", i, info->name);
|
||||||
}
|
}
|
||||||
|
@ -401,47 +408,64 @@ int main (int argc, char** argv)
|
||||||
int32_t video_frame_duration = 10;
|
int32_t video_frame_duration = 10;
|
||||||
|
|
||||||
/* Parse settings */
|
/* Parse settings */
|
||||||
CHECK_ARG: switch (getopt(argc, argv, "a:b:v:x:o:dh")) {
|
CHECK_ARG:
|
||||||
|
|
||||||
|
switch (getopt(argc, argv, "a:b:v:x:o:dh")) {
|
||||||
case 'a':
|
case 'a':
|
||||||
af_name = optarg;
|
af_name = optarg;
|
||||||
goto CHECK_ARG;
|
goto CHECK_ARG;
|
||||||
|
|
||||||
case 'b': {
|
case 'b': {
|
||||||
char *d;
|
char *d;
|
||||||
audio_frame_duration = strtol(optarg, &d, 10);
|
audio_frame_duration = strtol(optarg, &d, 10);
|
||||||
|
|
||||||
if (*d) {
|
if (*d) {
|
||||||
printf("Invalid value for argument: 'b'");
|
printf("Invalid value for argument: 'b'");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto CHECK_ARG;
|
goto CHECK_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
vf_name = optarg;
|
vf_name = optarg;
|
||||||
goto CHECK_ARG;
|
goto CHECK_ARG;
|
||||||
|
|
||||||
case 'x': {
|
case 'x': {
|
||||||
char *d;
|
char *d;
|
||||||
video_frame_duration = strtol(optarg, &d, 10);
|
video_frame_duration = strtol(optarg, &d, 10);
|
||||||
|
|
||||||
if (*d) {
|
if (*d) {
|
||||||
printf("Invalid value for argument: 'x'");
|
printf("Invalid value for argument: 'x'");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto CHECK_ARG;
|
goto CHECK_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'o': {
|
case 'o': {
|
||||||
char *d;
|
char *d;
|
||||||
audio_out_dev_idx = strtol(optarg, &d, 10);
|
audio_out_dev_idx = strtol(optarg, &d, 10);
|
||||||
|
|
||||||
if (*d) {
|
if (*d) {
|
||||||
printf("Invalid value for argument: 'o'");
|
printf("Invalid value for argument: 'o'");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
goto CHECK_ARG;
|
goto CHECK_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
return print_audio_devices();
|
return print_audio_devices();
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
return print_help(argv[0]);
|
return print_help(argv[0]);
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
exit(1);
|
exit(1);
|
||||||
case -1:;
|
|
||||||
|
case -1:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ /* Check files */
|
{ /* Check files */
|
||||||
|
@ -456,14 +480,12 @@ int main (int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for files */
|
/* Check for files */
|
||||||
if(stat(af_name, &st) != 0 || !S_ISREG(st.st_mode))
|
if (stat(af_name, &st) != 0 || !S_ISREG(st.st_mode)) {
|
||||||
{
|
|
||||||
printf("%s doesn't seem to be a regular file!\n", af_name);
|
printf("%s doesn't seem to be a regular file!\n", af_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stat(vf_name, &st) != 0 || !S_ISREG(st.st_mode))
|
if (stat(vf_name, &st) != 0 || !S_ISREG(st.st_mode)) {
|
||||||
{
|
|
||||||
printf("%s doesn't seem to be a regular file!\n", vf_name);
|
printf("%s doesn't seem to be a regular file!\n", vf_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -473,6 +495,7 @@ int main (int argc, char** argv)
|
||||||
audio_out_dev_idx = Pa_GetDefaultOutputDevice();
|
audio_out_dev_idx = Pa_GetDefaultOutputDevice();
|
||||||
|
|
||||||
const PaDeviceInfo *audio_dev = Pa_GetDeviceInfo(audio_out_dev_idx);
|
const PaDeviceInfo *audio_dev = Pa_GetDeviceInfo(audio_out_dev_idx);
|
||||||
|
|
||||||
if (!audio_dev) {
|
if (!audio_dev) {
|
||||||
fprintf(stderr, "Device under index: %ld invalid", audio_out_dev_idx);
|
fprintf(stderr, "Device under index: %ld invalid", audio_out_dev_idx);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -536,6 +559,7 @@ int main (int argc, char** argv)
|
||||||
|
|
||||||
/* Open audio file */
|
/* Open audio file */
|
||||||
af_handle = sf_open(af_name, SFM_READ, &af_info);
|
af_handle = sf_open(af_name, SFM_READ, &af_info);
|
||||||
|
|
||||||
if (af_handle == NULL) {
|
if (af_handle == NULL) {
|
||||||
printf("Failed to open the file.\n");
|
printf("Failed to open the file.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -581,15 +605,20 @@ int main (int argc, char** argv)
|
||||||
pthread_detach(t);
|
pthread_detach(t);
|
||||||
|
|
||||||
printf("Sample rate %d\n", af_info.samplerate);
|
printf("Sample rate %d\n", af_info.samplerate);
|
||||||
|
|
||||||
while (start_time + expected_time > time(NULL) ) {
|
while (start_time + expected_time > time(NULL) ) {
|
||||||
uint64_t enc_start_time = current_time_monotonic();
|
uint64_t enc_start_time = current_time_monotonic();
|
||||||
int64_t count = sf_read_short(af_handle, PCM, frame_size);
|
int64_t count = sf_read_short(af_handle, PCM, frame_size);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
TOXAV_ERR_SEND_FRAME rc;
|
TOXAV_ERR_SEND_FRAME rc;
|
||||||
if (toxav_audio_send_frame(AliceAV, 0, PCM, count/af_info.channels, af_info.channels, af_info.samplerate, &rc) == false) {
|
|
||||||
|
if (toxav_audio_send_frame(AliceAV, 0, PCM, count / af_info.channels, af_info.channels, af_info.samplerate,
|
||||||
|
&rc) == false) {
|
||||||
printf("Error sending frame of size %ld: %d\n", count, rc);
|
printf("Error sending frame of size %ld: %d\n", count, rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate_tox(bootstrap, AliceAV, BobAV);
|
iterate_tox(bootstrap, AliceAV, BobAV);
|
||||||
c_sleep(abs(audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1));
|
c_sleep(abs(audio_frame_duration - (current_time_monotonic() - enc_start_time) - 1));
|
||||||
}
|
}
|
||||||
|
@ -614,6 +643,7 @@ int main (int argc, char** argv)
|
||||||
|
|
||||||
/* Stop decode thread */
|
/* Stop decode thread */
|
||||||
data.sig = -1;
|
data.sig = -1;
|
||||||
|
|
||||||
while (data.sig != 1)
|
while (data.sig != 1)
|
||||||
pthread_yield();
|
pthread_yield();
|
||||||
|
|
||||||
|
@ -621,6 +651,7 @@ int main (int argc, char** argv)
|
||||||
pthread_mutex_destroy(BobCC.arb_mutex);
|
pthread_mutex_destroy(BobCC.arb_mutex);
|
||||||
|
|
||||||
void *f = NULL;
|
void *f = NULL;
|
||||||
|
|
||||||
while (rb_read(AliceCC.arb, &f))
|
while (rb_read(AliceCC.arb, &f))
|
||||||
free(f);
|
free(f);
|
||||||
|
|
||||||
|
@ -673,6 +704,7 @@ int main (int argc, char** argv)
|
||||||
pthread_detach(dect);
|
pthread_detach(dect);
|
||||||
|
|
||||||
CvCapture *capture = cvCreateFileCapture(vf_name);
|
CvCapture *capture = cvCreateFileCapture(vf_name);
|
||||||
|
|
||||||
if (!capture) {
|
if (!capture) {
|
||||||
printf("Failed to open video file: %s\n", vf_name);
|
printf("Failed to open video file: %s\n", vf_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -681,8 +713,10 @@ int main (int argc, char** argv)
|
||||||
// toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL);
|
// toxav_video_bit_rate_set(AliceAV, 0, 5000, false, NULL);
|
||||||
|
|
||||||
time_t start_time = time(NULL);
|
time_t start_time = time(NULL);
|
||||||
|
|
||||||
while (start_time + 90 > time(NULL)) {
|
while (start_time + 90 > time(NULL)) {
|
||||||
IplImage *frame = cvQueryFrame(capture );
|
IplImage *frame = cvQueryFrame(capture );
|
||||||
|
|
||||||
if (!frame)
|
if (!frame)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -709,6 +743,7 @@ int main (int argc, char** argv)
|
||||||
/* Stop decode thread */
|
/* Stop decode thread */
|
||||||
printf("Stopping decode thread\n");
|
printf("Stopping decode thread\n");
|
||||||
data.sig = -1;
|
data.sig = -1;
|
||||||
|
|
||||||
while (data.sig != 1)
|
while (data.sig != 1)
|
||||||
pthread_yield();
|
pthread_yield();
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ BWControler *bwc_new(Messenger *m, uint32_t friendnumber,
|
||||||
|
|
||||||
/* Fill with zeros */
|
/* Fill with zeros */
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < BWC_AVG_PKT_COUNT; i ++)
|
for (; i < BWC_AVG_PKT_COUNT; i ++)
|
||||||
rb_write(retu->rcvpkt.rb, retu->rcvpkt.rb_s + i);
|
rb_write(retu->rcvpkt.rb, retu->rcvpkt.rb_s + i);
|
||||||
|
|
||||||
|
@ -114,6 +115,7 @@ void bwc_add_lost(BWControler *bwc, uint32_t bytes)
|
||||||
rb_data(bwc->rcvpkt.rb, (void **) t_avg);
|
rb_data(bwc->rcvpkt.rb, (void **) t_avg);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (; i < BWC_AVG_PKT_COUNT; i ++) {
|
for (; i < BWC_AVG_PKT_COUNT; i ++) {
|
||||||
bytes += *(t_avg[i]);
|
bytes += *(t_avg[i]);
|
||||||
|
|
||||||
|
@ -149,11 +151,9 @@ void send_update(BWControler *bwc)
|
||||||
bwc->cycle.lost /= 10;
|
bwc->cycle.lost /= 10;
|
||||||
bwc->cycle.recv /= 10;
|
bwc->cycle.recv /= 10;
|
||||||
bwc->cycle.lfu = current_time_monotonic();
|
bwc->cycle.lfu = current_time_monotonic();
|
||||||
}
|
} else if (current_time_monotonic() - bwc->cycle.lsu > BWC_SEND_INTERVAL_MS) {
|
||||||
else if (current_time_monotonic() - bwc->cycle.lsu > BWC_SEND_INTERVAL_MS) {
|
|
||||||
|
|
||||||
if (bwc->cycle.lost)
|
if (bwc->cycle.lost) {
|
||||||
{
|
|
||||||
LOGGER_DEBUG ("%p Sent update rcv: %u lost: %u",
|
LOGGER_DEBUG ("%p Sent update rcv: %u lost: %u",
|
||||||
bwc, bwc->cycle.recv, bwc->cycle.lost);
|
bwc, bwc->cycle.recv, bwc->cycle.lost);
|
||||||
|
|
||||||
|
|
|
@ -630,8 +630,7 @@ void handle_init (MSICall* call, const MSIMessage* msg)
|
||||||
goto FAILURE;
|
goto FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (call->state)
|
switch (call->state) {
|
||||||
{
|
|
||||||
case msi_CallInactive: {
|
case msi_CallInactive: {
|
||||||
/* Call requested */
|
/* Call requested */
|
||||||
call->peer_capabilities = msg->capabilities.value;
|
call->peer_capabilities = msg->capabilities.value;
|
||||||
|
@ -814,9 +813,11 @@ void handle_msi_packet (Messenger *m, uint32_t friend_number, const uint8_t *dat
|
||||||
case requ_init:
|
case requ_init:
|
||||||
handle_init(call, &msg);
|
handle_init(call, &msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case requ_push:
|
case requ_push:
|
||||||
handle_push(call, &msg);
|
handle_push(call, &msg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case requ_pop:
|
case requ_pop:
|
||||||
handle_pop(call, &msg); /* always kills the call */
|
handle_pop(call, &msg); /* always kills the call */
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -197,6 +197,7 @@ bool chloss (const RTPSession *session, const struct RTPHeader *header)
|
||||||
session->rsequnum - hosq;
|
session->rsequnum - hosq;
|
||||||
|
|
||||||
puts ("Lost packet");
|
puts ("Lost packet");
|
||||||
|
|
||||||
while (lost --)
|
while (lost --)
|
||||||
bwc_add_lost(session->bwc , 0);
|
bwc_add_lost(session->bwc , 0);
|
||||||
|
|
||||||
|
|
|
@ -441,6 +441,7 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co
|
||||||
case TOXAV_CALL_CONTROL_CANCEL: {
|
case TOXAV_CALL_CONTROL_CANCEL: {
|
||||||
/* Hang up */
|
/* Hang up */
|
||||||
pthread_mutex_lock(call->mutex);
|
pthread_mutex_lock(call->mutex);
|
||||||
|
|
||||||
if (msi_hangup(call->msi_call) != 0) {
|
if (msi_hangup(call->msi_call) != 0) {
|
||||||
rc = TOXAV_ERR_CALL_CONTROL_SYNC;
|
rc = TOXAV_ERR_CALL_CONTROL_SYNC;
|
||||||
pthread_mutex_unlock(call->mutex);
|
pthread_mutex_unlock(call->mutex);
|
||||||
|
@ -566,18 +567,22 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
LOGGER_DEBUG("Audio bitrate already set to: %d", audio_bit_rate);
|
LOGGER_DEBUG("Audio bitrate already set to: %d", audio_bit_rate);
|
||||||
} else if (audio_bit_rate == 0) {
|
} else if (audio_bit_rate == 0) {
|
||||||
LOGGER_DEBUG("Turned off audio sending");
|
LOGGER_DEBUG("Turned off audio sending");
|
||||||
|
|
||||||
if (msi_change_capabilities(call->msi_call, call->msi_call->
|
if (msi_change_capabilities(call->msi_call, call->msi_call->
|
||||||
self_capabilities ^ msi_CapSAudio) != 0) {
|
self_capabilities ^ msi_CapSAudio) != 0) {
|
||||||
pthread_mutex_unlock(av->mutex);
|
pthread_mutex_unlock(av->mutex);
|
||||||
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Audio sending is turned off; notify peer */
|
/* Audio sending is turned off; notify peer */
|
||||||
call->audio_bit_rate = 0;
|
call->audio_bit_rate = 0;
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_lock(call->mutex);
|
pthread_mutex_lock(call->mutex);
|
||||||
|
|
||||||
if (call->audio_bit_rate == 0) {
|
if (call->audio_bit_rate == 0) {
|
||||||
LOGGER_DEBUG("Turned on audio sending");
|
LOGGER_DEBUG("Turned on audio sending");
|
||||||
|
|
||||||
/* The audio has been turned off before this */
|
/* The audio has been turned off before this */
|
||||||
if (msi_change_capabilities(call->msi_call, call->
|
if (msi_change_capabilities(call->msi_call, call->
|
||||||
msi_call->self_capabilities | msi_CapSAudio) != 0) {
|
msi_call->self_capabilities | msi_CapSAudio) != 0) {
|
||||||
|
@ -588,6 +593,7 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
LOGGER_DEBUG("Set new audio bit rate %d", audio_bit_rate);
|
LOGGER_DEBUG("Set new audio bit rate %d", audio_bit_rate);
|
||||||
|
|
||||||
call->audio_bit_rate = audio_bit_rate;
|
call->audio_bit_rate = audio_bit_rate;
|
||||||
pthread_mutex_unlock(call->mutex);
|
pthread_mutex_unlock(call->mutex);
|
||||||
}
|
}
|
||||||
|
@ -600,6 +606,7 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
LOGGER_DEBUG("Video bitrate already set to: %d", video_bit_rate);
|
LOGGER_DEBUG("Video bitrate already set to: %d", video_bit_rate);
|
||||||
} else if (video_bit_rate == 0) {
|
} else if (video_bit_rate == 0) {
|
||||||
LOGGER_DEBUG("Turned off video sending");
|
LOGGER_DEBUG("Turned off video sending");
|
||||||
|
|
||||||
/* Video sending is turned off; notify peer */
|
/* Video sending is turned off; notify peer */
|
||||||
if (msi_change_capabilities(call->msi_call, call->msi_call->
|
if (msi_change_capabilities(call->msi_call, call->msi_call->
|
||||||
self_capabilities ^ msi_CapSVideo) != 0) {
|
self_capabilities ^ msi_CapSVideo) != 0) {
|
||||||
|
@ -607,11 +614,14 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
rc = TOXAV_ERR_BIT_RATE_SET_SYNC;
|
||||||
goto END;
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
call->video_bit_rate = 0;
|
call->video_bit_rate = 0;
|
||||||
} else {
|
} else {
|
||||||
pthread_mutex_lock(call->mutex);
|
pthread_mutex_lock(call->mutex);
|
||||||
|
|
||||||
if (call->video_bit_rate == 0) {
|
if (call->video_bit_rate == 0) {
|
||||||
LOGGER_DEBUG("Turned on video sending");
|
LOGGER_DEBUG("Turned on video sending");
|
||||||
|
|
||||||
/* The video has been turned off before this */
|
/* The video has been turned off before this */
|
||||||
if (msi_change_capabilities(call->msi_call, call->
|
if (msi_change_capabilities(call->msi_call, call->
|
||||||
msi_call->self_capabilities | msi_CapSVideo) != 0) {
|
msi_call->self_capabilities | msi_CapSVideo) != 0) {
|
||||||
|
@ -622,6 +632,7 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
LOGGER_DEBUG("Set new video bit rate %d", video_bit_rate);
|
LOGGER_DEBUG("Set new video bit rate %d", video_bit_rate);
|
||||||
|
|
||||||
call->video_bit_rate = video_bit_rate;
|
call->video_bit_rate = video_bit_rate;
|
||||||
pthread_mutex_unlock(call->mutex);
|
pthread_mutex_unlock(call->mutex);
|
||||||
}
|
}
|
||||||
|
@ -629,6 +640,7 @@ bool toxav_bit_rate_set(ToxAV *av, uint32_t friend_number, int32_t audio_bit_rat
|
||||||
|
|
||||||
pthread_mutex_unlock(av->mutex);
|
pthread_mutex_unlock(av->mutex);
|
||||||
END:
|
END:
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = rc;
|
*error = rc;
|
||||||
|
|
||||||
|
@ -719,6 +731,7 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
|
||||||
pthread_mutex_unlock(call->mutex_audio);
|
pthread_mutex_unlock(call->mutex_audio);
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = rc;
|
*error = rc;
|
||||||
|
|
||||||
|
@ -817,6 +830,7 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
|
||||||
pthread_mutex_unlock(call->mutex_video);
|
pthread_mutex_unlock(call->mutex_video);
|
||||||
|
|
||||||
END:
|
END:
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = rc;
|
*error = rc;
|
||||||
|
|
||||||
|
@ -861,6 +875,7 @@ void callback_bwc(BWControler* bwc, uint32_t friend_number, float loss, void* us
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pthread_mutex_lock(call->av->mutex);
|
pthread_mutex_lock(call->av->mutex);
|
||||||
|
|
||||||
if (!call->av->bcb.first) {
|
if (!call->av->bcb.first) {
|
||||||
pthread_mutex_unlock(call->av->mutex);
|
pthread_mutex_unlock(call->av->mutex);
|
||||||
LOGGER_WARNING("No callback to report loss on");
|
LOGGER_WARNING("No callback to report loss on");
|
||||||
|
|
|
@ -341,7 +341,8 @@ typedef enum TOXAV_ERR_ANSWER {
|
||||||
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
|
* @param video_bit_rate Video bit rate in Kb/sec. Set this to 0 to disable
|
||||||
* video sending.
|
* video sending.
|
||||||
*/
|
*/
|
||||||
bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, TOXAV_ERR_ANSWER *error);
|
bool toxav_answer(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate,
|
||||||
|
TOXAV_ERR_ANSWER *error);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -474,7 +475,8 @@ typedef enum TOXAV_ERR_CALL_CONTROL {
|
||||||
*
|
*
|
||||||
* @return true on success.
|
* @return true on success.
|
||||||
*/
|
*/
|
||||||
bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control, TOXAV_ERR_CALL_CONTROL *error);
|
bool toxav_call_control(ToxAV *toxAV, uint32_t friend_number, TOXAV_CALL_CONTROL control,
|
||||||
|
TOXAV_ERR_CALL_CONTROL *error);
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -533,7 +535,8 @@ bool toxav_bit_rate_set(ToxAV *toxAV, uint32_t friend_number, int32_t audio_bit_
|
||||||
* @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec.
|
* @param audio_bit_rate Suggested maximum audio bit rate in Kb/sec.
|
||||||
* @param video_bit_rate Suggested maximum video bit rate in Kb/sec.
|
* @param video_bit_rate Suggested maximum video bit rate in Kb/sec.
|
||||||
*/
|
*/
|
||||||
typedef void toxav_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate, uint32_t video_bit_rate, void *user_data);
|
typedef void toxav_bit_rate_status_cb(ToxAV *toxAV, uint32_t friend_number, uint32_t audio_bit_rate,
|
||||||
|
uint32_t video_bit_rate, void *user_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the callback for the `bit_rate_status` event. Pass NULL to unset.
|
* Set the callback for the `bit_rate_status` event. Pass NULL to unset.
|
||||||
|
|
|
@ -218,8 +218,7 @@ int vc_reconfigure_encoder(VCSession* vc, uint32_t bit_rate, uint16_t width, uin
|
||||||
if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height)
|
if (cfg.rc_target_bitrate == bit_rate && cfg.g_w == width && cfg.g_h == height)
|
||||||
return 0; /* Nothing changed */
|
return 0; /* Nothing changed */
|
||||||
|
|
||||||
if (cfg.g_w == width && cfg.g_h == height)
|
if (cfg.g_w == width && cfg.g_h == height) {
|
||||||
{
|
|
||||||
/* Only bit rate changed */
|
/* Only bit rate changed */
|
||||||
cfg.rc_target_bitrate = bit_rate;
|
cfg.rc_target_bitrate = bit_rate;
|
||||||
|
|
||||||
|
@ -229,9 +228,7 @@ int vc_reconfigure_encoder(VCSession* vc, uint32_t bit_rate, uint16_t width, uin
|
||||||
LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
|
LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support
|
/* Resolution is changed, must reinitialize encoder since libvpx v1.4 doesn't support
|
||||||
* reconfiguring encoder to use resolutions greater than initially set.
|
* reconfiguring encoder to use resolutions greater than initially set.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -212,6 +212,7 @@ bool rb_empty(const RingBuffer *b)
|
||||||
void *rb_write(RingBuffer *b, void *p)
|
void *rb_write(RingBuffer *b, void *p)
|
||||||
{
|
{
|
||||||
void *rc = NULL;
|
void *rc = NULL;
|
||||||
|
|
||||||
if ((b->end + 1) % b->size == b->start) /* full */
|
if ((b->end + 1) % b->size == b->start) /* full */
|
||||||
rc = b->data[b->start];
|
rc = b->data[b->start];
|
||||||
|
|
||||||
|
@ -269,6 +270,7 @@ uint16_t rb_size(const RingBuffer* b)
|
||||||
uint16_t rb_data(const RingBuffer *b, void **dest)
|
uint16_t rb_data(const RingBuffer *b, void **dest)
|
||||||
{
|
{
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
|
|
||||||
for (; i < rb_size(b); i++)
|
for (; i < rb_size(b); i++)
|
||||||
dest[i] = b->data[(b->start + i) % b->size];
|
dest[i] = b->data[(b->start + i) % b->size];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user