extensions

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package extensions implements the Opus packet-extension grammar carried in RFC 6716 code-3 padding.

Index

Constants

View Source
const (
	MinID     = 3
	MaxID     = 127
	MaxFrames = 48
)

Variables

View Source
var (
	ErrBadArg         = errors.New("extensions: bad argument")
	ErrInvalidPacket  = errors.New("extensions: invalid packet")
	ErrBufferTooSmall = errors.New("extensions: buffer too small")
)

Functions

func Count

func Count(data []byte, nbFrames int) (int, error)

Count validates and counts the extensions in an extension-bearing padding region. Repeat indicators count once for every expanded frame occurrence.

func Generate

func Generate(extensions []Extension, nbFrames, targetLen int) ([]byte, error)

Generate encodes extensions using the libopus repeat and separator grammar. targetLen==0 produces the minimal representation. A positive targetLen produces exactly that many bytes by prepending extension padding bytes.

Types

type Extension

type Extension struct {
	ID    int
	Frame int
	Data  []byte
}

Extension is one decoded packet extension. Data is owned by the caller.

func Parse

func Parse(data []byte, nbFrames int) ([]Extension, error)

Parse decodes an extension-bearing padding region in bitstream order. Repeat indicators are expanded into one Extension per target frame.

Jump to

Keyboard shortcuts

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