1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x0551;
28
29pub const REVISION: u16 = 2;
32
33pub const PICS: &str = "AVSM";
35
36pub mod feature {
41 pub const AUDIO: u32 = 1 << 0;
45 pub const VIDEO: u32 = 1 << 1;
49 pub const SNAPSHOT: u32 = 1 << 2;
53 pub const PRIVACY: u32 = 1 << 3;
57 pub const SPEAKER: u32 = 1 << 4;
61 pub const IMAGE_CONTROL: u32 = 1 << 5;
65 pub const WATERMARK: u32 = 1 << 6;
69 pub const ON_SCREEN_DISPLAY: u32 = 1 << 7;
73 pub const LOCAL_STORAGE: u32 = 1 << 8;
77 pub const HIGH_DYNAMIC_RANGE: u32 = 1 << 9;
81 pub const NIGHT_VISION: u32 = 1 << 10;
85}
86
87pub const FEATURES: &[Feature] = &[
89 Feature {
90 bit: 0,
91 code: "ADO",
92 name: "Audio",
93 conform: Conform::OPTIONAL,
94 },
95 Feature {
96 bit: 1,
97 code: "VDO",
98 name: "Video",
99 conform: Conform::OPTIONAL,
100 },
101 Feature {
102 bit: 2,
103 code: "SNP",
104 name: "Snapshot",
105 conform: Conform::OPTIONAL,
106 },
107 Feature {
108 bit: 3,
109 code: "PRIV",
110 name: "Privacy",
111 conform: Conform::OPTIONAL,
112 },
113 Feature {
114 bit: 4,
115 code: "SPKR",
116 name: "Speaker",
117 conform: Conform {
118 clauses: &[Clause {
119 verdict: Conformance::Optional,
120 when: Condition::Feature(0),
121 }],
122 },
123 },
124 Feature {
125 bit: 5,
126 code: "ICTL",
127 name: "ImageControl",
128 conform: Conform {
129 clauses: &[Clause {
130 verdict: Conformance::Optional,
131 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
132 }],
133 },
134 },
135 Feature {
136 bit: 6,
137 code: "WMARK",
138 name: "Watermark",
139 conform: Conform {
140 clauses: &[Clause {
141 verdict: Conformance::Optional,
142 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
143 }],
144 },
145 },
146 Feature {
147 bit: 7,
148 code: "OSD",
149 name: "OnScreenDisplay",
150 conform: Conform {
151 clauses: &[Clause {
152 verdict: Conformance::Optional,
153 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
154 }],
155 },
156 },
157 Feature {
158 bit: 8,
159 code: "STOR",
160 name: "LocalStorage",
161 conform: Conform::OPTIONAL,
162 },
163 Feature {
164 bit: 9,
165 code: "HDR",
166 name: "HighDynamicRange",
167 conform: Conform {
168 clauses: &[Clause {
169 verdict: Conformance::Optional,
170 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
171 }],
172 },
173 },
174 Feature {
175 bit: 10,
176 code: "NV",
177 name: "NightVision",
178 conform: Conform {
179 clauses: &[Clause {
180 verdict: Conformance::Optional,
181 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
182 }],
183 },
184 },
185];
186
187pub mod attribute {
189 use crate::im::AttributeId;
190
191 pub const MAX_CONCURRENT_ENCODERS: AttributeId = 0x00;
193 pub const MAX_ENCODED_PIXEL_RATE: AttributeId = 0x01;
195 pub const VIDEO_SENSOR_PARAMS: AttributeId = 0x02;
197 pub const NIGHT_VISION_USES_INFRARED: AttributeId = 0x03;
199 pub const MIN_VIEWPORT_RESOLUTION: AttributeId = 0x04;
201 pub const RATE_DISTORTION_TRADE_OFF_POINTS: AttributeId = 0x05;
203 pub const MAX_CONTENT_BUFFER_SIZE: AttributeId = 0x06;
205 pub const MICROPHONE_CAPABILITIES: AttributeId = 0x07;
207 pub const SPEAKER_CAPABILITIES: AttributeId = 0x08;
209 pub const TWO_WAY_TALK_SUPPORT: AttributeId = 0x09;
211 pub const SNAPSHOT_CAPABILITIES: AttributeId = 0x0A;
213 pub const MAX_NETWORK_BANDWIDTH: AttributeId = 0x0B;
215 pub const CURRENT_FRAME_RATE: AttributeId = 0x0C;
217 pub const HDR_MODE_ENABLED: AttributeId = 0x0D;
219 pub const SUPPORTED_STREAM_USAGES: AttributeId = 0x0E;
221 pub const ALLOCATED_VIDEO_STREAMS: AttributeId = 0x0F;
223 pub const ALLOCATED_AUDIO_STREAMS: AttributeId = 0x10;
225 pub const ALLOCATED_SNAPSHOT_STREAMS: AttributeId = 0x11;
227 pub const STREAM_USAGE_PRIORITIES: AttributeId = 0x12;
229 pub const SOFT_RECORDING_PRIVACY_MODE_ENABLED: AttributeId = 0x13;
231 pub const SOFT_LIVESTREAM_PRIVACY_MODE_ENABLED: AttributeId = 0x14;
233 pub const HARD_PRIVACY_MODE_ON: AttributeId = 0x15;
235 pub const NIGHT_VISION: AttributeId = 0x16;
237 pub const NIGHT_VISION_ILLUM: AttributeId = 0x17;
239 pub const VIEWPORT: AttributeId = 0x18;
241 pub const SPEAKER_MUTED: AttributeId = 0x19;
243 pub const SPEAKER_VOLUME_LEVEL: AttributeId = 0x1A;
245 pub const SPEAKER_MAX_LEVEL: AttributeId = 0x1B;
247 pub const SPEAKER_MIN_LEVEL: AttributeId = 0x1C;
249 pub const MICROPHONE_MUTED: AttributeId = 0x1D;
251 pub const MICROPHONE_VOLUME_LEVEL: AttributeId = 0x1E;
253 pub const MICROPHONE_MAX_LEVEL: AttributeId = 0x1F;
255 pub const MICROPHONE_MIN_LEVEL: AttributeId = 0x20;
257 pub const MICROPHONE_AGC_ENABLED: AttributeId = 0x21;
259 pub const IMAGE_ROTATION: AttributeId = 0x22;
261 pub const IMAGE_FLIP_HORIZONTAL: AttributeId = 0x23;
263 pub const IMAGE_FLIP_VERTICAL: AttributeId = 0x24;
265 pub const LOCAL_VIDEO_RECORDING_ENABLED: AttributeId = 0x25;
267 pub const LOCAL_SNAPSHOT_RECORDING_ENABLED: AttributeId = 0x26;
269 pub const STATUS_LIGHT_ENABLED: AttributeId = 0x27;
271 pub const STATUS_LIGHT_BRIGHTNESS: AttributeId = 0x28;
273 pub const IMAGE_ROTATION_DISCRETE_ANGLES: AttributeId = 0x29;
275}
276
277pub mod command {
279 use crate::im::CommandId;
280
281 pub const AUDIO_STREAM_ALLOCATE: CommandId = 0x00;
283 pub const AUDIO_STREAM_ALLOCATE_RESPONSE: CommandId = 0x01;
285 pub const AUDIO_STREAM_DEALLOCATE: CommandId = 0x02;
287 pub const VIDEO_STREAM_ALLOCATE: CommandId = 0x03;
289 pub const VIDEO_STREAM_ALLOCATE_RESPONSE: CommandId = 0x04;
291 pub const VIDEO_STREAM_MODIFY: CommandId = 0x05;
293 pub const VIDEO_STREAM_DEALLOCATE: CommandId = 0x06;
295 pub const SNAPSHOT_STREAM_ALLOCATE: CommandId = 0x07;
297 pub const SNAPSHOT_STREAM_ALLOCATE_RESPONSE: CommandId = 0x08;
299 pub const SNAPSHOT_STREAM_MODIFY: CommandId = 0x09;
301 pub const SNAPSHOT_STREAM_DEALLOCATE: CommandId = 0x0A;
303 pub const SET_STREAM_PRIORITIES: CommandId = 0x0B;
305 pub const CAPTURE_SNAPSHOT: CommandId = 0x0C;
307 pub const CAPTURE_SNAPSHOT_RESPONSE: CommandId = 0x0D;
309}
310
311#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
313#[repr(u8)]
314pub enum AudioCodecEnum {
315 OPUS = 0,
317 AACLC = 1,
319}
320
321impl AudioCodecEnum {
322 #[must_use]
324 pub const fn from_value(value: u8) -> Option<Self> {
325 match value {
326 0 => Some(Self::OPUS),
327 1 => Some(Self::AACLC),
328 _ => None,
329 }
330 }
331
332 #[must_use]
334 pub const fn value(self) -> u8 {
335 self as u8
336 }
337}
338
339impl ToTlv for AudioCodecEnum {
340 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
341 self.value().to_tlv(w, tag)
342 }
343}
344
345impl<'a> FromTlv<'a> for AudioCodecEnum {
346 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
347 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
348 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
349 }
350}
351
352#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
354#[repr(u8)]
355pub enum ImageCodecEnum {
356 JPEG = 0,
358 HEIC = 1,
360}
361
362impl ImageCodecEnum {
363 #[must_use]
365 pub const fn from_value(value: u8) -> Option<Self> {
366 match value {
367 0 => Some(Self::JPEG),
368 1 => Some(Self::HEIC),
369 _ => None,
370 }
371 }
372
373 #[must_use]
375 pub const fn value(self) -> u8 {
376 self as u8
377 }
378}
379
380impl ToTlv for ImageCodecEnum {
381 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
382 self.value().to_tlv(w, tag)
383 }
384}
385
386impl<'a> FromTlv<'a> for ImageCodecEnum {
387 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
388 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
389 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
390 }
391}
392
393#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
395#[repr(u8)]
396pub enum TriStateAutoEnum {
397 Off = 0,
399 On = 1,
401 Auto = 2,
403}
404
405impl TriStateAutoEnum {
406 #[must_use]
408 pub const fn from_value(value: u8) -> Option<Self> {
409 match value {
410 0 => Some(Self::Off),
411 1 => Some(Self::On),
412 2 => Some(Self::Auto),
413 _ => None,
414 }
415 }
416
417 #[must_use]
419 pub const fn value(self) -> u8 {
420 self as u8
421 }
422}
423
424impl ToTlv for TriStateAutoEnum {
425 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
426 self.value().to_tlv(w, tag)
427 }
428}
429
430impl<'a> FromTlv<'a> for TriStateAutoEnum {
431 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
432 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
433 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
434 }
435}
436
437#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
439#[repr(u8)]
440pub enum TwoWayTalkSupportTypeEnum {
441 NotSupported = 0,
443 HalfDuplex = 1,
445 FullDuplex = 2,
447}
448
449impl TwoWayTalkSupportTypeEnum {
450 #[must_use]
452 pub const fn from_value(value: u8) -> Option<Self> {
453 match value {
454 0 => Some(Self::NotSupported),
455 1 => Some(Self::HalfDuplex),
456 2 => Some(Self::FullDuplex),
457 _ => None,
458 }
459 }
460
461 #[must_use]
463 pub const fn value(self) -> u8 {
464 self as u8
465 }
466}
467
468impl ToTlv for TwoWayTalkSupportTypeEnum {
469 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
470 self.value().to_tlv(w, tag)
471 }
472}
473
474impl<'a> FromTlv<'a> for TwoWayTalkSupportTypeEnum {
475 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
476 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
477 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
478 }
479}
480
481#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
483#[repr(u8)]
484pub enum VideoCodecEnum {
485 H264 = 0,
487 HEVC = 1,
489 VVC = 2,
491 AV1 = 3,
493}
494
495impl VideoCodecEnum {
496 #[must_use]
498 pub const fn from_value(value: u8) -> Option<Self> {
499 match value {
500 0 => Some(Self::H264),
501 1 => Some(Self::HEVC),
502 2 => Some(Self::VVC),
503 3 => Some(Self::AV1),
504 _ => None,
505 }
506 }
507
508 #[must_use]
510 pub const fn value(self) -> u8 {
511 self as u8
512 }
513}
514
515impl ToTlv for VideoCodecEnum {
516 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
517 self.value().to_tlv(w, tag)
518 }
519}
520
521impl<'a> FromTlv<'a> for VideoCodecEnum {
522 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
523 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
524 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
525 }
526}
527
528#[derive(Debug, Clone, Copy, PartialEq)]
530pub struct AVMetadataStruct<'a> {
531 pub utc_time: Nullable<u64>,
533 pub motion_zones_active: Option<TlvList<'a, u16>>,
535 pub black_and_white_active: Option<bool>,
537 pub user_defined: Option<&'a [u8]>,
539}
540
541impl<'a> ToTlv for AVMetadataStruct<'a> {
542 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
543 w.start_structure(tag)?;
544 self.utc_time.to_tlv(w, Tag::Context(1))?;
545 if let Some(value) = &self.motion_zones_active {
546 value.to_tlv(w, Tag::Context(2))?;
547 }
548 if let Some(value) = &self.black_and_white_active {
549 value.to_tlv(w, Tag::Context(3))?;
550 }
551 if let Some(value) = &self.user_defined {
552 value.to_tlv(w, Tag::Context(4))?;
553 }
554 w.end_container()
555 }
556}
557
558impl<'a> FromTlv<'a> for AVMetadataStruct<'a> {
559 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
560 if element.value.container() != Some(ContainerKind::Structure) {
561 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
562 }
563 let mut utc_time = None;
564 let mut motion_zones_active = None;
565 let mut black_and_white_active = None;
566 let mut user_defined = None;
567 loop {
568 let Some(field) = reader.next_element()? else {
569 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
570 };
571 if field.value == Value::EndOfContainer {
572 break;
573 }
574 match field.tag.context() {
575 Some(1) => utc_time = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
576 Some(2) => {
577 motion_zones_active = Some(<TlvList<'a, u16>>::from_tlv(reader, &field)?)
578 }
579 Some(3) => black_and_white_active = Some(<bool>::from_tlv(reader, &field)?),
580 Some(4) => user_defined = Some(<&'a [u8]>::from_tlv(reader, &field)?),
581 _ => reader.skip_value(&field)?,
585 }
586 }
587 Ok(Self {
588 utc_time: utc_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
589 motion_zones_active,
590 black_and_white_active,
591 user_defined,
592 })
593 }
594}
595
596#[derive(Debug, Clone, Copy, PartialEq)]
598pub struct AudioCapabilitiesStruct<'a> {
599 pub max_number_of_channels: u8,
601 pub supported_codecs: TlvList<'a, AudioCodecEnum>,
603 pub supported_sample_rates: TlvList<'a, u32>,
605 pub supported_bit_depths: TlvList<'a, u8>,
607}
608
609impl<'a> ToTlv for AudioCapabilitiesStruct<'a> {
610 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
611 w.start_structure(tag)?;
612 self.max_number_of_channels.to_tlv(w, Tag::Context(0))?;
613 self.supported_codecs.to_tlv(w, Tag::Context(1))?;
614 self.supported_sample_rates.to_tlv(w, Tag::Context(2))?;
615 self.supported_bit_depths.to_tlv(w, Tag::Context(3))?;
616 w.end_container()
617 }
618}
619
620impl<'a> FromTlv<'a> for AudioCapabilitiesStruct<'a> {
621 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
622 if element.value.container() != Some(ContainerKind::Structure) {
623 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
624 }
625 let mut max_number_of_channels = None;
626 let mut supported_codecs = None;
627 let mut supported_sample_rates = None;
628 let mut supported_bit_depths = None;
629 loop {
630 let Some(field) = reader.next_element()? else {
631 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
632 };
633 if field.value == Value::EndOfContainer {
634 break;
635 }
636 match field.tag.context() {
637 Some(0) => max_number_of_channels = Some(<u8>::from_tlv(reader, &field)?),
638 Some(1) => {
639 supported_codecs =
640 Some(<TlvList<'a, AudioCodecEnum>>::from_tlv(reader, &field)?)
641 }
642 Some(2) => {
643 supported_sample_rates = Some(<TlvList<'a, u32>>::from_tlv(reader, &field)?)
644 }
645 Some(3) => {
646 supported_bit_depths = Some(<TlvList<'a, u8>>::from_tlv(reader, &field)?)
647 }
648 _ => reader.skip_value(&field)?,
652 }
653 }
654 Ok(Self {
655 max_number_of_channels: max_number_of_channels
656 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
657 supported_codecs: supported_codecs
658 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
659 supported_sample_rates: supported_sample_rates
660 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
661 supported_bit_depths: supported_bit_depths
662 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
663 })
664 }
665}
666
667#[derive(Debug, Clone, Copy, PartialEq)]
669pub struct AudioStreamStruct {
670 pub audio_stream_id: u16,
672 pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
674 pub audio_codec: AudioCodecEnum,
676 pub channel_count: u8,
678 pub sample_rate: u32,
680 pub bit_rate: u32,
682 pub bit_depth: u8,
684 pub reference_count: u8,
686}
687
688impl ToTlv for AudioStreamStruct {
689 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
690 w.start_structure(tag)?;
691 self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
692 self.stream_usage.to_tlv(w, Tag::Context(1))?;
693 self.audio_codec.to_tlv(w, Tag::Context(2))?;
694 self.channel_count.to_tlv(w, Tag::Context(3))?;
695 self.sample_rate.to_tlv(w, Tag::Context(4))?;
696 self.bit_rate.to_tlv(w, Tag::Context(5))?;
697 self.bit_depth.to_tlv(w, Tag::Context(6))?;
698 self.reference_count.to_tlv(w, Tag::Context(7))?;
699 w.end_container()
700 }
701}
702
703impl<'a> FromTlv<'a> for AudioStreamStruct {
704 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
705 if element.value.container() != Some(ContainerKind::Structure) {
706 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
707 }
708 let mut audio_stream_id = None;
709 let mut stream_usage = None;
710 let mut audio_codec = None;
711 let mut channel_count = None;
712 let mut sample_rate = None;
713 let mut bit_rate = None;
714 let mut bit_depth = None;
715 let mut reference_count = None;
716 loop {
717 let Some(field) = reader.next_element()? else {
718 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
719 };
720 if field.value == Value::EndOfContainer {
721 break;
722 }
723 match field.tag.context() {
724 Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
725 Some(1) => {
726 stream_usage = Some(
727 <crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
728 reader, &field,
729 )?,
730 )
731 }
732 Some(2) => audio_codec = Some(<AudioCodecEnum>::from_tlv(reader, &field)?),
733 Some(3) => channel_count = Some(<u8>::from_tlv(reader, &field)?),
734 Some(4) => sample_rate = Some(<u32>::from_tlv(reader, &field)?),
735 Some(5) => bit_rate = Some(<u32>::from_tlv(reader, &field)?),
736 Some(6) => bit_depth = Some(<u8>::from_tlv(reader, &field)?),
737 Some(7) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
738 _ => reader.skip_value(&field)?,
742 }
743 }
744 Ok(Self {
745 audio_stream_id: audio_stream_id
746 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
747 stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
748 audio_codec: audio_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
749 channel_count: channel_count.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
750 sample_rate: sample_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
751 bit_rate: bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
752 bit_depth: bit_depth.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
753 reference_count: reference_count
754 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
755 })
756 }
757}
758
759#[derive(Debug, Clone, Copy, PartialEq)]
761pub struct RateDistortionTradeOffPointsStruct {
762 pub codec: VideoCodecEnum,
764 pub resolution: VideoResolutionStruct,
766 pub min_bit_rate: u32,
768}
769
770impl ToTlv for RateDistortionTradeOffPointsStruct {
771 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
772 w.start_structure(tag)?;
773 self.codec.to_tlv(w, Tag::Context(0))?;
774 self.resolution.to_tlv(w, Tag::Context(1))?;
775 self.min_bit_rate.to_tlv(w, Tag::Context(2))?;
776 w.end_container()
777 }
778}
779
780impl<'a> FromTlv<'a> for RateDistortionTradeOffPointsStruct {
781 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
782 if element.value.container() != Some(ContainerKind::Structure) {
783 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
784 }
785 let mut codec = None;
786 let mut resolution = None;
787 let mut min_bit_rate = None;
788 loop {
789 let Some(field) = reader.next_element()? else {
790 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
791 };
792 if field.value == Value::EndOfContainer {
793 break;
794 }
795 match field.tag.context() {
796 Some(0) => codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
797 Some(1) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
798 Some(2) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
799 _ => reader.skip_value(&field)?,
803 }
804 }
805 Ok(Self {
806 codec: codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
807 resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
808 min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
809 })
810 }
811}
812
813#[derive(Debug, Clone, Copy, PartialEq)]
815pub struct SnapshotCapabilitiesStruct {
816 pub resolution: VideoResolutionStruct,
818 pub max_frame_rate: u16,
820 pub image_codec: ImageCodecEnum,
822 pub requires_encoded_pixels: bool,
824 pub requires_hardware_encoder: Option<bool>,
826}
827
828impl ToTlv for SnapshotCapabilitiesStruct {
829 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
830 w.start_structure(tag)?;
831 self.resolution.to_tlv(w, Tag::Context(0))?;
832 self.max_frame_rate.to_tlv(w, Tag::Context(1))?;
833 self.image_codec.to_tlv(w, Tag::Context(2))?;
834 self.requires_encoded_pixels.to_tlv(w, Tag::Context(3))?;
835 if let Some(value) = &self.requires_hardware_encoder {
836 value.to_tlv(w, Tag::Context(4))?;
837 }
838 w.end_container()
839 }
840}
841
842impl<'a> FromTlv<'a> for SnapshotCapabilitiesStruct {
843 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
844 if element.value.container() != Some(ContainerKind::Structure) {
845 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
846 }
847 let mut resolution = None;
848 let mut max_frame_rate = None;
849 let mut image_codec = None;
850 let mut requires_encoded_pixels = None;
851 let mut requires_hardware_encoder = None;
852 loop {
853 let Some(field) = reader.next_element()? else {
854 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
855 };
856 if field.value == Value::EndOfContainer {
857 break;
858 }
859 match field.tag.context() {
860 Some(0) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
861 Some(1) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
862 Some(2) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
863 Some(3) => requires_encoded_pixels = Some(<bool>::from_tlv(reader, &field)?),
864 Some(4) => requires_hardware_encoder = Some(<bool>::from_tlv(reader, &field)?),
865 _ => reader.skip_value(&field)?,
869 }
870 }
871 Ok(Self {
872 resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
873 max_frame_rate: max_frame_rate
874 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
875 image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
876 requires_encoded_pixels: requires_encoded_pixels
877 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
878 requires_hardware_encoder,
879 })
880 }
881}
882
883#[derive(Debug, Clone, Copy, PartialEq)]
885pub struct SnapshotStreamStruct {
886 pub snapshot_stream_id: u16,
888 pub image_codec: ImageCodecEnum,
890 pub frame_rate: u16,
892 pub min_resolution: VideoResolutionStruct,
894 pub max_resolution: VideoResolutionStruct,
896 pub quality: u8,
898 pub reference_count: u8,
900 pub encoded_pixels: bool,
902 pub hardware_encoder: bool,
904 pub watermark_enabled: Option<bool>,
906 pub osd_enabled: Option<bool>,
908}
909
910impl ToTlv for SnapshotStreamStruct {
911 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
912 w.start_structure(tag)?;
913 self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
914 self.image_codec.to_tlv(w, Tag::Context(1))?;
915 self.frame_rate.to_tlv(w, Tag::Context(2))?;
916 self.min_resolution.to_tlv(w, Tag::Context(3))?;
917 self.max_resolution.to_tlv(w, Tag::Context(4))?;
918 self.quality.to_tlv(w, Tag::Context(5))?;
919 self.reference_count.to_tlv(w, Tag::Context(6))?;
920 self.encoded_pixels.to_tlv(w, Tag::Context(7))?;
921 self.hardware_encoder.to_tlv(w, Tag::Context(8))?;
922 if let Some(value) = &self.watermark_enabled {
923 value.to_tlv(w, Tag::Context(9))?;
924 }
925 if let Some(value) = &self.osd_enabled {
926 value.to_tlv(w, Tag::Context(10))?;
927 }
928 w.end_container()
929 }
930}
931
932impl<'a> FromTlv<'a> for SnapshotStreamStruct {
933 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
934 if element.value.container() != Some(ContainerKind::Structure) {
935 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
936 }
937 let mut snapshot_stream_id = None;
938 let mut image_codec = None;
939 let mut frame_rate = None;
940 let mut min_resolution = None;
941 let mut max_resolution = None;
942 let mut quality = None;
943 let mut reference_count = None;
944 let mut encoded_pixels = None;
945 let mut hardware_encoder = None;
946 let mut watermark_enabled = None;
947 let mut osd_enabled = None;
948 loop {
949 let Some(field) = reader.next_element()? else {
950 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
951 };
952 if field.value == Value::EndOfContainer {
953 break;
954 }
955 match field.tag.context() {
956 Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
957 Some(1) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
958 Some(2) => frame_rate = Some(<u16>::from_tlv(reader, &field)?),
959 Some(3) => {
960 min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
961 }
962 Some(4) => {
963 max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
964 }
965 Some(5) => quality = Some(<u8>::from_tlv(reader, &field)?),
966 Some(6) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
967 Some(7) => encoded_pixels = Some(<bool>::from_tlv(reader, &field)?),
968 Some(8) => hardware_encoder = Some(<bool>::from_tlv(reader, &field)?),
969 Some(9) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
970 Some(10) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
971 _ => reader.skip_value(&field)?,
975 }
976 }
977 Ok(Self {
978 snapshot_stream_id: snapshot_stream_id
979 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
980 image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
981 frame_rate: frame_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
982 min_resolution: min_resolution
983 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
984 max_resolution: max_resolution
985 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
986 quality: quality.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
987 reference_count: reference_count
988 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
989 encoded_pixels: encoded_pixels
990 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
991 hardware_encoder: hardware_encoder
992 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
993 watermark_enabled,
994 osd_enabled,
995 })
996 }
997}
998
999#[derive(Debug, Clone, Copy, PartialEq)]
1001pub struct VideoResolutionStruct {
1002 pub width: u16,
1004 pub height: u16,
1006}
1007
1008impl ToTlv for VideoResolutionStruct {
1009 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1010 w.start_structure(tag)?;
1011 self.width.to_tlv(w, Tag::Context(0))?;
1012 self.height.to_tlv(w, Tag::Context(1))?;
1013 w.end_container()
1014 }
1015}
1016
1017impl<'a> FromTlv<'a> for VideoResolutionStruct {
1018 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1019 if element.value.container() != Some(ContainerKind::Structure) {
1020 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1021 }
1022 let mut width = None;
1023 let mut height = None;
1024 loop {
1025 let Some(field) = reader.next_element()? else {
1026 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1027 };
1028 if field.value == Value::EndOfContainer {
1029 break;
1030 }
1031 match field.tag.context() {
1032 Some(0) => width = Some(<u16>::from_tlv(reader, &field)?),
1033 Some(1) => height = Some(<u16>::from_tlv(reader, &field)?),
1034 _ => reader.skip_value(&field)?,
1038 }
1039 }
1040 Ok(Self {
1041 width: width.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1042 height: height.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1043 })
1044 }
1045}
1046
1047#[derive(Debug, Clone, Copy, PartialEq)]
1049pub struct VideoSensorParamsStruct {
1050 pub sensor_width: u16,
1052 pub sensor_height: u16,
1054 pub max_fps: u16,
1056 pub max_hdrfps: Option<u16>,
1058}
1059
1060impl ToTlv for VideoSensorParamsStruct {
1061 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1062 w.start_structure(tag)?;
1063 self.sensor_width.to_tlv(w, Tag::Context(0))?;
1064 self.sensor_height.to_tlv(w, Tag::Context(1))?;
1065 self.max_fps.to_tlv(w, Tag::Context(2))?;
1066 if let Some(value) = &self.max_hdrfps {
1067 value.to_tlv(w, Tag::Context(3))?;
1068 }
1069 w.end_container()
1070 }
1071}
1072
1073impl<'a> FromTlv<'a> for VideoSensorParamsStruct {
1074 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1075 if element.value.container() != Some(ContainerKind::Structure) {
1076 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1077 }
1078 let mut sensor_width = None;
1079 let mut sensor_height = None;
1080 let mut max_fps = None;
1081 let mut max_hdrfps = None;
1082 loop {
1083 let Some(field) = reader.next_element()? else {
1084 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1085 };
1086 if field.value == Value::EndOfContainer {
1087 break;
1088 }
1089 match field.tag.context() {
1090 Some(0) => sensor_width = Some(<u16>::from_tlv(reader, &field)?),
1091 Some(1) => sensor_height = Some(<u16>::from_tlv(reader, &field)?),
1092 Some(2) => max_fps = Some(<u16>::from_tlv(reader, &field)?),
1093 Some(3) => max_hdrfps = Some(<u16>::from_tlv(reader, &field)?),
1094 _ => reader.skip_value(&field)?,
1098 }
1099 }
1100 Ok(Self {
1101 sensor_width: sensor_width.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1102 sensor_height: sensor_height.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1103 max_fps: max_fps.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1104 max_hdrfps,
1105 })
1106 }
1107}
1108
1109#[derive(Debug, Clone, Copy, PartialEq)]
1111pub struct VideoStreamStruct {
1112 pub video_stream_id: u16,
1114 pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
1116 pub video_codec: VideoCodecEnum,
1118 pub min_frame_rate: u16,
1120 pub max_frame_rate: u16,
1122 pub min_resolution: VideoResolutionStruct,
1124 pub max_resolution: VideoResolutionStruct,
1126 pub min_bit_rate: u32,
1128 pub max_bit_rate: u32,
1130 pub key_frame_interval: u16,
1132 pub watermark_enabled: Option<bool>,
1134 pub osd_enabled: Option<bool>,
1136 pub reference_count: u8,
1138}
1139
1140impl ToTlv for VideoStreamStruct {
1141 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1142 w.start_structure(tag)?;
1143 self.video_stream_id.to_tlv(w, Tag::Context(0))?;
1144 self.stream_usage.to_tlv(w, Tag::Context(1))?;
1145 self.video_codec.to_tlv(w, Tag::Context(2))?;
1146 self.min_frame_rate.to_tlv(w, Tag::Context(3))?;
1147 self.max_frame_rate.to_tlv(w, Tag::Context(4))?;
1148 self.min_resolution.to_tlv(w, Tag::Context(5))?;
1149 self.max_resolution.to_tlv(w, Tag::Context(6))?;
1150 self.min_bit_rate.to_tlv(w, Tag::Context(7))?;
1151 self.max_bit_rate.to_tlv(w, Tag::Context(8))?;
1152 self.key_frame_interval.to_tlv(w, Tag::Context(9))?;
1153 if let Some(value) = &self.watermark_enabled {
1154 value.to_tlv(w, Tag::Context(10))?;
1155 }
1156 if let Some(value) = &self.osd_enabled {
1157 value.to_tlv(w, Tag::Context(11))?;
1158 }
1159 self.reference_count.to_tlv(w, Tag::Context(12))?;
1160 w.end_container()
1161 }
1162}
1163
1164impl<'a> FromTlv<'a> for VideoStreamStruct {
1165 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1166 if element.value.container() != Some(ContainerKind::Structure) {
1167 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1168 }
1169 let mut video_stream_id = None;
1170 let mut stream_usage = None;
1171 let mut video_codec = None;
1172 let mut min_frame_rate = None;
1173 let mut max_frame_rate = None;
1174 let mut min_resolution = None;
1175 let mut max_resolution = None;
1176 let mut min_bit_rate = None;
1177 let mut max_bit_rate = None;
1178 let mut key_frame_interval = None;
1179 let mut watermark_enabled = None;
1180 let mut osd_enabled = None;
1181 let mut reference_count = None;
1182 loop {
1183 let Some(field) = reader.next_element()? else {
1184 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1185 };
1186 if field.value == Value::EndOfContainer {
1187 break;
1188 }
1189 match field.tag.context() {
1190 Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1191 Some(1) => {
1192 stream_usage = Some(
1193 <crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
1194 reader, &field,
1195 )?,
1196 )
1197 }
1198 Some(2) => video_codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
1199 Some(3) => min_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
1200 Some(4) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
1201 Some(5) => {
1202 min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1203 }
1204 Some(6) => {
1205 max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1206 }
1207 Some(7) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
1208 Some(8) => max_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
1209 Some(9) => key_frame_interval = Some(<u16>::from_tlv(reader, &field)?),
1210 Some(10) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
1211 Some(11) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
1212 Some(12) => reference_count = Some(<u8>::from_tlv(reader, &field)?),
1213 _ => reader.skip_value(&field)?,
1217 }
1218 }
1219 Ok(Self {
1220 video_stream_id: video_stream_id
1221 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1222 stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1223 video_codec: video_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1224 min_frame_rate: min_frame_rate
1225 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1226 max_frame_rate: max_frame_rate
1227 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1228 min_resolution: min_resolution
1229 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1230 max_resolution: max_resolution
1231 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1232 min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1233 max_bit_rate: max_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1234 key_frame_interval: key_frame_interval
1235 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1236 watermark_enabled,
1237 osd_enabled,
1238 reference_count: reference_count
1239 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1240 })
1241 }
1242}
1243
1244#[derive(Debug, Clone, Copy, PartialEq)]
1246pub struct AudioStreamAllocateFields {
1247 pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
1249 pub audio_codec: AudioCodecEnum,
1251 pub channel_count: u8,
1253 pub sample_rate: u32,
1255 pub bit_rate: u32,
1257 pub bit_depth: u8,
1259}
1260
1261impl ToTlv for AudioStreamAllocateFields {
1262 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1263 w.start_structure(tag)?;
1264 self.stream_usage.to_tlv(w, Tag::Context(0))?;
1265 self.audio_codec.to_tlv(w, Tag::Context(1))?;
1266 self.channel_count.to_tlv(w, Tag::Context(2))?;
1267 self.sample_rate.to_tlv(w, Tag::Context(3))?;
1268 self.bit_rate.to_tlv(w, Tag::Context(4))?;
1269 self.bit_depth.to_tlv(w, Tag::Context(5))?;
1270 w.end_container()
1271 }
1272}
1273
1274impl<'a> FromTlv<'a> for AudioStreamAllocateFields {
1275 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1276 if element.value.container() != Some(ContainerKind::Structure) {
1277 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1278 }
1279 let mut stream_usage = None;
1280 let mut audio_codec = None;
1281 let mut channel_count = None;
1282 let mut sample_rate = None;
1283 let mut bit_rate = None;
1284 let mut bit_depth = None;
1285 loop {
1286 let Some(field) = reader.next_element()? else {
1287 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1288 };
1289 if field.value == Value::EndOfContainer {
1290 break;
1291 }
1292 match field.tag.context() {
1293 Some(0) => {
1294 stream_usage = Some(
1295 <crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
1296 reader, &field,
1297 )?,
1298 )
1299 }
1300 Some(1) => audio_codec = Some(<AudioCodecEnum>::from_tlv(reader, &field)?),
1301 Some(2) => channel_count = Some(<u8>::from_tlv(reader, &field)?),
1302 Some(3) => sample_rate = Some(<u32>::from_tlv(reader, &field)?),
1303 Some(4) => bit_rate = Some(<u32>::from_tlv(reader, &field)?),
1304 Some(5) => bit_depth = Some(<u8>::from_tlv(reader, &field)?),
1305 _ => reader.skip_value(&field)?,
1309 }
1310 }
1311 Ok(Self {
1312 stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1313 audio_codec: audio_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1314 channel_count: channel_count.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1315 sample_rate: sample_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1316 bit_rate: bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1317 bit_depth: bit_depth.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1318 })
1319 }
1320}
1321
1322#[derive(Debug, Clone, Copy, PartialEq)]
1324pub struct AudioStreamAllocateResponseFields {
1325 pub audio_stream_id: u16,
1327}
1328
1329impl ToTlv for AudioStreamAllocateResponseFields {
1330 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1331 w.start_structure(tag)?;
1332 self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
1333 w.end_container()
1334 }
1335}
1336
1337impl<'a> FromTlv<'a> for AudioStreamAllocateResponseFields {
1338 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1339 if element.value.container() != Some(ContainerKind::Structure) {
1340 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1341 }
1342 let mut audio_stream_id = None;
1343 loop {
1344 let Some(field) = reader.next_element()? else {
1345 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1346 };
1347 if field.value == Value::EndOfContainer {
1348 break;
1349 }
1350 match field.tag.context() {
1351 Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1352 _ => reader.skip_value(&field)?,
1356 }
1357 }
1358 Ok(Self {
1359 audio_stream_id: audio_stream_id
1360 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1361 })
1362 }
1363}
1364
1365#[derive(Debug, Clone, Copy, PartialEq)]
1367pub struct AudioStreamDeallocateFields {
1368 pub audio_stream_id: u16,
1370}
1371
1372impl ToTlv for AudioStreamDeallocateFields {
1373 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1374 w.start_structure(tag)?;
1375 self.audio_stream_id.to_tlv(w, Tag::Context(0))?;
1376 w.end_container()
1377 }
1378}
1379
1380impl<'a> FromTlv<'a> for AudioStreamDeallocateFields {
1381 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1382 if element.value.container() != Some(ContainerKind::Structure) {
1383 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1384 }
1385 let mut audio_stream_id = None;
1386 loop {
1387 let Some(field) = reader.next_element()? else {
1388 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1389 };
1390 if field.value == Value::EndOfContainer {
1391 break;
1392 }
1393 match field.tag.context() {
1394 Some(0) => audio_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1395 _ => reader.skip_value(&field)?,
1399 }
1400 }
1401 Ok(Self {
1402 audio_stream_id: audio_stream_id
1403 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1404 })
1405 }
1406}
1407
1408#[derive(Debug, Clone, Copy, PartialEq)]
1410pub struct VideoStreamAllocateFields {
1411 pub stream_usage: crate::clusters::generated::globals::StreamUsageEnum,
1413 pub video_codec: VideoCodecEnum,
1415 pub min_frame_rate: u16,
1417 pub max_frame_rate: u16,
1419 pub min_resolution: VideoResolutionStruct,
1421 pub max_resolution: VideoResolutionStruct,
1423 pub min_bit_rate: u32,
1425 pub max_bit_rate: u32,
1427 pub key_frame_interval: u16,
1429 pub watermark_enabled: Option<bool>,
1431 pub osd_enabled: Option<bool>,
1433}
1434
1435impl ToTlv for VideoStreamAllocateFields {
1436 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1437 w.start_structure(tag)?;
1438 self.stream_usage.to_tlv(w, Tag::Context(0))?;
1439 self.video_codec.to_tlv(w, Tag::Context(1))?;
1440 self.min_frame_rate.to_tlv(w, Tag::Context(2))?;
1441 self.max_frame_rate.to_tlv(w, Tag::Context(3))?;
1442 self.min_resolution.to_tlv(w, Tag::Context(4))?;
1443 self.max_resolution.to_tlv(w, Tag::Context(5))?;
1444 self.min_bit_rate.to_tlv(w, Tag::Context(6))?;
1445 self.max_bit_rate.to_tlv(w, Tag::Context(7))?;
1446 self.key_frame_interval.to_tlv(w, Tag::Context(8))?;
1447 if let Some(value) = &self.watermark_enabled {
1448 value.to_tlv(w, Tag::Context(9))?;
1449 }
1450 if let Some(value) = &self.osd_enabled {
1451 value.to_tlv(w, Tag::Context(10))?;
1452 }
1453 w.end_container()
1454 }
1455}
1456
1457impl<'a> FromTlv<'a> for VideoStreamAllocateFields {
1458 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1459 if element.value.container() != Some(ContainerKind::Structure) {
1460 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1461 }
1462 let mut stream_usage = None;
1463 let mut video_codec = None;
1464 let mut min_frame_rate = None;
1465 let mut max_frame_rate = None;
1466 let mut min_resolution = None;
1467 let mut max_resolution = None;
1468 let mut min_bit_rate = None;
1469 let mut max_bit_rate = None;
1470 let mut key_frame_interval = None;
1471 let mut watermark_enabled = None;
1472 let mut osd_enabled = None;
1473 loop {
1474 let Some(field) = reader.next_element()? else {
1475 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1476 };
1477 if field.value == Value::EndOfContainer {
1478 break;
1479 }
1480 match field.tag.context() {
1481 Some(0) => {
1482 stream_usage = Some(
1483 <crate::clusters::generated::globals::StreamUsageEnum>::from_tlv(
1484 reader, &field,
1485 )?,
1486 )
1487 }
1488 Some(1) => video_codec = Some(<VideoCodecEnum>::from_tlv(reader, &field)?),
1489 Some(2) => min_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
1490 Some(3) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
1491 Some(4) => {
1492 min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1493 }
1494 Some(5) => {
1495 max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1496 }
1497 Some(6) => min_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
1498 Some(7) => max_bit_rate = Some(<u32>::from_tlv(reader, &field)?),
1499 Some(8) => key_frame_interval = Some(<u16>::from_tlv(reader, &field)?),
1500 Some(9) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
1501 Some(10) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
1502 _ => reader.skip_value(&field)?,
1506 }
1507 }
1508 Ok(Self {
1509 stream_usage: stream_usage.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1510 video_codec: video_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1511 min_frame_rate: min_frame_rate
1512 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1513 max_frame_rate: max_frame_rate
1514 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1515 min_resolution: min_resolution
1516 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1517 max_resolution: max_resolution
1518 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1519 min_bit_rate: min_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1520 max_bit_rate: max_bit_rate.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1521 key_frame_interval: key_frame_interval
1522 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1523 watermark_enabled,
1524 osd_enabled,
1525 })
1526 }
1527}
1528
1529#[derive(Debug, Clone, Copy, PartialEq)]
1531pub struct VideoStreamAllocateResponseFields {
1532 pub video_stream_id: u16,
1534}
1535
1536impl ToTlv for VideoStreamAllocateResponseFields {
1537 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1538 w.start_structure(tag)?;
1539 self.video_stream_id.to_tlv(w, Tag::Context(0))?;
1540 w.end_container()
1541 }
1542}
1543
1544impl<'a> FromTlv<'a> for VideoStreamAllocateResponseFields {
1545 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1546 if element.value.container() != Some(ContainerKind::Structure) {
1547 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1548 }
1549 let mut video_stream_id = None;
1550 loop {
1551 let Some(field) = reader.next_element()? else {
1552 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1553 };
1554 if field.value == Value::EndOfContainer {
1555 break;
1556 }
1557 match field.tag.context() {
1558 Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1559 _ => reader.skip_value(&field)?,
1563 }
1564 }
1565 Ok(Self {
1566 video_stream_id: video_stream_id
1567 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1568 })
1569 }
1570}
1571
1572#[derive(Debug, Clone, Copy, PartialEq)]
1574pub struct VideoStreamModifyFields {
1575 pub video_stream_id: u16,
1577 pub watermark_enabled: Option<bool>,
1579 pub osd_enabled: Option<bool>,
1581}
1582
1583impl ToTlv for VideoStreamModifyFields {
1584 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1585 w.start_structure(tag)?;
1586 self.video_stream_id.to_tlv(w, Tag::Context(0))?;
1587 if let Some(value) = &self.watermark_enabled {
1588 value.to_tlv(w, Tag::Context(1))?;
1589 }
1590 if let Some(value) = &self.osd_enabled {
1591 value.to_tlv(w, Tag::Context(2))?;
1592 }
1593 w.end_container()
1594 }
1595}
1596
1597impl<'a> FromTlv<'a> for VideoStreamModifyFields {
1598 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1599 if element.value.container() != Some(ContainerKind::Structure) {
1600 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1601 }
1602 let mut video_stream_id = None;
1603 let mut watermark_enabled = None;
1604 let mut osd_enabled = None;
1605 loop {
1606 let Some(field) = reader.next_element()? else {
1607 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1608 };
1609 if field.value == Value::EndOfContainer {
1610 break;
1611 }
1612 match field.tag.context() {
1613 Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1614 Some(1) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
1615 Some(2) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
1616 _ => reader.skip_value(&field)?,
1620 }
1621 }
1622 Ok(Self {
1623 video_stream_id: video_stream_id
1624 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1625 watermark_enabled,
1626 osd_enabled,
1627 })
1628 }
1629}
1630
1631#[derive(Debug, Clone, Copy, PartialEq)]
1633pub struct VideoStreamDeallocateFields {
1634 pub video_stream_id: u16,
1636}
1637
1638impl ToTlv for VideoStreamDeallocateFields {
1639 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1640 w.start_structure(tag)?;
1641 self.video_stream_id.to_tlv(w, Tag::Context(0))?;
1642 w.end_container()
1643 }
1644}
1645
1646impl<'a> FromTlv<'a> for VideoStreamDeallocateFields {
1647 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1648 if element.value.container() != Some(ContainerKind::Structure) {
1649 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1650 }
1651 let mut video_stream_id = None;
1652 loop {
1653 let Some(field) = reader.next_element()? else {
1654 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1655 };
1656 if field.value == Value::EndOfContainer {
1657 break;
1658 }
1659 match field.tag.context() {
1660 Some(0) => video_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1661 _ => reader.skip_value(&field)?,
1665 }
1666 }
1667 Ok(Self {
1668 video_stream_id: video_stream_id
1669 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1670 })
1671 }
1672}
1673
1674#[derive(Debug, Clone, Copy, PartialEq)]
1676pub struct SnapshotStreamAllocateFields {
1677 pub image_codec: ImageCodecEnum,
1679 pub max_frame_rate: u16,
1681 pub min_resolution: VideoResolutionStruct,
1683 pub max_resolution: VideoResolutionStruct,
1685 pub quality: u8,
1687 pub watermark_enabled: Option<bool>,
1689 pub osd_enabled: Option<bool>,
1691}
1692
1693impl ToTlv for SnapshotStreamAllocateFields {
1694 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1695 w.start_structure(tag)?;
1696 self.image_codec.to_tlv(w, Tag::Context(0))?;
1697 self.max_frame_rate.to_tlv(w, Tag::Context(1))?;
1698 self.min_resolution.to_tlv(w, Tag::Context(2))?;
1699 self.max_resolution.to_tlv(w, Tag::Context(3))?;
1700 self.quality.to_tlv(w, Tag::Context(4))?;
1701 if let Some(value) = &self.watermark_enabled {
1702 value.to_tlv(w, Tag::Context(5))?;
1703 }
1704 if let Some(value) = &self.osd_enabled {
1705 value.to_tlv(w, Tag::Context(6))?;
1706 }
1707 w.end_container()
1708 }
1709}
1710
1711impl<'a> FromTlv<'a> for SnapshotStreamAllocateFields {
1712 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1713 if element.value.container() != Some(ContainerKind::Structure) {
1714 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1715 }
1716 let mut image_codec = None;
1717 let mut max_frame_rate = None;
1718 let mut min_resolution = None;
1719 let mut max_resolution = None;
1720 let mut quality = None;
1721 let mut watermark_enabled = None;
1722 let mut osd_enabled = None;
1723 loop {
1724 let Some(field) = reader.next_element()? else {
1725 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1726 };
1727 if field.value == Value::EndOfContainer {
1728 break;
1729 }
1730 match field.tag.context() {
1731 Some(0) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
1732 Some(1) => max_frame_rate = Some(<u16>::from_tlv(reader, &field)?),
1733 Some(2) => {
1734 min_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1735 }
1736 Some(3) => {
1737 max_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1738 }
1739 Some(4) => quality = Some(<u8>::from_tlv(reader, &field)?),
1740 Some(5) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
1741 Some(6) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
1742 _ => reader.skip_value(&field)?,
1746 }
1747 }
1748 Ok(Self {
1749 image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1750 max_frame_rate: max_frame_rate
1751 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1752 min_resolution: min_resolution
1753 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1754 max_resolution: max_resolution
1755 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1756 quality: quality.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1757 watermark_enabled,
1758 osd_enabled,
1759 })
1760 }
1761}
1762
1763#[derive(Debug, Clone, Copy, PartialEq)]
1765pub struct SnapshotStreamAllocateResponseFields {
1766 pub snapshot_stream_id: u16,
1768}
1769
1770impl ToTlv for SnapshotStreamAllocateResponseFields {
1771 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1772 w.start_structure(tag)?;
1773 self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
1774 w.end_container()
1775 }
1776}
1777
1778impl<'a> FromTlv<'a> for SnapshotStreamAllocateResponseFields {
1779 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1780 if element.value.container() != Some(ContainerKind::Structure) {
1781 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1782 }
1783 let mut snapshot_stream_id = None;
1784 loop {
1785 let Some(field) = reader.next_element()? else {
1786 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1787 };
1788 if field.value == Value::EndOfContainer {
1789 break;
1790 }
1791 match field.tag.context() {
1792 Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1793 _ => reader.skip_value(&field)?,
1797 }
1798 }
1799 Ok(Self {
1800 snapshot_stream_id: snapshot_stream_id
1801 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1802 })
1803 }
1804}
1805
1806#[derive(Debug, Clone, Copy, PartialEq)]
1808pub struct SnapshotStreamModifyFields {
1809 pub snapshot_stream_id: u16,
1811 pub watermark_enabled: Option<bool>,
1813 pub osd_enabled: Option<bool>,
1815}
1816
1817impl ToTlv for SnapshotStreamModifyFields {
1818 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1819 w.start_structure(tag)?;
1820 self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
1821 if let Some(value) = &self.watermark_enabled {
1822 value.to_tlv(w, Tag::Context(1))?;
1823 }
1824 if let Some(value) = &self.osd_enabled {
1825 value.to_tlv(w, Tag::Context(2))?;
1826 }
1827 w.end_container()
1828 }
1829}
1830
1831impl<'a> FromTlv<'a> for SnapshotStreamModifyFields {
1832 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1833 if element.value.container() != Some(ContainerKind::Structure) {
1834 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1835 }
1836 let mut snapshot_stream_id = None;
1837 let mut watermark_enabled = None;
1838 let mut osd_enabled = None;
1839 loop {
1840 let Some(field) = reader.next_element()? else {
1841 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1842 };
1843 if field.value == Value::EndOfContainer {
1844 break;
1845 }
1846 match field.tag.context() {
1847 Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1848 Some(1) => watermark_enabled = Some(<bool>::from_tlv(reader, &field)?),
1849 Some(2) => osd_enabled = Some(<bool>::from_tlv(reader, &field)?),
1850 _ => reader.skip_value(&field)?,
1854 }
1855 }
1856 Ok(Self {
1857 snapshot_stream_id: snapshot_stream_id
1858 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1859 watermark_enabled,
1860 osd_enabled,
1861 })
1862 }
1863}
1864
1865#[derive(Debug, Clone, Copy, PartialEq)]
1867pub struct SnapshotStreamDeallocateFields {
1868 pub snapshot_stream_id: u16,
1870}
1871
1872impl ToTlv for SnapshotStreamDeallocateFields {
1873 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1874 w.start_structure(tag)?;
1875 self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
1876 w.end_container()
1877 }
1878}
1879
1880impl<'a> FromTlv<'a> for SnapshotStreamDeallocateFields {
1881 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1882 if element.value.container() != Some(ContainerKind::Structure) {
1883 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1884 }
1885 let mut snapshot_stream_id = None;
1886 loop {
1887 let Some(field) = reader.next_element()? else {
1888 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1889 };
1890 if field.value == Value::EndOfContainer {
1891 break;
1892 }
1893 match field.tag.context() {
1894 Some(0) => snapshot_stream_id = Some(<u16>::from_tlv(reader, &field)?),
1895 _ => reader.skip_value(&field)?,
1899 }
1900 }
1901 Ok(Self {
1902 snapshot_stream_id: snapshot_stream_id
1903 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1904 })
1905 }
1906}
1907
1908#[derive(Debug, Clone, Copy, PartialEq)]
1910pub struct SetStreamPrioritiesFields<'a> {
1911 pub stream_priorities: TlvList<'a, crate::clusters::generated::globals::StreamUsageEnum>,
1913}
1914
1915impl<'a> ToTlv for SetStreamPrioritiesFields<'a> {
1916 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1917 w.start_structure(tag)?;
1918 self.stream_priorities.to_tlv(w, Tag::Context(0))?;
1919 w.end_container()
1920 }
1921}
1922
1923impl<'a> FromTlv<'a> for SetStreamPrioritiesFields<'a> {
1924 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1925 if element.value.container() != Some(ContainerKind::Structure) {
1926 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1927 }
1928 let mut stream_priorities = None;
1929 loop {
1930 let Some(field) = reader.next_element()? else {
1931 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1932 };
1933 if field.value == Value::EndOfContainer {
1934 break;
1935 }
1936 match field.tag.context() {
1937 Some(0) => {
1938 stream_priorities = Some(<TlvList<
1939 'a,
1940 crate::clusters::generated::globals::StreamUsageEnum,
1941 >>::from_tlv(reader, &field)?)
1942 }
1943 _ => reader.skip_value(&field)?,
1947 }
1948 }
1949 Ok(Self {
1950 stream_priorities: stream_priorities
1951 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1952 })
1953 }
1954}
1955
1956#[derive(Debug, Clone, Copy, PartialEq)]
1958pub struct CaptureSnapshotFields {
1959 pub snapshot_stream_id: Nullable<u16>,
1961 pub requested_resolution: VideoResolutionStruct,
1963}
1964
1965impl ToTlv for CaptureSnapshotFields {
1966 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1967 w.start_structure(tag)?;
1968 self.snapshot_stream_id.to_tlv(w, Tag::Context(0))?;
1969 self.requested_resolution.to_tlv(w, Tag::Context(1))?;
1970 w.end_container()
1971 }
1972}
1973
1974impl<'a> FromTlv<'a> for CaptureSnapshotFields {
1975 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1976 if element.value.container() != Some(ContainerKind::Structure) {
1977 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1978 }
1979 let mut snapshot_stream_id = None;
1980 let mut requested_resolution = None;
1981 loop {
1982 let Some(field) = reader.next_element()? else {
1983 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1984 };
1985 if field.value == Value::EndOfContainer {
1986 break;
1987 }
1988 match field.tag.context() {
1989 Some(0) => snapshot_stream_id = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
1990 Some(1) => {
1991 requested_resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?)
1992 }
1993 _ => reader.skip_value(&field)?,
1997 }
1998 }
1999 Ok(Self {
2000 snapshot_stream_id: snapshot_stream_id
2001 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2002 requested_resolution: requested_resolution
2003 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2004 })
2005 }
2006}
2007
2008#[derive(Debug, Clone, Copy, PartialEq)]
2010pub struct CaptureSnapshotResponseFields<'a> {
2011 pub data: &'a [u8],
2013 pub image_codec: ImageCodecEnum,
2015 pub resolution: VideoResolutionStruct,
2017}
2018
2019impl<'a> ToTlv for CaptureSnapshotResponseFields<'a> {
2020 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
2021 w.start_structure(tag)?;
2022 self.data.to_tlv(w, Tag::Context(0))?;
2023 self.image_codec.to_tlv(w, Tag::Context(1))?;
2024 self.resolution.to_tlv(w, Tag::Context(2))?;
2025 w.end_container()
2026 }
2027}
2028
2029impl<'a> FromTlv<'a> for CaptureSnapshotResponseFields<'a> {
2030 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
2031 if element.value.container() != Some(ContainerKind::Structure) {
2032 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
2033 }
2034 let mut data = None;
2035 let mut image_codec = None;
2036 let mut resolution = None;
2037 loop {
2038 let Some(field) = reader.next_element()? else {
2039 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
2040 };
2041 if field.value == Value::EndOfContainer {
2042 break;
2043 }
2044 match field.tag.context() {
2045 Some(0) => data = Some(<&'a [u8]>::from_tlv(reader, &field)?),
2046 Some(1) => image_codec = Some(<ImageCodecEnum>::from_tlv(reader, &field)?),
2047 Some(2) => resolution = Some(<VideoResolutionStruct>::from_tlv(reader, &field)?),
2048 _ => reader.skip_value(&field)?,
2052 }
2053 }
2054 Ok(Self {
2055 data: data.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2056 image_codec: image_codec.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2057 resolution: resolution.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
2058 })
2059 }
2060}
2061
2062pub const ATTRIBUTES: &[Attribute] = &[
2064 Attribute {
2065 id: 0x0000,
2066 name: "MaxConcurrentEncoders",
2067 kind: "uint8",
2068 access: Access::read_only(Privilege::View),
2069 qualities: AttributeQualities::FIXED,
2070 reporting: Reporting::OnChange,
2071 conform: Conform {
2072 clauses: &[Clause {
2073 verdict: Conformance::Mandatory,
2074 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
2075 }],
2076 },
2077 },
2078 Attribute {
2079 id: 0x0001,
2080 name: "MaxEncodedPixelRate",
2081 kind: "uint32",
2082 access: Access::read_only(Privilege::View),
2083 qualities: AttributeQualities::FIXED,
2084 reporting: Reporting::OnChange,
2085 conform: Conform {
2086 clauses: &[Clause {
2087 verdict: Conformance::Mandatory,
2088 when: Condition::Any(&[Condition::Feature(1), Condition::Feature(2)]),
2089 }],
2090 },
2091 },
2092 Attribute {
2093 id: 0x0002,
2094 name: "VideoSensorParams",
2095 kind: "VideoSensorParamsStruct",
2096 access: Access::read_only(Privilege::View),
2097 qualities: AttributeQualities::FIXED,
2098 reporting: Reporting::OnChange,
2099 conform: Conform {
2100 clauses: &[Clause {
2101 verdict: Conformance::Mandatory,
2102 when: Condition::Feature(1),
2103 }],
2104 },
2105 },
2106 Attribute {
2107 id: 0x0003,
2108 name: "NightVisionUsesInfrared",
2109 kind: "bool",
2110 access: Access::read_only(Privilege::View),
2111 qualities: AttributeQualities::FIXED,
2112 reporting: Reporting::OnChange,
2113 conform: Conform {
2114 clauses: &[Clause {
2115 verdict: Conformance::Mandatory,
2116 when: Condition::Feature(10),
2117 }],
2118 },
2119 },
2120 Attribute {
2121 id: 0x0004,
2122 name: "MinViewportResolution",
2123 kind: "VideoResolutionStruct",
2124 access: Access::read_only(Privilege::View),
2125 qualities: AttributeQualities::FIXED,
2126 reporting: Reporting::OnChange,
2127 conform: Conform {
2128 clauses: &[Clause {
2129 verdict: Conformance::Mandatory,
2130 when: Condition::Feature(1),
2131 }],
2132 },
2133 },
2134 Attribute {
2135 id: 0x0005,
2136 name: "RateDistortionTradeOffPoints",
2137 kind: "list[RateDistortionTradeOffPointsStruct]",
2138 access: Access::read_only(Privilege::View),
2139 qualities: AttributeQualities::FIXED,
2140 reporting: Reporting::OnChange,
2141 conform: Conform {
2142 clauses: &[Clause {
2143 verdict: Conformance::Mandatory,
2144 when: Condition::Feature(1),
2145 }],
2146 },
2147 },
2148 Attribute {
2149 id: 0x0006,
2150 name: "MaxContentBufferSize",
2151 kind: "uint32",
2152 access: Access::read_only(Privilege::View),
2153 qualities: AttributeQualities::FIXED,
2154 reporting: Reporting::OnChange,
2155 conform: Conform::MANDATORY,
2156 },
2157 Attribute {
2158 id: 0x0007,
2159 name: "MicrophoneCapabilities",
2160 kind: "AudioCapabilitiesStruct",
2161 access: Access::read_only(Privilege::View),
2162 qualities: AttributeQualities::FIXED,
2163 reporting: Reporting::OnChange,
2164 conform: Conform {
2165 clauses: &[Clause {
2166 verdict: Conformance::Mandatory,
2167 when: Condition::Feature(0),
2168 }],
2169 },
2170 },
2171 Attribute {
2172 id: 0x0008,
2173 name: "SpeakerCapabilities",
2174 kind: "AudioCapabilitiesStruct",
2175 access: Access::read_only(Privilege::View),
2176 qualities: AttributeQualities::FIXED,
2177 reporting: Reporting::OnChange,
2178 conform: Conform {
2179 clauses: &[Clause {
2180 verdict: Conformance::Mandatory,
2181 when: Condition::Feature(4),
2182 }],
2183 },
2184 },
2185 Attribute {
2186 id: 0x0009,
2187 name: "TwoWayTalkSupport",
2188 kind: "TwoWayTalkSupportTypeEnum",
2189 access: Access::read_only(Privilege::View),
2190 qualities: AttributeQualities::FIXED,
2191 reporting: Reporting::OnChange,
2192 conform: Conform {
2193 clauses: &[Clause {
2194 verdict: Conformance::Mandatory,
2195 when: Condition::Feature(4),
2196 }],
2197 },
2198 },
2199 Attribute {
2200 id: 0x000A,
2201 name: "SnapshotCapabilities",
2202 kind: "list[SnapshotCapabilitiesStruct]",
2203 access: Access::read_only(Privilege::View),
2204 qualities: AttributeQualities::FIXED,
2205 reporting: Reporting::OnChange,
2206 conform: Conform {
2207 clauses: &[Clause {
2208 verdict: Conformance::Mandatory,
2209 when: Condition::Feature(2),
2210 }],
2211 },
2212 },
2213 Attribute {
2214 id: 0x000B,
2215 name: "MaxNetworkBandwidth",
2216 kind: "uint32",
2217 access: Access::read_only(Privilege::View),
2218 qualities: AttributeQualities::FIXED,
2219 reporting: Reporting::OnChange,
2220 conform: Conform::MANDATORY,
2221 },
2222 Attribute {
2223 id: 0x000C,
2224 name: "CurrentFrameRate",
2225 kind: "uint16",
2226 access: Access::read_only(Privilege::View),
2227 qualities: AttributeQualities::empty(),
2228 reporting: Reporting::OnChange,
2229 conform: Conform {
2230 clauses: &[Clause {
2231 verdict: Conformance::Mandatory,
2232 when: Condition::Feature(1),
2233 }],
2234 },
2235 },
2236 Attribute {
2237 id: 0x000D,
2238 name: "HDRModeEnabled",
2239 kind: "bool",
2240 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2241 qualities: AttributeQualities::NON_VOLATILE,
2242 reporting: Reporting::OnChange,
2243 conform: Conform {
2244 clauses: &[Clause {
2245 verdict: Conformance::Mandatory,
2246 when: Condition::Feature(9),
2247 }],
2248 },
2249 },
2250 Attribute {
2251 id: 0x000E,
2252 name: "SupportedStreamUsages",
2253 kind: "list[StreamUsageEnum]",
2254 access: Access::read_only(Privilege::View),
2255 qualities: AttributeQualities::FIXED,
2256 reporting: Reporting::OnChange,
2257 conform: Conform::MANDATORY,
2258 },
2259 Attribute {
2260 id: 0x000F,
2261 name: "AllocatedVideoStreams",
2262 kind: "list[VideoStreamStruct]",
2263 access: Access::read_only(Privilege::View),
2264 qualities: AttributeQualities::NON_VOLATILE,
2265 reporting: Reporting::OnChange,
2266 conform: Conform {
2267 clauses: &[Clause {
2268 verdict: Conformance::Mandatory,
2269 when: Condition::Feature(1),
2270 }],
2271 },
2272 },
2273 Attribute {
2274 id: 0x0010,
2275 name: "AllocatedAudioStreams",
2276 kind: "list[AudioStreamStruct]",
2277 access: Access::read_only(Privilege::View),
2278 qualities: AttributeQualities::NON_VOLATILE,
2279 reporting: Reporting::OnChange,
2280 conform: Conform {
2281 clauses: &[Clause {
2282 verdict: Conformance::Mandatory,
2283 when: Condition::Feature(0),
2284 }],
2285 },
2286 },
2287 Attribute {
2288 id: 0x0011,
2289 name: "AllocatedSnapshotStreams",
2290 kind: "list[SnapshotStreamStruct]",
2291 access: Access::read_only(Privilege::View),
2292 qualities: AttributeQualities::NON_VOLATILE,
2293 reporting: Reporting::OnChange,
2294 conform: Conform {
2295 clauses: &[Clause {
2296 verdict: Conformance::Mandatory,
2297 when: Condition::Feature(2),
2298 }],
2299 },
2300 },
2301 Attribute {
2302 id: 0x0012,
2303 name: "StreamUsagePriorities",
2304 kind: "list[StreamUsageEnum]",
2305 access: Access::read_only(Privilege::View),
2306 qualities: AttributeQualities::NON_VOLATILE,
2307 reporting: Reporting::OnChange,
2308 conform: Conform::MANDATORY,
2309 },
2310 Attribute {
2311 id: 0x0013,
2312 name: "SoftRecordingPrivacyModeEnabled",
2313 kind: "bool",
2314 access: Access::read_write_with(Privilege::View, Privilege::Operate),
2315 qualities: AttributeQualities::NON_VOLATILE,
2316 reporting: Reporting::OnChange,
2317 conform: Conform {
2318 clauses: &[Clause {
2319 verdict: Conformance::Mandatory,
2320 when: Condition::Feature(3),
2321 }],
2322 },
2323 },
2324 Attribute {
2325 id: 0x0014,
2326 name: "SoftLivestreamPrivacyModeEnabled",
2327 kind: "bool",
2328 access: Access::read_write_with(Privilege::View, Privilege::Operate),
2329 qualities: AttributeQualities::NON_VOLATILE,
2330 reporting: Reporting::OnChange,
2331 conform: Conform {
2332 clauses: &[Clause {
2333 verdict: Conformance::Mandatory,
2334 when: Condition::Feature(3),
2335 }],
2336 },
2337 },
2338 Attribute {
2339 id: 0x0015,
2340 name: "HardPrivacyModeOn",
2341 kind: "bool",
2342 access: Access::read_only(Privilege::View),
2343 qualities: AttributeQualities::empty(),
2344 reporting: Reporting::OnChange,
2345 conform: Conform::OPTIONAL,
2346 },
2347 Attribute {
2348 id: 0x0016,
2349 name: "NightVision",
2350 kind: "TriStateAutoEnum",
2351 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2352 qualities: AttributeQualities::NON_VOLATILE,
2353 reporting: Reporting::OnChange,
2354 conform: Conform {
2355 clauses: &[Clause {
2356 verdict: Conformance::Mandatory,
2357 when: Condition::Feature(10),
2358 }],
2359 },
2360 },
2361 Attribute {
2362 id: 0x0017,
2363 name: "NightVisionIllum",
2364 kind: "TriStateAutoEnum",
2365 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2366 qualities: AttributeQualities::NON_VOLATILE,
2367 reporting: Reporting::OnChange,
2368 conform: Conform {
2369 clauses: &[Clause {
2370 verdict: Conformance::Optional,
2371 when: Condition::Feature(10),
2372 }],
2373 },
2374 },
2375 Attribute {
2376 id: 0x0018,
2377 name: "Viewport",
2378 kind: "ViewportStruct",
2379 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2380 qualities: AttributeQualities::NON_VOLATILE,
2381 reporting: Reporting::OnChange,
2382 conform: Conform {
2383 clauses: &[Clause {
2384 verdict: Conformance::Mandatory,
2385 when: Condition::Feature(1),
2386 }],
2387 },
2388 },
2389 Attribute {
2390 id: 0x0019,
2391 name: "SpeakerMuted",
2392 kind: "bool",
2393 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2394 qualities: AttributeQualities::NON_VOLATILE,
2395 reporting: Reporting::OnChange,
2396 conform: Conform {
2397 clauses: &[Clause {
2398 verdict: Conformance::Mandatory,
2399 when: Condition::Feature(4),
2400 }],
2401 },
2402 },
2403 Attribute {
2404 id: 0x001A,
2405 name: "SpeakerVolumeLevel",
2406 kind: "uint8",
2407 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2408 qualities: AttributeQualities::NON_VOLATILE,
2409 reporting: Reporting::OnChange,
2410 conform: Conform {
2411 clauses: &[Clause {
2412 verdict: Conformance::Mandatory,
2413 when: Condition::Feature(4),
2414 }],
2415 },
2416 },
2417 Attribute {
2418 id: 0x001B,
2419 name: "SpeakerMaxLevel",
2420 kind: "uint8",
2421 access: Access::read_only(Privilege::Manage),
2422 qualities: AttributeQualities::empty(),
2423 reporting: Reporting::OnChange,
2424 conform: Conform {
2425 clauses: &[Clause {
2426 verdict: Conformance::Mandatory,
2427 when: Condition::Feature(4),
2428 }],
2429 },
2430 },
2431 Attribute {
2432 id: 0x001C,
2433 name: "SpeakerMinLevel",
2434 kind: "uint8",
2435 access: Access::read_only(Privilege::Manage),
2436 qualities: AttributeQualities::empty(),
2437 reporting: Reporting::OnChange,
2438 conform: Conform {
2439 clauses: &[Clause {
2440 verdict: Conformance::Mandatory,
2441 when: Condition::Feature(4),
2442 }],
2443 },
2444 },
2445 Attribute {
2446 id: 0x001D,
2447 name: "MicrophoneMuted",
2448 kind: "bool",
2449 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2450 qualities: AttributeQualities::NON_VOLATILE,
2451 reporting: Reporting::OnChange,
2452 conform: Conform {
2453 clauses: &[Clause {
2454 verdict: Conformance::Mandatory,
2455 when: Condition::Feature(0),
2456 }],
2457 },
2458 },
2459 Attribute {
2460 id: 0x001E,
2461 name: "MicrophoneVolumeLevel",
2462 kind: "uint8",
2463 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2464 qualities: AttributeQualities::NON_VOLATILE,
2465 reporting: Reporting::OnChange,
2466 conform: Conform {
2467 clauses: &[Clause {
2468 verdict: Conformance::Mandatory,
2469 when: Condition::Feature(0),
2470 }],
2471 },
2472 },
2473 Attribute {
2474 id: 0x001F,
2475 name: "MicrophoneMaxLevel",
2476 kind: "uint8",
2477 access: Access::read_only(Privilege::Manage),
2478 qualities: AttributeQualities::empty(),
2479 reporting: Reporting::OnChange,
2480 conform: Conform {
2481 clauses: &[Clause {
2482 verdict: Conformance::Mandatory,
2483 when: Condition::Feature(0),
2484 }],
2485 },
2486 },
2487 Attribute {
2488 id: 0x0020,
2489 name: "MicrophoneMinLevel",
2490 kind: "uint8",
2491 access: Access::read_only(Privilege::Manage),
2492 qualities: AttributeQualities::empty(),
2493 reporting: Reporting::OnChange,
2494 conform: Conform {
2495 clauses: &[Clause {
2496 verdict: Conformance::Mandatory,
2497 when: Condition::Feature(0),
2498 }],
2499 },
2500 },
2501 Attribute {
2502 id: 0x0021,
2503 name: "MicrophoneAGCEnabled",
2504 kind: "bool",
2505 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2506 qualities: AttributeQualities::NON_VOLATILE,
2507 reporting: Reporting::OnChange,
2508 conform: Conform {
2509 clauses: &[Clause {
2510 verdict: Conformance::Optional,
2511 when: Condition::Feature(0),
2512 }],
2513 },
2514 },
2515 Attribute {
2516 id: 0x0022,
2517 name: "ImageRotation",
2518 kind: "uint16",
2519 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2520 qualities: AttributeQualities::NON_VOLATILE,
2521 reporting: Reporting::OnChange,
2522 conform: Conform {
2523 clauses: &[Clause {
2524 verdict: Conformance::Optional,
2525 when: Condition::Feature(5),
2526 }],
2527 },
2528 },
2529 Attribute {
2530 id: 0x0023,
2531 name: "ImageFlipHorizontal",
2532 kind: "bool",
2533 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2534 qualities: AttributeQualities::NON_VOLATILE,
2535 reporting: Reporting::OnChange,
2536 conform: Conform {
2537 clauses: &[Clause {
2538 verdict: Conformance::Optional,
2539 when: Condition::Feature(5),
2540 }],
2541 },
2542 },
2543 Attribute {
2544 id: 0x0024,
2545 name: "ImageFlipVertical",
2546 kind: "bool",
2547 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2548 qualities: AttributeQualities::NON_VOLATILE,
2549 reporting: Reporting::OnChange,
2550 conform: Conform {
2551 clauses: &[Clause {
2552 verdict: Conformance::Optional,
2553 when: Condition::Feature(5),
2554 }],
2555 },
2556 },
2557 Attribute {
2558 id: 0x0025,
2559 name: "LocalVideoRecordingEnabled",
2560 kind: "bool",
2561 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2562 qualities: AttributeQualities::NON_VOLATILE,
2563 reporting: Reporting::OnChange,
2564 conform: Conform {
2565 clauses: &[Clause {
2566 verdict: Conformance::Mandatory,
2567 when: Condition::All(&[Condition::Feature(1), Condition::Feature(8)]),
2568 }],
2569 },
2570 },
2571 Attribute {
2572 id: 0x0026,
2573 name: "LocalSnapshotRecordingEnabled",
2574 kind: "bool",
2575 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2576 qualities: AttributeQualities::NON_VOLATILE,
2577 reporting: Reporting::OnChange,
2578 conform: Conform {
2579 clauses: &[Clause {
2580 verdict: Conformance::Mandatory,
2581 when: Condition::All(&[Condition::Feature(2), Condition::Feature(8)]),
2582 }],
2583 },
2584 },
2585 Attribute {
2586 id: 0x0027,
2587 name: "StatusLightEnabled",
2588 kind: "bool",
2589 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2590 qualities: AttributeQualities::NON_VOLATILE,
2591 reporting: Reporting::OnChange,
2592 conform: Conform::OPTIONAL,
2593 },
2594 Attribute {
2595 id: 0x0028,
2596 name: "StatusLightBrightness",
2597 kind: "ThreeLevelAutoEnum",
2598 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2599 qualities: AttributeQualities::NON_VOLATILE,
2600 reporting: Reporting::OnChange,
2601 conform: Conform::OPTIONAL,
2602 },
2603 Attribute {
2604 id: 0x0029,
2605 name: "ImageRotationDiscreteAngles",
2606 kind: "uint16",
2607 access: Access::read_write_with(Privilege::Manage, Privilege::Manage),
2608 qualities: AttributeQualities::NON_VOLATILE,
2609 reporting: Reporting::OnChange,
2610 conform: Conform {
2611 clauses: &[
2612 Clause {
2613 verdict: Conformance::Provisional,
2614 when: Condition::Always,
2615 },
2616 Clause {
2617 verdict: Conformance::Described,
2618 when: Condition::All(&[
2619 Condition::Named("comparison"),
2620 Condition::Feature(5),
2621 Condition::Not(&Condition::Attribute(0x0022)),
2622 ]),
2623 },
2624 ],
2625 },
2626 },
2627];
2628
2629pub const COMMANDS: &[Command] = &[
2631 Command {
2632 id: 0x00,
2633 name: "AudioStreamAllocate",
2634 to_server: true,
2635 response: Some(0x01),
2636 access: Access::invoke(Privilege::Manage),
2637 conform: Conform {
2638 clauses: &[Clause {
2639 verdict: Conformance::Mandatory,
2640 when: Condition::Feature(0),
2641 }],
2642 },
2643 },
2644 Command {
2645 id: 0x01,
2646 name: "AudioStreamAllocateResponse",
2647 to_server: false,
2648 response: None,
2649 access: Access::invoke(Privilege::Operate),
2650 conform: Conform {
2651 clauses: &[Clause {
2652 verdict: Conformance::Mandatory,
2653 when: Condition::Feature(0),
2654 }],
2655 },
2656 },
2657 Command {
2658 id: 0x02,
2659 name: "AudioStreamDeallocate",
2660 to_server: true,
2661 response: None,
2662 access: Access::invoke(Privilege::Manage),
2663 conform: Conform {
2664 clauses: &[Clause {
2665 verdict: Conformance::Mandatory,
2666 when: Condition::Feature(0),
2667 }],
2668 },
2669 },
2670 Command {
2671 id: 0x03,
2672 name: "VideoStreamAllocate",
2673 to_server: true,
2674 response: Some(0x04),
2675 access: Access::invoke(Privilege::Manage),
2676 conform: Conform {
2677 clauses: &[Clause {
2678 verdict: Conformance::Mandatory,
2679 when: Condition::Feature(1),
2680 }],
2681 },
2682 },
2683 Command {
2684 id: 0x04,
2685 name: "VideoStreamAllocateResponse",
2686 to_server: false,
2687 response: None,
2688 access: Access::invoke(Privilege::Operate),
2689 conform: Conform {
2690 clauses: &[Clause {
2691 verdict: Conformance::Mandatory,
2692 when: Condition::Feature(1),
2693 }],
2694 },
2695 },
2696 Command {
2697 id: 0x05,
2698 name: "VideoStreamModify",
2699 to_server: true,
2700 response: None,
2701 access: Access::invoke(Privilege::Manage),
2702 conform: Conform {
2703 clauses: &[Clause {
2704 verdict: Conformance::Mandatory,
2705 when: Condition::All(&[
2706 Condition::Feature(1),
2707 Condition::Any(&[Condition::Feature(6), Condition::Feature(7)]),
2708 ]),
2709 }],
2710 },
2711 },
2712 Command {
2713 id: 0x06,
2714 name: "VideoStreamDeallocate",
2715 to_server: true,
2716 response: None,
2717 access: Access::invoke(Privilege::Manage),
2718 conform: Conform {
2719 clauses: &[Clause {
2720 verdict: Conformance::Mandatory,
2721 when: Condition::Feature(1),
2722 }],
2723 },
2724 },
2725 Command {
2726 id: 0x07,
2727 name: "SnapshotStreamAllocate",
2728 to_server: true,
2729 response: Some(0x08),
2730 access: Access::invoke(Privilege::Manage),
2731 conform: Conform {
2732 clauses: &[Clause {
2733 verdict: Conformance::Mandatory,
2734 when: Condition::Feature(2),
2735 }],
2736 },
2737 },
2738 Command {
2739 id: 0x08,
2740 name: "SnapshotStreamAllocateResponse",
2741 to_server: false,
2742 response: None,
2743 access: Access::invoke(Privilege::Operate),
2744 conform: Conform {
2745 clauses: &[Clause {
2746 verdict: Conformance::Mandatory,
2747 when: Condition::Feature(2),
2748 }],
2749 },
2750 },
2751 Command {
2752 id: 0x09,
2753 name: "SnapshotStreamModify",
2754 to_server: true,
2755 response: None,
2756 access: Access::invoke(Privilege::Manage),
2757 conform: Conform {
2758 clauses: &[Clause {
2759 verdict: Conformance::Mandatory,
2760 when: Condition::All(&[
2761 Condition::Feature(2),
2762 Condition::Any(&[Condition::Feature(6), Condition::Feature(7)]),
2763 ]),
2764 }],
2765 },
2766 },
2767 Command {
2768 id: 0x0A,
2769 name: "SnapshotStreamDeallocate",
2770 to_server: true,
2771 response: None,
2772 access: Access::invoke(Privilege::Manage),
2773 conform: Conform {
2774 clauses: &[Clause {
2775 verdict: Conformance::Mandatory,
2776 when: Condition::Feature(2),
2777 }],
2778 },
2779 },
2780 Command {
2781 id: 0x0B,
2782 name: "SetStreamPriorities",
2783 to_server: true,
2784 response: None,
2785 access: Access::invoke(Privilege::Administer),
2786 conform: Conform::MANDATORY,
2787 },
2788 Command {
2789 id: 0x0C,
2790 name: "CaptureSnapshot",
2791 to_server: true,
2792 response: Some(0x0D),
2793 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::LARGE),
2794 conform: Conform {
2795 clauses: &[Clause {
2796 verdict: Conformance::Mandatory,
2797 when: Condition::Feature(2),
2798 }],
2799 },
2800 },
2801 Command {
2802 id: 0x0D,
2803 name: "CaptureSnapshotResponse",
2804 to_server: false,
2805 response: None,
2806 access: Access::invoke(Privilege::Operate).with_qualities(AccessQualities::LARGE),
2807 conform: Conform {
2808 clauses: &[Clause {
2809 verdict: Conformance::Mandatory,
2810 when: Condition::Feature(2),
2811 }],
2812 },
2813 },
2814];
2815
2816pub const EVENTS: &[Event] = &[];
2818
2819pub const CLUSTER: Cluster = Cluster {
2821 id: ID,
2822 name: "Camera AV Stream Management",
2823 revision: REVISION,
2824 pics: "AVSM",
2825 derived_from: None,
2826 features: FEATURES,
2827 attributes: ATTRIBUTES,
2828 commands: COMMANDS,
2829 events: EVENTS,
2830};