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) HandleRecordings(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, httpAddr string) error
- type MinLSSelector
- type Orchestrator
- type ReceivedTranscodeResult
- type Redeemer
- func (r *Redeemer) MaxFloat(ctx context.Context, req *net.MaxFloatReq) (*net.MaxFloatUpdate, error)
- func (r *Redeemer) MonitorMaxFloat(req *net.MaxFloatReq, stream net.TicketRedeemer_MonitorMaxFloatServer) error
- func (r *Redeemer) QueueTicket(ctx context.Context, ticket *net.Ticket) (*net.QueueTicketRes, error)
- func (r *Redeemer) Start(url *url.URL, workDir string) error
- func (r *Redeemer) Stop()
- type RedeemerClient
- type Router
- func (r *Router) GetOrchestrator(ctx context.Context, req *net.OrchestratorRequest) (*net.OrchestratorInfo, error)
- func (r *Router) Ping(ctx context.Context, req *net.PingPong) (*net.PingPong, error)
- func (r *Router) Start(uri *url.URL, serviceURI *url.URL, workDir string) error
- func (r *Router) Stop()
- type SegFlightMetadata
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 *url.URL
var BroadcastCfg = &BroadcastConfig{}
var BroadcastJobVideoProfiles = []ffmpeg.VideoProfile{ffmpeg.P240p30fps4x3, ffmpeg.P360p30fps16x9}
var DetectionWebhookURL *url.URL
var DetectionWhClient = &http.Client{Timeout: 2 * time.Second}
var MaxAttempts = 3
var MetadataPublishTimeout = 1 * time.Second
var MetadataQueue event.Producer
var NonRetryableErrMap = nonRetryableErrMapInit()
var Policy *verification.Policy
var StreamPrefix = regexp.MustCompile(`^[ /]*(stream/)?|(live/)?`) // test carefully!
StreamPrefix 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 Params *core.StreamParameters OrchestratorInfo *net.OrchestratorInfo OrchestratorOS drivers.OSSession BroadcasterOS drivers.OSSession Sender pm.Sender PMSessionID string Balances *core.AddressBalances Balance Balance LatencyScore float64 SegsInFlight []SegFlightMetadata }
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 *core.StreamParameters, 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, httpIngest bool, transcodingOptions string) (*LivepeerServer, error)
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)
HandlePush processes request for HTTP ingest
func (*LivepeerServer) HandleRecordings ¶ added in v0.5.13
func (s *LivepeerServer) HandleRecordings(w http.ResponseWriter, r *http.Request)
HandleRecordings handle requests to /recordings/ endpoint
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, 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, priceInfo *net.PriceInfo) (*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) Capabilities() *net.Capabilities AuthToken(sessionID string, expiration int64) *net.AuthToken }
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)
type Redeemer ¶ added in v0.5.9
type Redeemer struct {
// contains filtered or unexported fields
}
func NewRedeemer ¶ added in v0.5.9
func NewRedeemer(recipient ethcommon.Address, eth eth.LivepeerEthClient, sm *pm.LocalSenderMonitor) (*Redeemer, error)
NewRedeemer creates a new ticket redemption service instance
func (*Redeemer) MaxFloat ¶ added in v0.5.9
func (r *Redeemer) MaxFloat(ctx context.Context, req *net.MaxFloatReq) (*net.MaxFloatUpdate, error)
MaxFloat is a unary RPC method to request the max float value for a sender
func (*Redeemer) MonitorMaxFloat ¶ added in v0.5.9
func (r *Redeemer) MonitorMaxFloat(req *net.MaxFloatReq, stream net.TicketRedeemer_MonitorMaxFloatServer) error
MonitorMaxFloat starts a server-side stream to the client to send max float updates for sender specified in the request
func (*Redeemer) QueueTicket ¶ added in v0.5.9
func (r *Redeemer) QueueTicket(ctx context.Context, ticket *net.Ticket) (*net.QueueTicketRes, error)
QueueTicket adds a ticket to the ticket queue
type RedeemerClient ¶ added in v0.5.9
type RedeemerClient struct {
// contains filtered or unexported fields
}
func NewRedeemerClient ¶ added in v0.5.9
func NewRedeemerClient(uri string, sm pm.SenderManager, tm pm.TimeManager) (*RedeemerClient, error)
NewRedeemerClient instantiates a new client for the ticket redemption service The client implements the pm.SenderMonitor interface
func (*RedeemerClient) MaxFloat ¶ added in v0.5.9
MaxFloat returns the max float for 'sender' If no local cache is available this method will remotely request max float from the Redeemer server and start watching for subsequent updates from the Redeemer server
func (*RedeemerClient) QueueTicket ¶ added in v0.5.9
func (r *RedeemerClient) QueueTicket(ticket *pm.SignedTicket) error
QueueTicket sends a winning ticket to the Redeemer
func (*RedeemerClient) Start ¶ added in v0.5.9
func (r *RedeemerClient) Start()
func (*RedeemerClient) Stop ¶ added in v0.5.9
func (r *RedeemerClient) Stop()
Stop stops the Redeemer client
func (*RedeemerClient) ValidateSender ¶ added in v0.5.9
func (r *RedeemerClient) ValidateSender(sender ethcommon.Address) error
ValidateSender checks whether a sender has not recently unlocked its deposit and reserve
type Router ¶ added in v0.5.15
type Router struct {
// contains filtered or unexported fields
}
func (*Router) GetOrchestrator ¶ added in v0.5.15
func (r *Router) GetOrchestrator(ctx context.Context, req *net.OrchestratorRequest) (*net.OrchestratorInfo, error)
type SegFlightMetadata ¶ added in v0.5.14
type SegFlightMetadata struct {
// contains filtered or unexported fields
}