codec

package
v0.0.0-...-6af8141 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 6 Imported by: 4 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAV1KeyFrame

func IsAV1KeyFrame(payload []byte) bool

IsAV1KeyFrame detects if av1 payload is a keyframe taken from https://github.com/jech/galene/blob/master/codecs/codecs.go all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU

func IsH264KeyFrame

func IsH264KeyFrame(payload []byte) bool

IsH264KeyFrame detects if h264 payload is a keyframe this code was taken from https://github.com/jech/galene/blob/codecs/rtpconn/rtpreader.go#L45 all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU

func IsH265KeyFrame

func IsH265KeyFrame(payload []byte) (kf bool)

func IsKeyFrame

func IsKeyFrame(codec string, payload []byte) bool

func IsVP8KeyFrame

func IsVP8KeyFrame(payload []byte) bool

func IsVP9KeyFrame

func IsVP9KeyFrame(vp9 *codecs.VP9Packet, payload []byte) bool

IsVP9KeyFrame detects if vp9 payload is a keyframe taken from https://github.com/jech/galene/blob/master/codecs/codecs.go all credits belongs to Juliusz Chroboczek @jech and the awesome Galene SFU

func VPxPictureIdSizeDiff

func VPxPictureIdSizeDiff(mBit1 bool, mBit2 bool) int

Types

type BitReader

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

-------- BitReader --------

func NewBitReader

func NewBitReader(data []byte) *BitReader

func (*BitReader) ReadBits

func (br *BitReader) ReadBits(n int) (uint, error)

func (*BitReader) ReadFlag

func (br *BitReader) ReadFlag() (bool, error)

func (*BitReader) ReadSE

func (br *BitReader) ReadSE() (int, error)

func (*BitReader) ReadUE

func (br *BitReader) ReadUE() (uint, error)

type SPSInfo

type SPSInfo struct {
	ChromaFormatIDC             uint
	PicWidthInLumaSamples       uint
	PicHeightInLumaSamples      uint
	ConformanceWindowFlag       bool
	ConfWinLeftOffset           uint
	ConfWinRightOffset          uint
	ConfWinTopOffset            uint
	ConfWinBottomOffset         uint
	CodedWidth, CodedHeight     uint // Raw coded resolution
	DisplayWidth, DisplayHeight uint // Resolution after conformance window cropping
}

SPSInfo holds parsed SPS parameters

type VP8

type VP8 struct {
	FirstByte byte
	S         bool

	I         bool
	M         bool
	PictureID uint16 /* 7 or 15 bits, picture ID */

	L         bool
	TL0PICIDX uint8 /* 8 bits temporal level zero index */

	// Optional Header If either of the T or K bits are set to 1,
	// the TID/Y/KEYIDX extension field MUST be present.
	T   bool
	TID uint8 /* 2 bits temporal layer idx */
	Y   bool

	K      bool
	KEYIDX uint8 /* 5 bits of key frame idx */

	HeaderSize int

	// IsKeyFrame is a helper to detect if current packet is a keyframe
	IsKeyFrame bool
}

VP8 is a helper to get temporal data from VP8 packet header

VP8 Payload Descriptor
		0 1 2 3 4 5 6 7                      0 1 2 3 4 5 6 7
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
		|X|R|N|S|R| PID | (REQUIRED)        |X|R|N|S|R| PID | (REQUIRED)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	X:  |I|L|T|K| RSV   | (OPTIONAL)   X:   |I|L|T|K| RSV   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	I:  |M| PictureID   | (OPTIONAL)   I:   |M| PictureID   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	L:  |   TL0PICIDX   | (OPTIONAL)        |   PictureID   |
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	T/K:|TID|Y| KEYIDX  | (OPTIONAL)   L:   |   TL0PICIDX   | (OPTIONAL)
		+-+-+-+-+-+-+-+-+                   +-+-+-+-+-+-+-+-+
	T/K:|TID|Y| KEYIDX  | (OPTIONAL)
		+-+-+-+-+-+-+-+-+

func (VP8) Marshal

func (v VP8) Marshal() ([]byte, error)

func (VP8) MarshalTo

func (v VP8) MarshalTo(buf []byte) (int, error)

func (*VP8) Unmarshal

func (v *VP8) Unmarshal(payload []byte) error

Unmarshal parses the passed byte slice and stores the result in the VP8 this method is called upon

type VideoSize

type VideoSize struct {
	Width  uint32
	Height uint32
}

VideoSize represents video resolution

func ExtractH264VideoSize

func ExtractH264VideoSize(payload []byte) VideoSize

ExtractH264VideoSize extracts resolution from H.264 RTP payload

func ExtractH265VideoSize

func ExtractH265VideoSize(payload []byte) VideoSize

func ExtractVP8VideoSize

func ExtractVP8VideoSize(vp8Packet *VP8, payload []byte) VideoSize

ExtractVP8VideoSize extracts video resolution from VP8 key frame

Jump to

Keyboard shortcuts

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