Live video on the AT Protocol
1package media
2
3import (
4 "context"
5
6 "stream.place/streamplace/pkg/log"
7 "stream.place/streamplace/pkg/rtcrec"
8)
9
10func (mm *MediaManager) shouldRecord(ctx context.Context, user string) (bool, error) {
11 shouldRecord := false
12 settings, err := mm.model.GetServerSettings(ctx, mm.cli.BroadcasterHost, user)
13 if err != nil {
14 return false, err
15 }
16 if settings != nil {
17 spsettings, err := settings.ToStreamplaceServerSettings()
18 if err != nil {
19 return false, err
20 }
21 if spsettings.DebugRecording != nil {
22 shouldRecord = *spsettings.DebugRecording
23 }
24 }
25 return shouldRecord, nil
26}
27
28func (mm *MediaManager) NewPeerConnection(ctx context.Context, user string) (rtcrec.PeerConnection, error) {
29 ctx = log.WithLogValues(ctx, "func", "NewPeerConnection", "streamer", user)
30 shouldRecord, err := mm.shouldRecord(ctx, user)
31 if err != nil {
32 return nil, err
33 }
34 pionpc, err := mm.webrtcAPI.NewPeerConnection(mm.webrtcConfig)
35 if err != nil {
36 return nil, err
37 }
38 return rtcrec.NewRecordingPeerConnection(ctx, *mm.cli, user, pionpc, shouldRecord)
39}