rtmp

package
v0.0.0-...-e303c84 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

Package rtmp provides RTMP connectivity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromStream

func FromStream(
	str *stream.Stream,
	reader stream.Reader,
	conn Conn,
	nconn net.Conn,
	writeTimeout time.Duration,
) error

FromStream maps a MediaMTX stream to a RTMP stream.

func ToStream

func ToStream(r *Reader, stream **stream.Stream) ([]*description.Media, error)

ToStream maps a RTMP stream to a MediaMTX stream.

Types

type Client

type Client struct {
	URL       *url.URL
	TLSConfig *ctls.Config
	Publish   bool
	// contains filtered or unexported fields
}

Client is a client-side RTMP connection.

func (*Client) BytesReceived

func (c *Client) BytesReceived() uint64

BytesReceived returns the number of bytes received.

func (*Client) BytesSent

func (c *Client) BytesSent() uint64

BytesSent returns the number of bytes sent.

func (*Client) Close

func (c *Client) Close()

Close closes the connection.

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context) error

Initialize initializes Client.

func (*Client) NetConn

func (c *Client) NetConn() net.Conn

NetConn returns the underlying net.Conn.

func (*Client) Read

func (c *Client) Read() (message.Message, error)

Read reads a message.

func (*Client) Write

func (c *Client) Write(msg message.Message) error

Write writes a message.

type Conn

type Conn interface {
	BytesReceived() uint64
	BytesSent() uint64
	Read() (message.Message, error)
	Write(msg message.Message) error
}

Conn is implemented by Client and ServerConn.

type OnDataAC3Func

type OnDataAC3Func func(pts time.Duration, frame []byte)

OnDataAC3Func is the prototype of the callback passed to OnDataAC3().

type OnDataAV1Func

type OnDataAV1Func func(pts time.Duration, tu [][]byte)

OnDataAV1Func is the prototype of the callback passed to OnDataAV1().

type OnDataG711Func

type OnDataG711Func func(pts time.Duration, samples []byte)

OnDataG711Func is the prototype of the callback passed to OnDataG711().

type OnDataH26xFunc

type OnDataH26xFunc func(pts time.Duration, au [][]byte)

OnDataH26xFunc is the prototype of the callback passed to OnDataH26x().

type OnDataLPCMFunc

type OnDataLPCMFunc func(pts time.Duration, samples []byte)

OnDataLPCMFunc is the prototype of the callback passed to OnDataLPCM().

type OnDataMPEG1AudioFunc

type OnDataMPEG1AudioFunc func(pts time.Duration, frame []byte)

OnDataMPEG1AudioFunc is the prototype of the callback passed to OnDataMPEG1Audio().

type OnDataMPEG4AudioFunc

type OnDataMPEG4AudioFunc func(pts time.Duration, au []byte)

OnDataMPEG4AudioFunc is the prototype of the callback passed to OnDataMPEG4Audio().

type OnDataOpusFunc

type OnDataOpusFunc func(pts time.Duration, packet []byte)

OnDataOpusFunc is the prototype of the callback passed to OnDataOpus().

type OnDataVP9Func

type OnDataVP9Func func(pts time.Duration, frame []byte)

OnDataVP9Func is the prototype of the callback passed to OnDataVP9().

type Reader

type Reader struct {
	Conn Conn
	// contains filtered or unexported fields
}

Reader provides functions to read incoming data.

func (*Reader) Initialize

func (r *Reader) Initialize() error

Initialize initializes Reader.

func (*Reader) OnDataAC3

func (r *Reader) OnDataAC3(track *format.AC3, cb OnDataAC3Func)

OnDataAC3 sets a callback that is called when AC-3 data is received.

func (*Reader) OnDataAV1

func (r *Reader) OnDataAV1(track *format.AV1, cb OnDataAV1Func)

OnDataAV1 sets a callback that is called when AV1 data is received.

func (*Reader) OnDataG711

func (r *Reader) OnDataG711(track *format.G711, cb OnDataG711Func)

OnDataG711 sets a callback that is called when G711 data is received.

func (*Reader) OnDataH264

func (r *Reader) OnDataH264(track *format.H264, cb OnDataH26xFunc)

OnDataH264 sets a callback that is called when H264 data is received.

func (*Reader) OnDataH265

func (r *Reader) OnDataH265(track *format.H265, cb OnDataH26xFunc)

OnDataH265 sets a callback that is called when H265 data is received.

func (*Reader) OnDataLPCM

func (r *Reader) OnDataLPCM(track *format.LPCM, cb OnDataLPCMFunc)

OnDataLPCM sets a callback that is called when LPCM data is received.

func (*Reader) OnDataMPEG1Audio

func (r *Reader) OnDataMPEG1Audio(track *format.MPEG1Audio, cb OnDataMPEG1AudioFunc)

OnDataMPEG1Audio sets a callback that is called when MPEG-1 Audio data is received.

func (*Reader) OnDataMPEG4Audio

func (r *Reader) OnDataMPEG4Audio(track *format.MPEG4Audio, cb OnDataMPEG4AudioFunc)

OnDataMPEG4Audio sets a callback that is called when MPEG-4 Audio data is received.

func (*Reader) OnDataOpus

func (r *Reader) OnDataOpus(track *format.Opus, cb OnDataOpusFunc)

OnDataOpus sets a callback that is called when Opus data is received.

func (*Reader) OnDataVP9

func (r *Reader) OnDataVP9(track *format.VP9, cb OnDataVP9Func)

OnDataVP9 sets a callback that is called when VP9 data is received.

func (*Reader) Read

func (r *Reader) Read() error

Read reads data.

func (*Reader) Tracks

func (r *Reader) Tracks() []format.Format

Tracks returns detected tracks

type ServerConn

type ServerConn struct {
	RW io.ReadWriter

	// filled by Accept
	URL     *url.URL
	Publish bool
	// contains filtered or unexported fields
}

ServerConn is a server-side RTMP connection.

func (*ServerConn) Accept

func (c *ServerConn) Accept() error

Accept accepts the connection.

func (*ServerConn) BytesReceived

func (c *ServerConn) BytesReceived() uint64

BytesReceived returns the number of bytes received.

func (*ServerConn) BytesSent

func (c *ServerConn) BytesSent() uint64

BytesSent returns the number of bytes sent.

func (*ServerConn) CheckCredentials

func (c *ServerConn) CheckCredentials(expectedUser string, expectedPass string) error

CheckCredentials checks credentials.

func (*ServerConn) Initialize

func (c *ServerConn) Initialize() error

Initialize initializes ServerConn.

func (*ServerConn) Read

func (c *ServerConn) Read() (message.Message, error)

Read reads a message.

func (*ServerConn) Write

func (c *ServerConn) Write(msg message.Message) error

Write writes a message.

type Writer

type Writer struct {
	Conn       Conn
	VideoTrack format.Format
	AudioTrack format.Format
}

Writer provides functions to write outgoing data.

func (*Writer) Initialize

func (w *Writer) Initialize() error

Initialize initializes Writer.

func (*Writer) WriteH264

func (w *Writer) WriteH264(pts time.Duration, dts time.Duration, au [][]byte) error

WriteH264 writes H264 data.

func (*Writer) WriteMPEG1Audio

func (w *Writer) WriteMPEG1Audio(pts time.Duration, h *mpeg1audio.FrameHeader, frame []byte) error

WriteMPEG1Audio writes MPEG-1 Audio data.

func (*Writer) WriteMPEG4Audio

func (w *Writer) WriteMPEG4Audio(pts time.Duration, au []byte) error

WriteMPEG4Audio writes MPEG-4 Audio data.

Directories

Path Synopsis
Package amf0 contains an AMF0 decoder and encoder.
Package amf0 contains an AMF0 decoder and encoder.
Package bytecounter contains a reader/writer that allows to count bytes.
Package bytecounter contains a reader/writer that allows to count bytes.
Package chunk implements RTMP chunks.
Package chunk implements RTMP chunks.
Package h264conf contains a H264 configuration parser.
Package h264conf contains a H264 configuration parser.
Package handshake contains the RTMP handshake mechanism.
Package handshake contains the RTMP handshake mechanism.
Package message contains a RTMP message reader/writer.
Package message contains a RTMP message reader/writer.
Package rawmessage contains a RTMP raw message reader/writer.
Package rawmessage contains a RTMP raw message reader/writer.

Jump to

Keyboard shortcuts

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