Skip to content

Commit

Permalink
Add Optional Attributes support
Browse files Browse the repository at this point in the history
  • Loading branch information
pidarped committed Oct 31, 2024
1 parent 2cf20d1 commit 1038b8d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace CameraAVStreamMgmt {

CameraAVStreamMgmtServer::CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId,
ClusterId aClusterId, BitMask<Feature> aFeature,
OptionalAttributes aOptionalAttrs,
uint8_t aMaxConcurrentVideoEncoders, uint32_t aMaxEncodedPixelRate,
const VideoSensorParamsStruct & aVideoSensorParams, bool aNightVisionCapable,
const VideoResolutionStruct & aMinViewPort, uint32_t aMaxContentBufferSize,
Expand All @@ -50,7 +51,7 @@ CameraAVStreamMgmtServer::CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate &
TwoWayTalkSupportTypeEnum aTwoWayTalkSupport, uint32_t aMaxNetworkBandwidth) :
CommandHandlerInterface(MakeOptional(aEndpointId), aClusterId),
AttributeAccessInterface(MakeOptional(aEndpointId), aClusterId), mDelegate(aDelegate), mEndpointId(aEndpointId),
mClusterId(aClusterId), mFeature(aFeature), mMaxConcurrentVideoEncoders(aMaxConcurrentVideoEncoders),
mClusterId(aClusterId), mFeature(aFeature), mOptionalAttrs(aOptionalAttrs), mMaxConcurrentVideoEncoders(aMaxConcurrentVideoEncoders),
mMaxEncodedPixelRate(aMaxEncodedPixelRate), mVideoSensorParams(aVideoSensorParams), mNightVisionCapable(aNightVisionCapable),
mMinViewPort(aMinViewPort), mMaxContentBufferSize(aMaxContentBufferSize), mMicrophoneCapabilities(aMicrophoneCapabilities),
mSpeakerCapabilities(aSpeakerCapabilities), mTwoWayTalkSupport(aTwoWayTalkSupport), mMaxNetworkBandwidth(aMaxNetworkBandwidth)
Expand Down Expand Up @@ -82,6 +83,11 @@ bool CameraAVStreamMgmtServer::HasFeature(Feature feature) const
return mFeature.Has(feature);
}

bool CameraAVStreamMgmtServer::SupportsOptAttr(OptionalAttributes aOptionalAttrs) const
{
return mOptionalAttrs.Has(aOptionalAttrs);
}

bool CameraAVStreamMgmtServer::IsLocalVideoRecordingEnabled() const
{
return mLocalVideoRecordingEnabled;
Expand Down Expand Up @@ -592,7 +598,24 @@ CHIP_ERROR CameraAVStreamMgmtServer::Write(const ConcreteDataAttributePath & aPa

switch (aPath.mAttributeId)
{
case HDRModeEnabled::Id: {
// Optional Attribute if Video is supported
if ((!HasFeature(Feature::kVideo)) ||
(!SupportsOptAttr(OptionalAttributes::kSupportsHDRModeEnabled)))
{
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set HDRModeEnabled, feature is not supported");
return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute);
}

bool newValue;
ReturnErrorOnFailure(aDecoder.Decode(newValue));
ReturnErrorOnFailure(SetHDRModeEnabled(newValue));
return CHIP_NO_ERROR;
}
case RankedVideoStreamPrioritiesList::Id: {
VerifyOrReturnError(
HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not write to RankedVideoStreamPrioritiesList, feature is not supported"));
uint8_t newValue;
ReturnErrorOnFailure(aDecoder.Decode(newValue));
ReturnErrorOnFailure(mDelegate.SetRankedVideoStreamPrioritiesList(newValue));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ class CameraAVStreamMgmtDelegate
CameraAVStreamMgmtServer * GetCameraAVStreamMgmtServer() const { return mCameraAVStreamMgmtServer; }
};

enum class OptionalAttributes : uint32_t
{
kSupportsHDRModeEnabled = 0x0001,
kSupportsHardPrivacyModeOn = 0x0002,
kSupportsNightVision = 0x0004,
kSupportsNightVisionIllum = 0x0008,
kSupportsMicrophoneAGCEnabled = 0x0010,
kSupportsDepthSensorStatus = 0x0020,
};

class CameraAVStreamMgmtServer : public CommandHandlerInterface, public AttributeAccessInterface
{
public:
Expand All @@ -171,7 +181,7 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut
* @param aFeature The bitmask value that identifies which features are supported by this instance.
*/
CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate * aDelegate, EndpointId aEndpointId, ClusterId aClusterId,
BitMask<CameraAVStreamMgmt::Feature> aFeature, uint8_t aMaxConVideoEncoders,
BitMask<CameraAVStreamMgmt::Feature> aFeature, OptionalAttributes aOptionalAttrs, uint8_t aMaxConVideoEncoders,
uint32_t aMaxEncodedPixelRate, VideoSensorParamsStruct aVideoSensorParams, bool aNightVisionCapable,
VideoResolutionStruct minViewPort, uint32_t aMaxContentBufferSize,
AudioCapabilitiesStruct aMicCapabilities, AudioCapabilitiesStruct aSpkrCapabilities,
Expand All @@ -190,6 +200,8 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut

bool HasFeature(Feature feature) const;

bool SupportsOptAttr(OptionalAttributes aOptionalAttrs) const;

bool IsLocalVideoRecordingEnabled() const;

Protocols::InteractionModel::Status SetCurrentFrameRate(uint16_t aCurrentFrameRate);
Expand Down Expand Up @@ -257,6 +269,7 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut
EndpointId mEndpointId;
ClusterId mClusterId;
BitMask<Feature> mFeature;
BitMask<OptionalAttributes> mOptionalAttrs;

// Attributes with F quality
const uint8_t mMaxConcurrentVideoEncoders;
Expand Down

0 comments on commit 1038b8d

Please sign in to comment.