mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 00:17:07 +08:00
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package resolver
|
|
|
|
// This file will be automatically regenerated based on the schema, any resolver implementations
|
|
// will be copied through when generating and any unknown code will be moved to the end.
|
|
// Code generated by github.com/99designs/gqlgen version v0.17.33
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/datarhei/core/v16/encoding/json"
|
|
"github.com/datarhei/core/v16/http/graph/models"
|
|
"github.com/datarhei/core/v16/playout"
|
|
"github.com/datarhei/core/v16/restream/app"
|
|
)
|
|
|
|
// PlayoutStatus is the resolver for the playoutStatus field.
|
|
func (r *queryResolver) PlayoutStatus(ctx context.Context, id string, domain string, input string) (*models.RawAVstream, error) {
|
|
user, _ := ctx.Value("user").(string)
|
|
|
|
if !r.IAM.Enforce(user, domain, "process", id, "read") {
|
|
return nil, fmt.Errorf("forbidden")
|
|
}
|
|
|
|
tid := app.ProcessID{
|
|
ID: id,
|
|
Domain: domain,
|
|
}
|
|
|
|
addr, err := r.Restream.GetPlayout(tid, input)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unknown process or input: %w", err)
|
|
}
|
|
|
|
path := "/v1/status"
|
|
|
|
data, err := r.playoutRequest(http.MethodGet, addr, path, "", nil)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to get status: %w", err)
|
|
}
|
|
|
|
status := playout.Status{}
|
|
|
|
if err := json.Unmarshal(data, &status); err != nil {
|
|
return nil, fmt.Errorf("failed to decode response: %w", err)
|
|
}
|
|
|
|
s := &models.RawAVstream{}
|
|
s.UnmarshalPlayout(status)
|
|
|
|
return s, nil
|
|
}
|