Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CXXFLAGS := $(CXXFLAGS) -DMAVLINK_SIGNING_TIMESTAMP_LIMIT=600
LIBS := -ltdb -lssl -lcrypto

# Source files
SOURCES := supportproxy.cpp mavlink.cpp util.cpp keydb.cpp conntdb.cpp tlog.cpp session.cpp binlog.cpp cleanup.cpp websocket.cpp video.cpp videoauth.cpp videots.cpp videostream.cpp videorec.cpp videoview.cpp httpreq.cpp videortsp.cpp videortmp.cpp videortspview.cpp
SOURCES := supportproxy.cpp mavlink.cpp util.cpp keydb.cpp conntdb.cpp tlog.cpp session.cpp binlog.cpp cleanup.cpp websocket.cpp video.cpp videoauth.cpp videots.cpp videostream.cpp videorec.cpp videoview.cpp videomux.cpp httpreq.cpp videortsp.cpp videortmp.cpp videortspview.cpp
OBJECTS := $(SOURCES:.cpp=.o)
TARGET := supportproxy

Expand Down Expand Up @@ -95,7 +95,8 @@ session.o: session.cpp session.h keydb.h
binlog.o: binlog.cpp binlog.h session.h mavlink.h util.h cleanup.h $(MAVLINK_DIR)/protocol.h
cleanup.o: cleanup.cpp cleanup.h keydb.h
websocket.o: websocket.cpp websocket.h util.h
video.o videoview.o: videomkv.h
video.o videoview.o videomux.o supportproxy.o: videomkv.h videomux.h videostream.h videots.h
videomux.o: videomux.cpp videortsp.h

video.o: video.cpp video.h videoauth.h videots.h videostream.h videorec.h videoview.h httpreq.h videortsp.h videortmp.h conntdb.h keydb.h util.h
videoauth.o: videoauth.cpp videoauth.h conntdb.h keydb.h
Expand All @@ -108,7 +109,7 @@ videoview.o: videoview.cpp videoview.h httpreq.h videostream.h videots.h videoau
httpreq.o: httpreq.cpp httpreq.h
videortsp.o: videortsp.cpp videortsp.h
video.o videoview.o videortspview.o: videortspview.h
videortspview.o: videortspview.cpp videoview.h videostream.h videomkv.h videots.h videoauth.h httpreq.h keydb.h
videortspview.o: videortspview.cpp videoview.h videomux.h videostream.h videomkv.h videots.h videoauth.h httpreq.h keydb.h
videortmp.o: videortmp.cpp videortmp.h httpreq.h

# Testing
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -849,3 +849,46 @@ Tests: `python3 -m pytest tests/test_video_matroska.py` covers authentication,
fragmentation, late joining, restart, slow viewers, malformed lengths and
recording rotation. The camera repository's `sitl/test_support_proxy.py
--raw-thermal --reconnect` additionally checks actual FFV1 pixels and telemetry.

### Combined RGB and raw thermal (two-track Matroska)

An entry that has an MPEG-TS slot (a camera's RGB stream, however it was
published) and a raw thermal slot can serve the two as one live Matroska
stream with two video tracks. A viewer asks for `/mux/A,B` on the port of
slot A, where A is the MPEG-TS slot and B the raw thermal slot, over HTTP or
WebSocket:

```text
wss://HOST:PORT_OF_SLOT_1/mux/1,3
```

The combined stream needs `ffmpeg` on the proxy host. It exists only while it
has viewers (and for 30 seconds after the last one leaves); with none, nothing
extra runs. While it does, a second sandboxed `ffmpeg` remuxes slot A's
MPEG-TS, without transcoding, into Matroska blocks. Thermal frames are copied
from the publisher's Clusters with their BlockAdditional telemetry unchanged.

- Access is by the entry's viewer password (`?pw=...`), or open viewing when
none is set. A viewer token names one slot and is not accepted.
- One pair per entry at a time, with at most 8 viewers. While the pair has
viewers, requests for another pair receive HTTP `409`. Over `wss://`, the
upgrade happens first, so a refused request closes the WebSocket.
- The stream starts once both slots are publishing. Until then a WebSocket
viewer waits; an HTTP viewer waits up to 5 seconds, then gets `503`.
- Each frame is its own Cluster. Cluster timestamps are milliseconds on the
proxy's clock and strictly increasing; they order and pace the stream but do
not align the two tracks exactly. Use the camera's time in each frame's
metadata for that.
- Info carries a random SegmentUID for each run of the combined stream, so a
reconnecting viewer can tell a continuation from a new stream.
- A viewer starts at the newest RGB keyframe. If either publisher stops, its
track goes quiet and the other continues; when it returns with the same
format it carries on (RGB from a keyframe). A changed format ends the
combined stream and its viewers reconnect to a new one.
- RGB with B-pictures is not carried; the thermal track still is.
- The combined stream is not recorded. Each slot's own **record** option is
unaffected, as are the slots' own viewers.

With a live viewer configured (`"live_viewer"`, as for raw thermal above), the
web video page links to the combined stream when the entry has a video slot
and a raw thermal slot publishing: the first of each.
9 changes: 9 additions & 0 deletions supportproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "video.h"
#include "videots.h"
#include "videostream.h"
#include "videomux.h"

#include <vector>

Expand Down Expand Up @@ -1633,6 +1634,14 @@ int main(int argc, char *argv[])
const uint32_t seed = argc > 3 ? uint32_t(atoi(argv[3])) : 1;
rc = videots_fuzz(iters, seed);
}
if (rc == 0) {
rc = videomux_selftest();
}
if (rc == 0) {
const unsigned iters = argc > 2 ? unsigned(atoi(argv[2])) : 2000;
const uint32_t seed = argc > 3 ? uint32_t(atoi(argv[3])) : 1;
rc = videomux_fuzz(iters, seed);
}
return rc;
}
// a peer-closed TCP/WS/SSL connection must fail the write with
Expand Down
Loading
Loading