server

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 60 Imported by: 1

Documentation

Overview

Package server is the place we integrate the Livepeer node with the LPMS media server.

Index

Constants

View Source
const (
	// Staged indicates that the update has been created but the credit
	// has not been spent yet
	Staged = iota
	// CreditSpent indicates that the update's credit has been spent
	// but the debit has not been processed yet
	CreditSpent
	// ReceivedChange indicates that the update's credit has been spent
	// and a debit was processed such that there was "change" (net of credit/debit)
	ReceivedChange
)
View Source
const BroadcastRetry = 15 * time.Second
View Source
const GRPCConnectTimeout = 3 * time.Second
View Source
const GRPCTimeout = 8 * time.Second
View Source
const HLSBufferCap = uint(43200) //12 hrs assuming 1s segment
View Source
const HLSBufferWindow = uint(5)
View Source
const HLSWaitInterval = time.Second
View Source
const RefreshIntervalHttpPush = 1 * time.Minute
View Source
const SegLen = 2 * time.Second
View Source
const StreamKeyBytes = 6

Variables

View Source
var AuthWebhookURL string
View Source
var BroadcastCfg = &BroadcastConfig{}
View Source
var StreamPrefix = regexp.MustCompile(`^[ /]*(stream/)?|(live/)?`) // test carefully!

Match all leading spaces, slashes and optionally `stream/`

Functions

func CheckOrchestratorAvailability added in v0.5.0

func CheckOrchestratorAvailability(orch Orchestrator) bool

CheckOrchestratorAvailability - the broadcaster calls CheckOrchestratorAvailability which invokes Ping on the orchestrator

func GetOrchestratorInfo added in v0.5.0

func GetOrchestratorInfo(ctx context.Context, bcast Broadcaster, orchestratorServer *url.URL) (*net.OrchestratorInfo, error)

GetOrchestratorInfo - the broadcaster calls GetOrchestratorInfo which invokes GetOrchestrator on the orchestrator

func RunTranscoder added in v0.5.0

func RunTranscoder(n *core.LivepeerNode, orchAddr string, capacity int)

RunTranscoder is main routing of standalone transcoder Exiting it will terminate executable

func StartTranscodeServer added in v0.3.3

func StartTranscodeServer(orch Orchestrator, bind string, mux *http.ServeMux, workDir string, acceptRemoteTranscoders bool)

XXX do something about the implicit start of the http mux? this smells

func SubmitSegment added in v0.3.3

func SubmitSegment(sess *BroadcastSession, seg *stream.HLSSegment, nonce uint64) (*net.TranscodeData, error)

Types

type Balance added in v0.5.0

type Balance interface {
	Credit(amount *big.Rat)
	StageUpdate(minCredit *big.Rat, ev *big.Rat) (int, *big.Rat, *big.Rat)
}

Balance describes methods for a session's balance maintenance

type BalanceUpdate added in v0.5.0

type BalanceUpdate struct {
	// ExistingCredit is the existing credit reserved for the update
	ExistingCredit *big.Rat

	// NewCredit is the new credit for the update provided by a payment
	NewCredit *big.Rat

	// NumTickets is the number of tickets in the payment for the update
	NumTickets int

	// Debit is the amount to debit for the update
	Debit *big.Rat

	// Status is the current status of the update
	Status BalanceUpdateStatus
}

BalanceUpdate describes an update to be performed on the balance of a session

type BalanceUpdateStatus added in v0.5.0

type BalanceUpdateStatus int

BalanceUpdateStatus indicates the current status of a balance update

type BlockGetter added in v0.5.0

type BlockGetter interface {
	// LastSeenBlock returns the last seen block number
	LastSeenBlock() (*big.Int, error)
}

BlockGetter is an interface which describes an object capable of getting blocks

type BroadcastConfig added in v0.5.0

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

func (*BroadcastConfig) MaxPrice added in v0.5.0

func (cfg *BroadcastConfig) MaxPrice() *big.Rat

func (*BroadcastConfig) SetMaxPrice added in v0.5.0

func (cfg *BroadcastConfig) SetMaxPrice(price *big.Rat)

type BroadcastSession added in v0.5.0

type BroadcastSession struct {
	Broadcaster      Broadcaster
	ManifestID       core.ManifestID
	Profiles         []ffmpeg.VideoProfile
	OrchestratorInfo *net.OrchestratorInfo
	OrchestratorOS   drivers.OSSession
	BroadcasterOS    drivers.OSSession
	Sender           pm.Sender
	PMSessionID      string
	Balance          Balance
}

BroadcastSession - session-specific state for broadcasters

type BroadcastSessionsManager added in v0.5.0

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

func NewSessionManager added in v0.5.0

func NewSessionManager(node *core.LivepeerNode, params *streamParameters, pl core.PlaylistManager) *BroadcastSessionsManager

type Broadcaster added in v0.3.3

type Broadcaster interface {
	Address() ethcommon.Address
	Sign([]byte) ([]byte, error)
}

type LivepeerServer

type LivepeerServer struct {
	RTMPSegmenter         lpmscore.RTMPSegmenter
	LPMS                  *lpmscore.LPMS
	LivepeerNode          *core.LivepeerNode
	HTTPMux               *http.ServeMux
	ExposeCurrentManifest bool
	// contains filtered or unexported fields
}

func NewLivepeerServer

func NewLivepeerServer(rtmpAddr string, lpNode *core.LivepeerNode) *LivepeerServer

func (*LivepeerServer) GetNodeStatus added in v0.5.0

func (s *LivepeerServer) GetNodeStatus() *net.NodeStatus

func (*LivepeerServer) HandlePush added in v0.5.0

func (s *LivepeerServer) HandlePush(w http.ResponseWriter, r *http.Request)

func (*LivepeerServer) LastHLSStreamID added in v0.5.0

func (s *LivepeerServer) LastHLSStreamID() core.StreamID

func (*LivepeerServer) LastManifestID added in v0.5.0

func (s *LivepeerServer) LastManifestID() core.ManifestID

func (*LivepeerServer) LatestPlaylist added in v0.5.0

func (s *LivepeerServer) LatestPlaylist() core.PlaylistManager

Debug helpers

func (*LivepeerServer) StartCliWebserver added in v0.5.0

func (s *LivepeerServer) StartCliWebserver(bindAddr string)

StartCliWebserver starts web server for CLI blocks until exit

func (*LivepeerServer) StartMediaServer

func (s *LivepeerServer) StartMediaServer(ctx context.Context, transcodingOptions string, httpAddr string) error

StartMediaServer starts the LPMS server

type Orchestrator added in v0.3.3

type Orchestrator interface {
	ServiceURI() *url.URL
	Address() ethcommon.Address
	TranscoderSecret() string
	Sign([]byte) ([]byte, error)
	VerifySig(ethcommon.Address, string, []byte) bool
	CurrentBlock() *big.Int
	CheckCapacity(core.ManifestID) error
	TranscodeSeg(*core.SegTranscodingMetadata, *stream.HLSSegment) (*core.TranscodeResult, error)
	ServeTranscoder(stream net.Transcoder_RegisterTranscoderServer, capacity int)
	TranscoderResults(job int64, res *core.RemoteTranscoderResult)
	ProcessPayment(payment net.Payment, manifestID core.ManifestID) error
	TicketParams(sender ethcommon.Address) (*net.TicketParams, error)
	PriceInfo(sender ethcommon.Address) (*net.PriceInfo, error)
	SufficientBalance(addr ethcommon.Address, manifestID core.ManifestID) bool
	DebitFees(addr ethcommon.Address, manifestID core.ManifestID, price *net.PriceInfo, pixels int64)
}

Jump to

Keyboard shortcuts

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