diff --git a/cmd/olcrtc/main_test.go b/cmd/olcrtc/main_test.go index c2bb41d..e70042a 100644 --- a/cmd/olcrtc/main_test.go +++ b/cmd/olcrtc/main_test.go @@ -161,8 +161,8 @@ func TestRunWithArgsAppliesTransportDefaults(t *testing.T) { oldRunSession := runSession t.Cleanup(func() { runSession = oldRunSession }) runSession = func(_ context.Context, cfg session.Config) error { - if cfg.VP8FPS != 25 || cfg.VP8BatchSize != 1 { - t.Fatalf("VP8 defaults = fps %d batch %d, want 25/1", cfg.VP8FPS, cfg.VP8BatchSize) + if cfg.VP8.FPS != 25 || cfg.VP8.BatchSize != 1 { + t.Fatalf("VP8 defaults = fps %d batch %d, want 25/1", cfg.VP8.FPS, cfg.VP8.BatchSize) } return nil } @@ -201,8 +201,8 @@ func TestRunWithArgsFailoverProfiles(t *testing.T) { var seen []string runSession = func(_ context.Context, cfg session.Config) error { seen = append(seen, cfg.Auth+"/"+cfg.Transport) - if cfg.Auth == "wbstream" && (cfg.VP8FPS != 25 || cfg.VP8BatchSize != 1) { - t.Fatalf("VP8 defaults = fps %d batch %d, want 25/1", cfg.VP8FPS, cfg.VP8BatchSize) + if cfg.Auth == "wbstream" && (cfg.VP8.FPS != 25 || cfg.VP8.BatchSize != 1) { + t.Fatalf("VP8 defaults = fps %d batch %d, want 25/1", cfg.VP8.FPS, cfg.VP8.BatchSize) } return errBoom } diff --git a/internal/app/session/session.go b/internal/app/session/session.go index 6ef7d23..f901cd6 100644 --- a/internal/app/session/session.go +++ b/internal/app/session/session.go @@ -144,6 +144,34 @@ var ( errNonNegativeDuration = errors.New("duration must be >= 0") ) +// VideoConfig holds tunables for the videochannel transport. +type VideoConfig struct { + Width int + Height int + FPS int + Bitrate string + HW string + QRSize int + QRRecovery string + Codec string + TileModule int + TileRS int +} + +// VP8Config holds tunables for the vp8channel transport. +type VP8Config struct { + FPS int + BatchSize int +} + +// SEIConfig holds tunables for the seichannel transport. +type SEIConfig struct { + FPS int + BatchSize int + FragmentSize int + AckTimeoutMS int +} + // Config holds runtime session settings. type Config struct { Mode string @@ -162,22 +190,9 @@ type Config struct { DNSServer string SOCKSProxyAddr string SOCKSProxyPort int - VideoWidth int - VideoHeight int - VideoFPS int - VideoBitrate string - VideoHW string - VideoQRSize int - VideoQRRecovery string - VideoCodec string - VideoTileModule int - VideoTileRS int - VP8FPS int - VP8BatchSize int - SEIFPS int - SEIBatchSize int - SEIFragmentSize int - SEIAckTimeoutMS int + Video VideoConfig + VP8 VP8Config + SEI SEIConfig LivenessInterval string LivenessTimeout string LivenessFailures int @@ -255,56 +270,56 @@ func ApplyLivenessDefaults(cfg Config) Config { } func applyVideoDefaults(cfg Config) Config { - if cfg.VideoCodec == "" { - cfg.VideoCodec = videoCodecQRCode + if cfg.Video.Codec == "" { + cfg.Video.Codec = videoCodecQRCode } width := defaultVideoWidth - if cfg.VideoCodec == videoCodecTile { + if cfg.Video.Codec == videoCodecTile { width = defaultVideoHeight } - if cfg.VideoWidth == 0 { - cfg.VideoWidth = width + if cfg.Video.Width == 0 { + cfg.Video.Width = width } - if cfg.VideoHeight == 0 { - cfg.VideoHeight = defaultVideoHeight + if cfg.Video.Height == 0 { + cfg.Video.Height = defaultVideoHeight } - if cfg.VideoFPS == 0 { - cfg.VideoFPS = defaultVideoFPS + if cfg.Video.FPS == 0 { + cfg.Video.FPS = defaultVideoFPS } - if cfg.VideoBitrate == "" { - cfg.VideoBitrate = defaultVideoBitrate + if cfg.Video.Bitrate == "" { + cfg.Video.Bitrate = defaultVideoBitrate } - if cfg.VideoHW == "" { - cfg.VideoHW = defaultVideoHW + if cfg.Video.HW == "" { + cfg.Video.HW = defaultVideoHW } - if cfg.VideoQRRecovery == "" { - cfg.VideoQRRecovery = defaultVideoQRRecovery + if cfg.Video.QRRecovery == "" { + cfg.Video.QRRecovery = defaultVideoQRRecovery } return cfg } func applyVP8Defaults(cfg Config) Config { - if cfg.VP8FPS == 0 { - cfg.VP8FPS = defaultVP8FPS + if cfg.VP8.FPS == 0 { + cfg.VP8.FPS = defaultVP8FPS } - if cfg.VP8BatchSize == 0 { - cfg.VP8BatchSize = defaultVP8BatchSize + if cfg.VP8.BatchSize == 0 { + cfg.VP8.BatchSize = defaultVP8BatchSize } return cfg } func applySEIDefaults(cfg Config) Config { - if cfg.SEIFPS == 0 { - cfg.SEIFPS = defaultSEIFPS + if cfg.SEI.FPS == 0 { + cfg.SEI.FPS = defaultSEIFPS } - if cfg.SEIBatchSize == 0 { - cfg.SEIBatchSize = defaultSEIBatchSize + if cfg.SEI.BatchSize == 0 { + cfg.SEI.BatchSize = defaultSEIBatchSize } - if cfg.SEIFragmentSize == 0 { - cfg.SEIFragmentSize = defaultSEIFragmentSize + if cfg.SEI.FragmentSize == 0 { + cfg.SEI.FragmentSize = defaultSEIFragmentSize } - if cfg.SEIAckTimeoutMS == 0 { - cfg.SEIAckTimeoutMS = defaultSEIAckTimeoutMS + if cfg.SEI.AckTimeoutMS == 0 { + cfg.SEI.AckTimeoutMS = defaultSEIAckTimeoutMS } return cfg } @@ -394,55 +409,55 @@ func validateTransportConfig(cfg Config) error { } func validateVideoCodec(cfg Config) error { - if cfg.VideoCodec != "" && cfg.VideoCodec != videoCodecQRCode && cfg.VideoCodec != videoCodecTile { + if cfg.Video.Codec != "" && cfg.Video.Codec != videoCodecQRCode && cfg.Video.Codec != videoCodecTile { return ErrVideoCodecInvalid } - if cfg.VideoCodec == videoCodecTile && (cfg.VideoWidth != 1080 || cfg.VideoHeight != 1080) { + if cfg.Video.Codec == videoCodecTile && (cfg.Video.Width != 1080 || cfg.Video.Height != 1080) { return ErrTileCodecDimensions } return nil } func validateVideoChannel(cfg Config) error { - if cfg.VideoWidth == 0 { + if cfg.Video.Width == 0 { return ErrVideoWidthRequired } - if cfg.VideoHeight == 0 { + if cfg.Video.Height == 0 { return ErrVideoHeightRequired } - if cfg.VideoFPS == 0 { + if cfg.Video.FPS == 0 { return ErrVideoFPSRequired } - if cfg.VideoBitrate == "" { + if cfg.Video.Bitrate == "" { return ErrVideoBitrateRequired } - if cfg.VideoHW == "" { + if cfg.Video.HW == "" { return ErrVideoHWRequired } return validateVideoCodec(cfg) } func validateVP8Channel(cfg Config) error { - if cfg.VP8FPS == 0 { + if cfg.VP8.FPS == 0 { return ErrVP8FPSRequired } - if cfg.VP8BatchSize == 0 { + if cfg.VP8.BatchSize == 0 { return ErrVP8BatchSizeRequired } return nil } func validateSEIChannel(cfg Config) error { - if cfg.SEIFPS == 0 { + if cfg.SEI.FPS == 0 { return ErrSEIFPSRequired } - if cfg.SEIBatchSize == 0 { + if cfg.SEI.BatchSize == 0 { return ErrSEIBatchSizeRequired } - if cfg.SEIFragmentSize == 0 { + if cfg.SEI.FragmentSize == 0 { return ErrSEIFragmentSizeRequired } - if cfg.SEIAckTimeoutMS == 0 { + if cfg.SEI.AckTimeoutMS == 0 { return ErrSEIAckTimeoutRequired } return nil diff --git a/internal/app/session/session_test.go b/internal/app/session/session_test.go index 02206a3..7310907 100644 --- a/internal/app/session/session_test.go +++ b/internal/app/session/session_test.go @@ -22,62 +22,47 @@ func TestApplyTransportDefaults(t *testing.T) { { name: "vp8", in: Config{Transport: transportVP8}, - want: Config{Transport: transportVP8, VP8FPS: 25, VP8BatchSize: 1}, + want: Config{Transport: transportVP8, VP8: VP8Config{FPS: 25, BatchSize: 1}}, }, { name: "sei", in: Config{Transport: transportSEI}, want: Config{ - Transport: transportSEI, - SEIFPS: 60, - SEIBatchSize: 64, - SEIFragmentSize: 900, - SEIAckTimeoutMS: 2000, + Transport: transportSEI, + SEI: SEIConfig{FPS: 60, BatchSize: 64, FragmentSize: 900, AckTimeoutMS: 2000}, }, }, { name: "video qrcode", in: Config{Transport: transportVideo}, want: Config{ - Transport: transportVideo, - VideoWidth: 1920, - VideoHeight: 1080, - VideoFPS: 30, - VideoBitrate: "2M", - VideoHW: defaultVideoHW, - VideoQRRecovery: "low", - VideoCodec: videoCodecQRCode, + Transport: transportVideo, + Video: VideoConfig{ + Width: 1920, Height: 1080, FPS: 30, Bitrate: "2M", + HW: defaultVideoHW, QRRecovery: "low", Codec: videoCodecQRCode, + }, }, }, { name: "video tile dimensions", - in: Config{Transport: transportVideo, VideoCodec: videoCodecTile}, + in: Config{Transport: transportVideo, Video: VideoConfig{Codec: videoCodecTile}}, want: Config{ - Transport: transportVideo, - VideoWidth: 1080, - VideoHeight: 1080, - VideoFPS: 30, - VideoBitrate: "2M", - VideoHW: defaultVideoHW, - VideoQRRecovery: "low", - VideoCodec: videoCodecTile, + Transport: transportVideo, + Video: VideoConfig{ + Width: 1080, Height: 1080, FPS: 30, Bitrate: "2M", + HW: defaultVideoHW, QRRecovery: "low", Codec: videoCodecTile, + }, }, }, { name: "keeps explicit values", in: Config{ - Transport: transportSEI, - SEIFPS: 10, - SEIBatchSize: 2, - SEIFragmentSize: 300, - SEIAckTimeoutMS: 1500, + Transport: transportSEI, + SEI: SEIConfig{FPS: 10, BatchSize: 2, FragmentSize: 300, AckTimeoutMS: 1500}, }, want: Config{ - Transport: transportSEI, - SEIFPS: 10, - SEIBatchSize: 2, - SEIFragmentSize: 300, - SEIAckTimeoutMS: 1500, + Transport: transportSEI, + SEI: SEIConfig{FPS: 10, BatchSize: 2, FragmentSize: 300, AckTimeoutMS: 1500}, }, }, } @@ -241,12 +226,12 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 - cfg.VideoHeight = 480 - cfg.VideoFPS = 30 - cfg.VideoBitrate = "1M" - cfg.VideoHW = defaultVideoHW - cfg.VideoCodec = "bogus" + cfg.Video.Width = 640 + cfg.Video.Height = 480 + cfg.Video.FPS = 30 + cfg.Video.Bitrate = "1M" + cfg.Video.HW = defaultVideoHW + cfg.Video.Codec = "bogus" return cfg }(), want: ErrVideoCodecInvalid, @@ -256,7 +241,7 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 + cfg.Video.Width = 640 return cfg }(), want: ErrVideoHeightRequired, @@ -266,8 +251,8 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 - cfg.VideoHeight = 480 + cfg.Video.Width = 640 + cfg.Video.Height = 480 return cfg }(), want: ErrVideoFPSRequired, @@ -277,9 +262,9 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 - cfg.VideoHeight = 480 - cfg.VideoFPS = 30 + cfg.Video.Width = 640 + cfg.Video.Height = 480 + cfg.Video.FPS = 30 return cfg }(), want: ErrVideoBitrateRequired, @@ -289,10 +274,10 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 - cfg.VideoHeight = 480 - cfg.VideoFPS = 30 - cfg.VideoBitrate = "1M" + cfg.Video.Width = 640 + cfg.Video.Height = 480 + cfg.Video.FPS = 30 + cfg.Video.Bitrate = "1M" return cfg }(), want: ErrVideoHWRequired, @@ -302,12 +287,12 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 640 - cfg.VideoHeight = 480 - cfg.VideoFPS = 30 - cfg.VideoBitrate = "1M" - cfg.VideoHW = defaultVideoHW - cfg.VideoCodec = "tile" + cfg.Video.Width = 640 + cfg.Video.Height = 480 + cfg.Video.FPS = 30 + cfg.Video.Bitrate = "1M" + cfg.Video.HW = defaultVideoHW + cfg.Video.Codec = "tile" return cfg }(), want: ErrTileCodecDimensions, @@ -317,12 +302,12 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "videochannel" - cfg.VideoWidth = 1080 - cfg.VideoHeight = 1080 - cfg.VideoFPS = 30 - cfg.VideoBitrate = "1M" - cfg.VideoHW = defaultVideoHW - cfg.VideoCodec = "tile" + cfg.Video.Width = 1080 + cfg.Video.Height = 1080 + cfg.Video.FPS = 30 + cfg.Video.Bitrate = "1M" + cfg.Video.HW = defaultVideoHW + cfg.Video.Codec = "tile" return cfg }(), }, @@ -340,7 +325,7 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "vp8channel" - cfg.VP8FPS = 25 + cfg.VP8.FPS = 25 return cfg }(), want: ErrVP8BatchSizeRequired, @@ -350,8 +335,8 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "vp8channel" - cfg.VP8FPS = 25 - cfg.VP8BatchSize = 16 + cfg.VP8.FPS = 25 + cfg.VP8.BatchSize = 16 return cfg }(), }, @@ -369,7 +354,7 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "seichannel" - cfg.SEIFPS = 20 + cfg.SEI.FPS = 20 return cfg }(), want: ErrSEIBatchSizeRequired, @@ -379,8 +364,8 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "seichannel" - cfg.SEIFPS = 20 - cfg.SEIBatchSize = 1 + cfg.SEI.FPS = 20 + cfg.SEI.BatchSize = 1 return cfg }(), want: ErrSEIFragmentSizeRequired, @@ -390,9 +375,9 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "seichannel" - cfg.SEIFPS = 20 - cfg.SEIBatchSize = 1 - cfg.SEIFragmentSize = 900 + cfg.SEI.FPS = 20 + cfg.SEI.BatchSize = 1 + cfg.SEI.FragmentSize = 900 return cfg }(), want: ErrSEIAckTimeoutRequired, @@ -402,10 +387,10 @@ func TestValidate(t *testing.T) { cfg: func() Config { cfg := base cfg.Transport = "seichannel" - cfg.SEIFPS = 20 - cfg.SEIBatchSize = 1 - cfg.SEIFragmentSize = 900 - cfg.SEIAckTimeoutMS = 3000 + cfg.SEI.FPS = 20 + cfg.SEI.BatchSize = 1 + cfg.SEI.FragmentSize = 900 + cfg.SEI.AckTimeoutMS = 3000 return cfg }(), }, diff --git a/internal/app/session/transport_options.go b/internal/app/session/transport_options.go index 911549d..5f15484 100644 --- a/internal/app/session/transport_options.go +++ b/internal/app/session/transport_options.go @@ -14,28 +14,28 @@ func buildTransportOptions(cfg Config) transport.Options { switch cfg.Transport { case transportVideo: return videochannel.Options{ - Width: cfg.VideoWidth, - Height: cfg.VideoHeight, - FPS: cfg.VideoFPS, - Bitrate: cfg.VideoBitrate, - HW: cfg.VideoHW, - QRSize: cfg.VideoQRSize, - QRRecovery: cfg.VideoQRRecovery, - Codec: cfg.VideoCodec, - TileModule: cfg.VideoTileModule, - TileRS: cfg.VideoTileRS, + Width: cfg.Video.Width, + Height: cfg.Video.Height, + FPS: cfg.Video.FPS, + Bitrate: cfg.Video.Bitrate, + HW: cfg.Video.HW, + QRSize: cfg.Video.QRSize, + QRRecovery: cfg.Video.QRRecovery, + Codec: cfg.Video.Codec, + TileModule: cfg.Video.TileModule, + TileRS: cfg.Video.TileRS, } case transportVP8: return vp8channel.Options{ - FPS: cfg.VP8FPS, - BatchSize: cfg.VP8BatchSize, + FPS: cfg.VP8.FPS, + BatchSize: cfg.VP8.BatchSize, } case transportSEI: return seichannel.Options{ - FPS: cfg.SEIFPS, - BatchSize: cfg.SEIBatchSize, - FragmentSize: cfg.SEIFragmentSize, - AckTimeoutMS: cfg.SEIAckTimeoutMS, + FPS: cfg.SEI.FPS, + BatchSize: cfg.SEI.BatchSize, + FragmentSize: cfg.SEI.FragmentSize, + AckTimeoutMS: cfg.SEI.AckTimeoutMS, } default: return nil diff --git a/internal/config/config.go b/internal/config/config.go index 5af1fd3..e770297 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -256,22 +256,22 @@ func Apply(dst session.Config, f File) session.Config { dst.DNSServer = pickString(dst.DNSServer, f.Net.DNS) dst.SOCKSProxyAddr = pickString(dst.SOCKSProxyAddr, f.SOCKS.ProxyAddr) dst.SOCKSProxyPort = pickInt(dst.SOCKSProxyPort, f.SOCKS.ProxyPort) - dst.VideoWidth = pickInt(dst.VideoWidth, f.Video.Width) - dst.VideoHeight = pickInt(dst.VideoHeight, f.Video.Height) - dst.VideoFPS = pickInt(dst.VideoFPS, f.Video.FPS) - dst.VideoBitrate = pickString(dst.VideoBitrate, f.Video.Bitrate) - dst.VideoHW = pickString(dst.VideoHW, f.Video.HW) - dst.VideoQRSize = pickInt(dst.VideoQRSize, f.Video.QRSize) - dst.VideoQRRecovery = pickString(dst.VideoQRRecovery, f.Video.QRRecovery) - dst.VideoCodec = pickString(dst.VideoCodec, f.Video.Codec) - dst.VideoTileModule = pickInt(dst.VideoTileModule, f.Video.TileModule) - dst.VideoTileRS = pickInt(dst.VideoTileRS, f.Video.TileRS) - dst.VP8FPS = pickInt(dst.VP8FPS, f.VP8.FPS) - dst.VP8BatchSize = pickInt(dst.VP8BatchSize, f.VP8.BatchSize) - dst.SEIFPS = pickInt(dst.SEIFPS, f.SEI.FPS) - dst.SEIBatchSize = pickInt(dst.SEIBatchSize, f.SEI.BatchSize) - dst.SEIFragmentSize = pickInt(dst.SEIFragmentSize, f.SEI.FragmentSize) - dst.SEIAckTimeoutMS = pickInt(dst.SEIAckTimeoutMS, f.SEI.AckTimeoutMS) + dst.Video.Width = pickInt(dst.Video.Width, f.Video.Width) + dst.Video.Height = pickInt(dst.Video.Height, f.Video.Height) + dst.Video.FPS = pickInt(dst.Video.FPS, f.Video.FPS) + dst.Video.Bitrate = pickString(dst.Video.Bitrate, f.Video.Bitrate) + dst.Video.HW = pickString(dst.Video.HW, f.Video.HW) + dst.Video.QRSize = pickInt(dst.Video.QRSize, f.Video.QRSize) + dst.Video.QRRecovery = pickString(dst.Video.QRRecovery, f.Video.QRRecovery) + dst.Video.Codec = pickString(dst.Video.Codec, f.Video.Codec) + dst.Video.TileModule = pickInt(dst.Video.TileModule, f.Video.TileModule) + dst.Video.TileRS = pickInt(dst.Video.TileRS, f.Video.TileRS) + dst.VP8.FPS = pickInt(dst.VP8.FPS, f.VP8.FPS) + dst.VP8.BatchSize = pickInt(dst.VP8.BatchSize, f.VP8.BatchSize) + dst.SEI.FPS = pickInt(dst.SEI.FPS, f.SEI.FPS) + dst.SEI.BatchSize = pickInt(dst.SEI.BatchSize, f.SEI.BatchSize) + dst.SEI.FragmentSize = pickInt(dst.SEI.FragmentSize, f.SEI.FragmentSize) + dst.SEI.AckTimeoutMS = pickInt(dst.SEI.AckTimeoutMS, f.SEI.AckTimeoutMS) dst.LivenessInterval = pickString(dst.LivenessInterval, f.Liveness.Interval) dst.LivenessTimeout = pickString(dst.LivenessTimeout, f.Liveness.Timeout) dst.LivenessFailures = pickInt(dst.LivenessFailures, f.Liveness.Failures) @@ -301,22 +301,22 @@ func ApplyProfile(base session.Config, p Profile) session.Config { dst.DNSServer = overlayString(dst.DNSServer, p.Net.DNS) dst.SOCKSProxyAddr = overlayString(dst.SOCKSProxyAddr, p.SOCKS.ProxyAddr) dst.SOCKSProxyPort = overlayInt(dst.SOCKSProxyPort, p.SOCKS.ProxyPort) - dst.VideoWidth = overlayInt(dst.VideoWidth, p.Video.Width) - dst.VideoHeight = overlayInt(dst.VideoHeight, p.Video.Height) - dst.VideoFPS = overlayInt(dst.VideoFPS, p.Video.FPS) - dst.VideoBitrate = overlayString(dst.VideoBitrate, p.Video.Bitrate) - dst.VideoHW = overlayString(dst.VideoHW, p.Video.HW) - dst.VideoQRSize = overlayInt(dst.VideoQRSize, p.Video.QRSize) - dst.VideoQRRecovery = overlayString(dst.VideoQRRecovery, p.Video.QRRecovery) - dst.VideoCodec = overlayString(dst.VideoCodec, p.Video.Codec) - dst.VideoTileModule = overlayInt(dst.VideoTileModule, p.Video.TileModule) - dst.VideoTileRS = overlayInt(dst.VideoTileRS, p.Video.TileRS) - dst.VP8FPS = overlayInt(dst.VP8FPS, p.VP8.FPS) - dst.VP8BatchSize = overlayInt(dst.VP8BatchSize, p.VP8.BatchSize) - dst.SEIFPS = overlayInt(dst.SEIFPS, p.SEI.FPS) - dst.SEIBatchSize = overlayInt(dst.SEIBatchSize, p.SEI.BatchSize) - dst.SEIFragmentSize = overlayInt(dst.SEIFragmentSize, p.SEI.FragmentSize) - dst.SEIAckTimeoutMS = overlayInt(dst.SEIAckTimeoutMS, p.SEI.AckTimeoutMS) + dst.Video.Width = overlayInt(dst.Video.Width, p.Video.Width) + dst.Video.Height = overlayInt(dst.Video.Height, p.Video.Height) + dst.Video.FPS = overlayInt(dst.Video.FPS, p.Video.FPS) + dst.Video.Bitrate = overlayString(dst.Video.Bitrate, p.Video.Bitrate) + dst.Video.HW = overlayString(dst.Video.HW, p.Video.HW) + dst.Video.QRSize = overlayInt(dst.Video.QRSize, p.Video.QRSize) + dst.Video.QRRecovery = overlayString(dst.Video.QRRecovery, p.Video.QRRecovery) + dst.Video.Codec = overlayString(dst.Video.Codec, p.Video.Codec) + dst.Video.TileModule = overlayInt(dst.Video.TileModule, p.Video.TileModule) + dst.Video.TileRS = overlayInt(dst.Video.TileRS, p.Video.TileRS) + dst.VP8.FPS = overlayInt(dst.VP8.FPS, p.VP8.FPS) + dst.VP8.BatchSize = overlayInt(dst.VP8.BatchSize, p.VP8.BatchSize) + dst.SEI.FPS = overlayInt(dst.SEI.FPS, p.SEI.FPS) + dst.SEI.BatchSize = overlayInt(dst.SEI.BatchSize, p.SEI.BatchSize) + dst.SEI.FragmentSize = overlayInt(dst.SEI.FragmentSize, p.SEI.FragmentSize) + dst.SEI.AckTimeoutMS = overlayInt(dst.SEI.AckTimeoutMS, p.SEI.AckTimeoutMS) dst.LivenessInterval = overlayString(dst.LivenessInterval, p.Liveness.Interval) dst.LivenessTimeout = overlayString(dst.LivenessTimeout, p.Liveness.Timeout) dst.LivenessFailures = overlayInt(dst.LivenessFailures, p.Liveness.Failures) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 0dbef4e..926aac9 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -96,8 +96,7 @@ func requireAppliedConfig(t *testing.T, got session.Config) { SOCKSPort: 1080, SOCKSUser: "u", SOCKSPass: "p", - VP8FPS: 25, - VP8BatchSize: 4, + VP8: session.VP8Config{FPS: 25, BatchSize: 4}, LivenessInterval: "2s", LivenessTimeout: "500ms", LivenessFailures: 4, @@ -208,7 +207,7 @@ failover: if first.Auth != "wbstream" || first.Transport != "vp8channel" || first.RoomID != "wb-room" { t.Fatalf("first profile = %+v", first) } - if first.KeyHex != "shared-key" || first.DNSServer != "1.1.1.1:53" || first.VP8FPS != 30 || + if first.KeyHex != "shared-key" || first.DNSServer != "1.1.1.1:53" || first.VP8.FPS != 30 || first.LivenessInterval != "1s" || first.LivenessTimeout != "2s" || first.LivenessFailures != 5 || first.MaxSessionDuration != "30m" || first.TrafficMaxPayloadSize != 4096 || first.TrafficMinDelay != "10ms" || first.TrafficMaxDelay != "20ms" { diff --git a/internal/e2e/tunnel_test.go b/internal/e2e/tunnel_test.go index 2f2fe38..4d53291 100644 --- a/internal/e2e/tunnel_test.go +++ b/internal/e2e/tunnel_test.go @@ -632,27 +632,19 @@ func requireRealRoom(ctx context.Context, t *testing.T, carrierName string) stri func validSessionConfig(mode, carrierName, transportName string) session.Config { return session.Config{ Mode: mode, - Transport: transportName, - Auth: carrierName, - RoomID: testRoom, - KeyHex: testKeyHex, - SOCKSHost: "127.0.0.1", - SOCKSPort: 1080, - DNSServer: localDNSServer, - VideoWidth: 1080, - VideoHeight: 1080, - VideoFPS: 30, - VideoBitrate: "1M", - VideoHW: videoHWNone, - VideoCodec: "tile", - VideoTileModule: 4, - VideoTileRS: 20, - VP8FPS: 60, - VP8BatchSize: 8, - SEIFPS: 30, - SEIBatchSize: 4, - SEIFragmentSize: 512, - SEIAckTimeoutMS: 1500, + Transport: transportName, + Auth: carrierName, + RoomID: testRoom, + KeyHex: testKeyHex, + SOCKSHost: "127.0.0.1", + SOCKSPort: 1080, + DNSServer: localDNSServer, + Video: session.VideoConfig{ + Width: 1080, Height: 1080, FPS: 30, Bitrate: "1M", + HW: videoHWNone, Codec: "tile", TileModule: 4, TileRS: 20, + }, + VP8: session.VP8Config{FPS: 60, BatchSize: 8}, + SEI: session.SEIConfig{FPS: 30, BatchSize: 4, FragmentSize: 512, AckTimeoutMS: 1500}, } }