Live video on the AT Protocol
1package media
2
3import (
4 "context"
5 "fmt"
6
7 "github.com/go-gst/go-gst/gst"
8 "stream.place/streamplace/pkg/model"
9)
10
11// Handle shutting down a pipeline when a signing key is revoked
12func (mm *MediaManager) HandleKeyRevocation(ctx context.Context, ms MediaSigner, pipeline *gst.Pipeline) {
13 sub := mm.bus.Subscribe(ms.Streamer())
14 defer mm.bus.Unsubscribe(ms.Streamer(), sub)
15 for {
16 select {
17 case <-ctx.Done():
18 return
19 case msg := <-sub:
20 signingKey, ok := msg.(*model.SigningKey)
21 if !ok {
22 continue
23 }
24 if signingKey.RevokedAt == nil {
25 continue
26 }
27 if signingKey.DID == ms.DID() {
28 err := fmt.Errorf("signing key revoked, ending stream: %s", signingKey.RKey)
29 pipeline.Error(err.Error(), err)
30 return
31 }
32 }
33 }
34}