-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathhandlers.go
More file actions
67 lines (56 loc) · 2.02 KB
/
Copy pathhandlers.go
File metadata and controls
67 lines (56 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package runner
import (
"context"
"github.com/tum-dev/gocast/runner/pkg/ptr"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/tum-dev/gocast/runner/pkg/actions"
"github.com/tum-dev/gocast/runner/protobuf"
)
func (r *Runner) RequestStream(_ context.Context, req *protobuf.StreamRequest) (*protobuf.StreamResponse, error) {
data := map[string]any{
"streamID": req.GetStreamId(),
"streamVersion": protobuf.StreamVersion_name[int32(req.GetVersion())],
"streamEnd": req.End.AsTime(),
"globalOpts": req.GetFfmpegGlobalOptions(),
"inputOpts": req.GetFfmpegInputOptions(),
"outputOpts": req.GetFfmpegOutputOptions(),
"input": req.GetInput(),
}
r.log.Info("RequestStream data constructed", "data", data)
a := []actions.Action{
actions.Stream,
actions.StreamEnd,
actions.MkVOD,
actions.CheckVoD,
actions.MkThumb,
}
jID := r.RunAction(a, data, r.log.With("stream_id", req.GetStreamId(), "stream_version", req.GetVersion(), "input", req.GetInput()))
r.log.Info("job added", "ID", jID)
return &protobuf.StreamResponse{JobId: ptr.Take(jID)}, nil
}
func (r *Runner) RequestStreamEnd(_ context.Context, req *protobuf.StreamEndRequest) (*protobuf.StreamEndResponse, error) {
cancel, ok := r.jobs[req.GetJobId()]
if ok {
cancel()
return nil, nil
}
return nil, status.Errorf(codes.NotFound, "stream not found")
}
func (r *Runner) HandleVOD(_ context.Context, req *protobuf.HandleVODRequest) (*protobuf.HandleVODResponse, error) {
data := map[string]any{
"streamID": req.GetStreamId(),
"streamVersion": req.GetVersion().String(),
"recordingDir": req.GetFilepath(),
}
r.log.Info("HandleVOD data constructed", "data", data)
a := []actions.Action{
actions.CheckCodec,
actions.MkVOD,
actions.CheckVoD,
actions.MkThumb,
}
jID := r.RunAction(a, data, r.log.With("stream_id", req.GetStreamId(), "stream_version", req.GetVersion(), "input", req.GetFilepath()))
r.log.Info("job added", "ID", jID)
return &protobuf.HandleVODResponse{JobId: ptr.Take(jID)}, nil
}