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

gphoto2-webapi server #514

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
7f81005
mongoose webserver submodule added
thorsten-l Jun 17, 2022
a3ea8d1
mongoose subproject
thorsten-l Jun 17, 2022
dfe9116
additional binary gphoto2-webapi configured
thorsten-l Jun 17, 2022
022f86e
json output for webapi added
thorsten-l Jun 17, 2022
d03c01c
webapi initial commit
thorsten-l Jun 17, 2022
92783ba
WEBAPI README added
thorsten-l Jun 17, 2022
454b129
describe clone with submodule
thorsten-l Jun 17, 2022
1b2ef40
gphoto2-webapi binary added to ignore list
thorsten-l Jun 18, 2022
bcd3cf3
downloaded images, add image info to json response
thorsten-l Jun 18, 2022
80014e8
add image_info also to capture-image
thorsten-l Jun 18, 2022
2c48bea
WEBAPI added to flags
thorsten-l Jun 18, 2022
e653345
get-file api implemented
thorsten-l Jun 18, 2022
f7967d7
a few responses added
thorsten-l Jun 18, 2022
e66d85a
using jsonc tag
thorsten-l Jun 18, 2022
e236a53
get-exif added
thorsten-l Jun 18, 2022
a5ffea4
Merge branch 'master' of https://github.com/thorsten-l/gphoto2
thorsten-l Jun 18, 2022
2ba7381
get-exif added
thorsten-l Jun 18, 2022
bc9ca86
remove several cli params
thorsten-l Jun 18, 2022
84d7b40
exif name to lower
thorsten-l Jun 18, 2022
9b7c75c
remove webapi flag
thorsten-l Jun 18, 2022
aa782c8
use webapi flag as parameter
thorsten-l Jun 18, 2022
81dea6e
own init of path and name
thorsten-l Jun 18, 2022
83b2eff
change api to match description
thorsten-l Jun 18, 2022
f322505
additional check for to short param
thorsten-l Jun 18, 2022
0209958
list-files added to webapi
thorsten-l Jun 19, 2022
4e78450
cleanup webapi
thorsten-l Jun 19, 2022
f4238de
clean up
thorsten-l Jun 19, 2022
08ea993
WEBAPI_SERVER_VERSION added
thorsten-l Jun 19, 2022
884225b
file/delete/... api added
thorsten-l Jun 19, 2022
5082419
clone and build info
thorsten-l Jun 19, 2022
69192b6
/api/file/get now returns HTTP 404 if file not exists
thorsten-l Jun 19, 2022
e59aa4a
reformat code
thorsten-l Jun 20, 2022
984eaf3
basic auth implemented
thorsten-l Jun 20, 2022
f8df221
capture image result now supports multiple files
thorsten-l Jun 20, 2022
6714b6c
'files' attr renamed to 'images'
thorsten-l Jun 20, 2022
237b1cf
'image_info' attr renamed to 'info'
thorsten-l Jun 20, 2022
c1add9a
auth (enabled,user,password) parameters added
thorsten-l Jun 20, 2022
4906da7
WEBAPI_SERVER_VERSION 0.0.2
thorsten-l Jun 20, 2022
f94d084
api get single config property
thorsten-l Jun 20, 2022
d87e6eb
get single config property
thorsten-l Jun 20, 2022
b8ec855
sample request and response for config/get added
thorsten-l Jun 20, 2022
5fc9783
useless 'puts' removed
thorsten-l Jun 20, 2022
ca5d070
remove mongoose submodule
thorsten-l Jun 20, 2022
b61d2a0
remove mongoose submodule
thorsten-l Jun 20, 2022
a4bb6b9
mongoose version 7.7 source added
thorsten-l Jun 20, 2022
6037d68
api config/set property added
thorsten-l Jun 20, 2022
054443e
WEBAPI_SERVER_VERSION 0.0.3
thorsten-l Jun 20, 2022
50730be
remove section - clone with submodule
thorsten-l Jun 21, 2022
0298ca8
api show-preview added
thorsten-l Jun 21, 2022
4b9b52c
WEBAPI_SERVER_VERSION 0.0.4
thorsten-l Jun 21, 2022
e70cf39
Add new *.c files to POTFILES.in for translation
ndim Jun 22, 2022
042964f
Add "make update-mongoose" target
ndim Jun 22, 2022
42c7849
First cleanup for gphoto2/Makefile.am
ndim Jun 22, 2022
8609149
Move macro definitions from _CFLAGS to _CPPFLAGS
ndim Jun 22, 2022
df04591
Make --version action print the program name
ndim Jun 22, 2022
cc39cf2
Fix #include "mongoose.h" lines to not use dir part
ndim Jun 22, 2022
ef3193f
Hook gphoto2-webapi/mongoose into --version code
ndim Jun 22, 2022
0ca6adf
Rename WEBAPI conditional to GPHOTO2_WEBAPI
ndim Jun 22, 2022
1343245
Clean up compile flags
ndim Jun 22, 2022
1d4b977
factor out common _SOURCES definitions
ndim Jun 22, 2022
6128ee9
simplify capture-preview source for webapi
thorsten-l Jun 22, 2022
b48f5f2
merge
thorsten-l Jun 22, 2022
82356e6
Remove aalib parts from gphoto2-webapi
ndim Jun 22, 2022
ff50cce
move webapi show_preview source from action.c to server.c
thorsten-l Jun 22, 2022
7c60bfe
/api/live-preview, about 1 frame per second (much space for improvement)
thorsten-l Jun 22, 2022
76fbed1
WEBAPI_SERVER_VERSION 0.0.5
thorsten-l Jun 22, 2022
3063176
store/load webapi config to/from HOME/.gphoto/webapi.config
thorsten-l Jun 22, 2022
ddb1e1a
WEBAPI_SERVER_VERSION 0.0.6
thorsten-l Jun 22, 2022
992601f
define config labels
thorsten-l Jun 23, 2022
e3c6327
remove print config on startup
thorsten-l Jun 23, 2022
3a1227a
remove output of config directory
thorsten-l Jun 23, 2022
374b98a
tabs to spaces
thorsten-l Jun 23, 2022
1e0c331
tabs to spaces
thorsten-l Jun 23, 2022
cdc506e
Merge pull request #1 from gphoto/master
thorsten-l Jun 25, 2022
1f14015
insert mongoose multi-thread example code for capture-movie (not fini…
thorsten-l Jun 25, 2022
1904bd2
capture-movie
thorsten-l Jun 25, 2022
4a362b9
WEBAPI_SERVER_VERSION 0.0.7
thorsten-l Jun 25, 2022
41c0c35
api live-preview replaced by capture-movie
thorsten-l Jun 26, 2022
64530c4
WEBAPI_SERVER_VERSION 0.0.8
thorsten-l Jun 26, 2022
8e3c808
add capture-movie api call
thorsten-l Jun 26, 2022
226b918
only one stream ist supported
thorsten-l Jun 26, 2022
77544fd
typo removed
thorsten-l Jun 26, 2022
b668cc4
reformat code
thorsten-l Jun 26, 2022
ee26b07
ignore .vscode folder
thorsten-l Jun 27, 2022
0061285
Access-Control-Allow-Origin * added to HTTP header
thorsten-l Jun 28, 2022
42bc257
remove debug output
thorsten-l Jun 28, 2022
ae03ebe
html-root parameter added to deliver html pages
thorsten-l Jun 28, 2022
3ad0604
WEBAPI_SERVER_VERSION 0.0.9
thorsten-l Jun 28, 2022
e18c429
access control origin was missing for server shutdown
thorsten-l Jul 3, 2022
ff6680c
WEBAPI_SERVER_VERSION 0.0.10
thorsten-l Jul 3, 2022
ed9e965
store auth password base64 encoded
thorsten-l Jul 4, 2022
785701f
WEBAPI_SERVER_VERSION 0.0.11
thorsten-l Jul 4, 2022
4a8e225
more access control allow added
thorsten-l Jul 10, 2022
a4da63b
WEBAPI_SERVER_VERSION 0.0.12
thorsten-l Jul 10, 2022
6c35cb1
rtrim current value in MENU
thorsten-l Jul 11, 2022
414b77e
WEBAPI_SERVER_VERSION 0.0.13
thorsten-l Jul 11, 2022
3fba881
file/get/... use allway mimetype application/octet-stream (download i…
thorsten-l Jul 11, 2022
db945f2
new /api/file/download/... call
thorsten-l Jul 11, 2022
4f7bd17
/api/file/download added
thorsten-l Jul 11, 2022
3063d87
WEBAPI_SERVER_VERSION 0.0.14
thorsten-l Jul 11, 2022
4885ad5
Merge pull request #2 from gphoto/master
thorsten-l Mar 26, 2023
985c61f
Merge pull request #3 from gphoto/master
thorsten-l Apr 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ snap/.snapcraft
*.x86_64
*.hex
gphoto2/gphoto2
gphoto2/gphoto2-webapi

# Debug files
*.dSYM/
Expand All @@ -56,6 +57,9 @@ gphoto2/gphoto2
.dirstamp
po/*.header

# Visual Studio Code
.vscode/

auto-m4/
auto-aux/
Makefile
Expand Down
35 changes: 35 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,38 @@ all-local:
# Dummy target to force Automake to make the "distclean" target depend on it
distclean-local:
@:

# Where to get mongoose from
MONGOOSE_REPO = https://github.com/cesanta/mongoose.git
MONGOOSE_RELEASE = 7.7

# The files to copy from the upstream mongoose repo to gphoto2/mongoose/
MONGOOSE_FILES =
MONGOOSE_FILES += README.md
MONGOOSE_FILES += LICENSE
MONGOOSE_FILES += mongoose.c
MONGOOSE_FILES += mongoose.h

# Update local copy of mongoose source to latest mongoose release
update-mongoose:
@set -ex; \
test -f "$(srcdir)/.git/config"; \
if test -f mongoose-repo/.git/config; then \
(cd mongoose-repo; git fetch -v); \
else \
git clone '$(MONGOOSE_REPO)' mongoose-repo; \
fi; \
(cd mongoose-repo; \
latest="$$(git tag --sort=version:refname | tail -n1)"; \
if test "x$(MONGOOSE_RELEASE)" = "x$$latest"; then :; else \
echo "The latest upstream mongoose release is $$latest."; \
echo "We still have MONGOOSE_RELEASE=$(MONGOOSE_RELEASE) in Makefile.am."; \
echo "To update our mongoose copy to $$latest, update Makefile.am to"; \
echo "MONGOOSE_RELEASE=$${latest} and re-run 'make update-mongoose'."; \
exit 1; \
fi; \
git checkout "$$latest" ); \
for f in $(MONGOOSE_FILES); do \
cp -f "mongoose-repo/$$f" "$(srcdir)/gphoto2/mongoose/$$f"; \
done; \
(cd "$(srcdir)"; git diff gphoto2/mongoose)
258 changes: 258 additions & 0 deletions README_WEBAPI_SERVER.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
# GPhoto2 WEBAPI Server

I need to control my camera via a small embedded controller so i decided to implement this little server direct into the wonderful gphoto2 application.

2022 June, Thorsten Ludewig ([email protected])

## Run server

`gphoto2-webapi --server` default port 8866

binding to a different port

`gphoto2-webapi --server-url=http://0.0.0.0:9999 --server`

binding to a specific ip and or port

`gphoto2-webapi --server-url=http://127.0.0.1:8866 --server`

## API Calls - all HTTP GET

Nearly all responses are [JSON](https://json.org) formated.

### general

- `http://<server ip>:8866/`

version information for now

- `http://<server ip>:8866/api/version`

version information

- `http://<server ip>:8866/api/auto-detect`

show detected camera info
```jsonc
{
result: [
{
model: "Canon EOS 550D",
port: "usb:003,005"
}
],
return_code: 0
}
```

- `http://<server ip>:8866/api/trigger-capture`

trigger capture image

- `http://<server ip>:8866/api/capture-image`

response

```jsonc
{
images: [
{
info: {
name: "IMG_0322.CR2",
folder: "/store_00020001/DCIM/100CANON",
path: "/store_00020001/DCIM/100CANON/IMG_0322.CR2",
mtime: 1655724028,
size: 21937775,
type: "image/x-canon-cr2"
},
download: false
},
{
info: {
name: "IMG_0322.JPG",
folder: "/store_00020001/DCIM/100CANON",
path: "/store_00020001/DCIM/100CANON/IMG_0322.JPG",
mtime: 1655724026,
size: 4038986,
height: 3456,
width: 5184,
type: "image/jpeg"
},
download: false
}
],
return_code: 0
}
```

- `http://<server ip>:8866/api/capture-image-download`

response

```jsonc
{
images: [
{
info: {
name: "IMG_0321.CR2",
folder: "/store_00020001/DCIM/100CANON",
path: "/store_00020001/DCIM/100CANON/IMG_0321.CR2",
mtime: 1655723756,
size: 21888193,
type: "image/x-canon-cr2"
},
download: true,
local_folder: "/home/user/Projects/gphoto2",
keeping_file_on_camera: true
},
{
info: {
name: "IMG_0321.JPG",
folder: "/store_00020001/DCIM/100CANON",
path: "/store_00020001/DCIM/100CANON/IMG_0321.JPG",
mtime: 1655723756,
size: 4113431,
height: 3456,
width: 5184,
type: "image/jpeg"
},
download: true,
local_folder: "/home/user/Projects/gphoto2",
keeping_file_on_camera: true
}
],
return_code: 0
}
```

- `http://<server ip>:8866/api/show-preview`

show preview image

- `http://<server ip>:8866/api/capture-movie`

online preview as motion jpeg stream

*ATTENTION: Only one stream is supported!*

### server

- `http://<server ip>:8866/api/server/shutdown`

shutdown http server

### config

- `http://<server ip>:8866/api/config/list`

list available config names

- `http://<server ip>:8866/api/config/list-all`

list config including current and available config values

- `http://<server ip>:8866/api/config/set-index/<config name>?i=<index value>`

set the `config name` to the specified `index value`

- `http://<server ip>:8866/api/config/get/<config name>`

get single config property

sample request

`http://localhost:8866/api/config/get/main/imgsettings/colorspace`

response

```jsonc
{
path: "/main/imgsettings/colorspace",
label: "Farbraum",
readonly: false,
type: "MENU",
current: "sRGB",
choice: [
{
index: 0,
value: "sRGB"
},
{
index: 1,
value: "AdobeRGB"
}
],
return_code: 0
}
```

- `http://<server ip>:8866/api/config/set/<config name>?v=<value>`

set the `config name` to the specified `value`

### file

- `http://<server ip>:8866/api/file/get/<path to file/image>`

response - native file

- `http://<server ip>:8866/api/file/exif/<path to image>`

response

```jsonc
{
make: "Canon",
model: "Canon EOS 550D",
orientation: "Oben links",
xresolution: "72",
yresolution: "72",
...
}
```

- `http://<server ip>:8866/api/file/list/<path to folder>`

response

```jsonc
{
path: "/store_00020001/DCIM/",
files: [
{
name: "100CANON",
isFolder: true
}
],
entries: 1,
return_code: 0
}
```

- `http://<server ip>:8866/api/file/delete/<path to file>`

remove specified file

## Mongoose HTTP Server - LICENSE

https://github.com/cesanta/mongoose


```
Copyright (c) 2004-2013 Sergey Lyubka
Copyright (c) 2013-2021 Cesanta Software Limited
All rights reserved

This software is dual-licensed: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation. For the terms of this
license, see <http://www.gnu.org/licenses/>.

You are free to use this software under the terms of the GNU General
Public License, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

Alternatively, you can license this software under a commercial
license, as set out in <https://mongoose.ws/licensing/>.
```
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ AM_INIT_AUTOMAKE([
dist-bzip2
dist-xz
check-news
subdir-objects
])

GP_CHECK_SHELL_ENVIRONMENT
Expand Down
Loading