Skip to content

Commit e021ebd

Browse files
Handle change of DPTZRelativeMove -> DPTZStreams (list of int to list of struct) (#38850)
* XML update of CameraAVStreamManagement from Alchemy * Zap regen * Align with updated XML * Adding Push AV * Zap regen after adding PushAV * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-json * Handle watermark in snapshot stream modify Correctly handle setting of nightvision based on the HAL * Restyled by whitespace * Restyled by clang-format * Revert optattr setting * Restyled by clang-format * Align with latest PR that makes enum values contiguous * Add regen code * Align with latest camera spec. Change DPTZRelativeMove attribute to DPTZStreams, which is now a struct that takes a viewport and a stream ID. Handle plumbing in the app to correctly set values based on stream allocation and deallocation. * Zap Regen after merge with master * Restyled by whitespace * Restyled by clang-format * Remove debug log * Zap formatting fixes * Add static cast * Remove inadvertant inclusions * Update AVSUM 2_1 to reflect the new attribute name and type * Zap changes --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 137e0a6 commit e021ebd

File tree

57 files changed

+1106
-490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1106
-490
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7287,10 +7287,15 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
72877287
int16u y2 = 3;
72887288
}
72897289

7290+
struct DPTZStruct {
7291+
int16u videoStreamID = 0;
7292+
ViewportStruct viewport = 1;
7293+
}
7294+
72907295
readonly attribute optional MPTZStruct MPTZPosition = 0;
72917296
readonly attribute optional int8u maxPresets = 1;
72927297
readonly attribute optional MPTZPresetStruct MPTZPresets[] = 2;
7293-
readonly attribute optional int16u DPTZRelativeMove[] = 3;
7298+
readonly attribute optional DPTZStruct DPTZStreams[] = 3;
72947299
readonly attribute optional int8u zoomMax = 4;
72957300
readonly attribute optional int16s tiltMin = 5;
72967301
readonly attribute optional int16s tiltMax = 6;
@@ -7341,7 +7346,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
73417346

73427347
/** This command SHALL set the values for the pan, tilt, and zoom in the mechanical PTZ. */
73437348
command MPTZSetPosition(MPTZSetPositionRequest): DefaultSuccess = 0;
7344-
/** This command SHALL move the device by the delta values relative to the currently defined position. */
7349+
/** This command SHALL move the camera by the delta values relative to the currently defined position. */
73457350
command MPTZRelativeMove(MPTZRelativeMoveRequest): DefaultSuccess = 1;
73467351
/** This command SHALL move the camera to the positions specified by the Preset passed. */
73477352
command MPTZMoveToPreset(MPTZMoveToPresetRequest): DefaultSuccess = 2;
@@ -7351,7 +7356,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
73517356
command MPTZRemovePreset(MPTZRemovePresetRequest): DefaultSuccess = 4;
73527357
/** This command allows for setting the digital viewport for a specific Video Stream. */
73537358
command DPTZSetViewport(DPTZSetViewportRequest): DefaultSuccess = 5;
7354-
/** This command SHALL change the viewports location by the amount specified in a relative fashion. */
7359+
/** This command SHALL change the per stream viewport by the amount specified in a relative fashion. */
73557360
command DPTZRelativeMove(DPTZRelativeMoveRequest): DefaultSuccess = 6;
73567361
}
73577362

@@ -9699,7 +9704,7 @@ endpoint 1 {
96999704
callback attribute MPTZPosition;
97009705
ram attribute maxPresets default = 5;
97019706
callback attribute MPTZPresets;
9702-
callback attribute DPTZRelativeMove;
9707+
callback attribute DPTZStreams;
97039708
ram attribute zoomMax default = 100;
97049709
ram attribute tiltMin default = -90;
97059710
ram attribute tiltMax default = 90;

examples/all-clusters-app/all-clusters-common/include/camera-av-settings-user-level-management-instance.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,15 @@ class AVSettingsUserLevelManagementDelegate : public Delegate
3333
~AVSettingsUserLevelManagementDelegate() = default;
3434

3535
bool CanChangeMPTZ() override;
36-
bool IsValidVideoStreamID(uint16_t videoStreamID) override;
3736

3837
CHIP_ERROR LoadMPTZPresets(std::vector<MPTZPresetHelper> & mptzPresetHelpers) override;
39-
CHIP_ERROR LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove) override;
38+
CHIP_ERROR LoadDPTZStreams(std::vector<Structs::DPTZStruct::Type> dptzStream) override;
4039
CHIP_ERROR PersistentAttributesLoadedCallback() override;
4140

41+
virtual void VideoStreamAllocated(uint16_t aStreamID) override;
42+
virtual void VideoStreamDeallocated(uint16_t aStreamID) override;
43+
virtual void DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport) override;
44+
4245
/**
4346
* delegate command handlers
4447
*/
@@ -52,7 +55,8 @@ class AVSettingsUserLevelManagementDelegate : public Delegate
5255
Protocols::InteractionModel::Status MPTZRemovePreset(uint8_t aPreset) override;
5356
Protocols::InteractionModel::Status DPTZSetViewport(uint16_t aVideoStreamID, Structs::ViewportStruct::Type aViewport) override;
5457
Protocols::InteractionModel::Status DPTZRelativeMove(uint16_t aVideoStreamID, Optional<int16_t> aDeltaX,
55-
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta) override;
58+
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta,
59+
Structs::ViewportStruct::Type & aViewport) override;
5660
};
5761

5862
void Shutdown();

examples/all-clusters-app/all-clusters-common/src/camera-av-settings-user-level-management-stub.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,26 @@ bool AVSettingsUserLevelManagementDelegate::CanChangeMPTZ()
4646
return true;
4747
}
4848

49-
bool AVSettingsUserLevelManagementDelegate::IsValidVideoStreamID(uint16_t aVideoStreamID)
49+
void AVSettingsUserLevelManagementDelegate::VideoStreamAllocated(uint16_t aStreamID)
5050
{
51-
// The server needs to verify that the provided Video Stream ID is valid and known and subject to digital modification
52-
// The camera app needs to also have an instance of AV Stream Management, querying that to determine validity of the provided
53-
// id.
54-
return true;
51+
// The app needs to invoke this whenever the AV Stream Manager allocates a video stream; this informs the server of the
52+
// id that is now subject to DPTZ, and the default viewport of the device
53+
Structs::ViewportStruct::Type viewport = { 0, 0, 1920, 1080 };
54+
this->GetServer()->AddMoveCapableVideoStream(aStreamID, viewport);
55+
}
56+
57+
void AVSettingsUserLevelManagementDelegate::VideoStreamDeallocated(uint16_t aStreamID)
58+
{
59+
// The app needs to invoke this whenever the AV Stream Manager deallocates a video stream; this informs the server of the
60+
// deallocated id that is now not subject to DPTZ
61+
this->GetServer()->RemoveMoveCapableVideoStream(aStreamID);
62+
}
63+
64+
void AVSettingsUserLevelManagementDelegate::DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport)
65+
{
66+
// The app needs to invoke this whenever the AV Stream Manager updates the device level default Viewport. This informs
67+
// the server of the new viewport that shall be appled to all known streams.
68+
this->GetServer()->UpdateMoveCapableVideoStreams(aViewport);
5569
}
5670

5771
Status AVSettingsUserLevelManagementDelegate::MPTZSetPosition(Optional<int16_t> aPan, Optional<int16_t> aTilt,
@@ -109,12 +123,17 @@ Status AVSettingsUserLevelManagementDelegate::DPTZSetViewport(uint16_t aVideoStr
109123
}
110124

111125
Status AVSettingsUserLevelManagementDelegate::DPTZRelativeMove(uint16_t aVideoStreamID, Optional<int16_t> aDeltaX,
112-
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta)
126+
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta,
127+
Structs::ViewportStruct::Type & aViewport)
113128
{
114129
// The Cluster implementation has ensured that the videoStreamID represents a valid stream.
115-
// The application needs to interact with its instance of AVStreamManagement to access the stream, validate the viewport
116-
// and set the new values for the viewpoort based on the pixel movement requested
130+
// The application needs to interact with its instance of AVStreamManagement to access the stream, validate
131+
// new dimensions after application of the deltas, and set the new values for the viewport based on the pixel movement
132+
// requested
133+
// The passed in viewport is empty, and needs to be populated by the delegate with the value of the viewport after
134+
// applying all deltas within the constraints of the sensor.
117135
//
136+
aViewport = { 0, 0, 1920, 1080 };
118137
return Status::Success;
119138
}
120139

@@ -124,9 +143,9 @@ CHIP_ERROR AVSettingsUserLevelManagementDelegate::LoadMPTZPresets(std::vector<MP
124143
return CHIP_NO_ERROR;
125144
}
126145

127-
CHIP_ERROR AVSettingsUserLevelManagementDelegate::LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove)
146+
CHIP_ERROR AVSettingsUserLevelManagementDelegate::LoadDPTZStreams(std::vector<DPTZStruct> dptzStreams)
128147
{
129-
dptzRelativeMove.clear();
148+
dptzStreams.clear();
130149
return CHIP_NO_ERROR;
131150
}
132151

@@ -156,7 +175,7 @@ void emberAfCameraAvSettingsUserLevelManagementClusterInitCallback(chip::Endpoin
156175
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPosition,
157176
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMaxPresets,
158177
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPresets,
159-
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzRelativeMove,
178+
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzStreams,
160179
CameraAvSettingsUserLevelManagement::OptionalAttributes::kZoomMax,
161180
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMin,
162181
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMax,

examples/camera-app/camera-common/camera-app.matter

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,10 +2385,15 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
23852385
int16u y2 = 3;
23862386
}
23872387

2388+
struct DPTZStruct {
2389+
int16u videoStreamID = 0;
2390+
ViewportStruct viewport = 1;
2391+
}
2392+
23882393
readonly attribute optional MPTZStruct MPTZPosition = 0;
23892394
readonly attribute optional int8u maxPresets = 1;
23902395
readonly attribute optional MPTZPresetStruct MPTZPresets[] = 2;
2391-
readonly attribute optional int16u DPTZRelativeMove[] = 3;
2396+
readonly attribute optional DPTZStruct DPTZStreams[] = 3;
23922397
readonly attribute optional int8u zoomMax = 4;
23932398
readonly attribute optional int16s tiltMin = 5;
23942399
readonly attribute optional int16s tiltMax = 6;
@@ -2439,7 +2444,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
24392444

24402445
/** This command SHALL set the values for the pan, tilt, and zoom in the mechanical PTZ. */
24412446
command MPTZSetPosition(MPTZSetPositionRequest): DefaultSuccess = 0;
2442-
/** This command SHALL move the device by the delta values relative to the currently defined position. */
2447+
/** This command SHALL move the camera by the delta values relative to the currently defined position. */
24432448
command MPTZRelativeMove(MPTZRelativeMoveRequest): DefaultSuccess = 1;
24442449
/** This command SHALL move the camera to the positions specified by the Preset passed. */
24452450
command MPTZMoveToPreset(MPTZMoveToPresetRequest): DefaultSuccess = 2;
@@ -2449,7 +2454,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
24492454
command MPTZRemovePreset(MPTZRemovePresetRequest): DefaultSuccess = 4;
24502455
/** This command allows for setting the digital viewport for a specific Video Stream. */
24512456
command DPTZSetViewport(DPTZSetViewportRequest): DefaultSuccess = 5;
2452-
/** This command SHALL change the viewports location by the amount specified in a relative fashion. */
2457+
/** This command SHALL change the per stream viewport by the amount specified in a relative fashion. */
24532458
command DPTZRelativeMove(DPTZRelativeMoveRequest): DefaultSuccess = 6;
24542459
}
24552460

@@ -3206,7 +3211,7 @@ endpoint 1 {
32063211
callback attribute MPTZPosition;
32073212
ram attribute maxPresets default = 5;
32083213
callback attribute MPTZPresets;
3209-
callback attribute DPTZRelativeMove;
3214+
callback attribute DPTZStreams;
32103215
ram attribute zoomMax default = 100;
32113216
ram attribute tiltMin default = -90;
32123217
ram attribute tiltMax default = 90;

examples/camera-app/camera-common/src/camera-app.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ CameraApp::CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface *
9595
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPosition,
9696
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMaxPresets,
9797
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPresets,
98-
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzRelativeMove,
98+
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzStreams,
9999
CameraAvSettingsUserLevelManagement::OptionalAttributes::kZoomMax,
100100
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMin,
101101
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMax,

examples/camera-app/linux/include/camera-device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class CameraDevice : public CameraDeviceInterface, public CameraDeviceInterface:
237237
int16_t mTilt = chip::app::Clusters::CameraAvSettingsUserLevelManagement::kDefaultTilt;
238238
uint8_t mZoom = chip::app::Clusters::CameraAvSettingsUserLevelManagement::kDefaultZoom;
239239
// Use a standard 1080p aspect ratio
240-
chip::app::Clusters::CameraAvStreamManagement::ViewportStruct mViewport = { 320, 585, 2240, 1665 };
240+
chip::app::Clusters::CameraAvStreamManagement::ViewportStruct mViewport = { 0, 0, 1920, 1080 };
241241
uint16_t mCurrentVideoFrameRate = 0;
242242
bool mHDREnabled = false;
243243
bool mMicrophoneMuted = false;

examples/camera-app/linux/include/clusters/camera-avsettingsuserlevel-mgmt/camera-avsettingsuserlevel-manager.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,9 @@ class CameraAVSettingsUserLevelManager : public Delegate
3737
~CameraAVSettingsUserLevelManager() = default;
3838

3939
bool CanChangeMPTZ() override;
40-
bool IsValidVideoStreamID(uint16_t videoStreamID) override;
4140

4241
CHIP_ERROR LoadMPTZPresets(std::vector<MPTZPresetHelper> & mptzPresetHelpers) override;
43-
CHIP_ERROR LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove) override;
42+
CHIP_ERROR LoadDPTZStreams(std::vector<DPTZStruct> dptzStreams) override;
4443
CHIP_ERROR PersistentAttributesLoadedCallback() override;
4544

4645
/**
@@ -56,12 +55,20 @@ class CameraAVSettingsUserLevelManager : public Delegate
5655
Protocols::InteractionModel::Status MPTZRemovePreset(uint8_t aPreset) override;
5756
Protocols::InteractionModel::Status DPTZSetViewport(uint16_t aVideoStreamID, Structs::ViewportStruct::Type aViewport) override;
5857
Protocols::InteractionModel::Status DPTZRelativeMove(uint16_t aVideoStreamID, Optional<int16_t> aDeltaX,
59-
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta) override;
58+
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta,
59+
Structs::ViewportStruct::Type & aViewport) override;
6060

61-
void SetCameraDeviceHAL(CameraDeviceInterface::CameraHALInterface * aCameraDevice);
61+
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);
62+
63+
/**
64+
* DPTZ Stream Indication
65+
*/
66+
void VideoStreamAllocated(uint16_t aStreamID) override;
67+
void VideoStreamDeallocated(uint16_t aStreamID) override;
68+
void DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport) override;
6269

6370
private:
64-
CameraDeviceInterface::CameraHALInterface * mCameraDeviceHAL = nullptr;
71+
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
6572
};
6673

6774
} // namespace CameraAvSettingsUserLevelManagement

examples/camera-app/linux/include/clusters/camera-avstream-mgmt/camera-av-stream-manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class CameraAVStreamManager : public CameraAVStreamMgmtDelegate
7878
CameraAVStreamManager() = default;
7979
~CameraAVStreamManager() = default;
8080

81-
void SetCameraDeviceHAL(CameraDeviceInterface::CameraHALInterface * aCameraDevice);
81+
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);
8282

8383
private:
84-
CameraDeviceInterface::CameraHALInterface * mCameraDeviceHAL = nullptr;
84+
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
8585
};
8686

8787
} // namespace CameraAvStreamManagement

examples/camera-app/linux/src/camera-device.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ CameraDevice::CameraDevice()
6565

6666
// Provider manager uses the Media controller to register WebRTC Transport with media controller for AV source data
6767
mWebRTCProviderManager.SetMediaController(&mMediaController);
68-
69-
mCameraAVSettingsUserLevelManager.SetCameraDeviceHAL(this);
7068
}
7169

7270
CameraDevice::~CameraDevice()

0 commit comments

Comments
 (0)