Skip to content

Commit 12d1c1c

Browse files
committed
Add camera-av-stream-manager.h header
1 parent febe766 commit 12d1c1c

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h>
22+
#include <app/util/config.h>
23+
#include <vector>
24+
25+
namespace chip {
26+
namespace app {
27+
namespace Clusters {
28+
namespace CameraAvStreamManagement {
29+
30+
constexpr uint8_t kMaxVideoStreams = 10; // Maximum number of pre-allocated streams
31+
constexpr uint16_t kInvalidStreamID = 65500;
32+
33+
struct VideoStream
34+
{
35+
uint16_t id; // Stream ID
36+
bool isAllocated; // Flag to indicate if the stream is allocated
37+
VideoCodecEnum codec; // Codec information (e.g., "H.264", "HEVC")
38+
uint16_t frameRate; // frame rate
39+
};
40+
41+
struct AudioStream
42+
{
43+
uint16_t id; // Stream ID
44+
bool isAllocated; // Flag to indicate if the stream is allocated
45+
AudioCodecEnum codec; // Codec information (e.g., "OPUS", "AACLC")
46+
uint8_t channelCount; // channel count
47+
};
48+
49+
struct SnapshotStream
50+
{
51+
uint16_t id; // Stream ID
52+
bool isAllocated; // Flag to indicate if the stream is allocated
53+
ImageCodecEnum codec; // Codec information (e.g., "JPEG")
54+
uint8_t quality; // Quality
55+
};
56+
57+
/**
58+
* The application delegate to define the options & implement commands.
59+
*/
60+
class CameraAVStreamManager : public CameraAVStreamMgmtDelegate
61+
{
62+
public:
63+
Protocols::InteractionModel::Status VideoStreamAllocate(const VideoStreamStruct & allocateArgs, uint16_t & outStreamID);
64+
65+
Protocols::InteractionModel::Status VideoStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
66+
const chip::Optional<bool> osdEnabled);
67+
68+
Protocols::InteractionModel::Status VideoStreamDeallocate(const uint16_t streamID);
69+
70+
Protocols::InteractionModel::Status AudioStreamAllocate(const AudioStreamStruct & allocateArgs, uint16_t & outStreamID);
71+
72+
Protocols::InteractionModel::Status AudioStreamDeallocate(const uint16_t streamID);
73+
74+
Protocols::InteractionModel::Status SnapshotStreamAllocate(const SnapshotStreamStruct & allocateArgs, uint16_t & outStreamID);
75+
76+
Protocols::InteractionModel::Status SnapshotStreamModify(const uint16_t streamID, const chip::Optional<bool> waterMarkEnabled,
77+
const chip::Optional<bool> osdEnabled);
78+
79+
Protocols::InteractionModel::Status SnapshotStreamDeallocate(const uint16_t streamID);
80+
81+
void OnRankedStreamPrioritiesChanged();
82+
83+
void OnAttributeChanged(AttributeId attributeId);
84+
85+
Protocols::InteractionModel::Status CaptureSnapshot(const uint16_t streamID, const VideoResolutionStruct & resolution,
86+
ImageSnapshot & outImageSnapshot);
87+
88+
CHIP_ERROR
89+
LoadAllocatedVideoStreams(std::vector<VideoStreamStruct> & allocatedVideoStreams);
90+
91+
CHIP_ERROR
92+
LoadAllocatedAudioStreams(std::vector<AudioStreamStruct> & allocatedAudioStreams);
93+
94+
CHIP_ERROR
95+
LoadAllocatedSnapshotStreams(std::vector<SnapshotStreamStruct> & allocatedSnapshotStreams);
96+
97+
CHIP_ERROR PersistentAttributesLoadedCallback();
98+
99+
void Init();
100+
101+
CameraAVStreamManager() = default;
102+
~CameraAVStreamManager() = default;
103+
104+
private:
105+
std::vector<VideoStream> videoStreams; // Vector to hold available video streams
106+
std::vector<AudioStream> audioStreams; // Vector to hold available audio streams
107+
std::vector<SnapshotStream> snapshotStreams; // Vector to hold available snapshot streams
108+
109+
void InitializeAvailableVideoStreams();
110+
void InitializeAvailableAudioStreams();
111+
void InitializeAvailableSnapshotStreams();
112+
};
113+
114+
} // namespace CameraAvStreamManagement
115+
} // namespace Clusters
116+
} // namespace app
117+
} // namespace chip

0 commit comments

Comments
 (0)