diff options
-rw-r--r-- | toxav/audio.c | 9 | ||||
-rw-r--r-- | toxav/bwcontroller.c | 4 | ||||
-rw-r--r-- | toxav/msi.c | 27 | ||||
-rw-r--r-- | toxav/toxav.c | 28 |
4 files changed, 35 insertions, 33 deletions
diff --git a/toxav/audio.c b/toxav/audio.c index b936f7a4..da1ea11f 100644 --- a/toxav/audio.c +++ b/toxav/audio.c | |||
@@ -355,7 +355,8 @@ static struct RTPMessage *jbuf_read(struct JitterBuffer *q, int32_t *success) | |||
355 | *success = 0; | 355 | *success = 0; |
356 | return nullptr; | 356 | return nullptr; |
357 | } | 357 | } |
358 | OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t sampling_rate, int32_t channel_count) | 358 | static OpusEncoder *create_audio_encoder(const Logger *log, int32_t bit_rate, int32_t sampling_rate, |
359 | int32_t channel_count) | ||
359 | { | 360 | { |
360 | int status = OPUS_OK; | 361 | int status = OPUS_OK; |
361 | /* | 362 | /* |
@@ -448,8 +449,8 @@ FAILURE: | |||
448 | return nullptr; | 449 | return nullptr; |
449 | } | 450 | } |
450 | 451 | ||
451 | bool reconfigure_audio_encoder(const Logger *log, OpusEncoder **e, int32_t new_br, int32_t new_sr, uint8_t new_ch, | 452 | static bool reconfigure_audio_encoder(const Logger *log, OpusEncoder **e, int32_t new_br, int32_t new_sr, |
452 | int32_t *old_br, int32_t *old_sr, int32_t *old_ch) | 453 | uint8_t new_ch, int32_t *old_br, int32_t *old_sr, int32_t *old_ch) |
453 | { | 454 | { |
454 | /* Values are checked in toxav.c */ | 455 | /* Values are checked in toxav.c */ |
455 | if (*old_sr != new_sr || *old_ch != new_ch) { | 456 | if (*old_sr != new_sr || *old_ch != new_ch) { |
@@ -480,7 +481,7 @@ bool reconfigure_audio_encoder(const Logger *log, OpusEncoder **e, int32_t new_b | |||
480 | return true; | 481 | return true; |
481 | } | 482 | } |
482 | 483 | ||
483 | bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int8_t channels) | 484 | static bool reconfigure_audio_decoder(ACSession *ac, int32_t sampling_rate, int8_t channels) |
484 | { | 485 | { |
485 | if (sampling_rate != ac->ld_sample_rate || channels != ac->ld_channel_count) { | 486 | if (sampling_rate != ac->ld_sample_rate || channels != ac->ld_channel_count) { |
486 | if (current_time_monotonic(ac->mono_time) - ac->ldrts < 500) { | 487 | if (current_time_monotonic(ac->mono_time) - ac->ldrts < 500) { |
diff --git a/toxav/bwcontroller.c b/toxav/bwcontroller.c index 9a778291..2af8eee8 100644 --- a/toxav/bwcontroller.c +++ b/toxav/bwcontroller.c | |||
@@ -120,7 +120,7 @@ void bwc_add_recv(BWController *bwc, uint32_t recv_bytes) | |||
120 | send_update(bwc); | 120 | send_update(bwc); |
121 | } | 121 | } |
122 | 122 | ||
123 | void send_update(BWController *bwc) | 123 | static void send_update(BWController *bwc) |
124 | { | 124 | { |
125 | if (bwc->packet_loss_counted_cycles > BWC_AVG_LOSS_OVER_CYCLES_COUNT && | 125 | if (bwc->packet_loss_counted_cycles > BWC_AVG_LOSS_OVER_CYCLES_COUNT && |
126 | current_time_monotonic(bwc->m->mono_time) - bwc->cycle.last_sent_timestamp > BWC_SEND_INTERVAL_MS) { | 126 | current_time_monotonic(bwc->m->mono_time) - bwc->cycle.last_sent_timestamp > BWC_SEND_INTERVAL_MS) { |
@@ -180,7 +180,7 @@ static int on_update(BWController *bwc, const struct BWCMessage *msg) | |||
180 | return 0; | 180 | return 0; |
181 | } | 181 | } |
182 | 182 | ||
183 | int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object) | 183 | static int bwc_handle_data(Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object) |
184 | { | 184 | { |
185 | if (length - 1 != sizeof(struct BWCMessage)) { | 185 | if (length - 1 != sizeof(struct BWCMessage)) { |
186 | return -1; | 186 | return -1; |
diff --git a/toxav/msi.c b/toxav/msi.c index aad2bb2d..4772ac8a 100644 --- a/toxav/msi.c +++ b/toxav/msi.c | |||
@@ -309,13 +309,13 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities) | |||
309 | /** | 309 | /** |
310 | * Private functions | 310 | * Private functions |
311 | */ | 311 | */ |
312 | void msg_init(MSIMessage *dest, MSIRequest request) | 312 | static void msg_init(MSIMessage *dest, MSIRequest request) |
313 | { | 313 | { |
314 | memset(dest, 0, sizeof(*dest)); | 314 | memset(dest, 0, sizeof(*dest)); |
315 | dest->request.exists = true; | 315 | dest->request.exists = true; |
316 | dest->request.value = request; | 316 | dest->request.value = request; |
317 | } | 317 | } |
318 | int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length) | 318 | static int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length) |
319 | { | 319 | { |
320 | /* Parse raw data received from socket into MSIMessage struct */ | 320 | /* Parse raw data received from socket into MSIMessage struct */ |
321 | 321 | ||
@@ -394,7 +394,8 @@ int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint1 | |||
394 | 394 | ||
395 | return 0; | 395 | return 0; |
396 | } | 396 | } |
397 | uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, uint16_t *length) | 397 | static uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, |
398 | uint16_t *length) | ||
398 | { | 399 | { |
399 | /* Parse a single header for sending */ | 400 | /* Parse a single header for sending */ |
400 | assert(dest); | 401 | assert(dest); |
@@ -412,7 +413,7 @@ uint8_t *msg_parse_header_out(MSIHeaderID id, uint8_t *dest, const void *value, | |||
412 | 413 | ||
413 | return dest + value_len; /* Set to next position ready to be written */ | 414 | return dest + value_len; /* Set to next position ready to be written */ |
414 | } | 415 | } |
415 | int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg) | 416 | static int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg) |
416 | { | 417 | { |
417 | /* Parse and send message */ | 418 | /* Parse and send message */ |
418 | assert(m); | 419 | assert(m); |
@@ -457,7 +458,7 @@ int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg) | |||
457 | 458 | ||
458 | return -1; | 459 | return -1; |
459 | } | 460 | } |
460 | int send_error(Messenger *m, uint32_t friend_number, MSIError error) | 461 | static int send_error(Messenger *m, uint32_t friend_number, MSIError error) |
461 | { | 462 | { |
462 | /* Send error message */ | 463 | /* Send error message */ |
463 | assert(m); | 464 | assert(m); |
@@ -473,7 +474,7 @@ int send_error(Messenger *m, uint32_t friend_number, MSIError error) | |||
473 | send_message(m, friend_number, &msg); | 474 | send_message(m, friend_number, &msg); |
474 | return 0; | 475 | return 0; |
475 | } | 476 | } |
476 | int invoke_callback(MSICall *call, MSICallbackID cb) | 477 | static int invoke_callback(MSICall *call, MSICallbackID cb) |
477 | { | 478 | { |
478 | assert(call); | 479 | assert(call); |
479 | 480 | ||
@@ -510,7 +511,7 @@ static MSICall *get_call(MSISession *session, uint32_t friend_number) | |||
510 | 511 | ||
511 | return session->calls[friend_number]; | 512 | return session->calls[friend_number]; |
512 | } | 513 | } |
513 | MSICall *new_call(MSISession *session, uint32_t friend_number) | 514 | static MSICall *new_call(MSISession *session, uint32_t friend_number) |
514 | { | 515 | { |
515 | assert(session); | 516 | assert(session); |
516 | 517 | ||
@@ -563,7 +564,7 @@ MSICall *new_call(MSISession *session, uint32_t friend_number) | |||
563 | session->calls[friend_number] = rc; | 564 | session->calls[friend_number] = rc; |
564 | return rc; | 565 | return rc; |
565 | } | 566 | } |
566 | void kill_call(MSICall *call) | 567 | static void kill_call(MSICall *call) |
567 | { | 568 | { |
568 | /* Assume that session mutex is locked */ | 569 | /* Assume that session mutex is locked */ |
569 | if (call == nullptr) { | 570 | if (call == nullptr) { |
@@ -604,7 +605,7 @@ CLEAR_CONTAINER: | |||
604 | free(call); | 605 | free(call); |
605 | session->calls = nullptr; | 606 | session->calls = nullptr; |
606 | } | 607 | } |
607 | void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data) | 608 | static void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *data) |
608 | { | 609 | { |
609 | MSISession *session = (MSISession *)data; | 610 | MSISession *session = (MSISession *)data; |
610 | 611 | ||
@@ -630,7 +631,7 @@ void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void * | |||
630 | break; | 631 | break; |
631 | } | 632 | } |
632 | } | 633 | } |
633 | void handle_init(MSICall *call, const MSIMessage *msg) | 634 | static void handle_init(MSICall *call, const MSIMessage *msg) |
634 | { | 635 | { |
635 | assert(call); | 636 | assert(call); |
636 | LOGGER_DEBUG(call->session->messenger->log, | 637 | LOGGER_DEBUG(call->session->messenger->log, |
@@ -691,7 +692,7 @@ FAILURE: | |||
691 | send_error(call->session->messenger, call->friend_number, call->error); | 692 | send_error(call->session->messenger, call->friend_number, call->error); |
692 | kill_call(call); | 693 | kill_call(call); |
693 | } | 694 | } |
694 | void handle_push(MSICall *call, const MSIMessage *msg) | 695 | static void handle_push(MSICall *call, const MSIMessage *msg) |
695 | { | 696 | { |
696 | assert(call); | 697 | assert(call); |
697 | 698 | ||
@@ -746,7 +747,7 @@ FAILURE: | |||
746 | send_error(call->session->messenger, call->friend_number, call->error); | 747 | send_error(call->session->messenger, call->friend_number, call->error); |
747 | kill_call(call); | 748 | kill_call(call); |
748 | } | 749 | } |
749 | void handle_pop(MSICall *call, const MSIMessage *msg) | 750 | static void handle_pop(MSICall *call, const MSIMessage *msg) |
750 | { | 751 | { |
751 | assert(call); | 752 | assert(call); |
752 | 753 | ||
@@ -791,7 +792,7 @@ void handle_pop(MSICall *call, const MSIMessage *msg) | |||
791 | 792 | ||
792 | kill_call(call); | 793 | kill_call(call); |
793 | } | 794 | } |
794 | void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object) | 795 | static void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object) |
795 | { | 796 | { |
796 | LOGGER_DEBUG(m->log, "Got msi message"); | 797 | LOGGER_DEBUG(m->log, "Got msi message"); |
797 | 798 | ||
diff --git a/toxav/toxav.c b/toxav/toxav.c index a30bd7fb..2d753176 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -956,7 +956,7 @@ void toxav_callback_video_receive_frame(ToxAV *av, toxav_video_receive_frame_cb | |||
956 | * :: Internal | 956 | * :: Internal |
957 | * | 957 | * |
958 | ******************************************************************************/ | 958 | ******************************************************************************/ |
959 | void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data) | 959 | static void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *user_data) |
960 | { | 960 | { |
961 | /* Callback which is called when the internal measure mechanism reported packet loss. | 961 | /* Callback which is called when the internal measure mechanism reported packet loss. |
962 | * We report suggested lowered bitrate to an app. If app is sending both audio and video, | 962 | * We report suggested lowered bitrate to an app. If app is sending both audio and video, |
@@ -1001,7 +1001,7 @@ void callback_bwc(BWController *bwc, uint32_t friend_number, float loss, void *u | |||
1001 | 1001 | ||
1002 | pthread_mutex_unlock(call->av->mutex); | 1002 | pthread_mutex_unlock(call->av->mutex); |
1003 | } | 1003 | } |
1004 | int callback_invite(void *toxav_inst, MSICall *call) | 1004 | static int callback_invite(void *toxav_inst, MSICall *call) |
1005 | { | 1005 | { |
1006 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1006 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1007 | pthread_mutex_lock(toxav->mutex); | 1007 | pthread_mutex_lock(toxav->mutex); |
@@ -1029,7 +1029,7 @@ int callback_invite(void *toxav_inst, MSICall *call) | |||
1029 | pthread_mutex_unlock(toxav->mutex); | 1029 | pthread_mutex_unlock(toxav->mutex); |
1030 | return 0; | 1030 | return 0; |
1031 | } | 1031 | } |
1032 | int callback_start(void *toxav_inst, MSICall *call) | 1032 | static int callback_start(void *toxav_inst, MSICall *call) |
1033 | { | 1033 | { |
1034 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1034 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1035 | pthread_mutex_lock(toxav->mutex); | 1035 | pthread_mutex_lock(toxav->mutex); |
@@ -1057,7 +1057,7 @@ int callback_start(void *toxav_inst, MSICall *call) | |||
1057 | pthread_mutex_unlock(toxav->mutex); | 1057 | pthread_mutex_unlock(toxav->mutex); |
1058 | return 0; | 1058 | return 0; |
1059 | } | 1059 | } |
1060 | int callback_end(void *toxav_inst, MSICall *call) | 1060 | static int callback_end(void *toxav_inst, MSICall *call) |
1061 | { | 1061 | { |
1062 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1062 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1063 | pthread_mutex_lock(toxav->mutex); | 1063 | pthread_mutex_lock(toxav->mutex); |
@@ -1072,7 +1072,7 @@ int callback_end(void *toxav_inst, MSICall *call) | |||
1072 | pthread_mutex_unlock(toxav->mutex); | 1072 | pthread_mutex_unlock(toxav->mutex); |
1073 | return 0; | 1073 | return 0; |
1074 | } | 1074 | } |
1075 | int callback_error(void *toxav_inst, MSICall *call) | 1075 | static int callback_error(void *toxav_inst, MSICall *call) |
1076 | { | 1076 | { |
1077 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1077 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1078 | pthread_mutex_lock(toxav->mutex); | 1078 | pthread_mutex_lock(toxav->mutex); |
@@ -1087,7 +1087,7 @@ int callback_error(void *toxav_inst, MSICall *call) | |||
1087 | pthread_mutex_unlock(toxav->mutex); | 1087 | pthread_mutex_unlock(toxav->mutex); |
1088 | return 0; | 1088 | return 0; |
1089 | } | 1089 | } |
1090 | int callback_capabilites(void *toxav_inst, MSICall *call) | 1090 | static int callback_capabilites(void *toxav_inst, MSICall *call) |
1091 | { | 1091 | { |
1092 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1092 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1093 | pthread_mutex_lock(toxav->mutex); | 1093 | pthread_mutex_lock(toxav->mutex); |
@@ -1109,14 +1109,14 @@ int callback_capabilites(void *toxav_inst, MSICall *call) | |||
1109 | pthread_mutex_unlock(toxav->mutex); | 1109 | pthread_mutex_unlock(toxav->mutex); |
1110 | return 0; | 1110 | return 0; |
1111 | } | 1111 | } |
1112 | bool audio_bit_rate_invalid(uint32_t bit_rate) | 1112 | static bool audio_bit_rate_invalid(uint32_t bit_rate) |
1113 | { | 1113 | { |
1114 | /* Opus RFC 6716 section-2.1.1 dictates the following: | 1114 | /* Opus RFC 6716 section-2.1.1 dictates the following: |
1115 | * Opus supports all bit rates from 6 kbit/s to 510 kbit/s. | 1115 | * Opus supports all bit rates from 6 kbit/s to 510 kbit/s. |
1116 | */ | 1116 | */ |
1117 | return bit_rate < 6 || bit_rate > 510; | 1117 | return bit_rate < 6 || bit_rate > 510; |
1118 | } | 1118 | } |
1119 | bool video_bit_rate_invalid(uint32_t bit_rate) | 1119 | static bool video_bit_rate_invalid(uint32_t bit_rate) |
1120 | { | 1120 | { |
1121 | /* https://www.webmproject.org/docs/webm-sdk/structvpx__codec__enc__cfg.html shows the following: | 1121 | /* https://www.webmproject.org/docs/webm-sdk/structvpx__codec__enc__cfg.html shows the following: |
1122 | * unsigned int rc_target_bitrate | 1122 | * unsigned int rc_target_bitrate |
@@ -1127,7 +1127,7 @@ bool video_bit_rate_invalid(uint32_t bit_rate) | |||
1127 | */ | 1127 | */ |
1128 | return bit_rate > UINT_MAX; | 1128 | return bit_rate > UINT_MAX; |
1129 | } | 1129 | } |
1130 | bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t state) | 1130 | static bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t state) |
1131 | { | 1131 | { |
1132 | if (av->scb) { | 1132 | if (av->scb) { |
1133 | av->scb(av, friend_number, state, av->scb_user_data); | 1133 | av->scb(av, friend_number, state, av->scb_user_data); |
@@ -1138,7 +1138,7 @@ bool invoke_call_state_callback(ToxAV *av, uint32_t friend_number, uint32_t stat | |||
1138 | return true; | 1138 | return true; |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error) | 1141 | static ToxAVCall *call_new(ToxAV *av, uint32_t friend_number, Toxav_Err_Call *error) |
1142 | { | 1142 | { |
1143 | /* Assumes mutex locked */ | 1143 | /* Assumes mutex locked */ |
1144 | Toxav_Err_Call rc = TOXAV_ERR_CALL_OK; | 1144 | Toxav_Err_Call rc = TOXAV_ERR_CALL_OK; |
@@ -1228,7 +1228,7 @@ RETURN: | |||
1228 | return call; | 1228 | return call; |
1229 | } | 1229 | } |
1230 | 1230 | ||
1231 | ToxAVCall *call_get(ToxAV *av, uint32_t friend_number) | 1231 | static ToxAVCall *call_get(ToxAV *av, uint32_t friend_number) |
1232 | { | 1232 | { |
1233 | /* Assumes mutex locked */ | 1233 | /* Assumes mutex locked */ |
1234 | if (av->calls == nullptr || av->calls_tail < friend_number) { | 1234 | if (av->calls == nullptr || av->calls_tail < friend_number) { |
@@ -1238,7 +1238,7 @@ ToxAVCall *call_get(ToxAV *av, uint32_t friend_number) | |||
1238 | return av->calls[friend_number]; | 1238 | return av->calls[friend_number]; |
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | ToxAVCall *call_remove(ToxAVCall *call) | 1241 | static ToxAVCall *call_remove(ToxAVCall *call) |
1242 | { | 1242 | { |
1243 | if (call == nullptr) { | 1243 | if (call == nullptr) { |
1244 | return nullptr; | 1244 | return nullptr; |
@@ -1288,7 +1288,7 @@ CLEAR: | |||
1288 | return nullptr; | 1288 | return nullptr; |
1289 | } | 1289 | } |
1290 | 1290 | ||
1291 | bool call_prepare_transmission(ToxAVCall *call) | 1291 | static bool call_prepare_transmission(ToxAVCall *call) |
1292 | { | 1292 | { |
1293 | /* Assumes mutex locked */ | 1293 | /* Assumes mutex locked */ |
1294 | 1294 | ||
@@ -1371,7 +1371,7 @@ FAILURE_2: | |||
1371 | return false; | 1371 | return false; |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | void call_kill_transmission(ToxAVCall *call) | 1374 | static void call_kill_transmission(ToxAVCall *call) |
1375 | { | 1375 | { |
1376 | if (call == nullptr || call->active == 0) { | 1376 | if (call == nullptr || call->active == 0) { |
1377 | return; | 1377 | return; |