diff --git a/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.cpp b/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.cpp index 0736b9da18880d..535c4afbd951f8 100644 --- a/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.cpp +++ b/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.cpp @@ -43,24 +43,24 @@ namespace app { namespace Clusters { namespace CameraAvStreamManagement { -CameraAVStreamMgmtServer::CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId, - ClusterId aClusterId, BitMask 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 aFeature, + OptionalAttributes aOptionalAttrs, PersistentStorageDelegate & aPersistentStorage, uint8_t aMaxConcurrentVideoEncoders, + uint32_t aMaxEncodedPixelRate, const VideoSensorParamsStruct & aVideoSensorParams, bool aNightVisionCapable, + const VideoResolutionStruct & aMinViewPort, + const std::vector & aRateDistortionTradeOffPoints, + uint32_t aMaxContentBufferSize, const AudioCapabilitiesStruct & aMicrophoneCapabilities, + const AudioCapabilitiesStruct & aSpeakerCapabilities, TwoWayTalkSupportTypeEnum aTwoWayTalkSupport, + const std::vector & 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); } @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -293,32 +293,29 @@ 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( @@ -326,8 +323,7 @@ CHIP_ERROR CameraAVStreamMgmtServer::Read(const ConcreteReadAttributePath & aPat 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( @@ -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; @@ -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; @@ -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)); @@ -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 @@ -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) @@ -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; @@ -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) { @@ -1497,7 +1496,6 @@ void CameraAVStreamMgmtServer::HandleVideoStreamModify(HandlerContext & ctx, if (HasFeature(Feature::kWatermark)) { isWaterMarkEnabled = commandData.watermarkEnabled.ValueOr(false); - } else { diff --git a/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h b/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h index 89a1b166dc1fad..916b1b5594b364 100644 --- a/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h +++ b/src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h @@ -43,8 +43,7 @@ constexpr uint8_t kMaxSpeakerLevel = 254; constexpr uint8_t kMaxMicrophoneLevel = 254; constexpr uint16_t kMaxImageRotationDegrees = 359; -constexpr size_t kViewportStructMaxSerializedSize = - TLV::EstimateStructOverhead(sizeof(uint16_t) * 4); +constexpr size_t kViewportStructMaxSerializedSize = TLV::EstimateStructOverhead(sizeof(uint16_t) * 4); constexpr uint8_t kNumOfStreamTypes = 4; @@ -63,23 +62,18 @@ class CameraAVStreamMgmtDelegate /** * @brief Handle Command Delegate for Video stream allocation. */ - virtual Protocols::InteractionModel::Status VideoStreamAllocate(StreamTypeEnum streamType, - CameraAvStreamManagement::VideoCodecEnum videoCodec, - const uint16_t minFrameRate, const uint16_t maxFrameRate, - VideoResolutionStruct minResolution, - VideoResolutionStruct maxResolution, const uint32_t minBitRate, - const uint32_t maxBitRate, const uint16_t minFragmentLen, - const uint16_t maxFragmentLen, - bool waterMarkEnabled, - bool osdEnabled) = 0; + virtual Protocols::InteractionModel::Status + VideoStreamAllocate(StreamTypeEnum streamType, CameraAvStreamManagement::VideoCodecEnum videoCodec, const uint16_t minFrameRate, + const uint16_t maxFrameRate, VideoResolutionStruct minResolution, VideoResolutionStruct maxResolution, + const uint32_t minBitRate, const uint32_t maxBitRate, const uint16_t minFragmentLen, + const uint16_t maxFragmentLen, bool waterMarkEnabled, bool osdEnabled) = 0; /** * @brief Handle Command Delegate for Video stream modification. */ virtual Protocols::InteractionModel::Status VideoStreamModify(const uint16_t streamID, Optional videoResolution, - bool waterMarkEnabled, - bool osdEnabled) = 0; + bool waterMarkEnabled, bool osdEnabled) = 0; /** * @brief Handle Command Delegate for Video stream deallocation. @@ -119,12 +113,14 @@ class CameraAVStreamMgmtDelegate /** * @brief Handle Command Delegate for SetStreamPriorities. */ - virtual Protocols::InteractionModel::Status SetStreamPriorities(const DataModel::DecodableList streamPriorities) = 0; + virtual Protocols::InteractionModel::Status + SetStreamPriorities(const DataModel::DecodableList streamPriorities) = 0; - // Get attribute methods for list index items - - virtual uint8_t GetMaxConcurrentVideoEncoders() = 0; - virtual uint32_t GetMaxEncodedPixelRate() = 0; + /** + * @brief Callback into the delegate once persistent attributes managed by + * the Cluster have been loaded from Storage. + */ + virtual Protocols::InteractionModel::Status PersistentAttributesLoadedCallback() = 0; protected: friend class CameraAVStreamMgmtServer; @@ -170,17 +166,16 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut * @param aClusterId The ID of the Camera AV Stream Management cluster to be instantiated. * @param aFeature The bitmask value that identifies which features are supported by this instance. */ - CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId, - ClusterId aClusterId, BitMask 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 & aSpkrCapabilities, - TwoWayTalkSupportTypeEnum aTwoWayTalkSupport, uint32_t aMaxNetworkBandwidth); + CameraAVStreamMgmtServer(CameraAVStreamMgmtDelegate & aDelegate, EndpointId aEndpointId, ClusterId aClusterId, + BitMask aFeature, OptionalAttributes aOptionalAttrs, + PersistentStorageDelegate & aPersistentStorage, uint8_t aMaxConcurrentVideoEncoders, + uint32_t aMaxEncodedPixelRate, const VideoSensorParamsStruct & aVideoSensorParams, + bool aNightVisionCapable, const VideoResolutionStruct & aMinViewPort, + const std::vector & aRateDistortionTradeOffPoints, + uint32_t aMaxContentBufferSize, const AudioCapabilitiesStruct & aMicrophoneCapabilities, + const AudioCapabilitiesStruct & aSpkrCapabilities, TwoWayTalkSupportTypeEnum aTwoWayTalkSupport, + const std::vector & aSupportedSnapshotParams, + uint32_t aMaxNetworkBandwidth); ~CameraAVStreamMgmtServer() override; @@ -199,6 +194,7 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut bool IsLocalVideoRecordingEnabled() const; + // Attribute Setters Protocols::InteractionModel::Status SetCurrentFrameRate(uint16_t aCurrentFrameRate); Protocols::InteractionModel::Status SetHDRModeEnabled(bool aHDRModeEnabled); @@ -247,47 +243,110 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut Protocols::InteractionModel::Status SetStatusLightBrightness(Globals::ThreeLevelAutoEnum aStatusLightBrightness); - EndpointId GetEndpointId() { return AttributeAccessInterface::GetEndpointId().Value(); } + // Attribute Getters + uint8_t GetMaxConcurrentVideoEncoders() const { return mMaxConcurrentVideoEncoders; } - CHIP_ERROR AddToFabricsUsingCamera(chip::FabricIndex aFabricIndex) - { - mFabricsUsingCamera.insert(aFabricIndex); - return CHIP_NO_ERROR; - } + uint32_t GetMaxEncodedPixelRate() const { return mMaxEncodedPixelRate; } - CHIP_ERROR RemoveFromFabricsUsingCamera(chip::FabricIndex aFabricIndex) + const VideoSensorParamsStruct & GetVideoSensorParams() const { return mVideoSensorParams; } + + bool GetNightVisionCapable() const { return mNightVisionCapable; } + + const VideoResolutionStruct & GetMinViewport() const { return mMinViewPort; } + + const std::vector & GetRateDistortionTradeOffPoints() const { - mFabricsUsingCamera.erase(aFabricIndex); - return CHIP_NO_ERROR; + return mRateDistortionTradeOffPointsList; } - CHIP_ERROR AddToRateDistortionTradeOffPointsList(Structs::RateDistortionTradeOffPointsStruct::Type aRateDistortionTradeOffPoints) - { - mRateDistortionTradeOffPointsList.push_back(aRateDistortionTradeOffPoints); + uint32_t GetMaxContentBufferSize() const { return mMaxContentBufferSize; } - return CHIP_NO_ERROR; - } + const AudioCapabilitiesStruct & GetMicrophoneCapabilities() const { return mMicrophoneCapabilities; } + + const AudioCapabilitiesStruct & GetSpeakerCapabilities() const { return mSpeakerCapabilities; } + + TwoWayTalkSupportTypeEnum GetTwoWayTalkSupport() const { return mTwoWayTalkSupport; } - CHIP_ERROR ClearRateDistortionTradeOffPointsList() + const std::vector & GetSupportedSnapshotParams() const { - mRateDistortionTradeOffPointsList.clear(); - return CHIP_NO_ERROR; + return mSupportedSnapshotParamsList; } - CHIP_ERROR AddToSupportedSnapshotParamssList(Structs::SnapshotParamsStruct::Type aSupportedSnapshotParams) - { - mSupportedSnapshotParamsList.push_back(aSupportedSnapshotParams); + uint32_t GetMaxNetworkBandwidth() const { return mMaxNetworkBandwidth; } + + uint16_t GetCurrentFrameRate() const { return mCurrentFrameRate; } + + bool GetHDRModeEnabled() const { return mHDRModeEnabled; } + + const std::unordered_set & GetFabricsUsingCamera() const { return mFabricsUsingCamera; } + + const std::vector & GetAllocatedVideoStreams() const { return mAllocatedVideoStreams; } + + const std::vector & GetAllocatedAudioStreams() const { return mAllocatedAudioStreams; } + + const std::vector & GetAllocatedSnapshotStreams() const { return mAllocatedSnapshotStreams; } + + const StreamTypeEnum * GetRankedVideoStreamPriorities() const { return mRankedVideoStreamPriorities; } + + bool GetSoftRecordingPrivacyModeEnabled() const { return mSoftRecordingPrivacyModeEnabled; } + + bool GetSoftLivestreamPrivacyModeEnabled() const { return mSoftLivestreamPrivacyModeEnabled; } + bool GetHardPrivacyModeOn() const { return mHardPrivacyModeOn; } + + TriStateAutoEnum GetNightVision() const { return mNightVision; } + + TriStateAutoEnum GetNightVisionIllum() const { return mNightVisionIllum; } + + const ViewportStruct & GetViewport() const { return mViewport; } + + bool GetSpeakerMuted() const { return mSpeakerMuted; } + + uint8_t GetSpeakerVolumeLevel() const { return mSpeakerVolumeLevel; } + + uint8_t GetSpeakerMaxLevel() const { return mSpeakerMaxLevel; } + + uint8_t GetSpeakerMinLevel() const { return mSpeakerMinLevel; } + + bool GetMicrophoneMuted() const { return mMicrophoneMuted; } + + uint8_t GetMicrophoneVolumeLevel() const { return mMicrophoneVolumeLevel; } + + uint8_t GetMicrophoneMaxLevel() const { return mMicrophoneMaxLevel; } + + uint8_t GetMicrophoneMinLevel() const { return mMicrophoneMinLevel; } + + bool IsMicrophoneAGCEnabled() const { return mMicrophoneAGCEnabled; } + + uint16_t GetImageRotation() const { return mImageRotation; } + + bool GetImageFlipHorizontal() const { return mImageFlipHorizontal; } + + bool GetImageFlipVertical() const { return mImageFlipVertical; } + + bool GetLocalVideoRecordingEnabled() const { return mLocalVideoRecordingEnabled; } + + bool GetLocalSnapshotRecordingEnabled() const { return mLocalSnapshotRecordingEnabled; } + + bool GetStatusLightEnabled() const { return mStatusLightEnabled; } + + Globals::ThreeLevelAutoEnum GetStatusLightBrightness() const { return mStatusLightBrightness; } + + EndpointId GetEndpointId() { return AttributeAccessInterface::GetEndpointId().Value(); } + + CHIP_ERROR AddToFabricsUsingCamera(chip::FabricIndex aFabricIndex) + { + mFabricsUsingCamera.insert(aFabricIndex); return CHIP_NO_ERROR; } - CHIP_ERROR ClearSnapshotParamsList() + CHIP_ERROR RemoveFromFabricsUsingCamera(chip::FabricIndex aFabricIndex) { - mSupportedSnapshotParamsList.clear(); + mFabricsUsingCamera.erase(aFabricIndex); return CHIP_NO_ERROR; } - CHIP_ERROR SetRankedVideoStreamPriorities(const uint8_t newPriorities[kNumOfStreamTypes]) + CHIP_ERROR SetRankedVideoStreamPriorities(const StreamTypeEnum newPriorities[kNumOfStreamTypes]) { std::copy(newPriorities, newPriorities + kNumOfStreamTypes, mRankedVideoStreamPriorities); return CHIP_NO_ERROR; @@ -301,8 +360,10 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut CHIP_ERROR RemoveVideoStream(uint16_t videoStreamId) { - mAllocatedVideoStreams.erase(std::remove_if(mAllocatedVideoStreams.begin(), mAllocatedVideoStreams.end(), - [&](const VideoStreamStruct& vStream) { return vStream.videoStreamID == videoStreamId; }), mAllocatedVideoStreams.end()); + mAllocatedVideoStreams.erase( + std::remove_if(mAllocatedVideoStreams.begin(), mAllocatedVideoStreams.end(), + [&](const VideoStreamStruct & vStream) { return vStream.videoStreamID == videoStreamId; }), + mAllocatedVideoStreams.end()); return CHIP_NO_ERROR; } @@ -314,8 +375,10 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut CHIP_ERROR RemoveAudioStream(uint16_t audioStreamId) { - mAllocatedAudioStreams.erase(std::remove_if(mAllocatedAudioStreams.begin(), mAllocatedAudioStreams.end(), - [&](const AudioStreamStruct& aStream) { return aStream.audioStreamID == audioStreamId; }), mAllocatedAudioStreams.end()); + mAllocatedAudioStreams.erase( + std::remove_if(mAllocatedAudioStreams.begin(), mAllocatedAudioStreams.end(), + [&](const AudioStreamStruct & aStream) { return aStream.audioStreamID == audioStreamId; }), + mAllocatedAudioStreams.end()); return CHIP_NO_ERROR; } @@ -327,10 +390,13 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut CHIP_ERROR RemoveSnapshotStream(uint16_t snapshotStreamId) { - mAllocatedSnapshotStreams.erase(std::remove_if(mAllocatedSnapshotStreams.begin(), mAllocatedSnapshotStreams.end(), - [&](const SnapshotStreamStruct& sStream) { return sStream.snapshotStreamID == snapshotStreamId; }), mAllocatedSnapshotStreams.end()); + mAllocatedSnapshotStreams.erase( + std::remove_if(mAllocatedSnapshotStreams.begin(), mAllocatedSnapshotStreams.end(), + [&](const SnapshotStreamStruct & sStream) { return sStream.snapshotStreamID == snapshotStreamId; }), + mAllocatedSnapshotStreams.end()); return CHIP_NO_ERROR; } + private: CameraAVStreamMgmtDelegate & mDelegate; EndpointId mEndpointId; @@ -345,45 +411,44 @@ class CameraAVStreamMgmtServer : public CommandHandlerInterface, public Attribut const VideoSensorParamsStruct mVideoSensorParams; const bool mNightVisionCapable; const VideoResolutionStruct mMinViewPort; + const std::vector mRateDistortionTradeOffPointsList; const uint32_t mMaxContentBufferSize; const AudioCapabilitiesStruct mMicrophoneCapabilities; const AudioCapabilitiesStruct mSpeakerCapabilities; const TwoWayTalkSupportTypeEnum mTwoWayTalkSupport; + const std::vector mSupportedSnapshotParamsList; const uint32_t mMaxNetworkBandwidth; - uint16_t mCurrentFrameRate; + uint16_t mCurrentFrameRate = 0; bool mHDRModeEnabled = false; bool mSoftRecordingPrivacyModeEnabled = false; bool mSoftLivestreamPrivacyModeEnabled = false; bool mHardPrivacyModeOn = false; - TriStateAutoEnum mNightVision; - TriStateAutoEnum mNightVisionIllum; - ViewportStruct mViewport; - bool mSpeakerMuted = false; - uint8_t mSpeakerVolumeLevel; - uint8_t mSpeakerMaxLevel = kMaxSpeakerLevel; - uint8_t mSpeakerMinLevel = 0; - bool mMicrophoneMuted = false; - uint8_t mMicrophoneVolumeLevel; - uint8_t mMicrophoneMaxLevel = kMaxMicrophoneLevel; - uint8_t mMicrophoneMinLevel = 0; - bool mMicrophoneAGCEnabled = false; - uint16_t mImageRotation; - bool mImageFlipHorizontal = false; - bool mImageFlipVertical = false; - bool mLocalVideoRecordingEnabled = false; - bool mLocalSnapshotRecordingEnabled = false; - bool mStatusLightEnabled = false; - Globals::ThreeLevelAutoEnum mStatusLightBrightness; + TriStateAutoEnum mNightVision = TriStateAutoEnum::kOn; + TriStateAutoEnum mNightVisionIllum = TriStateAutoEnum::kOn; + ViewportStruct mViewport = { 0, 0, 0, 0 }; + bool mSpeakerMuted = false; + uint8_t mSpeakerVolumeLevel = 0; + uint8_t mSpeakerMaxLevel = kMaxSpeakerLevel; + uint8_t mSpeakerMinLevel = 0; + bool mMicrophoneMuted = false; + uint8_t mMicrophoneVolumeLevel = 0; + uint8_t mMicrophoneMaxLevel = kMaxMicrophoneLevel; + uint8_t mMicrophoneMinLevel = 0; + bool mMicrophoneAGCEnabled = false; + uint16_t mImageRotation = 0; + bool mImageFlipHorizontal = false; + bool mImageFlipVertical = false; + bool mLocalVideoRecordingEnabled = false; + bool mLocalSnapshotRecordingEnabled = false; + bool mStatusLightEnabled = false; + + Globals::ThreeLevelAutoEnum mStatusLightBrightness = Globals::ThreeLevelAutoEnum::kMedium; // Managed lists std::unordered_set mFabricsUsingCamera; - std::vector mRateDistortionTradeOffPointsList; - - std::vector mSupportedSnapshotParamsList; - - uint8_t mRankedVideoStreamPriorities[kNumOfStreamTypes]; + StreamTypeEnum mRankedVideoStreamPriorities[kNumOfStreamTypes]; std::vector mAllocatedVideoStreams; std::vector mAllocatedAudioStreams;