streamcontrol

package
v0.0.0-...-4503ccc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2024 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CapabilityUndefined = Capability(iota)
	CapabilitySendChatMessage
	CapabilityDeleteChatMessage
	CapabilityBanUser
	EndOfCapability
)

Variables

This section is empty.

Functions

func AssertStreamProfile

func AssertStreamProfile[T StreamProfile](
	ctx context.Context,
	v AbstractStreamProfile,
) (*T, error)

func ConvertAbstractStreamProfiles

func ConvertAbstractStreamProfiles(
	s StreamProfiles[AbstractStreamProfile],
	platID PlatformName,
) error

func ConvertPlatformConfigInplace

func ConvertPlatformConfigInplace(
	cfg Config,
	platID PlatformName,
) error

func ConvertStreamProfiles

func ConvertStreamProfiles[T StreamProfile](
	ctx context.Context,
	m map[ProfileName]AbstractStreamProfile,
) error

func GetPlatformSpecificConfig

func GetPlatformSpecificConfig[T PlatformSpecificConfig](
	ctx context.Context,
	platCfgCfg any,
) T

func GetStreamProfile

func GetStreamProfile[T StreamProfile](
	ctx context.Context,
	v AbstractStreamProfile,
) (*T, error)

func InitConfig

func InitConfig[T PlatformSpecificConfig, S StreamProfile](cfg Config, id PlatformName, platCfg PlatformConfig[T, S])

func IsInitialized

func IsInitialized(
	cfg Config,
	platID PlatformName,
) bool

func RegisterPlatform

func RegisterPlatform[PSC PlatformSpecificConfig, SP StreamProfile](id PlatformName)

func ToAbstractStreamProfiles

func ToAbstractStreamProfiles[S StreamProfile](
	in map[ProfileName]S,
) map[ProfileName]AbstractStreamProfile

Types

type AbstractStreamController

type AbstractStreamController interface {
	StreamController[AbstractStreamProfile]
	GetImplementation() StreamControllerCommons
	StreamProfileType() reflect.Type
}

type AbstractStreamProfile

type AbstractStreamProfile interface {
	GetParent() (ProfileName, bool)
	GetOrder() int
}

type Capability

type Capability uint

type ChatMessage

type ChatMessage struct {
	CreatedAt time.Time
	UserID    ChatUserID
	Username  string
	MessageID ChatMessageID
	Message   string
}

type ChatMessageID

type ChatMessageID string

type ChatUserID

type ChatUserID string

type Config

func (Config) Convert

func (cfg Config) Convert() error

func (*Config) UnmarshalYAML

func (cfg *Config) UnmarshalYAML(b []byte) (_err error)

type ErrInvalidStreamProfileType

type ErrInvalidStreamProfileType struct {
	Received AbstractStreamProfile
	Expected AbstractStreamProfile
}

func (ErrInvalidStreamProfileType) Error

type ErrNoStreamControllerForProfile

type ErrNoStreamControllerForProfile struct {
	StreamProfile AbstractStreamProfile
}

func (ErrNoStreamControllerForProfile) Error

type PlatformConfig

type PlatformConfig[T PlatformSpecificConfig, S StreamProfile] struct {
	Enable         *bool
	Config         T
	StreamProfiles StreamProfiles[S]
	Custom         map[string]any
}

func ConvertPlatformConfig

func ConvertPlatformConfig[T PlatformSpecificConfig, S StreamProfile](
	ctx context.Context,
	platCfg *AbstractPlatformConfig,
) *PlatformConfig[T, S]

func GetPlatformConfig

func GetPlatformConfig[T PlatformSpecificConfig, S StreamProfile](
	ctx context.Context,
	cfg Config,
	id PlatformName,
) *PlatformConfig[T, S]

func (*PlatformConfig[T, S]) GetCustomString

func (cfg *PlatformConfig[T, S]) GetCustomString(key string) (string, bool)

func (PlatformConfig[T, S]) GetStreamProfile

func (cfg PlatformConfig[T, S]) GetStreamProfile(name ProfileName) (S, bool)

func (*PlatformConfig[T, S]) IsInitialized

func (cfg *PlatformConfig[T, S]) IsInitialized() bool

func (*PlatformConfig[T, S]) SetCustomString

func (cfg *PlatformConfig[T, S]) SetCustomString(key string, value any) bool

type PlatformName

type PlatformName string

type PlatformSpecificConfig

type PlatformSpecificConfig interface {
	IsInitialized() bool
}

func GetAbstractPlatformSpecificConfig

func GetAbstractPlatformSpecificConfig(
	cfg Config,
	platID PlatformName,
) (PlatformSpecificConfig, error)

type ProfileName

type ProfileName string

type RawMessage

type RawMessage json.RawMessage

func (RawMessage) GetOrder

func (RawMessage) GetOrder() int

func (RawMessage) GetParent

func (RawMessage) GetParent() (ProfileName, bool)

func (RawMessage) IsInitialized

func (RawMessage) IsInitialized() bool

func (RawMessage) MarshalJSON

func (m RawMessage) MarshalJSON() ([]byte, error)

func (RawMessage) MarshalYAML

func (m RawMessage) MarshalYAML() ([]byte, error)

func (*RawMessage) UnmarshalJSON

func (m *RawMessage) UnmarshalJSON(b []byte) error

func (*RawMessage) UnmarshalYAML

func (m *RawMessage) UnmarshalYAML(b []byte) error

type StreamController

type StreamController[ProfileType StreamProfile] interface {
	StreamControllerCommons

	ApplyProfile(ctx context.Context, profile ProfileType, customArgs ...any) error
	StartStream(
		ctx context.Context,
		title string,
		description string,
		profile ProfileType,
		customArgs ...any,
	) error
}

type StreamControllerCommons

type StreamControllerCommons interface {
	io.Closer

	SetTitle(ctx context.Context, title string) error
	SetDescription(ctx context.Context, description string) error
	InsertAdsCuePoint(ctx context.Context, ts time.Time, duration time.Duration) error
	Flush(ctx context.Context) error
	EndStream(ctx context.Context) error
	GetStreamStatus(ctx context.Context) (*StreamStatus, error)

	GetChatMessagesChan(ctx context.Context) (<-chan ChatMessage, error)
	SendChatMessage(ctx context.Context, message string) error
	RemoveChatMessage(ctx context.Context, messageID ChatMessageID) error
	BanUser(ctx context.Context, userID ChatUserID, reason string, deadline time.Time) error

	IsCapable(context.Context, Capability) bool
}

type StreamControllers

type StreamControllers []AbstractStreamController

func (StreamControllers) ApplyProfiles

func (s StreamControllers) ApplyProfiles(
	ctx context.Context,
	profiles []AbstractStreamProfile,
) error

func (StreamControllers) EndStream

func (s StreamControllers) EndStream(
	ctx context.Context,
) error

func (StreamControllers) Flush

func (s StreamControllers) Flush(
	ctx context.Context,
) error

func (StreamControllers) InsertAdsCuePoint

func (s StreamControllers) InsertAdsCuePoint(
	ctx context.Context,
	ts time.Time,
	duration time.Duration,
) error

func (StreamControllers) SetDescription

func (s StreamControllers) SetDescription(
	ctx context.Context,
	description string,
) error

func (StreamControllers) SetTitle

func (s StreamControllers) SetTitle(
	ctx context.Context,
	title string,
) error

func (StreamControllers) StartStream

func (s StreamControllers) StartStream(
	ctx context.Context,
	title string,
	description string,
	profiles []AbstractStreamProfile,
	customArgs ...any,
) error

type StreamProfile

type StreamProfile interface {
	AbstractStreamProfile
}

func ConvertStreamProfile

func ConvertStreamProfile(
	p StreamProfile,
	platID PlatformName,
) (StreamProfile, error)

type StreamProfileBase

type StreamProfileBase struct {
	Parent ProfileName
	Order  int
}

func (StreamProfileBase) GetOrder

func (profile StreamProfileBase) GetOrder() int

func (StreamProfileBase) GetParent

func (profile StreamProfileBase) GetParent() (ProfileName, bool)

func (*StreamProfileBase) SetOrder

func (profile *StreamProfileBase) SetOrder(v int)

type StreamProfiles

type StreamProfiles[S StreamProfile] map[ProfileName]S

func GetStreamProfiles

func GetStreamProfiles[S StreamProfile](
	streamProfiles map[ProfileName]AbstractStreamProfile,
) StreamProfiles[S]

func (StreamProfiles[S]) Get

func (profiles StreamProfiles[S]) Get(name ProfileName) (S, bool)

type StreamStatus

type StreamStatus struct {
	IsActive     bool
	ViewersCount *uint      `json:",omitempty"`
	StartedAt    *time.Time `json:",omitempty"`
	CustomData   any        `json:",omitempty"`
}

Directories

Path Synopsis
obs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL