protocol

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MpegTsPacketSize is the TS packet size (188 bytes)
	MpegTsPacketSize = 188
	// MpegTsSyncByte is the byte value of the TS synchronization code (0x47)
	MpegTsSyncByte = 0x47
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FixedReader added in v0.7.0

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

FixedReader implements a buffered reader that always reads a fixed amount of data from an underlying io.Reader.

It is intended to produce a stream from a packet-based network socket, such as net.UDPConn.

Note that packet-based sockets normally give no guarantee about the order of incoming packets, and don't account for resends of dropped ones. If order is important, reordering must be implemented by other means.

If the underlying reader implements the io.Closer interface, Close() calls will be forwarded. Otherwise, Close() is a no-op.

func NewFixedReader added in v0.7.0

func NewFixedReader(reader io.Reader, psize int) *FixedReader

NewFixedReader creates a new buffered reader that pulls in data from an io.Reader in chunks of psize bytes.

func (*FixedReader) Close added in v0.7.0

func (b *FixedReader) Close() error

Close closes the underlying reader.

Subsequent Read calls will succeed as long as the internal buffer still has data. If the buffer is drained, Read returns an error.

func (*FixedReader) Read added in v0.7.0

func (b *FixedReader) Read(p []byte) (n int, err error)

Read reads as many bytes from the internal buffer as can fit into p.

If the buffer has no data left, it tries to pull in a new packet from the underlying reader.

type ForkReader added in v0.9.0

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

func NewForkReader added in v0.9.0

func NewForkReader(command string, arguments []string) (*ForkReader, error)

func (*ForkReader) Close added in v0.9.0

func (f *ForkReader) Close() error

func (*ForkReader) Read added in v0.9.0

func (f *ForkReader) Read(p []byte) (n int, err error)

type MpegTsPacket added in v0.7.0

type MpegTsPacket []byte

MpegTsPacket is an alias to a byte slice and represents one TS packet. It is 188 bytes long and starts with 0x47.

func ReadMpegTsPacket added in v0.7.0

func ReadMpegTsPacket(reader io.Reader) (MpegTsPacket, error)

ReadMpegTsPacket reads data from the input stream, scans for the sync byte and returns one packet from that point on.

If a sync byte can't be found among the first 188 bytes, no packets are returned

Jump to

Keyboard shortcuts

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