Documentation
¶
Overview ¶
Package server is the place we integrate the Livepeer node with the LPMS media server.
Index ¶
- Constants
- Variables
- func CheckOrchestratorAvailability(orch Orchestrator) bool
- func GetOrchestratorInfo(ctx context.Context, bcast common.Broadcaster, orchestratorServer *url.URL) (*net.OrchestratorInfo, error)
- func RunTranscoder(n *core.LivepeerNode, orchAddr string, capacity int)
- func StartTranscodeServer(orch Orchestrator, bind string, mux *http.ServeMux, workDir string, ...)
- type Balance
- type BalanceUpdate
- type BalanceUpdateStatus
- type BlockGetter
- type BroadcastConfig
- type BroadcastSession
- type BroadcastSessionsManager
- type BroadcastSessionsSelector
- type LIFOSelector
- type LivepeerServer
- func (s *LivepeerServer) GetNodeStatus() *net.NodeStatus
- func (s *LivepeerServer) HandlePush(w http.ResponseWriter, r *http.Request)
- func (s *LivepeerServer) LastHLSStreamID() core.StreamID
- func (s *LivepeerServer) LastManifestID() core.ManifestID
- func (s *LivepeerServer) LatestPlaylist() core.PlaylistManager
- func (s *LivepeerServer) StartCliWebserver(bindAddr string)
- func (s *LivepeerServer) StartMediaServer(ctx context.Context, transcodingOptions string, httpAddr string) error
- type MinLSSelector
- type Orchestrator
- type ReceivedTranscodeResult
Constants ¶
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 )
const BroadcastRetry = 15 * time.Second
const GRPCConnectTimeout = 3 * time.Second
const GRPCTimeout = 8 * time.Second
const HLSBufferCap = uint(43200) //12 hrs assuming 1s segment
const HLSBufferWindow = uint(5)
const HLSWaitInterval = time.Second
const SegLen = 2 * time.Second
const StreamKeyBytes = 6
Variables ¶
var AuthWebhookURL string
var BroadcastCfg = &BroadcastConfig{}
var BroadcastJobVideoProfiles = []ffmpeg.VideoProfile{ffmpeg.P240p30fps4x3, ffmpeg.P360p30fps16x9}
var Policy *verification.Policy
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 common.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
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 common.Broadcaster ManifestID core.ManifestID Profiles []ffmpeg.VideoProfile OrchestratorInfo *net.OrchestratorInfo OrchestratorOS drivers.OSSession BroadcasterOS drivers.OSSession Sender pm.Sender PMSessionID string Balance Balance LatencyScore float64 }
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, sel BroadcastSessionsSelector) *BroadcastSessionsManager
type BroadcastSessionsSelector ¶ added in v0.5.2
type BroadcastSessionsSelector interface { Add(sessions []*BroadcastSession) Complete(sess *BroadcastSession) Select() *BroadcastSession Size() int Clear() }
BroadcastSessionsSelector selects the next BroadcastSession to use
type LIFOSelector ¶ added in v0.5.2
type LIFOSelector []*BroadcastSession
LIFOSelector selects the next BroadcastSession in LIFO order
func (*LIFOSelector) Add ¶ added in v0.5.2
func (s *LIFOSelector) Add(sessions []*BroadcastSession)
Add adds the sessions to the front of the selector's list
func (*LIFOSelector) Clear ¶ added in v0.5.2
func (s *LIFOSelector) Clear()
Clear resets the selector's state
func (*LIFOSelector) Complete ¶ added in v0.5.2
func (s *LIFOSelector) Complete(sess *BroadcastSession)
Complete adds the session to the end of the selector's list
func (*LIFOSelector) Select ¶ added in v0.5.2
func (s *LIFOSelector) Select() *BroadcastSession
Select returns the last session in the selector's list
func (*LIFOSelector) Size ¶ added in v0.5.2
func (s *LIFOSelector) Size() int
Size returns the number of sessions stored by the selector
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 MinLSSelector ¶ added in v0.5.2
type MinLSSelector struct {
// contains filtered or unexported fields
}
MinLSSelector selects the next BroadcastSession with the lowest latency score if it is good enough. Otherwise, it selects a session that does not have a latency score yet MinLSSelector is not concurrency safe so the caller is responsible for ensuring safety for concurrent method calls
func NewMinLSSelector ¶ added in v0.5.2
func NewMinLSSelector(stakeRdr stakeReader, minLS float64) *MinLSSelector
NewMinLSSelector returns an instance of MinLSSelector configured with a good enough latency score
func (*MinLSSelector) Add ¶ added in v0.5.2
func (s *MinLSSelector) Add(sessions []*BroadcastSession)
Add adds the sessions to the selector's list of sessions without a latency score
func (*MinLSSelector) Clear ¶ added in v0.5.2
func (s *MinLSSelector) Clear()
Clear resets the selector's state
func (*MinLSSelector) Complete ¶ added in v0.5.2
func (s *MinLSSelector) Complete(sess *BroadcastSession)
Complete adds the session to the selector's list sessions with a latency score
func (*MinLSSelector) Select ¶ added in v0.5.2
func (s *MinLSSelector) Select() *BroadcastSession
Select returns the session with the lowest latency score if it is good enough. Otherwise, a session without a latency score yet is returned
func (*MinLSSelector) Size ¶ added in v0.5.2
func (s *MinLSSelector) Size() int
Size returns the number of sessions stored by the selector
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) }
type ReceivedTranscodeResult ¶ added in v0.5.2
type ReceivedTranscodeResult struct { *net.TranscodeData Info *net.OrchestratorInfo LatencyScore float64 }
ReceivedTranscodeResult contains received transcode result data and related metadata
func SubmitSegment ¶ added in v0.3.3
func SubmitSegment(sess *BroadcastSession, seg *stream.HLSSegment, nonce uint64) (*ReceivedTranscodeResult, error)