Skip to content

Handle change of DPTZRelativeMove -> DPTZStreams (list of int to list of struct) #38850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5ba42a7
XML update of CameraAVStreamManagement from Alchemy
marktrayer May 1, 2025
2dc6620
Zap regen
marktrayer May 1, 2025
03f7b74
Align with updated XML
marktrayer May 2, 2025
a527532
Adding Push AV
marktrayer May 2, 2025
5609b9a
Zap regen after adding PushAV
marktrayer May 2, 2025
34e9c23
Restyled by whitespace
restyled-commits May 2, 2025
97dfccf
Restyled by clang-format
restyled-commits May 2, 2025
56f2f02
Restyled by prettier-json
restyled-commits May 2, 2025
2e4f3b8
Handle watermark in snapshot stream modify
marktrayer May 2, 2025
5dd57e5
Restyled by whitespace
restyled-commits May 2, 2025
2fe44a7
Restyled by clang-format
restyled-commits May 2, 2025
66406d3
Revert optattr setting
marktrayer May 2, 2025
047132e
Restyled by clang-format
restyled-commits May 2, 2025
c6931da
Align with latest PR that makes enum values contiguous
marktrayer May 5, 2025
297f54a
Add regen code
marktrayer May 5, 2025
a8a2663
Align with latest camera spec.
marktrayer May 9, 2025
7829469
Merge branch 'master' into viewportupdatedhandling
marktrayer May 9, 2025
220e1c0
Zap Regen after merge with master
marktrayer May 9, 2025
4ebb407
Merge branch 'master' into viewportupdatedhandling
marktrayer May 9, 2025
35d8275
Restyled by whitespace
restyled-commits May 9, 2025
f732d10
Restyled by clang-format
restyled-commits May 9, 2025
55663bc
Merge branch 'viewportupdatedhandling' of https://github.com/marktray…
marktrayer May 9, 2025
45021de
Remove debug log
marktrayer May 9, 2025
f6b0211
Zap formatting fixes
marktrayer May 9, 2025
5c0fdce
Add static cast
marktrayer May 9, 2025
34fcf4e
Merge branch 'viewportupdatedhandling' of https://github.com/marktray…
marktrayer May 9, 2025
e7ecde3
Remove inadvertant inclusions
marktrayer May 10, 2025
6feb936
Update AVSUM 2_1 to reflect the new attribute name and type
marktrayer May 10, 2025
f8f6281
Merge branch 'master' into viewportupdatedhandling
marktrayer May 15, 2025
da3a6b3
Merge branch 'master' into viewportupdatedhandling
marktrayer May 16, 2025
59febb0
Zap changes
marktrayer May 16, 2025
23f511c
Merge branch 'viewportupdatedhandling' of https://github.com/marktray…
marktrayer May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7287,10 +7287,15 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
int16u y2 = 3;
}

struct DPTZStruct {
int16u videoStreamID = 0;
ViewportStruct viewport = 1;
}

readonly attribute optional MPTZStruct MPTZPosition = 0;
readonly attribute optional int8u maxPresets = 1;
readonly attribute optional MPTZPresetStruct MPTZPresets[] = 2;
readonly attribute optional int16u DPTZRelativeMove[] = 3;
readonly attribute optional DPTZStruct DPTZStreams[] = 3;
readonly attribute optional int8u zoomMax = 4;
readonly attribute optional int16s tiltMin = 5;
readonly attribute optional int16s tiltMax = 6;
Expand Down Expand Up @@ -7341,7 +7346,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {

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

Expand Down Expand Up @@ -9699,7 +9704,7 @@ endpoint 1 {
callback attribute MPTZPosition;
ram attribute maxPresets default = 5;
callback attribute MPTZPresets;
callback attribute DPTZRelativeMove;
callback attribute DPTZStreams;
ram attribute zoomMax default = 100;
ram attribute tiltMin default = -90;
ram attribute tiltMax default = 90;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ class AVSettingsUserLevelManagementDelegate : public Delegate
~AVSettingsUserLevelManagementDelegate() = default;

bool CanChangeMPTZ() override;
bool IsValidVideoStreamID(uint16_t videoStreamID) override;

CHIP_ERROR LoadMPTZPresets(std::vector<MPTZPresetHelper> & mptzPresetHelpers) override;
CHIP_ERROR LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove) override;
CHIP_ERROR LoadDPTZStreams(std::vector<Structs::DPTZStruct::Type> dptzStream) override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;

virtual void VideoStreamAllocated(uint16_t aStreamID) override;
virtual void VideoStreamDeallocated(uint16_t aStreamID) override;
virtual void DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport) override;

/**
* delegate command handlers
*/
Expand All @@ -52,7 +55,8 @@ class AVSettingsUserLevelManagementDelegate : public Delegate
Protocols::InteractionModel::Status MPTZRemovePreset(uint8_t aPreset) override;
Protocols::InteractionModel::Status DPTZSetViewport(uint16_t aVideoStreamID, Structs::ViewportStruct::Type aViewport) override;
Protocols::InteractionModel::Status DPTZRelativeMove(uint16_t aVideoStreamID, Optional<int16_t> aDeltaX,
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta) override;
Optional<int16_t> aDeltaY, Optional<int8_t> aZoomDelta,
Structs::ViewportStruct::Type & aViewport) override;
};

void Shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,26 @@ bool AVSettingsUserLevelManagementDelegate::CanChangeMPTZ()
return true;
}

bool AVSettingsUserLevelManagementDelegate::IsValidVideoStreamID(uint16_t aVideoStreamID)
void AVSettingsUserLevelManagementDelegate::VideoStreamAllocated(uint16_t aStreamID)
{
// The server needs to verify that the provided Video Stream ID is valid and known and subject to digital modification
// The camera app needs to also have an instance of AV Stream Management, querying that to determine validity of the provided
// id.
return true;
// The app needs to invoke this whenever the AV Stream Manager allocates a video stream; this informs the server of the
// id that is now subject to DPTZ, and the default viewport of the device
Structs::ViewportStruct::Type viewport = { 0, 0, 1920, 1080 };
this->GetServer()->AddMoveCapableVideoStream(aStreamID, viewport);
}

void AVSettingsUserLevelManagementDelegate::VideoStreamDeallocated(uint16_t aStreamID)
{
// The app needs to invoke this whenever the AV Stream Manager deallocates a video stream; this informs the server of the
// deallocated id that is now not subject to DPTZ
this->GetServer()->RemoveMoveCapableVideoStream(aStreamID);
}

void AVSettingsUserLevelManagementDelegate::DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport)
{
// The app needs to invoke this whenever the AV Stream Manager updates the device level default Viewport. This informs
// the server of the new viewport that shall be appled to all known streams.
this->GetServer()->UpdateMoveCapableVideoStreams(aViewport);
}

Status AVSettingsUserLevelManagementDelegate::MPTZSetPosition(Optional<int16_t> aPan, Optional<int16_t> aTilt,
Expand Down Expand Up @@ -109,12 +123,17 @@ Status AVSettingsUserLevelManagementDelegate::DPTZSetViewport(uint16_t aVideoStr
}

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

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

CHIP_ERROR AVSettingsUserLevelManagementDelegate::LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove)
CHIP_ERROR AVSettingsUserLevelManagementDelegate::LoadDPTZStreams(std::vector<DPTZStruct> dptzStreams)
{
dptzRelativeMove.clear();
dptzStreams.clear();
return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -156,7 +175,7 @@ void emberAfCameraAvSettingsUserLevelManagementClusterInitCallback(chip::Endpoin
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPosition,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMaxPresets,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPresets,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzRelativeMove,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzStreams,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kZoomMax,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMin,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMax,
Expand Down
13 changes: 9 additions & 4 deletions examples/camera-app/camera-common/camera-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -2385,10 +2385,15 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {
int16u y2 = 3;
}

struct DPTZStruct {
int16u videoStreamID = 0;
ViewportStruct viewport = 1;
}

readonly attribute optional MPTZStruct MPTZPosition = 0;
readonly attribute optional int8u maxPresets = 1;
readonly attribute optional MPTZPresetStruct MPTZPresets[] = 2;
readonly attribute optional int16u DPTZRelativeMove[] = 3;
readonly attribute optional DPTZStruct DPTZStreams[] = 3;
readonly attribute optional int8u zoomMax = 4;
readonly attribute optional int16s tiltMin = 5;
readonly attribute optional int16s tiltMax = 6;
Expand Down Expand Up @@ -2439,7 +2444,7 @@ provisional cluster CameraAvSettingsUserLevelManagement = 1362 {

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

Expand Down Expand Up @@ -3206,7 +3211,7 @@ endpoint 1 {
callback attribute MPTZPosition;
ram attribute maxPresets default = 5;
callback attribute MPTZPresets;
callback attribute DPTZRelativeMove;
callback attribute DPTZStreams;
ram attribute zoomMax default = 100;
ram attribute tiltMin default = -90;
ram attribute tiltMax default = 90;
Expand Down
2 changes: 1 addition & 1 deletion examples/camera-app/camera-common/src/camera-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ CameraApp::CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface *
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPosition,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMaxPresets,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kMptzPresets,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzRelativeMove,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kDptzStreams,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kZoomMax,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMin,
CameraAvSettingsUserLevelManagement::OptionalAttributes::kTiltMax,
Expand Down
2 changes: 1 addition & 1 deletion examples/camera-app/linux/include/camera-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class CameraDevice : public CameraDeviceInterface, public CameraDeviceInterface:
int16_t mTilt = chip::app::Clusters::CameraAvSettingsUserLevelManagement::kDefaultTilt;
uint8_t mZoom = chip::app::Clusters::CameraAvSettingsUserLevelManagement::kDefaultZoom;
// Use a standard 1080p aspect ratio
chip::app::Clusters::CameraAvStreamManagement::ViewportStruct mViewport = { 320, 585, 2240, 1665 };
chip::app::Clusters::CameraAvStreamManagement::ViewportStruct mViewport = { 0, 0, 1920, 1080 };
uint16_t mCurrentVideoFrameRate = 0;
bool mHDREnabled = false;
bool mMicrophoneMuted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ class CameraAVSettingsUserLevelManager : public Delegate
~CameraAVSettingsUserLevelManager() = default;

bool CanChangeMPTZ() override;
bool IsValidVideoStreamID(uint16_t videoStreamID) override;

CHIP_ERROR LoadMPTZPresets(std::vector<MPTZPresetHelper> & mptzPresetHelpers) override;
CHIP_ERROR LoadDPTZRelativeMove(std::vector<uint16_t> dptzRelativeMove) override;
CHIP_ERROR LoadDPTZStreams(std::vector<DPTZStruct> dptzStreams) override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;

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

void SetCameraDeviceHAL(CameraDeviceInterface::CameraHALInterface * aCameraDevice);
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);

/**
* DPTZ Stream Indication
*/
void VideoStreamAllocated(uint16_t aStreamID) override;
void VideoStreamDeallocated(uint16_t aStreamID) override;
void DefaultViewportUpdated(Structs::ViewportStruct::Type aViewport) override;

private:
CameraDeviceInterface::CameraHALInterface * mCameraDeviceHAL = nullptr;
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
};

} // namespace CameraAvSettingsUserLevelManagement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ class CameraAVStreamManager : public CameraAVStreamMgmtDelegate
CameraAVStreamManager() = default;
~CameraAVStreamManager() = default;

void SetCameraDeviceHAL(CameraDeviceInterface::CameraHALInterface * aCameraDevice);
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);

private:
CameraDeviceInterface::CameraHALInterface * mCameraDeviceHAL = nullptr;
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
};

} // namespace CameraAvStreamManagement
Expand Down
2 changes: 0 additions & 2 deletions examples/camera-app/linux/src/camera-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ CameraDevice::CameraDevice()

// Provider manager uses the Media controller to register WebRTC Transport with media controller for AV source data
mWebRTCProviderManager.SetMediaController(&mMediaController);

mCameraAVSettingsUserLevelManager.SetCameraDeviceHAL(this);
}

CameraDevice::~CameraDevice()
Expand Down
Loading
Loading