fcast

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPort = 46899
)

Variables

View Source
var (
	ErrHeaderTooShort = errors.New("header is too short")
	ErrBodyTooShort   = errors.New("body is too short")
)

Functions

func SerializeRaw

func SerializeRaw(message *RawMessage) []byte

Types

type CodeRegistry

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

type Connection

type Connection struct {
	net.Conn
}

func Connect

func Connect(host string) (*Connection, error)

func (*Connection) ListenForMessages

func (c *Connection) ListenForMessages(em *EventManager) error

func (*Connection) SendMessage

func (c *Connection) SendMessage(message Message) error

type DiscoveredHost

type DiscoveredHost struct {
	Name string
	IPv4 string
	IPv6 string
}

func Discover

func Discover() ([]DiscoveredHost, error)

type EventHandler

type EventHandler func(message Message)

type EventManager

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

func (*EventManager) SetHandler

func (em *EventManager) SetHandler(message Message, handler EventHandler)

type Message

type Message interface {
	// contains filtered or unexported methods
}

type MessageHeader

type MessageHeader struct {
	Size   uint32 // little endian (4) 0-3
	OpCode OpCode // (1) 4-4
}

type OpCode

type OpCode uint8
const (
	Play           OpCode = 1
	Pause          OpCode = 2
	Resume         OpCode = 3
	Stop           OpCode = 4
	Seek           OpCode = 5
	PlaybackUpdate OpCode = 6
	VolumeUpdate   OpCode = 7
	SetVolume      OpCode = 8
	PlaybackError  OpCode = 9
	SetSpeed       OpCode = 10
	Version        OpCode = 11
	Ping           OpCode = 12
	Pong           OpCode = 13
)

type PauseMessage

type PauseMessage struct{}

type PingMessage

type PingMessage struct{}

type PlayMessage

type PlayMessage struct {
	Container string            `json:"container"`
	Url       string            `json:"url,omitempty"`
	Content   string            `json:"content,omitempty"`
	Time      int               `json:"time"`              // start time of playback (s)
	Speed     float32           `json:"speed,omitempty"`   // 1=100%, 1 is default
	Headers   map[string]string `json:"headers,omitempty"` // headers to be passed to the server when requesting media
}

type PlaybackErrorMessage

type PlaybackErrorMessage struct {
	Message string `json:"message"`
}

type PlaybackState

type PlaybackState uint8
const (
	Idle    PlaybackState = 0
	Playing PlaybackState = 1
	Paused  PlaybackState = 2
)

type PlaybackUpdateMessage

type PlaybackUpdateMessage struct {
	GenerationTime int64         `json:"generationTime"` // generation time in UNIX (ms)
	Time           float32       `json:"time"`           // current time playing (s)
	Duration       float32       `json:"duration"`
	State          PlaybackState `json:"state"`
}

type PongMessage

type PongMessage struct{}

type RawMessage

type RawMessage struct {
	Header MessageHeader // 0-4
	Body   []byte        // 5-
}

func DeserializeRaw

func DeserializeRaw(bodyLen, opCode, body []byte) (*RawMessage, error)

func NewMessage

func NewMessage(op OpCode, body []byte) *RawMessage

type ResumeMessage

type ResumeMessage struct{}

type SeekMessage

type SeekMessage struct {
	Time int `json:"time"` // time to seek in seconds
}

type SetSpeedMessage

type SetSpeedMessage struct {
	Speed float32 `json:"speed"`
}

type SetVolumeMessage

type SetVolumeMessage struct {
	Volume float32 `json:"volume"` // range: 0-1
}

type StopMessage

type StopMessage struct{}

type VersionMessage

type VersionMessage struct {
	Version float32 `json:"version"`
}

type VolumeUpdateMessage

type VolumeUpdateMessage struct {
	GenerationTime int64   `json:"generationTime"`
	Volume         float32 `json:"volume"` // range: 0-1
}

Jump to

Keyboard shortcuts

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