add arg groups
This commit is contained in:
@@ -28,7 +28,7 @@ func main() {
|
||||
|
||||
http := server.NewHttpServer(lg.With(zap.String("context", "server")), &cfg)
|
||||
|
||||
webrtc.NewWebrtcHandler(ctx, lg.With(zap.String("context", "webrtc")), &cfg.Stream, http.Hndl)
|
||||
webrtc.NewWebrtcHandler(ctx, lg.With(zap.String("context", "webrtc")), cfg.Stream(), http.Hndl)
|
||||
|
||||
http.ListenAndServe(ctx, cfg.Http.Address())
|
||||
|
||||
|
||||
+19
-9
@@ -8,9 +8,17 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Logging ConfigLogging `arg:"group:Logging"`
|
||||
Stream ConfigStream `arg:"group:Stream"`
|
||||
Http ConfigHTTP `arg:"group:Http"`
|
||||
VideoOut ConfigVideoOutputStream `arg:"group:VideoOut"`
|
||||
AudioOut ConfigAudioOutputStream `arg:"group:AudioOut"`
|
||||
AudioIn ConfigAudioInputStream `arg:"group:AudioIn"`
|
||||
Logging ConfigLogging `arg:"group:Logging"`
|
||||
Http ConfigHTTP `arg:"group:Http"`
|
||||
}
|
||||
|
||||
type ConfigStream struct {
|
||||
VideoOut ConfigVideoOutputStream
|
||||
AudioOut ConfigAudioOutputStream
|
||||
AudioIn ConfigAudioInputStream
|
||||
}
|
||||
|
||||
type ConfigLogging struct {
|
||||
@@ -25,12 +33,6 @@ type ConfigHTTP struct {
|
||||
StaticPath *string `arg:"--http-static,env:HTTP_STATIC"`
|
||||
}
|
||||
|
||||
type ConfigStream struct {
|
||||
VideoOut ConfigVideoOutputStream `arg:"group:VideoOut"`
|
||||
AudioOut ConfigAudioOutputStream `arg:"group:AudioOut"`
|
||||
AudioIn ConfigAudioInputStream `arg:"group:AudioIn"`
|
||||
}
|
||||
|
||||
type ConfigVideoOutputStream struct {
|
||||
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
||||
Device string `arg:"--video-device,env:VIDEO_DEVICE" default:"/dev/video0"`
|
||||
@@ -55,6 +57,14 @@ type ConfigAudioInputStream struct {
|
||||
Channels uint `arg:"--audio-channels,env:AUDIO_CHANNELS" default:"1"`
|
||||
}
|
||||
|
||||
func (c *Config) Stream() *ConfigStream {
|
||||
return &ConfigStream{
|
||||
VideoOut: c.VideoOut,
|
||||
AudioOut: c.AudioOut,
|
||||
AudioIn: c.AudioIn,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConfigHTTP) Address() string {
|
||||
return net.JoinHostPort(c.Host, fmt.Sprint(c.Port))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user