Skip to content

Commit

Permalink
Add Getters for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pidarped committed Dec 13, 2024
1 parent 48824b7 commit 364baee
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ namespace app {
namespace Clusters {
namespace CameraAvStreamManagement {

CameraAVStreamMgmtServer::CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId,
ClusterId aClusterId, BitMask<Feature> aFeature,
OptionalAttributes aOptionalAttrs,
PersistentStorageDelegate & aPersistentStorage,
uint8_t aMaxConcurrentVideoEncoders,
uint32_t aMaxEncodedPixelRate,
const VideoSensorParamsStruct & aVideoSensorParams, bool aNightVisionCapable,
const VideoResolutionStruct & aMinViewPort, uint32_t aMaxContentBufferSize,
const AudioCapabilitiesStruct & aMicrophoneCapabilities,
const AudioCapabilitiesStruct & aSpeakerCapabilities,
TwoWayTalkSupportTypeEnum aTwoWayTalkSupport, uint32_t aMaxNetworkBandwidth) :
CameraAVStreamMgmtServer::CameraAVStreamMgmtServer(
CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId, ClusterId aClusterId, BitMask<Feature> aFeature,
OptionalAttributes aOptionalAttrs, PersistentStorageDelegate & aPersistentStorage, uint8_t aMaxConcurrentVideoEncoders,
uint32_t aMaxEncodedPixelRate, const VideoSensorParamsStruct & aVideoSensorParams, bool aNightVisionCapable,
const VideoResolutionStruct & aMinViewPort,
const std::vector<Structs::RateDistortionTradeOffPointsStruct::Type> & aRateDistortionTradeOffPoints,
uint32_t aMaxContentBufferSize, const AudioCapabilitiesStruct & aMicrophoneCapabilities,
const AudioCapabilitiesStruct & aSpeakerCapabilities, TwoWayTalkSupportTypeEnum aTwoWayTalkSupport,
const std::vector<Structs::SnapshotParamsStruct::Type> & aSupportedSnapshotParams, uint32_t aMaxNetworkBandwidth) :
CommandHandlerInterface(MakeOptional(aEndpointId), aClusterId),
AttributeAccessInterface(MakeOptional(aEndpointId), aClusterId), mDelegate(aDelegate), mEndpointId(aEndpointId),
mClusterId(aClusterId), mFeature(aFeature), mOptionalAttrs(aOptionalAttrs), mPersistentStorage(&aPersistentStorage),
mMaxConcurrentVideoEncoders(aMaxConcurrentVideoEncoders), mMaxEncodedPixelRate(aMaxEncodedPixelRate),
mVideoSensorParams(aVideoSensorParams), mNightVisionCapable(aNightVisionCapable), mMinViewPort(aMinViewPort),
mMaxContentBufferSize(aMaxContentBufferSize), mMicrophoneCapabilities(aMicrophoneCapabilities),
mSpeakerCapabilities(aSpeakerCapabilities), mTwoWayTalkSupport(aTwoWayTalkSupport), mMaxNetworkBandwidth(aMaxNetworkBandwidth)
mRateDistortionTradeOffPointsList(aRateDistortionTradeOffPoints), mMaxContentBufferSize(aMaxContentBufferSize),
mMicrophoneCapabilities(aMicrophoneCapabilities), mSpeakerCapabilities(aSpeakerCapabilities),
mTwoWayTalkSupport(aTwoWayTalkSupport), mSupportedSnapshotParamsList(aSupportedSnapshotParams),
mMaxNetworkBandwidth(aMaxNetworkBandwidth)
{
mDelegate.SetCameraAVStreamMgmtServer(this);
}
Expand Down Expand Up @@ -105,7 +105,7 @@ CameraAVStreamMgmtServer::ReadAndEncodeRateDistortionTradeOffPoints(const Attrib
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& rateDistortionTradeOffPoints : mRateDistortionTradeOffPointsList)
for (const auto & rateDistortionTradeOffPoints : mRateDistortionTradeOffPointsList)
{
err = encoder.Encode(rateDistortionTradeOffPoints);
SuccessOrExit(err);
Expand All @@ -120,7 +120,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeSupportedSnapshotParams(const
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& snapshotParams : mSupportedSnapshotParamsList)
for (const auto & snapshotParams : mSupportedSnapshotParamsList)
{
err = encoder.Encode(snapshotParams);
SuccessOrExit(err);
Expand All @@ -135,7 +135,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeFabricsUsingCamera(const Attri
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& fabricIndex : mFabricsUsingCamera)
for (const auto & fabricIndex : mFabricsUsingCamera)
{
err = encoder.Encode(fabricIndex);
SuccessOrExit(err);
Expand All @@ -150,7 +150,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeAllocatedVideoStreams(const At
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& videoStream : mAllocatedVideoStreams)
for (const auto & videoStream : mAllocatedVideoStreams)
{
err = encoder.Encode(videoStream);
SuccessOrExit(err);
Expand All @@ -165,7 +165,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeAllocatedAudioStreams(const At
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& audioStream : mAllocatedAudioStreams)
for (const auto & audioStream : mAllocatedAudioStreams)
{
err = encoder.Encode(audioStream);
SuccessOrExit(err);
Expand All @@ -180,7 +180,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeAllocatedSnapshotStreams(const
{
CHIP_ERROR err = CHIP_NO_ERROR;

for (const auto& audioStream : mAllocatedAudioStreams)
for (const auto & audioStream : mAllocatedAudioStreams)
{
err = encoder.Encode(audioStream);
SuccessOrExit(err);
Expand Down Expand Up @@ -293,41 +293,37 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
VerifyOrReturnError(HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get FabricsUsingCamera, feature is not supported"));
ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR {
return this->ReadAndEncodeFabricsUsingCamera(encoder); }));
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeFabricsUsingCamera(encoder); }));
break;
case AllocatedVideoStreams::Id:
VerifyOrReturnError(HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get AllocatedVideoStreams, feature is not supported"));

ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR {
return this->ReadAndEncodeAllocatedVideoStreams(encoder); }));
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeAllocatedVideoStreams(encoder); }));
break;
case AllocatedAudioStreams::Id:
VerifyOrReturnError(HasFeature(Feature::kAudio), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get AllocatedAudioStreams, feature is not supported"));

ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR {
return this->ReadAndEncodeAllocatedAudioStreams(encoder); }));
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeAllocatedAudioStreams(encoder); }));
break;
case AllocatedSnapshotStreams::Id:
VerifyOrReturnError(HasFeature(Feature::kSnapshot), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(
HasFeature(Feature::kSnapshot), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get AllocatedSnapshotStreams, feature is not supported"));

ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR {
return this->ReadAndEncodeAllocatedSnapshotStreams(encoder); }));
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeAllocatedSnapshotStreams(encoder); }));
break;
case RankedVideoStreamPrioritiesList::Id:
VerifyOrReturnError(
HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get RankedVideoStreamPrioritiesList, feature is not supported"));

ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR {
return this->ReadAndEncodeRankedVideoStreamPrioritiesList(encoder); }));
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeRankedVideoStreamPrioritiesList(encoder); }));
break;
case SoftRecordingPrivacyModeEnabled::Id:
VerifyOrReturnError(
Expand All @@ -342,20 +338,21 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
ReturnErrorOnFailure(aEncoder.Encode(mSoftLivestreamPrivacyModeEnabled));
break;
case HardPrivacyModeOn::Id:
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsHardPrivacyModeOn),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsHardPrivacyModeOn), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get HardPrivacyModeOn, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mHardPrivacyModeOn));
break;
case NightVision::Id:
VerifyOrReturnError((HasFeature(Feature::kVideo) || HasFeature(Feature::kSnapshot)) &&
SupportsOptAttr(OptionalAttributes::kSupportsNightVision), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
SupportsOptAttr(OptionalAttributes::kSupportsNightVision),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get NightVision, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mNightVision));
break;
case NightVisionIllum::Id:
VerifyOrReturnError((HasFeature(Feature::kVideo) || HasFeature(Feature::kSnapshot)) &&
SupportsOptAttr(OptionalAttributes::kSupportsNightVisionIllum), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
SupportsOptAttr(OptionalAttributes::kSupportsNightVisionIllum),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get NightVisionIllumination, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mNightVisionIllum));
break;
Expand Down Expand Up @@ -441,8 +438,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
ReturnErrorOnFailure(aEncoder.Encode(mLocalSnapshotRecordingEnabled));
break;
case StatusLightEnabled::Id:
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsStatusLightEnabled),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsStatusLightEnabled), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get StatusLightEnabled, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mStatusLightEnabled));
break;
Expand Down Expand Up @@ -612,8 +608,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::Write(const ConcreteDataAttributePath & aPa
return StatusIB(status).ToChipError();
}
case StatusLightEnabled::Id: {
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsStatusLightEnabled),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(SupportsOptAttr(OptionalAttributes::kSupportsStatusLightEnabled), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set StatusLightEnabled, feature is not supported"));
bool statusLightEnabled;
ReturnErrorOnFailure(aDecoder.Decode(statusLightEnabled));
Expand Down Expand Up @@ -1048,7 +1043,8 @@ void CameraAVStreamMgmtServer::LoadPersistentAttributes()
}
else
{
ChipLogDetail(Zcl, "CameraAVStreamMgmt: Unable to load the NightVision from the KVS. Defaulting to %d", to_underlying(mNightVision));
ChipLogDetail(Zcl, "CameraAVStreamMgmt: Unable to load the NightVision from the KVS. Defaulting to %d",
to_underlying(mNightVision));
}

// Load NightVisionIllum
Expand Down Expand Up @@ -1257,6 +1253,9 @@ void CameraAVStreamMgmtServer::LoadPersistentAttributes()
ChipLogDetail(Zcl, "CameraAVStreamMgmt: Unable to load the StatusLightBrightness from the KVS. Defaulting to %d",
to_underlying(mStatusLightBrightness));
}

// Signal delegate that all persistent configuration attributes have been loaded.
mDelegate.PersistentAttributesLoadedCallback();
}

CHIP_ERROR CameraAVStreamMgmtServer::StoreViewport(const ViewportStruct & viewport)
Expand Down Expand Up @@ -1434,7 +1433,7 @@ void CameraAVStreamMgmtServer::InvokeCommand(HandlerContext & handlerContext)
void CameraAVStreamMgmtServer::HandleVideoStreamAllocate(HandlerContext & ctx,
const Commands::VideoStreamAllocate::DecodableType & commandData)
{
Status status = Status::Success;
Status status = Status::Success;

Commands::VideoStreamAllocateResponse::Type response;
auto & streamType = commandData.streamType;
Expand Down Expand Up @@ -1471,9 +1470,9 @@ void CameraAVStreamMgmtServer::HandleVideoStreamAllocate(HandlerContext & ctx,
}

// Call the delegate
status = mDelegate.VideoStreamAllocate(streamType, videoCodec, minFrameRate, maxFrameRate, minResolution, maxResolution,
minBitRate, maxBitRate, minFragmentLen, maxFragmentLen,
isWaterMarkEnabled, isOSDEnabled);
status =
mDelegate.VideoStreamAllocate(streamType, videoCodec, minFrameRate, maxFrameRate, minResolution, maxResolution, minBitRate,
maxBitRate, minFragmentLen, maxFragmentLen, isWaterMarkEnabled, isOSDEnabled);

if (status == Status::Success)
{
Expand All @@ -1497,7 +1496,6 @@ void CameraAVStreamMgmtServer::HandleVideoStreamModify(HandlerContext & ctx,
if (HasFeature(Feature::kWatermark))
{
isWaterMarkEnabled = commandData.watermarkEnabled.ValueOr(false);

}
else
{
Expand Down
Loading

0 comments on commit 364baee

Please sign in to comment.