Documentation ¶
Index ¶
- Constants
- func EncodeCompressionHeader(compressedLen uint32, framesId uint64, checksum uint32) []byte
- func ReadHeader(data []byte) (compressedLen uint32, framesId uint64, checksum uint32)
- func ReceiveUDP(s Streamable) (err error)
- func SendUDP(s Streamable) (err error)
- type Compressor
- type Huff0Compressor
- type Streamable
Constants ¶
const HeaderLength = 16 // 16 bits
HeaderLength correspond to the compressed Header length Byte 0 to 3: the compressed bytes Length (Big Endian Uint32) Byte 4 to 11: the incremental frame identifier (Big Endian Uint64) Byte 12 to 15: the crc32 checksum of the uncompressed payload (Big Endian Uint32)
Variables ¶
This section is empty.
Functions ¶
func EncodeCompressionHeader ¶
EncodeCompressionHeader is a global function that does not require a CompressionStack
func ReadHeader ¶
ReadHeader returns the Header's infos.
func ReceiveUDP ¶
func ReceiveUDP(s Streamable) (err error)
func SendUDP ¶
func SendUDP(s Streamable) (err error)
Types ¶
type Compressor ¶
type Compressor interface { Compress(src []byte) (res []byte, err error) Decompress(src []byte) (res []byte, err error) }
Compressor defines the interface for compression providers
type Huff0Compressor ¶
type Huff0Compressor struct { Compressor // contains filtered or unexported fields }
Huff0Compressor is a Huffman encoding and decoding as used in "zstd". "Huff0, a Huffman codec designed for modern CPU, featuring OoO (Out of Order) operations on multiple ALU (Arithmetic Logic Unit), achieving extremely fast compression and decompression speeds." ```
compressor := streams.NewHuff0Compressor() streamer := &miniaudio.Miniaudio{Format: malgo.FormatS16, Compressor: compressor}
``` With a modern processor this compressor delivers an average lossless compression between 20% to 30% on PCM data with a latency < 0.5 milliseconds for encoding + decoding.
func NewHuff0Compressor ¶
func NewHuff0Compressor() *Huff0Compressor
func (*Huff0Compressor) Compress ¶
func (c *Huff0Compressor) Compress(src []byte) (res []byte, err error)
func (*Huff0Compressor) Decompress ¶
func (c *Huff0Compressor) Decompress(src []byte) (res []byte, err error)
type Streamable ¶
type Streamable interface { // Configure is the designated configuration method Configure(address string, sampleRate float64, nbChannels int, echo bool, done chan interface{}) // ReadStreamFrom reads the chunks from the stream. ReadStreamFrom(c io.Reader) error // WriteStreamTo writes to the given connection stream WriteStreamTo(c io.Writer) error // Address correspond to the <IP or Name:PORT> Address() string // SampleRate is the sample rate :) SampleRate() float64 // NbChannels stereo = 2 NbChannels() int // Echo if responding true prints the flow in the stdio Echo() bool // Done is the cancellation channel Done() chan interface{} }
Streamable the interface to implement to be streamable over a network.