mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-06-07 12:54:43 +00:00
session.Config used to spread 16 per-transport tuning fields across its top level (VideoWidth/Height/.../VP8FPS/.../SEIAckTimeoutMS). The flat layout meant every caller had to know which fields belong to which transport, and the YAML→session bridge in internal/config repeated the same name 32 times across Apply/ApplyProfile. Group them under VideoConfig/VP8Config/SEIConfig structs hung off session.Config. internal/config now does e.g. dst.Video.Width = pickInt(dst.Video.Width, f.Video.Width) instead of touching dst.VideoWidth. session.ApplyTransportDefaults, validateVideoChannel/VP8Channel/SEIChannel and buildTransportOptions read through cfg.Video.*/cfg.VP8.*/cfg.SEI.* in the same way. The YAML schema itself was already grouped (Video / VP8 / SEI sections); this commit lines session.Config up with it so the Apply functions can mirror the YAML structure 1:1 instead of unpacking it into 32 flat assignments. All session/config/e2e/cmd/main tests that referenced cfg.VideoX directly are updated to cfg.Video.X. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
44 lines
1.3 KiB
Go
44 lines
1.3 KiB
Go
package session
|
|
|
|
import (
|
|
"github.com/openlibrecommunity/olcrtc/internal/transport"
|
|
"github.com/openlibrecommunity/olcrtc/internal/transport/seichannel"
|
|
"github.com/openlibrecommunity/olcrtc/internal/transport/videochannel"
|
|
"github.com/openlibrecommunity/olcrtc/internal/transport/vp8channel"
|
|
)
|
|
|
|
// buildTransportOptions packs per-transport tuning fields from cfg into the
|
|
// typed Options value the chosen transport expects. Transports without
|
|
// tunable options (datachannel) return nil.
|
|
func buildTransportOptions(cfg Config) transport.Options {
|
|
switch cfg.Transport {
|
|
case transportVideo:
|
|
return videochannel.Options{
|
|
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.VP8.FPS,
|
|
BatchSize: cfg.VP8.BatchSize,
|
|
}
|
|
case transportSEI:
|
|
return seichannel.Options{
|
|
FPS: cfg.SEI.FPS,
|
|
BatchSize: cfg.SEI.BatchSize,
|
|
FragmentSize: cfg.SEI.FragmentSize,
|
|
AckTimeoutMS: cfg.SEI.AckTimeoutMS,
|
|
}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|