oggreader

package
v2.20.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 1 module, 1 package

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

This section is empty.

Variables

View Source
var (
	ErrInvalidPacket = errors.New("invalid opus packet")
)

Functions

func NewOggReader

func NewOggReader(in io.Reader) (*OggReader, *OggHeader, error)

NewWith returns a new Ogg reader and Ogg header with an io.Reader input

func ParsePacketDuration

func ParsePacketDuration(data []byte) (time.Duration, error)

Parse the duration of a an OpusPacket https://www.rfc-editor.org/rfc/rfc6716#section-3.1

Types

type OggHeader

type OggHeader struct {
	ChannelMap uint8
	Channels   uint8
	OutputGain uint16
	PreSkip    uint16
	SampleRate uint32
	Version    uint8
}

OggHeader is the metadata from the first two pages in the file (ID and Comment)

https://tools.ietf.org/html/rfc7845.html#section-3

type OggPage

type OggPage struct {
	GranulePosition uint64
	// contains filtered or unexported fields
}

OggPageHeader is the metadata for a Page Pages are the fundamental unit of multiplexing in an Ogg stream

https://tools.ietf.org/html/rfc7845.html#section-1

type OggReader

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

This is a modified version of the oggreader package from github.com/pion/webrtc The original Pion package can only read OGG pages, and the payload can only be used if the page contains only one segment. And this specific segment must only contains one Opus Packet.

RTP Packet can contains only one Opus Packet. https://www.rfc-editor.org/rfc/rfc7587#section-4.2

func (*OggReader) ReadPacket

func (o *OggReader) ReadPacket() ([]byte, error)

Pages can contain up to a second of audio data, which is much too large for an RTP packet. Instead of returning the entire page, this will return one sample at a time.

Jump to

Keyboard shortcuts

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