Skip to content

Commit

Permalink
Add write support for ImageRotation, ImageFlipHorizontal and ImageFli…
Browse files Browse the repository at this point in the history
…pVertical attributes.
  • Loading branch information
pidarped committed Nov 15, 2024
1 parent 31c6f24 commit 339fa18
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,17 +509,20 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
ReturnErrorOnFailure(aEncoder.Encode(mMicrophoneAGCEnabled));
break;
case ImageRotation::Id:
VerifyOrReturnError(HasFeature(Feature::kImageControl), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageRotation),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get ImageRotation, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mImageRotation));
break;
case ImageFlipHorizontal::Id:
VerifyOrReturnError(HasFeature(Feature::kImageControl), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageFlipHorizontal),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get ImageFlipHorizontal, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mImageFlipHorizontal));
break;
case ImageFlipVertical::Id:
VerifyOrReturnError(HasFeature(Feature::kImageControl), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageFlipVertical),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get ImageFlipHorizontal, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mImageFlipVertical));
break;
Expand Down Expand Up @@ -569,15 +572,6 @@ CHIP_ERROR CameraAVStreamMgmtServer::Write(const ConcreteDataAttributePath & aPa
ReturnErrorOnFailure(SetHDRModeEnabled(hdrModeEnabled));
return CHIP_NO_ERROR;
}
case RankedVideoStreamPrioritiesList::Id: { // TODO
VerifyOrReturnError(
HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set RankedVideoStreamPrioritiesList, feature is not supported"));
uint8_t newValue;
ReturnErrorOnFailure(aDecoder.Decode(newValue));
ReturnErrorOnFailure(mDelegate.SetRankedVideoStreamPrioritiesList(newValue));
return CHIP_NO_ERROR;
}
case SoftRecordingPrivacyModeEnabled::Id: {
VerifyOrReturnError(
HasFeature(Feature::kPrivacy), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
Expand Down Expand Up @@ -621,9 +615,8 @@ CHIP_ERROR CameraAVStreamMgmtServer::Write(const ConcreteDataAttributePath & aPa
return CHIP_NO_ERROR;
}
case Viewport::Id: {
VerifyOrReturnError(
HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set RankedVideoStreamPrioritiesList, feature is not supported"));
VerifyOrReturnError(HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set Viewport, feature is not supported"));
ViewportStruct viewPort;
ReturnErrorOnFailure(aDecoder.Decode(viewPort));
ReturnErrorOnFailure(SetViewport(viewPort));
Expand Down Expand Up @@ -670,6 +663,33 @@ CHIP_ERROR CameraAVStreamMgmtServer::Write(const ConcreteDataAttributePath & aPa
ReturnErrorOnFailure(SetMicrophoneAGCEnabled(micAGCEnabled));
return CHIP_NO_ERROR;
}
case ImageRotation::Id: {
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageRotation),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set ImageRotation, feature is not supported"));
uint16_t imageRotation;
ReturnErrorOnFailure(aDecoder.Decode(imageRotation));
ReturnErrorOnFailure(SetImageRotation(imageRotation));
return CHIP_NO_ERROR;
}
case ImageFlipHorizontal::Id: {
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageFlipHorizontal),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set ImageFlipHorizontal, feature is not supported"));
bool imageFlipHorizontal;
ReturnErrorOnFailure(aDecoder.Decode(imageFlipHorizontal));
ReturnErrorOnFailure(SetImageFlipHorizontal(imageFlipHorizontal));
return CHIP_NO_ERROR;
}
case ImageFlipVertical::Id: {
VerifyOrReturnError(HasFeature(Feature::kImageControl) && SupportsOptAttr(OptionalAttributes::kSupportsImageFlipVertical),
CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not set ImageFlipVertical, feature is not supported"));
bool imageFlipVertical;
ReturnErrorOnFailure(aDecoder.Decode(imageFlipVertical));
ReturnErrorOnFailure(SetImageFlipVertical(imageFlipVertical));
return CHIP_NO_ERROR;
}
case LocalVideoRecordingEnabled::Id: {
VerifyOrReturnError(
HasFeature(Feature::kVideo) && HasFeature(Feature::kStorage), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ enum class OptionalAttributes : uint32_t
kSupportsNightVision = 0x0004,
kSupportsNightVisionIllum = 0x0008,
kSupportsMicrophoneAGCEnabled = 0x0010,
kSupportsStatusLightEnabled = 0x0020,
kSupportsStatusLightBrightness = 0x0040,
kSupportsDepthSensorStatus = 0x0080,
kSupportsImageRotation = 0x0020,
kSupportsImageFlipHorizontal = 0x0040,
kSupportsImageFlipVertical = 0x0080,
kSupportsStatusLightEnabled = 0x0100,
kSupportsStatusLightBrightness = 0x0200,
};

class CameraAVStreamMgmtServer : public CommandHandlerInterface, public AttributeAccessInterface
Expand Down

0 comments on commit 339fa18

Please sign in to comment.