chunk

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package chunk implements RTMP chunks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk interface {
	Read(io.Reader, uint32) error
	Marshal() ([]byte, error)
}

Chunk is a chunk.

type Chunk0

type Chunk0 struct {
	ChunkStreamID   byte
	Timestamp       uint32
	Type            uint8
	MessageStreamID uint32
	BodyLen         uint32
	Body            []byte
}

Chunk0 is a type 0 chunk. This type MUST be used at the start of a chunk stream, and whenever the stream timestamp goes backward (e.g., because of a backward seek).

func (Chunk0) Marshal

func (c Chunk0) Marshal() ([]byte, error)

Marshal writes the chunk.

func (*Chunk0) Read

func (c *Chunk0) Read(r io.Reader, chunkMaxBodyLen uint32) error

Read reads the chunk.

type Chunk1

type Chunk1 struct {
	ChunkStreamID  byte
	TimestampDelta uint32
	Type           uint8
	BodyLen        uint32
	Body           []byte
}

Chunk1 is a type 1 chunk. The message stream ID is not included; this chunk takes the same stream ID as the preceding chunk. Streams with variable-sized messages (for example, many video formats) SHOULD use this format for the first chunk of each new message after the first.

func (Chunk1) Marshal

func (c Chunk1) Marshal() ([]byte, error)

Marshal writes the chunk.

func (*Chunk1) Read

func (c *Chunk1) Read(r io.Reader, chunkMaxBodyLen uint32) error

Read reads the chunk.

type Chunk2

type Chunk2 struct {
	ChunkStreamID  byte
	TimestampDelta uint32
	Body           []byte
}

Chunk2 is a type 2 chunk. Neither the stream ID nor the message length is included; this chunk has the same stream ID and message length as the preceding chunk.

func (Chunk2) Marshal

func (c Chunk2) Marshal() ([]byte, error)

Marshal writes the chunk.

func (*Chunk2) Read

func (c *Chunk2) Read(r io.Reader, chunkBodyLen uint32) error

Read reads the chunk.

type Chunk3

type Chunk3 struct {
	ChunkStreamID byte
	Body          []byte
}

Chunk3 is a type 3 chunk. Type 3 chunks have no message header. The stream ID, message length and timestamp delta fields are not present; chunks of this type take values from the preceding chunk for the same Chunk Stream ID. When a single message is split into chunks, all chunks of a message except the first one SHOULD use this type.

func (Chunk3) Marshal

func (c Chunk3) Marshal() ([]byte, error)

Marshal writes the chunk.

func (*Chunk3) Read

func (c *Chunk3) Read(r io.Reader, chunkBodyLen uint32) error

Read reads the chunk.

Jump to

Keyboard shortcuts

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