Skip to content

Commit

Permalink
Missed files from ./scripts/tools/zap_regen_all.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarcosb committed Oct 2, 2024
1 parent 3e2617e commit 53e605b
Show file tree
Hide file tree
Showing 5 changed files with 1,539 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* 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.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import java.util.Optional
import matter.tlv.AnonymousTag
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class WebRTCTransportProviderClusterICEServerStruct(
val urls: List<String>,
val username: Optional<String>,
val credential: Optional<String>,
val caid: Optional<UInt>,
) {
override fun toString(): String = buildString {
append("WebRTCTransportProviderClusterICEServerStruct {\n")
append("\turls : $urls\n")
append("\tusername : $username\n")
append("\tcredential : $credential\n")
append("\tcaid : $caid\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
startArray(ContextSpecificTag(TAG_URLS))
for (item in urls.iterator()) {
put(AnonymousTag, item)
}
endArray()
if (username.isPresent) {
val optusername = username.get()
put(ContextSpecificTag(TAG_USERNAME), optusername)
}
if (credential.isPresent) {
val optcredential = credential.get()
put(ContextSpecificTag(TAG_CREDENTIAL), optcredential)
}
if (caid.isPresent) {
val optcaid = caid.get()
put(ContextSpecificTag(TAG_CAID), optcaid)
}
endStructure()
}
}

companion object {
private const val TAG_URLS = 1
private const val TAG_USERNAME = 2
private const val TAG_CREDENTIAL = 3
private const val TAG_CAID = 4

fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): WebRTCTransportProviderClusterICEServerStruct {
tlvReader.enterStructure(tlvTag)
val urls =
buildList<String> {
tlvReader.enterArray(ContextSpecificTag(TAG_URLS))
while (!tlvReader.isEndOfContainer()) {
add(tlvReader.getString(AnonymousTag))
}
tlvReader.exitContainer()
}
val username =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_USERNAME))) {
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_USERNAME)))
} else {
Optional.empty()
}
val credential =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIAL))) {
Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CREDENTIAL)))
} else {
Optional.empty()
}
val caid =
if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAID))) {
Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CAID)))
} else {
Optional.empty()
}

tlvReader.exitContainer()

return WebRTCTransportProviderClusterICEServerStruct(urls, username, credential, caid)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
*
* Copyright (c) 2023 Project CHIP Authors
*
* 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.
*/
package chip.devicecontroller.cluster.structs

import chip.devicecontroller.cluster.*
import matter.tlv.ContextSpecificTag
import matter.tlv.Tag
import matter.tlv.TlvReader
import matter.tlv.TlvWriter

class WebRTCTransportProviderClusterWebRTCSessionStruct(
val id: UInt,
val peerNodeID: ULong,
val peerFabricIndex: UInt,
val streamType: UInt,
val videoStreamID: UInt?,
val audioStreamID: UInt?,
val metadataOptions: UInt,
) {
override fun toString(): String = buildString {
append("WebRTCTransportProviderClusterWebRTCSessionStruct {\n")
append("\tid : $id\n")
append("\tpeerNodeID : $peerNodeID\n")
append("\tpeerFabricIndex : $peerFabricIndex\n")
append("\tstreamType : $streamType\n")
append("\tvideoStreamID : $videoStreamID\n")
append("\taudioStreamID : $audioStreamID\n")
append("\tmetadataOptions : $metadataOptions\n")
append("}\n")
}

fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) {
tlvWriter.apply {
startStructure(tlvTag)
put(ContextSpecificTag(TAG_ID), id)
put(ContextSpecificTag(TAG_PEER_NODE_ID), peerNodeID)
put(ContextSpecificTag(TAG_PEER_FABRIC_INDEX), peerFabricIndex)
put(ContextSpecificTag(TAG_STREAM_TYPE), streamType)
if (videoStreamID != null) {
put(ContextSpecificTag(TAG_VIDEO_STREAM_ID), videoStreamID)
} else {
putNull(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
}
if (audioStreamID != null) {
put(ContextSpecificTag(TAG_AUDIO_STREAM_ID), audioStreamID)
} else {
putNull(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
}
put(ContextSpecificTag(TAG_METADATA_OPTIONS), metadataOptions)
endStructure()
}
}

companion object {
private const val TAG_ID = 1
private const val TAG_PEER_NODE_ID = 2
private const val TAG_PEER_FABRIC_INDEX = 3
private const val TAG_STREAM_TYPE = 4
private const val TAG_VIDEO_STREAM_ID = 5
private const val TAG_AUDIO_STREAM_ID = 6
private const val TAG_METADATA_OPTIONS = 7

fun fromTlv(
tlvTag: Tag,
tlvReader: TlvReader,
): WebRTCTransportProviderClusterWebRTCSessionStruct {
tlvReader.enterStructure(tlvTag)
val id = tlvReader.getUInt(ContextSpecificTag(TAG_ID))
val peerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PEER_NODE_ID))
val peerFabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_PEER_FABRIC_INDEX))
val streamType = tlvReader.getUInt(ContextSpecificTag(TAG_STREAM_TYPE))
val videoStreamID =
if (!tlvReader.isNull()) {
tlvReader.getUInt(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
} else {
tlvReader.getNull(ContextSpecificTag(TAG_VIDEO_STREAM_ID))
null
}
val audioStreamID =
if (!tlvReader.isNull()) {
tlvReader.getUInt(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
} else {
tlvReader.getNull(ContextSpecificTag(TAG_AUDIO_STREAM_ID))
null
}
val metadataOptions = tlvReader.getUInt(ContextSpecificTag(TAG_METADATA_OPTIONS))

tlvReader.exitContainer()

return WebRTCTransportProviderClusterWebRTCSessionStruct(
id,
peerNodeID,
peerFabricIndex,
streamType,
videoStreamID,
audioStreamID,
metadataOptions,
)
}
}
}
Loading

0 comments on commit 53e605b

Please sign in to comment.