Skip to content

Commit

Permalink
Make CameraAVStreamMgmt handle list attributes inside cluster server …
Browse files Browse the repository at this point in the history
…implementation.
  • Loading branch information
pidarped committed Dec 10, 2024
1 parent d794ff2 commit 48824b7
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,179 +105,89 @@ CameraAVStreamMgmtServer::ReadAndEncodeRateDistortionTradeOffPoints(const Attrib
{
CHIP_ERROR err = CHIP_NO_ERROR;

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

for (uint8_t i = 0; true; i++)
for (const auto& rateDistortionTradeOffPoints : mRateDistortionTradeOffPointsList)
{
Structs::RateDistortionTradeOffPointsStruct::Type rateDistortionTradeOffPoints;

err = mDelegate.GetRateDistortionTradeOffPointByIndex(i, rateDistortionTradeOffPoints);
SuccessOrExit(err);

err = encoder.Encode(rateDistortionTradeOffPoints);
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.EndRateDistortionTradeOffPointsRead();
return err;
}

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

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

for (uint8_t i = 0; true; i++)
for (const auto& snapshotParams : mSupportedSnapshotParamsList)
{
Structs::SnapshotParamsStruct::Type supportedSnapshotParams;

err = mDelegate.GetSupportedSnapshotParamByIndex(i, supportedSnapshotParams);
SuccessOrExit(err);

err = encoder.Encode(supportedSnapshotParams);
err = encoder.Encode(snapshotParams);
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.EndSupportedSnapshotParamsRead();
return err;
}

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

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

for (uint8_t i = 0; true; i++)
for (const auto& fabricIndex : mFabricsUsingCamera)
{
chip::FabricIndex fabricIndex;

err = mDelegate.GetFabricUsingCameraByIndex(i, fabricIndex);
SuccessOrExit(err);

err = encoder.Encode(fabricIndex);
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.EndFabricsUsingCameraRead();
return err;
}

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

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

for (uint8_t i = 0; true; i++)
for (const auto& videoStream : mAllocatedVideoStreams)
{
Structs::VideoStreamStruct::Type videoStream;

err = mDelegate.GetAllocatedVideoStreamByIndex(i, videoStream);
SuccessOrExit(err);

err = encoder.Encode(videoStream);
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.EndAllocatedVideoStreamsRead();
return err;
}

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

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

for (uint8_t i = 0; true; i++)
for (const auto& audioStream : mAllocatedAudioStreams)
{
Structs::AudioStreamStruct::Type audioStream;

err = mDelegate.GetAllocatedAudioStreamByIndex(i, audioStream);
SuccessOrExit(err);

err = encoder.Encode(audioStream);
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.EndAllocatedAudioStreamsRead();
return err;
}

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

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

for (uint8_t i = 0; true; i++)
for (const auto& audioStream : mAllocatedAudioStreams)
{
Structs::SnapshotStreamStruct::Type snapshotStream;

err = mDelegate.GetAllocatedSnapshotStreamByIndex(i, snapshotStream);
SuccessOrExit(err);

err = encoder.Encode(snapshotStream);
err = encoder.Encode(audioStream);
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.EndAllocatedSnapshotStreamsRead();
return err;
}

Expand All @@ -286,29 +196,15 @@ CameraAVStreamMgmtServer::ReadAndEncodeRankedVideoStreamPrioritiesList(const Att
{
CHIP_ERROR err = CHIP_NO_ERROR;

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

for (uint8_t i = 0; true; i++)
for (uint8_t i = 0; i < kNumOfStreamTypes; i++)
{
detail::StreamTypeEnum streamType;

err = mDelegate.GetRankedVideoStreamPrioritiesListByIndex(i, streamType);
SuccessOrExit(err);

err = encoder.Encode(streamType);
err = encoder.Encode(mRankedVideoStreamPriorities[i]);
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.EndRankedVideoStreamPrioritiesListRead();
return err;
}

Expand Down Expand Up @@ -417,8 +313,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat
return this->ReadAndEncodeAllocatedAudioStreams(encoder); }));
break;
case AllocatedSnapshotStreams::Id:
VerifyOrReturnError(
HasFeature(Feature::kAudio), 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(
Expand Down Expand Up @@ -1104,6 +999,11 @@ void CameraAVStreamMgmtServer::LoadPersistentAttributes()
}

// TODO: Load allocated streams and ranked priorities list
// Load AllocatedVideoStreams

// Load AllocatedAudioStreams

// Load AllocatedSnapshotStreams

// Load SoftRecordingPrivacyModeEnabled
bool softRecordingPrivacyModeEnabled;
Expand Down
Loading

0 comments on commit 48824b7

Please sign in to comment.