#![allow(unused_imports)]
use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
use crate::dm::meta::{EventPriority, Reporting};
use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
use crate::error::Result;
use crate::im::{AttributeId, ClusterId, CommandId, EventId};
use crate::tlv::{
ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
};
pub const ID: ClusterId = 0x0551;
pub const REVISION: u16 = 2;
pub const PICS: &str = "AVSM";
pub mod feature {
pub const AUDIO: u32 = 1 << 0;
pub const VIDEO: u32 = 1 << 1;
pub const SNAPSHOT: u32 = 1 << 2;
pub const PRIVACY: u32 = 1 << 3;
pub const SPEAKER: u32 = 1 << 4;
pub const IMAGE_CONTROL: u32 = 1 << 5;
pub const WATERMARK: u32 = 1 << 6;
pub const ON_SCREEN_DISPLAY: u32 = 1 << 7;
pub const LOCAL_STORAGE: u32 = 1 << 8;
pub const HIGH_DYNAMIC_RANGE: u32 = 1 << 9;
pub const NIGHT_VISION: u32 = 1 << 10;
}
pub const FEATURES: &[Feature] = &[
Feature {
bit: 0,
code: "ADO",
name: "Audio",
conform: Conform::OPTIONAL,
},
Feature {
bit: 1,
code: "VDO",
name: "Video",
conform: Conform::OPTIONAL,
},
Feature {
bit: 2,
code: "SNP",
name: "Snapshot",
conform: Conform::OPTIONAL,
},
Feature {
bit: 3,
code: "PRIV",
name: "Privacy",
conform: Conform::OPTIONAL,
},
Feature {
bit: 4,
code: "SPKR",
name: "Speaker",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(0),
}],
},
},
Feature {
bit: 5,
code: "ICTL",
name: "ImageControl",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Feature {
bit: 6,
code: "WMARK",
name: "Watermark",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Feature {
bit: 7,
code: "OSD",
name: "OnScreenDisplay",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Feature {
bit: 8,
code: "STOR",
name: "LocalStorage",
conform: Conform::OPTIONAL,
},
Feature {
bit: 9,
code: "HDR",
name: "HighDynamicRange",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Feature {
bit: 10,
code: "NV",
name: "NightVision",
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
];
pub mod attribute {
use crate::im::AttributeId;
pub const MAX_CONCURRENT_ENCODERS: AttributeId = 0x00;
pub const MAX_ENCODED_PIXEL_RATE: AttributeId = 0x01;
pub const VIDEO_SENSOR_PARAMS: AttributeId = 0x02;
pub const NIGHT_VISION_USES_INFRARED: AttributeId = 0x03;
pub const MIN_VIEWPORT_RESOLUTION: AttributeId = 0x04;
pub const RATE_DISTORTION_TRADE_OFF_POINTS: AttributeId = 0x05;
pub const MAX_CONTENT_BUFFER_SIZE: AttributeId = 0x06;
pub const MICROPHONE_CAPABILITIES: AttributeId = 0x07;
pub const SPEAKER_CAPABILITIES: AttributeId = 0x08;
pub const TWO_WAY_TALK_SUPPORT: AttributeId = 0x09;
pub const SNAPSHOT_CAPABILITIES: AttributeId = 0x0A;
pub const MAX_NETWORK_BANDWIDTH: AttributeId = 0x0B;
pub const CURRENT_FRAME_RATE: AttributeId = 0x0C;
pub const HDR_MODE_ENABLED: AttributeId = 0x0D;
pub const SUPPORTED_STREAM_USAGES: AttributeId = 0x0E;
pub const ALLOCATED_VIDEO_STREAMS: AttributeId = 0x0F;
pub const ALLOCATED_AUDIO_STREAMS: AttributeId = 0x10;
pub const ALLOCATED_SNAPSHOT_STREAMS: AttributeId = 0x11;
pub const STREAM_USAGE_PRIORITIES: AttributeId = 0x12;
pub const SOFT_RECORDING_PRIVACY_MODE_ENABLED: AttributeId = 0x13;
pub const SOFT_LIVESTREAM_PRIVACY_MODE_ENABLED: AttributeId = 0x14;
pub const HARD_PRIVACY_MODE_ON: AttributeId = 0x15;
pub const NIGHT_VISION: AttributeId = 0x16;
pub const NIGHT_VISION_ILLUM: AttributeId = 0x17;
pub const VIEWPORT: AttributeId = 0x18;
pub const SPEAKER_MUTED: AttributeId = 0x19;
pub const SPEAKER_VOLUME_LEVEL: AttributeId = 0x1A;
pub const SPEAKER_MAX_LEVEL: AttributeId = 0x1B;
pub const SPEAKER_MIN_LEVEL: AttributeId = 0x1C;
pub const MICROPHONE_MUTED: AttributeId = 0x1D;
pub const MICROPHONE_VOLUME_LEVEL: AttributeId = 0x1E;
pub const MICROPHONE_MAX_LEVEL: AttributeId = 0x1F;
pub const MICROPHONE_MIN_LEVEL: AttributeId = 0x20;
pub const MICROPHONE_AGC_ENABLED: AttributeId = 0x21;
pub const IMAGE_ROTATION: AttributeId = 0x22;
pub const IMAGE_FLIP_HORIZONTAL: AttributeId = 0x23;
pub const IMAGE_FLIP_VERTICAL: AttributeId = 0x24;
pub const LOCAL_VIDEO_RECORDING_ENABLED: AttributeId = 0x25;
pub const LOCAL_SNAPSHOT_RECORDING_ENABLED: AttributeId = 0x26;
pub const STATUS_LIGHT_ENABLED: AttributeId = 0x27;
pub const STATUS_LIGHT_BRIGHTNESS: AttributeId = 0x28;
pub const IMAGE_ROTATION_DISCRETE_ANGLES: AttributeId = 0x29;
}
pub mod command {
use crate::im::CommandId;
pub const AUDIO_STREAM_ALLOCATE: CommandId = 0x00;
pub const AUDIO_STREAM_ALLOCATE_RESPONSE: CommandId = 0x01;
pub const AUDIO_STREAM_DEALLOCATE: CommandId = 0x02;
pub const VIDEO_STREAM_ALLOCATE: CommandId = 0x03;
pub const VIDEO_STREAM_ALLOCATE_RESPONSE: CommandId = 0x04;
pub const VIDEO_STREAM_MODIFY: CommandId = 0x05;
pub const VIDEO_STREAM_DEALLOCATE: CommandId = 0x06;
pub const SNAPSHOT_STREAM_ALLOCATE: CommandId = 0x07;
pub const SNAPSHOT_STREAM_ALLOCATE_RESPONSE: CommandId = 0x08;
pub const SNAPSHOT_STREAM_MODIFY: CommandId = 0x09;
pub const SNAPSHOT_STREAM_DEALLOCATE: CommandId = 0x0A;
pub const SET_STREAM_PRIORITIES: CommandId = 0x0B;
pub const CAPTURE_SNAPSHOT: CommandId = 0x0C;
pub const CAPTURE_SNAPSHOT_RESPONSE: CommandId = 0x0D;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum AudioCodecEnum {
OPUS = 0,
AACLC = 1,
}
impl AudioCodecEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::OPUS),
1 => Some(Self::AACLC),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for AudioCodecEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for AudioCodecEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum ImageCodecEnum {
JPEG = 0,
HEIC = 1,
}
impl ImageCodecEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::JPEG),
1 => Some(Self::HEIC),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for ImageCodecEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for ImageCodecEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum TriStateAutoEnum {
Off = 0,
On = 1,
Auto = 2,
}
impl TriStateAutoEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::Off),
1 => Some(Self::On),
2 => Some(Self::Auto),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for TriStateAutoEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for TriStateAutoEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum TwoWayTalkSupportTypeEnum {
NotSupported = 0,
HalfDuplex = 1,
FullDuplex = 2,
}
impl TwoWayTalkSupportTypeEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::NotSupported),
1 => Some(Self::HalfDuplex),
2 => Some(Self::FullDuplex),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for TwoWayTalkSupportTypeEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for TwoWayTalkSupportTypeEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u8)]
pub enum VideoCodecEnum {
H264 = 0,
HEVC = 1,
VVC = 2,
AV1 = 3,
}
impl VideoCodecEnum {
#[must_use]
pub const fn from_value(value: u8) -> Option<Self> {
match value {
0 => Some(Self::H264),
1 => Some(Self::HEVC),
2 => Some(Self::VVC),
3 => Some(Self::AV1),
_ => None,
}
}
#[must_use]
pub const fn value(self) -> u8 {
self as u8
}
}
impl ToTlv for VideoCodecEnum {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
self.value().to_tlv(w, tag)
}
}
impl<'a> FromTlv<'a> for VideoCodecEnum {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AVMetadataStruct<'a> {
pub utc_time: Nullable<u64>,
pub motion_zones_active: Option<TlvList<'a, u16>>,
pub black_and_white_active: Option<bool>,
pub user_defined: Option<&'a [u8]>,
}
impl<'a> ToTlv for AVMetadataStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.utc_time.to_tlv(w, Tag::Context(1))?;
if let Some(value) = &self.motion_zones_active {
value.to_tlv(w, Tag::Context(2))?;
}
if let Some(value) = &self.black_and_white_active {
value.to_tlv(w, Tag::Context(3))?;
}
if let Some(value) = &self.user_defined {
value.to_tlv(w, Tag::Context(4))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for AVMetadataStruct<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut utc_time = None;
let mut motion_zones_active = None;
let mut black_and_white_active = None;
let mut user_defined = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(1) => utc_time = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
Some(2) => {
motion_zones_active = Some(<TlvList<'a, u16>>::from_tlv(reader, &field)?)
}
Some(3) => black_and_white_active = Some(<bool>::from_tlv(reader, &field)?),
Some(4) => user_defined = Some(<&'a [u8]>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
utc_time: utc_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
motion_zones_active,
black_and_white_active,
user_defined,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AudioCapabilitiesStruct<'a> {
pub max_number_of_channels: u8,
pub supported_codecs: TlvList<'a, AudioCodecEnum>,
pub supported_sample_rates: TlvList<'a, u32>,
pub supported_bit_depths: TlvList<'a, u8>,
}
impl<'a> ToTlv for AudioCapabilitiesStruct<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.max_number_of_channels.to_tlv(w, Tag::Context(0))?;
self.supported_codecs.to_tlv(w, Tag::Context(1))?;
self.supported_sample_rates.to_tlv(w, Tag::Context(2))?;
self.supported_bit_depths.to_tlv(w, Tag::Context(3))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for AudioCapabilitiesStruct<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut max_number_of_channels = None;
let mut supported_codecs = None;
let mut supported_sample_rates = None;
let mut supported_bit_depths = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => max_number_of_channels = Some(<u8>::from_tlv(reader, &field)?),
Some(1) => {
supported_codecs =
Some(<TlvList<'a, AudioCodecEnum>>::from_tlv(reader, &field)?)
}
Some(2) => {
supported_sample_rates = Some(<TlvList<'a, u32>>::from_tlv(reader, &field)?)
}
Some(3) => {
supported_bit_depths = Some(<TlvList<'a, u8>>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
max_number_of_channels: max_number_of_channels
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
supported_codecs: supported_codecs
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
supported_sample_rates: supported_sample_rates
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
supported_bit_depths: supported_bit_depths
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AudioStreamStruct {
pub audio_stream_id: u16,
pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
pub audio_codec: AudioCodecEnum,
pub channel_count: u8,
pub sample_rate: u32,
pub bit_rate: u32,
pub bit_depth: u8,
pub reference_count: u8,
}
impl ToTlv for AudioStreamStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
self.stream_usage.to_tlv(w, Tag::Context(1))?;
self.audio_codec.to_tlv(w, Tag::Context(2))?;
self.channel_count.to_tlv(w, Tag::Context(3))?;
self.sample_rate.to_tlv(w, Tag::Context(4))?;
self.bit_rate.to_tlv(w, Tag::Context(5))?;
self.bit_depth.to_tlv(w, Tag::Context(6))?;
self.reference_count.to_tlv(w, Tag::Context(7))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for AudioStreamStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut audio_stream_id = None;
let mut stream_usage = None;
let mut audio_codec = None;
let mut channel_count = None;
let mut sample_rate = None;
let mut bit_rate = None;
let mut bit_depth = None;
let mut reference_count = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => {
stream_usage = Some(
<crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
reader, &field,
)?,
)
}
Some(2) => audio_codec = Some(<AudioCodecEnum>::from_tlv(reader, &field)?),
Some(3) => channel_count = Some(<u8>::from_tlv(reader, &field)?),
Some(4) => sample_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(5) => bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(6) => bit_depth = Some(<u8>::from_tlv(reader, &field)?),
Some(7) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
audio_stream_id: audio_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
audio_codec: audio_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
channel_count: channel_count.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
sample_rate: sample_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
bit_rate: bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
bit_depth: bit_depth.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
reference_count: reference_count
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RateDistortionTradeOffPointsStruct {
pub codec: VideoCodecEnum,
pub resolution: VideoResolutionStruct,
pub min_bit_rate: u32,
}
impl ToTlv for RateDistortionTradeOffPointsStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.codec.to_tlv(w, Tag::Context(0))?;
self.resolution.to_tlv(w, Tag::Context(1))?;
self.min_bit_rate.to_tlv(w, Tag::Context(2))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for RateDistortionTradeOffPointsStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut codec = None;
let mut resolution = None;
let mut min_bit_rate = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
Some(1) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
Some(2) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
codec: codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotCapabilitiesStruct {
pub resolution: VideoResolutionStruct,
pub max_frame_rate: u16,
pub image_codec: ImageCodecEnum,
pub requires_encoded_pixels: bool,
pub requires_hardware_encoder: Option<bool>,
}
impl ToTlv for SnapshotCapabilitiesStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.resolution.to_tlv(w, Tag::Context(0))?;
self.max_frame_rate.to_tlv(w, Tag::Context(1))?;
self.image_codec.to_tlv(w, Tag::Context(2))?;
self.requires_encoded_pixels.to_tlv(w, Tag::Context(3))?;
if let Some(value) = &self.requires_hardware_encoder {
value.to_tlv(w, Tag::Context(4))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotCapabilitiesStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut resolution = None;
let mut max_frame_rate = None;
let mut image_codec = None;
let mut requires_encoded_pixels = None;
let mut requires_hardware_encoder = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
Some(1) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
Some(3) => requires_encoded_pixels = Some(<bool>::from_tlv(reader, &field)?),
Some(4) => requires_hardware_encoder = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_frame_rate: max_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
requires_encoded_pixels: requires_encoded_pixels
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
requires_hardware_encoder,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotStreamStruct {
pub snapshot_stream_id: u16,
pub image_codec: ImageCodecEnum,
pub frame_rate: u16,
pub min_resolution: VideoResolutionStruct,
pub max_resolution: VideoResolutionStruct,
pub quality: u8,
pub reference_count: u8,
pub encoded_pixels: bool,
pub hardware_encoder: bool,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
}
impl ToTlv for SnapshotStreamStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
self.image_codec.to_tlv(w, Tag::Context(1))?;
self.frame_rate.to_tlv(w, Tag::Context(2))?;
self.min_resolution.to_tlv(w, Tag::Context(3))?;
self.max_resolution.to_tlv(w, Tag::Context(4))?;
self.quality.to_tlv(w, Tag::Context(5))?;
self.reference_count.to_tlv(w, Tag::Context(6))?;
self.encoded_pixels.to_tlv(w, Tag::Context(7))?;
self.hardware_encoder.to_tlv(w, Tag::Context(8))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(9))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(10))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotStreamStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut snapshot_stream_id = None;
let mut image_codec = None;
let mut frame_rate = None;
let mut min_resolution = None;
let mut max_resolution = None;
let mut quality = None;
let mut reference_count = None;
let mut encoded_pixels = None;
let mut hardware_encoder = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
Some(2) => frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => {
min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(4) => {
max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(5) => quality = Some(<u8>::from_tlv(reader, &field)?),
Some(6) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
Some(7) => encoded_pixels = Some(<bool>::from_tlv(reader, &field)?),
Some(8) => hardware_encoder = Some(<bool>::from_tlv(reader, &field)?),
Some(9) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(10) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
snapshot_stream_id: snapshot_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
frame_rate: frame_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_resolution: min_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_resolution: max_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
quality: quality.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
reference_count: reference_count
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
encoded_pixels: encoded_pixels
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
hardware_encoder: hardware_encoder
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoResolutionStruct {
pub width: u16,
pub height: u16,
}
impl ToTlv for VideoResolutionStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.width.to_tlv(w, Tag::Context(0))?;
self.height.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoResolutionStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut width = None;
let mut height = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => width = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => height = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
width: width.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
height: height.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoSensorParamsStruct {
pub sensor_width: u16,
pub sensor_height: u16,
pub max_fps: u16,
pub max_hdrfps: Option<u16>,
}
impl ToTlv for VideoSensorParamsStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.sensor_width.to_tlv(w, Tag::Context(0))?;
self.sensor_height.to_tlv(w, Tag::Context(1))?;
self.max_fps.to_tlv(w, Tag::Context(2))?;
if let Some(value) = &self.max_hdrfps {
value.to_tlv(w, Tag::Context(3))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoSensorParamsStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut sensor_width = None;
let mut sensor_height = None;
let mut max_fps = None;
let mut max_hdrfps = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => sensor_width = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => sensor_height = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => max_fps = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => max_hdrfps = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
sensor_width: sensor_width.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
sensor_height: sensor_height.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_fps: max_fps.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_hdrfps,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoStreamStruct {
pub video_stream_id: u16,
pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
pub video_codec: VideoCodecEnum,
pub min_frame_rate: u16,
pub max_frame_rate: u16,
pub min_resolution: VideoResolutionStruct,
pub max_resolution: VideoResolutionStruct,
pub min_bit_rate: u32,
pub max_bit_rate: u32,
pub key_frame_interval: u16,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
pub reference_count: u8,
}
impl ToTlv for VideoStreamStruct {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.video_stream_id.to_tlv(w, Tag::Context(0))?;
self.stream_usage.to_tlv(w, Tag::Context(1))?;
self.video_codec.to_tlv(w, Tag::Context(2))?;
self.min_frame_rate.to_tlv(w, Tag::Context(3))?;
self.max_frame_rate.to_tlv(w, Tag::Context(4))?;
self.min_resolution.to_tlv(w, Tag::Context(5))?;
self.max_resolution.to_tlv(w, Tag::Context(6))?;
self.min_bit_rate.to_tlv(w, Tag::Context(7))?;
self.max_bit_rate.to_tlv(w, Tag::Context(8))?;
self.key_frame_interval.to_tlv(w, Tag::Context(9))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(10))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(11))?;
}
self.reference_count.to_tlv(w, Tag::Context(12))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoStreamStruct {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut video_stream_id = None;
let mut stream_usage = None;
let mut video_codec = None;
let mut min_frame_rate = None;
let mut max_frame_rate = None;
let mut min_resolution = None;
let mut max_resolution = None;
let mut min_bit_rate = None;
let mut max_bit_rate = None;
let mut key_frame_interval = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
let mut reference_count = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => {
stream_usage = Some(
<crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
reader, &field,
)?,
)
}
Some(2) => video_codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
Some(3) => min_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(4) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(5) => {
min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(6) => {
max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(7) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(8) => max_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(9) => key_frame_interval = Some(<u16>::from_tlv(reader, &field)?),
Some(10) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(11) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(12) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
video_stream_id: video_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
video_codec: video_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_frame_rate: min_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_frame_rate: max_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_resolution: min_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_resolution: max_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_bit_rate: max_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
key_frame_interval: key_frame_interval
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
reference_count: reference_count
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AudioStreamAllocateFields {
pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
pub audio_codec: AudioCodecEnum,
pub channel_count: u8,
pub sample_rate: u32,
pub bit_rate: u32,
pub bit_depth: u8,
}
impl ToTlv for AudioStreamAllocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.stream_usage.to_tlv(w, Tag::Context(0))?;
self.audio_codec.to_tlv(w, Tag::Context(1))?;
self.channel_count.to_tlv(w, Tag::Context(2))?;
self.sample_rate.to_tlv(w, Tag::Context(3))?;
self.bit_rate.to_tlv(w, Tag::Context(4))?;
self.bit_depth.to_tlv(w, Tag::Context(5))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for AudioStreamAllocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut stream_usage = None;
let mut audio_codec = None;
let mut channel_count = None;
let mut sample_rate = None;
let mut bit_rate = None;
let mut bit_depth = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
stream_usage = Some(
<crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
reader, &field,
)?,
)
}
Some(1) => audio_codec = Some(<AudioCodecEnum>::from_tlv(reader, &field)?),
Some(2) => channel_count = Some(<u8>::from_tlv(reader, &field)?),
Some(3) => sample_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(4) => bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(5) => bit_depth = Some(<u8>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
audio_codec: audio_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
channel_count: channel_count.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
sample_rate: sample_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
bit_rate: bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
bit_depth: bit_depth.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AudioStreamAllocateResponseFields {
pub audio_stream_id: u16,
}
impl ToTlv for AudioStreamAllocateResponseFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for AudioStreamAllocateResponseFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut audio_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
audio_stream_id: audio_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct AudioStreamDeallocateFields {
pub audio_stream_id: u16,
}
impl ToTlv for AudioStreamDeallocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for AudioStreamDeallocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut audio_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
audio_stream_id: audio_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoStreamAllocateFields {
pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
pub video_codec: VideoCodecEnum,
pub min_frame_rate: u16,
pub max_frame_rate: u16,
pub min_resolution: VideoResolutionStruct,
pub max_resolution: VideoResolutionStruct,
pub min_bit_rate: u32,
pub max_bit_rate: u32,
pub key_frame_interval: u16,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
}
impl ToTlv for VideoStreamAllocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.stream_usage.to_tlv(w, Tag::Context(0))?;
self.video_codec.to_tlv(w, Tag::Context(1))?;
self.min_frame_rate.to_tlv(w, Tag::Context(2))?;
self.max_frame_rate.to_tlv(w, Tag::Context(3))?;
self.min_resolution.to_tlv(w, Tag::Context(4))?;
self.max_resolution.to_tlv(w, Tag::Context(5))?;
self.min_bit_rate.to_tlv(w, Tag::Context(6))?;
self.max_bit_rate.to_tlv(w, Tag::Context(7))?;
self.key_frame_interval.to_tlv(w, Tag::Context(8))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(9))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(10))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoStreamAllocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut stream_usage = None;
let mut video_codec = None;
let mut min_frame_rate = None;
let mut max_frame_rate = None;
let mut min_resolution = None;
let mut max_resolution = None;
let mut min_bit_rate = None;
let mut max_bit_rate = None;
let mut key_frame_interval = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
stream_usage = Some(
<crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
reader, &field,
)?,
)
}
Some(1) => video_codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
Some(2) => min_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(3) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(4) => {
min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(5) => {
max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(6) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(7) => max_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
Some(8) => key_frame_interval = Some(<u16>::from_tlv(reader, &field)?),
Some(9) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(10) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
video_codec: video_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_frame_rate: min_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_frame_rate: max_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_resolution: min_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_resolution: max_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_bit_rate: max_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
key_frame_interval: key_frame_interval
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoStreamAllocateResponseFields {
pub video_stream_id: u16,
}
impl ToTlv for VideoStreamAllocateResponseFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.video_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoStreamAllocateResponseFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut video_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
video_stream_id: video_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoStreamModifyFields {
pub video_stream_id: u16,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
}
impl ToTlv for VideoStreamModifyFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.video_stream_id.to_tlv(w, Tag::Context(0))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(1))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(2))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoStreamModifyFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut video_stream_id = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(2) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
video_stream_id: video_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct VideoStreamDeallocateFields {
pub video_stream_id: u16,
}
impl ToTlv for VideoStreamDeallocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.video_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for VideoStreamDeallocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut video_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
video_stream_id: video_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotStreamAllocateFields {
pub image_codec: ImageCodecEnum,
pub max_frame_rate: u16,
pub min_resolution: VideoResolutionStruct,
pub max_resolution: VideoResolutionStruct,
pub quality: u8,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
}
impl ToTlv for SnapshotStreamAllocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.image_codec.to_tlv(w, Tag::Context(0))?;
self.max_frame_rate.to_tlv(w, Tag::Context(1))?;
self.min_resolution.to_tlv(w, Tag::Context(2))?;
self.max_resolution.to_tlv(w, Tag::Context(3))?;
self.quality.to_tlv(w, Tag::Context(4))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(5))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(6))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotStreamAllocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut image_codec = None;
let mut max_frame_rate = None;
let mut min_resolution = None;
let mut max_resolution = None;
let mut quality = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
Some(1) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
Some(2) => {
min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(3) => {
max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
Some(4) => quality = Some(<u8>::from_tlv(reader, &field)?),
Some(5) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(6) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_frame_rate: max_frame_rate
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
min_resolution: min_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
max_resolution: max_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
quality: quality.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotStreamAllocateResponseFields {
pub snapshot_stream_id: u16,
}
impl ToTlv for SnapshotStreamAllocateResponseFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotStreamAllocateResponseFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut snapshot_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
snapshot_stream_id: snapshot_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotStreamModifyFields {
pub snapshot_stream_id: u16,
pub watermark_enabled: Option<bool>,
pub osd_enabled: Option<bool>,
}
impl ToTlv for SnapshotStreamModifyFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
if let Some(value) = &self.watermark_enabled {
value.to_tlv(w, Tag::Context(1))?;
}
if let Some(value) = &self.osd_enabled {
value.to_tlv(w, Tag::Context(2))?;
}
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotStreamModifyFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut snapshot_stream_id = None;
let mut watermark_enabled = None;
let mut osd_enabled = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
Some(1) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
Some(2) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
snapshot_stream_id: snapshot_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
watermark_enabled,
osd_enabled,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SnapshotStreamDeallocateFields {
pub snapshot_stream_id: u16,
}
impl ToTlv for SnapshotStreamDeallocateFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SnapshotStreamDeallocateFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut snapshot_stream_id = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
snapshot_stream_id: snapshot_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SetStreamPrioritiesFields<'a> {
pub stream_priorities: TlvList<'a, crate::clusters::generated::globals::StreamUsageEnum>,
}
impl<'a> ToTlv for SetStreamPrioritiesFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.stream_priorities.to_tlv(w, Tag::Context(0))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for SetStreamPrioritiesFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut stream_priorities = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => {
stream_priorities = Some(<TlvList<
'a,
crate::clusters::generated::globals::StreamUsageEnum,
>>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
stream_priorities: stream_priorities
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CaptureSnapshotFields {
pub snapshot_stream_id: Nullable<u16>,
pub requested_resolution: VideoResolutionStruct,
}
impl ToTlv for CaptureSnapshotFields {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
self.requested_resolution.to_tlv(w, Tag::Context(1))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for CaptureSnapshotFields {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut snapshot_stream_id = None;
let mut requested_resolution = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => snapshot_stream_id = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
Some(1) => {
requested_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
}
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
snapshot_stream_id: snapshot_stream_id
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
requested_resolution: requested_resolution
.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CaptureSnapshotResponseFields<'a> {
pub data: &'a [u8],
pub image_codec: ImageCodecEnum,
pub resolution: VideoResolutionStruct,
}
impl<'a> ToTlv for CaptureSnapshotResponseFields<'a> {
fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
w.start_structure(tag)?;
self.data.to_tlv(w, Tag::Context(0))?;
self.image_codec.to_tlv(w, Tag::Context(1))?;
self.resolution.to_tlv(w, Tag::Context(2))?;
w.end_container()
}
}
impl<'a> FromTlv<'a> for CaptureSnapshotResponseFields<'a> {
fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
if element.value.container() != Some(ContainerKind::Structure) {
return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
}
let mut data = None;
let mut image_codec = None;
let mut resolution = None;
loop {
let Some(field) = reader.next_element()? else {
return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
};
if field.value == Value::EndOfContainer {
break;
}
match field.tag.context() {
Some(0) => data = Some(<&'a [u8]>::from_tlv(reader, &field)?),
Some(1) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
Some(2) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
_ => reader.skip_value(&field)?,
}
}
Ok(Self {
data: data.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
})
}
}
pub const ATTRIBUTES: &[Attribute] = &[
Attribute {
id: 0x0000,
name: "MaxConcurrentEncoders",
kind: "uint8",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Attribute {
id: 0x0001,
name: "MaxEncodedPixelRate",
kind: "uint32",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
}],
},
},
Attribute {
id: 0x0002,
name: "VideoSensorParams",
kind: "VideoSensorParamsStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0003,
name: "NightVisionUsesInfrared",
kind: "bool",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(10),
}],
},
},
Attribute {
id: 0x0004,
name: "MinViewportResolution",
kind: "VideoResolutionStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0005,
name: "RateDistortionTradeOffPoints",
kind: "list[RateDistortionTradeOffPointsStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0006,
name: "MaxContentBufferSize",
kind: "uint32",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0007,
name: "MicrophoneCapabilities",
kind: "AudioCapabilitiesStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0008,
name: "SpeakerCapabilities",
kind: "AudioCapabilitiesStruct",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x0009,
name: "TwoWayTalkSupport",
kind: "TwoWayTalkSupportTypeEnum",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x000A,
name: "SnapshotCapabilities",
kind: "list[SnapshotCapabilitiesStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x000B,
name: "MaxNetworkBandwidth",
kind: "uint32",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x000C,
name: "CurrentFrameRate",
kind: "uint16",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x000D,
name: "HDRModeEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(9),
}],
},
},
Attribute {
id: 0x000E,
name: "SupportedStreamUsages",
kind: "list[StreamUsageEnum]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::FIXED,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x000F,
name: "AllocatedVideoStreams",
kind: "list[VideoStreamStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0010,
name: "AllocatedAudioStreams",
kind: "list[AudioStreamStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0011,
name: "AllocatedSnapshotStreams",
kind: "list[SnapshotStreamStruct]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Attribute {
id: 0x0012,
name: "StreamUsagePriorities",
kind: "list[StreamUsageEnum]",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::MANDATORY,
},
Attribute {
id: 0x0013,
name: "SoftRecordingPrivacyModeEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::View, Privilege::Operate),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Attribute {
id: 0x0014,
name: "SoftLivestreamPrivacyModeEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::View, Privilege::Operate),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(3),
}],
},
},
Attribute {
id: 0x0015,
name: "HardPrivacyModeOn",
kind: "bool",
access: Access::read_only(Privilege::View),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0016,
name: "NightVision",
kind: "TriStateAutoEnum",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(10),
}],
},
},
Attribute {
id: 0x0017,
name: "NightVisionIllum",
kind: "TriStateAutoEnum",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(10),
}],
},
},
Attribute {
id: 0x0018,
name: "Viewport",
kind: "ViewportStruct",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Attribute {
id: 0x0019,
name: "SpeakerMuted",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x001A,
name: "SpeakerVolumeLevel",
kind: "uint8",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x001B,
name: "SpeakerMaxLevel",
kind: "uint8",
access: Access::read_only(Privilege::Manage),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x001C,
name: "SpeakerMinLevel",
kind: "uint8",
access: Access::read_only(Privilege::Manage),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(4),
}],
},
},
Attribute {
id: 0x001D,
name: "MicrophoneMuted",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x001E,
name: "MicrophoneVolumeLevel",
kind: "uint8",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x001F,
name: "MicrophoneMaxLevel",
kind: "uint8",
access: Access::read_only(Privilege::Manage),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0020,
name: "MicrophoneMinLevel",
kind: "uint8",
access: Access::read_only(Privilege::Manage),
qualities: AttributeQualities::empty(),
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0021,
name: "MicrophoneAGCEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(0),
}],
},
},
Attribute {
id: 0x0022,
name: "ImageRotation",
kind: "uint16",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(5),
}],
},
},
Attribute {
id: 0x0023,
name: "ImageFlipHorizontal",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(5),
}],
},
},
Attribute {
id: 0x0024,
name: "ImageFlipVertical",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Optional,
when: Condition::Feature(5),
}],
},
},
Attribute {
id: 0x0025,
name: "LocalVideoRecordingEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[Condition::Feature(1), Condition::Feature(8)]),
}],
},
},
Attribute {
id: 0x0026,
name: "LocalSnapshotRecordingEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[Condition::Feature(2), Condition::Feature(8)]),
}],
},
},
Attribute {
id: 0x0027,
name: "StatusLightEnabled",
kind: "bool",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0028,
name: "StatusLightBrightness",
kind: "ThreeLevelAutoEnum",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform::OPTIONAL,
},
Attribute {
id: 0x0029,
name: "ImageRotationDiscreteAngles",
kind: "uint16",
access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
qualities: AttributeQualities::NON_VOLATILE,
reporting: Reporting::OnChange,
conform: Conform {
clauses: &[
Clause {
verdict: Conformance::Provisional,
when: Condition::Always,
},
Clause {
verdict: Conformance::Described,
when: Condition::All(&[
Condition::Named("comparison"),
Condition::Feature(5),
Condition::Not(&Condition::Attribute(0x0022)),
]),
},
],
},
},
];
pub const COMMANDS: &[Command] = &[
Command {
id: 0x00,
name: "AudioStreamAllocate",
to_server: true,
response: Some(0x01),
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x01,
name: "AudioStreamAllocateResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x02,
name: "AudioStreamDeallocate",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(0),
}],
},
},
Command {
id: 0x03,
name: "VideoStreamAllocate",
to_server: true,
response: Some(0x04),
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x04,
name: "VideoStreamAllocateResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x05,
name: "VideoStreamModify",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[
Condition::Feature(1),
Condition::Any(&[Condition::Feature(6), Condition::Feature(7)]),
]),
}],
},
},
Command {
id: 0x06,
name: "VideoStreamDeallocate",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(1),
}],
},
},
Command {
id: 0x07,
name: "SnapshotStreamAllocate",
to_server: true,
response: Some(0x08),
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x08,
name: "SnapshotStreamAllocateResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x09,
name: "SnapshotStreamModify",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::All(&[
Condition::Feature(2),
Condition::Any(&[Condition::Feature(6), Condition::Feature(7)]),
]),
}],
},
},
Command {
id: 0x0A,
name: "SnapshotStreamDeallocate",
to_server: true,
response: None,
access: Access::invoke(Privilege::Manage),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x0B,
name: "SetStreamPriorities",
to_server: true,
response: None,
access: Access::invoke(Privilege::Administer),
conform: Conform::MANDATORY,
},
Command {
id: 0x0C,
name: "CaptureSnapshot",
to_server: true,
response: Some(0x0D),
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::LARGE),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
Command {
id: 0x0D,
name: "CaptureSnapshotResponse",
to_server: false,
response: None,
access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::LARGE),
conform: Conform {
clauses: &[Clause {
verdict: Conformance::Mandatory,
when: Condition::Feature(2),
}],
},
},
];
pub const EVENTS: &[Event] = &[];
pub const CLUSTER: Cluster = Cluster {
id: ID,
name: "Camera AV Stream Management",
revision: REVISION,
pics: "AVSM",
derived_from: None,
features: FEATURES,
attributes: ATTRIBUTES,
commands: COMMANDS,
events: EVENTS,
};