feat(v2): add reconnecting FFmpeg stream source

This commit is contained in:
ila
2026-07-22 21:15:25 +08:00
parent 70d9c5c73e
commit 3edda4fb62
5 changed files with 388 additions and 9 deletions
@@ -98,7 +98,7 @@ git commit -m "feat(v2): add safe runtime configuration"
- Create: `v2/internal/source/stream_test.go`
- Modify: `docs/04-architecture.md`
- [ ] **Step 1: Write deterministic source tests before subprocess integration**
- [x] **Step 1: Write deterministic source tests before subprocess integration**
```go
func TestLatestFrameDropsStaleFrame(t *testing.T) {
@@ -114,12 +114,12 @@ func TestBackoffIsBoundedAndCancellationStopsRetry(t *testing.T) {
}
```
- [ ] **Step 2: Verify the tests fail**
- [x] **Step 2: Verify the tests fail**
Run: `Set-Location v2; go test ./internal/source -run 'Test(Latest|Backoff)' -v`
Expected: FAIL because `internal/source` does not exist.
- [ ] **Step 3: Implement probe and worker ownership**
- [x] **Step 3: Implement probe and worker ownership**
```go
type Status string
@@ -136,14 +136,12 @@ func Start(ctx context.Context, cfg Config, commands CommandFactory) (Stream, er
Use `-rtsp_transport`, `-rw_timeout`, low-latency FFmpeg input flags when configured, and `-f rawvideo -pix_fmt bgr24 -` output. Capture stderr internally but publish only a generic status code/message such as `视频流已断开,正在重连`; it must never contain command arguments or the RTSP URL. Cancellation kills the current process and closes channels exactly once.
- [ ] **Step 4: Run source tests and a safe invalid-source smoke**
- [x] **Step 4: Run source tests**
Run: `Set-Location v2; go test ./internal/source -v`
Expected: PASS.
Run: `go run ./cmd/silver-pose --config config.example.json`
Expected: clean missing-environment configuration error without an RTSP address.
Expected: PASS. The production command's missing-environment smoke is performed in Task 6 after `cmd/silver-pose` exists.
- [ ] **Step 5: Commit the source slice**
- [x] **Step 5: Commit the source slice**
```powershell
git add v2/internal/source docs/04-architecture.md