From 3e3988a67f00f872606675dc1a73863efe534655 Mon Sep 17 00:00:00 2001 From: seydx Date: Sat, 25 Jan 2025 16:11:39 +0100 Subject: [PATCH] minor improvements --- pkg/ring/client.go | 5 ++--- pkg/ring/snapshot.go | 8 +++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pkg/ring/client.go b/pkg/ring/client.go index 7014213d..4c473276 100644 --- a/pkg/ring/client.go +++ b/pkg/ring/client.go @@ -514,7 +514,6 @@ func (c *Client) Stop() error { if c.prod != nil { _ = c.prod.Stop() - c.prod = nil } if c.ws != nil { @@ -537,6 +536,6 @@ func (c *Client) MarshalJSON() ([]byte, error) { if webrtcProd, ok := c.prod.(*webrtc.Conn); ok { return webrtcProd.MarshalJSON() } - - return nil, errors.New("ring: can't marshal") + + return json.Marshal(c.prod) } diff --git a/pkg/ring/snapshot.go b/pkg/ring/snapshot.go index 84da0fd3..f64e4f79 100644 --- a/pkg/ring/snapshot.go +++ b/pkg/ring/snapshot.go @@ -20,6 +20,7 @@ func NewSnapshotProducer(client *RingRestClient, camera *CameraData) *SnapshotPr ID: core.NewID(), FormatName: "ring/snapshot", Protocol: "https", + RemoteAddr: "app-snaps.ring.com", Medias: []*core.Media{ { Kind: core.KindVideo, @@ -43,7 +44,7 @@ func (p *SnapshotProducer) Start() error { // Fetch snapshot response, err := p.client.Request("GET", fmt.Sprintf("https://app-snaps.ring.com/snapshots/next/%d", int(p.camera.ID)), nil) if err != nil { - return fmt.Errorf("failed to get snapshot: %w", err) + return err } pkt := &rtp.Packet{ @@ -51,10 +52,7 @@ func (p *SnapshotProducer) Start() error { Payload: response, } - // Send to all receivers - for _, receiver := range p.Receivers { - receiver.WriteRTP(pkt) - } + p.Receivers[0].WriteRTP(pkt) return nil }