Documentation
¶
Index ¶
- Variables
- type Handler
- func (h *Handler) OnAudio(timestamp uint32, payload io.Reader) error
- func (h *Handler) OnClose()
- func (h *Handler) OnConnect(timestamp uint32, cmd *rtmpmsg.NetConnectionConnect) error
- func (h *Handler) OnCreateStream(timestamp uint32, cmd *rtmpmsg.NetConnectionCreateStream) error
- func (h *Handler) OnError(e error)
- func (h *Handler) OnPlay(ctx *rtmp.StreamContext, timestamp uint32, cmd *rtmpmsg.NetStreamPlay) error
- func (h *Handler) OnPublish(ctx *rtmp.StreamContext, timestamp uint32, cmd *rtmpmsg.NetStreamPublish) error
- func (h *Handler) OnServe(conn *rtmp.Conn)
- func (h *Handler) OnSetDataFrame(timestamp uint32, data *rtmpmsg.NetStreamSetDataFrame) error
- func (h *Handler) OnStop()
- func (h *Handler) OnVideo(timestamp uint32, payload io.Reader) error
- type HlsClient
- type Pub
- type Pubsub
- type RelayService
- type Sub
Constants ¶
This section is empty.
Variables ¶
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 ¶
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) 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 ¶
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.
type Pubsub ¶
type Pubsub struct {
// contains filtered or unexported fields
}
func NewPubsub ¶
func NewPubsub(srv *RelayService, name string) *Pubsub
func (*Pubsub) Deregister ¶
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) RemovePubsub ¶
func (s *RelayService) RemovePubsub(key string) error