submodule: update connectedhomeip submodule to commit id 8f943388af

This commit is contained in:
WanqQixiang
2026-01-06 09:45:20 +08:00
parent 20385fb136
commit baf5959df1
99 changed files with 6072 additions and 3927 deletions
@@ -12,7 +12,8 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Events.h>
#include <app/clusters/electrical-energy-measurement-server/ElectricalEnergyMeasurementCluster.h>
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
#include <data_model_provider/clusters/electrical_power_measurement/integration.h>
#include <data_model_provider/clusters/electrical_energy_measurement/integration.h>
#include <app/reporting/reporting.h>
#include <app/data-model/Nullable.h>
#include <system/SystemClock.h>
@@ -31,13 +32,10 @@ using namespace chip::app::Clusters::ElectricalPowerMeasurement::Structs;
static const char *TAG = "electrical_measurement";
// A pointer to store our attribute access object
static std::unique_ptr<ElectricalEnergyMeasurementAttrAccess> gEEMAttrAccess;
// Global pointer to our ElectricalPowerMeasurementDelegate
static std::unique_ptr<ElectricalPowerMeasurementDelegate> gEPMDelegate;
// Global pointer to our ElectricalPowerMeasurementInstance
static std::unique_ptr<ElectricalPowerMeasurementInstance> gEPMInstance;
static std::unique_ptr<ElectricalPowerMeasurement::Instance> gEPMInstance;
CHIP_ERROR PowerTopology::PowerTopologyDelegate::GetAvailableEndpointAtIndex(size_t index, EndpointId & endpointId)
{
@@ -116,21 +114,11 @@ esp_err_t electrical_measurement_example(uint16_t endpoint_id)
ESP_LOGI(TAG, "Initializing Electrical Energy Measurement cluster for endpoint %d", endpoint_id);
// First ensure we don't initialize it twice
if (gEEMAttrAccess) {
if (GetClusterInstance(endpoint_id)) {
ESP_LOGI(TAG, "Electrical Energy Measurement cluster already initialized");
return send_energy_measurement_events(endpoint_id);
}
// Create the attribute access instance with the desired features
gEEMAttrAccess = std::make_unique<ElectricalEnergyMeasurementAttrAccess>(
BitMask<ElectricalEnergyMeasurement::Feature, uint32_t>(
ElectricalEnergyMeasurement::Feature::kImportedEnergy,
ElectricalEnergyMeasurement::Feature::kExportedEnergy,
ElectricalEnergyMeasurement::Feature::kCumulativeEnergy,
ElectricalEnergyMeasurement::Feature::kPeriodicEnergy),
BitMask<ElectricalEnergyMeasurement::OptionalAttributes, uint32_t>(
ElectricalEnergyMeasurement::OptionalAttributes::kOptionalAttributeCumulativeEnergyReset));
// Create accuracy ranges for energy measurements
MeasurementAccuracyRangeStruct::Type energyAccuracyRanges[] = {
{
@@ -159,10 +147,7 @@ esp_err_t electrical_measurement_example(uint16_t endpoint_id)
};
// Initialize and set values if attribute access was created successfully
if (gEEMAttrAccess) {
ESP_LOGI(TAG, "Initializing electrical energy measurement attribute access");
gEEMAttrAccess->Init();
if (GetClusterInstance(endpoint_id)) {
// Set accuracy and reset information
CHIP_ERROR err = SetMeasurementAccuracy(endpoint_id, accuracy);
if (err != CHIP_NO_ERROR) {
@@ -9,7 +9,7 @@
#pragma once
#include <esp_err.h>
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
#include <data_model_provider/clusters/electrical_power_measurement/integration.h>
#include <app/util/af-types.h>
#include <lib/core/CHIPError.h>
File diff suppressed because it is too large Load Diff
+184 -241
View File
@@ -25,38 +25,35 @@
// Camera Constraints set to typical values.
// TODO: Look into ways to fetch from hardware, if required/possible.
static constexpr uint32_t kMaxContentBufferSizeBytes = 4096;
static constexpr uint32_t kMaxNetworkBandwidthbps = 128000000; // 128 Mbps
static constexpr uint8_t kMaxConcurrentEncoders = 1;
static constexpr uint8_t kSpeakerMinLevel = 1;
static constexpr uint8_t kSpeakerMaxLevel = 254; // Spec constraint
static constexpr uint8_t kSpeakerMaxChannelCount = 8; // Same as Microphone
static constexpr uint32_t kMaxEncodedPixelRate =
248832000; // 1080p at 120fps(1920 * 1080 * 120)
static constexpr uint8_t kMicrophoneMinLevel = 1;
static constexpr uint8_t kMicrophoneMaxLevel = 254; // Spec constraint
static constexpr uint8_t kMicrophoneMaxChannelCount =
8; // Spec Constraint in AudioStreamAllocate
static constexpr uint16_t kMinResolutionWidth = 640; // Low SD resolution
static constexpr uint16_t kMinResolutionHeight = 360; // Low SD resolution
static constexpr uint16_t k720pResolutionWidth = 1280; // 720p resolution
static constexpr uint16_t k720pResolutionHeight = 720; // 720p resolution
static constexpr uint16_t kMaxResolutionWidth = 1920; // 1080p resolution
static constexpr uint16_t kMaxResolutionHeight = 1080; // 1080p resolution
static constexpr uint16_t kSnapshotStreamFrameRate = 30;
static constexpr uint16_t kMaxVideoFrameRate = 120;
static constexpr uint16_t k60fpsVideoFrameRate = 60;
static constexpr uint16_t kMinVideoFrameRate = 30;
static constexpr uint32_t kMinBitRateBps = 10000; // 10 kbps
static constexpr uint32_t kMaxBitRateBps = 2000000; // 2 mbps
static constexpr uint32_t kKeyFrameIntervalMsec =
4000; // 4 sec; recommendation from Spec
static constexpr uint16_t kVideoSensorWidthPixels = 1920; // 1080p resolution
static constexpr uint16_t kVideoSensorHeightPixels = 1080; // 1080p resolution
static constexpr uint16_t kMinImageRotation = 0;
static constexpr uint16_t kMaxImageRotation = 359; // Spec constraint
static constexpr uint8_t kMaxZones = 10; // Spec has min 1
static constexpr uint8_t kMaxUserDefinedZones = 10; // Spec has min 5
static constexpr uint8_t kSensitivityMax = 10; // Spec has 2 to 10
static constexpr uint32_t kMaxNetworkBandwidthbps = 128000000; // 128 Mbps
static constexpr uint8_t kMaxConcurrentEncoders = 2;
static constexpr uint8_t kSpeakerMinLevel = 1;
static constexpr uint8_t kSpeakerMaxLevel = 254; // Spec constraint
static constexpr uint8_t kSpeakerMaxChannelCount = 8; // Same as Microphone
static constexpr uint32_t kMaxEncodedPixelRate = 373248000; // 1080p at 60fps + 120fps(1920 * 1080 * 180)
static constexpr uint8_t kMicrophoneMinLevel = 1;
static constexpr uint8_t kMicrophoneMaxLevel = 254; // Spec constraint
static constexpr uint8_t kMicrophoneMaxChannelCount = 8; // Spec Constraint in AudioStreamAllocate
static constexpr uint16_t kMinResolutionWidth = 640; // Low SD resolution
static constexpr uint16_t kMinResolutionHeight = 360; // Low SD resolution
static constexpr uint16_t k720pResolutionWidth = 1280; // 720p resolution
static constexpr uint16_t k720pResolutionHeight = 720; // 720p resolution
static constexpr uint16_t kMaxResolutionWidth = 1920; // 1080p resolution
static constexpr uint16_t kMaxResolutionHeight = 1080; // 1080p resolution
static constexpr uint16_t kSnapshotStreamFrameRate = 30;
static constexpr uint16_t kMaxVideoFrameRate = 120;
static constexpr uint16_t k60fpsVideoFrameRate = 60;
static constexpr uint16_t kMinVideoFrameRate = 30;
static constexpr uint32_t kMinBitRateBps = 10000; // 10 kbps
static constexpr uint32_t kMaxBitRateBps = 2000000; // 2 mbps
static constexpr uint32_t kKeyFrameIntervalMsec = 4000; // 4 sec; recommendation from Spec
static constexpr uint16_t kVideoSensorWidthPixels = 1920; // 1080p resolution
static constexpr uint16_t kVideoSensorHeightPixels = 1080; // 1080p resolution
static constexpr uint16_t kMinImageRotation = 0;
static constexpr uint16_t kMaxImageRotation = 359; // Spec constraint
static constexpr uint8_t kMaxZones = 10; // Spec has min 1
static constexpr uint8_t kMaxUserDefinedZones = 10; // Spec has min 5
static constexpr uint8_t kSensitivityMax = 10; // Spec has 2 to 10
// StreamIDs typically start from 0 and monotonically increase. Setting
// Invalid value to a large and practically unused value.
@@ -65,278 +62,224 @@ static constexpr uint16_t kInvalidStreamID = 65500;
namespace Camera {
class CameraDevice : public CameraDeviceInterface,
public CameraDeviceInterface::CameraHALInterface {
class CameraDevice : public CameraDeviceInterface, public CameraDeviceInterface::CameraHALInterface
{
public:
chip::app::Clusters::WebRTCTransportProvider::Delegate &
GetWebRTCProviderDelegate() override;
chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderController &
GetWebRTCProviderController() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamMgmtDelegate &
GetCameraAVStreamMgmtDelegate() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController &
GetCameraAVStreamMgmtController() override;
CameraDevice();
~CameraDevice();
chip::app::Clusters::WebRTCTransportProvider::Delegate & GetWebRTCProviderDelegate() override;
void
SetWebRTCTransportProvider(chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster * provider) override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate & GetCameraAVStreamMgmtDelegate() override;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController & GetCameraAVStreamMgmtController() override;
CameraDevice();
~CameraDevice();
CameraDeviceInterface::CameraHALInterface &GetCameraHALInterface() override {
return *this;
}
CameraDeviceInterface::CameraHALInterface & GetCameraHALInterface() override { return *this; }
void Init();
void Init();
// HAL interface impl
CameraError InitializeCameraDevice() override;
// HAL interface impl
CameraError InitializeCameraDevice() override;
CameraError InitializeStreams() override;
CameraError InitializeStreams() override;
CameraError
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) override;
CameraError CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID, const VideoResolutionStruct & resolution,
ImageSnapshot & outImageSnapshot) override;
// Allocate snapshot stream
CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs &args,
uint16_t &outStreamID) override;
// Allocate snapshot stream
CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs & args,
uint16_t & outStreamID) override;
uint8_t GetMaxConcurrentEncoders() override;
uint8_t GetMaxConcurrentEncoders() override;
uint32_t GetMaxEncodedPixelRate() override;
uint32_t GetMaxEncodedPixelRate() override;
VideoSensorParamsStruct &GetVideoSensorParams() override;
VideoSensorParamsStruct & GetVideoSensorParams() override;
bool GetCameraSupportsHDR() override;
bool GetCameraSupportsHDR() override;
bool GetCameraSupportsNightVision() override;
bool GetCameraSupportsNightVision() override;
bool GetNightVisionUsesInfrared() override;
bool GetNightVisionUsesInfrared() override;
bool GetCameraSupportsWatermark() override;
bool GetCameraSupportsWatermark() override;
bool GetCameraSupportsOSD() override;
bool GetCameraSupportsOSD() override;
bool GetCameraSupportsSoftPrivacy() override;
bool GetCameraSupportsSoftPrivacy() override;
bool GetCameraSupportsImageControl() override;
bool GetCameraSupportsImageControl() override;
VideoResolutionStruct &GetMinViewport() override;
VideoResolutionStruct & GetMinViewport() override;
std::vector<RateDistortionTradeOffStruct> &
GetRateDistortionTradeOffPoints() override;
std::vector<RateDistortionTradeOffStruct> & GetRateDistortionTradeOffPoints() override;
uint32_t GetMaxContentBufferSize() override;
uint32_t GetMaxContentBufferSize() override;
AudioCapabilitiesStruct &GetMicrophoneCapabilities() override;
AudioCapabilitiesStruct & GetMicrophoneCapabilities() override;
AudioCapabilitiesStruct &GetSpeakerCapabilities() override;
AudioCapabilitiesStruct & GetSpeakerCapabilities() override;
std::vector<SnapshotCapabilitiesStruct> &GetSnapshotCapabilities() override;
std::vector<SnapshotCapabilitiesStruct> & GetSnapshotCapabilities() override;
uint32_t GetMaxNetworkBandwidth() override;
uint32_t GetMaxNetworkBandwidth() override;
uint16_t GetCurrentFrameRate() override;
uint16_t GetCurrentFrameRate() override;
CameraError SetHDRMode(bool hdrMode) override;
bool GetHDRMode() override { return mHDREnabled; }
CameraError SetHDRMode(bool hdrMode) override;
bool GetHDRMode() override { return mHDREnabled; }
CameraError SetHardPrivacyMode(bool hardPrivacyMode) override;
bool GetHardPrivacyMode() override { return mHardPrivacyModeOn; }
CameraError SetHardPrivacyMode(bool hardPrivacyMode) override;
bool GetHardPrivacyMode() override { return mHardPrivacyModeOn; }
CameraError
SetNightVision(chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum
nightVision) override;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum
GetNightVision() override {
return mNightVision;
}
CameraError SetNightVision(chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum nightVision) override;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum GetNightVision() override { return mNightVision; }
std::vector<StreamUsageEnum> &GetSupportedStreamUsages() override;
std::vector<StreamUsageEnum> & GetSupportedStreamUsages() override;
std::vector<StreamUsageEnum> &GetStreamUsagePriorities() override {
return mStreamUsagePriorities;
}
CameraError SetStreamUsagePriorities(
std::vector<StreamUsageEnum> streamUsagePriorities) override;
std::vector<StreamUsageEnum> & GetStreamUsagePriorities() override { return mStreamUsagePriorities; }
CameraError SetStreamUsagePriorities(std::vector<StreamUsageEnum> streamUsagePriorities) override;
// Sets the Default Camera Viewport
CameraError
SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) override;
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type &
GetViewport() override {
return mViewport;
}
// Sets the Default Camera Viewport
CameraError SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) override;
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & GetViewport() override { return mViewport; }
/**
* Sets the Viewport for a specific stream. The implementation of this HAL API
* is responsible for updating the stream identified with the provided
* viewport. The invoker of this API shall have already ensured that the
* provided viewport conforms to the specification requirements on size and
* aspect ratio.
*
* @param stream the currently allocated video stream on which the viewport
* is being set
* @param viewport the viewport to be set on the stream
*/
CameraError
SetViewport(VideoStream &stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewport) override;
/**
* Sets the Viewport for a specific stream. The implementation of this HAL API
* is responsible for updating the stream identified with the provided
* viewport. The invoker of this API shall have already ensured that the
* provided viewport conforms to the specification requirements on size and
* aspect ratio.
*
* @param stream the currently allocated video stream on which the viewport
* is being set
* @param viewport the viewport to be set on the stream
*/
CameraError SetViewport(VideoStream & stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewport) override;
// Get/Set SoftRecordingPrivacyMode.
CameraError
SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) override;
bool GetSoftRecordingPrivacyModeEnabled() override {
return mSoftRecordingPrivacyModeEnabled;
}
// Get/Set SoftRecordingPrivacyMode.
CameraError SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) override;
bool GetSoftRecordingPrivacyModeEnabled() override { return mSoftRecordingPrivacyModeEnabled; }
// Get/Set SoftLivestreamPrivacyMode.
CameraError
SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) override;
bool GetSoftLivestreamPrivacyModeEnabled() override {
return mSoftLivestreamPrivacyModeEnabled;
}
// Get/Set SoftLivestreamPrivacyMode.
CameraError SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) override;
bool GetSoftLivestreamPrivacyModeEnabled() override { return mSoftLivestreamPrivacyModeEnabled; }
// Currently, defaulting to not supporting hard privacy switch.
bool HasHardPrivacySwitch() override { return false; }
// Currently, defaulting to not supporting hard privacy switch.
bool HasHardPrivacySwitch() override { return false; }
// Currently, defaulting to not supporting speaker.
bool HasSpeaker() override { return false; }
// Currently, defaulting to not supporting speaker.
bool HasSpeaker() override { return false; }
// Mute/Unmute speaker.
CameraError SetSpeakerMuted(bool muteSpeaker) override;
bool GetSpeakerMuted() override { return mSpeakerMuted; }
// Mute/Unmute speaker.
CameraError SetSpeakerMuted(bool muteSpeaker) override;
bool GetSpeakerMuted() override { return mSpeakerMuted; }
// Get/Set speaker volume level.
CameraError SetSpeakerVolume(uint8_t speakerVol) override;
uint8_t GetSpeakerVolume() override { return mSpeakerVol; }
// Get/Set speaker volume level.
CameraError SetSpeakerVolume(uint8_t speakerVol) override;
uint8_t GetSpeakerVolume() override { return mSpeakerVol; }
// Get the speaker max and min levels.
uint8_t GetSpeakerMaxLevel() override { return INVALID_SPKR_LEVEL; }
uint8_t GetSpeakerMinLevel() override { return INVALID_SPKR_LEVEL; }
// Get the speaker max and min levels.
uint8_t GetSpeakerMaxLevel() override { return INVALID_SPKR_LEVEL; }
uint8_t GetSpeakerMinLevel() override { return INVALID_SPKR_LEVEL; }
// Does camera have a microphone
bool HasMicrophone() override { return true; }
// Does camera have a microphone
bool HasMicrophone() override { return true; }
// Mute/Unmute microphone.
CameraError SetMicrophoneMuted(bool muteMicrophone) override;
bool GetMicrophoneMuted() override { return mMicrophoneMuted; }
// Mute/Unmute microphone.
CameraError SetMicrophoneMuted(bool muteMicrophone) override;
bool GetMicrophoneMuted() override { return mMicrophoneMuted; }
// Set microphone volume level.
CameraError SetMicrophoneVolume(uint8_t microphoneVol) override;
uint8_t GetMicrophoneVolume() override { return mMicrophoneVol; }
// Set microphone volume level.
CameraError SetMicrophoneVolume(uint8_t microphoneVol) override;
uint8_t GetMicrophoneVolume() override { return mMicrophoneVol; }
// Get the microphone max and min levels.
uint8_t GetMicrophoneMaxLevel() override { return mMicrophoneMaxLevel; }
uint8_t GetMicrophoneMinLevel() override { return mMicrophoneMinLevel; }
// Get the microphone max and min levels.
uint8_t GetMicrophoneMaxLevel() override { return mMicrophoneMaxLevel; }
uint8_t GetMicrophoneMinLevel() override { return mMicrophoneMinLevel; }
// Get/Set image control attributes
CameraError SetImageRotation(uint16_t imageRotation) override;
uint16_t GetImageRotation() override { return mImageRotation; }
// Get/Set image control attributes
CameraError SetImageRotation(uint16_t imageRotation) override;
uint16_t GetImageRotation() override { return mImageRotation; }
CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) override;
bool GetImageFlipHorizontal() override { return mImageFlipHorizontal; }
CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) override;
bool GetImageFlipHorizontal() override { return mImageFlipHorizontal; }
CameraError SetImageFlipVertical(bool imageFlipVertical) override;
bool GetImageFlipVertical() override { return mImageFlipVertical; }
CameraError SetImageFlipVertical(bool imageFlipVertical) override;
bool GetImageFlipVertical() override { return mImageFlipVertical; }
// Does camera have local storage
bool HasLocalStorage() override { return false; }
// Does camera have local storage
bool HasLocalStorage() override { return false; }
// Set/Get LocalVideoRecordingEnabled
CameraError
SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) override;
bool GetLocalVideoRecordingEnabled() override {
return mLocalVideoRecordingEnabled;
}
// Set/Get LocalVideoRecordingEnabled
CameraError SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) override;
bool GetLocalVideoRecordingEnabled() override { return mLocalVideoRecordingEnabled; }
// Set/Get LocalSnapshotRecordingEnabled
CameraError
SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) override;
bool GetLocalSnapshotRecordingEnabled() override {
return mLocalSnapshotRecordingEnabled;
}
// Set/Get LocalSnapshotRecordingEnabled
CameraError SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) override;
bool GetLocalSnapshotRecordingEnabled() override { return mLocalSnapshotRecordingEnabled; }
// Does camera have a status light
bool HasStatusLight() override { return true; }
// Does camera have a status light
bool HasStatusLight() override { return true; }
// Set/Get StatusLightEnabled
CameraError SetStatusLightEnabled(bool statusLightEnabled) override;
bool GetStatusLightEnabled() override { return mStatusLightEnabled; }
// Set/Get StatusLightEnabled
CameraError SetStatusLightEnabled(bool statusLightEnabled) override;
bool GetStatusLightEnabled() override { return mStatusLightEnabled; }
std::vector<VideoStream> &GetAvailableVideoStreams() override {
return mVideoStreams;
}
std::vector<VideoStream> & GetAvailableVideoStreams() override { return mVideoStreams; }
std::vector<AudioStream> &GetAvailableAudioStreams() override {
return mAudioStreams;
}
std::vector<AudioStream> & GetAvailableAudioStreams() override { return mAudioStreams; }
std::vector<SnapshotStream> &GetAvailableSnapshotStreams() override {
return mSnapshotStreams;
}
std::vector<SnapshotStream> & GetAvailableSnapshotStreams() override { return mSnapshotStreams; }
private:
std::vector<VideoStream>
mVideoStreams; // Vector to hold available video streams
std::vector<AudioStream>
mAudioStreams; // Vector to hold available audio streams
std::vector<SnapshotStream>
mSnapshotStreams; // Vector to hold available snapshot streams
std::vector<VideoStream> mVideoStreams; // Vector to hold available video streams
std::vector<AudioStream> mAudioStreams; // Vector to hold available audio streams
std::vector<SnapshotStream> mSnapshotStreams; // Vector to hold available snapshot streams
void InitializeVideoStreams();
void InitializeAudioStreams();
void InitializeSnapshotStreams();
void InitializeVideoStreams();
void InitializeAudioStreams();
void InitializeSnapshotStreams();
bool AddSnapshotStream(const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamManager::SnapshotStreamAllocateArgs
&snapshotStreamAllocateArgs,
uint16_t &outStreamID);
bool AddSnapshotStream(const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager::SnapshotStreamAllocateArgs &
snapshotStreamAllocateArgs,
uint16_t & outStreamID);
bool MatchClosestSnapshotParams(
const VideoResolutionStruct &requested,
VideoResolutionStruct &outResolution,
chip::app::Clusters::CameraAvStreamManagement::ImageCodecEnum &outCodec);
bool MatchClosestSnapshotParams(const VideoResolutionStruct & requested, VideoResolutionStruct & outResolution,
chip::app::Clusters::CameraAvStreamManagement::ImageCodecEnum & outCodec);
// Various cluster server delegates
chip::app::Clusters::WebRTCTransportProvider::WebRTCProviderManager
mWebRTCProviderManager;
// Various cluster server delegates
chip::app::Clusters::WebRTCTransportProvider::WebRTCProviderManager mWebRTCProviderManager;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager
mCameraAVStreamManager;
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManager mCameraAVStreamManager;
// Use a standard 1080p aspect ratio
chip::app::Clusters::Globals::Structs::ViewportStruct::Type mViewport = {
0, 0, 1920, 1080};
uint16_t mCurrentVideoFrameRate = kMinVideoFrameRate;
bool mHDREnabled = false;
bool mSpeakerMuted = false;
bool mMicrophoneMuted = false;
bool mHardPrivacyModeOn = false;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum mNightVision =
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum::kOff;
bool mSoftRecordingPrivacyModeEnabled = false;
bool mSoftLivestreamPrivacyModeEnabled = false;
uint8_t mSpeakerVol = kSpeakerMinLevel;
uint8_t mSpeakerMinLevel = kSpeakerMinLevel;
uint8_t mSpeakerMaxLevel = kSpeakerMaxLevel;
uint8_t mMicrophoneVol = kMicrophoneMinLevel;
uint8_t mMicrophoneMinLevel = kMicrophoneMinLevel;
uint8_t mMicrophoneMaxLevel = kMicrophoneMaxLevel;
bool mLocalVideoRecordingEnabled = false;
bool mLocalSnapshotRecordingEnabled = false;
bool mStatusLightEnabled = false;
uint16_t mImageRotation = kMinImageRotation;
bool mImageFlipHorizontal = false;
bool mImageFlipVertical = false;
uint8_t mDetectionSensitivity =
(1 + kSensitivityMax) / 2; // Average over the range
// Use a standard 1080p aspect ratio
chip::app::Clusters::Globals::Structs::ViewportStruct::Type mViewport = { 0, 0, 1920, 1080 };
uint16_t mCurrentVideoFrameRate = kMinVideoFrameRate;
bool mHDREnabled = false;
bool mSpeakerMuted = false;
bool mMicrophoneMuted = false;
bool mHardPrivacyModeOn = false;
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum mNightVision =
chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum::kOff;
bool mSoftRecordingPrivacyModeEnabled = false;
bool mSoftLivestreamPrivacyModeEnabled = false;
uint8_t mSpeakerVol = kSpeakerMinLevel;
uint8_t mSpeakerMinLevel = kSpeakerMinLevel;
uint8_t mSpeakerMaxLevel = kSpeakerMaxLevel;
uint8_t mMicrophoneVol = kMicrophoneMinLevel;
uint8_t mMicrophoneMinLevel = kMicrophoneMinLevel;
uint8_t mMicrophoneMaxLevel = kMicrophoneMaxLevel;
bool mLocalVideoRecordingEnabled = false;
bool mLocalSnapshotRecordingEnabled = false;
bool mStatusLightEnabled = false;
uint16_t mImageRotation = kMinImageRotation;
bool mImageFlipHorizontal = false;
bool mImageFlipVertical = false;
uint8_t mDetectionSensitivity = (1 + kSensitivityMax) / 2; // Average over the range
std::vector<StreamUsageEnum> mStreamUsagePriorities = {
StreamUsageEnum::kLiveView, StreamUsageEnum::kRecording};
std::vector<StreamUsageEnum> mStreamUsagePriorities = { StreamUsageEnum::kLiveView, StreamUsageEnum::kRecording };
};
} // namespace Camera
File diff suppressed because it is too large Load Diff
@@ -1,8 +1,25 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "camera-avstream-controller.h"
#include "camera-device-interface.h"
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
#include <app/util/config.h>
#include <vector>
@@ -14,112 +31,90 @@ namespace CameraAvStreamManagement {
/**
* The application delegate to define the options & implement commands.
*/
class CameraAVStreamManager : public CameraAVStreamMgmtDelegate,
public CameraAVStreamController {
class CameraAVStreamManager : public CameraAVStreamManagementDelegate, public CameraAVStreamController
{
public:
Protocols::InteractionModel::Status
VideoStreamAllocate(const VideoStreamStruct &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status VideoStreamAllocate(const VideoStreamStruct & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
VideoStreamModify(const uint16_t streamID,
const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status VideoStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status
VideoStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status VideoStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status
AudioStreamAllocate(const AudioStreamStruct &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status AudioStreamAllocate(const AudioStreamStruct & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
AudioStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status AudioStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status
SnapshotStreamAllocate(const SnapshotStreamAllocateArgs &allocateArgs,
uint16_t &outStreamID) override;
Protocols::InteractionModel::Status SnapshotStreamAllocate(const SnapshotStreamAllocateArgs & allocateArgs,
uint16_t & outStreamID) override;
Protocols::InteractionModel::Status
SnapshotStreamModify(const uint16_t streamID,
const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status SnapshotStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
const chip::Optional<bool> osdEnabled) override;
Protocols::InteractionModel::Status
SnapshotStreamDeallocate(const uint16_t streamID) override;
Protocols::InteractionModel::Status SnapshotStreamDeallocate(const uint16_t streamID) override;
void OnVideoStreamAllocated(const VideoStreamStruct &allocatedStream,
StreamAllocationAction action) override;
void OnVideoStreamAllocated(const VideoStreamStruct & allocatedStream, StreamAllocationAction action) override;
void OnStreamUsagePrioritiesChanged() override;
void OnStreamUsagePrioritiesChanged() override;
void OnAttributeChanged(AttributeId attributeId) override;
void OnAttributeChanged(AttributeId attributeId) override;
Protocols::InteractionModel::Status
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) override;
Protocols::InteractionModel::Status CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct & resolution,
ImageSnapshot & outImageSnapshot) override;
CHIP_ERROR
ValidateStreamUsage(
StreamUsageEnum streamUsage,
Optional<DataModel::Nullable<uint16_t>> &videoStreamId,
Optional<DataModel::Nullable<uint16_t>> &audioStreamId) override;
CHIP_ERROR
ValidateStreamUsage(StreamUsageEnum streamUsage, Optional<DataModel::Nullable<uint16_t>> & videoStreamId,
Optional<DataModel::Nullable<uint16_t>> & audioStreamId) override;
CHIP_ERROR
ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR
ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR
ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR
ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR IsHardPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsHardPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool & isActive) override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedAudioStreams() override;
bool HasAllocatedAudioStreams() override;
CHIP_ERROR SetHardPrivacyModeOn(bool hardPrivacyMode) override;
CHIP_ERROR SetHardPrivacyModeOn(bool hardPrivacyMode) override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;
CHIP_ERROR PersistentAttributesLoadedCallback() override;
CHIP_ERROR
OnTransportAcquireAudioVideoStreams(uint16_t audioStreamID,
uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportAcquireAudioVideoStreams(uint16_t audioStreamID, uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportReleaseAudioVideoStreams(uint16_t audioStreamID,
uint16_t videoStreamID) override;
CHIP_ERROR
OnTransportReleaseAudioVideoStreams(uint16_t audioStreamID, uint16_t videoStreamID) override;
const std::vector<
chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct> &
GetAllocatedVideoStreams() const override;
const std::vector<chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct> & GetAllocatedVideoStreams() const override;
const std::vector<
chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct> &
GetAllocatedAudioStreams() const override;
const std::vector<chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct> & GetAllocatedAudioStreams() const override;
void GetBandwidthForStreams(
const Optional<DataModel::Nullable<uint16_t>> &videoStreamId,
const Optional<DataModel::Nullable<uint16_t>> &audioStreamId,
uint32_t &outBandwidthbps) override;
void GetBandwidthForStreams(const Optional<DataModel::Nullable<uint16_t>> & videoStreamId,
const Optional<DataModel::Nullable<uint16_t>> & audioStreamId, uint32_t & outBandwidthbps) override;
CameraAVStreamManager() = default;
~CameraAVStreamManager() = default;
CameraAVStreamManager() = default;
~CameraAVStreamManager() = default;
void SetCameraDeviceHAL(CameraDeviceInterface *aCameraDevice);
void SetCameraDeviceHAL(CameraDeviceInterface * aCameraDevice);
private:
CHIP_ERROR AllocatedVideoStreamsLoaded();
CHIP_ERROR AllocatedVideoStreamsLoaded();
CHIP_ERROR AllocatedAudioStreamsLoaded();
CHIP_ERROR AllocatedAudioStreamsLoaded();
CHIP_ERROR AllocatedSnapshotStreamsLoaded();
CHIP_ERROR AllocatedSnapshotStreamsLoaded();
CameraDeviceInterface *mCameraDeviceHAL = nullptr;
CameraDeviceInterface * mCameraDeviceHAL = nullptr;
};
} // namespace CameraAvStreamManagement
File diff suppressed because it is too large Load Diff
@@ -1,9 +1,26 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "camera-device-interface.h"
#include <app-common/zap-generated/cluster-enums.h>
#include <app/CASESessionManager.h>
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
#include <map>
#include <webrtc-transport.h>
@@ -12,156 +29,129 @@ namespace app {
namespace Clusters {
namespace WebRTCTransportProvider {
using ICEServerDecodableStruct =
chip::app::Clusters::Globals::Structs::ICEServerStruct::DecodableType;
using WebRTCSessionStruct =
chip::app::Clusters::Globals::Structs::WebRTCSessionStruct::Type;
using ICECandidateStruct =
chip::app::Clusters::Globals::Structs::ICECandidateStruct::Type;
using StreamUsageEnum = chip::app::Clusters::Globals::StreamUsageEnum;
using WebRTCEndReasonEnum = chip::app::Clusters::Globals::WebRTCEndReasonEnum;
using ICEServerDecodableStruct = chip::app::Clusters::Globals::Structs::ICEServerStruct::DecodableType;
using WebRTCSessionStruct = chip::app::Clusters::Globals::Structs::WebRTCSessionStruct::Type;
using ICECandidateStruct = chip::app::Clusters::Globals::Structs::ICECandidateStruct::Type;
using StreamUsageEnum = chip::app::Clusters::Globals::StreamUsageEnum;
using WebRTCEndReasonEnum = chip::app::Clusters::Globals::WebRTCEndReasonEnum;
class WebRTCProviderManager : public Delegate,
public WebRTCTransportProviderController {
class WebRTCProviderManager : public Delegate
{
public:
WebRTCProviderManager()
: mOnConnectedCallback(OnDeviceConnected, this),
mOnConnectionFailureCallback(OnDeviceConnectionFailure, this) {}
WebRTCProviderManager() :
mOnConnectedCallback(OnDeviceConnected, this), mOnConnectionFailureCallback(OnDeviceConnectionFailure, this)
{}
~WebRTCProviderManager() { CloseConnection(); };
~WebRTCProviderManager() { CloseConnection(); };
void Init();
void Init();
void CloseConnection();
void CloseConnection();
void SetWebRTCTransportProvider(std::unique_ptr<WebRTCTransportProviderServer>
webRTCTransportProvider) override;
void SetWebRTCTransportProvider(WebRTCTransportProviderCluster * webRTCTransportProvider);
CHIP_ERROR HandleSolicitOffer(
const OfferRequestArgs &args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct
&outSession,
bool &outDeferredOffer) override;
CHIP_ERROR HandleSolicitOffer(const OfferRequestArgs & args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct & outSession,
bool & outDeferredOffer) override;
CHIP_ERROR
HandleProvideOffer(
const ProvideOfferRequestArgs &args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct
&outSession) override;
CHIP_ERROR
HandleProvideOffer(const ProvideOfferRequestArgs & args,
chip::app::Clusters::WebRTCTransportProvider::WebRTCSessionStruct & outSession) override;
CHIP_ERROR HandleProvideAnswer(uint16_t sessionId,
const std::string &sdpAnswer) override;
CHIP_ERROR HandleProvideAnswer(uint16_t sessionId, const std::string & sdpAnswer) override;
CHIP_ERROR HandleProvideICECandidates(
uint16_t sessionId,
const std::vector<ICECandidateStruct> &candidates) override;
CHIP_ERROR HandleProvideICECandidates(uint16_t sessionId, const std::vector<ICECandidateStruct> & candidates) override;
CHIP_ERROR HandleEndSession(
uint16_t sessionId,
chip::app::Clusters::WebRTCTransportProvider::WebRTCEndReasonEnum
reasonCode,
chip::app::DataModel::Nullable<uint16_t> videoStreamID,
chip::app::DataModel::Nullable<uint16_t> audioStreamID) override;
CHIP_ERROR HandleEndSession(uint16_t sessionId, chip::app::Clusters::WebRTCTransportProvider::WebRTCEndReasonEnum reasonCode,
chip::app::DataModel::Nullable<uint16_t> videoStreamID,
chip::app::DataModel::Nullable<uint16_t> audioStreamID) override;
CHIP_ERROR ValidateStreamUsage(
StreamUsageEnum streamUsage,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> &videoStreamId,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> &audioStreamId)
override;
CHIP_ERROR ValidateStreamUsage(StreamUsageEnum streamUsage,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> & videoStreamId,
chip::Optional<chip::app::DataModel::Nullable<uint16_t>> & audioStreamId) override;
void SetCameraDevice(CameraDeviceInterface *aCameraDevice);
void SetCameraDevice(CameraDeviceInterface * aCameraDevice);
CHIP_ERROR ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR ValidateVideoStreamID(uint16_t videoStreamId) override;
CHIP_ERROR ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR ValidateAudioStreamID(uint16_t audioStreamId) override;
CHIP_ERROR IsStreamUsageSupported(StreamUsageEnum streamUsage) override;
CHIP_ERROR IsStreamUsageSupported(StreamUsageEnum streamUsage) override;
CHIP_ERROR IsHardPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsHardPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftRecordingPrivacyModeActive(bool & isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool &isActive) override;
CHIP_ERROR IsSoftLivestreamPrivacyModeActive(bool & isActive) override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedVideoStreams() override;
bool HasAllocatedAudioStreams() override;
bool HasAllocatedAudioStreams() override;
CHIP_ERROR ValidateSFrameConfig(uint16_t cipherSuite, size_t baseKeyLength) override;
CHIP_ERROR ValidateSFrameConfig(uint16_t cipherSuite, size_t baseKeyLength) override;
CHIP_ERROR IsUTCTimeNull(bool & isNull) override;
CHIP_ERROR IsUTCTimeNull(bool & isNull) override;
void LiveStreamPrivacyModeChanged(bool privacyModeEnabled);
void LiveStreamPrivacyModeChanged(bool privacyModeEnabled);
WebrtcTransport *GetTransport(uint16_t sessionId);
WebrtcTransport * GetTransport(uint16_t sessionId);
private:
void ScheduleOfferSend(uint16_t sessionId);
void ScheduleOfferSend(uint16_t sessionId);
void ScheduleICECandidatesSend(uint16_t sessionId);
void ScheduleICECandidatesSend(uint16_t sessionId);
void ScheduleAnswerSend(uint16_t sessionId);
void ScheduleAnswerSend(uint16_t sessionId);
void ScheduleEndSend(uint16_t sessionId);
void ScheduleEndSend(uint16_t sessionId);
void RegisterWebrtcTransport(uint16_t sessionId);
void RegisterWebrtcTransport(uint16_t sessionId);
void UnregisterWebrtcTransport(uint16_t sessionId);
void UnregisterWebrtcTransport(uint16_t sessionId);
CHIP_ERROR SendOfferCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendOfferCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendAnswerCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendAnswerCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR
SendICECandidatesCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId);
CHIP_ERROR
SendICECandidatesCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId);
CHIP_ERROR SendEndCommand(chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle,
uint16_t sessionId, WebRTCEndReasonEnum endReason);
CHIP_ERROR SendEndCommand(chip::Messaging::ExchangeManager & exchangeMgr, const chip::SessionHandle & sessionHandle,
uint16_t sessionId, WebRTCEndReasonEnum endReason);
CHIP_ERROR AcquireAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR AcquireAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR ReleaseAudioVideoStreams(uint16_t sessionId);
CHIP_ERROR ReleaseAudioVideoStreams(uint16_t sessionId);
static void OnDeviceConnected(void *context,
chip::Messaging::ExchangeManager &exchangeMgr,
const chip::SessionHandle &sessionHandle);
static void OnDeviceConnected(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
const chip::SessionHandle & sessionHandle);
static void OnDeviceConnectionFailure(void *context,
const chip::ScopedNodeId &peerId,
CHIP_ERROR error);
static void OnDeviceConnectionFailure(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error);
// WebRTC Callbacks
void OnLocalDescription(const std::string &sdp, SDPType type,
const uint16_t sessionId);
void OnConnectionStateChanged(bool connected, const uint16_t sessionId);
// WebRTC Callbacks
void OnLocalDescription(const std::string & sdp, SDPType type, const uint16_t sessionId);
void OnConnectionStateChanged(bool connected, const uint16_t sessionId);
chip::Callback::Callback<chip::OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure>
mOnConnectionFailureCallback;
chip::Callback::Callback<chip::OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnConnectionFailureCallback;
std::unordered_map<uint16_t, std::unique_ptr<WebrtcTransport>>
mWebrtcTransportMap;
// This is to retrieve the sessionIds for a given NodeId
std::map<ScopedNodeId, uint16_t> mSessionIdMap;
std::unordered_map<uint16_t, std::unique_ptr<WebrtcTransport>> mWebrtcTransportMap;
// This is to retrieve the sessionIds for a given NodeId
std::map<ScopedNodeId, uint16_t> mSessionIdMap;
std::unique_ptr<WebRTCTransportProviderServer> mWebRTCTransportProvider =
nullptr;
WebRTCTransportProviderCluster * mWebRTCTransportProvider = nullptr;
// Handle to the Camera Device interface. For accessing other
// clusters, if required.
CameraDeviceInterface *mCameraDevice = nullptr;
// Handle to the Camera Device interface. For accessing other
// clusters, if required.
CameraDeviceInterface * mCameraDevice = nullptr;
bool mSoftLiveStreamPrivacyEnabled = false;
bool mSoftLiveStreamPrivacyEnabled = false;
};
} // namespace WebRTCTransportProvider
} // namespace Clusters
} // namespace app
} // namespace chip
} // namespace chip
+195 -187
View File
@@ -1,4 +1,22 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "camera-app.h"
#include "esp_matter_data_model_provider.h"
using namespace chip;
using namespace chip::app;
@@ -9,235 +27,225 @@ using namespace chip::app::Clusters::CameraAvStreamManagement;
static constexpr uint32_t kBitsPerMegabit = 1000000;
template <typename T> using List = chip::app::DataModel::List<T>;
template <typename T>
using List = chip::app::DataModel::List<T>;
using Status = Protocols::InteractionModel::Status;
CameraApp::CameraApp(chip::EndpointId aClustersEndpoint,
CameraDeviceInterface *aCameraDevice) {
mEndpoint = aClustersEndpoint;
mCameraDevice = aCameraDevice;
CameraApp::CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface * aCameraDevice)
{
mEndpoint = aClustersEndpoint;
mCameraDevice = aCameraDevice;
// Instantiate WebRTCTransport Provider
mWebRTCTransportProviderPtr = std::make_unique<WebRTCTransportProviderServer>(
mCameraDevice->GetWebRTCProviderDelegate(), mEndpoint);
// Fetch all initialization parameters for CameraAVStreamMgmt Server
BitFlags<CameraAvStreamManagement::Feature> avsmFeatures;
BitFlags<CameraAvStreamManagement::OptionalAttribute> avsmOptionalAttrs;
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSnapshot);
avsmFeatures.Set(CameraAvStreamManagement::Feature::kVideo);
// Fetch all initialization parameters for CameraAVStreamMgmt Server
BitFlags<CameraAvStreamManagement::Feature> avsmFeatures;
BitFlags<CameraAvStreamManagement::OptionalAttribute> avsmOptionalAttrs;
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSnapshot);
avsmFeatures.Set(CameraAvStreamManagement::Feature::kVideo);
// Enable the Watermark and OSD features if camera supports
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsWatermark())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kWatermark);
}
// Enable the Watermark and OSD features if camera supports
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsWatermark()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kWatermark);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsOSD())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kOnScreenDisplay);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsOSD()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kOnScreenDisplay);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kPrivacy);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kPrivacy);
}
// Check microphone support to set Audio feature
if (mCameraDevice->GetCameraHALInterface().HasMicrophone())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kAudio);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kMicrophoneAGCEnabled);
}
// Check microphone support to set Audio feature
if (mCameraDevice->GetCameraHALInterface().HasMicrophone()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kAudio);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kMicrophoneAGCEnabled);
}
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kLocalStorage);
}
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kLocalStorage);
}
// Check if camera has speaker
if (mCameraDevice->GetCameraHALInterface().HasSpeaker())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSpeaker);
}
// Check if camera has speaker
if (mCameraDevice->GetCameraHALInterface().HasSpeaker()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kSpeaker);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kHighDynamicRange);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kHighDynamicRange);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kNightVision);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kNightVisionIllum);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kNightVision);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kNightVisionIllum);
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch())
{
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kHardPrivacyModeOn);
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch()) {
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kHardPrivacyModeOn);
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight())
{
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kStatusLightEnabled);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kStatusLightBrightness);
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight()) {
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kStatusLightEnabled);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kStatusLightBrightness);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl())
{
avsmFeatures.Set(CameraAvStreamManagement::Feature::kImageControl);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageFlipVertical);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageFlipHorizontal);
avsmOptionalAttrs.Set(CameraAvStreamManagement::OptionalAttribute::kImageRotation);
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl()) {
avsmFeatures.Set(CameraAvStreamManagement::Feature::kImageControl);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageFlipVertical);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageFlipHorizontal);
avsmOptionalAttrs.Set(
CameraAvStreamManagement::OptionalAttribute::kImageRotation);
}
uint32_t maxConcurrentVideoEncoders = mCameraDevice->GetCameraHALInterface().GetMaxConcurrentEncoders();
uint32_t maxEncodedPixelRate = mCameraDevice->GetCameraHALInterface().GetMaxEncodedPixelRate();
VideoSensorParamsStruct sensorParams = mCameraDevice->GetCameraHALInterface().GetVideoSensorParams();
bool nightVisionUsesInfrared = mCameraDevice->GetCameraHALInterface().GetNightVisionUsesInfrared();
VideoResolutionStruct minViewport = mCameraDevice->GetCameraHALInterface().GetMinViewport();
std::vector<RateDistortionTradeOffStruct> rateDistortionTradeOffPoints =
mCameraDevice->GetCameraHALInterface().GetRateDistortionTradeOffPoints();
uint32_t maxConcurrentVideoEncoders =
mCameraDevice->GetCameraHALInterface().GetMaxConcurrentEncoders();
uint32_t maxEncodedPixelRate =
mCameraDevice->GetCameraHALInterface().GetMaxEncodedPixelRate();
VideoSensorParamsStruct sensorParams =
mCameraDevice->GetCameraHALInterface().GetVideoSensorParams();
bool nightVisionUsesInfrared =
mCameraDevice->GetCameraHALInterface().GetNightVisionUsesInfrared();
VideoResolutionStruct minViewport =
mCameraDevice->GetCameraHALInterface().GetMinViewport();
std::vector<RateDistortionTradeOffStruct> rateDistortionTradeOffPoints =
mCameraDevice->GetCameraHALInterface().GetRateDistortionTradeOffPoints();
uint32_t maxContentBufferSize = mCameraDevice->GetCameraHALInterface().GetMaxContentBufferSize();
AudioCapabilitiesStruct micCapabilities = mCameraDevice->GetCameraHALInterface().GetMicrophoneCapabilities();
AudioCapabilitiesStruct spkrCapabilities = mCameraDevice->GetCameraHALInterface().GetSpeakerCapabilities();
TwoWayTalkSupportTypeEnum twowayTalkSupport =
mCameraDevice->GetCameraHALInterface().HasMicrophone() && mCameraDevice->GetCameraHALInterface().HasSpeaker()
? TwoWayTalkSupportTypeEnum::kFullDuplex
: TwoWayTalkSupportTypeEnum::kNotSupported;
std::vector<SnapshotCapabilitiesStruct> snapshotCapabilities = mCameraDevice->GetCameraHALInterface().GetSnapshotCapabilities();
uint32_t maxNetworkBandwidth = mCameraDevice->GetCameraHALInterface().GetMaxNetworkBandwidth() * kBitsPerMegabit;
std::vector<StreamUsageEnum> supportedStreamUsages = mCameraDevice->GetCameraHALInterface().GetSupportedStreamUsages();
std::vector<StreamUsageEnum> streamUsagePriorities = mCameraDevice->GetCameraHALInterface().GetStreamUsagePriorities();
uint32_t maxContentBufferSize =
mCameraDevice->GetCameraHALInterface().GetMaxContentBufferSize();
AudioCapabilitiesStruct micCapabilities =
mCameraDevice->GetCameraHALInterface().GetMicrophoneCapabilities();
AudioCapabilitiesStruct spkrCapabilities =
mCameraDevice->GetCameraHALInterface().GetSpeakerCapabilities();
TwoWayTalkSupportTypeEnum twowayTalkSupport =
mCameraDevice->GetCameraHALInterface().HasMicrophone() &&
mCameraDevice->GetCameraHALInterface().HasSpeaker()
? TwoWayTalkSupportTypeEnum::kFullDuplex
: TwoWayTalkSupportTypeEnum::kNotSupported;
std::vector<SnapshotCapabilitiesStruct> snapshotCapabilities =
mCameraDevice->GetCameraHALInterface().GetSnapshotCapabilities();
uint32_t maxNetworkBandwidth =
mCameraDevice->GetCameraHALInterface().GetMaxNetworkBandwidth() *
kBitsPerMegabit;
std::vector<StreamUsageEnum> supportedStreamUsages =
mCameraDevice->GetCameraHALInterface().GetSupportedStreamUsages();
std::vector<StreamUsageEnum> streamUsagePriorities =
mCameraDevice->GetCameraHALInterface().GetStreamUsagePriorities();
// Instantiate the CameraAVStreamMgmt Server
mAVStreamMgmtServerPtr = std::make_unique<CameraAVStreamMgmtServer>(
mCameraDevice->GetCameraAVStreamMgmtDelegate(), mEndpoint, avsmFeatures,
avsmOptionalAttrs, maxConcurrentVideoEncoders, maxEncodedPixelRate,
sensorParams, nightVisionUsesInfrared, minViewport,
rateDistortionTradeOffPoints, maxContentBufferSize, micCapabilities,
spkrCapabilities, twowayTalkSupport, snapshotCapabilities,
maxNetworkBandwidth, supportedStreamUsages, streamUsagePriorities);
// Instantiate the CameraAVStreamMgmt Server
mAVStreamMgmtServerPtr = std::make_unique<CameraAVStreamManagementCluster>(
mCameraDevice->GetCameraAVStreamMgmtDelegate(), mEndpoint, avsmFeatures, avsmOptionalAttrs, maxConcurrentVideoEncoders,
maxEncodedPixelRate, sensorParams, nightVisionUsesInfrared, minViewport, rateDistortionTradeOffPoints, maxContentBufferSize,
micCapabilities, spkrCapabilities, twowayTalkSupport, snapshotCapabilities, maxNetworkBandwidth, supportedStreamUsages,
streamUsagePriorities);
}
void CameraApp::InitializeCameraAVStreamMgmt() {
// Set the attribute defaults
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR()) {
mAVStreamMgmtServerPtr->SetHDRModeEnabled(
mCameraDevice->GetCameraHALInterface().GetHDRMode());
}
void CameraApp::InitializeCameraAVStreamMgmt()
{
// Set the attribute defaults
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsHDR())
{
mAVStreamMgmtServerPtr->SetHDRModeEnabled(mCameraDevice->GetCameraHALInterface().GetHDRMode());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy()) {
mAVStreamMgmtServerPtr->SetSoftRecordingPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface()
.GetSoftRecordingPrivacyModeEnabled());
mAVStreamMgmtServerPtr->SetSoftLivestreamPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface()
.GetSoftLivestreamPrivacyModeEnabled());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsSoftPrivacy())
{
mAVStreamMgmtServerPtr->SetSoftRecordingPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface().GetSoftRecordingPrivacyModeEnabled());
mAVStreamMgmtServerPtr->SetSoftLivestreamPrivacyModeEnabled(
mCameraDevice->GetCameraHALInterface().GetSoftLivestreamPrivacyModeEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch()) {
mAVStreamMgmtServerPtr->SetHardPrivacyModeOn(
mCameraDevice->GetCameraHALInterface().GetHardPrivacyMode());
}
if (mCameraDevice->GetCameraHALInterface().HasHardPrivacySwitch())
{
mAVStreamMgmtServerPtr->SetHardPrivacyModeOn(mCameraDevice->GetCameraHALInterface().GetHardPrivacyMode());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision()) {
mAVStreamMgmtServerPtr->SetNightVision(
mCameraDevice->GetCameraHALInterface().GetNightVision());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsNightVision())
{
mAVStreamMgmtServerPtr->SetNightVision(mCameraDevice->GetCameraHALInterface().GetNightVision());
}
mAVStreamMgmtServerPtr->SetViewport(
mCameraDevice->GetCameraHALInterface().GetViewport());
mAVStreamMgmtServerPtr->SetViewport(mCameraDevice->GetCameraHALInterface().GetViewport());
if (mCameraDevice->GetCameraHALInterface().HasSpeaker()) {
mAVStreamMgmtServerPtr->SetSpeakerMuted(
mCameraDevice->GetCameraHALInterface().GetSpeakerMuted());
mAVStreamMgmtServerPtr->SetSpeakerVolumeLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerVolume());
mAVStreamMgmtServerPtr->SetSpeakerMaxLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerMaxLevel());
mAVStreamMgmtServerPtr->SetSpeakerMinLevel(
mCameraDevice->GetCameraHALInterface().GetSpeakerMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasSpeaker())
{
mAVStreamMgmtServerPtr->SetSpeakerMuted(mCameraDevice->GetCameraHALInterface().GetSpeakerMuted());
mAVStreamMgmtServerPtr->SetSpeakerVolumeLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerVolume());
mAVStreamMgmtServerPtr->SetSpeakerMaxLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerMaxLevel());
mAVStreamMgmtServerPtr->SetSpeakerMinLevel(mCameraDevice->GetCameraHALInterface().GetSpeakerMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasMicrophone()) {
mAVStreamMgmtServerPtr->SetMicrophoneMuted(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMuted());
mAVStreamMgmtServerPtr->SetMicrophoneVolumeLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneVolume());
mAVStreamMgmtServerPtr->SetMicrophoneMaxLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMaxLevel());
mAVStreamMgmtServerPtr->SetMicrophoneMinLevel(
mCameraDevice->GetCameraHALInterface().GetMicrophoneMinLevel());
}
if (mCameraDevice->GetCameraHALInterface().HasMicrophone())
{
mAVStreamMgmtServerPtr->SetMicrophoneMuted(mCameraDevice->GetCameraHALInterface().GetMicrophoneMuted());
mAVStreamMgmtServerPtr->SetMicrophoneVolumeLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneVolume());
mAVStreamMgmtServerPtr->SetMicrophoneMaxLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneMaxLevel());
mAVStreamMgmtServerPtr->SetMicrophoneMinLevel(mCameraDevice->GetCameraHALInterface().GetMicrophoneMinLevel());
}
// Video and Snapshot features are already enabled.
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage()) {
mAVStreamMgmtServerPtr->SetLocalVideoRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalVideoRecordingEnabled());
mAVStreamMgmtServerPtr->SetLocalSnapshotRecordingEnabled(
mCameraDevice->GetCameraHALInterface()
.GetLocalSnapshotRecordingEnabled());
}
// Video and Snapshot features are already enabled.
if (mCameraDevice->GetCameraHALInterface().HasLocalStorage())
{
mAVStreamMgmtServerPtr->SetLocalVideoRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalVideoRecordingEnabled());
mAVStreamMgmtServerPtr->SetLocalSnapshotRecordingEnabled(
mCameraDevice->GetCameraHALInterface().GetLocalSnapshotRecordingEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight()) {
mAVStreamMgmtServerPtr->SetStatusLightEnabled(
mCameraDevice->GetCameraHALInterface().GetStatusLightEnabled());
}
if (mCameraDevice->GetCameraHALInterface().HasStatusLight())
{
mAVStreamMgmtServerPtr->SetStatusLightEnabled(mCameraDevice->GetCameraHALInterface().GetStatusLightEnabled());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl()) {
mAVStreamMgmtServerPtr->SetImageRotation(
mCameraDevice->GetCameraHALInterface().GetImageRotation());
mAVStreamMgmtServerPtr->SetImageFlipVertical(
mCameraDevice->GetCameraHALInterface().GetImageFlipVertical());
mAVStreamMgmtServerPtr->SetImageFlipHorizontal(
mCameraDevice->GetCameraHALInterface().GetImageFlipHorizontal());
}
if (mCameraDevice->GetCameraHALInterface().GetCameraSupportsImageControl())
{
mAVStreamMgmtServerPtr->SetImageRotation(mCameraDevice->GetCameraHALInterface().GetImageRotation());
mAVStreamMgmtServerPtr->SetImageFlipVertical(mCameraDevice->GetCameraHALInterface().GetImageFlipVertical());
mAVStreamMgmtServerPtr->SetImageFlipHorizontal(mCameraDevice->GetCameraHALInterface().GetImageFlipHorizontal());
}
mAVStreamMgmtServerPtr->Init();
mAVStreamMgmtServerPtr->Init();
}
void CameraApp::InitCameraDeviceClusters() {
// Initialize Cluster Servers
mWebRTCTransportProviderPtr->Init();
mCameraDevice->GetWebRTCProviderController().SetWebRTCTransportProvider(
std::move(mWebRTCTransportProviderPtr));
InitializeCameraAVStreamMgmt();
void CameraApp::InitCameraDeviceClusters()
{
// Initialize Cluster Servers
mWebRTCTransportProviderServer.Create(mEndpoint, mCameraDevice->GetWebRTCProviderDelegate());
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Register(mWebRTCTransportProviderServer.Registration());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Camera,
"Failed to register WebRTCTransportProvider on endpoint %u: "
"%" CHIP_ERROR_FORMAT,
mEndpoint, err.Format());
}
InitializeCameraAVStreamMgmt();
}
void CameraApp::ShutdownCameraDeviceClusters() {
ChipLogDetail(Camera,
"CameraAppShutdown: Shutting down Camera device clusters");
mWebRTCTransportProviderPtr->Shutdown();
void CameraApp::ShutdownCameraDeviceClusters()
{
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera device clusters");
CHIP_ERROR err = esp_matter::data_model::provider::get_instance().registry().Unregister(&mWebRTCTransportProviderServer.Cluster());
if (err != CHIP_NO_ERROR)
{
ChipLogError(Camera, "WebRTCTransportProvider unregister error: %" CHIP_ERROR_FORMAT, err.Format());
}
mWebRTCTransportProviderServer.Destroy();
}
static constexpr EndpointId kCameraEndpointId = 1;
std::unique_ptr<CameraApp> gCameraApp;
void CameraAppInit(CameraDeviceInterface *cameraDevice) {
void CameraAppInit(CameraDeviceInterface * cameraDevice)
{
gCameraApp = std::make_unique<CameraApp>(kCameraEndpointId, cameraDevice);
gCameraApp = std::make_unique<CameraApp>(kCameraEndpointId, cameraDevice);
gCameraApp.get()->InitCameraDeviceClusters();
gCameraApp.get()->InitCameraDeviceClusters();
ChipLogDetail(Camera, "CameraAppInit: Initialized Camera clusters");
ChipLogDetail(Camera, "CameraAppInit: Initialized Camera clusters");
}
void CameraAppShutdown() {
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera app");
gCameraApp.get()->ShutdownCameraDeviceClusters();
gCameraApp = nullptr;
void CameraAppShutdown()
{
ChipLogDetail(Camera, "CameraAppShutdown: Shutting down Camera app");
gCameraApp.get()->ShutdownCameraDeviceClusters();
gCameraApp = nullptr;
}
+36 -24
View File
@@ -1,3 +1,20 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <app-common/zap-generated/cluster-objects.h>
@@ -5,43 +22,38 @@
#include "camera-device-interface.h"
#include <app/util/config.h>
#include <cstring>
#include <data-model-providers/codegen/CodegenDataModelProvider.h>
#include <protocols/interaction_model/StatusCode.h>
#include <utility>
// Camera App defines all the cluster servers needed for a particular device
class CameraApp {
class CameraApp
{
public:
// This class is responsible for initialising all the camera clusters and
// managing the interactions between them
CameraApp(chip::EndpointId aClustersEndpoint,
CameraDeviceInterface *cameraDevice);
// This class is responsible for initialising all the camera clusters and
// managing the interactions between them
CameraApp(chip::EndpointId aClustersEndpoint, CameraDeviceInterface * cameraDevice);
// Initialize all the camera device clusters.
void InitCameraDeviceClusters();
// Initialize all the camera device clusters.
void InitCameraDeviceClusters();
// Shutdown all the camera device clusters
void ShutdownCameraDeviceClusters();
// Shutdown all the camera device clusters
void ShutdownCameraDeviceClusters();
private:
chip::EndpointId mEndpoint;
CameraDeviceInterface *mCameraDevice;
chip::EndpointId mEndpoint;
CameraDeviceInterface * mCameraDevice;
// SDK cluster servers
std::unique_ptr<chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderServer>
mWebRTCTransportProviderPtr;
// std::unique_ptr<chip::app::Clusters::ChimeServer> mChimeServerPtr;
std::unique_ptr<
chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamMgmtServer>
mAVStreamMgmtServerPtr;
// std::unique_ptr<chip::app::Clusters::CameraAvSettingsUserLevelManagement::CameraAvSettingsUserLevelMgmtServer>
// mAVSettingsUserLevelMgmtServerPtr;
// SDK cluster servers
chip::app::LazyRegisteredServerCluster<chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster>
mWebRTCTransportProviderServer;
std::unique_ptr<chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementCluster> mAVStreamMgmtServerPtr;
// Helper to set attribute defaults for CameraAVStreamMgmt
void InitializeCameraAVStreamMgmt();
// Helper to set attribute defaults for CameraAVStreamMgmt
void InitializeCameraAVStreamMgmt();
};
void CameraAppInit(CameraDeviceInterface *cameraDevice);
void CameraAppInit(CameraDeviceInterface * cameraDevice);
void CameraAppShutdown();
@@ -1,6 +1,6 @@
#pragma once
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
namespace chip {
namespace app {
@@ -1,18 +1,18 @@
/*
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "camera-avstream-controller.h"
// #include <media-controller.h>
#include "webrtc-provider-controller.h"
// #include
// <app/clusters/camera-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h>
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
// #include <app/clusters/chime-server/chime-server.h>
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/camera-av-stream-management-server/CameraAVStreamManagementCluster.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
using chip::app::Clusters::CameraAvStreamManagement::AudioCapabilitiesStruct;
using chip::app::Clusters::CameraAvStreamManagement::AudioStreamStruct;
using chip::app::Clusters::CameraAvStreamManagement::ImageSnapshot;
using chip::app::Clusters::CameraAvStreamManagement::
RateDistortionTradeOffStruct;
using chip::app::Clusters::CameraAvStreamManagement::RateDistortionTradeOffStruct;
using chip::app::Clusters::CameraAvStreamManagement::SnapshotCapabilitiesStruct;
using chip::app::Clusters::CameraAvStreamManagement::SnapshotStreamStruct;
using chip::app::Clusters::CameraAvStreamManagement::TriStateAutoEnum;
@@ -21,312 +21,290 @@ using chip::app::Clusters::CameraAvStreamManagement::VideoSensorParamsStruct;
using chip::app::Clusters::CameraAvStreamManagement::VideoStreamStruct;
using chip::app::Clusters::Globals::StreamUsageEnum;
struct VideoStream {
VideoStreamStruct videoStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
chip::app::Clusters::Globals::Structs::ViewportStruct::Type
viewport; // Stream specific viewport, defaults to the camera viewport
void *videoContext; // Platform-specific context object associated with
// video stream;
struct VideoStream
{
VideoStreamStruct videoStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
chip::app::Clusters::Globals::Structs::ViewportStruct::Type
viewport; // Stream specific viewport, defaults to the camera viewport
void * videoContext; // Platform-specific context object associated with
// video stream;
bool IsCompatible(const VideoStreamStruct &inputParams) const {
return (videoStreamParams.videoCodec == inputParams.videoCodec &&
videoStreamParams.minFrameRate <= inputParams.minFrameRate &&
videoStreamParams.maxFrameRate >= inputParams.maxFrameRate &&
videoStreamParams.minResolution.width <=
inputParams.minResolution.width &&
videoStreamParams.minResolution.height <=
inputParams.minResolution.height &&
videoStreamParams.maxResolution.width >=
inputParams.maxResolution.width &&
videoStreamParams.maxResolution.height >=
inputParams.maxResolution.height &&
videoStreamParams.minBitRate <= inputParams.minBitRate &&
videoStreamParams.maxBitRate >= inputParams.maxBitRate &&
videoStreamParams.keyFrameInterval == inputParams.keyFrameInterval);
}
bool IsCompatible(const VideoStreamStruct & inputParams) const
{
return (videoStreamParams.videoCodec == inputParams.videoCodec &&
videoStreamParams.minFrameRate >= inputParams.minFrameRate &&
videoStreamParams.maxFrameRate <= inputParams.maxFrameRate &&
videoStreamParams.minResolution.width <= inputParams.minResolution.width &&
videoStreamParams.minResolution.height <= inputParams.minResolution.height &&
videoStreamParams.maxResolution.width >= inputParams.maxResolution.width &&
videoStreamParams.maxResolution.height >= inputParams.maxResolution.height &&
videoStreamParams.minBitRate <= inputParams.minBitRate && videoStreamParams.maxBitRate >= inputParams.maxBitRate &&
videoStreamParams.keyFrameInterval == inputParams.keyFrameInterval);
}
};
struct AudioStream {
AudioStreamStruct audioStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
void *audioContext; // Platform-specific context object associated with
// video stream;
struct AudioStream
{
AudioStreamStruct audioStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated.
void * audioContext; // Platform-specific context object associated with
// video stream;
bool IsCompatible(const AudioStreamStruct &inputParams) const {
return (audioStreamParams.audioCodec == inputParams.audioCodec &&
audioStreamParams.channelCount == inputParams.channelCount &&
audioStreamParams.sampleRate == inputParams.sampleRate &&
audioStreamParams.bitDepth == inputParams.bitDepth);
}
bool IsCompatible(const AudioStreamStruct & inputParams) const
{
return (audioStreamParams.audioCodec == inputParams.audioCodec &&
audioStreamParams.channelCount == inputParams.channelCount &&
audioStreamParams.sampleRate == inputParams.sampleRate && audioStreamParams.bitDepth == inputParams.bitDepth);
}
};
struct SnapshotStream {
SnapshotStreamStruct snapshotStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated
void *snapshotContext; // Platform-specific context object associated with
// snapshot stream;
struct SnapshotStream
{
SnapshotStreamStruct snapshotStreamParams;
bool isAllocated; // Flag to indicate if the stream is allocated
void * snapshotContext; // Platform-specific context object associated with
// snapshot stream;
bool IsCompatible(const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs
&inputParams) const {
return (snapshotStreamParams.imageCodec == inputParams.imageCodec &&
snapshotStreamParams.quality == inputParams.quality &&
snapshotStreamParams.frameRate <= inputParams.maxFrameRate &&
snapshotStreamParams.minResolution.width <=
inputParams.minResolution.width &&
snapshotStreamParams.minResolution.height <=
inputParams.minResolution.height &&
snapshotStreamParams.maxResolution.width >=
inputParams.maxResolution.width &&
snapshotStreamParams.maxResolution.height >=
inputParams.maxResolution.height);
}
bool
IsCompatible(const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs &
inputParams) const
{
return (snapshotStreamParams.imageCodec == inputParams.imageCodec && snapshotStreamParams.quality == inputParams.quality &&
snapshotStreamParams.frameRate <= inputParams.maxFrameRate &&
snapshotStreamParams.minResolution.width <= inputParams.minResolution.width &&
snapshotStreamParams.minResolution.height <= inputParams.minResolution.height &&
snapshotStreamParams.maxResolution.width >= inputParams.maxResolution.width &&
snapshotStreamParams.maxResolution.height >= inputParams.maxResolution.height);
}
};
// Enumeration for common camera errors
enum class CameraError {
SUCCESS,
ERROR_INIT_FAILED,
ERROR_VIDEO_STREAM_START_FAILED,
ERROR_VIDEO_STREAM_STOP_FAILED,
ERROR_AUDIO_STREAM_START_FAILED,
ERROR_AUDIO_STREAM_STOP_FAILED,
ERROR_SNAPSHOT_STREAM_START_FAILED,
ERROR_SNAPSHOT_STREAM_STOP_FAILED,
ERROR_CAPTURE_SNAPSHOT_FAILED,
ERROR_CONFIG_FAILED,
ERROR_RESOURCE_EXHAUSTED,
ERROR_NOT_IMPLEMENTED, // For features not supported on a platform
enum class CameraError
{
SUCCESS,
ERROR_INIT_FAILED,
ERROR_VIDEO_STREAM_START_FAILED,
ERROR_VIDEO_STREAM_STOP_FAILED,
ERROR_AUDIO_STREAM_START_FAILED,
ERROR_AUDIO_STREAM_STOP_FAILED,
ERROR_SNAPSHOT_STREAM_START_FAILED,
ERROR_SNAPSHOT_STREAM_STOP_FAILED,
ERROR_CAPTURE_SNAPSHOT_FAILED,
ERROR_CONFIG_FAILED,
ERROR_RESOURCE_EXHAUSTED,
ERROR_NOT_IMPLEMENTED, // For features not supported on a platform
};
// Camera Device Interface defines all the clusters that need to be implemented
// for a Camera Device
class CameraDeviceInterface {
class CameraDeviceInterface
{
public:
virtual ~CameraDeviceInterface() = default;
virtual ~CameraDeviceInterface() = default;
// Getter for WebRTCProvider Delegate
virtual chip::app::Clusters::WebRTCTransportProvider::Delegate &
GetWebRTCProviderDelegate() = 0;
// Getter for WebRTCProvider Delegate
virtual chip::app::Clusters::WebRTCTransportProvider::Delegate & GetWebRTCProviderDelegate() = 0;
// Getter for WebRTCProvider Controller
virtual chip::app::Clusters::WebRTCTransportProvider::
WebRTCTransportProviderController &
GetWebRTCProviderController() = 0;
// Set the WebRTC Transport Provider server instance
virtual void
SetWebRTCTransportProvider(chip::app::Clusters::WebRTCTransportProvider::WebRTCTransportProviderCluster * provider) = 0;
// Getter for CameraAVStreamManagement Delegate
virtual chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate &
GetCameraAVStreamMgmtDelegate() = 0;
// Getter for CameraAVStreamManagement Delegate
virtual chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate & GetCameraAVStreamMgmtDelegate() = 0;
// Getter for CameraAVStreamManagement Controller
virtual chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamController &
GetCameraAVStreamMgmtController() = 0;
// Getter for CameraAVStreamManagement Controller
virtual chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamController & GetCameraAVStreamMgmtController() = 0;
// Class defining the Camera HAL interface
class CameraHALInterface {
public:
// Virtual destructor
virtual ~CameraHALInterface() = default;
// Class defining the Camera HAL interface
class CameraHALInterface
{
public:
// Virtual destructor
virtual ~CameraHALInterface() = default;
// Initialize the camera hardware
virtual CameraError InitializeCameraDevice() = 0;
// Initialize the camera hardware
virtual CameraError InitializeCameraDevice() = 0;
virtual CameraError InitializeStreams() = 0;
virtual CameraError InitializeStreams() = 0;
virtual std::vector<VideoStream> &GetAvailableVideoStreams() = 0;
virtual std::vector<VideoStream> & GetAvailableVideoStreams() = 0;
virtual std::vector<AudioStream> &GetAvailableAudioStreams() = 0;
virtual std::vector<AudioStream> & GetAvailableAudioStreams() = 0;
virtual std::vector<SnapshotStream> &GetAvailableSnapshotStreams() = 0;
virtual std::vector<SnapshotStream> & GetAvailableSnapshotStreams() = 0;
// Capture a snapshot image
virtual CameraError
CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct &resolution,
ImageSnapshot &outImageSnapshot) = 0;
// Capture a snapshot image
virtual CameraError CaptureSnapshot(const chip::app::DataModel::Nullable<uint16_t> streamID,
const VideoResolutionStruct & resolution, ImageSnapshot & outImageSnapshot) = 0;
// Allocate snapshot stream
virtual CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::
CameraAVStreamMgmtDelegate::SnapshotStreamAllocateArgs &args,
uint16_t &outStreamID) = 0;
// Allocate snapshot stream
virtual CameraError AllocateSnapshotStream(
const chip::app::Clusters::CameraAvStreamManagement::CameraAVStreamManagementDelegate::SnapshotStreamAllocateArgs &
args,
uint16_t & outStreamID) = 0;
// Get the maximum number of concurrent encoders supported by camera.
virtual uint8_t GetMaxConcurrentEncoders() = 0;
// Get the maximum number of concurrent encoders supported by camera.
virtual uint8_t GetMaxConcurrentEncoders() = 0;
// Get the maximum data rate in encoded pixels per second that the
// camera can produce given the hardware encoders it has.
virtual uint32_t GetMaxEncodedPixelRate() = 0;
// Get the maximum data rate in encoded pixels per second that the
// camera can produce given the hardware encoders it has.
virtual uint32_t GetMaxEncodedPixelRate() = 0;
// Get the Video sensor params(sensor dimensions, framerate, HDR
// capabilities)
virtual VideoSensorParamsStruct &GetVideoSensorParams() = 0;
// Get the Video sensor params(sensor dimensions, framerate, HDR
// capabilities)
virtual VideoSensorParamsStruct & GetVideoSensorParams() = 0;
// Get indication whether camera supports high dynamic range for video
virtual bool GetCameraSupportsHDR() = 0;
// Get indication whether camera supports high dynamic range for video
virtual bool GetCameraSupportsHDR() = 0;
// Get indication whether camera supports night vision
virtual bool GetCameraSupportsNightVision() = 0;
// Get indication whether camera supports night vision
virtual bool GetCameraSupportsNightVision() = 0;
// Get indication whether camera night vision using infrared
virtual bool GetNightVisionUsesInfrared() = 0;
// Get indication whether camera night vision using infrared
virtual bool GetNightVisionUsesInfrared() = 0;
// Get indication whether camera supports image control
virtual bool GetCameraSupportsImageControl() = 0;
// Get indication whether camera supports image control
virtual bool GetCameraSupportsImageControl() = 0;
// Get indication whether camera supports watermark for video and snapshot
virtual bool GetCameraSupportsWatermark() = 0;
// Get indication whether camera supports watermark for video and snapshot
virtual bool GetCameraSupportsWatermark() = 0;
// Get indication whether camera supports on-screen display for video and
// snapshot
virtual bool GetCameraSupportsOSD() = 0;
// Get indication whether camera supports on-screen display for video and
// snapshot
virtual bool GetCameraSupportsOSD() = 0;
// Get indication whether camera supports soft recording and livestream
// privacy modes
virtual bool GetCameraSupportsSoftPrivacy() = 0;
// Get indication whether camera supports soft recording and livestream
// privacy modes
virtual bool GetCameraSupportsSoftPrivacy() = 0;
// Get indication of the min resolution(pixels) that camera allows for
// its viewport.
virtual VideoResolutionStruct &GetMinViewport() = 0;
// Get indication of the min resolution(pixels) that camera allows for
// its viewport.
virtual VideoResolutionStruct & GetMinViewport() = 0;
// Get the rate distortion tradeoff points(min bitrate for resolutions) for
// video codecs.
virtual std::vector<RateDistortionTradeOffStruct> &
GetRateDistortionTradeOffPoints() = 0;
// Get the rate distortion tradeoff points(min bitrate for resolutions) for
// video codecs.
virtual std::vector<RateDistortionTradeOffStruct> & GetRateDistortionTradeOffPoints() = 0;
// Get the maximum size of content buffer in bytes. This buffer holds
// compressed and/or raw audio/video content.
virtual uint32_t GetMaxContentBufferSize() = 0;
// Get the maximum size of content buffer in bytes. This buffer holds
// compressed and/or raw audio/video content.
virtual uint32_t GetMaxContentBufferSize() = 0;
// Get microphone capabilities.
virtual AudioCapabilitiesStruct &GetMicrophoneCapabilities() = 0;
// Get microphone capabilities.
virtual AudioCapabilitiesStruct & GetMicrophoneCapabilities() = 0;
// Get speaker capabilities.
virtual AudioCapabilitiesStruct &GetSpeakerCapabilities() = 0;
// Get speaker capabilities.
virtual AudioCapabilitiesStruct & GetSpeakerCapabilities() = 0;
// Get snapshot capabilities
virtual std::vector<SnapshotCapabilitiesStruct> &
GetSnapshotCapabilities() = 0;
// Get snapshot capabilities
virtual std::vector<SnapshotCapabilitiesStruct> & GetSnapshotCapabilities() = 0;
// Get the maximum network bandwidth(mbps) that the camera would consume
// for transmission of its media streams.
virtual uint32_t GetMaxNetworkBandwidth() = 0;
// Get the maximum network bandwidth(mbps) that the camera would consume
// for transmission of its media streams.
virtual uint32_t GetMaxNetworkBandwidth() = 0;
// Get the current frame rate of the camera sensor.
virtual uint16_t GetCurrentFrameRate() = 0;
// Get the current frame rate of the camera sensor.
virtual uint16_t GetCurrentFrameRate() = 0;
// Enable/Disable High Dynamic Range mode.
virtual CameraError SetHDRMode(bool hdrMode) = 0;
// Enable/Disable High Dynamic Range mode.
virtual CameraError SetHDRMode(bool hdrMode) = 0;
// Get the current camera HDR mode.
virtual bool GetHDRMode() = 0;
// Get the current camera HDR mode.
virtual bool GetHDRMode() = 0;
// Get Supported Stream usages; Typically set by manudacturer.
// This also sets the default priority of the stream usages.
virtual std::vector<StreamUsageEnum> &GetSupportedStreamUsages() = 0;
// Get Supported Stream usages; Typically set by manudacturer.
// This also sets the default priority of the stream usages.
virtual std::vector<StreamUsageEnum> & GetSupportedStreamUsages() = 0;
// Get stream usage priorities as an ordered list. This is expected to
// be a subset of the SupportedStreamUsages.
virtual std::vector<StreamUsageEnum> &GetStreamUsagePriorities() = 0;
virtual CameraError SetStreamUsagePriorities(
std::vector<StreamUsageEnum> streamUsagePriorities) = 0;
// Get stream usage priorities as an ordered list. This is expected to
// be a subset of the SupportedStreamUsages.
virtual std::vector<StreamUsageEnum> & GetStreamUsagePriorities() = 0;
virtual CameraError SetStreamUsagePriorities(std::vector<StreamUsageEnum> streamUsagePriorities) = 0;
// Get/Set soft recording privacy mode
virtual CameraError
SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) = 0;
virtual bool GetSoftRecordingPrivacyModeEnabled() = 0;
// Get/Set soft recording privacy mode
virtual CameraError SetSoftRecordingPrivacyModeEnabled(bool softRecordingPrivacyMode) = 0;
virtual bool GetSoftRecordingPrivacyModeEnabled() = 0;
// Get/Set soft livestream privacy mode
virtual CameraError
SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) = 0;
virtual bool GetSoftLivestreamPrivacyModeEnabled() = 0;
// Get/Set soft livestream privacy mode
virtual CameraError SetSoftLivestreamPrivacyModeEnabled(bool softLivestreamPrivacyMode) = 0;
virtual bool GetSoftLivestreamPrivacyModeEnabled() = 0;
// Does camera have a hard privacy switch
virtual bool HasHardPrivacySwitch() = 0;
// Does camera have a hard privacy switch
virtual bool HasHardPrivacySwitch() = 0;
// Get/Set hard privacy mode
virtual CameraError SetHardPrivacyMode(bool hardPrivacyMode) = 0;
virtual bool GetHardPrivacyMode() = 0;
// Get/Set hard privacy mode
virtual CameraError SetHardPrivacyMode(bool hardPrivacyMode) = 0;
virtual bool GetHardPrivacyMode() = 0;
// Get/Set night vision
virtual CameraError SetNightVision(TriStateAutoEnum nightVision) = 0;
virtual TriStateAutoEnum GetNightVision() = 0;
// Get/Set night vision
virtual CameraError SetNightVision(TriStateAutoEnum nightVision) = 0;
virtual TriStateAutoEnum GetNightVision() = 0;
// Set the viewport for all streams
virtual CameraError SetViewport(
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) = 0;
// Set the viewport for all streams
virtual CameraError SetViewport(const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) = 0;
// Get the current camera viewport.
virtual const chip::app::Clusters::Globals::Structs::ViewportStruct::Type &
GetViewport() = 0;
// Get the current camera viewport.
virtual const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & GetViewport() = 0;
// Set the viewport for a specific stream
virtual CameraError SetViewport(
VideoStream &stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type
&viewPort) = 0;
// Set the viewport for a specific stream
virtual CameraError SetViewport(VideoStream & stream,
const chip::app::Clusters::Globals::Structs::ViewportStruct::Type & viewPort) = 0;
// Does camera have a speaker
virtual bool HasSpeaker() = 0;
// Does camera have a speaker
virtual bool HasSpeaker() = 0;
// Mute/Unmute speaker.
virtual bool GetSpeakerMuted() = 0;
virtual CameraError SetSpeakerMuted(bool muteSpeaker) = 0;
// Mute/Unmute speaker.
virtual bool GetSpeakerMuted() = 0;
virtual CameraError SetSpeakerMuted(bool muteSpeaker) = 0;
// Get/Set speaker volume level.
virtual uint8_t GetSpeakerVolume() = 0;
virtual CameraError SetSpeakerVolume(uint8_t speakerVol) = 0;
// Get/Set speaker volume level.
virtual uint8_t GetSpeakerVolume() = 0;
virtual CameraError SetSpeakerVolume(uint8_t speakerVol) = 0;
// Get the speaker max and min levels.
virtual uint8_t GetSpeakerMaxLevel() = 0;
virtual uint8_t GetSpeakerMinLevel() = 0;
// Get the speaker max and min levels.
virtual uint8_t GetSpeakerMaxLevel() = 0;
virtual uint8_t GetSpeakerMinLevel() = 0;
// Does camera have a microphone
virtual bool HasMicrophone() = 0;
// Does camera have a microphone
virtual bool HasMicrophone() = 0;
// Mute/Unmute microphone.
virtual CameraError SetMicrophoneMuted(bool muteMicrophone) = 0;
virtual bool GetMicrophoneMuted() = 0;
// Mute/Unmute microphone.
virtual CameraError SetMicrophoneMuted(bool muteMicrophone) = 0;
virtual bool GetMicrophoneMuted() = 0;
// Set microphone volume level.
virtual CameraError SetMicrophoneVolume(uint8_t microphoneVol) = 0;
virtual uint8_t GetMicrophoneVolume() = 0;
// Set microphone volume level.
virtual CameraError SetMicrophoneVolume(uint8_t microphoneVol) = 0;
virtual uint8_t GetMicrophoneVolume() = 0;
// Get the microphone max and min levels.
virtual uint8_t GetMicrophoneMaxLevel() = 0;
virtual uint8_t GetMicrophoneMinLevel() = 0;
// Get the microphone max and min levels.
virtual uint8_t GetMicrophoneMaxLevel() = 0;
virtual uint8_t GetMicrophoneMinLevel() = 0;
// Get/Set image control attributes
virtual CameraError SetImageRotation(uint16_t imageRotation) = 0;
virtual uint16_t GetImageRotation() = 0;
// Get/Set image control attributes
virtual CameraError SetImageRotation(uint16_t imageRotation) = 0;
virtual uint16_t GetImageRotation() = 0;
virtual CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) = 0;
virtual bool GetImageFlipHorizontal() = 0;
virtual CameraError SetImageFlipHorizontal(bool imageFlipHorizontal) = 0;
virtual bool GetImageFlipHorizontal() = 0;
virtual CameraError SetImageFlipVertical(bool imageFlipVertical) = 0;
virtual bool GetImageFlipVertical() = 0;
virtual CameraError SetImageFlipVertical(bool imageFlipVertical) = 0;
virtual bool GetImageFlipVertical() = 0;
// Does camera have local storage
virtual bool HasLocalStorage() = 0;
// Does camera have local storage
virtual bool HasLocalStorage() = 0;
virtual CameraError
SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) = 0;
virtual bool GetLocalVideoRecordingEnabled() = 0;
virtual CameraError SetLocalVideoRecordingEnabled(bool localVideoRecordingEnabled) = 0;
virtual bool GetLocalVideoRecordingEnabled() = 0;
virtual CameraError
SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) = 0;
virtual bool GetLocalSnapshotRecordingEnabled() = 0;
virtual CameraError SetLocalSnapshotRecordingEnabled(bool localSnapshotRecordingEnabled) = 0;
virtual bool GetLocalSnapshotRecordingEnabled() = 0;
// Does camera have a status light
virtual bool HasStatusLight() = 0;
// Does camera have a status light
virtual bool HasStatusLight() = 0;
virtual CameraError SetStatusLightEnabled(bool statusLightEnabled) = 0;
virtual bool GetStatusLightEnabled();
};
virtual CameraError SetStatusLightEnabled(bool statusLightEnabled) = 0;
virtual bool GetStatusLightEnabled();
};
virtual CameraHALInterface &GetCameraHALInterface() = 0;
virtual CameraHALInterface & GetCameraHALInterface() = 0;
};
@@ -1,6 +1,6 @@
#pragma once
#include <app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.h>
#include <app/clusters/webrtc-transport-provider-server/WebRTCTransportProviderCluster.h>
namespace chip {
namespace app {
@@ -14,9 +14,7 @@ class WebRTCTransportProviderController {
public:
virtual ~WebRTCTransportProviderController() = default;
virtual void
SetWebRTCTransportProvider(std::unique_ptr<WebRTCTransportProviderServer>
webRTCTransportProvider) = 0;
virtual void SetWebRTCTransportProvider(WebRTCTransportProviderCluster *webRTCTransportProvider) = 0;
};
} // namespace WebRTCTransportProvider
+50 -29
View File
@@ -1,3 +1,20 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <functional>
@@ -9,46 +26,50 @@
class WebRTCPeerConnection;
class WebRTCTrack;
enum class SDPType : uint8_t { Offer, Answer, Pranswer, Rollback };
enum class MediaType : uint8_t {
Audio,
Video,
enum class SDPType : uint8_t
{
Offer,
Answer,
Pranswer,
Rollback
};
using OnLocalDescriptionCallback =
std::function<void(const std::string &sdp, SDPType type)>;
using OnICECandidateCallback =
std::function<void(const std::string &candidate)>;
using OnConnectionStateCallback = std::function<void(bool connected)>;
using OnTrackCallback = std::function<void(std::shared_ptr<WebRTCTrack> track)>;
enum class MediaType : uint8_t
{
Audio,
Video,
};
using OnLocalDescriptionCallback = std::function<void(const std::string & sdp, SDPType type)>;
using OnICECandidateCallback = std::function<void(const std::string & candidate)>;
using OnConnectionStateCallback = std::function<void(bool connected)>;
using OnTrackCallback = std::function<void(std::shared_ptr<WebRTCTrack> track)>;
// Abstract track interface
class WebRTCTrack {
class WebRTCTrack
{
public:
virtual ~WebRTCTrack() = default;
virtual ~WebRTCTrack() = default;
virtual void SendData(const char *data, size_t size) = 0;
virtual bool IsReady() = 0;
virtual std::string GetType() = 0; // "video" or "audio"
virtual void SendData(const char * data, size_t size) = 0;
virtual bool IsReady() = 0;
virtual std::string GetType() = 0; // "video" or "audio"
};
// Abstract peer connection interface
class WebRTCPeerConnection {
class WebRTCPeerConnection
{
public:
virtual ~WebRTCPeerConnection() = default;
virtual ~WebRTCPeerConnection() = default;
virtual void SetCallbacks(OnLocalDescriptionCallback onLocalDescription,
OnICECandidateCallback onICECandidate,
OnConnectionStateCallback onConnectionState,
OnTrackCallback onTrack) = 0;
virtual void Close() = 0;
virtual void CreateOffer(uint16_t sessionId) = 0;
virtual void CreateAnswer() = 0;
virtual void SetRemoteDescription(const std::string &sdp, SDPType type) = 0;
virtual void AddRemoteCandidate(const std::string &candidate,
const std::string &mid) = 0;
virtual std::shared_ptr<WebRTCTrack> AddTrack(MediaType mediaType) = 0;
virtual void SetCallbacks(OnLocalDescriptionCallback onLocalDescription, OnICECandidateCallback onICECandidate,
OnConnectionStateCallback onConnectionState, OnTrackCallback onTrack) = 0;
virtual void Close() = 0;
virtual void CreateOffer(uint16_t sessionId) = 0;
virtual void CreateAnswer() = 0;
virtual void SetRemoteDescription(const std::string & sdp, SDPType type) = 0;
virtual void AddRemoteCandidate(const std::string & candidate, const std::string & mid) = 0;
virtual std::shared_ptr<WebRTCTrack> AddTrack(MediaType mediaType) = 0;
};
std::shared_ptr<WebRTCPeerConnection> CreateWebRTCPeerConnection();
+133 -107
View File
@@ -1,157 +1,183 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "webrtc-abstract.h"
#include <lib/support/logging/CHIPLogging.h>
#include <webrtc-transport.h>
WebrtcTransport::WebrtcTransport() {
ChipLogProgress(Camera, "WebrtcTransport created");
mRequestArgs = {0, 0, 0, 0, 0, 0}; // Initialize request arguments to zero
WebrtcTransport::WebrtcTransport()
{
ChipLogProgress(Camera, "WebrtcTransport created");
mRequestArgs = { 0, 0, 0, 0, 0, 0 }; // Initialize request arguments to zero
}
WebrtcTransport::~WebrtcTransport() {
ClosePeerConnection();
ChipLogProgress(Camera, "WebrtcTransport destroyed for sessionID: [%u]",
mRequestArgs.sessionId);
WebrtcTransport::~WebrtcTransport()
{
ClosePeerConnection();
ChipLogProgress(Camera, "WebrtcTransport destroyed for sessionID: [%u]", mRequestArgs.sessionId);
}
void WebrtcTransport::SetCallbacks(
OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState) {
mOnLocalDescription = onLocalDescription;
mOnConnectionState = onConnectionState;
void WebrtcTransport::SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState)
{
mOnLocalDescription = onLocalDescription;
mOnConnectionState = onConnectionState;
}
void WebrtcTransport::SetRequestArgs(const RequestArgs &args) {
mRequestArgs = args;
void WebrtcTransport::SetRequestArgs(const RequestArgs & args)
{
mRequestArgs = args;
}
WebrtcTransport::RequestArgs &WebrtcTransport::GetRequestArgs() {
return mRequestArgs;
WebrtcTransport::RequestArgs & WebrtcTransport::GetRequestArgs()
{
return mRequestArgs;
}
const char *WebrtcTransport::GetStateStr() const {
switch (mState) {
case State::Idle:
return "Idle";
const char * WebrtcTransport::GetStateStr() const
{
switch (mState)
{
case State::Idle:
return "Idle";
case State::SendingOffer:
return "SendingOffer";
case State::SendingOffer:
return "SendingOffer";
case State::SendingAnswer:
return "SendingAnswer";
case State::SendingAnswer:
return "SendingAnswer";
case State::SendingICECandidates:
return "SendingICECandidates";
case State::SendingICECandidates:
return "SendingICECandidates";
case State::SendingEnd:
return "SendingEnd";
}
return "N/A";
case State::SendingEnd:
return "SendingEnd";
}
return "N/A";
}
void WebrtcTransport::MoveToState(const State targetState) {
mState = targetState;
ChipLogProgress(Camera, "WebrtcTransport moving to [ %s ]", GetStateStr());
void WebrtcTransport::MoveToState(const State targetState)
{
mState = targetState;
ChipLogProgress(Camera, "WebrtcTransport moving to [ %s ]", GetStateStr());
}
void WebrtcTransport::SetCommandType(const CommandType commandtype) {
mCommandType = commandtype;
void WebrtcTransport::SetCommandType(const CommandType commandtype)
{
mCommandType = commandtype;
}
void WebrtcTransport::Start() {
if (mPeerConnection.get()) {
ChipLogProgress(Camera, "Start, mPeerConnection is already created");
return;
}
void WebrtcTransport::Start()
{
if (mPeerConnection.get())
{
ChipLogProgress(Camera, "Start, mPeerConnection is already created");
return;
}
mPeerConnection = CreateWebRTCPeerConnection();
mPeerConnection = CreateWebRTCPeerConnection();
mPeerConnection->SetCallbacks(
[this](const std::string &sdp, SDPType type) {
this->OnLocalDescription(sdp, type);
},
[this](const std::string &candidate) { this->OnICECandidate(candidate); },
[this](bool connected) { this->OnConnectionStateChanged(connected); },
[this](std::shared_ptr<WebRTCTrack> track) { this->OnTrack(track); });
mPeerConnection->SetCallbacks([this](const std::string & sdp, SDPType type) { this->OnLocalDescription(sdp, type); },
[this](const std::string & candidate) { this->OnICECandidate(candidate); },
[this](bool connected) { this->OnConnectionStateChanged(connected); },
[this](std::shared_ptr<WebRTCTrack> track) { this->OnTrack(track); });
}
void WebrtcTransport::Stop() {
mVideoTrack = nullptr;
mAudioTrack = nullptr;
if (mPeerConnection != nullptr) {
// KVSWebRTC close is handled by the KVSWebRTCManager.
// mPeerConnection->Close();
}
void WebrtcTransport::Stop()
{
mVideoTrack = nullptr;
mAudioTrack = nullptr;
}
void WebrtcTransport::AddTracks() {
if (mPeerConnection != nullptr) {
mVideoTrack = mPeerConnection->AddTrack(MediaType::Video);
mAudioTrack = mPeerConnection->AddTrack(MediaType::Audio);
}
void WebrtcTransport::AddTracks()
{
if (mPeerConnection != nullptr)
{
mVideoTrack = mPeerConnection->AddTrack(MediaType::Video);
mAudioTrack = mPeerConnection->AddTrack(MediaType::Audio);
}
}
// Implementation of SetVideoTrack method
void WebrtcTransport::SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack) {
ChipLogProgress(Camera, "Setting video track for sessionID: %u",
mRequestArgs.sessionId);
mVideoTrack = videoTrack;
void WebrtcTransport::SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack)
{
ChipLogProgress(Camera, "Setting video track for sessionID: %u", mRequestArgs.sessionId);
mVideoTrack = videoTrack;
}
// Implementation of SetAudioTrack method
void WebrtcTransport::SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack) {
ChipLogProgress(Camera, "Setting audio track for sessionID: %u",
mRequestArgs.sessionId);
mAudioTrack = audioTrack;
void WebrtcTransport::SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack)
{
ChipLogProgress(Camera, "Setting audio track for sessionID: %u", mRequestArgs.sessionId);
mAudioTrack = audioTrack;
}
void WebrtcTransport::AddRemoteCandidate(const std::string &candidate,
const std::string &mid) {
ChipLogProgress(Camera, "Adding remote candidate for sessionID: %u",
mRequestArgs.sessionId);
mPeerConnection->AddRemoteCandidate(candidate, mid);
void WebrtcTransport::AddRemoteCandidate(const std::string & candidate, const std::string & mid)
{
ChipLogProgress(Camera, "Adding remote candidate for sessionID: %u", mRequestArgs.sessionId);
mPeerConnection->AddRemoteCandidate(candidate, mid);
}
// WebRTC Callbacks
void WebrtcTransport::OnLocalDescription(const std::string &sdp, SDPType type) {
ChipLogProgress(Camera, "Local description received for sessionID: %u",
mRequestArgs.sessionId);
mLocalSdp = sdp;
mLocalSdpType = type;
if (mOnLocalDescription)
mOnLocalDescription(sdp, type, mRequestArgs.sessionId);
void WebrtcTransport::OnLocalDescription(const std::string & sdp, SDPType type)
{
ChipLogProgress(Camera, "Local description received for sessionID: %u", mRequestArgs.sessionId);
mLocalSdp = sdp;
mLocalSdpType = type;
if (mOnLocalDescription)
mOnLocalDescription(sdp, type, mRequestArgs.sessionId);
}
bool WebrtcTransport::ClosePeerConnection() {
if (mPeerConnection == nullptr) {
return false;
}
// KVSWebRTC close is handled by the KVSWebRTCManager.
return true;
bool WebrtcTransport::ClosePeerConnection()
{
if (mPeerConnection == nullptr)
{
return false;
}
// KVSWebRTC close is handled by the KVSWebRTCManager.
return true;
}
void WebrtcTransport::OnICECandidate(const std::string &candidate) {
ChipLogProgress(Camera, "ICE Candidate received for sessionID: %u",
mRequestArgs.sessionId);
mLocalCandidates.push_back(candidate);
ChipLogProgress(Camera, "Local Candidate:");
ChipLogProgress(Camera, "%s", candidate.c_str());
void WebrtcTransport::OnICECandidate(const std::string & candidate)
{
ChipLogProgress(Camera, "ICE Candidate received for sessionID: %u", mRequestArgs.sessionId);
mLocalCandidates.push_back(candidate);
ChipLogProgress(Camera, "Local Candidate:");
ChipLogProgress(Camera, "%s", candidate.c_str());
}
void WebrtcTransport::OnConnectionStateChanged(bool connected) {
ChipLogProgress(Camera, "Connection state changed for sessionID: %u",
mRequestArgs.sessionId);
if (mOnConnectionState)
mOnConnectionState(connected, mRequestArgs.sessionId);
void WebrtcTransport::OnConnectionStateChanged(bool connected)
{
ChipLogProgress(Camera, "Connection state changed for sessionID: %u", mRequestArgs.sessionId);
if (mOnConnectionState)
mOnConnectionState(connected, mRequestArgs.sessionId);
}
void WebrtcTransport::OnTrack(std::shared_ptr<WebRTCTrack> track) {
ChipLogProgress(Camera, "Track received for sessionID: %u, type: %s",
mRequestArgs.sessionId, track->GetType().c_str());
if (track->GetType() == "video") {
ChipLogProgress(Camera, "Video track updated from remote peer");
SetVideoTrack(track);
} else if (track->GetType() == "audio") {
ChipLogProgress(Camera, "audio track updated from remote peer");
SetAudioTrack(track);
}
void WebrtcTransport::OnTrack(std::shared_ptr<WebRTCTrack> track)
{
ChipLogProgress(Camera, "Track received for sessionID: %u, type: %s", mRequestArgs.sessionId, track->GetType().c_str());
if (track->GetType() == "video")
{
ChipLogProgress(Camera, "Video track updated from remote peer");
SetVideoTrack(track);
}
else if (track->GetType() == "audio")
{
ChipLogProgress(Camera, "audio track updated from remote peer");
SetAudioTrack(track);
}
}
+90 -76
View File
@@ -1,112 +1,126 @@
/*
*
* Copyright (c) 2025 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "webrtc-abstract.h"
#include <lib/core/DataModelTypes.h>
#include <lib/core/ScopedNodeId.h>
using OnTransportLocalDescriptionCallback = std::function<void(
const std::string &sdp, SDPType type, const int16_t sessionId)>;
using OnTransportConnectionStateCallback =
std::function<void(bool connected, const int16_t sessionId)>;
using OnTransportLocalDescriptionCallback = std::function<void(const std::string & sdp, SDPType type, const int16_t sessionId)>;
using OnTransportConnectionStateCallback = std::function<void(bool connected, const int16_t sessionId)>;
class WebrtcTransport {
class WebrtcTransport
{
public:
enum class CommandType : uint8_t {
kUndefined = 0,
kOffer = 1,
kAnswer = 2,
kICECandidates = 3,
kEnd = 4,
};
enum class CommandType : uint8_t
{
kUndefined = 0,
kOffer = 1,
kAnswer = 2,
kICECandidates = 3,
kEnd = 4,
};
enum class State : uint8_t {
Idle, ///< Default state, no communication initiated yet
SendingOffer, ///< Sending Offer command from camera
SendingAnswer, ///< Sending Answer command from camera
SendingICECandidates, ///< Sending ICECandidates command from camera
SendingEnd, ///< Sending End command from camera
};
enum class State : uint8_t
{
Idle, ///< Default state, no communication initiated yet
SendingOffer, ///< Sending Offer command from camera
SendingAnswer, ///< Sending Answer command from camera
SendingICECandidates, ///< Sending ICECandidates command from camera
SendingEnd, ///< Sending End command from camera
};
struct RequestArgs {
uint16_t sessionId;
uint16_t videoStreamId;
uint16_t audioStreamId;
chip::NodeId peerNodeId;
chip::FabricIndex fabricIndex;
chip::EndpointId originatingEndpointId;
chip::ScopedNodeId peerId;
};
struct RequestArgs
{
uint16_t sessionId;
uint16_t videoStreamId;
uint16_t audioStreamId;
chip::NodeId peerNodeId;
chip::FabricIndex fabricIndex;
chip::EndpointId originatingEndpointId;
chip::ScopedNodeId peerId;
};
WebrtcTransport();
WebrtcTransport();
~WebrtcTransport();
~WebrtcTransport();
void SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription,
OnTransportConnectionStateCallback onConnectionState);
void SetCallbacks(OnTransportLocalDescriptionCallback onLocalDescription, OnTransportConnectionStateCallback onConnectionState);
void MoveToState(const State targetState);
const char *GetStateStr() const;
void MoveToState(const State targetState);
const char * GetStateStr() const;
State GetState() { return mState; }
State GetState() { return mState; }
// Takes care of creation WebRTC peer connection and registering the necessary
// callbacks
void Start();
// Takes care of creation WebRTC peer connection and registering the necessary
// callbacks
void Start();
// Stops WebRTC peer connection and cleanup
void Stop();
// Stops WebRTC peer connection and cleanup
void Stop();
void AddTracks();
void AddTracks();
// Set video track for the transport
void SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack);
// Set video track for the transport
void SetVideoTrack(std::shared_ptr<WebRTCTrack> videoTrack);
// Set audio track for the transport
void SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack);
// Set audio track for the transport
void SetAudioTrack(std::shared_ptr<WebRTCTrack> audioTrack);
std::shared_ptr<WebRTCPeerConnection> GetPeerConnection() {
return mPeerConnection;
}
std::shared_ptr<WebRTCPeerConnection> GetPeerConnection() { return mPeerConnection; }
std::string GetLocalDescription() { return mLocalSdp; }
std::string GetLocalDescription() { return mLocalSdp; }
void SetSdpAnswer(std::string localSdp) { mLocalSdp = localSdp; }
void SetSdpAnswer(std::string localSdp) { mLocalSdp = localSdp; }
std::vector<std::string> GetCandidates() { return mLocalCandidates; }
std::vector<std::string> GetCandidates() { return mLocalCandidates; }
void SetCandidates(std::vector<std::string> candidates) {
mLocalCandidates = candidates;
}
void SetCandidates(std::vector<std::string> candidates) { mLocalCandidates = candidates; }
void AddRemoteCandidate(const std::string &candidate, const std::string &mid);
void AddRemoteCandidate(const std::string & candidate, const std::string & mid);
bool ClosePeerConnection();
bool ClosePeerConnection();
void SetCommandType(const CommandType commandtype);
void SetCommandType(const CommandType commandtype);
CommandType GetCommandType() { return mCommandType; }
CommandType GetCommandType() { return mCommandType; }
// WebRTC Callbacks
void OnLocalDescription(const std::string &sdp, SDPType type);
void OnICECandidate(const std::string &candidate);
void OnConnectionStateChanged(bool connected);
void OnTrack(std::shared_ptr<WebRTCTrack> track);
// WebRTC Callbacks
void OnLocalDescription(const std::string & sdp, SDPType type);
void OnICECandidate(const std::string & candidate);
void OnConnectionStateChanged(bool connected);
void OnTrack(std::shared_ptr<WebRTCTrack> track);
void SetRequestArgs(const RequestArgs &args);
RequestArgs &GetRequestArgs();
void SetRequestArgs(const RequestArgs & args);
RequestArgs & GetRequestArgs();
private:
CommandType mCommandType = CommandType::kUndefined;
State mState = State::Idle;
CommandType mCommandType = CommandType::kUndefined;
State mState = State::Idle;
std::shared_ptr<WebRTCPeerConnection> mPeerConnection;
std::shared_ptr<WebRTCTrack> mVideoTrack;
std::shared_ptr<WebRTCTrack> mAudioTrack;
std::string mLocalSdp;
SDPType mLocalSdpType;
std::vector<std::string> mLocalCandidates;
std::shared_ptr<WebRTCPeerConnection> mPeerConnection;
std::shared_ptr<WebRTCTrack> mVideoTrack;
std::shared_ptr<WebRTCTrack> mAudioTrack;
std::string mLocalSdp;
SDPType mLocalSdpType;
std::vector<std::string> mLocalCandidates;
RequestArgs mRequestArgs;
OnTransportLocalDescriptionCallback mOnLocalDescription = nullptr;
OnTransportConnectionStateCallback mOnConnectionState = nullptr;
RequestArgs mRequestArgs;
OnTransportLocalDescriptionCallback mOnLocalDescription = nullptr;
OnTransportConnectionStateCallback mOnConnectionState = nullptr;
};
+1 -1
View File
@@ -18,7 +18,7 @@ set(EXTRA_COMPONENT_DIRS
project(controller)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H;-Wno-overloaded-virtual" APPEND)
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H;-Wno-overloaded-virtual;-Wno-error=unused-result" APPEND)
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
# We don't need Thread Network Commissioning Driver
-2
View File
@@ -16,8 +16,6 @@
#include <app_reset.h>
#include <app/clusters/ota-provider/CodegenIntegration.h>
#include <app/clusters/ota-provider/ota-provider-cluster.h>
#include <app/server/Server.h>
#include <credentials/FabricTable.h>
#include <platform/CHIPDeviceLayer.h>