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) NewPeerConnection(ctx context.Context, user string) (rtcrec.PeerConnection, error) {
11 shouldRecord := false
12 settings, err := mm.model.GetServerSettings(ctx, mm.cli.PublicHost, user)
13 if err != nil {
14 return nil, err
15 }
16 if settings != nil {
17 spsettings, err := settings.ToStreamplaceServerSettings()
18 if err != nil {
19 return nil, err
20 }
21 if spsettings.DebugRecording != nil {
22 shouldRecord = *spsettings.DebugRecording
23 }
24 }
25 if !shouldRecord {
26 log.Warn(ctx, "no server settings found, will not record")
27 }
28 pionpc, err := mm.webrtcAPI.NewPeerConnection(mm.webrtcConfig)
29 if err != nil {
30 return nil, err
31 }
32 return rtcrec.NewRecordingPeerConnection(ctx, *mm.cli, user, pionpc, shouldRecord)
33}