hStream

package
v0.0.0-...-67ac977 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeVideoEncode = "video:encode"
)

A list of task types.

Variables

View Source
var (
	// ADDR    = "localhost"
	PORT = "5480"
)

Functions

func DeleteVideo

func DeleteVideo(w http.ResponseWriter, r *http.Request)

func FullUpdateVideo

func FullUpdateVideo(w http.ResponseWriter, r *http.Request)

func GetEnv

func GetEnv(key string) string

Get value from `.env` file.

func GetVideo

func GetVideo(w http.ResponseWriter, r *http.Request)

func GetVideos

func GetVideos(w http.ResponseWriter, r *http.Request)

func HandleVideoEncodeTask

func HandleVideoEncodeTask(ctx context.Context, t *asynq.Task) error

func HealthCheck

func HealthCheck(w http.ResponseWriter, r *http.Request)

func NewVideoEncodeTask

func NewVideoEncodeTask(uuid string, resX int, resY int) (*asynq.Task, error)

func PartialUpdateVideo

func PartialUpdateVideo(w http.ResponseWriter, r *http.Request)

func PostVideo

func PostVideo(w http.ResponseWriter, r *http.Request)

func SetStreamURL

func SetStreamURL(v *Video, r *http.Request) error

Set Video.StreamURL manually to generate URL.

func StartServer

func StartServer()

Start API server.

func StartTaskClient

func StartTaskClient()

Start Task queue server.

func StartTaskServer

func StartTaskServer()

Types

type Video

type Video struct {
	CreatedAt time.Time
	UpdatedAt time.Time

	// Manual primary key with uuid4 as value.
	ID string `gorm:"primaryKey"`

	// Video original filename after update.
	FileName string `json:"filename"`

	// Video title.
	Title string `json:"title"`

	// Video duration.
	Duration int `json:"duration"`

	// By default `false`, set as `true` when video is fully encoded.
	IsReady bool `json:"isReady"`

	// Dynamic field that will be filled with the stream url of th the video.
	StreamURL string `json:"streamURL"`
}

Model

TODO: Use uuid instead of auto incremented uint

func (*Video) Encode

func (v *Video) Encode(format string, resX int, resY int) error

Encode video to given format.

func (*Video) GetEncodedDestinationPath

func (v *Video) GetEncodedDestinationPath(format string, resX int, resY int) string

func (*Video) GetOriginalFilePath

func (v *Video) GetOriginalFilePath() string

func (*Video) PrepareFolder

func (v *Video) PrepareFolder() error

Create a folder with the video UUID as name.

type VideoEncodePayload

type VideoEncodePayload struct {
	UUID string
	ResX int
	ResY int
}

type WebData

type WebData struct {
	ID string
}

Jump to

Keyboard shortcuts

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