core

package
v0.0.0-...-ced71c4 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

The RTMP server. This will put up a RTMP endpoint when starting up Swarm. To integrate with LPMS means your code will become the source / destination of the media server. This RTMP endpoint is mainly used for video upload. The expected url is rtmp://localhost:port/livepeer/stream

Index

Constants

This section is empty.

Variables

View Source
var RetryCount = 3
View Source
var SegmenterRetryWait = 500 * time.Millisecond

Functions

This section is empty.

Types

type LPMS

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

LPMS struct is the container of all the LPMS server related tools.

func New

func New(opts *LPMSOpts) *LPMS

New creates a new LPMS server object. It really just brokers everything to the components.

func (*LPMS) HandleHLSPlay

func (l *LPMS) HandleHLSPlay(
	getMasterPlaylist func(url *url.URL) (*m3u8.MasterPlaylist, error),
	getMediaPlaylist func(url *url.URL) (*m3u8.MediaPlaylist, error),
	getSegment func(url *url.URL) ([]byte, error))

HandleHLSPlay offload to the video player

func (*LPMS) HandleRTMPPlay

func (l *LPMS) HandleRTMPPlay(getStream func(url *url.URL) (stream.RTMPVideoStream, error)) error

HandleRTMPPlay offload to the video player

func (*LPMS) HandleRTMPPublish

func (l *LPMS) HandleRTMPPublish(
	makeStreamID func(url *url.URL) (strmID stream.AppData),
	gotStream func(url *url.URL, rtmpStrm stream.RTMPVideoStream) (err error),
	endStream func(url *url.URL, rtmpStrm stream.RTMPVideoStream) error)

HandleRTMPPublish offload to the video listener. To understand how it works, look at videoListener.HandleRTMPPublish.

func (*LPMS) SegmentRTMPToHLS

func (l *LPMS) SegmentRTMPToHLS(ctx context.Context, rs stream.RTMPVideoStream, hs stream.HLSVideoStream, segOptions segmenter.SegmenterOptions) error

SegmentRTMPToHLS takes a rtmp stream and re-packages it into a HLS stream with the specified segmenter options

func (*LPMS) Start

func (l *LPMS) Start(ctx context.Context) error

Start starts the rtmp and http servers, and initializes ffmpeg

type LPMSOpts

type LPMSOpts struct {
	RtmpAddr     string
	RtmpDisabled bool
	HttpAddr     string
	HttpDisabled bool
	VodPath      string
	WorkDir      string

	// Pass in a custom HTTP mux.
	// Useful if a non-default mux needs to be used.
	// The caller is responsible for setting up the listener
	// on the mux; LPMS won't initialize it.
	// If set, HttpPort and HttpDisabled are ignored.
	HttpMux *http.ServeMux
}

type RTMPSegmenter

type RTMPSegmenter interface {
	SegmentRTMPToHLS(ctx context.Context, rs stream.RTMPVideoStream, hs stream.HLSVideoStream, segOptions segmenter.SegmenterOptions) error
}

RTMPSegmenter describes an interface for a segmenter

Jump to

Keyboard shortcuts

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