Commit 502d6c6
committed
Replace rpicam-still/rpicam-vid with picamera2 daemon, add WebSocket live stream
Camera daemon (single-process, eliminates capture vs stream contention):
- picamera2_daemon.py: standalone daemon owning Picamera2 instance
- Continuous grab loop in daemon thread
- Shared memory for JPEG stream (dynamically sized from stream resolution)
- Unix socket IPC for controls, capture, metadata, sensor info
- OSD overlay via original indi-allsky overlay modules (orb, cardinals,
moon texture, Pillow text with # color/xy/anchor/size directives)
- Stream resolution/quality/OSD state persisted to config DB
- picamera2_client.py: zero-dependency client for capture worker and Flask
- Resource tracker unregister to prevent shm deletion on client exit
- libcamera.py: setCcdExposure uses daemon client instead of rpicam-still
- Async capture via background thread, sync via blocking wait
- Metadata from daemon instead of JSON file parsing
- findCcd queries daemon for live sensor info
- No colorspace conversions (BGR throughout)
- stream_overlay.py: imports real overlay modules (orb, cardinals, moon),
translates config from DB, renders with Pillow (TrueType fonts, Unicode)
WebSocket live stream:
- Flask WebSocket endpoint reads directly from daemon shared memory
- Binary frame protocol: [4B JSON len][metadata JSON][JPEG data]
- Metadata: exposure, gain, lux, colour_temp, sensor_temp, WB gains
- Sends latest frame immediately on connect (no stall during long exposures)
- Metadata RPC cached at 1s intervals (not per frame)
- AllskyPlayer JS: canvas-based WS player with MJPEG fallback, OSD bar
- Camera controls: unified sliders (gain, exposure, brightness, contrast,
target ADU, JPEG quality), resolution selector, OSD toggle
- All controls send to daemon via stream update API
Flask/gunicorn:
- wsgi.py: root redirect middleware for direct SSL without reverse proxy
- captureapi_views.py: MJPEGStreamManager reads from daemon shared memory,
_stop_allsky/_start_allsky removed (no camera contention),
SensorInfoMethodView queries daemon, stream update sends to daemon
- flask-sock added to requirements for WebSocket support
Infrastructure:
- picamera2-daemon.service: systemd unit (starts before indi-allsky)
- activate-indi-allsky.sh / activate-allsky-ng.sh: switching scripts
- Runs on HTTPS/443 via gunicorn SSL — no Apache/nginx needed1 parent b611971 commit 502d6c6
15 files changed
Lines changed: 3501 additions & 350 deletions
File tree
- indi_allsky
- camera
- flask
- static
- css
- js
- templates
- requirements
- service
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments