dbuezas / icsee-ptz

56 stars 10 forks source link

Question about contributing this feature? #41

Closed ibz0q closed 5 months ago

ibz0q commented 5 months ago

Hi, I was looking for a something which uses browsers GamePad API to control PTZ cameras via Onvif PTZ.

The difficulty would be in transalating movements non linearly and only supporting main set of controllers (maybe just Xbox).

I may have some free time to work on this, as this plugin is a custom component, would you be open to the idea of me adding a lovelace js plugin and me submitting changes to custom component to act as a reverse proxy to any stored camera config.

dbuezas commented 5 months ago

Sure, as long as it is optional and doesn't break webrtc card support.

Btw, wouldn't it be easier to add gamepad support to that frontend component instead? That's where I added some features to make better use of the APIi

ibz0q commented 5 months ago

I think adding it to frontend component would be better, fortunately from my tests Game API is widely supported.

As for custom component because of browser CORS, there would need to be a "proxy" to bypass this. I'd write a very basic http proxy that injects allow cross origin headers. The onvif API expects POST to ptz endpoints. This will be optional, webserver won't start unless specified. Will look at other security considerations (only allow reqs from Home Assistant etc)

Any suggestions where this could be best fit would be helpful.

dbuezas commented 5 months ago

Uhm... I really think you'd be better off implementing it inside the webrtc card. You'll need no proxy, it would work with other cameras, go2rtc would provide standard support for all kinds of streams, etc.

I'd rather not add a proxy that opens a hole in home assistant to this component :/

But this is open source, so you can fork it! :)

ibz0q commented 5 months ago

That's a fair point. I think this is quite a niche feature and would risk bloating this component/plugin though it does share the same goals of ptz control.

I'll look at webrtc or could potentially consider a separate component. Thanks for for suggestions.

dbuezas commented 5 months ago

I think it will be a lot easier there too. Maybe you can use this very related MR as a guide: https://github.com/AlexxIT/WebRTC/pull/520

If you plug the game API to the same callbacks you should be good to go.

Happy to help

ibz0q commented 5 months ago

thanks for the MR as guide it's really helpful.

PS i realised:

I think adding it to frontend component would be better, fortunately from my tests Game API is widely supported.

Sounded as if I wanted to add a frontend component to this repo, It should belong to the frontend repo as you suggested.

I will be working on this very soon in a seperate repo :) and will submit a PR with features to WebRTC at some stage.

dbuezas commented 5 months ago

Oh I see! Cool, feel free to write back if you get stuck