#3 can be configured llhls or hls as config.toml (#5)

This commit is contained in:
Han Gyoung-Su
2024-09-08 16:12:08 +09:00
committed by GitHub
parent 1a0c9fe7f9
commit ef42f9c343
4 changed files with 19 additions and 6 deletions

View File

@@ -4,5 +4,6 @@ port = 5555
port = 1930
[hls]
port = 8044
llhls = true
[docker]
mode = false

View File

@@ -2,16 +2,25 @@ package config
// Struct to hold the configuration
type Config struct {
Whep ServerConfig `mapstructure:"whep"`
RTMP ServerConfig `mapstructure:"rtmp"`
HLS ServerConfig `mapstructure:"hls"`
Whep Whep `mapstructure:"whep"`
RTMP RTMP `mapstructure:"rtmp"`
HLS HLS `mapstructure:"hls"`
Docker DockerConfig `mapstructure:"docker"`
}
type ServerConfig struct {
type RTMP struct {
Port int `mapstructure:"port"`
}
type Whep struct {
Port int `mapstructure:"port"`
}
type HLS struct {
Port int `mapstructure:"port"`
LLHLS bool `mapstructure:"llhls"`
}
type DockerConfig struct {
Mode bool `mapstructure:"mode"`
}

View File

@@ -73,6 +73,7 @@ func main() {
Hub: hub,
HLSHub: hlsHub,
Port: conf.HLS.Port,
LLHLS: conf.HLS.LLHLS,
})
err := hls.Start(ctx, source)
if err != nil {

View File

@@ -36,12 +36,14 @@ type HLS struct {
muxer *gohlslib.Muxer
mpeg4AudioConfigBytes []byte
mpeg4AudioConfig *aacparser.MPEG4AudioConfig
llHLS bool
}
type HLSArgs struct {
Hub *hub.Hub
HLSHub *hlshub.HLSHub
Port int
LLHLS bool
}
func NewHLS(args HLSArgs) *HLS {
@@ -49,6 +51,7 @@ func NewHLS(args HLSArgs) *HLS {
hub: args.Hub,
hlsHub: args.HLSHub,
port: args.Port,
llHLS: args.LLHLS,
}
}
@@ -167,8 +170,7 @@ func (h *HLS) makeMuxer(extraData []byte) (*gohlslib.Muxer, error) {
},
AudioTrack: audioTrack,
}
llHLS := false
if llHLS {
if h.llHLS {
muxer.Variant = gohlslib.MuxerVariantLowLatency
muxer.PartDuration = 500 * time.Millisecond
} else {