Skip to content

Commit

Permalink
Remove redundant CurrentSnapshotConfig and CurrentVideoCodecs attributes
Browse files Browse the repository at this point in the history
Fix name of MaxFramRate in Snapshot Allocation functions.
  • Loading branch information
pidarped committed Nov 13, 2024
1 parent c01deda commit 2efcf21
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,36 +154,6 @@ CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeSupportedSnapshotParams(const
return err;
}

CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeCurrentVideoCodecs(const AttributeValueEncoder::ListEncodeHelper & encoder)
{
CHIP_ERROR err = CHIP_NO_ERROR;

// Tell the delegate the read is starting..
ReturnErrorOnFailure(mDelegate.StartCurrentVideoCodecsRead());

for (uint8_t i = 0; true; i++)
{
VideoCodecEnum videoCodec;

err = mDelegate.GetCurrentVideoCodecByIndex(i, videoCodec);
SuccessOrExit(err);

err = encoder.Encode(videoCodec);
SuccessOrExit(err);
}

exit:
if (err == CHIP_ERROR_PROVIDER_LIST_EXHAUSTED)
{
// Convert end of list to CHIP_NO_ERROR
err = CHIP_NO_ERROR;
}

// Tell the delegate the read is complete
err = mDelegate.EndCurrentVideoCodecsRead();
return err;
}

CHIP_ERROR CameraAVStreamMgmtServer::ReadAndEncodeFabricsUsingCamera(const AttributeValueEncoder::ListEncodeHelper & encoder)
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down Expand Up @@ -415,17 +385,6 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get HDRModeEnabled, feature is not supported");
ReturnErrorOnFailure(aEncoder.Encode(mHDRModeEnabled));
break;
case CurrentVideoCodecs::Id:
VerifyOrReturnError(HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get CurrentVideoCodecs, feature is not supported"));
ReturnErrorOnFailure(aEncoder.EncodeList(
[this](const auto & encoder) -> CHIP_ERROR { return this->ReadAndEncodeCurrentVideoCodecs(encoder); }));
break;
case CurrentSnapshotConfig::Id:
VerifyOrReturnError(HasFeature(Feature::kSnapshot), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get CurrentSnapshotConfig, feature is not supported"));
ReturnErrorOnFailure(aEncoder.Encode(mCurrentSnapshotConfig));
break;
case FabricsUsingCamera::Id:
VerifyOrReturnError(HasFeature(Feature::kVideo), CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE,
ChipLogError(Zcl, "CameraAVStreamMgmt: can not get FabricsUsingCamera, feature is not supported"));
Expand Down Expand Up @@ -770,34 +729,6 @@ Status CameraAVStreamMgmtServer::SetHDRModeEnabled(bool aHDRModeEnabled)
return Protocols::InteractionModel::Status::Success;
}

Status CameraAVStreamMgmtServer::SetCurrentSnapshotConfig(const VideoResolutionStruct & aVideoResolution, uint16_t aMaxFrameRate,
ImageCodecEnum aImageCodecEnum)
{
bool snapshotConfigChanged = false;
if (mCurrentSnapshotConfig.Resolution != aVideoResolution)
{
mCurrentSnapshotConfig.Resolution = aVideoResolution;
snapshotConfigChanged = true;
}
if (mCurrentSnapshotConfig.MaxFrameRate != aMaxFrameRate)
{
mCurrentSnapshotConfig.MaxFrameRate = aMaxFrameRate;
snapshotConfigChanged = true;
}
if (mCurrentSnapshotConfig.ImageCodec != aImageCodecEnum)
{
mCurrentSnapshotConfig.ImageCodec = aImageCodecEnum;
snapshotConfigChanged = true;
}
if (snapshotConfigChanged)
{
ConcreteAttributePath path = ConcreteAttributePath(mEndpointId, mClusterId, Attributes::CurrentSnapshotConfig::Id);
MatterReportingAttributeChangeCallback(path);
}

return Protocols::InteractionModel::Status::Success;
}

Status CameraAVStreamMgmtServer::SetSoftRecordingPrivacyModeEnabled(bool aSoftRecordingPrivacyModeEnabled)
{
if (mSoftRecordingPrivacyModeEnabled != aSoftRecordingPrivacyModeEnabled)
Expand Down Expand Up @@ -1392,14 +1323,14 @@ void CameraAVStreamMgmtServer::HandleSnapshotStreamAllocate(HandlerContext & ctx

Commands::SnapshotStreamAllocateResponse::Type response;
auto & imageCodec = commandData.imageCodec;
auto & frameRate = commandData.frameRate;
auto & maxFrameRate = commandData.maxFrameRate;
auto & bitRate = commandData.bitRate;
auto & minResolution = commandData.minResolution;
auto & maxResolution = commandData.maxResolution;
auto & quality = commandData.quality;

// Call the delegate
Status status = mDelegate.SnapshotStreamAllocate(imageCodec, frameRate, bitRate, minResolution, maxResolution, quality);
Status status = mDelegate.SnapshotStreamAllocate(imageCodec, maxFrameRate, bitRate, minResolution, maxResolution, quality);

if (status != Status::Success)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ class CameraAVStreamMgmtDelegate
virtual CHIP_ERROR GetSupportedSnapshotParamByIndex(uint8_t, Structs::RateDistortionTradeOffPointsStruct::Type &) = 0;
virtual CHIP_ERROR EndSupportedSnapshotParamsRead() = 0;

virtual CHIP_ERROR StartCurrentVideoCodecsRead() = 0;
virtual CHIP_ERROR GetCurrentVideoCodecByIndex(uint8_t, VideoCodecEnumType) = 0;
virtual CHIP_ERROR EndCurrentVideoCodecsRead() = 0;

virtual CHIP_ERROR StartFabricsUsingCameraRead() = 0;
virtual CHIP_ERROR GetFabricUsingCameraByIndex(uint8_t, chip::FabricIndex) = 0;
virtual CHIP_ERROR EndFabricsUsingCameraRead() = 0;
Expand Down Expand Up @@ -210,10 +206,6 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut

Protocols::InteractionModel::Status SetHDRModeEnabled(bool aHDRModeEnabled);

Protocols::InteractionModel::Status
CameraAVStreamMgmtServer::SetCurrentSnapshotConfig(const VideoResolutionStruct & aVideoResolution, uint16_t aMaxFrameRate,
ImageCodecEnumType aImageCodecEnum);

Protocols::InteractionModel::Status SetSoftRecordingPrivacyModeEnabled(bool aSoftRecordingPrivacyModeEnabled);

Protocols::InteractionModel::Status SetSoftLivestreamPrivacyModeEnabled(bool aSoftLivestreamPrivacyModeEnabled);
Expand Down Expand Up @@ -279,7 +271,6 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut

uint16_t mCurrentFrameRate;
bool mHDRModeEnabled = false;
SnapshotParamsStruct mCurrentSnapshotConfig;
bool mSoftRecordingPrivacyModeEnabled = false;
bool mSoftLivestreamPrivacyModeEnabled = false;
bool mHardPrivacyModeOn = false;
Expand Down Expand Up @@ -329,7 +320,6 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut
// Helpers to read list items via delegate APIs
CHIP_ERROR ReadAndEncodeRateDistortionTradeOffPoints(const AttributeValueEncoder::ListEncodeHelper & encoder);
CHIP_ERROR ReadAndEncodeSupportedSnapshotParams(const AttributeValueEncoder::ListEncodeHelper & encoder);
CHIP_ERROR ReadAndEncodeCurrentVideoCodecs(const AttributeValueEncoder::ListEncodeHelper & encoder);
CHIP_ERROR ReadAndEncodeFabricsUsingCamera(const AttributeValueEncoder::ListEncodeHelper & encoder);

CHIP_ERROR ReadAndEncodeAllocatedVideoStreams(const AttributeValueEncoder::ListEncodeHelper & encoder);
Expand Down

0 comments on commit 2efcf21

Please sign in to comment.