Commit e054bb8
[AVAnalysis] Server Implementation with Remote Context Detection (project-chip#73360)
* [AVAnalysis] Cleanups: dedupe test mock, guard delegate derefs, remove dead code
- Extract duplicated MockAvAnalysisDelegate into tests/MockAvAnalysisDelegate.h
- Null-guard mDelegate use in Shutdown() and LoadPersistentAttributes()
- Remove stray kMaxSpeakerLevel and unused CameraAvSettingsUserLevelManagement includes
- Register AvAnalysisStorage.h in BUILD.gn
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [AVAnalysis] Add fixed-capacity stream table backing the REMCONDETECT attributes
- New AnalysisStreamTable: single fixed allocation sized by MaxAnalysisStreamCount,
entries keyed by the camera-provided AnalysisStreamID (the VideoStreamID returned
by VideoStreamAllocate), created in PendingInitiation state
- MaxAnalysisStreamCount becomes a constructor parameter, matching its Fixed
quality; Startup() requires it to be non-zero iff RemoteContextDetection and
initializes the table; the runtime setter is removed
- CurrentAnalysisStreamCount is now derived from the table count and
AnalysisStreams encodes from the table, keeping the two attributes consistent
by construction
* [AVAnalysis] Persist AnalysisStreams and TrackingEnabled
* [AVAnalysis] Introduce AvAnalysisCameraClient for camera-facing interactions
- Remove unused placeholder stream methods from AvAnalysisDelegate;
- Camera stream allocation/deallocation will be performed by the cluster
itself through AvAnalysisCameraClient
* [AVAnalysis] Add DefaultAvAnalysisCameraClient
- AvAnalysisCameraClient: reaches the camera via
CASESessionManager and sends VideoStreamAllocate (StreamUsage=Analysis,
default constraints) / VideoStreamDeallocate with a CommandSender
- Camera response status is propagated to the callback per spec;
* [AVAnalysis] Implement EstablishAnalysisStream
- The command response waits on the camera's
VideoStreamAllocate response; camera status is propagated and
EstablishAnalysisStreamResponse carries the camera-assigned stream id
- Stream entries record the camera node (survives reboot); persistence format
becomes {id, nodeId, fabric} since session state is reset on restore
* [AVAnalysis] Implement RemoveAnalysisStream
- VideoStreamDeallocate is sent to the camera
- On success the entry is removed, counts updated and the table persisted
* [AVAnalysis] Fix issues from CI
* [AVAnalysis] Make Activate/Deactivate placeholders respond INVALID_IN_STATE
Session activation is implemented in a follow-up PR; until then no stream can
leave PendingInitiation, so INVALID_IN_STATE is the accurate response rather
than a misleading SUCCESS. Tests updated accordingly.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [AVAnalysis] Include feature-conditional Watermark/OSD fields in VideoStreamAllocate
Cameras with the Watermark/OSD features require WatermarkEnabled/OSDEnabled
to be present in VideoStreamAllocate (feature-conditional conformance) and
reject the command otherwise. Add SetCameraVideoTraits() so the application
declares the camera's features; discovery from the camera's FeatureMap is a
TODO. Found by two-application testing against the Linux camera-app.
* [AVAnalysis] Lower default VideoStreamAllocate max bitrate to 2 Mbps
* [AVAnalysis] Cancel in-flight camera interactions on cluster shutdown
* [AVAnalysis] Gate camera-bound commands on the in-flight interaction
The Busy gate used pending-command-handle validity, but the handle is
invalidated when the invoking client's exchange closes while the camera
interaction is still running; a second command in that window started a
second interaction and could be completed with the first one's result.
Track the interaction explicitly, answer Busy while it is in flight, and
map the camera client's CHIP_ERROR_BUSY to a Busy status.
* [AVAnalysis] Release camera streams orphaned by table-insertion failure
If VideoStreamAllocate succeeds but the stream table rejects the id,
the allocated camera stream had no owner and could never be removed.
Request its deallocation before failing the command.
* [AVAnalysis] Introduce CameraProfile in the camera client
VideoStreamAllocate requests are now built from a per-request CameraProfile
* [AVAnalysis] Make camera profile discovery asynchronous
Hold the session across a discovery phase between connection and command
send
* [AVAnalysis] Discover the camera's AVSM endpoint via Descriptor read
* [AVAnalysis] Read the camera's AVSM capabilities into the profile
After the Descriptor read locates the AVSM endpoint, a second targeted
read fetches FeatureMap, VideoSensorParams, RateDistortionTradeOffPoints
and SupportedStreamUsages from it. The allocate request bounds now come
from the camera: Watermark/OSD traits from the feature bits, maximum
resolution and frame rate from the sensor parameters. A camera whose
SupportedStreamUsages lacks Analysis fails the request with
INVALID_IN_STATE before any allocation is attempted. Fields the camera
does not report keep their configured defaults.
* [AVAnalysis] Make camera discovery authoritative in the camera client
Init no longer takes the camera's AVSM endpoint and SetCameraVideoTraits
is removed: the endpoint, the Watermark/OSD traits and the stream
constraints all come from the discovery reads. A camera on which no
CameraAVStreamManagement endpoint is found now fails the request instead
of falling back to a configured endpoint.
* [AVAnalysis] Do not deallocate a camera stream on a duplicate stream id
* [AVAnalysis] Model the in-flight camera interaction as a state machine
* [AVAnalysis] Reconcile the stream table even when the command exchange died
The camera's answer is ground truth regardless of whether the invoking
client is still listening. A successful allocation whose client exchange
timed out was previously never added to the table, leaking the camera
stream with no way to remove it; a successful deallocation in the same
situation left a permanently stuck table entry. The table mutations now
happen unconditionally on a Success completion; only the command
response requires the parked handler to still be alive.
* [AVAnalysis] Generate AnalysisStreamIDs in the cluster
AnalysisStreamIDs are now cluster-generated instead of reusing the
camera-assigned VideoStreamID, which is camera-scoped and could collide
across cameras. The VideoStreamID is kept internally per entry for the
camera-bound commands; it and the id counter persist across reboots.
Re-establishing an already-tracked camera stream returns the existing
analysis stream id, making retries idempotent.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* [AVAnalysis] Re-verify the camera session before each discovery read
* [AVAnalysis] Scope the response-delivered flag to one command interaction
* [AVAnalysis] List the camera client sources in the CMake build
* [AVAnalysis] Answer NOT_FOUND for unknown streams in the Activate stubs
* [AVAnalysis] Skip the capabilities read for deallocation requests
* [AVAnalysis] Fixes in the camera-interaction completion paths
* [AVAnalysis] Name camera stream ids for what they are in the client interface
* [AVAnalysis] Allocate the CommandSender through the CHIP platform allocator
* [AVAnalysis] Follow the spec on stream ids and the Remove status
* Discover camera profile
* Fix complete, abort and typos
* CI Fix
* Address coderabbit review comments
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Pradip De <pradipd@google.com>1 parent f43bc3a commit e054bb8
18 files changed
Lines changed: 3301 additions & 206 deletions
File tree
- examples/camera-app/linux
- include/clusters/av-analysis
- src/clusters/av-analysis
- src/app/clusters/av-analysis-server
- tests
Lines changed: 0 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | 41 | | |
62 | 42 | | |
63 | 43 | | |
| |||
Lines changed: 0 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 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 | 35 | | |
68 | 36 | | |
69 | 37 | | |
| |||
Lines changed: 95 additions & 0 deletions
| 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 | + | |
Lines changed: 113 additions & 0 deletions
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| |||
40 | 37 | | |
41 | 38 | | |
42 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
| |||
97 | 99 | | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 102 | | |
106 | 103 | | |
107 | 104 | | |
| |||
0 commit comments