opussampleprovider

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: MIT Imports: 7 Imported by: 1 module, 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

Overview

Package opussampleprovider adapts a Linear16 io.Reader to LiveKit's lksdk.SampleProvider interface, emitting Opus packets in real‑time using audiotranscoder.OpusStreamer.

The provider is deliberately opinionated — it assumes 48 kHz, mono Linear16 on input and produces 20‑ms Opus frames (typical for WebRTC/LiveKit). Feel free to extend the constructor to accept a sample‑rate/channels/options struct if you need something else.

src := getLinear16Reader()
provider := opussampleprovider.NewFromLinear16Reader(src)
// pass *provider to lksdk.NewLocalSampleTrack(provider, lksdk.Opus)

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSamples = errors.New("no samples")

Functions

This section is empty.

Types

type ByteReaderProvider

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

func NewFromLinear16Reader

func NewFromLinear16Reader(r io.Reader) *ByteReaderProvider

NewFromLinear16Reader wires a ByteReaderProvider with default OpusStreamer settings (48 kHz, mono, 20‑ms frames).

func (*ByteReaderProvider) Close

func (p *ByteReaderProvider) Close() error

Close fully releases resources; after this the ByteReaderProvider should not be used.

func (*ByteReaderProvider) NextSample

func (p *ByteReaderProvider) NextSample(ctx context.Context) (media.Sample, error)

NextSample blocks until the next Opus packet is available or context/error.

func (*ByteReaderProvider) OnBind

func (p *ByteReaderProvider) OnBind() error

OnBind is called by LiveKit when the track is added to a PeerConnection.

func (*ByteReaderProvider) OnUnbind

func (p *ByteReaderProvider) OnUnbind() error

OnUnbind stops the internal pipeline but keeps ByteReaderProvider reusable.

type OpusChunkProvider

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

func NewFromOpusChunkChan

func NewFromOpusChunkChan(chunks <-chan pkg.AudioChunk, frameDur time.Duration) *OpusChunkProvider

func (*OpusChunkProvider) Close

func (p *OpusChunkProvider) Close() error

func (*OpusChunkProvider) NextSample

func (p *OpusChunkProvider) NextSample() (media.Sample, error)

func (*OpusChunkProvider) OnBind

func (p *OpusChunkProvider) OnBind() error

func (*OpusChunkProvider) OnUnbind

func (p *OpusChunkProvider) OnUnbind() error

Jump to

Keyboard shortcuts

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