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

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