diff --git a/client/transports/Network/connection.c b/client/transports/Network/connection.c index 04fe7979..0767b0ba 100644 --- a/client/transports/Network/connection.c +++ b/client/transports/Network/connection.c @@ -47,7 +47,7 @@ #define NETWORK_CONNECT_POLL_MS 50U #define NETWORK_HANDSHAKE_TIMEOUT_MS 5000U -#define NETWORK_IDLE_TIMEOUT_MS 10000U +#define NETWORK_IDLE_TIMEOUT_MS 30000U #define NETWORK_KEEPALIVE_INTERVAL_MS 1000U #define NETWORK_INITIAL_RTT_MS 1U #define NETWORK_MAX_PEER_STREAMS 16U diff --git a/client/transports/Network/video.c b/client/transports/Network/video.c index 0d2f68ea..22c3ec99 100644 --- a/client/transports/Network/video.c +++ b/client/transports/Network/video.c @@ -48,6 +48,7 @@ #define NETWORK_VIDEO_MAX_FRAGMENTS LG_NET_VIDEO_MAX_FRAGMENTS #define NETWORK_VIDEO_MAX_BLOCKS LG_NET_VIDEO_MAX_BLOCKS #define NETWORK_VIDEO_MAX_FRAME_LATENCY_MS 50U +#define NETWORK_VIDEO_ASSEMBLY_STALL_MS 2000U #define NETWORK_VIDEO_MAX_FRAME_RATE UINT32_MAX #define NETWORK_VIDEO_SCHEDULE_CACHE 8U #define NETWORK_VIDEO_MAX_LEASES 8U @@ -213,6 +214,14 @@ static uint32_t networkVideoSaturatingIncrement(uint32_t value) return value == UINT32_MAX ? value : value + 1U; } +/* Frame latency remains the datagram presentation deadline. Reliable frame + * assembly instead expires after this period without receiving new data. */ +static uint64_t networkVideoAssemblyDeadline(uint64_t now) +{ + return now + (uint64_t)NETWORK_VIDEO_ASSEMBLY_STALL_MS * + UINT64_C(1000000); +} + static uint32_t networkVideoReadU32(const uint8_t * data) { return (uint32_t)data[0] | @@ -709,17 +718,19 @@ static bool networkVideoAllocateAssemblyNL(NetworkVideo * video, fragment->blockCount > NETWORK_VIDEO_MAX_BLOCKS) return false; - struct NetworkVideoAssembly assembly = + const bool sparseAllowed = + (video->config.flags & LG_NET_VIDEO_STREAM_DATAGRAMS) != 0; + struct NetworkVideoAssembly assembly = { .active = true, - .sparseAllowed = - (video->config.flags & LG_NET_VIDEO_STREAM_DATAGRAMS) != 0, + .sparseAllowed = sparseAllowed, .generation = video->decodeGeneration, .configEpoch = fragment->configEpoch, .frameID = fragment->frameID, .firstReceiveNs = now, - .deadlineNs = now + - (uint64_t)video->config.maxFrameLatencyMs * UINT64_C(1000000), + .deadlineNs = sparseAllowed ? + now + (uint64_t)video->config.maxFrameLatencyMs * UINT64_C(1000000) : + networkVideoAssemblyDeadline(now), .frameLength = fragment->frameLength, .fragmentCount = fragment->fragmentCount, .blockCount = fragment->blockCount, @@ -959,6 +970,8 @@ static bool networkVideoAddFragmentNL(NetworkVideo * video, (fragment->flags & LG_NET_VIDEO_FRAGMENT_BLOCK_START) != 0; block->end |= (fragment->flags & LG_NET_VIDEO_FRAGMENT_BLOCK_END) != 0; + if (!assembly->sparseAllowed) + assembly->deadlineNs = networkVideoAssemblyDeadline(now); if (!networkVideoAssemblyComplete(assembly)) return true; diff --git a/idd/LGIdd/transport/network/CNetworkAudio.cpp b/idd/LGIdd/transport/network/CNetworkAudio.cpp index 1714e5e9..f26cd01d 100644 --- a/idd/LGIdd/transport/network/CNetworkAudio.cpp +++ b/idd/LGIdd/transport/network/CNetworkAudio.cpp @@ -39,7 +39,7 @@ namespace constexpr uint32_t PLAYBACK_STREAM_ID = 1; constexpr uint32_t CAPTURE_STREAM_ID = 2; constexpr uint64_t AUDIO_LEASE_MS = 2000; - constexpr uint64_t AUTHORITY_STALL_MS = 20; + constexpr uint64_t AUTHORITY_STALL_MS = 250; constexpr size_t CLOCK_CACHE_SIZE = 8; constexpr size_t RECENT_PACKET_SIZE = 16; @@ -1372,6 +1372,11 @@ NetworkAudioPacketResult CNetworkAudio::Impl::HandleSubscribe( SameSubscription(peer.request, subscribe)) { peer.deadline = now + AUDIO_LEASE_MS; + if (peer.feedbackRevoked) + { + peer.feedbackRevoked = false; + RebalanceRolesNL(); + } if (!peer.pumpInFlight && peer.pumpStage == PumpStage::DONE) { peer.pumpStage = PumpStage::RENEWAL_GRANT;