add arg groups
This commit is contained in:
1 parent
efa0660945
commit
6e5f37db41
2 files changed
+20
-10
No files matched your search
@@ -28,7 +28,7 @@ func main() {
|
|||||||
|
|
||||||
http := server.NewHttpServer(lg.With(zap.String("context", "server")), &cfg)
|
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())
|
http.ListenAndServe(ctx, cfg.Http.Address())
|
||||||
|
|
||||||
|
|||||||
+19
-9
@@ -8,9 +8,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Logging ConfigLogging `arg:"group:Logging"`
|
VideoOut ConfigVideoOutputStream `arg:"group:VideoOut"`
|
||||||
Stream ConfigStream `arg:"group:Stream"`
|
AudioOut ConfigAudioOutputStream `arg:"group:AudioOut"`
|
||||||
Http ConfigHTTP `arg:"group:Http"`
|
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 {
|
type ConfigLogging struct {
|
||||||
@@ -25,12 +33,6 @@ type ConfigHTTP struct {
|
|||||||
StaticPath *string `arg:"--http-static,env:HTTP_STATIC"`
|
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 {
|
type ConfigVideoOutputStream struct {
|
||||||
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
Source string `arg:"--video-src,env:VIDEO_SRC" default:"v4l2src"`
|
||||||
Device string `arg:"--video-device,env:VIDEO_DEVICE" default:"/dev/video0"`
|
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"`
|
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 {
|
func (c *ConfigHTTP) Address() string {
|
||||||
return net.JoinHostPort(c.Host, fmt.Sprint(c.Port))
|
return net.JoinHostPort(c.Host, fmt.Sprint(c.Port))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user