Transcode Task Handling
This commit is contained in:
parent
fea955fb79
commit
13ea1cb755
6 changed files with 164 additions and 20 deletions
23
task/task.go
23
task/task.go
|
@ -49,7 +49,28 @@ func StartTask(conf config.Config, data types.TaskStart) error {
|
|||
}()
|
||||
return nil
|
||||
case constants.TASK_TYPE_TRANSCODE:
|
||||
return fmt.Errorf("Transcode Task Not Implemented")
|
||||
var tData types.TranscodeData
|
||||
err := json.Unmarshal(data.Data, &tData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Unmarshal Transcode Data: %w", err)
|
||||
}
|
||||
|
||||
tasks[data.ID].Status = constants.TASK_STATUS_RUNNING
|
||||
go func() {
|
||||
defer func() {
|
||||
taskMutex.Lock()
|
||||
defer taskMutex.Unlock()
|
||||
t, ok := tasks[data.ID]
|
||||
if ok {
|
||||
if t.Status == constants.TASK_STATUS_RUNNING {
|
||||
t.Status = constants.TASK_STATUS_FAILED
|
||||
t.Log = append(t.Log, "Task Status Set to Failed by defer")
|
||||
}
|
||||
}
|
||||
}()
|
||||
RunTranscode(conf, tasks[data.ID], tData)
|
||||
}()
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("Unknown Task Type %v", data.Type)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue