Live video on the AT Protocol
1package media
2
3import (
4 "context"
5 "fmt"
6
7 comatproto "github.com/bluesky-social/indigo/api/atproto"
8 "github.com/go-gst/go-gst/gst"
9 "stream.place/streamplace/pkg/atproto"
10 "stream.place/streamplace/pkg/model"
11)
12
13// Handle shutting down a pipeline when a signing key is revoked or a user gets banned
14func (mm *MediaManager) HandleKeyRevocation(ctx context.Context, ms MediaSigner, pipeline *gst.Pipeline) {
15 sub := mm.bus.Subscribe(ms.Streamer())
16 defer mm.bus.Unsubscribe(ms.Streamer(), sub)
17 for {
18 select {
19 case <-ctx.Done():
20 return
21 case msg := <-sub:
22 switch v := msg.(type) {
23 case *model.SigningKey:
24 if v.RevokedAt == nil {
25 continue
26 }
27 if v.DID == ms.DID() {
28 err := fmt.Errorf("signing key revoked, ending stream: %s", v.RKey)
29 pipeline.Error(err.Error(), err)
30 return
31 }
32 case *comatproto.LabelDefs_Label:
33 if atproto.IsBanned(v) {
34 err := fmt.Errorf("user banned, ending stream: %s", v.Uri)
35 pipeline.Error(err.Error(), err)
36 return
37 }
38 default:
39 continue
40 }
41 }
42 }
43}