#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 port = 1930
[hls] [hls]
port = 8044 port = 8044
llhls = true
[docker] [docker]
mode = false mode = false

View File

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

View File

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

View File

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