Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of PushAV Stream Transport Cluster #37787

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sayondeep
Copy link
Contributor

@sayondeep sayondeep commented Feb 26, 2025

This is the initial implementation of Push AV Stream Transport cluster

Delegate definition
Attributes support
Command Handling

Testing

Addition of delegate implementation in the example app is pending.

Copy link

semanticdiff-com bot commented Feb 26, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/app/zap_cluster_list.json  75% smaller
  src/app/chip_data_model.gni Unsupported file format
  src/app/clusters/push-av-stream-transport-server/push-av-stream-transport-server.cpp Unsupported file format
  src/app/clusters/push-av-stream-transport-server/push-av-stream-transport-server.h Unsupported file format
  src/app/common/templates/config-data.yaml  0% smaller
  zzz_generated/app-common/app-common/zap-generated/callback.h Unsupported file format

@CLAassistant
Copy link

CLAassistant commented Feb 26, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the app label Feb 26, 2025
@sayondeep sayondeep force-pushed the pr/camera/pushav branch 3 times, most recently from 48ff8e0 to 9d1591f Compare February 27, 2025 09:00
@sayondeep sayondeep changed the title initial implementation of pushav server Initial implementation of PushAV Stream Transport Cluster Feb 27, 2025
@sayondeep sayondeep marked this pull request as ready for review February 27, 2025 09:20
Copy link

PR #37787: Size comparison from 73fe30c to 543b7e1

Full report (3 builds for cc32xx, stm32)
platform target config section 73fe30c 543b7e1 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 540646 540646 0 0.0
RAM 205128 205128 0 0.0
lock CC3235SF_LAUNCHXL FLASH 574794 574794 0 0.0
RAM 205376 205376 0 0.0
stm32 light STM32WB5MM-DK FLASH 459840 459840 0 0.0
RAM 141472 141472 0 0.0

@yufengwangca
Copy link
Contributor

you need to enable this cluster in camera example app to include it into the build system

* produced; otherwise, the command SHALL be rejected with an appropriate
* error.
*/
virtual Protocols::InteractionModel::Status AllocatePushTransport(uint16_t & connectionID,
Copy link
Contributor

@yufengwangca yufengwangca Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocols::InteractionModel::Status is SDK internal, suggest to return general CHIP_ERROR in application code, same for other APIs bellow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocols::InteractionModel::Status is no more internal than CHIP_ERROR. It's fine for delegates to return it.

Comment on lines +162 to +173
friend class PushAvStreamTransportServer;

PushAvStreamTransportServer * mPushAvStreamTransportServer = nullptr;

/**
* This method is used by the SDK to set the PushAvStreamTransportServer pointer member in the delegate.
* This is done in the constructor during the instantiation of the PushAvStreamTransportServer object.
*
* @param aPushAvStreamTransportServer A pointer to the PushAvStreamTransportServer object related to this delegate object.
*/
void SetPushAvStreamTransportServer(PushAvStreamTransportServer * aPushAvStreamTransportServer)
{
mPushAvStreamTransportServer = aPushAvStreamTransportServer;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other cluster implementations, the cluster server is instantiated directly from the application rather than through its delegate. This approach avoids circular dependencies, since the cluster server itself contains the delegate.

}

protected:
PushAvStreamTransportServer * GetPushAvStreamTransportServer() const { return mPushAvStreamTransportServer; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app should instantiate and hold the Server instance by itself

AttributeAccessInterface(MakeOptional(aEndpointId), CameraAvStreamManagement::Id), mDelegate(aDelegate),
mEndpointId(aEndpointId), mFeature(aFeature)
{
mDelegate.SetPushAvStreamTransportServer(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This create circular dependency, we should have PushAvStreamTransportServer contains the reference to PushAvStreamTransportDelegate, not the other way around

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine for both to refer to each other... Why is this a problem?

Comment on lines 58 to 64
// Explicitly set the PushAvStreamTransportServer pointer in the Delegate to null.

mDelegate.SetPushAvStreamTransportServer(nullptr);

// Unregister command handler and attribute access interfaces
CommandHandlerInterfaceRegistry::Instance().UnregisterCommandHandler(this);
AttributeAccessInterfaceRegistry::Instance().Unregister(this);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mDelegate.SetPushAvStreamTransportServer(nullptr); is not needed, and move others to Shutdown API and call Shutdown here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mDelegate.SetPushAvStreamTransportServer(nullptr); is not needed

It's absolutely needed to avoid a dangling pointer, if the delegate holds a pointer to this object,

ReturnErrorOnFailure(aEncoder.Encode(mFeature));
break;

case SupportedContainerFormats::Id:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to intercept and override the default attributes in the attribute store? We only need to modify these default fields if we require the values to come from the app, since the default storage doesn't meet our requirements. However, it appears that these attributes aren't being handled specially.

private:
PushAvStreamTransportDelegate & mDelegate;
EndpointId mEndpointId;
const BitFlags<Feature> mFeature;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the default storage provided by the attribute store insufficient? Why must we maintain these attributes within the cluster server itself?

* produced; otherwise, the command SHALL be rejected with an appropriate
* error.
*/
virtual Protocols::InteractionModel::Status AllocatePushTransport(uint16_t & connectionID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protocols::InteractionModel::Status is no more internal than CHIP_ERROR. It's fine for delegates to return it.

*/
virtual Protocols::InteractionModel::Status
FindTransport(const Optional<DataModel::Nullable<uint16_t>> & connectionID,
DataModel::List<TransportConfigurationStruct> & outtransportConfigurations) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the lifetime of the memory the List points to? How is that lifetime supposed to be managed by the callee?

Comment on lines +211 to +217
// Helper functions
bool FindStreamTransportConnection(const uint16_t connectionID);
uint16_t GenerateConnectionID();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these meant to be public?

uint16_t connectionID = commandData.connectionID;
auto & transportOptions = commandData.transportOptions;

// Call the delegate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to validate the constraints first.

auto & activationReason = commandData.activationReason;
auto & timeControl = commandData.timeControl;

// Call the delegate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs constraint validation.

auto & activationReason = commandData.activationReason;
auto & timeControl = commandData.timeControl;

// Call the delegate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs connection id validation per spec.


DataModel::List<TransportConfigurationStruct> outStreamConfigurations;

// Call the delegate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs spec-required validation for a non-null connection id.

@mergify mergify bot added the conflict label Feb 28, 2025
@mergify mergify bot removed the conflict label Mar 4, 2025
@sayondeep sayondeep force-pushed the pr/camera/pushav branch 2 times, most recently from 5743f8e to 0e515e8 Compare March 4, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants