feat(gateway): relay complete encoded frames

This commit is contained in:
sechmachine
2026-07-30 22:47:48 +07:00
parent f12ed6c685
commit 786c96b110
22 changed files with 1023 additions and 159 deletions
+19
View File
@@ -1,6 +1,7 @@
package gateway
import (
"context"
"net"
"testing"
"time"
@@ -17,6 +18,24 @@ func TestGatewaySlowReaderStillCleansUpWithinBound(t *testing.T) {
harness.waitReleased(t)
}
func TestGatewayDropsVideoPastQueueResidenceBound(t *testing.T) {
harness := newGatewayTransportHarness(t)
harness.drainInitialMedia(t)
before := harness.server.Metrics().MediaDrops
harness.session.video <- ProviderMedia{
Payload: []byte("stale-complete-frame"), ReceivedAt: time.Now().Add(-time.Second),
EnqueuedAt: time.Now().Add(-nativeApolloVideoQueueLatency - time.Millisecond),
}
ctx, cancel := context.WithTimeout(context.Background(), 150*time.Millisecond)
defer cancel()
if frame, err := harness.client.ReceiveFrame(ctx); err == nil {
t.Fatalf("expired provider frame crossed the public transport: %#v", frame)
}
if drops := harness.server.Metrics().MediaDrops - before; drops != 1 {
t.Fatalf("expired queue drops = %d, want 1", drops)
}
}
func TestGatewayMalformedUDPDoesNotAmplify(t *testing.T) {
harness := newGatewayTransportHarness(t)
connection, err := net.DialUDP("udp", nil, harness.server.Addr().(*net.UDPAddr))