ebmltext

package
v0.0.0-...-3eaea91 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

Package ebmltext provides a low level API to interacts with EBML documents. Use directly with caution.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidVINTWidth = fmt.Errorf("ebmltext: invalid VINT_WIDTH")
	ErrAllOneVINT       = fmt.Errorf("ebmltext: VINT_DATA MUST NOT be set to all 1")
)

Functions

func AppendVint

func AppendVint(num uint64, b []byte) (w int, err error)

AppendVint appends the binary representation of a VINT to b based on https://datatracker.ietf.org/doc/html/rfc8794.html#section-4

func AppendVintData

func AppendVintData(num uint64, minW int, b []byte) (w int, err error)

AppendVintData appends the binary representation of a VINT to b based on https://datatracker.ietf.org/doc/html/rfc8794.html#section-4

func Date

func Date(b []byte) (time.Time, error)

Date reads a time,Time based on https://www.rfc-editor.org/rfc/rfc8794.html#section-7.6

func Float

func Float(b []byte) (float64, error)

Float reads a float64 based on https://www.rfc-editor.org/rfc/rfc8794.html#section-7.3

func Int

func Int(b []byte) (int64, error)

Int reads an int64 based on https://www.rfc-editor.org/rfc/rfc8794.html#section-7.1

func ReadVint

func ReadVint(b []byte) (vint uint64, w int, err error)

ReadVint reads the integer representation of a VINT from b based on https://datatracker.ietf.org/doc/html/rfc8794.html#section-4

func ReadVintData

func ReadVintData(b []byte) (vint uint64, w int, err error)

ReadVintData reads the integer representation of a VINT from b based on https://datatracker.ietf.org/doc/html/rfc8794.html#section-4

func String

func String(b []byte) (string, error)

String reads a string based on https://www.rfc-editor.org/rfc/rfc8794.html#section-7.5

func Uint

func Uint(b []byte) (uint64, error)

Uint reads an uint64 based on https://www.rfc-editor.org/rfc/rfc8794.html#section-7.2

Types

type DecodeSeeker

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

func (DecodeSeeker) Seek

func (s DecodeSeeker) Seek(offset int64, whence int) (int64, error)

type Decoder

type Decoder struct {
	// https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.4
	MaxIDLength uint
	// https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.5
	MaxSizeLength uint
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) AsSeeker

func (d *Decoder) AsSeeker() (io.Seeker, bool)

func (*Decoder) InputOffset

func (d *Decoder) InputOffset() int64

func (*Decoder) Read

func (d *Decoder) Read(b []byte) (int, error)

func (*Decoder) ReadElementDataSize

func (d *Decoder) ReadElementDataSize() (ds int64, err error)

ReadElementDataSize reads an Element Data Size based on https://datatracker.ietf.org/doc/html/rfc8794#section-6

TODO: EBMLMaxSizeLength can be greater than 8 https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.5

func (*Decoder) ReadElementID

func (d *Decoder) ReadElementID() (id schema.ElementID, err error)

ReadElementID reads an Element ID based on https://datatracker.ietf.org/doc/html/rfc8794#section-5

TODO: EBMLMaxIDLength can be greater than 8 https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.4

func (*Decoder) Release

func (d *Decoder) Release() int

Release releases n bytes from the internal buffer after reading an Element ID or an Element Data Size, where n is the number of bytes read by these operations.

This is useful if the file is damaged and have to look for valid Elements.

type Encoder

type Encoder struct {
	// https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.4
	MaxIDLength uint
	// https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.5
	MaxSizeLength uint
	// contains filtered or unexported fields
}

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

func (*Encoder) OutputOffset

func (e *Encoder) OutputOffset() int64

func (*Encoder) Write

func (e *Encoder) Write(v []byte) (int, error)

func (*Encoder) WriteElementDataSize

func (e *Encoder) WriteElementDataSize(ds int64, minW int) (n int, err error)

WriteElementDataSize writes an Element Data Size based on https://datatracker.ietf.org/doc/html/rfc8794#section-6

TODO: EBMLMaxSizeLength can be greater than 8 https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.5

func (*Encoder) WriteElementID

func (e *Encoder) WriteElementID(id schema.ElementID) (n int, err error)

WriteElementID writes an Element ID based on https://datatracker.ietf.org/doc/html/rfc8794#section-5

TODO: EBMLMaxIDLength can be greater than 8 https://datatracker.ietf.org/doc/html/rfc8794#section-11.2.4

type Token

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

Jump to

Keyboard shortcuts

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