forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from 76bc4c496d..501a32937f
501a32937f Merge branch 'toxav_deadline' of github.com:Green-Sky/c-toxcore into tomato_testing_in_prod 0b49ba2d94 Merge branch 'toxav_video_bitrate' of github.com:Green-Sky/c-toxcore into tomato_testing_in_prod 9c0977d7c6 Merge branch 'toxav_remove_img_copy_encode' of github.com:Green-Sky/c-toxcore into tomato_testing_in_prod 4071d74cc9 fix(ngc): dont double every message, if we are not directly connected but we and the other peer would support direct. 1d4cc783b1 fix(bazel): one more fuzz target that needs netprof 066aafbfcd fix(bazel): make net_prof visible to its consumers fa015c7e2e fix(toxav): remove extra copy of video frame on encode Tested and works, but there might be alignment issues and other stuff. d34f7d1f5c fix(toxav): handle vpx_image_alloc failure 865261a67a chore(toxav): use realtime deadline for vp8 encoder Technically all this does is choose a quality based on frame duration, which we always set to 1, and as such is always realtime. (In same timebase as pts, which we use as a frame counter...) dd12b9889a chore(toxav): tighten the video bitrate to the same as the vp8 encoder internally checks. 9dcc2f530d fix(bazel): missing dep for auto_tests 741ac5f5e6 fix(bazel): missing dep for fuzz target git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 501a32937f4550d4340406a6a73da548849a53af
This commit is contained in:
@ -29,6 +29,9 @@
|
||||
/** Seconds since last direct UDP packet was received before the connection is considered dead */
|
||||
#define GCC_UDP_DIRECT_TIMEOUT (GC_PING_TIMEOUT + 4)
|
||||
|
||||
/** Seconds since last direct UDP packet was sent before we can try again. Cheap NAT hole punch */
|
||||
#define GCC_UDP_DIRECT_RETRY 1
|
||||
|
||||
/** Returns true if array entry does not contain an active packet. */
|
||||
non_null()
|
||||
static bool array_entry_is_empty(const GC_Message_Array_Entry *array_entry)
|
||||
@ -595,7 +598,7 @@ void gcc_resend_packets(const GC_Chat *chat, GC_Connection *gconn)
|
||||
}
|
||||
}
|
||||
|
||||
bool gcc_send_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *packet, uint16_t length)
|
||||
bool gcc_send_packet(const GC_Chat *chat, GC_Connection *gconn, const uint8_t *packet, uint16_t length)
|
||||
{
|
||||
if (packet == nullptr || length == 0) {
|
||||
return false;
|
||||
@ -608,8 +611,12 @@ bool gcc_send_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint
|
||||
return (uint16_t) sendpacket(chat->net, &gconn->addr.ip_port, packet, length) == length;
|
||||
}
|
||||
|
||||
if ((uint16_t) sendpacket(chat->net, &gconn->addr.ip_port, packet, length) == length) {
|
||||
direct_send_attempt = true;
|
||||
if (gcc_conn_should_try_direct(chat->mono_time, gconn)) {
|
||||
gconn->last_sent_direct_try_time = mono_time_get(chat->mono_time);
|
||||
|
||||
if ((uint16_t) sendpacket(chat->net, &gconn->addr.ip_port, packet, length) == length) {
|
||||
direct_send_attempt = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -617,7 +624,7 @@ bool gcc_send_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint
|
||||
return ret == 0 || direct_send_attempt;
|
||||
}
|
||||
|
||||
int gcc_encrypt_and_send_lossless_packet(const GC_Chat *chat, const GC_Connection *gconn, const uint8_t *data,
|
||||
int gcc_encrypt_and_send_lossless_packet(const GC_Chat *chat, GC_Connection *gconn, const uint8_t *data,
|
||||
uint16_t length, uint64_t message_id, uint8_t packet_type)
|
||||
{
|
||||
const uint16_t packet_size = gc_get_wrapped_packet_size(length, NET_PACKET_GC_LOSSLESS);
|
||||
@ -659,6 +666,11 @@ bool gcc_conn_is_direct(const Mono_Time *mono_time, const GC_Connection *gconn)
|
||||
return GCC_UDP_DIRECT_TIMEOUT + gconn->last_received_direct_time > mono_time_get(mono_time);
|
||||
}
|
||||
|
||||
bool gcc_conn_should_try_direct(const Mono_Time *mono_time, const GC_Connection *gconn)
|
||||
{
|
||||
return mono_time_is_timeout(mono_time, gconn->last_sent_direct_try_time, GCC_UDP_DIRECT_RETRY);
|
||||
}
|
||||
|
||||
bool gcc_direct_conn_is_possible(const GC_Chat *chat, const GC_Connection *gconn)
|
||||
{
|
||||
return !net_family_is_unspec(gconn->addr.ip_port.ip.family) && !net_family_is_unspec(net_family(chat->net));
|
||||
|
Reference in New Issue
Block a user