video

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTranscodingUnderway = errors.New("transcoding in progress")
	ErrChannelNotEnabled   = errors.New("transcoding was not enabled for this channel")
	ErrNoSigningChannel    = errors.New("no signing channel for stream")
)
View Source
var InitialMigration = `` /* 561-byte string literal not displayed */

Functions

func FurloughVideos added in v0.5.0

func FurloughVideos(lib *Library, maxSize uint64) (uint64, uint64, error)

FurloughVideos deletes older videos locally, leaving them only on S3, keeping total size of local videos at maxSize.

func LoadEnabledChannels

func LoadEnabledChannels(channels []string)

func NewSweeper added in v0.5.0

func NewSweeper() *sweeper

func RetireVideos added in v0.5.0

func RetireVideos(lib *Library, maxSize uint64) (uint64, uint64, error)

RetireVideos deletes older videos from S3, keeping total size of remote videos at maxSize.

func SetLogger

func SetLogger(l *zap.SugaredLogger)

func SpawnLibraryCleaning added in v0.5.0

func SpawnLibraryCleaning(lib *Library) chan<- bool

func SpawnPopularSweeper added in v0.5.0

func SpawnPopularSweeper(lib *Library, q *queue.Queue, opts PopularSweeperOpts) chan<- bool

SpawnPopularSweeper will tally up the count of rejected videos and pick top N of them to be added to the queue. For it to work, `lib.IncViews(url, sdHash)` should be called somewhere for every video that is requested but rejected.

func SpawnProcessing

func SpawnProcessing(q *queue.Queue, lib *Library, p *queue.Poller)

func SpawnS3Uploader added in v0.5.0

func SpawnS3Uploader(lib *Library) dispatcher.Dispatcher

func StringToSize added in v0.5.0

func StringToSize(s string) uint64

func ValidateByClaim

func ValidateByClaim(c *claim.Claim) error

func ValidateIncomingVideo

func ValidateIncomingVideo(uri string) (*claim.Claim, error)

ValidateIncomingVideo checks if supplied video can be accepted for processing.

Types

type AddParams

type AddParams struct {
	URL      string
	SDHash   string
	Type     string
	Path     string
	Channel  string
	Size     int64
	Checksum string
}

type Config added in v0.5.0

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

func Configure added in v0.5.0

func Configure() *Config

func (*Config) DB added in v0.5.0

func (c *Config) DB(db *db.DB) *Config

DB ...

func (*Config) LocalStorage added in v0.5.0

func (c *Config) LocalStorage(s storage.LocalDriver) *Config

LocalStorage ...

func (*Config) MaxLocalSize added in v0.5.0

func (c *Config) MaxLocalSize(s string) *Config

MaxLocalSize ...

func (*Config) MaxRemoteSize added in v0.5.0

func (c *Config) MaxRemoteSize(s string) *Config

MaxRemoteSize ...

func (*Config) RemoteStorage added in v0.5.0

func (c *Config) RemoteStorage(s storage.RemoteDriver) *Config

RemoteStorage ...

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	BeginTx(context.Context, *sql.TxOptions) (*sql.Tx, error)
}

type Library

type Library struct {
	*Config
	// contains filtered or unexported fields
}

Library contains methods for accessing videos database.

func NewLibrary

func NewLibrary(cfg *Config) *Library

func (Library) Add

func (q Library) Add(params AddParams) (*Video, error)

Add records data about video into database.

func (Library) Furlough added in v0.5.0

func (q Library) Furlough(v *Video) error

func (Library) Get

func (q Library) Get(sdHash string) (*Video, error)

func (Library) IncViews added in v0.5.0

func (q Library) IncViews(uri, sdHash string)

func (Library) ListLocal added in v0.5.0

func (q Library) ListLocal() ([]*Video, error)

func (Library) ListLocalOnly added in v0.5.0

func (q Library) ListLocalOnly() ([]*Video, error)

func (Library) ListRemoteOnly added in v0.5.0

func (q Library) ListRemoteOnly() ([]*Video, error)

func (Library) Retire added in v0.5.0

func (q Library) Retire(v *Video) error

func (Library) UpdateRemotePath added in v0.5.0

func (q Library) UpdateRemotePath(sdHash, url string) error

type PopularSweeperOpts added in v0.5.0

type PopularSweeperOpts struct {
	// TopNumber limits the number of top viewed videos that will be added to queue every time.
	TopNumber int
	// LowerBound sets a lower limit for video views number to be considered.
	LowerBound int
	// Interval is the interval at which sweeping routine will be run.
	Interval time.Duration
}

PopularSweeperOpts sets additional options for SpawnPopularSweeper routine.

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) Add

func (q *Queries) Add(ctx context.Context, arg AddParams) (*Video, error)

func (*Queries) Delete added in v0.5.0

func (q *Queries) Delete(ctx context.Context, sdHash string) error

func (*Queries) Get

func (q *Queries) Get(ctx context.Context, sdHash string) (*Video, error)

func (*Queries) ListLocal added in v0.5.0

func (q *Queries) ListLocal(ctx context.Context) ([]*Video, error)

func (*Queries) ListLocalOnly added in v0.5.0

func (q *Queries) ListLocalOnly(ctx context.Context) ([]*Video, error)

func (*Queries) ListRemoteOnly added in v0.5.0

func (q *Queries) ListRemoteOnly(ctx context.Context) ([]*Video, error)

func (*Queries) UpdatePath added in v0.5.0

func (q *Queries) UpdatePath(ctx context.Context, sdHash, path string) error

func (*Queries) UpdateRemotePath added in v0.5.0

func (q *Queries) UpdateRemotePath(ctx context.Context, sdHash, url string) error

type S3Uploader added in v0.5.0

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

func (S3Uploader) Do added in v0.5.0

func (u S3Uploader) Do(t dispatcher.Task) error

type TallyItem added in v0.5.0

type TallyItem struct {
	URL    string
	SDHash string
	Count  uint64
}

type Video

type Video struct {
	SDHash     string
	CreatedAt  string
	URL        string
	Path       string
	RemotePath string
	Type       string
	Channel    string

	LastAccessed sql.NullTime
	AccessCount  int64

	Size     int64
	Checksum string
}

func (Video) GetLocation added in v0.5.0

func (v Video) GetLocation() (string, bool)

GetLocation returns a video location suitable for using in HTTP redirect response. Bool in return value signifies if it's a remote location (S3) or local (relative HTTP path).

func (Video) GetSize added in v0.5.0

func (v Video) GetSize() int64

func (Video) GetWeight added in v0.5.0

func (v Video) GetWeight() int64

Jump to

Keyboard shortcuts

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