Skip to content

Commit 3e3988a

Browse files
committed
minor improvements
1 parent f072dab commit 3e3988a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pkg/ring/client.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ func (c *Client) Stop() error {
514514

515515
if c.prod != nil {
516516
_ = c.prod.Stop()
517-
c.prod = nil
518517
}
519518

520519
if c.ws != nil {
@@ -537,6 +536,6 @@ func (c *Client) MarshalJSON() ([]byte, error) {
537536
if webrtcProd, ok := c.prod.(*webrtc.Conn); ok {
538537
return webrtcProd.MarshalJSON()
539538
}
540-
541-
return nil, errors.New("ring: can't marshal")
539+
540+
return json.Marshal(c.prod)
542541
}

pkg/ring/snapshot.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func NewSnapshotProducer(client *RingRestClient, camera *CameraData) *SnapshotPr
2020
ID: core.NewID(),
2121
FormatName: "ring/snapshot",
2222
Protocol: "https",
23+
RemoteAddr: "app-snaps.ring.com",
2324
Medias: []*core.Media{
2425
{
2526
Kind: core.KindVideo,
@@ -43,18 +44,15 @@ func (p *SnapshotProducer) Start() error {
4344
// Fetch snapshot
4445
response, err := p.client.Request("GET", fmt.Sprintf("https://app-snaps.ring.com/snapshots/next/%d", int(p.camera.ID)), nil)
4546
if err != nil {
46-
return fmt.Errorf("failed to get snapshot: %w", err)
47+
return err
4748
}
4849

4950
pkt := &rtp.Packet{
5051
Header: rtp.Header{Timestamp: core.Now90000()},
5152
Payload: response,
5253
}
5354

54-
// Send to all receivers
55-
for _, receiver := range p.Receivers {
56-
receiver.WriteRTP(pkt)
57-
}
55+
p.Receivers[0].WriteRTP(pkt)
5856

5957
return nil
6058
}

0 commit comments

Comments
 (0)