oggreader

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

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