proxy

package
v0.0.0-...-fd00b2c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, cfg config.Config) error

func GetAudioFormat

func GetAudioFormat(r *http.Request) string

func GetMountpoint

func GetMountpoint(r *http.Request) string

func IdentifierMiddleware

func IdentifierMiddleware(next http.Handler) http.Handler

func ToUTF8

func ToUTF8(ctx context.Context, charset, meta string) string

Types

type Identifier

type Identifier uint64

func IdentFromRequest

func IdentFromRequest(r *http.Request) Identifier

type Metadata

type Metadata struct {
	Time       time.Time
	Identifier Identifier
	User       radio.User
	MountName  string
	Addr       string

	Value string
}

type MetadataWriter

type MetadataWriter interface {
	io.Writer
	SendMetadata(ctx context.Context, metadata *Metadata)
}

type Mount

type Mount struct {

	// ContentType of this mount, this can only be set during creation and all
	// future clients afterwards will use the same content type
	ContentType string
	// Name of the mountpoint
	Name string

	// Conn is the conn to the icecast server
	Conn *util.TypedValue[net.Conn]

	// Sources is the different sources of audio data, the mount
	// broadcasts the data of the first entry and voids the others
	SourcesMu *sync.RWMutex
	Sources   []*MountSourceClient
	// contains filtered or unexported fields
}

func NewMount

func NewMount(ctx context.Context, cfg config.Config, pm *ProxyManager, name string, ct string, conn net.Conn) *Mount

func (*Mount) AddSource

func (m *Mount) AddSource(ctx context.Context, source *SourceClient)

func (*Mount) Close

func (m *Mount) Close() error

func (*Mount) RemoveSource

func (m *Mount) RemoveSource(ctx context.Context, id SourceID)

func (*Mount) RunMountSourceClient

func (m *Mount) RunMountSourceClient(ctx context.Context, msc *MountSourceClient)

func (*Mount) SendMetadata

func (m *Mount) SendMetadata(ctx context.Context, meta *Metadata)

SendMetadata finds the source associated with this metadata and updates their internal metadata. This does no transmission of metadata to the master server.

func (*Mount) Write

func (m *Mount) Write(b []byte) (n int, err error)

type MountMetadataWriter

type MountMetadataWriter struct {

	// metadata is the last metadata we send (or tried to send)
	Metadata string

	// live indicates if we are the live writer, actually writing to the master
	Live bool
	// out is the writer we write into
	Out io.Writer
	// contains filtered or unexported fields
}

func (*MountMetadataWriter) GetLive

func (mmw *MountMetadataWriter) GetLive() bool

func (*MountMetadataWriter) SendMetadata

func (mmw *MountMetadataWriter) SendMetadata(ctx context.Context, meta *Metadata)

func (*MountMetadataWriter) SetLive

func (mmw *MountMetadataWriter) SetLive(ctx context.Context, live bool)

func (*MountMetadataWriter) SetWriter

func (mmw *MountMetadataWriter) SetWriter(new io.Writer)

func (*MountMetadataWriter) Write

func (mmw *MountMetadataWriter) Write(p []byte) (n int, err error)

type MountSourceClient

type MountSourceClient struct {
	// Source is the SourceClient we're handling, should not be mutated by
	// anything once the MountSourceClient is made
	Source *SourceClient
	// Priority is the Priority for live-ness determination
	// lower is higher Priority
	Priority uint
	// MW is the writer this source is writing to
	MW *MountMetadataWriter
	// contains filtered or unexported fields
}

MountSourceClient is a SourceClient with extra fields for mount-specific bookkeeping

func (*MountSourceClient) GoLive

func (msc *MountSourceClient) GoLive(ctx context.Context, out MetadataWriter)

type ProxyManager

type ProxyManager struct {
	// contains filtered or unexported fields
}

func NewProxyManager

func NewProxyManager(ctx context.Context, cfg config.Config) (*ProxyManager, error)

func (*ProxyManager) AddSourceClient

func (pm *ProxyManager) AddSourceClient(source *SourceClient) error

func (*ProxyManager) Metadata

func (pm *ProxyManager) Metadata(identifier Identifier) *Metadata

func (*ProxyManager) RemoveMount

func (pm *ProxyManager) RemoveMount(mount *Mount)

func (*ProxyManager) SendMetadata

func (pm *ProxyManager) SendMetadata(ctx context.Context, metadata *Metadata) error

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, cfg config.Config, manager radio.ManagerService, storage radio.UserStorageService) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) GetListClients

func (s *Server) GetListClients(w http.ResponseWriter, r *http.Request)

func (*Server) GetMetadata

func (s *Server) GetMetadata(w http.ResponseWriter, r *http.Request)

func (*Server) PutSource

func (s *Server) PutSource(w http.ResponseWriter, r *http.Request)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

type SourceClient

type SourceClient struct {
	ID SourceID
	// UserAgent is the User-Agent HTTP header passed by the client
	UserAgent string
	// ContentType is the Content-Type HTTP header passed by the client
	ContentType string

	// MountName is the mount this client is trying to stream to
	MountName string
	// User is the user that is trying to stream
	User radio.User
	// Identifier is an identifier that should be the same between two
	// different requests, but same mountpoint and user. This is to match-up
	// metadata information
	Identifier Identifier
	// Metadata is a pointer to the last Metadata received for this client
	Metadata *atomic.Pointer[Metadata]
	// contains filtered or unexported fields
}

func NewSourceClient

func NewSourceClient(id SourceID, ua, ct, mount string, conn net.Conn, user radio.User, identifier Identifier, metadata *Metadata) *SourceClient

type SourceID

type SourceID struct {
	xid.ID
}

func NewSourceID

func NewSourceID(r *http.Request) SourceID

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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