Skip to content

Commit 47254d5

Browse files
Camera AV Stream Management Server Impl (#36204)
* Camera AV Stream Management Server Impl * Delegate definition - Support for list entries per index - Support for Command handlers * Server Impl - Attributes and Commands support -- Setters for Application to update values * Add attributes to json files * Autogen code changes to zzz_generated/ * Add Optional Attributes support * Add support logic for writable attributes. Modify feature checks for the attributes depending on their optionality and feature categories. * Remove some attributes to simplify AVStreamMgmt cluster slightly. Attributes related to White balance, ShutterSPeed, ISO and Depth sensor were removed based on feedback at the Nov member meeting. Also, adjustments for read/write mode changes for certain attributes. * Remove redundant CurrentSnapshotConfig and CurrentVideoCodecs attributes Fix name of MaxFramRate in Snapshot Allocation functions. * Add write support for ImageRotation, ImageFlipHorizontal and ImageFlipVertical attributes. * Add handler for the SetStreamPriorities command. * Retrieve persistent attributes from storage during initialization. * Miscellaneous syntactic fixes to CameraAVStreamMgmt. * Add persistence for Viewport struct attribute * Make CameraAVStreamMgmt handle list attributes inside cluster server implementation. Add Getter functions for cluster attributes. * Add Delegate functions for loading pre-allocated streams. Add persistence support for the ranked video stream priorities attribute. * Doc updates and adjustments based on latest Spec changes. * Address review comments. * Make watermark and OSD optional args. * Fix * Add feature and optional flags check in Init * Modify SetStreamPriorities * Add error handling for command params. * Add CameraAvStreamMgmt cluster partially inside all-clusters-app.zap config Make the snapshot attributes and commands of the CameraStreamMgmt cluster be part of the all-clusters-app(in a minimalistic way) to exercise the cluster. * Add more constraint checking for command params. Add a delegate notification callback for attribute changes. Address other review comments. * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Restyle fixes. * Add CameraAVStreamMgmt cluster to EP1 of camera-app.zap. * Remove Enum validation functions. * Address review comments - Add endpoint id to logs. - Add missing constraint checks. * Various Fixes - Remove usage of DefaultStorageAllocator for the TLV encoded stored attributes, and replace them with SafeWriteValue()/SafeReadValue() APIs from GetSafeAttributePersistenceProvider. - Make the RankedStreamPriorities a vector and handle the TLV encoding of the list of enums. - Populate the CaptureSnapshot response properly with image data received from delegate. * Add parameters struct for housing the set of stream allocation parameters for the delegate. * Add initial delegate implementation in all-clusters-app. * Update Camera AVStreamMgmt Server SDK based on Spec changes from Spec PR#11309. * Update all-clusters-app and camera-app with attribute changes. * Updates to CameraAVStreamMgmt delegate. * Fix Command de-allocation comments. * Fix Command code numbering in zap file. * Add SnapshotStreamModify command support. * Fix persisted storage handling for Viewport and STream Priorities. * Address review comments. * Resolve conflicts in all-clusters-app.matter and camera-app.matter. * Update src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Address review comments. --------- Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 89954f9 commit 47254d5

File tree

19 files changed

+4608
-1688
lines changed

19 files changed

+4608
-1688
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+307
Original file line numberDiff line numberDiff line change
@@ -7014,6 +7014,291 @@ cluster LowPower = 1288 {
70147014
command Sleep(): DefaultSuccess = 0;
70157015
}
70167016

7017+
/** The Camera AV Stream Management cluster is used to allow clients to manage, control, and configure various audio, video, and snapshot streams on a camera. */
7018+
provisional cluster CameraAvStreamManagement = 1361 {
7019+
revision 1;
7020+
7021+
enum AudioCodecEnum : enum8 {
7022+
kOPUS = 0;
7023+
kAACLC = 1;
7024+
}
7025+
7026+
enum ImageCodecEnum : enum8 {
7027+
kJPEG = 0;
7028+
}
7029+
7030+
enum StreamUsageEnum : enum8 {
7031+
kInternal = 0;
7032+
kRecording = 1;
7033+
kAnalysis = 2;
7034+
kLiveView = 3;
7035+
}
7036+
7037+
enum TriStateAutoEnum : enum8 {
7038+
kOff = 0;
7039+
kOn = 1;
7040+
kAuto = 2;
7041+
}
7042+
7043+
enum TwoWayTalkSupportTypeEnum : enum8 {
7044+
kNotSupported = 0;
7045+
kHalfDuplex = 1;
7046+
kFullDuplex = 2;
7047+
}
7048+
7049+
enum VideoCodecEnum : enum8 {
7050+
kH264 = 0;
7051+
kHEVC = 1;
7052+
kVVC = 2;
7053+
kAV1 = 3;
7054+
}
7055+
7056+
bitmap Feature : bitmap32 {
7057+
kAudio = 0x1;
7058+
kVideo = 0x2;
7059+
kSnapshot = 0x4;
7060+
kPrivacy = 0x8;
7061+
kSpeaker = 0x10;
7062+
kImageControl = 0x20;
7063+
kWatermark = 0x40;
7064+
kOnScreenDisplay = 0x80;
7065+
kLocalStorage = 0x100;
7066+
kHighDynamicRange = 0x200;
7067+
}
7068+
7069+
struct VideoResolutionStruct {
7070+
int16u width = 0;
7071+
int16u height = 1;
7072+
}
7073+
7074+
struct VideoStreamStruct {
7075+
int16u videoStreamID = 0;
7076+
StreamUsageEnum streamUsage = 1;
7077+
VideoCodecEnum videoCodec = 2;
7078+
int16u minFrameRate = 3;
7079+
int16u maxFrameRate = 4;
7080+
VideoResolutionStruct minResolution = 5;
7081+
VideoResolutionStruct maxResolution = 6;
7082+
int32u minBitRate = 7;
7083+
int32u maxBitRate = 8;
7084+
int16u minFragmentLen = 9;
7085+
int16u maxFragmentLen = 10;
7086+
optional boolean watermarkEnabled = 11;
7087+
optional boolean OSDEnabled = 12;
7088+
int8u referenceCount = 13;
7089+
}
7090+
7091+
struct SnapshotStreamStruct {
7092+
int16u snapshotStreamID = 0;
7093+
ImageCodecEnum imageCodec = 1;
7094+
int16u frameRate = 2;
7095+
int32u bitRate = 3;
7096+
VideoResolutionStruct minResolution = 4;
7097+
VideoResolutionStruct maxResolution = 5;
7098+
int8u quality = 6;
7099+
int8u referenceCount = 7;
7100+
}
7101+
7102+
struct SnapshotParamsStruct {
7103+
VideoResolutionStruct resolution = 0;
7104+
int16u maxFrameRate = 1;
7105+
ImageCodecEnum imageCodec = 2;
7106+
}
7107+
7108+
struct RateDistortionTradeOffPointsStruct {
7109+
VideoCodecEnum codec = 0;
7110+
VideoResolutionStruct resolution = 1;
7111+
int32u minBitRate = 2;
7112+
}
7113+
7114+
struct AudioCapabilitiesStruct {
7115+
int8u maxNumberOfChannels = 0;
7116+
AudioCodecEnum supportedCodecs[] = 1;
7117+
int32u supportedSampleRates[] = 2;
7118+
int8u supportedBitDepths[] = 3;
7119+
}
7120+
7121+
struct AudioStreamStruct {
7122+
int16u audioStreamID = 0;
7123+
StreamUsageEnum streamUsage = 1;
7124+
AudioCodecEnum audioCodec = 2;
7125+
int8u channelCount = 3;
7126+
int32u sampleRate = 4;
7127+
int32u bitRate = 5;
7128+
int8u bitDepth = 6;
7129+
int8u referenceCount = 7;
7130+
}
7131+
7132+
struct VideoSensorParamsStruct {
7133+
int16u sensorWidth = 0;
7134+
int16u sensorHeight = 1;
7135+
int16u maxFPS = 2;
7136+
optional int16u maxHDRFPS = 3;
7137+
}
7138+
7139+
struct ViewportStruct {
7140+
int16u x1 = 0;
7141+
int16u y1 = 1;
7142+
int16u x2 = 2;
7143+
int16u y2 = 3;
7144+
}
7145+
7146+
readonly attribute optional int8u maxConcurrentVideoEncoders = 0;
7147+
readonly attribute optional int32u maxEncodedPixelRate = 1;
7148+
readonly attribute optional VideoSensorParamsStruct videoSensorParams = 2;
7149+
readonly attribute optional boolean nightVisionCapable = 3;
7150+
readonly attribute optional VideoResolutionStruct minViewport = 4;
7151+
readonly attribute optional RateDistortionTradeOffPointsStruct rateDistortionTradeOffPoints[] = 5;
7152+
readonly attribute int32u maxContentBufferSize = 6;
7153+
readonly attribute optional AudioCapabilitiesStruct microphoneCapabilities = 7;
7154+
readonly attribute optional AudioCapabilitiesStruct speakerCapabilities = 8;
7155+
readonly attribute optional TwoWayTalkSupportTypeEnum twoWayTalkSupport = 9;
7156+
readonly attribute optional SnapshotParamsStruct supportedSnapshotParams[] = 10;
7157+
readonly attribute int32u maxNetworkBandwidth = 11;
7158+
readonly attribute optional int16u currentFrameRate = 12;
7159+
attribute access(read: manage, write: manage) optional boolean HDRModeEnabled = 13;
7160+
readonly attribute StreamUsageEnum supportedStreamUsages[] = 14;
7161+
readonly attribute optional VideoStreamStruct allocatedVideoStreams[] = 15;
7162+
readonly attribute optional AudioStreamStruct allocatedAudioStreams[] = 16;
7163+
readonly attribute optional SnapshotStreamStruct allocatedSnapshotStreams[] = 17;
7164+
readonly attribute optional StreamUsageEnum rankedVideoStreamPrioritiesList[] = 18;
7165+
attribute optional boolean softRecordingPrivacyModeEnabled = 19;
7166+
attribute optional boolean softLivestreamPrivacyModeEnabled = 20;
7167+
readonly attribute optional boolean hardPrivacyModeOn = 21;
7168+
attribute access(read: manage, write: manage) optional TriStateAutoEnum nightVision = 22;
7169+
attribute access(read: manage, write: manage) optional TriStateAutoEnum nightVisionIllum = 23;
7170+
attribute access(read: manage, write: manage) optional ViewportStruct viewport = 24;
7171+
attribute access(read: manage, write: manage) optional boolean speakerMuted = 25;
7172+
attribute access(read: manage, write: manage) optional int8u speakerVolumeLevel = 26;
7173+
readonly attribute access(read: manage) optional int8u speakerMaxLevel = 27;
7174+
readonly attribute access(read: manage) optional int8u speakerMinLevel = 28;
7175+
attribute access(read: manage, write: manage) optional boolean microphoneMuted = 29;
7176+
attribute access(read: manage, write: manage) optional int8u microphoneVolumeLevel = 30;
7177+
readonly attribute access(read: manage) optional int8u microphoneMaxLevel = 31;
7178+
readonly attribute access(read: manage) optional int8u microphoneMinLevel = 32;
7179+
attribute access(read: manage, write: manage) optional boolean microphoneAGCEnabled = 33;
7180+
attribute access(read: manage, write: manage) optional int16u imageRotation = 34;
7181+
attribute access(read: manage, write: manage) optional boolean imageFlipHorizontal = 35;
7182+
attribute access(read: manage, write: manage) optional boolean imageFlipVertical = 36;
7183+
attribute access(read: manage, write: manage) optional boolean localVideoRecordingEnabled = 37;
7184+
attribute access(read: manage, write: manage) optional boolean localSnapshotRecordingEnabled = 38;
7185+
attribute access(read: manage, write: manage) optional boolean statusLightEnabled = 39;
7186+
attribute access(read: manage, write: manage) optional ThreeLevelAutoEnum statusLightBrightness = 40;
7187+
readonly attribute command_id generatedCommandList[] = 65528;
7188+
readonly attribute command_id acceptedCommandList[] = 65529;
7189+
readonly attribute event_id eventList[] = 65530;
7190+
readonly attribute attrib_id attributeList[] = 65531;
7191+
readonly attribute bitmap32 featureMap = 65532;
7192+
readonly attribute int16u clusterRevision = 65533;
7193+
7194+
request struct AudioStreamAllocateRequest {
7195+
StreamUsageEnum streamUsage = 0;
7196+
AudioCodecEnum audioCodec = 1;
7197+
int8u channelCount = 2;
7198+
int32u sampleRate = 3;
7199+
int32u bitRate = 4;
7200+
int8u bitDepth = 5;
7201+
}
7202+
7203+
response struct AudioStreamAllocateResponse = 1 {
7204+
int16u audioStreamID = 0;
7205+
}
7206+
7207+
request struct AudioStreamDeallocateRequest {
7208+
int16u audioStreamID = 0;
7209+
}
7210+
7211+
request struct VideoStreamAllocateRequest {
7212+
StreamUsageEnum streamUsage = 0;
7213+
VideoCodecEnum videoCodec = 1;
7214+
int16u minFrameRate = 2;
7215+
int16u maxFrameRate = 3;
7216+
VideoResolutionStruct minResolution = 4;
7217+
VideoResolutionStruct maxResolution = 5;
7218+
int32u minBitRate = 6;
7219+
int32u maxBitRate = 7;
7220+
int16u minFragmentLen = 8;
7221+
int16u maxFragmentLen = 9;
7222+
optional boolean watermarkEnabled = 10;
7223+
optional boolean OSDEnabled = 11;
7224+
}
7225+
7226+
response struct VideoStreamAllocateResponse = 4 {
7227+
int16u videoStreamID = 0;
7228+
}
7229+
7230+
request struct VideoStreamModifyRequest {
7231+
int16u videoStreamID = 0;
7232+
optional boolean watermarkEnabled = 1;
7233+
optional boolean OSDEnabled = 2;
7234+
}
7235+
7236+
request struct VideoStreamDeallocateRequest {
7237+
int16u videoStreamID = 0;
7238+
}
7239+
7240+
request struct SnapshotStreamAllocateRequest {
7241+
ImageCodecEnum imageCodec = 0;
7242+
int16u maxFrameRate = 1;
7243+
int32u bitRate = 2;
7244+
VideoResolutionStruct minResolution = 3;
7245+
VideoResolutionStruct maxResolution = 4;
7246+
int8u quality = 5;
7247+
optional boolean watermarkEnabled = 6;
7248+
optional boolean OSDEnabled = 7;
7249+
}
7250+
7251+
response struct SnapshotStreamAllocateResponse = 8 {
7252+
int16u snapshotStreamID = 0;
7253+
}
7254+
7255+
request struct SnapshotStreamModifyRequest {
7256+
int16u snapshotStreamID = 0;
7257+
optional boolean watermarkEnabled = 1;
7258+
optional boolean OSDEnabled = 2;
7259+
}
7260+
7261+
request struct SnapshotStreamDeallocateRequest {
7262+
int16u snapshotStreamID = 0;
7263+
}
7264+
7265+
request struct SetStreamPrioritiesRequest {
7266+
StreamUsageEnum streamPriorities[] = 0;
7267+
}
7268+
7269+
request struct CaptureSnapshotRequest {
7270+
int16u snapshotStreamID = 0;
7271+
VideoResolutionStruct requestedResolution = 1;
7272+
}
7273+
7274+
response struct CaptureSnapshotResponse = 13 {
7275+
octet_string data = 0;
7276+
ImageCodecEnum imageCodec = 1;
7277+
VideoResolutionStruct resolution = 2;
7278+
}
7279+
7280+
/** This command SHALL allocate an audio stream on the camera and return an allocated audio stream identifier. */
7281+
command access(invoke: manage) AudioStreamAllocate(AudioStreamAllocateRequest): AudioStreamAllocateResponse = 0;
7282+
/** This command SHALL deallocate an audio stream on the camera, corresponding to the given audio stream identifier. */
7283+
command access(invoke: manage) AudioStreamDeallocate(AudioStreamDeallocateRequest): DefaultSuccess = 2;
7284+
/** This command SHALL allocate a video stream on the camera and return an allocated video stream identifier. */
7285+
command access(invoke: manage) VideoStreamAllocate(VideoStreamAllocateRequest): VideoStreamAllocateResponse = 3;
7286+
/** This command SHALL be used to modify a stream specified by the VideoStreamID. */
7287+
command access(invoke: manage) VideoStreamModify(VideoStreamModifyRequest): DefaultSuccess = 5;
7288+
/** This command SHALL deallocate a video stream on the camera, corresponding to the given video stream identifier. */
7289+
command access(invoke: manage) VideoStreamDeallocate(VideoStreamDeallocateRequest): DefaultSuccess = 6;
7290+
/** This command SHALL allocate a snapshot stream on the device and return an allocated snapshot stream identifier. */
7291+
command access(invoke: manage) SnapshotStreamAllocate(SnapshotStreamAllocateRequest): SnapshotStreamAllocateResponse = 7;
7292+
/** This command SHALL be used to modify a stream specified by the VideoStreamID. */
7293+
command access(invoke: manage) SnapshotStreamModify(SnapshotStreamModifyRequest): DefaultSuccess = 9;
7294+
/** This command SHALL deallocate an snapshot stream on the camera, corresponding to the given snapshot stream identifier. */
7295+
command access(invoke: manage) SnapshotStreamDeallocate(SnapshotStreamDeallocateRequest): DefaultSuccess = 10;
7296+
/** This command SHALL set the relative priorities of the various stream usages on the camera. */
7297+
command access(invoke: administer) SetStreamPriorities(SetStreamPrioritiesRequest): DefaultSuccess = 11;
7298+
/** This command SHALL return a Snapshot from the camera. */
7299+
command CaptureSnapshot(CaptureSnapshotRequest): CaptureSnapshotResponse = 12;
7300+
}
7301+
70177302
/** This cluster provides facilities to configure and play Chime sounds, such as those used in a doorbell. */
70187303
provisional cluster Chime = 1366 {
70197304
revision 1;
@@ -9313,6 +9598,28 @@ endpoint 1 {
93139598
handle command Sleep;
93149599
}
93159600

9601+
server cluster CameraAvStreamManagement {
9602+
callback attribute maxContentBufferSize;
9603+
callback attribute supportedSnapshotParams;
9604+
callback attribute maxNetworkBandwidth;
9605+
callback attribute supportedStreamUsages;
9606+
callback attribute allocatedSnapshotStreams;
9607+
callback attribute nightVision;
9608+
callback attribute nightVisionIllum;
9609+
callback attribute generatedCommandList;
9610+
callback attribute acceptedCommandList;
9611+
callback attribute attributeList;
9612+
callback attribute featureMap;
9613+
ram attribute clusterRevision default = 1;
9614+
9615+
handle command SnapshotStreamAllocate;
9616+
handle command SnapshotStreamAllocateResponse;
9617+
handle command SnapshotStreamDeallocate;
9618+
handle command SetStreamPriorities;
9619+
handle command CaptureSnapshot;
9620+
handle command CaptureSnapshotResponse;
9621+
}
9622+
93169623
server cluster Chime {
93179624
callback attribute installedChimeSounds;
93189625
callback attribute selectedChime;

0 commit comments

Comments
 (0)