client

package
v0.0.0-...-646ff60 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: CC0-1.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = func(ctx context.Context) Config {
	return Config{
		UsePersistentConnection: true,
		Reconnect: ReconnectConfig{
			InitialInterval:    200 * time.Millisecond,
			MaximalInterval:    5 * time.Second,
			IntervalMultiplier: 1.1,
		},
	}
}

Functions

This section is empty.

Types

type CallWrapperFunc

type CallWrapperFunc func(
	ctx context.Context,
	req any,
	callFunc func(ctx context.Context, opts ...grpc.CallOption) error,
	opts ...grpc.CallOption,
) error

type Client

type Client struct {
	Stats struct {
		BytesIn  uint64
		BytesOut uint64
	}
	Target string
	Config Config

	PersistentConnectionLocker xsync.Mutex
	PersistentConnection       *grpc.ClientConn
	PersistentStreamDClient    streamd_grpc.StreamDClient
	PersistentOBSClient        obs_grpc.OBSClient
}

func New

func New(
	ctx context.Context,
	target string,
	opts ...Option,
) (*Client, error)

func (*Client) AddIncomingStream

func (c *Client) AddIncomingStream(
	ctx context.Context,
	streamID api.StreamID,
) error

func (*Client) AddStreamDestination

func (c *Client) AddStreamDestination(
	ctx context.Context,
	destinationID api.DestinationID,
	url string,
	streamKey string,
) error

func (*Client) AddStreamForward

func (c *Client) AddStreamForward(
	ctx context.Context,
	streamID api.StreamID,
	destinationID api.DestinationID,
	enabled bool,
	quirks api.StreamForwardingQuirks,
) error

func (*Client) AddStreamPlayer

func (c *Client) AddStreamPlayer(
	ctx context.Context,
	streamID streamtypes.StreamID,
	playerType player.Backend,
	disabled bool,
	streamPlaybackConfig sptypes.Config,
) error

func (*Client) AddTimer

func (c *Client) AddTimer(
	ctx context.Context,
	triggerAt time.Time,
	action api.Action,
) (api.TimerID, error)

func (*Client) AddTriggerRule

func (c *Client) AddTriggerRule(
	ctx context.Context,
	triggerRule *api.TriggerRule,
) (api.TriggerRuleID, error)

func (*Client) ApplyProfile

func (c *Client) ApplyProfile(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	profile streamcontrol.AbstractStreamProfile,
	customArgs ...any,
) error

func (*Client) BanUser

func (c *Client) BanUser(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	userID streamcontrol.ChatUserID,
	reason string,
	deadline time.Time,
) error

func (*Client) DialContext

func (c *Client) DialContext(
	ctx context.Context,
	network string,
	addr string,
) (net.Conn, error)

func (*Client) EXPERIMENTAL_ReinitStreamControllers

func (c *Client) EXPERIMENTAL_ReinitStreamControllers(
	ctx context.Context,
) error

func (*Client) EndStream

func (c *Client) EndStream(
	ctx context.Context,
	platID streamcontrol.PlatformName,
) error

func (*Client) GetBackendInfo

func (c *Client) GetBackendInfo(
	ctx context.Context,
	platID streamcontrol.PlatformName,
) (*api.BackendInfo, error)

func (*Client) GetConfig

func (c *Client) GetConfig(
	ctx context.Context,
) (*streamdconfig.Config, error)

func (*Client) GetLoggingLevel

func (c *Client) GetLoggingLevel(
	ctx context.Context,
) (logger.Level, error)

func (*Client) GetStreamPlayer

func (c *Client) GetStreamPlayer(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (*api.StreamPlayer, error)

func (*Client) GetStreamStatus

func (c *Client) GetStreamStatus(
	ctx context.Context,
	platID streamcontrol.PlatformName,
) (*streamcontrol.StreamStatus, error)

func (*Client) GetVariable

func (c *Client) GetVariable(
	ctx context.Context,
	key consts.VarKey,
) ([]byte, error)

func (*Client) GetVariableHash

func (c *Client) GetVariableHash(
	ctx context.Context,
	key consts.VarKey,
	hashType crypto.Hash,
) ([]byte, error)

func (*Client) HandleConn

func (c *Client) HandleConn(
	context.Context,
	stats.ConnStats,
)

func (*Client) HandleRPC

func (c *Client) HandleRPC(
	ctx context.Context,
	s stats.RPCStats,
)

func (*Client) InitCache

func (c *Client) InitCache(ctx context.Context) error

func (*Client) IsBackendEnabled

func (c *Client) IsBackendEnabled(
	ctx context.Context,
	id streamcontrol.PlatformName,
) (bool, error)

func (*Client) ListIncomingStreams

func (c *Client) ListIncomingStreams(
	ctx context.Context,
) ([]api.IncomingStream, error)

func (*Client) ListStreamDestinations

func (c *Client) ListStreamDestinations(
	ctx context.Context,
) ([]api.StreamDestination, error)

func (*Client) ListStreamForwards

func (c *Client) ListStreamForwards(
	ctx context.Context,
) ([]api.StreamForward, error)

func (*Client) ListStreamPlayers

func (c *Client) ListStreamPlayers(
	ctx context.Context,
) ([]api.StreamPlayer, error)

func (*Client) ListStreamServers

func (c *Client) ListStreamServers(
	ctx context.Context,
) ([]api.StreamServer, error)

func (*Client) ListTimers

func (c *Client) ListTimers(
	ctx context.Context,
) ([]api.Timer, error)

func (*Client) ListTriggerRules

func (c *Client) ListTriggerRules(
	ctx context.Context,
) (api.TriggerRules, error)

func (*Client) OBS

func (*Client) Ping

func (c *Client) Ping(
	ctx context.Context,
	beforeSend func(context.Context, *streamd_grpc.PingRequest),
) error

func (*Client) RemoveChatMessage

func (c *Client) RemoveChatMessage(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	msgID streamcontrol.ChatMessageID,
) error

func (*Client) RemoveIncomingStream

func (c *Client) RemoveIncomingStream(
	ctx context.Context,
	streamID api.StreamID,
) error

func (*Client) RemoveStreamDestination

func (c *Client) RemoveStreamDestination(
	ctx context.Context,
	destinationID api.DestinationID,
) error

func (*Client) RemoveStreamForward

func (c *Client) RemoveStreamForward(
	ctx context.Context,
	streamID api.StreamID,
	destinationID api.DestinationID,
) error

func (*Client) RemoveStreamPlayer

func (c *Client) RemoveStreamPlayer(
	ctx context.Context,
	streamID streamtypes.StreamID,
) error

func (*Client) RemoveTimer

func (c *Client) RemoveTimer(
	ctx context.Context,
	timerID api.TimerID,
) error

func (*Client) RemoveTriggerRule

func (c *Client) RemoveTriggerRule(
	ctx context.Context,
	ruleID api.TriggerRuleID,
) error

func (*Client) ResetCache

func (c *Client) ResetCache(ctx context.Context) error

func (*Client) Restart

func (c *Client) Restart(ctx context.Context) error

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

func (*Client) SaveConfig

func (c *Client) SaveConfig(ctx context.Context) error

func (*Client) SendChatMessage

func (c *Client) SendChatMessage(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	message string,
) error

func (*Client) SetConfig

func (c *Client) SetConfig(
	ctx context.Context,
	cfg *streamdconfig.Config,
) error

func (*Client) SetDescription

func (c *Client) SetDescription(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	description string,
) error

func (*Client) SetLoggingLevel

func (c *Client) SetLoggingLevel(
	ctx context.Context,
	level logger.Level,
) error

func (*Client) SetTitle

func (c *Client) SetTitle(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	title string,
) error

func (*Client) SetVariable

func (c *Client) SetVariable(
	ctx context.Context,
	key consts.VarKey,
	value []byte,
) error

func (*Client) StartStream

func (c *Client) StartStream(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	title string, description string,
	profile streamcontrol.AbstractStreamProfile,
	customArgs ...any,
) error

func (*Client) StartStreamServer

func (c *Client) StartStreamServer(
	ctx context.Context,
	serverType api.StreamServerType,
	listenAddr string,
	opts ...streamportserver.Option,
) error

func (*Client) StopStreamServer

func (c *Client) StopStreamServer(
	ctx context.Context,
	listenAddr string,
) error

func (*Client) StreamPlayerClose

func (c *Client) StreamPlayerClose(
	ctx context.Context,
	streamID streamtypes.StreamID,
) error

func (*Client) StreamPlayerEndChan

func (c *Client) StreamPlayerEndChan(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (<-chan struct{}, error)

func (*Client) StreamPlayerGetLength

func (c *Client) StreamPlayerGetLength(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (time.Duration, error)
func (c *Client) StreamPlayerGetLink(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (string, error)

func (*Client) StreamPlayerGetPosition

func (c *Client) StreamPlayerGetPosition(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (time.Duration, error)

func (*Client) StreamPlayerIsEnded

func (c *Client) StreamPlayerIsEnded(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (bool, error)

func (*Client) StreamPlayerOpenURL

func (c *Client) StreamPlayerOpenURL(
	ctx context.Context,
	streamID streamtypes.StreamID,
	link string,
) error

func (*Client) StreamPlayerProcessTitle

func (c *Client) StreamPlayerProcessTitle(
	ctx context.Context,
	streamID streamtypes.StreamID,
) (string, error)

func (*Client) StreamPlayerSetPause

func (c *Client) StreamPlayerSetPause(
	ctx context.Context,
	streamID streamtypes.StreamID,
	pause bool,
) error

func (*Client) StreamPlayerSetSpeed

func (c *Client) StreamPlayerSetSpeed(
	ctx context.Context,
	streamID streamtypes.StreamID,
	speed float64,
) error

func (*Client) StreamPlayerStop

func (c *Client) StreamPlayerStop(
	ctx context.Context,
	streamID streamtypes.StreamID,
) error

func (*Client) SubmitEvent

func (c *Client) SubmitEvent(
	ctx context.Context,
	event event.Event,
) error

func (*Client) SubscribeToChatMessages

func (c *Client) SubscribeToChatMessages(
	ctx context.Context,
) (<-chan api.ChatMessage, error)

func (*Client) SubscribeToConfigChanges

func (c *Client) SubscribeToConfigChanges(
	ctx context.Context,
) (<-chan api.DiffConfig, error)

func (*Client) SubscribeToIncomingStreamsChanges

func (c *Client) SubscribeToIncomingStreamsChanges(
	ctx context.Context,
) (<-chan api.DiffIncomingStreams, error)

func (*Client) SubscribeToOAuthURLs

func (c *Client) SubscribeToOAuthURLs(
	ctx context.Context,
	listenPort uint16,
) (<-chan *streamd_grpc.OAuthRequest, error)

func (*Client) SubscribeToStreamDestinationsChanges

func (c *Client) SubscribeToStreamDestinationsChanges(
	ctx context.Context,
) (<-chan api.DiffStreamDestinations, error)

func (*Client) SubscribeToStreamForwardsChanges

func (c *Client) SubscribeToStreamForwardsChanges(
	ctx context.Context,
) (<-chan api.DiffStreamForwards, error)

func (*Client) SubscribeToStreamPlayersChanges

func (c *Client) SubscribeToStreamPlayersChanges(
	ctx context.Context,
) (<-chan api.DiffStreamPlayers, error)

func (*Client) SubscribeToStreamServersChanges

func (c *Client) SubscribeToStreamServersChanges(
	ctx context.Context,
) (<-chan api.DiffStreamServers, error)

func (*Client) SubscribeToStreamsChanges

func (c *Client) SubscribeToStreamsChanges(
	ctx context.Context,
) (<-chan api.DiffStreams, error)

func (*Client) TagConn

func (c *Client) TagConn(
	ctx context.Context,
	_ *stats.ConnTagInfo,
) context.Context

func (*Client) TagRPC

func (c *Client) TagRPC(
	ctx context.Context,
	_ *stats.RPCTagInfo,
) context.Context

func (*Client) UpdateStream

func (c *Client) UpdateStream(
	ctx context.Context,
	platID streamcontrol.PlatformName,
	title string, description string,
	profile streamcontrol.AbstractStreamProfile,
	customArgs ...any,
) error

func (*Client) UpdateStreamDestination

func (c *Client) UpdateStreamDestination(
	ctx context.Context,
	destinationID api.DestinationID,
	url string,
	streamKey string,
) error

func (*Client) UpdateStreamForward

func (c *Client) UpdateStreamForward(
	ctx context.Context,
	streamID api.StreamID,
	destinationID api.DestinationID,
	enabled bool,
	quirks api.StreamForwardingQuirks,
) error

func (*Client) UpdateStreamPlayer

func (c *Client) UpdateStreamPlayer(
	ctx context.Context,
	streamID streamtypes.StreamID,
	playerType player.Backend,
	disabled bool,
	streamPlaybackConfig sptypes.Config,
) (_err error)

func (*Client) UpdateTriggerRule

func (c *Client) UpdateTriggerRule(
	ctx context.Context,
	ruleID api.TriggerRuleID,
	triggerRule *api.TriggerRule,
) error

func (*Client) WaitForStreamPublisher

func (c *Client) WaitForStreamPublisher(
	ctx context.Context,
	streamID api.StreamID,
) (<-chan struct{}, error)

type Config

type Config struct {
	UsePersistentConnection bool
	CallWrapper             CallWrapperFunc
	ConnectWrapper          ConnectWrapperFunc
	Reconnect               ReconnectConfig
}

type ConnectWrapperFunc

type ConnectWrapperFunc func(
	ctx context.Context,
	connectFunc func(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error),
	opts ...grpc.DialOption,
) (*grpc.ClientConn, error)

type OBSInstanceID

type OBSInstanceID = streamtypes.OBSInstanceID

type Option

type Option interface {
	Apply(*Config)
}

type OptionCallWrapper

type OptionCallWrapper CallWrapperFunc

func (OptionCallWrapper) Apply

func (opt OptionCallWrapper) Apply(cfg *Config)

type OptionConnectWrapper

type OptionConnectWrapper ConnectWrapperFunc

func (OptionConnectWrapper) Apply

func (opt OptionConnectWrapper) Apply(cfg *Config)

type OptionReconnectInitialInterval

type OptionReconnectInitialInterval time.Duration

func (OptionReconnectInitialInterval) Apply

func (opt OptionReconnectInitialInterval) Apply(cfg *Config)

type OptionReconnectIntervalMultiplier

type OptionReconnectIntervalMultiplier float64

func (OptionReconnectIntervalMultiplier) Apply

func (opt OptionReconnectIntervalMultiplier) Apply(cfg *Config)

type OptionReconnectMaximalInterval

type OptionReconnectMaximalInterval time.Duration

func (OptionReconnectMaximalInterval) Apply

func (opt OptionReconnectMaximalInterval) Apply(cfg *Config)

type OptionUsePersistentConnection

type OptionUsePersistentConnection bool

func (OptionUsePersistentConnection) Apply

func (opt OptionUsePersistentConnection) Apply(cfg *Config)

type Options

type Options []Option

func (Options) Apply

func (s Options) Apply(cfg *Config)

func (Options) Config

func (s Options) Config(ctx context.Context) Config

type ReconnectConfig

type ReconnectConfig struct {
	InitialInterval    time.Duration
	MaximalInterval    time.Duration
	IntervalMultiplier float64
}

Jump to

Keyboard shortcuts

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