Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming Legacy Mode #1253

Closed
1 task done
nickustinov opened this issue Jul 4, 2023 · 50 comments
Closed
1 task done

Streaming Legacy Mode #1253

nickustinov opened this issue Jul 4, 2023 · 50 comments
Labels
live-streaming Problems with live streams

Comments

@nickustinov
Copy link

Streaming Issue

Hey, I need to switch cameras to the Legacy Mode. However, this article https://github.com/dgreif/ring/wiki/Streaming-Legacy-Mode sends to the Ring support page, which has broken images, so it's impossible to know how to enable it.

Could someone share the steps required and update your Wiki to reflect the proper steps?

N

Proposed Solution

Unknown

Environment

Homebridge

What operating system are you on?

Linux

Relevant log output

No response

Honesty Time

  • I swear this is worth your time!
@nickustinov nickustinov added the live-streaming Problems with live streams label Jul 4, 2023
@nickustinov
Copy link
Author

Just to add, there is no any way to enable Streaming Legacy Mode in Ring app 5.61.0 on iOS

@niqbert89
Copy link

I don’t have this option, too :(

@rav4kumar
Copy link

same

1 similar comment
@valerioceniccola
Copy link

same

@tsightler
Copy link
Collaborator

tsightler commented Jul 7, 2023

Based on my understanding the option is only available on platforms where HEVC is potentially not supported. For Apple products, the Ring app requires a minimum iOS version of 14 I believe, which only supports hardware that has HEVC support, so there's no real reason for them to provide a toggle for the iOS version of the Ring app.

However, for Android, Ring supports back to at least Android 9, and that version runs on some pretty low-end devices that definitely don't have the capability to support HEVC.

I've also read things that imply that if you use a web browser that doesn't support HEVC (like Firefox or even most Chrome builds) that it will give you an option to switch to legacy mode for those cameras that won't work.

As none of my cameras have been HEVC enabled, I can't research this. If someone has a camera that is not too sensitive, and is willing to share it for a day or two, I'd love to investigate what options might be possible. For example, maybe we can just call the same API that Andriod uses to set the legacy video mode, or maybe there some way to "negotiate down" which just isn't working with the current code, but without having a camera that supports HEVC, I haven't been able to dig deeper. If anyone is willing to share a camera with me via the Ring app, feel free to reach out to me directly, my contact info is the same username as here at Gmail.

@tsightler
Copy link
Collaborator

If you are uncomfortable sharing your camera (understandable), and still want to help with this issue, it would be interesting to know if visiting the Ring dashboard in Firefox will still successfully start a live stream with these cameras, or if it will prompt for reverting to legacy video mode. If it does either of these, it would be useful to use the Firefox web development tools to capture a network trace for review. Again, feel free to reach out to me using the same username at Gmail if you do this and are willing to share the captured data from the development tools.

@hhunger2404
Copy link

The Toggle for "Legacy Mode" ist not available anymore.
Tried an old Ring App on an old Android 5 Tablet.
Found my Floodlight Cam Wired Plus, No toggle.

Was on the phone with the RING Support this morning. This Toggle is off the table for now.

Is there any Chance to to handle H265 or HEVC in Homebridge?
I mean the camera can pull snapshots and motion triggers as far as I can tell. But no livestream anymore.

@tsightler
Copy link
Collaborator

tsightler commented Jul 9, 2023

@hhunger2404 It's certainly not going to be available on an old Ring app version. What version of the Ring app did you test? As far as I know that last version of the Ring app that supported anything lower than Andriod 9, was 3.49.0 which was released in early 2022, a year before Rng started rolling out HEVC. And I believe even that version required Andriod 6. My guess is you would need at least an Ring app version 3.56.0, or something around there.

Regardless, did streaming actually work for that camera with the old version of the app? That would be interesting to know is it would imply that there is a method to still negotiate H.264.

Also, did you see my post above? Anything you can do there (share a camera, verify and provide traces from firefox, so any old versions of ring app that still work with those camers, etc) would be useful.

@niqbert
Copy link

niqbert commented Jul 9, 2023

After a factory reset of the cam and re-installing the camera the live streaming works fine.

@tsightler
Copy link
Collaborator

tsightler commented Jul 9, 2023

@niqbert I have a tendency to believe that's a temporary workaround at best. Based on what I can tell, Ring is slow rolling HEVC to all supported camera models, roughly in order of registration. Resetting and re-registering the camera might move you back to the end of the line, but my guess is it will come back at some point. I'm seeing more and more users of ring-mqtt who's cameras have been switched to HEVC mode so we'd be better off to research the problem and figure out how to deal with it.

@tomtaz01
Copy link

After a factory reset of the cam and re-installing the camera the live streaming works fine.

Hi, this are not working for me yet. I have try'd to reset the cam more then 3 times. no change.

@tscanlin
Copy link

I sent an email to offer to try and help out. Thanks for looking into this!

@tsightler
Copy link
Collaborator

tsightler commented Jul 13, 2023

Thanks to @tscanlin for sharing his camera I did some poking and thought I would at least document what I discovered. Don't really have a solution yet, but it might help @dgreif figure out something eventually.

  1. You can determine if a camera is in HEVC mode by looking at device.data.settings.video_settings.hevc_enabled, which is either true or false.

  2. The Ring apps appear to have been modified to use HEVC exclusively if the camera is enabled with this mode.

  3. The API used by default in ring-client-api for non-Ring Edge cameras only includes H.265 in the SDP offer for cameras in HEVC mode, which is why it is rejected since the peer connection definition only includes H.264 (this much we pretty much already knew, but it was good to confirm).

  4. Simply adding H.265 to the peer connection definition as an additional video protocol allows the backend WebRTC calls to succeed, and I was able to play HEVC video from such a camera stream using VLC, but I have no idea what impact this would have on Homekit as I'm not sure if Homekit supports H.265/HEVC (anecdotal evidence I could find suggest it does not, even though Apple has led the charge for HEVC support). If Homekit does happen to support H.265/HEVC, then this is probably the super simple way to address this.

  5. Using MITM proxy I could see that the Andriod app actually uses an alternate method to start live streams that is the same as what is used by ring-client-api for Ring Edge devices. I modified the ring-client-api code to always use this method for all cameras because I hoped that this API might allow negotiating down since, instead of answering an SDP offer from Ring, it generates an offer. Unfortunately, if you provide an offer that doesn't include H.265/HEVC to try to start a stream with an HEVC enabled camera, the connection is immediately closed with the error "Unsupported media format - HEVC only camera" returned over the websocket, so a dead end there. On another note, to get this to work I had to modify the ring-edge-connection.js code slightly to include a "dialog_id" (basically a UUID) or the socket would just close the connection immediately.

  6. At this point I was starting to think the only option is to transcode, which is a heavy operation and perhaps not practical, however, Ring has yet a third streaming API, the simple peer connection which is used by the Ring web dashboard. I suspected this must support H.264 because so few browsers are ready for HEVC. Indeed, checking Firefox and Chrome with an HEVC camera using the Ring web dashboard showed that the video stream was still using H.264 and the SDP offer and answer only includes H.264, so it at least shows the cameras still can support this, either that, or Ring is transcoding on-the-fly for streams viewed via the dashboard. Either way, perhaps using this method to trigger live streams is an option that could be used to maintain wide compatibility without local transcoding, but I need to play with it some more.

@dgreif
Copy link
Owner

dgreif commented Jul 14, 2023

Thanks for all the investigation @tsightler! I've been traveling over the past few weeks and haven't had a chance to look into this, so I really appreciate you blazing the trail! I'd love to understand the web streaming method better, especially if it currently supports H.264. Otherwise, it might be worth figuring out the API endpoints for turning on Legacy Mode and simply calling those automatically before trying to stream. In either case, I completely agree that we want to avoid transcoding video if at all possible. We do transcode audio today, but it's levels of magnitude more intensive to transcode video. I'm also traveling next week so won't be able to dig into this any time soon, but look forward to hearing what you find!

@tsightler
Copy link
Collaborator

tsightler commented Jul 14, 2023

API endpoints for turning on Legacy Mode and simply calling those automatically before trying to stream

I agree in general, but my attempts to do this have failed so far, and the option doesn't seem to exist in the Ring app anymore and Ring has pulled down the KB article about it. I believe that Legacy mode was only a temporary workaround while they addressed various issues with HEVC compatibility. As far as I can tell all iPhone/iPad devices supported by the Ring app support HEVC and the vast majority of Andriod devices as well. Once they fixed the issues with screenshots and compatibiltiy with devices like Echos, I'm guessing they pulled the Legacy mode feature as it appeared to be intended as a stop-gap when they were first rolling out if customers had issues, which they did for sure.

Even if we were able to figure it out, my concern is that it might be a short term fix as devices like Car Cam appear to be HEVC only, although they still use H.264 when playing in the browser. I actually wonder if Ring may be simply transcoding on the fly at the media server when people view an HEVC enabled camera in a browser.

So far, the only way I've been able to get H.264 is via the SimpleWebRtcSession(), and it seems to work, but perhaps not with Ring Edge.

I did test with ffmpeg transcoding using ultrafast profile and it works, but on a 10 year old Intel box it uses ~40% of the CPU, and on a RPi4b it's closer to 85%, for a single stream. Not ideal for sure.

For my use case, which is different from Homekit case for sure, I tried to see what would happen if I just passed through H.265 without transcoding it to see what compatibility would look like. Chrome and Edge play back H.265 HLS streams of course it's HLS so the delay is not great (3-5 seconds). It seems for now only Safari supports H.265 via native WebRTC, which is how most of my users play back streams. I could not get Chrome or Edge to play back a WebRTC stream that used H.265, only Safari and other video players. That would be a real problem for my use case.

I'm thinking that using SimpleWebRtcSession is going to be the best option, but I'm still struggling with it a little bit.

@tsightler
Copy link
Collaborator

tsightler commented Jul 19, 2023

Continuing to dig and try to learn as much as possible while @tscanlin has allowed me to have access to his camera I've found a few things.

  1. When a camera is in HEVC mode, it's raw event recordings uploaded to Ring are also HEVC (makes sense, but just worth knowing).

  2. It does appear that it is possible to put a camera back into "Legacy mode" still. For those that want something that works now, here's the trick. Login to the Ring web dashbaord using Firefox. It must be Firefox because that is the only browser that does not support any playback of HEVC files, even via direct download (most browsers have some support for HEVC, just not via WebRTC which is used for live viewing). Go to your event history for this camera and select an event, it will not be able to disaplay and you will get a popup that allows switching to Legacy mode.

  3. Setting legacy mode via the API can be done via the standard setDeviceSettings() function in ring-client-api, the payload is {"video_settings":{"hevc_enabled":false}} but a shared user cannot change this setting (as expected).

For a while I thought the best short-term option was going to be #3, just set the camera to legacy mode, however, something interesting happened this week, Ring changed the way they stream for web browsers! I have HAR files from last week where the Ring web dashboard was using the simple HTTPS based WebRTC API, but then, this week, suddenly it has changed and it is using the same websocket based API as Ring Andriod app, just authenticating in a slightly different way. Overall this is not particularly interesting except, when the API is used with this slightly different authentication, it suddenly does allow negotiating down to H.264 for WebRTC!

How it works:

  1. Instead of opening the websocket using header based authentication, you make a call https://app.ring.com/api/v1/clap/ticket/request/signalsocket which returns a JSON with a ticket property

  2. Connect to the websocket with the following URL:
    wss://api.prod.signalling.ring.devices.a2z.com:443/ws?api_version=4.0&auth_type=ring_solutions&client_id=ring_site-${crypto.randomUUID()}&token=${ticket}

The UUID doesn't appear to matter, just has to exist, my gut says it is similar to X-Sig-Client-ID used for header authentication in the current ring-edge-connection.ts code. Token is of course the ticket acquired.

Another important thing is that the headers must include a User-Agent, I haven't found that it matter much what it is, but I just used the generic Firefox user agent for now so my code for connecting to the websocket looks like this:

new WebSocket(`wss://api.prod.signalling.ring.devices.a2z.com:443/ws?api_version=4.0&auth_type=ring_solutions&client_id=ring_site-${crypto.randomUUID()}&token=${authToken}`, {
    headers: {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0'
    }
})
  1. From there, the operation is identical to the code in ring-edge-connection.ts today with one exception, I had to include a "dialog_id" in the messages sent via the websocket. I have no idea what this is, but without it the websocket would close the connectiong pretty much immediately, it appeared to be a random UUID with a 6 digit number tacked on it, so I used:

this.dialogId = ${crypto.randomUUID()}-${Math.floor(100000 + Math.random() * 900000)}

And, as noted above, I had to add dialog_id: this.dialogId to all sendMessage commands. After that, this API appears to work with any camera, Ring Edge or not (although I don't have consistent access to a Ring Edge device to test, but this is the API already used for those) and allows HEVC cameras to be negotiated down to H.264/AVC on-the-fly which is the best of all possible worlds.

@dgreif My gut says Ring is attempting to standardize their four different streaming APIs (1 SIP, 3 WebRTC) down to this single API using this 4.0 protocol, since it appears that the latest version of the Andriod app and the latest web dashboard now use this very same API, just authenticated slightly differently. I'm thinking it might be time to standardize on this API for all cameras as well, no need for three different API methods in ring-client-api, but I'll let you decide.

@tsightler
Copy link
Collaborator

@dgreif I know you said you are travelling, and I'm also travelling the rest of this week, but I wanted to provide some working reference, in case you eventually get a chance to look at this. In ring-mqtt I don't use the streaming code in ring-client-api directly, rather I've copied it, converted it to native Javascript, stripped out some things ring-mqtt doesn't really need, and implemented some custom logging which makes it a little easier for me to tell what is happening when streams fail.

However, the overall code is still pretty much the same as in ring-client-api, so I've modified up a working version here that might provide a guideline of the changes:

https://github.com/tsightler/ring-mqtt/blob/dev/lib/streaming/webrtc-connection.js

This basically replaces the existing webrtc-connection code with the code from ring-edge-connection, but with the modifications I outlined above. The actual call to get a ticket is in camera.js, but I think that's straightforward. My gut says you'd just modify createStreamingConnection() to call the ticket API instead of the live_call API and then pass that ticket to WebrtcConnection.

Honestly, I'll probably merge webrtc-connection.js and streaming-connection-base.js together as I don't think it's really needed if there's not two separate code paths.

I've tested this with a bunch of cameras, and I'm tempted to just push it out and see what happens, but I have not tested it with Ring Edge devices because I don't have access to one at the moment, however, my gut says it would work.

When I get back next week I can try to put together a PR for ring-client-api, but for now, I've got a working solution for ring-mqtt and I'll probably try to recruit some users to test.

If you wanted to do something "safer" we could check for Ring Edge and HEVC mode and only use the new method in those cases, while continuing to use the existing method for all other cameras, but my testing indicates that this new API works fine for all cameras. I'll leave that up to you.

@tcarr85
Copy link

tcarr85 commented Jul 20, 2023

@dgreif I know you said you are travelling, and I'm also travelling the rest of this week, but I wanted to provide some working reference, in case you eventually get a chance to look at this. In ring-mqtt I don't use the streaming code in ring-client-api directly, rather I've copied it, converted it to native Javascript, stripped out some things ring-mqtt doesn't really need, and implemented some custom logging which makes it a little easier for me to tell what is happening when streams fail.

However, the overall code is still pretty much the same as in ring-client-api, so I've modified up a working version here that might provide a guideline of the changes:

https://github.com/tsightler/ring-mqtt/blob/dev/lib/streaming/webrtc-connection.js

This basically replaces the existing webrtc-connection code with the code from ring-edge-connection, but with the modifications I outlined above. The actual call to get a ticket is in camera.js, but I think that's straightforward. My gut says you'd just modify createStreamingConnection() to call the ticket API instead of the live_call API and then pass that ticket to WebrtcConnection.

Honestly, I'll probably merge webrtc-connection.js and streaming-connection-base.js together as I don't think it's really needed if there's not two separate code paths.

I've tested this with a bunch of cameras, and I'm tempted to just push it out and see what happens, but I have not tested it with Ring Edge devices because I don't have access to one at the moment, however, my gut says it would work.

When I get back next week I can try to put together a PR for ring-client-api, but for now, I've got a working solution for ring-mqtt and I'll probably try to recruit some users to test.

If you wanted to do something "safer" we could check for Ring Edge and HEVC mode and only use the new method in those cases, while continuing to use the existing method for all other cameras, but my testing indicates that this new API works fine for all cameras. I'll leave that up to you.

I’m willing to test.

@SamTheGeek
Copy link

I know y'all have been investigating this for a while, and I'm also happy to test. I just want to add that I got official confirmation from Ring that Legacy Mode is no longer supported/extant and they won't be bringing it back. How annoying.

@tsightler
Copy link
Collaborator

@SamTheGeek I just posted last week that it seems legacy mode is still available, I even found the API required to switch it. The only way I've found to enable it via Ring official methods is to use Firefox, login to Ring web dashboard, go to a camera and trry to view a recorded video. It won't work because Firefox has no support for H.265 and it will prompt you to enable Legacy mode.

Regardless, we know what needs to be done, I've already pushed the fixes out to ring-mqtt users a week ago with no reported negative side effects, I just need to find time to put together a patch for ring-cleint-api and ring-homebridge. Just don't have that time right now.

@SamTheGeek
Copy link

@tsightler even on Firefox today (on a Mac, mind) it isn't prompting to enable legacy mode. So something must have changed. I suspect it isn't a coincidence that all the 'seamless' user experience stuff landed at the same time as the rollout accelerated.

@tsightler
Copy link
Collaborator

@SamTheGeek How are they playing back recorded events from HEVC cameras on Firefox? The reason it was still offered there when I tested it last week is because the Web UI simply passed the S3 tokenized link to the recording directly to the browser and had the browser play it, which works for most browsers, but not for Firefox. It's difficult for me to see how they would solve this without transcoding on the fly. which is what they appear to do for the live stream. Maybe Firefox on Mac can use the OS support for HEVC or are they using some other method to play back these recordings? Would be interesting to know because just lat week Firefox still prompted for legacy mode for me.

No idea what the "seamless' user experience stuff is referring to, perhaps you can clue me in there.

@jadedjabels
Copy link

Was there ever a resolution to this? This is my exact problem and I cannot find any answers.

@tomtaz01
Copy link

tomtaz01 commented Aug 2, 2023

Hello,

I tried Firefox and Windows to bring the camera back into legacy mode. The popup no longer appeared. Any ideas?

@tsightler
Copy link
Collaborator

@tomtaz01 When you played back an event in Firefox from a camera with HEVC, did it work?

@tsightler
Copy link
Collaborator

On another note, I have submitted a PR for updating ring-client-api to the new streaming API which works with these cameras, so progress is being made.

@tomtaz01
Copy link

tomtaz01 commented Aug 2, 2023

@tomtaz01 When you played back an event in Firefox from a camera with HEVC, did it work?

Yes

@tsightler
Copy link
Collaborator

tsightler commented Aug 2, 2023

@tomtaz01 When you played back an event in Firefox from a camera with HEVC, did it work?

Yes

Interesting, I wish I could see how they were doing that, would provide more clues into options available. Completely different than just two weeks ago I guess but I gave up access to the camera a user had graciously shared with me. I guess at this point it doesn't matter, the code to work with this is available, just have to wait for it to be reviewed since it is somewhat of a high risk change.

@SamTheGeek
Copy link

@tsightler When I stream on firefox, live or recorded, it just automatically provides an H.264 stream, they must be transcoding on the fly. I thought maybe FF on MacOS had HEVC support but even on a PC it plays back fine. I booted into Windows for you!

@tsightler
Copy link
Collaborator

tsightler commented Aug 4, 2023

@SamTheGeek I'm just super curious how they are playing back HEVC recording on Firefox. I already know they are transcoding on the fly for live stream via WebRTC as that's the method the patches I've submitted are using as well, but the way they were playing back recordings was by simply using the browsers ability to play back files via HTTP and were playing back files directly from S3, which just wouldn't work for Firefox. I'm not sure how they could transcode on the fly in this case, but perhaps they've implemented some other method. A HAR file from Firefox dev tools of the process would be interesting to understand how exactly they've implemented this.

@SamTheGeek
Copy link

@tsightler I'll fire up the PC tonight and record.

@tsightler
Copy link
Collaborator

Thanks @SamTheGeek. The reason I'm personally interested in this is because I've already implemented support for live streaming from HEVC cameras in ring-mqtt, but ring-mqtt also supports playback of recorded streams (called event streams in ring-mqtt). For HEVC cameras I'm having to do local transcoding of recordings to get reliable playback across a wide range of devices, but if Ring has some API that allows playback of recordings on the fly, that would be a huge win.

For those following this thread for HEVC support in ring-homebridge, a new beta version, 12.0.0-beta.0, has been released with the new streaming API implemented so any testing results from that version would be appreciated.

@valerioceniccola
Copy link

Thanks @SamTheGeek. The reason I'm personally interested in this is because I've already implemented support for live streaming from HEVC cameras in ring-mqtt, but ring-mqtt also supports playback of recorded streams (called event streams in ring-mqtt). For HEVC cameras I'm having to do local transcoding of recordings to get reliable playback across a wide range of devices, but if Ring has some API that allows playback of recordings on the fly, that would be a huge win.

For those following this thread for HEVC support in ring-homebridge, a new beta version, 12.0.0-beta.0, has been released with the new streaming API implemented so any testing results from that version would be appreciated.

I tried the beta version, but when I try to stream a camera I got an error:

[homebridge-ring] RangeError: offset is out of bounds
at Uint8Array.set ()
at Function.padStart (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:972:13)
at Function.encodeSignature (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:940:22)
at Function.sign (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1575:54)
at EcdsaProvider.onSign (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1737:25)
at EcdsaProvider.sign (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:157:28)
at SubtleCrypto.sign (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:1405:39)
at Function.create (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/x509/build/x509.cjs.js:2407:35)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at Function.value [as createSelfSignedCertificateWithKey] (/homebridge/node_modules/homebridge-ring/node_modules/dtls/src/context/cipher.ts:108:18)

@raiubreaksthings
Copy link

I am starting to see errors in home bridge when trying to access live videos in the Apple Home App as well.
I have uninstalled the plugin, reinstalled, added devices back to my home. Still same issue.

[08/08/2023, 11:25:08] [Ring] connectionStateChange: closed
[08/08/2023, 11:25:08] [Ring] iceConnectionStateChange: closed
[08/08/2023, 11:25:08] [Ring] Failed to activate stream
[08/08/2023, 11:25:08] [Ring] RangeError: offset is out of bounds
at Uint8Array.set ()
at Function.padStart (/usr/local/lib/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:972:13)
at Function.encodeSignature (/usr/local/lib/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:940:22)
at Function.sign (/usr/local/lib/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1575:54)
at EcdsaProvider.onSign (/usr/local/lib/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1737:25)
at EcdsaProvider.sign (/usr/local/lib/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:157:28)
at SubtleCrypto.sign (/usr/local/lib/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:1405:39)
at Function.create (/usr/local/lib/node_modules/homebridge-ring/node_modules/@peculiar/x509/build/x509.cjs.js:2407:35)
at Function.value [as createSelfSignedCertificateWithKey] (/usr/local/lib/node_modules/homebridge-ring/node_modules/dtls/src/context/cipher.ts:108:18)
at RTCDtlsTransport.setupCertificate (/usr/local/lib/node_modules/homebridge-ring/node_modules/werift/src/transport/dtls.ts:76:9)

@raiubreaksthings
Copy link

Unsure if these are related? I just restarted the homebridge server.

[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/43352214/subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/22586843/motions_subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/22586843/subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/185890745/motions_subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/23647682/motions_subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/326661330/subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/43352214/motions_subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/185890745/subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/326661330/motions_subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.
[08/08/2023, 14:51:25] [Ring] 404 from endpoint https://api.ring.com/clients_api/doorbots/23647682/subscribe
[08/08/2023, 14:51:25] [Ring] Session hardware_id not found. Creating a new session and trying again.

@SamTheGeek

This comment was marked as outdated.

@raiubreaksthings
Copy link

Thanks @SamTheGeek. The reason I'm personally interested in this is because I've already implemented support for live streaming from HEVC cameras in ring-mqtt, but ring-mqtt also supports playback of recorded streams (called event streams in ring-mqtt). For HEVC cameras I'm having to do local transcoding of recordings to get reliable playback across a wide range of devices, but if Ring has some API that allows playback of recordings on the fly, that would be a huge win.
For those following this thread for HEVC support in ring-homebridge, a new beta version, 12.0.0-beta.0, has been released with the new streaming API implemented so any testing results from that version would be appreciated.

I tried the beta version, but when I try to stream a camera I got an error:

[homebridge-ring] RangeError: offset is out of bounds at Uint8Array.set () at Function.padStart (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:972:13) at Function.encodeSignature (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:940:22) at Function.sign (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1575:54) at EcdsaProvider.onSign (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1737:25) at EcdsaProvider.sign (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:157:28) at SubtleCrypto.sign (/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:1405:39) at Function.create (/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/x509/build/x509.cjs.js:2407:35) at processTicksAndRejections (node:internal/process/task_queues:95:5) at Function.value [as createSelfSignedCertificateWithKey] (/homebridge/node_modules/homebridge-ring/node_modules/dtls/src/context/cipher.ts:108:18)

I have the beta installed in hoobs now. I am still see the same issues when trying to open live view with the cameras.
8/10/2023, 2:07:38 PMRing Bridge BetaRingPreparing Live Stream for Backyard
8/10/2023, 2:07:38 PMRing Bridge BetaRingStream Prepared for Backyard (0.208s)
8/10/2023, 2:07:38 PMRing Bridge BetaRingActivating stream for Backyard (0.264s)
8/10/2023, 2:07:38 PMRing Bridge BetaRingERRORRangeError: offset is out of bounds
8/10/2023, 2:07:38 PMRing Bridge BetaRingconnectionStateChange: closed
8/10/2023, 2:07:38 PMRing Bridge BetaRingiceConnectionStateChange: closed
8/10/2023, 2:07:41 PMRing Bridge BetaERROR[Ring Bridge Beta 1F1A@Selected RTP Stream Configuration] The write handler for the characteristic 'Selected RTP Stream Configuration' on the accessory 'Backyard' was slow to respond!
8/10/2023, 2:07:47 PMRing Bridge BetaERROR[Ring Bridge Beta 1F1A@Selected RTP Stream Configuration] The write handler for the characteristic 'Selected RTP Stream Configuration' on the accessory 'Backyard' didn't respond at all!. Please check that you properly call the callback!

@alexqzd
Copy link

alexqzd commented Aug 13, 2023

I'm also getting the RangeError: offset is out of bounds error using the beta:

[13/08/2023, 01:48:19] [Ring] RangeError: offset is out of bounds
    at Uint8Array.set (<anonymous>)
    at Function.padStart (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:972:13)
    at Function.encodeSignature (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:940:22)
    at Function.sign (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1575:54)
    at EcdsaProvider.onSign (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/webcrypto/build/webcrypto.js:1737:25)
    at EcdsaProvider.sign (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:157:28)
    at SubtleCrypto.sign (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/webcrypto-core/build/webcrypto-core.js:1405:39)
    at Function.create (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/@peculiar/x509/build/x509.cjs.js:2407:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Function.value [as createSelfSignedCertificateWithKey] (/var/lib/homebridge/node_modules/homebridge-ring/node_modules/dtls/src/context/cipher.ts:108:18)
[13/08/2023, 01:48:19] [Ring] connectionStateChange: closed
[13/08/2023, 01:48:19] [Ring] iceConnectionStateChange: closed

@dgreif
Copy link
Owner

dgreif commented Aug 13, 2023

Let's track the RangeError: offset is out of bounds errors over in #1286. It's not specifically related to "Legacy Mode", so it's just creating noise here.

@BinDevID
Copy link

Hoobs beta here as well and seeing the error as well: The write handler for the characteristic 'Selected RTP Stream Configuration' on the accessory didn't respond at all!. Please check that you properly call the callback! Get the legacy error and link if using any other version

@tsightler
Copy link
Collaborator

@SamTheGeek Thanks for the HAR file, unfortunately it wasn't enough for me to figure out what was going on. It looked like it was a live view, not an event recording. Regardless, it's OK, I think what I'm doing with ring-mqtt is good enough for now. Thanks again for the help!

For anyone else following this thread. Please make sure you install the latest beta which should address the rangeError (not related to HEVC, just bad timing with a bug in another package). We believe the current beta should fix that issue and allow testing for HEVC users to proceed.

@SamTheGeek

This comment was marked as outdated.

@SamTheGeek
Copy link

@tsightler As promised, a HAR file of streaming a previous recording (from earlier today). I've killed the other link.

@valerioceniccola
Copy link

With the new beta it works!!! Thank you!

@rav4kumar
Copy link

it still does not work for me.

@valerioceniccola
Copy link

it still does not work for me.

try to restart the bridge

@SamTheGeek
Copy link

For folks finding this thread: This is the right place only for issues in the logs like Failed to negotiate codecs. Other issues should be gathered in different issue reports.

@BinDevID
Copy link

BinDevID commented Aug 17, 2023

Hoobs 12.0.0-beta 2 with a bridge restart still gives errors.

8/17/2023, 5:19:51 AMHoob BridgeERROR[Hoob Bridge 996D@Selected RTP Stream Configuration] The write handler for the characteristic 'Selected RTP Stream Configuration' on the accessory 'Front Floods' was slow to respond!
8/17/2023, 5:19:57 AMHoob BridgeERROR[Hoob Bridge 996D@Selected RTP Stream Configuration] The write handler for the characteristic 'Selected RTP Stream Configuration' on the accessory 'Front Floods' didn't respond at all!. Please check that you properly call the callback!
8/17/2023, 5:19:57 AMHoob BridgeRingStopped Live Stream for Front Floods

Hoobs 4.3.0
Model HSLF-1
System Version 11
Node 18.16.0
Homebridge 1.6.0

As a test, I setup and installed Homebridge on a Pi, installed 12.0.0-beta 2 and didn't get any errors when streaming.

Raspbian GNU/Linux Bullseye (11)
Node 18.16.0
Homebridge 1.6.1

Maybe this is a Hoobs issue?

@DreadPirateRbrt
Copy link

Works for me on the new beta as well!
Running Node 18.16.0, and Homebridge 1.6.1 on MacOS.

@dgreif
Copy link
Owner

dgreif commented Aug 20, 2023

All streaming should (include cameras with HEVC) should now work with v12. Huge thank you to @tsightler for all your hard work switching us over to the new streaming API, and to everyone who contributed ideas and feedback here.

If you have issues on v12, please open a new issue.

@dgreif dgreif closed this as completed Aug 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
live-streaming Problems with live streams
Projects
None yet
Development

No branches or pull requests