streaminfo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Marker = "fLaC"

	MetadataTypeStreamInfo    = 0
	MetadataTypeVorbisComment = 4
	MetadataTypePicture       = 6
	Length                    = 34

	MetadataKey = "flac.streaminfo"
	// MetadataBlockKey stores opaque FLAC metadata blocks. Each value contains
	// the four-byte FLAC block header followed by its payload.
	MetadataBlockKey = "flac.metadata.block"
	MaxChannels      = 8
)

Variables

This section is empty.

Functions

func ChannelLayout

func ChannelLayout(channels int) media.ChannelLayout

ChannelLayout maps a FLAC channel count to a channel layout.

func Encode

func Encode(info StreamInfo) []byte

Encode serializes a STREAMINFO metadata block payload.

func ParseBlockHeader

func ParseBlockHeader(header [4]byte) (isLast bool, blockType byte, length int)

ParseBlockHeader decodes a 4-byte FLAC metadata block header into its last-block flag, block type, and payload length.

func SampleFormat

func SampleFormat(bitsPerSample int) media.SampleFormat

SampleFormat maps a FLAC bit depth to the PCM sample format used to represent decoded samples.

func Validate

func Validate(info StreamInfo) error

Validate checks that a StreamInfo (whether parsed or synthesized) has sane values.

Types

type PCMMD5Parameters

type PCMMD5Parameters struct{}

PCMMD5Parameters identifies a 16-byte source PCM MD5 payload.

type StreamInfo

type StreamInfo struct {
	MinBlockSize  uint16
	MaxBlockSize  uint16
	MinFrameSize  uint32
	MaxFrameSize  uint32
	SampleRate    int
	Channels      int
	BitsPerSample int
	TotalSamples  uint64
	MD5           [16]byte
}

func Parse

func Parse(data []byte) (StreamInfo, error)

Parse decodes and validates a 34-byte FLAC STREAMINFO metadata block.

func (StreamInfo) Duration

func (s StreamInfo) Duration() time.Duration

Duration returns the stream duration derived from TotalSamples. It returns 0 when the duration is unknown (TotalSamples or SampleRate is unset) or does not fit in time.Duration.

Jump to

Keyboard shortcuts

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