models

package
v0.0.0-...-3b7a923 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TASK_NAME_ENUM = map[TaskKind]string{
	TaskNew:       "TASK_NEW",
	TaskSplit:     "TASK_SPLIT",
	TaskMerge:     "TASK_MERGE",
	TaskTranscode: "TASK_TRANSCODE",
	TaskDash:      "TASK_DASH",
}

Functions

This section is empty.

Types

type Audio

type Audio struct {
	FileName string
	Bitrate  int
}

type DashTask

type DashTask struct {
	ListVideo  []*Video
	ListAudio  []*Audio
	ResultDash []string
}

type MergeTask

type MergeTask struct {
	// List of actual video that ready to be merged
	// TODO: refactor this list video data model
	// Worker just need the filename
	ListVideo []*Video `json:"list_video"`
	Result    *Video   `json:"result"`
}

type SplitTask

type SplitTask struct {
	Video *Video
	// Split to X chunk
	TargetChunk  int      `json:"target_chunk"`
	SizePerVid   int64    `json:"size_per_vid"`
	SizeLeft     int64    `json:"size_left"`
	SplitedVideo []*Video `json:"splited_video"`
}

type Task

type Task struct {
	Id          primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	OriginVideo *Video             `json:"origin_video"`

	Kind          TaskKind       `json:"kind"`
	TaskSplit     *SplitTask     `json:"task_split"`
	TaskTranscode *TranscodeTask `json:"task_transcode"`
	TaskMerge     *MergeTask     `json:"task_merge"`
	TaskDash      *DashTask      `json:"task_dash"`
	PrevTask      TaskKind       `json:"prev_task"`

	Status TaskStatus `json:"status"`
	Worker string     `gorm:"size:255" json:"worker"`

	TaskSubmitted time.Time     `json:"task_submitted"` // time (approx <1ms) when task submitted to queue
	TaskStarted   time.Time     `json:"task_started"`
	TaskCompleted time.Time     `json:"task_completed"` // time when task finished by worker
	TaskDuration  time.Duration `json:"task_duration"`
}

func (*Task) TableName

func (t *Task) TableName() string

type TaskKind

type TaskKind int
const (
	TaskNew TaskKind = iota // new task, not from other task
	TaskSplit
	TaskMerge
	TaskTranscode
	TaskDash
)

type TaskPostAction

type TaskPostAction struct {
	Message amqp.Delivery
	Err     error
}

TaskPostAction is struct for handling post action after task is either scheduled or rejected based on the error

type TaskProgressResponse

type TaskProgressResponse struct {
	OriginVideo   *Video        `json:"origin_video"`
	TotalDuration time.Duration `json:"total_duration"`
	TaskList      []*Task       `json:"task_list"`
}

type TaskStatus

type TaskStatus int
const (
	TaskQueued TaskStatus = iota
	TaskStatusDone
	TaskStatusOnProgress
	TaskStatusFailed
)

type TaskTranscodeType

type TaskTranscodeType int
const (
	TranscodeVideo TaskTranscodeType = iota
	TranscodeAudio
)

type TranscodeTask

type TranscodeTask struct {
	TranscodeType   TaskTranscodeType `json:"transcode_type"`
	Video           *Video            `json:"video"`
	TargetRes       string            `gorm:"size:255;" json:"target_res"`
	TargetBitrate   int               `gorm:"size:255;" json:"target_bitrate"`
	TargetEncoding  string            `json:"target_encoding"`
	TargetReprCount int               `json:"target_representation_count"` //Number of target representation
	ResultVideo     *Video            `json:"result_video"`
	ResultAudio     *Audio            `json:"result_audio"`
}

type Video

type Video struct {
	//gorm.Model, changed to mongodb
	Id       primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	FileName string             `gorm:"size:255;not null;unique" json:"file_name"`

	Size     int64   `json:"size,omitempty"` // File size in Byte
	Bitrate  int     `json:"bitrate"`
	Duration float32 `json:"duration"`
	Width    int     `json:"width"`
	Height   int     `json:"height"`

	Audio *Audio   `json:"audio,omitempty"`
	Video []*Video `json:"video,omitempty"` //list of available video representation

	DashFile []string `json:"dash_file"`
}

type Worker

type Worker struct {
	Id            primitive.ObjectID `bson:"id,omitempty" json:"id"`
	WorkerPodName string             `json:"worker_pod_name"`
	IpAddress     string             `json:"ip_address"`
	Status        WorkerStatus       `json:"status"`
	WorkingOn     string             `json:"working_on"` // string of task id that worker working on
	UpdatedAt     time.Time          `json:"updated_at"`
}

func (*Worker) TableName

func (w *Worker) TableName() string

type WorkerStatus

type WorkerStatus int
const (
	WorkerStatusReady WorkerStatus = iota
	WorkerStatusWorking
	WorkerStatusTerminated
	WorkerStatusUnreachable
)

Jump to

Keyboard shortcuts

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