Documentation
¶
Overview ¶
Package oggreader implements the Ogg media container reader
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewWith ¶
NewWith returns a new Ogg reader and Ogg header with an io.Reader input.
Warning: NewWith only parses the first OpusHead (a single logical bitstream/track) and returns a single OggHeader. If you need to handle Ogg containers with multiple Opus headers/tracks, use NewWithOptions and scan pages (e.g. via ParseNextPage) to find and parse each OpusHead.
Types ¶
type HeaderType ¶ added in v4.2.0
type HeaderType string
const ( HeaderOpusID HeaderType = "OpusHead" HeaderOpusTags HeaderType = "OpusTags" )
type OggHeader ¶
type OggHeader struct {
ChannelMap uint8
Channels uint8
OutputGain uint16
PreSkip uint16
SampleRate uint32
Version uint8
StreamCount uint8
CoupledCount uint8
// ChannelMapping we store it as a string to be comparable (maps/struct equality)
// while still holding raw bytes.
ChannelMapping string
}
OggHeader contains Opus codec metadata parsed from an Opus ID page. This header is extracted from an Ogg page payload that starts with the OpusHead signature (the first page of an Opus stream in an Ogg container).
Use OggPageHeader.OpusPacketType() to classify a page payload as OpusHead, and OggPageHeader.ParseOpusHeader() to parse the OpusHead payload.
https://tools.ietf.org/html/rfc7845.html#section-3
func ParseOpusHead ¶ added in v4.2.0
ParseOpusHead parses an Opus head from the page payload.
type OggPageHeader ¶
type OggPageHeader struct {
GranulePosition uint64
Serial uint32
// 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
func (*OggPageHeader) HeaderType ¶ added in v4.2.0
func (p *OggPageHeader) HeaderType(payload []byte) (HeaderType, bool)
HeaderType classifies the page.
type OggReader ¶
type OggReader struct {
// contains filtered or unexported fields
}
OggReader is used to read Ogg files and return page payloads.
func NewWithOptions ¶ added in v4.2.0
NewWithOptions returns a new Ogg reader.
func (*OggReader) ParseNextPage ¶
func (o *OggReader) ParseNextPage() ([]byte, *OggPageHeader, error)
ParseNextPage reads from stream and returns Ogg page payload, header, and an error if there is incomplete page data.
type Option ¶ added in v4.2.0
func WithDoChecksum ¶ added in v4.2.0
WithDoChecksum is an option to set the doChecksum flag Default is true.
type OpusTags ¶ added in v4.2.0
type OpusTags struct {
Vendor string
UserComments []UserComment
}
OpusTags is the metadata for an OpusTags page. https://www.xiph.org/vorbis/doc/v-comment.html
func ParseOpusTags ¶ added in v4.2.0
ParseOpusTags parses an OpusTags from the page payload. https://datatracker.ietf.org/doc/html/rfc7845#section-5.2
type UserComment ¶ added in v4.2.0
UserComment is a key-value pair of a vorbis comment.