Skip to content

Commit f2423f1

Browse files
committed
Track files added from zap-generate which for some reason weren't detected
1 parent a9e8749 commit f2423f1

5 files changed

+1539
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package chip.devicecontroller.cluster.structs
18+
19+
import chip.devicecontroller.cluster.*
20+
import java.util.Optional
21+
import matter.tlv.AnonymousTag
22+
import matter.tlv.ContextSpecificTag
23+
import matter.tlv.Tag
24+
import matter.tlv.TlvReader
25+
import matter.tlv.TlvWriter
26+
27+
class WebRTCTransportProviderClusterICEServerStruct(
28+
val urls: List<String>,
29+
val username: Optional<String>,
30+
val credential: Optional<String>,
31+
val caid: Optional<UInt>,
32+
) {
33+
override fun toString(): String = buildString {
34+
append("WebRTCTransportProviderClusterICEServerStruct {\n")
35+
append("\turls : $urls\n")
36+
append("\tusername : $username\n")
37+
append("\tcredential : $credential\n")
38+
append("\tcaid : $caid\n")
39+
append("}\n")
40+
}
41+
42+
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
43+
tlvWriter.apply {
44+
startStructure(tlvTag)
45+
startArray(ContextSpecificTag(TAG_URLS))
46+
for (item in urls.iterator()) {
47+
put(AnonymousTag, item)
48+
}
49+
endArray()
50+
if (username.isPresent) {
51+
val optusername = username.get()
52+
put(ContextSpecificTag(TAG_USERNAME), optusername)
53+
}
54+
if (credential.isPresent) {
55+
val optcredential = credential.get()
56+
put(ContextSpecificTag(TAG_CREDENTIAL), optcredential)
57+
}
58+
if (caid.isPresent) {
59+
val optcaid = caid.get()
60+
put(ContextSpecificTag(TAG_CAID), optcaid)
61+
}
62+
endStructure()
63+
}
64+
}
65+
66+
companion object {
67+
private const val TAG_URLS = 1
68+
private const val TAG_USERNAME = 2
69+
private const val TAG_CREDENTIAL = 3
70+
private const val TAG_CAID = 4
71+
72+
fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): WebRTCTransportProviderClusterICEServerStruct {
73+
tlvReader.enterStructure(tlvTag)
74+
val urls =
75+
buildList<String> {
76+
tlvReader.enterArray(ContextSpecificTag(TAG_URLS))
77+
while (!tlvReader.isEndOfContainer()) {
78+
add(tlvReader.getString(AnonymousTag))
79+
}
80+
tlvReader.exitContainer()
81+
}
82+
val username =
83+
if (tlvReader.isNextTag(ContextSpecificTag(TAG_USERNAME))) {
84+
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_USERNAME)))
85+
} else {
86+
Optional.empty()
87+
}
88+
val credential =
89+
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIAL))) {
90+
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CREDENTIAL)))
91+
} else {
92+
Optional.empty()
93+
}
94+
val caid =
95+
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAID))) {
96+
Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CAID)))
97+
} else {
98+
Optional.empty()
99+
}
100+
101+
tlvReader.exitContainer()
102+
103+
return WebRTCTransportProviderClusterICEServerStruct(urls, username, credential, caid)
104+
}
105+
}
106+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
*
3+
* Copyright (c) 2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package chip.devicecontroller.cluster.structs
18+
19+
import chip.devicecontroller.cluster.*
20+
import matter.tlv.ContextSpecificTag
21+
import matter.tlv.Tag
22+
import matter.tlv.TlvReader
23+
import matter.tlv.TlvWriter
24+
25+
class WebRTCTransportProviderClusterWebRTCSessionStruct(
26+
val id: UInt,
27+
val peerNodeId: ULong,
28+
val peerFabricIndex: UInt,
29+
val streamType: UInt,
30+
val videoStreamID: UInt?,
31+
val audioStreamID: UInt?,
32+
val metadataOptions: UInt,
33+
) {
34+
override fun toString(): String = buildString {
35+
append("WebRTCTransportProviderClusterWebRTCSessionStruct {\n")
36+
append("\tid : $id\n")
37+
append("\tpeerNodeId : $peerNodeId\n")
38+
append("\tpeerFabricIndex : $peerFabricIndex\n")
39+
append("\tstreamType : $streamType\n")
40+
append("\tvideoStreamID : $videoStreamID\n")
41+
append("\taudioStreamID : $audioStreamID\n")
42+
append("\tmetadataOptions : $metadataOptions\n")
43+
append("}\n")
44+
}
45+
46+
fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
47+
tlvWriter.apply {
48+
startStructure(tlvTag)
49+
put(ContextSpecificTag(TAG_ID), id)
50+
put(ContextSpecificTag(TAG_PEER_NODE_ID), peerNodeId)
51+
put(ContextSpecificTag(TAG_PEER_FABRIC_INDEX), peerFabricIndex)
52+
put(ContextSpecificTag(TAG_STREAM_TYPE), streamType)
53+
if (videoStreamID != null) {
54+
put(ContextSpecificTag(TAG_VIDEO_STREAM_ID), videoStreamID)
55+
} else {
56+
putNull(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
57+
}
58+
if (audioStreamID != null) {
59+
put(ContextSpecificTag(TAG_AUDIO_STREAM_ID), audioStreamID)
60+
} else {
61+
putNull(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
62+
}
63+
put(ContextSpecificTag(TAG_METADATA_OPTIONS), metadataOptions)
64+
endStructure()
65+
}
66+
}
67+
68+
companion object {
69+
private const val TAG_ID = 1
70+
private const val TAG_PEER_NODE_ID = 2
71+
private const val TAG_PEER_FABRIC_INDEX = 3
72+
private const val TAG_STREAM_TYPE = 4
73+
private const val TAG_VIDEO_STREAM_ID = 5
74+
private const val TAG_AUDIO_STREAM_ID = 6
75+
private const val TAG_METADATA_OPTIONS = 7
76+
77+
fun fromTlv(
78+
tlvTag: Tag,
79+
tlvReader: TlvReader,
80+
): WebRTCTransportProviderClusterWebRTCSessionStruct {
81+
tlvReader.enterStructure(tlvTag)
82+
val id = tlvReader.getUInt(ContextSpecificTag(TAG_ID))
83+
val peerNodeId = tlvReader.getULong(ContextSpecificTag(TAG_PEER_NODE_ID))
84+
val peerFabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_PEER_FABRIC_INDEX))
85+
val streamType = tlvReader.getUInt(ContextSpecificTag(TAG_STREAM_TYPE))
86+
val videoStreamID =
87+
if (!tlvReader.isNull()) {
88+
tlvReader.getUInt(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
89+
} else {
90+
tlvReader.getNull(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
91+
null
92+
}
93+
val audioStreamID =
94+
if (!tlvReader.isNull()) {
95+
tlvReader.getUInt(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
96+
} else {
97+
tlvReader.getNull(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
98+
null
99+
}
100+
val metadataOptions = tlvReader.getUInt(ContextSpecificTag(TAG_METADATA_OPTIONS))
101+
102+
tlvReader.exitContainer()
103+
104+
return WebRTCTransportProviderClusterWebRTCSessionStruct(
105+
id,
106+
peerNodeId,
107+
peerFabricIndex,
108+
streamType,
109+
videoStreamID,
110+
audioStreamID,
111+
metadataOptions,
112+
)
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)