Sources
連接 RTSP 或傳入測試影格
Source 是持久化影像輸入,保存期望狀態與可觀測的執行狀態。列表與查詢永遠不回傳密碼或未遮罩 RTSP URL。
先允許攝影機目的地
RTSP 預設全部拒絕。建立 Source 前,在 deploy/api/.env 設定精確 IP、host:port 或 CIDR,然後只重建 API service;不支援萬用字元。
SENTINEL_RTSP_ALLOWED_HOSTS=192.168.10.25:554
SENTINEL_RTSP_ALLOWED_CIDRS=192.168.10.0/24
docker compose config --quiet
docker compose up -d --no-deps --force-recreate apiDNS hostname 模式還需要操作文件列出的 firewall 與 residual-risk flags。初次設定請優先使用固定 IP 或精確 CIDR。
建立 RTSP Source
curl -X POST http://localhost:8000/v1/sources \
-H "Authorization: Bearer $SENTINEL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: site-a-loading-dock" \
-d '{
"name": "Loading dock",
"input": {
"type": "rtsp",
"url": "rtsp://user:password@camera.local/stream2"
}
}'input.url 只在建立或更換憑證時送入。回應只顯示 credentials_configured 與已淨化的連線資訊;不會把 URL 或密碼送回。每支攝影機建議使用專用唯讀帳號與低解析子碼流。
沒有攝影機時建立圖片 Source
POST /v1/sources
{
"name": "Integration test",
"input": {"type": "frame"}
}測試與影格 ingest
POST /v1/sources/{source_id}/test
POST /v1/sources/{source_id}/frames
Content-Type: image/jpeg
Idempotency-Key: frame-20260829-001
<raw JPEG bytes>frames 只接受有限的測試/自訂 ingest,不是影片儲存 API。伺服器在進入推理前檢查 Content-Type、byte 大小、JPEG 解碼與影像尺寸。
取得目前圖片
GET /v1/sources/{source_id}/image?view=preview
GET /v1/sources/{source_id}/image?view=inference兩者都回傳 binary image/jpeg、需要與 Source 相同的存取權,並使用 Cache-Control: no-store。沒有影格時回傳 503;不要將即時圖片當成不可變事件證據。
受限制的即時預覽
GET /v1/sources/{source_id}/stream?max_fps=15&max_height=720
Authorization: Bearer $SENTINEL_API_KEY
Content-Type: multipart/x-mixed-replace; boundary=frame此 endpoint 回傳受限制的 MJPEG 預覽,不是錄影或事件證據下載。需要 sources:read;max_fps 預設 15、允許 1–30,max_height 預設 0(保留來源尺寸)、允許 0–2160。串流不儲存且使用 Cache-Control: no-store。
Runtime 狀態
pending | connecting | online | degraded | offline | stoppedAPI 回報 runtime_state、last_frame_at 與已淨化的 status_code/status_message,讓整合方區分連線中、離線與串流錯誤。停用/重新啟用不會改變 src_* ID。
如果 Source response、log 或 error 中出現完整 RTSP URL/密碼,請視為安全漏洞並停止使用該 build。