nativeaudio

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	SampleRate     = 48_000
	Channels       = 2
	FrameSamples   = 960
	FrameBytes     = FrameSamples * Channels * 2
	MaxPacketBytes = 4_000
	DefaultBitrate = 128_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

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

Encoder adapts the capture process's fixed 48 kHz PCM frames to WebRTC Opus packets. The buffers are owned by the encoder and reused after each Encode call; the returned packet must be consumed before the next call.

func NewEncoder

func NewEncoder(bitrate int) (*Encoder, error)

func (*Encoder) Bitrate

func (encoder *Encoder) Bitrate() int

func (*Encoder) Encode

func (encoder *Encoder) Encode(pcm []byte) ([]byte, error)

Encode accepts one interleaved little-endian PCM16 frame and returns an Opus packet backed by the encoder's reusable output buffer.

func (*Encoder) SetBitrate

func (encoder *Encoder) SetBitrate(bitrate int) error

Jump to

Keyboard shortcuts

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