core

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2019 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Core contains the main functionality of the Livepeer node.

The logical orgnization of the `core` module is as follows:

livepeernode.go: Main struct definition and code that is common to all node types. broadcaster.go: Code that is called only when the node is in broadcaster mode. orchestrator.go: Code that is called only when the node is in orchestrator mode.

Index

Constants

View Source
const (
	HashLength = 32
)
View Source
const TranscodeLoopTimeout = 10 * time.Minute

Variables

View Source
var DefaultJobLength = int64(5760) //Avg 1 day in 15 sec blocks
View Source
var ErrLivepeerNode = errors.New("ErrLivepeerNode")
View Source
var ErrManifestID = errors.New("ErrManifestID")
View Source
var ErrNotFound = errors.New("ErrNotFound")
View Source
var ErrStreamID = errors.New("ErrStreamID")
View Source
var ErrTranscode = errors.New("ErrTranscode")
View Source
var GetMasterPlaylistWaitTime = time.Second * 5
View Source
var GetMediaPlaylistWaitTime = time.Second * 10
View Source
var LivepeerVersion = "0.3.3-unstable"
View Source
var SegCacheLen = 10

Functions

func NewBroadcaster added in v0.3.3

func NewBroadcaster(node *LivepeerNode, job *ethTypes.Job) *broadcaster

func NewOrchestrator added in v0.3.3

func NewOrchestrator(n *LivepeerNode) *orchestrator

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 BasicVideoSource added in v0.3.3

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

func (*BasicVideoSource) DeleteCache added in v0.3.3

func (c *BasicVideoSource) DeleteCache(strmID StreamID)

func (*BasicVideoSource) EvictHLSMasterPlaylist added in v0.3.3

func (c *BasicVideoSource) EvictHLSMasterPlaylist(manifestID ManifestID)

func (*BasicVideoSource) EvictHLSStream added in v0.3.3

func (c *BasicVideoSource) EvictHLSStream(streamID StreamID) error

func (*BasicVideoSource) GetCache added in v0.3.3

func (c *BasicVideoSource) GetCache(strmID StreamID) (*segCache, bool)

func (*BasicVideoSource) GetHLSMasterPlaylist added in v0.3.3

func (c *BasicVideoSource) GetHLSMasterPlaylist(manifestID ManifestID) *m3u8.MasterPlaylist

func (*BasicVideoSource) GetHLSMediaPlaylist added in v0.3.3

func (c *BasicVideoSource) GetHLSMediaPlaylist(streamID StreamID) *m3u8.MediaPlaylist

func (*BasicVideoSource) GetHLSSegment added in v0.3.3

func (c *BasicVideoSource) GetHLSSegment(streamID StreamID, segName string) *stream.HLSSegment

func (*BasicVideoSource) GetNodeStatus added in v0.3.3

func (c *BasicVideoSource) GetNodeStatus() *net.NodeStatus

func (*BasicVideoSource) InsertHLSSegment added in v0.3.3

func (c *BasicVideoSource) InsertHLSSegment(streamID StreamID, seg *stream.HLSSegment)

func (*BasicVideoSource) UpdateHLSMasterPlaylist added in v0.3.3

func (c *BasicVideoSource) UpdateHLSMasterPlaylist(manifestID ManifestID, mpl *m3u8.MasterPlaylist)

type LivepeerNode

type LivepeerNode struct {

	// Common fields
	VideoSource     VideoSource
	Eth             eth.LivepeerEthClient
	EthEventMonitor eth.EventMonitor
	EthServices     map[string]eth.EventService
	WorkDir         string
	NodeType        NodeType
	Database        *common.DB

	// Transcoder public fields
	ClaimManagers map[int64]eth.ClaimManager
	SegmentChans  map[int64]SegmentChan
	Ipfs          ipfs.IpfsApi
	ServiceURI    *url.URL
	// contains filtered or unexported fields
}

LivepeerNode handles videos going in and coming out of the Livepeer network.

func NewLivepeerNode

func NewLivepeerNode(e eth.LivepeerEthClient, wd string, dbh *common.DB) (*LivepeerNode, error)

NewLivepeerNode creates a new Livepeer Node. Eth can be nil.

func (*LivepeerNode) CreateTranscodeJob

func (n *LivepeerNode) CreateTranscodeJob(strmID StreamID, profiles []ffmpeg.VideoProfile, price *big.Int) (*ethTypes.Job, error)

CreateTranscodeJob creates the on-chain transcode job.

func (*LivepeerNode) GetClaimManager added in v0.3.3

func (n *LivepeerNode) GetClaimManager(job *ethTypes.Job) (eth.ClaimManager, error)

func (*LivepeerNode) StartEthServices added in v0.3.3

func (n *LivepeerNode) StartEthServices() error

func (*LivepeerNode) StopEthServices added in v0.3.3

func (n *LivepeerNode) StopEthServices() error

func (*LivepeerNode) TranscodeSegment added in v0.3.3

func (n *LivepeerNode) TranscodeSegment(job *ethTypes.Job, ss *SignedSegment) (*TranscodeResult, error)

type ManifestID

type ManifestID string

ManifestID is VideoID

func MakeManifestID

func MakeManifestID(id []byte) (ManifestID, error)

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 NodeType added in v0.3.3

type NodeType int
const (
	Broadcaster NodeType = iota
	Transcoder
)

type SegChanData added in v0.3.3

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

type SegmentChan added in v0.3.3

type SegmentChan chan *SegChanData

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 StreamID

type StreamID string

StreamID is VideoID|Rendition

func MakeStreamID

func MakeStreamID(id []byte, rendition string) (StreamID, error)

func (*StreamID) GetRendition

func (id *StreamID) GetRendition() string

func (*StreamID) GetVideoID

func (id *StreamID) GetVideoID() []byte

func (*StreamID) IsValid

func (id *StreamID) IsValid() bool

func (StreamID) ManifestIDFromStreamID added in v0.3.3

func (id StreamID) ManifestIDFromStreamID() (ManifestID, error)

func (StreamID) String

func (id StreamID) String() string

type TranscodeResult added in v0.3.3

type TranscodeResult struct {
	Err  error
	Urls []string
	Sig  []byte
}

XXX maybe reuse protobuf response struct somehow

type VideoSource added in v0.3.3

type VideoSource interface {
	GetHLSMasterPlaylist(manifestID ManifestID) *m3u8.MasterPlaylist
	UpdateHLSMasterPlaylist(manifestID ManifestID, mpl *m3u8.MasterPlaylist)
	EvictHLSMasterPlaylist(manifestID ManifestID)
	GetHLSMediaPlaylist(streamID StreamID) *m3u8.MediaPlaylist
	InsertHLSSegment(streamID StreamID, seg *stream.HLSSegment)
	GetHLSSegment(streamID StreamID, segName string) *stream.HLSSegment
	EvictHLSStream(streamID StreamID) error

	GetNodeStatus() *net.NodeStatus
}

func NewBasicVideoSource added in v0.3.3

func NewBasicVideoSource() VideoSource

Jump to

Keyboard shortcuts

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