lima-plugin-webrtc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lima_plugin_webrtc-0.1.0/.gitignore +29 -0
- lima_plugin_webrtc-0.1.0/.gitlab-ci.yml +65 -0
- lima_plugin_webrtc-0.1.0/PKG-INFO +14 -0
- lima_plugin_webrtc-0.1.0/README.md +75 -0
- lima_plugin_webrtc-0.1.0/docs/index.md +171 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/PKG-INFO +14 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/SOURCES.txt +25 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/dependency_links.txt +1 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/entry_points.txt +3 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/requires.txt +9 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/scm_file_list.json +21 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/scm_version.json +8 -0
- lima_plugin_webrtc-0.1.0/lima_plugin_webrtc.egg-info/top_level.txt +2 -0
- lima_plugin_webrtc-0.1.0/pyproject.toml +35 -0
- lima_plugin_webrtc-0.1.0/setup.cfg +4 -0
- lima_plugin_webrtc-0.1.0/src/H264VideoStream.py +1797 -0
- lima_plugin_webrtc-0.1.0/src/lima_1_11/H264VideoStream.py +1807 -0
- lima_plugin_webrtc-0.1.0/src/viewer/__init__.py +0 -0
- lima_plugin_webrtc-0.1.0/src/viewer/common.py +56 -0
- lima_plugin_webrtc-0.1.0/src/viewer/snapshot.py +82 -0
- lima_plugin_webrtc-0.1.0/src/viewer/viewer.html +350 -0
- lima_plugin_webrtc-0.1.0/src/viewer/viewer.py +225 -0
- lima_plugin_webrtc-0.1.0/tests/conftest.py +38 -0
- lima_plugin_webrtc-0.1.0/tests/data/lima_h264.yml +12 -0
- lima_plugin_webrtc-0.1.0/tests/test_e2e_simulator.py +71 -0
- lima_plugin_webrtc-0.1.0/tests/test_h264_views.py +226 -0
- lima_plugin_webrtc-0.1.0/tests/test_y32.py +41 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
*~
|
|
2
|
+
*.pyc
|
|
3
|
+
*.o
|
|
4
|
+
*.P
|
|
5
|
+
*.d
|
|
6
|
+
*.so
|
|
7
|
+
\#*\#
|
|
8
|
+
*target*
|
|
9
|
+
*.bck
|
|
10
|
+
*.bak
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
*.egg-info/
|
|
15
|
+
*.egg
|
|
16
|
+
build/
|
|
17
|
+
dist/
|
|
18
|
+
.eggs/
|
|
19
|
+
|
|
20
|
+
# Test / coverage
|
|
21
|
+
.pytest_cache/
|
|
22
|
+
.coverage
|
|
23
|
+
|
|
24
|
+
# Docs build output
|
|
25
|
+
site/
|
|
26
|
+
public/
|
|
27
|
+
|
|
28
|
+
# Python cache
|
|
29
|
+
__pycache__/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
stages:
|
|
2
|
+
- style
|
|
3
|
+
- tests
|
|
4
|
+
- build
|
|
5
|
+
- publish
|
|
6
|
+
|
|
7
|
+
check_style:
|
|
8
|
+
stage: style
|
|
9
|
+
tags:
|
|
10
|
+
- linux
|
|
11
|
+
image: condaforge/miniforge3
|
|
12
|
+
script:
|
|
13
|
+
- pip install "black==26.*"
|
|
14
|
+
- black --check --safe .
|
|
15
|
+
interruptible: true
|
|
16
|
+
|
|
17
|
+
check_lint:
|
|
18
|
+
stage: style
|
|
19
|
+
tags:
|
|
20
|
+
- linux
|
|
21
|
+
image: condaforge/miniforge3
|
|
22
|
+
script:
|
|
23
|
+
- pip install flake8 flake8-pyproject
|
|
24
|
+
- flake8
|
|
25
|
+
interruptible: true
|
|
26
|
+
allow_failure: true
|
|
27
|
+
|
|
28
|
+
test:
|
|
29
|
+
stage: tests
|
|
30
|
+
tags:
|
|
31
|
+
- linux
|
|
32
|
+
image: condaforge/miniforge3
|
|
33
|
+
script:
|
|
34
|
+
- mamba create -q -y --name test -c esrf-bcu -c conda-forge python=3.13 lima-tango-server lima-camera-simulator lima-camera-simulator-tango av pillow pytango
|
|
35
|
+
- source activate test
|
|
36
|
+
- pip install aiortc
|
|
37
|
+
- pip install .[test]
|
|
38
|
+
- pytest tests/
|
|
39
|
+
interruptible: true
|
|
40
|
+
|
|
41
|
+
sdist:
|
|
42
|
+
stage: build
|
|
43
|
+
tags:
|
|
44
|
+
- linux
|
|
45
|
+
image: condaforge/miniforge3
|
|
46
|
+
variables:
|
|
47
|
+
GIT_DEPTH: 0 # setuptools-scm needs the tags to derive the version
|
|
48
|
+
script:
|
|
49
|
+
- pip install build
|
|
50
|
+
- python -m build
|
|
51
|
+
artifacts:
|
|
52
|
+
paths:
|
|
53
|
+
- dist
|
|
54
|
+
expire_in: 7 days
|
|
55
|
+
|
|
56
|
+
pypi:
|
|
57
|
+
stage: publish
|
|
58
|
+
tags:
|
|
59
|
+
- linux
|
|
60
|
+
image: condaforge/miniforge3
|
|
61
|
+
script:
|
|
62
|
+
- pip install twine
|
|
63
|
+
- twine upload dist/*
|
|
64
|
+
rules:
|
|
65
|
+
- if: $CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+$/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lima-plugin-webrtc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: H264/WebRTC video streaming plugin for the LimaCCDs Tango device server
|
|
5
|
+
Project-URL: Homepage, https://gitlab.esrf.fr/limagroup/lima-plugin-webrtc
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: aiortc
|
|
8
|
+
Requires-Dist: av
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: Pillow
|
|
11
|
+
Requires-Dist: pytango
|
|
12
|
+
Provides-Extra: test
|
|
13
|
+
Requires-Dist: pytest; extra == "test"
|
|
14
|
+
Requires-Dist: nosqltangodb; extra == "test"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# lima-plugin-webrtc
|
|
2
|
+
|
|
3
|
+
Low-latency H264/WebRTC video streaming plugin for the [LImA](https://lima.blissgarden.org) Tango device server, plus on-demand JPEG/PNG snapshots.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install in the same conda environment as the `LimaCCDs` server.
|
|
8
|
+
|
|
9
|
+
First install `av` and `pillow` via conda rather than pip, so that `av`'s native ffmpeg library dependencies are handled correctly:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
mamba install -c conda-forge av pillow
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`pillow` can be installed from either conda-forge or PyPI. Installing both beforehand satisfies the plugin's own dependency on them, so `pip install` won't try to build them itself.
|
|
16
|
+
|
|
17
|
+
Then install the plugin, which pulls in `aiortc` from PyPI:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install lima-plugin-webrtc
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
An editable install (`pip install -e .`) does not work: LimaCCDs finds plugins by listing the files in its own `plugins` directory, so the plugin has to be installed into it.
|
|
24
|
+
|
|
25
|
+
### Lima version compatibility
|
|
26
|
+
|
|
27
|
+
Both Lima-tango-python 1.11 and 1.12+ are supported. The plugin is installed into both `Lima.Server.plugins` (1.11) and `lima.server.plugins` (1.12+); LimaCCDs only loads the one matching its own version.
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
Frames are only produced while the main `LimaCCDs` device has `video_live` set to `True`.
|
|
32
|
+
|
|
33
|
+
### Snapshot
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
LimaH264Snapshot <instance|device> <output_path> [--format JPEG|PNG] [--quality N]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Browser viewer
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
LimaH264Viewer <instance|device> [--host HOST] [--port N]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then open `http://<host>:<port>/` in a browser.
|
|
46
|
+
|
|
47
|
+
### From Python
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
import tango
|
|
51
|
+
|
|
52
|
+
dev = tango.DeviceProxy("id00/h264videostream/simulator1")
|
|
53
|
+
image_format, data = dev.SaveLastVideoImage("JPEG:90")
|
|
54
|
+
|
|
55
|
+
with open(f"snapshot.{image_format.lower()}", "wb") as f:
|
|
56
|
+
f.write(data)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Documentation
|
|
60
|
+
|
|
61
|
+
See [docs/index.md](docs/index.md) for full documentation: properties, commands, attributes, stream views, and WebRTC flow.
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
The tests start a real `LimaCCDs` with the simulator camera against an in-memory Tango database ([nosqltangodb](https://gitlab.esrf.fr/bliss/nosql-tango-db)). The esrf-bcu simulator builds need Python 3.13.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mamba create -n h264-test -c esrf-bcu -c conda-forge python=3.13 lima-tango-server lima-camera-simulator lima-camera-simulator-tango av pillow pytango
|
|
69
|
+
mamba activate h264-test
|
|
70
|
+
pip install aiortc
|
|
71
|
+
pip install .[test]
|
|
72
|
+
pytest tests/
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Reinstall with `pip install .` after changing the plugin source.
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# H264VideoStream
|
|
2
|
+
|
|
3
|
+
A plugin device that streams the camera's live video feed as H264 over WebRTC, and can grab a full-size JPEG/PNG snapshot on demand.
|
|
4
|
+
|
|
5
|
+
Rather than a client polling the main `LimaCCDs` device's `video_last_image` attribute over Tango, this plugin polls `CtVideo.getLastImage()`/`getLastImageCounter()` directly, in the same process as `LimaCCDs` — the same accessor `LimaCCDs.py` itself uses for that attribute. Per-frame data never goes through Tango — only the one-time WebRTC signaling handshake does. It cannot instead register its own `CtVideo` image callback: only one can be registered at a time, and `LimaCCDs.py` already occupies that slot for `video_last_image` push events. The polling loop and its event loop thread only start on the first `JoinStream` call; `SaveLastVideoImage` reads the last frame directly and does not need them. Frames are only produced while the main `LimaCCDs` device has `video_live` set to `True`, since that is what drives the camera's video acquisition.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install in the same conda environment as the `LimaCCDs` server.
|
|
10
|
+
|
|
11
|
+
First install the dependencies. `av` (PyAV) wraps ffmpeg — in a conda environment use conda rather than pip so that the native library dependencies are handled correctly:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mamba install -c conda-forge av pillow
|
|
15
|
+
pip install aiortc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then install the plugin:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install lima-plugin-webrtc
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
An editable install (`pip install -e .`) does not work: LimaCCDs finds plugins by listing the files in its own `plugins` directory, so the plugin has to be installed into it.
|
|
25
|
+
|
|
26
|
+
LimaCCDs creates the plugin device itself at startup if it is not already in the Tango database, named after its own device: `id00/limaccds/simulator1` gives `id00/h264videostream/simulator1`.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Dependencies
|
|
30
|
+
|
|
31
|
+
- [aiortc](https://github.com/aiortc/aiortc) — WebRTC stack (H264 encoding, RTP, ICE/DTLS)
|
|
32
|
+
- [av](https://github.com/PyAV-Org/PyAV) (PyAV) — pixel format conversion (demosaic, colorspace)
|
|
33
|
+
- [Pillow](https://python-pillow.org/) — JPEG/PNG encoding for the snapshot command
|
|
34
|
+
|
|
35
|
+
## Supported video modes
|
|
36
|
+
|
|
37
|
+
Raw frames from `CtVideo` are converted via `libswscale` (through PyAV), which handles Bayer demosaicing and colorspace conversion in one step:
|
|
38
|
+
|
|
39
|
+
| Lima `VideoMode` | Notes |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `Y8`, `Y16` | Mono |
|
|
42
|
+
| `Y32` | Mono, scaled to 16 bits from the frame's own range (0..max, or the `normalize` range) |
|
|
43
|
+
| `RGB24`, `BGR24` | |
|
|
44
|
+
| `RGB32`, `BGR32` | Treated as packed RGBA/BGRA |
|
|
45
|
+
| `BAYER_RG8`, `BAYER_RG16` | Demosaiced by libswscale |
|
|
46
|
+
| `BAYER_BG8`, `BAYER_BG16` | Demosaiced by libswscale |
|
|
47
|
+
| `YUV422PACKED` | `uyvy422` |
|
|
48
|
+
|
|
49
|
+
Other `YUV411/422/444` modes (planar or `PACKED`) are not mapped — frames in those modes are dropped with a `warn_stream` log line rather than streamed.
|
|
50
|
+
|
|
51
|
+
For the 16-bit-container modes (`Y16`, `BAYER_RG16`, `BAYER_BG16`), a sensor with a native depth below 16 bits (e.g. a 12-bit Basler sensor) leaves its raw values unscaled in the low bits of each 16-bit sample, which renders as near-black. This is detected from the camera's own `Bpp<N>` image type and corrected with a left-shift before the frame is converted or cached for a snapshot.
|
|
52
|
+
|
|
53
|
+
## Properties
|
|
54
|
+
|
|
55
|
+
| Property | Type | Default | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `MaxStreamWidth` | DevLong | 0 | Downscale streamed frames wider than this (`0` = no limit). Does not affect `SaveLastVideoImage`, which always uses the full-size frame. |
|
|
58
|
+
| `MaxStreamHeight` | DevLong | 0 | Downscale streamed frames taller than this (`0` = no limit). Same exemption as above. |
|
|
59
|
+
| `IceServers` | DevVarStringArray | [] | STUN/TURN server URLs for WebRTC ICE negotiation. Can be left empty when the viewer and server are on the same network segment. |
|
|
60
|
+
| `JpegQuality` | DevShort | 90 | Default JPEG quality (1–100) used by `SaveLastVideoImage` when no quality is given. |
|
|
61
|
+
| `DisconnectTimeout` | DevDouble | 30.0 | Seconds a WebRTC connection may stay in the `disconnected` state before it is force-closed, in case `LeaveStream` is never called (client crash, network drop). |
|
|
62
|
+
| `IceHostAddress` | DevString | "" | If set, only advertise this IP as a host ICE candidate to viewers, dropping any others (e.g. a Docker bridge interface also present on the server machine). |
|
|
63
|
+
| `StreamMaxBitrate` | DevLong | 3000 | Ceiling (kbps) the H264 encoder's bitrate may reach via WebRTC congestion-control (REMB) feedback. |
|
|
64
|
+
| `StreamMaxFPS` | DevDouble | 10.0 | How often (Hz) the plugin looks for a new camera frame to convert for WebRTC viewers (`0` = 30). Frames arriving faster than this are skipped before the (relatively expensive) pixel conversion. Read once at startup. |
|
|
65
|
+
| `StreamMinBitrate` | DevLong | 0 | Floor and starting bitrate (kbps) of the H264 encoder; `0` keeps aiortc's own defaults. Read once at startup. |
|
|
66
|
+
| `DiagLog` | DevBoolean | False | Print `DIAG` lines to the device server's stdout: encoder rebuilds, encode rate, bytes per frame and bitrate. For diagnosing stream quality; off by default. Read at startup. |
|
|
67
|
+
| `H264Preset` | DevString | "medium" | libx264 preset (speed/quality tradeoff, e.g. `ultrafast`..`veryslow`). |
|
|
68
|
+
| `H264Profile` | DevString | "baseline" | H264 profile: `baseline` (Constrained Baseline, decodes everywhere) or `high` (better compression). |
|
|
69
|
+
| `H264Threads` | DevLong | 0 | Thread count for the libx264 encoder (`0` = automatic). Read once at startup. |
|
|
70
|
+
| `H264AqMode` | DevLong | 1 | libx264 adaptive quantization mode (`0`=off, `1`=variance, `2`=auto-variance). |
|
|
71
|
+
| `H264AqStrength` | DevDouble | 1.0 | libx264 adaptive quantization strength. |
|
|
72
|
+
| `StreamViews` | DevVarStringArray | [] | Named stream views. See [Stream views](#stream-views). Read once at startup. |
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
| Command | In | Out | Description |
|
|
77
|
+
|---|---|---|---|
|
|
78
|
+
| `Start` | DevVoid | DevVoid | Set device state to ON. |
|
|
79
|
+
| `Stop` | DevVoid | DevVoid | Set device state to OFF. |
|
|
80
|
+
| `JoinStream` | DevString — SDP offer | DevVarStringArray — `[connection_id, SDP answer]` | Start a new WebRTC viewer session. |
|
|
81
|
+
| `JoinStreamView` | DevVarStringArray — `[SDP offer, view name]` | DevVarStringArray — `[connection_id, SDP answer]` | Like `JoinStream`, for a named view from `StreamViews`. An empty name gives the default view. An unknown name raises `UnknownView`. |
|
|
82
|
+
| `ListStreamViews` | DevVoid | DevVarStringArray | The names of the configured views. |
|
|
83
|
+
| `LeaveStream` | DevString — `connection_id` | DevVoid | Close a viewer's peer connection immediately. Not required — cleanup also happens automatically via `DisconnectTimeout`. |
|
|
84
|
+
| `SaveLastVideoImage` | DevString — `"JPEG"`, `"PNG"`, or `"JPEG:<quality>"` | DevEncoded — frame as JPEG or PNG bytes | Encode the latest full-size video frame. Raises `NoImage` if no frame has been received yet. |
|
|
85
|
+
|
|
86
|
+
## Attributes
|
|
87
|
+
|
|
88
|
+
| Attribute | rw | Type | Description |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `RunLevel` | rw | DevLong | Inherited from the base plugin class. |
|
|
91
|
+
| `normalize` | rw | DevString | Contrast-stretch frames before streaming/snapshot: `"off"` (default), `"minmax"`, or `"sigma3"` (mean ± 3 standard deviations). |
|
|
92
|
+
|
|
93
|
+
### Reading a snapshot from a client
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
import tango
|
|
97
|
+
|
|
98
|
+
dev = tango.DeviceProxy("id00/h264videostream/simulator1")
|
|
99
|
+
image_format, data = dev.SaveLastVideoImage("JPEG:90")
|
|
100
|
+
|
|
101
|
+
with open(f"snapshot.{image_format.lower()}", "wb") as f:
|
|
102
|
+
f.write(data)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## WebRTC viewing flow
|
|
106
|
+
|
|
107
|
+
1. Browser creates an `RTCPeerConnection`, adds a receive-only video transceiver, and generates an SDP offer via `createOffer()` / `setLocalDescription()`.
|
|
108
|
+
2. Some backend that can reach Tango (e.g. the web UI's server) calls `JoinStream(offer_sdp)` and gets back `[connection_id, answer_sdp]`.
|
|
109
|
+
3. That answer is relayed back to the browser, which calls `setRemoteDescription(answer)`.
|
|
110
|
+
4. ICE negotiation and DTLS-SRTP setup happen automatically; video then flows directly between the browser and the server.
|
|
111
|
+
5. When the viewer disconnects, call `LeaveStream(connection_id)` to free the peer connection immediately.
|
|
112
|
+
|
|
113
|
+
## Snapshot tool
|
|
114
|
+
|
|
115
|
+
`LimaH264Snapshot` calls `SaveLastVideoImage` and writes the result to a file, finding the plugin device through the `plugin_list` attribute of the root `LimaCCDs` device.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
LimaH264Snapshot basler01 snapshot.png [--format JPEG|PNG] [--quality N]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The format defaults to `PNG`. The argument is the `LimaCCDs` server instance name (resolved via the Tango database) or a full device name.
|
|
122
|
+
|
|
123
|
+
## Test viewer
|
|
124
|
+
|
|
125
|
+
`LimaH264Viewer` serves a minimal browser client for checking a stream without any other web UI. A browser cannot call Tango, so the viewer relays the WebRTC offer/answer to `JoinStream`/`LeaveStream`; the media itself still flows directly from the device to the browser.
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
LimaH264Viewer basler01 [--host 127.0.0.1] [--port 8811]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Then open `http://<host>:<port>/`. The page joins the stream on load, logs `framesDecoded` and frame size every two seconds, and leaves the stream when the tab closes.
|
|
132
|
+
|
|
133
|
+
When the plugin has `StreamViews`, the page shows a **View** selector. A **Normalize** selector sets the `normalize` attribute. The page also toggles `video_live` and sets `video_exposure`.
|
|
134
|
+
|
|
135
|
+
## Stream views
|
|
136
|
+
|
|
137
|
+
By default every viewer receives the full frame (under `MaxStreamWidth` and `MaxStreamHeight`). `StreamViews` adds named views, each a cropped and/or size-limited version of the frame:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
overview; scale/2
|
|
141
|
+
high-resolution; crop/2
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
- `crop=w:h:x:y` uses ffmpeg's `crop` order and expressions: numbers, `in_w`, `in_h`, `+ - * /` and parentheses. Evaluated on the displayed frame (after `image_rotation`), rounded down to even values.
|
|
145
|
+
- `size=w:h` sets the output size with the same expressions, where `in_w`/`in_h` are the size of the cropped region.
|
|
146
|
+
- `scale/N` and `crop/N` are shorthands, with `N` a plain integer ≥ 1. `scale/N` is `size=in_w/N:in_h/N`. `crop/N` is a centred crop of 1/N of each dimension at native pixels. Both can be combined (`detail; crop/4; scale/2`).
|
|
147
|
+
- `max=WxH` limits the output size keeping aspect ratio, applied last.
|
|
148
|
+
- Names may contain letters, digits, `-`, `_` and `.`. A bad or duplicate entry is skipped with a warning.
|
|
149
|
+
|
|
150
|
+
`normalize` applies to every view. Its statistics come from the whole frame so a crop and the overview show the same brightness for the same pixel values. `SaveLastVideoImage` always returns the full frame regardless of views.
|
|
151
|
+
|
|
152
|
+
## Image rotation
|
|
153
|
+
|
|
154
|
+
The stream and `SaveLastVideoImage` follow the main device's `image_rotation` (90, 180, 270) when the camera has its own video interface. `MaxStreamWidth`/`MaxStreamHeight` apply to the rotated frame. `image_flip` is not applied.
|
|
155
|
+
|
|
156
|
+
## Cleanup without a clean disconnect
|
|
157
|
+
|
|
158
|
+
A client is not guaranteed to call `LeaveStream` — the browser tab can crash or the network can drop. Cleanup also happens automatically via WebRTC's ICE/DTLS layer:
|
|
159
|
+
|
|
160
|
+
- `failed` or `closed` close the connection immediately.
|
|
161
|
+
- `disconnected` starts a `DisconnectTimeout`-second grace period; if the connection has not recovered to `connected` by then, it is force-closed.
|
|
162
|
+
|
|
163
|
+
`LeaveStream` and this automatic path share the same cleanup code and are idempotent with each other.
|
|
164
|
+
|
|
165
|
+
## Lima version compatibility
|
|
166
|
+
|
|
167
|
+
Both Lima-tango-python 1.11 and 1.12+ are supported. The plugin is installed into both `Lima.Server.plugins` (1.11) and `lima.server.plugins` (1.12+); LimaCCDs only loads the one matching its own version.
|
|
168
|
+
|
|
169
|
+
## Known limitations
|
|
170
|
+
|
|
171
|
+
- `YUV411/422/444` video modes (planar or `PACKED`) other than `YUV422PACKED` are not converted.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lima-plugin-webrtc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: H264/WebRTC video streaming plugin for the LimaCCDs Tango device server
|
|
5
|
+
Project-URL: Homepage, https://gitlab.esrf.fr/limagroup/lima-plugin-webrtc
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: aiortc
|
|
8
|
+
Requires-Dist: av
|
|
9
|
+
Requires-Dist: numpy
|
|
10
|
+
Requires-Dist: Pillow
|
|
11
|
+
Requires-Dist: pytango
|
|
12
|
+
Provides-Extra: test
|
|
13
|
+
Requires-Dist: pytest; extra == "test"
|
|
14
|
+
Requires-Dist: nosqltangodb; extra == "test"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
.gitlab-ci.yml
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
docs/index.md
|
|
6
|
+
lima_plugin_webrtc.egg-info/PKG-INFO
|
|
7
|
+
lima_plugin_webrtc.egg-info/SOURCES.txt
|
|
8
|
+
lima_plugin_webrtc.egg-info/dependency_links.txt
|
|
9
|
+
lima_plugin_webrtc.egg-info/entry_points.txt
|
|
10
|
+
lima_plugin_webrtc.egg-info/requires.txt
|
|
11
|
+
lima_plugin_webrtc.egg-info/scm_file_list.json
|
|
12
|
+
lima_plugin_webrtc.egg-info/scm_version.json
|
|
13
|
+
lima_plugin_webrtc.egg-info/top_level.txt
|
|
14
|
+
src/H264VideoStream.py
|
|
15
|
+
src/lima_1_11/H264VideoStream.py
|
|
16
|
+
src/viewer/__init__.py
|
|
17
|
+
src/viewer/common.py
|
|
18
|
+
src/viewer/snapshot.py
|
|
19
|
+
src/viewer/viewer.html
|
|
20
|
+
src/viewer/viewer.py
|
|
21
|
+
tests/conftest.py
|
|
22
|
+
tests/test_e2e_simulator.py
|
|
23
|
+
tests/test_h264_views.py
|
|
24
|
+
tests/test_y32.py
|
|
25
|
+
tests/data/lima_h264.yml
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".gitignore",
|
|
4
|
+
".gitlab-ci.yml",
|
|
5
|
+
"README.md",
|
|
6
|
+
"docs/index.md",
|
|
7
|
+
"pyproject.toml",
|
|
8
|
+
"src/H264VideoStream.py",
|
|
9
|
+
"src/lima_1_11/H264VideoStream.py",
|
|
10
|
+
"src/viewer/__init__.py",
|
|
11
|
+
"src/viewer/common.py",
|
|
12
|
+
"src/viewer/snapshot.py",
|
|
13
|
+
"src/viewer/viewer.html",
|
|
14
|
+
"src/viewer/viewer.py",
|
|
15
|
+
"tests/conftest.py",
|
|
16
|
+
"tests/data/lima_h264.yml",
|
|
17
|
+
"tests/test_e2e_simulator.py",
|
|
18
|
+
"tests/test_h264_views.py",
|
|
19
|
+
"tests/test_y32.py"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "setuptools_scm"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lima-plugin-webrtc"
|
|
7
|
+
description = "H264/WebRTC video streaming plugin for the LimaCCDs Tango device server"
|
|
8
|
+
urls = {Homepage = "https://gitlab.esrf.fr/limagroup/lima-plugin-webrtc"}
|
|
9
|
+
dynamic = ["version"]
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = ["aiortc", "av", "numpy", "Pillow", "pytango"]
|
|
12
|
+
|
|
13
|
+
[project.optional-dependencies]
|
|
14
|
+
test = ["pytest", "nosqltangodb"]
|
|
15
|
+
|
|
16
|
+
[tool.setuptools]
|
|
17
|
+
packages = ["Lima.Server.plugins", "lima.server.plugins", "lima.server.h264"]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.package-dir]
|
|
20
|
+
"Lima.Server.plugins" = "src/lima_1_11"
|
|
21
|
+
"lima.server.plugins" = "src"
|
|
22
|
+
"lima.server.h264" = "src/viewer"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.package-data]
|
|
25
|
+
"lima.server.h264" = ["viewer.html"]
|
|
26
|
+
|
|
27
|
+
[tool.setuptools_scm]
|
|
28
|
+
|
|
29
|
+
[tool.flake8]
|
|
30
|
+
# E501/E203: line length and slice whitespace are black's call, not flake8's.
|
|
31
|
+
extend-ignore = ["E203", "E501"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
LimaH264Viewer = "lima.server.h264.viewer:main"
|
|
35
|
+
LimaH264Snapshot = "lima.server.h264.snapshot:main"
|