gphoto2 icon indicating copy to clipboard operation
gphoto2 copied to clipboard

gphoto2-webapi server

Open thorsten-l opened this issue 2 years ago • 9 comments

A new approach for the gphoto2 webapi server, integrated into the build system as a separate binary gphoto2-webapi.

thorsten-l avatar Jun 17 '22 11:06 thorsten-l

I think there is a remaining point of discussion: Do we want to subject our users to the hassle of dealing with git submodule?

I can see two alternatives:

  • Use git submodule.

    • proper history tracking of the mongoose.[ch] files used
    • using git submodule is a big hassle even for people very familiar with git, but the gphoto2 repo is used by many people not very familiar with git
    • We could mitigate that problem by making the build work by skipping the webapi build in the absence of a properly checked out git submodule. So the CLI would build by default, but the webapi would only build for people who have properly initialized and updated the git submodule.
  • Avoid git submodule, and copy over mongoose.[ch] from a git clone of mongoose and check them into the gphoto2 repository, possibly with the help of scripts.

    • Builds on every git clone.
    • Loses the direct history connection of mongoose.[ch].
    • Requires a bit of additional work to update and track the versions of mongoose.[ch], parts of which could be assisted by scripts, git hooks, etc.

In both cases, gphoto2 repo maintainers must regularly update mongoose.[ch], either with the proper git submodule commands, or by copying mongoose.[ch] from an updated mongoose repo and pushing them into the gphoto2 repo.

More comments/review/additional commits to follow.

ndim avatar Jun 20 '22 15:06 ndim

I'm honest to you, i'm dealing with github now over 10 years and this was the very first time i used git submodule and in my opinion it is not very handy. I see also an advantage in coping the mongoose sources into the gphoto2 repository, because in case of a major release upgrade with api incompatibilities one get time to migrate to the new release.

thorsten-l avatar Jun 20 '22 16:06 thorsten-l

Hmm, is there no commonly used http server c library we could use? libhttp? libmicrohttpd?

msmeissn avatar Jun 21 '22 11:06 msmeissn

But libhttp and libmicrohttpd are huge vs. mongoose - it's like to take a sledgehammer to crack a nut. mongoose is a well developed product.

https://github.com/cesanta/mongoose

from README.md:

  • Mongoose is used by hundreds of businesses, from Fortune500 giants like Siemens, Schneider Electric, Broadcom, Bosch, Google, Samsung, Qualcomm, Caterpillar to the small businesses
  • Used to solve a wide range of business needs, like implementing Web UI interface on devices, RESTful API services, telemetry data exchange, remote control for a product, remote software updates, remote monitoring, and others

thorsten-l avatar Jun 21 '22 11:06 thorsten-l

you are right. do not mind me then ;)

msmeissn avatar Jun 21 '22 12:06 msmeissn

@thorsten-l Which editor are you using? I am wondering if we can add a few magic lines to the source files to tell your editor to use the indentation the rest of the code in that file is already using.

Anyway, I will fix the indentation in the existing code by a rebase before merging it into master, but it would be nice we could tell your editor to not introduce more mixed code indentation in code yet to be written.

ndim avatar Jun 22 '22 06:06 ndim

@thorsten-l Which editor are you using? I am wondering if we can add a few magic lines to the source files to tell your editor to use the indentation the rest of the code in that file is already using.

Anyway, I will fix the indentation in the existing code by a rebase before merging it into master, but it would be nice we could tell your editor to not introduce more mixed code indentation in code yet to be written.

I'm using Visual-Studio-Code on Lubuntu 22.04

thorsten-l avatar Jun 22 '22 07:06 thorsten-l

I think now i've implemented all features that are of interest.

Two Questions:

  • What is the best way to reinitialize the Camera/Port? At this time i run the server in an endless script loop and do /api/server/shutdown for a reinit.
  • How do i 'close' the Mirror after /api/show-preview or /api/capture-movie?

thorsten-l avatar Jun 26 '22 10:06 thorsten-l

I just startet to implement a little sample Web Application.

https://github.com/thorsten-l/gphoto2-webapp

It is a sample WebApp to demonstrate the usage of the gphoto-webapi only.

thorsten-l avatar Jul 03 '22 19:07 thorsten-l