oggwriter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 12 Imported by: ? 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

Overview

Package oggwriter implements OGG media container writer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OggWriter

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

OggWriter is used to take RTP packets and write them to a single-track OGG.

func New

func New(fileName string, sampleRate uint32, channelCount uint16) (*OggWriter, error)

New builds a new single-track OGG Opus writer.

func NewWith

func NewWith(out io.Writer, sampleRate uint32, channelCount uint16) (*OggWriter, error)

NewWith initializes a new single-track OGG Opus writer with an io.Writer output.

func (*OggWriter) Close

func (w *OggWriter) Close() error

Close stops single-track recording.

func (*OggWriter) WriteRTP

func (w *OggWriter) WriteRTP(packet *rtp.Packet) error

WriteRTP adds a new packet and writes the appropriate headers for it.

type OpusTags

type OpusTags struct {
	Vendor       string
	UserComments []UserComment
}

OpusTags is the metadata for an OpusTags page. https://datatracker.ietf.org/doc/html/rfc7845#section-5.2

type Track

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

Track writes RTP packets for a single logical Opus stream in a Writer.

func (*Track) WriteRTP

func (w *Track) WriteRTP(packet *rtp.Packet) error

WriteRTP adds a packet to a single logical stream inside a Writer.

type TrackOption

type TrackOption interface {
	// contains filtered or unexported methods
}

TrackOption configures a logical Opus stream in a multiplexed Ogg container.

func WithSerial

func WithSerial(serial uint32) TrackOption

WithSerial sets the Ogg bitstream serial number for a track.

type UserComment

type UserComment struct {
	Comment string
	Value   string
}

UserComment is a key-value pair of a Vorbis comment.

type Writer

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

Writer is used to write multiple logical Opus streams into one OGG. Tracks are added before writing starts, and each returned Track owns WriteRTP.

func NewWriter

func NewWriter(out io.Writer, opts ...WriterOption) (*Writer, error)

NewWriter creates a new multi-track OGG Opus writer with an io.Writer output. Close finalizes each logical stream with EOS. Without WithSeekableOutput, Close appends nil EOS pages because previously written pages cannot be rewritten.

func (*Writer) Close

func (w *Writer) Close() error

Close stops multi-track recording.

func (*Writer) NewTrack

func (w *Writer) NewTrack(ssrc uint32, opts ...TrackOption) (*Track, error)

NewTrack registers a logical Opus stream and returns its Track. It must be called before the first packet is written.

type WriterOption

type WriterOption interface {
	// contains filtered or unexported methods
}

WriterOption configures a multiplexed Ogg writer.

func WithSeekableOutput

func WithSeekableOutput(output interface {
	io.Seeker
	io.WriterAt
},
) WriterOption

WithSeekableOutput enables close-time Ogg page rewrites for outputs that support Seek and WriteAt.

type WriterTrackOption

type WriterTrackOption interface {
	WriterOption
	TrackOption
}

WriterTrackOption configures both Writer defaults and per-track overrides.

func WithChannelCount

func WithChannelCount(channelCount uint16) WriterTrackOption

WithChannelCount sets the default channel count for a Writer or overrides it for a Track. Mono and stereo are written with Opus channel mapping family 0. For non-zero single-stream channel mapping families, use WithChannelMapping.

func WithChannelMapping

func WithChannelMapping(family, streamCount, coupledCount uint8, mapping []byte) WriterTrackOption

WithChannelMapping sets an explicit Opus channel mapping family for a Writer or Track. The channel count is derived from len(mapping). Only single-stream mappings are supported because WriteRTP accepts one Opus packet per Ogg packet. Family 1 supports mono/stereo Vorbis mappings, family 2 supports zero-order ambisonics, and family 255 supports arbitrary single-stream mappings.

func WithSampleRate

func WithSampleRate(sampleRate uint32) WriterTrackOption

WithSampleRate sets the default sample rate for a Writer or overrides it for a Track.

func WithUserComments

func WithUserComments(comments ...UserComment) WriterTrackOption

WithUserComments adds OpusTags user comments for a Writer or Track.

func WithVendor

func WithVendor(vendor string) WriterTrackOption

WithVendor sets the OpusTags vendor string for a Writer or overrides it for a Track.

Jump to

Keyboard shortcuts

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