rtmpc

package
v0.0.0-...-d64eb31 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyPublished = errors.New("already published")

Functions

This section is empty.

Types

type Handler

type Handler struct {
	rtmp.DefaultHandler

	Stream *core.StreamState
	// contains filtered or unexported fields
}

Handler An RTMP connection handler

func NewHandler

func NewHandler(relayService *RelayService, rd *redis.Client, hlsClient HlsClient, ps pubsub.Pubsub) *Handler

NewHandler creates and returns a new Handler instance for managing RTMP connections with provided dependencies.

func (*Handler) OnAudio

func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error

OnAudio processes incoming audio data, decodes it, and publishes it as an FLV tag for subscribers.

func (*Handler) OnClose

func (h *Handler) OnClose()

OnClose cleans up resources associated with the handler by closing the publisher and subscriber, if they are initialized.

func (*Handler) OnConnect

func (h *Handler) OnConnect(timestamp uint32, cmd *rtmpmsg.NetConnectionConnect) error

OnConnect validates the application name during an RTMP connection request and initializes the connection process.

func (*Handler) OnCreateStream

func (h *Handler) OnCreateStream(timestamp uint32, cmd *rtmpmsg.NetConnectionCreateStream) error

func (*Handler) OnError

func (h *Handler) OnError(e error)

func (*Handler) OnPlay

func (h *Handler) OnPlay(ctx *rtmp.StreamContext, timestamp uint32, cmd *rtmpmsg.NetStreamPlay) error

OnPlay sets up a subscriber for RTMP playback on a specified stream and validates the stream's availability.

func (*Handler) OnPublish

func (h *Handler) OnPublish(ctx *rtmp.StreamContext, timestamp uint32, cmd *rtmpmsg.NetStreamPublish) error

OnPublish handles publishing requests for incoming RTMP streams, validates publishing parameters, and initializes resources.

func (*Handler) OnServe

func (h *Handler) OnServe(conn *rtmp.Conn)

OnServe initializes the RTMP connection for the handler and assigns it to the handler's 'conn' field.

func (*Handler) OnSetDataFrame

func (h *Handler) OnSetDataFrame(timestamp uint32, data *rtmpmsg.NetStreamSetDataFrame) error

OnSetDataFrame processes the "onMetaData" script data from a NetStreamSetDataFrame message and publishes it to subscribers.

func (*Handler) OnStop

func (h *Handler) OnStop()

func (*Handler) OnVideo

func (h *Handler) OnVideo(timestamp uint32, payload io.Reader) error

OnVideo processes incoming video data, decodes it, and publishes it as an FLV tag for subscribers.

type HlsClient

type HlsClient interface {
	NewHlsStream(ctx context.Context, streamId, serverUrl, streamKey string, fps, resolution int) (err error)
}

type Pub

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

func (*Pub) Close

func (p *Pub) Close() error

func (*Pub) Publish

func (p *Pub) Publish(flv *flvtag.FlvTag) error

Publish TODO: Should check codec types and so on. In this example, checks only sequence headers and assume that AAC and AVC.

type Pubsub

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

func NewPubsub

func NewPubsub(srv *RelayService, name string) *Pubsub

func (*Pubsub) Deregister

func (pb *Pubsub) Deregister() error

func (*Pubsub) Pub

func (pb *Pubsub) Pub() *Pub

func (*Pubsub) Sub

func (pb *Pubsub) Sub() *Sub

type RelayService

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

RelayService TODO: Create this service per apps. In this example, this instance is singleton.

func NewRelayService

func NewRelayService() *RelayService

func (*RelayService) GetPubsub

func (s *RelayService) GetPubsub(key string) (*Pubsub, error)

func (*RelayService) NewPubsub

func (s *RelayService) NewPubsub(key string) (*Pubsub, error)

func (*RelayService) RemovePubsub

func (s *RelayService) RemovePubsub(key string) error

type Sub

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

func (*Sub) Close

func (s *Sub) Close() error

Jump to

Keyboard shortcuts

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