voice

package
v0.0.0-...-0ec6b16 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSize = 27 // Total header size in bytes
	MagicVCS   = "VCS"
)

Constants

View Source
const (
	BufferSize       = 1024                  // UDP buffer size
	JitterBufferSize = 10                    // Number of packets to buffer
	PlayoutDelay     = 60 * time.Millisecond // Initial playout delay

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Addr     *net.UDPAddr
	LastSeen time.Time
}

type PacketType

type PacketType uint8

PacketType represents the different packet types

const (
	PacketTypeVoice PacketType = iota
	PacketTypeHello
	PacketTypeHelloAck
	PacketTypeKeepalive
	PacketTypeBye
)

func (PacketType) String

func (pt PacketType) String() string

String returns the string representation of PacketType

type Server

type Server struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewServer

func NewServer(state *state.ServerState, logger *slog.Logger, distributionState *state.DistributionState, settingsState *state.SettingsState) *Server

func (*Server) DisconnectClient

func (v *Server) DisconnectClient(clientID uuid.UUID)

func (*Server) GetClientCount

func (v *Server) GetClientCount() int

func (*Server) GetConnectedClients

func (v *Server) GetConnectedClients() []uuid.UUID

func (*Server) GetListeningClients

func (v *Server) GetListeningClients(packet *VCSPacket, senderId uuid.UUID) []*Client

func (*Server) Listen

func (v *Server) Listen(address string, stopChan chan struct{}) error

func (*Server) PlayVoiceData

func (v *Server) PlayVoiceData(payload []byte)

Simple, direct PlayVoiceData without dejitter buffer - for clean local test playback

func (*Server) Stop

func (v *Server) Stop() error

type VCSPacket

type VCSPacket struct {
	Magic     [3]byte    // Protocol identifier (VCS)
	Version   uint8      // Protocol version (4 bits)
	Type      PacketType // Packet type (4 bits)
	Flags     uint8      // Flags (1. bit PTT, 2. bit Intercom, 6 bits reserved)
	Sequence  uint32     // 24-bit sequence number
	Frequency uint32     // 24-bit frequency in kHz
	SenderID  uuid.UUID  // UUIDv4 session identifier
	Payload   []byte     // Variable payload data
}

VCSPacket represents a parsed VCS protocol packet

func NewVCSHelloAckPacket

func NewVCSHelloAckPacket(clientId uuid.UUID) *VCSPacket

func NewVCSKeepalivePacket

func NewVCSKeepalivePacket(clientId uuid.UUID) *VCSPacket

func NewVCSVoicePacket

func NewVCSVoicePacket(clientId uuid.UUID, sequence uint32, frequency uint32, payload []byte) *VCSPacket

func ParsePacket

func ParsePacket(data []byte) (*VCSPacket, error)

ParsePacket parses a raw UDP packet into a VCSPacket struct

func (*VCSPacket) FrequencyAsFloat32

func (p *VCSPacket) FrequencyAsFloat32() float32

func (*VCSPacket) FrequencyMHz

func (p *VCSPacket) FrequencyMHz() float64

FrequencyMHz returns the frequency in MHz as a float64

func (*VCSPacket) IsIntercom

func (p *VCSPacket) IsIntercom() bool

IsIntercom returns true if the Intercom flag is set

func (*VCSPacket) IsPTTActive

func (p *VCSPacket) IsPTTActive() bool

IsPTTActive returns true if the PTT flag is set

func (*VCSPacket) SerializePacket

func (p *VCSPacket) SerializePacket() []byte

SerializePacket converts a VCSPacket struct back to raw bytes

func (*VCSPacket) SetFrequencyMHz

func (p *VCSPacket) SetFrequencyMHz(freqMHz float64)

SetFrequencyMHz sets the frequency from MHz (converts to kHz internally)

func (*VCSPacket) SetIntercom

func (p *VCSPacket) SetIntercom(active bool)

SetIntercom sets or clears the Intercom flag

func (*VCSPacket) SetPTT

func (p *VCSPacket) SetPTT(active bool)

SetPTT sets or clears the PTT flag

func (*VCSPacket) String

func (p *VCSPacket) String() string

String returns a string representation of the packet for debugging

Jump to

Keyboard shortcuts

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