Documentation
¶
Overview ¶
Core contains the main functionality of the Livepeer node.
Index ¶
- Constants
- Variables
- func RandomVideoID() []byte
- func SignedSegmentToBytes(ss SignedSegment) ([]byte, error)
- type BasicClaimManager
- func (c *BasicClaimManager) AddReceipt(seqNo int64, data []byte, tDataHash []byte, bSig []byte, ...) error
- func (c *BasicClaimManager) Claim() (claimCount int, rc chan types.Receipt, ec chan error)
- func (c *BasicClaimManager) DistributeFees() error
- func (c *BasicClaimManager) SufficientBroadcasterDeposit() (bool, error)
- func (c *BasicClaimManager) Verify() error
- type ClaimManager
- type LivepeerNode
- func (n *LivepeerNode) BroadcastFinishMsg(strmID string) error
- func (n *LivepeerNode) BroadcastManifestToNetwork(manifest stream.HLSVideoManifest) error
- func (n *LivepeerNode) BroadcastStreamToNetwork(strm stream.HLSVideoStream) error
- func (n *LivepeerNode) ClaimVerifyAndDistributeFees(cm ClaimManager) error
- func (n *LivepeerNode) CreateTranscodeJob(strmID StreamID, profiles []lpmscore.VideoProfile, price uint64) error
- func (n *LivepeerNode) GetMasterPlaylistFromNetwork(mid ManifestID) *m3u8.MasterPlaylist
- func (n *LivepeerNode) NotifyBroadcaster(nid NodeID, strmID StreamID, ...) error
- func (n *LivepeerNode) Start(ctx context.Context, bootID, bootAddr string) error
- func (n *LivepeerNode) SubscribeFromNetwork(ctx context.Context, strmID StreamID, strm stream.HLSVideoStream) error
- func (n *LivepeerNode) TranscodeAndBroadcast(config net.TranscodeConfig, cm ClaimManager, t transcoder.Transcoder) ([]StreamID, error)
- func (n *LivepeerNode) UnsubscribeFromNetwork(strmID StreamID) error
- type ManifestID
- type NodeID
- type PeerConn
- type RewardManager
- type SignedSegment
- type SortUint64
- type StreamID
- type VideoDB
- func (s *VideoDB) AddJid(strmID StreamID, jid *big.Int)
- func (s *VideoDB) AddNewHLSManifest(manifestID ManifestID) (stream.HLSVideoManifest, error)
- func (s *VideoDB) AddNewHLSStream(strmID StreamID) (strm stream.HLSVideoStream, err error)
- func (s *VideoDB) AddNewRTMPStream(strmID StreamID) (strm stream.RTMPVideoStream, err error)
- func (s *VideoDB) AddStream(strmID StreamID, strm stream.VideoStream) (err error)
- func (s *VideoDB) DeleteHLSManifest(mid ManifestID)
- func (s *VideoDB) DeleteStream(strmID StreamID)
- func (s *VideoDB) GetHLSManifest(mid ManifestID) stream.HLSVideoManifest
- func (s *VideoDB) GetHLSManifestFromStreamID(strmID StreamID) (stream.HLSVideoManifest, error)
- func (s *VideoDB) GetHLSStream(id StreamID) stream.HLSVideoStream
- func (s *VideoDB) GetJidByStreamID(strmID StreamID) *big.Int
- func (s *VideoDB) GetRTMPStream(id StreamID) stream.RTMPVideoStream
- func (s *VideoDB) GetStreamIDs(format stream.VideoFormat) []StreamID
- func (s VideoDB) String() string
Constants ¶
const ( HashLength = 32 NodeIDLength = 68 )
const HLSStreamWinSize = uint(3)
const HLSWaitTime = time.Second * 10
Variables ¶
var BroadcastTimeout = time.Second * 30
var ConnFileWriteFreq = time.Duration(60) * time.Second
var DefaultJobLength = int64(5760) //Avg 1 day in 15 sec blocks
var DefaultMasterPlaylistWaitTime = 60 * time.Second
var ErrBroadcast = errors.New("ErrBroadcast")
var ErrBroadcastJob = errors.New("ErrBroadcastJob")
var ErrBroadcastTimeout = errors.New("ErrBroadcastTimeout")
var ErrClaim = errors.New("ErrClaim")
var ErrClaimManager = errors.New("ErrClaimManager")
var ErrEOF = errors.New("ErrEOF")
var ErrLivepeerNode = errors.New("ErrLivepeerNode")
var ErrManifestID = errors.New("ErrManifestID")
var ErrNotFound = errors.New("NotFound")
var ErrStreamID = errors.New("ErrStreamID")
var ErrTranscode = errors.New("ErrTranscode")
var ErrVideoDB = errors.New("ErrVideoDB")
var EthEventTimeout = 5 * time.Second
var EthMinedTxTimeout = 60 * time.Second
var EthRpcTimeout = 5 * time.Second
var PlusOneBlockRetry = 5
var PlusOneBlockSleepInterval = time.Second * 3 //Max of 96 sec wait time
Functions ¶
func RandomVideoID ¶
func RandomVideoID() []byte
func SignedSegmentToBytes ¶
func SignedSegmentToBytes(ss SignedSegment) ([]byte, error)
Convenience function to convert between SignedSegments and byte slices to put on the wire.
Types ¶
type BasicClaimManager ¶
type BasicClaimManager struct {
// contains filtered or unexported fields
}
BasicClaimManager manages the claim process for a Livepeer transcoder. Check the Livepeer protocol for more details.
func NewBasicClaimManager ¶
func NewBasicClaimManager(sid string, jid *big.Int, broadcaster common.Address, pricePerSegment *big.Int, p []lpmscore.VideoProfile, c eth.LivepeerEthClient, ipfs ipfs.IpfsApi) *BasicClaimManager
NewBasicClaimManager creates a new claim manager.
func (*BasicClaimManager) AddReceipt ¶
func (c *BasicClaimManager) AddReceipt(seqNo int64, data []byte, tDataHash []byte, bSig []byte, profile lpmscore.VideoProfile) error
AddReceipt adds a claim for a given video segment.
func (*BasicClaimManager) Claim ¶
func (c *BasicClaimManager) Claim() (claimCount int, rc chan types.Receipt, ec chan error)
Claim creates the onchain claim for all the claims added through AddReceipt
func (*BasicClaimManager) DistributeFees ¶
func (c *BasicClaimManager) DistributeFees() error
func (*BasicClaimManager) SufficientBroadcasterDeposit ¶
func (c *BasicClaimManager) SufficientBroadcasterDeposit() (bool, error)
func (*BasicClaimManager) Verify ¶
func (c *BasicClaimManager) Verify() error
type ClaimManager ¶
type LivepeerNode ¶
type LivepeerNode struct {
Identity NodeID
Addrs []string
VideoNetwork net.VideoNetwork
VideoDB *VideoDB
Eth eth.LivepeerEthClient
EthAccount string
EthPassword string
Ipfs ipfs.IpfsApi
WorkDir string
PeerConns []PeerConn
}
LivepeerNode handles videos going in and coming out of the Livepeer network.
func NewLivepeerNode ¶
func NewLivepeerNode(e eth.LivepeerEthClient, vn net.VideoNetwork, nodeId NodeID, addrs []string, wd string) (*LivepeerNode, error)
NewLivepeerNode creates a new Livepeer Node. Eth can be nil.
func (*LivepeerNode) BroadcastFinishMsg ¶
func (n *LivepeerNode) BroadcastFinishMsg(strmID string) error
func (*LivepeerNode) BroadcastManifestToNetwork ¶
func (n *LivepeerNode) BroadcastManifestToNetwork(manifest stream.HLSVideoManifest) error
func (*LivepeerNode) BroadcastStreamToNetwork ¶
func (n *LivepeerNode) BroadcastStreamToNetwork(strm stream.HLSVideoStream) error
BroadcastToNetwork is called when a new broadcast stream is available. It lets the network decide how to deal with the stream.
func (*LivepeerNode) ClaimVerifyAndDistributeFees ¶
func (n *LivepeerNode) ClaimVerifyAndDistributeFees(cm ClaimManager) error
func (*LivepeerNode) CreateTranscodeJob ¶
func (n *LivepeerNode) CreateTranscodeJob(strmID StreamID, profiles []lpmscore.VideoProfile, price uint64) error
CreateTranscodeJob creates the on-chain transcode job.
func (*LivepeerNode) GetMasterPlaylistFromNetwork ¶
func (n *LivepeerNode) GetMasterPlaylistFromNetwork(mid ManifestID) *m3u8.MasterPlaylist
GetMasterPlaylistFromNetwork blocks until it gets the playlist, or it times out.
func (*LivepeerNode) NotifyBroadcaster ¶
func (n *LivepeerNode) NotifyBroadcaster(nid NodeID, strmID StreamID, transcodeStrmIDs map[StreamID]lpmscore.VideoProfile) error
NotifyBroadcaster sends a messages to the broadcaster of the video stream, containing the new streamIDs of the transcoded video streams.
func (*LivepeerNode) Start ¶
func (n *LivepeerNode) Start(ctx context.Context, bootID, bootAddr string) error
Start sets up the Livepeer protocol and connects the node to the network
func (*LivepeerNode) SubscribeFromNetwork ¶
func (n *LivepeerNode) SubscribeFromNetwork(ctx context.Context, strmID StreamID, strm stream.HLSVideoStream) error
SubscribeFromNetwork subscribes to a stream on the network. Returns the stream as a reference.
func (*LivepeerNode) TranscodeAndBroadcast ¶
func (n *LivepeerNode) TranscodeAndBroadcast(config net.TranscodeConfig, cm ClaimManager, t transcoder.Transcoder) ([]StreamID, error)
TranscodeAndBroadcast transcodes one stream into multiple streams (specified by TranscodeConfig), broadcasts the streams, and returns a list of streamIDs.
func (*LivepeerNode) UnsubscribeFromNetwork ¶
func (n *LivepeerNode) UnsubscribeFromNetwork(strmID StreamID) error
UnsubscribeFromNetwork unsubscribes to a stream on the network.
type ManifestID ¶
type ManifestID string
ManifestID is NodeID|VideoID
func MakeManifestID ¶
func MakeManifestID(nodeID NodeID, id []byte) (ManifestID, error)
func (*ManifestID) GetNodeID ¶
func (id *ManifestID) GetNodeID() NodeID
func (*ManifestID) GetVideoID ¶
func (id *ManifestID) GetVideoID() []byte
func (*ManifestID) IsValid ¶
func (id *ManifestID) IsValid() bool
func (ManifestID) String ¶
func (id ManifestID) String() string
type RewardManager ¶
type RewardManager struct {
// contains filtered or unexported fields
}
RewardManager manages the transcoder's reward-calling cycle.
func NewRewardManager ¶
func NewRewardManager(checkFreq time.Duration, client eth.LivepeerEthClient) *RewardManager
NewRewardManager creates a new reward manager with a given checkFrequency.
func (*RewardManager) Start ¶
func (r *RewardManager) Start(ctx context.Context)
Start repeatedly calls reward.
type SignedSegment ¶
type SignedSegment struct {
Seg stream.HLSSegment
Sig []byte
}
Segment and its signature by the broadcaster
func BytesToSignedSegment ¶
func BytesToSignedSegment(data []byte) (SignedSegment, error)
Convenience function to convert between SignedSegments and byte slices to put on the wire.
type SortUint64 ¶
type SortUint64 []int64
func (SortUint64) Len ¶
func (a SortUint64) Len() int
func (SortUint64) Less ¶
func (a SortUint64) Less(i, j int) bool
func (SortUint64) Swap ¶
func (a SortUint64) Swap(i, j int)
type StreamID ¶
type StreamID string
StreamID is NodeID|VideoID|Rendition
func (*StreamID) GetRendition ¶
func (*StreamID) GetVideoID ¶
type VideoDB ¶
type VideoDB struct {
SelfNodeID string
// contains filtered or unexported fields
}
VideoDB stores the video streams, the video buffers, and related information in memory. Note that HLS streams may have many streamIDs, each representing a ABS rendition, so there may be multiple streamIDs that map to the same HLS stream in the streams map.
func NewVideoDB ¶
NewVideo Create a new VideoDB with the node's network address
func (*VideoDB) AddNewHLSManifest ¶
func (s *VideoDB) AddNewHLSManifest(manifestID ManifestID) (stream.HLSVideoManifest, error)
func (*VideoDB) AddNewHLSStream ¶
func (s *VideoDB) AddNewHLSStream(strmID StreamID) (strm stream.HLSVideoStream, err error)
AddNewHLSStream creates a new HLS video stream in the VideoDB
func (*VideoDB) AddNewRTMPStream ¶
func (s *VideoDB) AddNewRTMPStream(strmID StreamID) (strm stream.RTMPVideoStream, err error)
AddNewRTMPStream creates a new RTMP video stream in the VideoDB
func (*VideoDB) AddStream ¶
func (s *VideoDB) AddStream(strmID StreamID, strm stream.VideoStream) (err error)
AddStream adds an existing video stream.
func (*VideoDB) DeleteHLSManifest ¶
func (s *VideoDB) DeleteHLSManifest(mid ManifestID)
func (*VideoDB) DeleteStream ¶
func (*VideoDB) GetHLSManifest ¶
func (s *VideoDB) GetHLSManifest(mid ManifestID) stream.HLSVideoManifest
func (*VideoDB) GetHLSManifestFromStreamID ¶
func (s *VideoDB) GetHLSManifestFromStreamID(strmID StreamID) (stream.HLSVideoManifest, error)
func (*VideoDB) GetHLSStream ¶
func (s *VideoDB) GetHLSStream(id StreamID) stream.HLSVideoStream
GetHLSStream gets a HLS video stream stored in the VideoDB
func (*VideoDB) GetRTMPStream ¶
func (s *VideoDB) GetRTMPStream(id StreamID) stream.RTMPVideoStream
GetRTMPStream gets a RTMP video stream stored in the VideoDB
func (*VideoDB) GetStreamIDs ¶
func (s *VideoDB) GetStreamIDs(format stream.VideoFormat) []StreamID