mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-12-24 12:27:57 +08:00
Initial commit, pt. 64
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
7
pkg/streamplayer/types/ctx_key.go
Normal file
7
pkg/streamplayer/types/ctx_key.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package types
|
||||
|
||||
type CtxKey string
|
||||
|
||||
const (
|
||||
CtxKeyStreamPlayer = CtxKey("StreamPlayer")
|
||||
)
|
||||
Reference in New Issue
Block a user