Initial commit, pt. 64

This commit is contained in:
Dmitrii Okunev
2024-08-04 02:29:52 +01:00
parent 589dc9684e
commit 74ce1285b8
10 changed files with 385 additions and 114 deletions

View File

@@ -3,14 +3,19 @@ package types
import (
"context"
"time"
"github.com/xaionaro-go/streamctl/pkg/streamtypes"
)
type FuncNotifyStart func(ctx context.Context, streamID streamtypes.StreamID)
type Config struct {
JitterBufDuration time.Duration
CatchupMaxSpeedFactor float64
MaxCatchupAtLag time.Duration
StartTimeout time.Duration
ReadTimeout time.Duration
NotifierStart []FuncNotifyStart
}
func (cfg Config) Options() Options {
@@ -21,15 +26,18 @@ func (cfg Config) Options() Options {
if cfg.CatchupMaxSpeedFactor != 0 {
opts = append(opts, OptionCatchupMaxSpeedFactor(cfg.CatchupMaxSpeedFactor))
}
if cfg.CatchupMaxSpeedFactor != 0 {
if cfg.MaxCatchupAtLag != 0 {
opts = append(opts, OptionMaxCatchupAtLag(cfg.MaxCatchupAtLag))
}
if cfg.CatchupMaxSpeedFactor != 0 {
if cfg.StartTimeout != 0 {
opts = append(opts, OptionStartTimeout(cfg.StartTimeout))
}
if cfg.CatchupMaxSpeedFactor != 0 {
if cfg.ReadTimeout != 0 {
opts = append(opts, OptionReadTimeout(cfg.ReadTimeout))
}
if cfg.NotifierStart != nil {
opts = append(opts, OptionNotifierStart(cfg.NotifierStart))
}
return opts
}
@@ -90,3 +98,9 @@ type OptionReadTimeout time.Duration
func (s OptionReadTimeout) Apply(cfg *Config) {
cfg.ReadTimeout = time.Duration(s)
}
type OptionNotifierStart []FuncNotifyStart
func (s OptionNotifierStart) Apply(cfg *Config) {
cfg.NotifierStart = ([]FuncNotifyStart)(s)
}

View File

@@ -0,0 +1,7 @@
package types
type CtxKey string
const (
CtxKeyStreamPlayer = CtxKey("StreamPlayer")
)