mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-12-24 12:27:57 +08:00
Decouple the common stream forwarding logic from the specific implementations
This commit is contained in:
@@ -1,11 +1,2 @@
|
||||
package types
|
||||
|
||||
type StreamForward[T any] struct {
|
||||
StreamID StreamID
|
||||
DestinationID DestinationID
|
||||
Enabled bool
|
||||
Quirks ForwardingQuirks
|
||||
ActiveForwarding T
|
||||
NumBytesWrote uint64
|
||||
NumBytesRead uint64
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/xaionaro-go/streamctl/pkg/player"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamplayer"
|
||||
sptypes "github.com/xaionaro-go/streamctl/pkg/streamplayer/types"
|
||||
"github.com/xaionaro-go/streamctl/pkg/streamtypes"
|
||||
)
|
||||
|
||||
type PubsubNameser interface {
|
||||
@@ -22,109 +19,6 @@ type Publisher = streamplayer.Publisher
|
||||
type WaitPublisherChaner = streamplayer.WaitPublisherChaner
|
||||
type GetPortServerser = streamplayer.GetPortServerser
|
||||
|
||||
type StreamServer[AF any] interface {
|
||||
streamplayer.StreamServer
|
||||
PubsubNameser
|
||||
|
||||
Init(
|
||||
ctx context.Context,
|
||||
opts ...InitOption,
|
||||
) error
|
||||
|
||||
StartServer(
|
||||
ctx context.Context,
|
||||
serverType streamtypes.ServerType,
|
||||
listenAddr string,
|
||||
opts ...ServerOption,
|
||||
) (PortServer, error)
|
||||
StopServer(
|
||||
ctx context.Context,
|
||||
server PortServer,
|
||||
) error
|
||||
|
||||
AddIncomingStream(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
) error
|
||||
ListIncomingStreams(
|
||||
ctx context.Context,
|
||||
) []IncomingStream
|
||||
RemoveIncomingStream(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
) error
|
||||
|
||||
ListStreamDestinations(
|
||||
ctx context.Context,
|
||||
) ([]StreamDestination, error)
|
||||
AddStreamDestination(
|
||||
ctx context.Context,
|
||||
destinationID DestinationID,
|
||||
url string,
|
||||
) error
|
||||
RemoveStreamDestination(
|
||||
ctx context.Context,
|
||||
destinationID DestinationID,
|
||||
) error
|
||||
|
||||
AddStreamForward(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
destinationID DestinationID,
|
||||
enabled bool,
|
||||
quirks ForwardingQuirks,
|
||||
) (*StreamForward[AF], error)
|
||||
ListStreamForwards(
|
||||
ctx context.Context,
|
||||
) ([]StreamForward[AF], error)
|
||||
UpdateStreamForward(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
destinationID DestinationID,
|
||||
enabled bool,
|
||||
quirks ForwardingQuirks,
|
||||
) (*StreamForward[AF], error)
|
||||
RemoveStreamForward(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
dstID DestinationID,
|
||||
) error
|
||||
|
||||
AddStreamPlayer(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
playerType player.Backend,
|
||||
disabled bool,
|
||||
streamPlaybackConfig sptypes.Config,
|
||||
opts ...StreamPlayerOption,
|
||||
) error
|
||||
UpdateStreamPlayer(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
playerType player.Backend,
|
||||
disabled bool,
|
||||
streamPlaybackConfig sptypes.Config,
|
||||
opts ...StreamPlayerOption,
|
||||
) error
|
||||
RemoveStreamPlayer(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
) error
|
||||
ListStreamPlayers(
|
||||
ctx context.Context,
|
||||
) ([]StreamPlayer, error)
|
||||
GetStreamPlayer(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
) (*StreamPlayer, error)
|
||||
GetActiveStreamPlayer(
|
||||
ctx context.Context,
|
||||
streamID StreamID,
|
||||
) (player.Player, error)
|
||||
|
||||
ListServers(ctx context.Context) []PortServer
|
||||
}
|
||||
|
||||
type InitConfig struct {
|
||||
DefaultStreamPlayerOptions streamplayer.Options
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user