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 = 0x050A;
28
29pub const REVISION: u16 = 2;
32
33pub const PICS: &str = "CONTENTLAUNCHER";
35
36pub mod feature {
41 pub const CONTENT_SEARCH: u32 = 1 << 0;
45 pub const URL_PLAYBACK: u32 = 1 << 1;
49 pub const ADVANCED_SEEK: u32 = 1 << 2;
53 pub const TEXT_TRACKS: u32 = 1 << 3;
57 pub const AUDIO_TRACKS: u32 = 1 << 4;
61}
62
63pub const FEATURES: &[Feature] = &[
65 Feature {
66 bit: 0,
67 code: "CS",
68 name: "ContentSearch",
69 conform: Conform::OPTIONAL,
70 },
71 Feature {
72 bit: 1,
73 code: "UP",
74 name: "URLPlayback",
75 conform: Conform::OPTIONAL,
76 },
77 Feature {
78 bit: 2,
79 code: "AS",
80 name: "AdvancedSeek",
81 conform: Conform::OPTIONAL,
82 },
83 Feature {
84 bit: 3,
85 code: "TT",
86 name: "TextTracks",
87 conform: Conform::OPTIONAL,
88 },
89 Feature {
90 bit: 4,
91 code: "AT",
92 name: "AudioTracks",
93 conform: Conform::OPTIONAL,
94 },
95];
96
97pub mod attribute {
99 use crate::im::AttributeId;
100
101 pub const ACCEPT_HEADER: AttributeId = 0x00;
103 pub const SUPPORTED_STREAMING_PROTOCOLS: AttributeId = 0x01;
105}
106
107pub mod command {
109 use crate::im::CommandId;
110
111 pub const LAUNCH_CONTENT: CommandId = 0x00;
113 pub const LAUNCH_URL: CommandId = 0x01;
115 pub const LAUNCHER_RESPONSE: CommandId = 0x02;
117}
118
119#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
121#[repr(u8)]
122pub enum MetricTypeEnum {
123 Pixels = 0,
125 Percentage = 1,
127}
128
129impl MetricTypeEnum {
130 #[must_use]
132 pub const fn from_value(value: u8) -> Option<Self> {
133 match value {
134 0 => Some(Self::Pixels),
135 1 => Some(Self::Percentage),
136 _ => None,
137 }
138 }
139
140 #[must_use]
142 pub const fn value(self) -> u8 {
143 self as u8
144 }
145}
146
147impl ToTlv for MetricTypeEnum {
148 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
149 self.value().to_tlv(w, tag)
150 }
151}
152
153impl<'a> FromTlv<'a> for MetricTypeEnum {
154 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
155 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
156 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
157 }
158}
159
160#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
162#[repr(u8)]
163pub enum ParameterEnum {
164 Actor = 0,
166 Channel = 1,
168 Character = 2,
170 Director = 3,
172 Event = 4,
174 Franchise = 5,
176 Genre = 6,
178 League = 7,
180 Popularity = 8,
182 Provider = 9,
184 Sport = 10,
186 SportsTeam = 11,
188 Type = 12,
190 Video = 13,
192 Season = 14,
194 Episode = 15,
196 Any = 16,
198}
199
200impl ParameterEnum {
201 #[must_use]
203 pub const fn from_value(value: u8) -> Option<Self> {
204 match value {
205 0 => Some(Self::Actor),
206 1 => Some(Self::Channel),
207 2 => Some(Self::Character),
208 3 => Some(Self::Director),
209 4 => Some(Self::Event),
210 5 => Some(Self::Franchise),
211 6 => Some(Self::Genre),
212 7 => Some(Self::League),
213 8 => Some(Self::Popularity),
214 9 => Some(Self::Provider),
215 10 => Some(Self::Sport),
216 11 => Some(Self::SportsTeam),
217 12 => Some(Self::Type),
218 13 => Some(Self::Video),
219 14 => Some(Self::Season),
220 15 => Some(Self::Episode),
221 16 => Some(Self::Any),
222 _ => None,
223 }
224 }
225
226 #[must_use]
228 pub const fn value(self) -> u8 {
229 self as u8
230 }
231}
232
233impl ToTlv for ParameterEnum {
234 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
235 self.value().to_tlv(w, tag)
236 }
237}
238
239impl<'a> FromTlv<'a> for ParameterEnum {
240 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
241 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
242 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
243 }
244}
245
246#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
248#[repr(u8)]
249pub enum StatusEnum {
250 Success = 0,
252 URLNotAvailable = 1,
254 AuthFailed = 2,
256 TextTrackNotAvailable = 3,
258 AudioTrackNotAvailable = 4,
260}
261
262impl StatusEnum {
263 #[must_use]
265 pub const fn from_value(value: u8) -> Option<Self> {
266 match value {
267 0 => Some(Self::Success),
268 1 => Some(Self::URLNotAvailable),
269 2 => Some(Self::AuthFailed),
270 3 => Some(Self::TextTrackNotAvailable),
271 4 => Some(Self::AudioTrackNotAvailable),
272 _ => None,
273 }
274 }
275
276 #[must_use]
278 pub const fn value(self) -> u8 {
279 self as u8
280 }
281}
282
283impl ToTlv for StatusEnum {
284 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
285 self.value().to_tlv(w, tag)
286 }
287}
288
289impl<'a> FromTlv<'a> for StatusEnum {
290 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
291 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
292 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
293 }
294}
295
296bitflags::bitflags! {
297 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
299 pub struct SupportedProtocolsBitmap: u8 {
300 const DASH = 1 << 0;
302 const HLS = 1 << 1;
304 }
305}
306
307impl ToTlv for SupportedProtocolsBitmap {
308 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
309 self.bits().to_tlv(w, tag)
310 }
311}
312
313impl<'a> FromTlv<'a> for SupportedProtocolsBitmap {
314 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
315 let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
316 Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
317 }
318}
319
320#[derive(Debug, Clone, Copy, PartialEq)]
322pub struct AdditionalInfoStruct<'a> {
323 pub name: &'a str,
325 pub value: &'a str,
327}
328
329impl<'a> ToTlv for AdditionalInfoStruct<'a> {
330 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
331 w.start_structure(tag)?;
332 self.name.to_tlv(w, Tag::Context(0))?;
333 self.value.to_tlv(w, Tag::Context(1))?;
334 w.end_container()
335 }
336}
337
338impl<'a> FromTlv<'a> for AdditionalInfoStruct<'a> {
339 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
340 if element.value.container() != Some(ContainerKind::Structure) {
341 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
342 }
343 let mut name = None;
344 let mut value = None;
345 loop {
346 let Some(field) = reader.next_element()? else {
347 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
348 };
349 if field.value == Value::EndOfContainer {
350 break;
351 }
352 match field.tag.context() {
353 Some(0) => name = Some(<&'a str>::from_tlv(reader, &field)?),
354 Some(1) => value = Some(<&'a str>::from_tlv(reader, &field)?),
355 _ => reader.skip_value(&field)?,
359 }
360 }
361 Ok(Self {
362 name: name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
363 value: value.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
364 })
365 }
366}
367
368#[derive(Debug, Clone, Copy, PartialEq)]
370pub struct BrandingInformationStruct<'a> {
371 pub provider_name: &'a str,
373 pub background: Option<StyleInformationStruct<'a>>,
375 pub logo: Option<StyleInformationStruct<'a>>,
377 pub progress_bar: Option<StyleInformationStruct<'a>>,
379 pub splash: Option<StyleInformationStruct<'a>>,
381 pub water_mark: Option<StyleInformationStruct<'a>>,
383}
384
385impl<'a> ToTlv for BrandingInformationStruct<'a> {
386 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
387 w.start_structure(tag)?;
388 self.provider_name.to_tlv(w, Tag::Context(0))?;
389 if let Some(value) = &self.background {
390 value.to_tlv(w, Tag::Context(1))?;
391 }
392 if let Some(value) = &self.logo {
393 value.to_tlv(w, Tag::Context(2))?;
394 }
395 if let Some(value) = &self.progress_bar {
396 value.to_tlv(w, Tag::Context(3))?;
397 }
398 if let Some(value) = &self.splash {
399 value.to_tlv(w, Tag::Context(4))?;
400 }
401 if let Some(value) = &self.water_mark {
402 value.to_tlv(w, Tag::Context(5))?;
403 }
404 w.end_container()
405 }
406}
407
408impl<'a> FromTlv<'a> for BrandingInformationStruct<'a> {
409 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
410 if element.value.container() != Some(ContainerKind::Structure) {
411 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
412 }
413 let mut provider_name = None;
414 let mut background = None;
415 let mut logo = None;
416 let mut progress_bar = None;
417 let mut splash = None;
418 let mut water_mark = None;
419 loop {
420 let Some(field) = reader.next_element()? else {
421 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
422 };
423 if field.value == Value::EndOfContainer {
424 break;
425 }
426 match field.tag.context() {
427 Some(0) => provider_name = Some(<&'a str>::from_tlv(reader, &field)?),
428 Some(1) => {
429 background = Some(<StyleInformationStruct<'a>>::from_tlv(reader, &field)?)
430 }
431 Some(2) => logo = Some(<StyleInformationStruct<'a>>::from_tlv(reader, &field)?),
432 Some(3) => {
433 progress_bar = Some(<StyleInformationStruct<'a>>::from_tlv(reader, &field)?)
434 }
435 Some(4) => splash = Some(<StyleInformationStruct<'a>>::from_tlv(reader, &field)?),
436 Some(5) => {
437 water_mark = Some(<StyleInformationStruct<'a>>::from_tlv(reader, &field)?)
438 }
439 _ => reader.skip_value(&field)?,
443 }
444 }
445 Ok(Self {
446 provider_name: provider_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
447 background,
448 logo,
449 progress_bar,
450 splash,
451 water_mark,
452 })
453 }
454}
455
456#[derive(Debug, Clone, Copy, PartialEq)]
458pub struct ContentSearchStruct<'a> {
459 pub parameter_list: TlvList<'a, ParameterStruct<'a>>,
461}
462
463impl<'a> ToTlv for ContentSearchStruct<'a> {
464 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
465 w.start_structure(tag)?;
466 self.parameter_list.to_tlv(w, Tag::Context(0))?;
467 w.end_container()
468 }
469}
470
471impl<'a> FromTlv<'a> for ContentSearchStruct<'a> {
472 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
473 if element.value.container() != Some(ContainerKind::Structure) {
474 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
475 }
476 let mut parameter_list = None;
477 loop {
478 let Some(field) = reader.next_element()? else {
479 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
480 };
481 if field.value == Value::EndOfContainer {
482 break;
483 }
484 match field.tag.context() {
485 Some(0) => {
486 parameter_list = Some(<TlvList<'a, ParameterStruct<'a>>>::from_tlv(
487 reader, &field,
488 )?)
489 }
490 _ => reader.skip_value(&field)?,
494 }
495 }
496 Ok(Self {
497 parameter_list: parameter_list
498 .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
499 })
500 }
501}
502
503#[derive(Debug, Clone, Copy, PartialEq)]
505pub struct DimensionStruct {
506 pub width: f64,
508 pub height: f64,
510 pub metric: MetricTypeEnum,
512}
513
514impl ToTlv for DimensionStruct {
515 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
516 w.start_structure(tag)?;
517 self.width.to_tlv(w, Tag::Context(0))?;
518 self.height.to_tlv(w, Tag::Context(1))?;
519 self.metric.to_tlv(w, Tag::Context(2))?;
520 w.end_container()
521 }
522}
523
524impl<'a> FromTlv<'a> for DimensionStruct {
525 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
526 if element.value.container() != Some(ContainerKind::Structure) {
527 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
528 }
529 let mut width = None;
530 let mut height = None;
531 let mut metric = None;
532 loop {
533 let Some(field) = reader.next_element()? else {
534 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
535 };
536 if field.value == Value::EndOfContainer {
537 break;
538 }
539 match field.tag.context() {
540 Some(0) => width = Some(<f64>::from_tlv(reader, &field)?),
541 Some(1) => height = Some(<f64>::from_tlv(reader, &field)?),
542 Some(2) => metric = Some(<MetricTypeEnum>::from_tlv(reader, &field)?),
543 _ => reader.skip_value(&field)?,
547 }
548 }
549 Ok(Self {
550 width: width.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
551 height: height.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
552 metric: metric.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
553 })
554 }
555}
556
557#[derive(Debug, Clone, Copy, PartialEq)]
559pub struct ParameterStruct<'a> {
560 pub type_: ParameterEnum,
562 pub value: &'a str,
564 pub external_id_list: Option<TlvList<'a, AdditionalInfoStruct<'a>>>,
566}
567
568impl<'a> ToTlv for ParameterStruct<'a> {
569 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
570 w.start_structure(tag)?;
571 self.type_.to_tlv(w, Tag::Context(0))?;
572 self.value.to_tlv(w, Tag::Context(1))?;
573 if let Some(value) = &self.external_id_list {
574 value.to_tlv(w, Tag::Context(2))?;
575 }
576 w.end_container()
577 }
578}
579
580impl<'a> FromTlv<'a> for ParameterStruct<'a> {
581 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
582 if element.value.container() != Some(ContainerKind::Structure) {
583 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
584 }
585 let mut type_ = None;
586 let mut value = None;
587 let mut external_id_list = None;
588 loop {
589 let Some(field) = reader.next_element()? else {
590 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
591 };
592 if field.value == Value::EndOfContainer {
593 break;
594 }
595 match field.tag.context() {
596 Some(0) => type_ = Some(<ParameterEnum>::from_tlv(reader, &field)?),
597 Some(1) => value = Some(<&'a str>::from_tlv(reader, &field)?),
598 Some(2) => {
599 external_id_list = Some(<TlvList<'a, AdditionalInfoStruct<'a>>>::from_tlv(
600 reader, &field,
601 )?)
602 }
603 _ => reader.skip_value(&field)?,
607 }
608 }
609 Ok(Self {
610 type_: type_.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
611 value: value.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
612 external_id_list,
613 })
614 }
615}
616
617#[derive(Debug, Clone, Copy, PartialEq)]
619pub struct PlaybackPreferencesStruct<'a> {
620 pub playback_position: Option<Nullable<u64>>,
622 pub text_track: Option<Nullable<TrackPreferenceStruct<'a>>>,
624 pub audio_tracks: Option<Nullable<TlvList<'a, TrackPreferenceStruct<'a>>>>,
626}
627
628impl<'a> ToTlv for PlaybackPreferencesStruct<'a> {
629 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
630 w.start_structure(tag)?;
631 if let Some(value) = &self.playback_position {
632 value.to_tlv(w, Tag::Context(0))?;
633 }
634 if let Some(value) = &self.text_track {
635 value.to_tlv(w, Tag::Context(1))?;
636 }
637 if let Some(value) = &self.audio_tracks {
638 value.to_tlv(w, Tag::Context(2))?;
639 }
640 w.end_container()
641 }
642}
643
644impl<'a> FromTlv<'a> for PlaybackPreferencesStruct<'a> {
645 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
646 if element.value.container() != Some(ContainerKind::Structure) {
647 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
648 }
649 let mut playback_position = None;
650 let mut text_track = None;
651 let mut audio_tracks = None;
652 loop {
653 let Some(field) = reader.next_element()? else {
654 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
655 };
656 if field.value == Value::EndOfContainer {
657 break;
658 }
659 match field.tag.context() {
660 Some(0) => playback_position = Some(<Nullable<u64>>::from_tlv(reader, &field)?),
661 Some(1) => {
662 text_track = Some(<Nullable<TrackPreferenceStruct<'a>>>::from_tlv(
663 reader, &field,
664 )?)
665 }
666 Some(2) => {
667 audio_tracks = Some(
668 <Nullable<TlvList<'a, TrackPreferenceStruct<'a>>>>::from_tlv(
669 reader, &field,
670 )?,
671 )
672 }
673 _ => reader.skip_value(&field)?,
677 }
678 }
679 Ok(Self {
680 playback_position,
681 text_track,
682 audio_tracks,
683 })
684 }
685}
686
687#[derive(Debug, Clone, Copy, PartialEq)]
689pub struct StyleInformationStruct<'a> {
690 pub image_url: Option<&'a str>,
692 pub color: Option<&'a str>,
694 pub size: Option<DimensionStruct>,
696}
697
698impl<'a> ToTlv for StyleInformationStruct<'a> {
699 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
700 w.start_structure(tag)?;
701 if let Some(value) = &self.image_url {
702 value.to_tlv(w, Tag::Context(0))?;
703 }
704 if let Some(value) = &self.color {
705 value.to_tlv(w, Tag::Context(1))?;
706 }
707 if let Some(value) = &self.size {
708 value.to_tlv(w, Tag::Context(2))?;
709 }
710 w.end_container()
711 }
712}
713
714impl<'a> FromTlv<'a> for StyleInformationStruct<'a> {
715 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
716 if element.value.container() != Some(ContainerKind::Structure) {
717 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
718 }
719 let mut image_url = None;
720 let mut color = None;
721 let mut size = None;
722 loop {
723 let Some(field) = reader.next_element()? else {
724 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
725 };
726 if field.value == Value::EndOfContainer {
727 break;
728 }
729 match field.tag.context() {
730 Some(0) => image_url = Some(<&'a str>::from_tlv(reader, &field)?),
731 Some(1) => color = Some(<&'a str>::from_tlv(reader, &field)?),
732 Some(2) => size = Some(<DimensionStruct>::from_tlv(reader, &field)?),
733 _ => reader.skip_value(&field)?,
737 }
738 }
739 Ok(Self {
740 image_url,
741 color,
742 size,
743 })
744 }
745}
746
747#[derive(Debug, Clone, Copy, PartialEq)]
749pub struct TrackPreferenceStruct<'a> {
750 pub language_code: &'a str,
752 pub characteristics: Option<
754 Nullable<TlvList<'a, crate::clusters::generated::media_playback::CharacteristicEnum>>,
755 >,
756 pub audio_output_index: Option<Nullable<u8>>,
758}
759
760impl<'a> ToTlv for TrackPreferenceStruct<'a> {
761 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
762 w.start_structure(tag)?;
763 self.language_code.to_tlv(w, Tag::Context(0))?;
764 if let Some(value) = &self.characteristics {
765 value.to_tlv(w, Tag::Context(1))?;
766 }
767 if let Some(value) = &self.audio_output_index {
768 value.to_tlv(w, Tag::Context(2))?;
769 }
770 w.end_container()
771 }
772}
773
774impl<'a> FromTlv<'a> for TrackPreferenceStruct<'a> {
775 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
776 if element.value.container() != Some(ContainerKind::Structure) {
777 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
778 }
779 let mut language_code = None;
780 let mut characteristics = None;
781 let mut audio_output_index = None;
782 loop {
783 let Some(field) = reader.next_element()? else {
784 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
785 };
786 if field.value == Value::EndOfContainer {
787 break;
788 }
789 match field.tag.context() {
790 Some(0) => language_code = Some(<&'a str>::from_tlv(reader, &field)?),
791 Some(1) => {
792 characteristics = Some(<Nullable<
793 TlvList<'a, crate::clusters::generated::media_playback::CharacteristicEnum>,
794 >>::from_tlv(reader, &field)?)
795 }
796 Some(2) => audio_output_index = Some(<Nullable<u8>>::from_tlv(reader, &field)?),
797 _ => reader.skip_value(&field)?,
801 }
802 }
803 Ok(Self {
804 language_code: language_code.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
805 characteristics,
806 audio_output_index,
807 })
808 }
809}
810
811#[derive(Debug, Clone, Copy, PartialEq)]
813pub struct LaunchContentFields<'a> {
814 pub search: ContentSearchStruct<'a>,
816 pub auto_play: bool,
818 pub data: Option<&'a str>,
820 pub playback_preferences: Option<PlaybackPreferencesStruct<'a>>,
822 pub use_current_context: Option<bool>,
824}
825
826impl<'a> ToTlv for LaunchContentFields<'a> {
827 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
828 w.start_structure(tag)?;
829 self.search.to_tlv(w, Tag::Context(0))?;
830 self.auto_play.to_tlv(w, Tag::Context(1))?;
831 if let Some(value) = &self.data {
832 value.to_tlv(w, Tag::Context(2))?;
833 }
834 if let Some(value) = &self.playback_preferences {
835 value.to_tlv(w, Tag::Context(3))?;
836 }
837 if let Some(value) = &self.use_current_context {
838 value.to_tlv(w, Tag::Context(4))?;
839 }
840 w.end_container()
841 }
842}
843
844impl<'a> FromTlv<'a> for LaunchContentFields<'a> {
845 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
846 if element.value.container() != Some(ContainerKind::Structure) {
847 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
848 }
849 let mut search = None;
850 let mut auto_play = None;
851 let mut data = None;
852 let mut playback_preferences = None;
853 let mut use_current_context = None;
854 loop {
855 let Some(field) = reader.next_element()? else {
856 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
857 };
858 if field.value == Value::EndOfContainer {
859 break;
860 }
861 match field.tag.context() {
862 Some(0) => search = Some(<ContentSearchStruct<'a>>::from_tlv(reader, &field)?),
863 Some(1) => auto_play = Some(<bool>::from_tlv(reader, &field)?),
864 Some(2) => data = Some(<&'a str>::from_tlv(reader, &field)?),
865 Some(3) => {
866 playback_preferences =
867 Some(<PlaybackPreferencesStruct<'a>>::from_tlv(reader, &field)?)
868 }
869 Some(4) => use_current_context = Some(<bool>::from_tlv(reader, &field)?),
870 _ => reader.skip_value(&field)?,
874 }
875 }
876 Ok(Self {
877 search: search.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
878 auto_play: auto_play.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
879 data,
880 playback_preferences,
881 use_current_context,
882 })
883 }
884}
885
886#[derive(Debug, Clone, Copy, PartialEq)]
888pub struct LaunchURLFields<'a> {
889 pub content_url: &'a str,
891 pub display_string: Option<&'a str>,
893 pub branding_information: Option<BrandingInformationStruct<'a>>,
895 pub playback_preferences: Option<PlaybackPreferencesStruct<'a>>,
897}
898
899impl<'a> ToTlv for LaunchURLFields<'a> {
900 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
901 w.start_structure(tag)?;
902 self.content_url.to_tlv(w, Tag::Context(0))?;
903 if let Some(value) = &self.display_string {
904 value.to_tlv(w, Tag::Context(1))?;
905 }
906 if let Some(value) = &self.branding_information {
907 value.to_tlv(w, Tag::Context(2))?;
908 }
909 if let Some(value) = &self.playback_preferences {
910 value.to_tlv(w, Tag::Context(3))?;
911 }
912 w.end_container()
913 }
914}
915
916impl<'a> FromTlv<'a> for LaunchURLFields<'a> {
917 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
918 if element.value.container() != Some(ContainerKind::Structure) {
919 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
920 }
921 let mut content_url = None;
922 let mut display_string = None;
923 let mut branding_information = None;
924 let mut playback_preferences = None;
925 loop {
926 let Some(field) = reader.next_element()? else {
927 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
928 };
929 if field.value == Value::EndOfContainer {
930 break;
931 }
932 match field.tag.context() {
933 Some(0) => content_url = Some(<&'a str>::from_tlv(reader, &field)?),
934 Some(1) => display_string = Some(<&'a str>::from_tlv(reader, &field)?),
935 Some(2) => {
936 branding_information =
937 Some(<BrandingInformationStruct<'a>>::from_tlv(reader, &field)?)
938 }
939 Some(3) => {
940 playback_preferences =
941 Some(<PlaybackPreferencesStruct<'a>>::from_tlv(reader, &field)?)
942 }
943 _ => reader.skip_value(&field)?,
947 }
948 }
949 Ok(Self {
950 content_url: content_url.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
951 display_string,
952 branding_information,
953 playback_preferences,
954 })
955 }
956}
957
958#[derive(Debug, Clone, Copy, PartialEq)]
960pub struct LauncherResponseFields<'a> {
961 pub status: StatusEnum,
963 pub data: Option<&'a str>,
965}
966
967impl<'a> ToTlv for LauncherResponseFields<'a> {
968 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
969 w.start_structure(tag)?;
970 self.status.to_tlv(w, Tag::Context(0))?;
971 if let Some(value) = &self.data {
972 value.to_tlv(w, Tag::Context(1))?;
973 }
974 w.end_container()
975 }
976}
977
978impl<'a> FromTlv<'a> for LauncherResponseFields<'a> {
979 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
980 if element.value.container() != Some(ContainerKind::Structure) {
981 return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
982 }
983 let mut status = None;
984 let mut data = None;
985 loop {
986 let Some(field) = reader.next_element()? else {
987 return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
988 };
989 if field.value == Value::EndOfContainer {
990 break;
991 }
992 match field.tag.context() {
993 Some(0) => status = Some(<StatusEnum>::from_tlv(reader, &field)?),
994 Some(1) => data = Some(<&'a str>::from_tlv(reader, &field)?),
995 _ => reader.skip_value(&field)?,
999 }
1000 }
1001 Ok(Self {
1002 status: status.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1003 data,
1004 })
1005 }
1006}
1007
1008pub const ATTRIBUTES: &[Attribute] = &[
1010 Attribute {
1011 id: 0x0000,
1012 name: "AcceptHeader",
1013 kind: "list[string]",
1014 access: Access::read_only(Privilege::View),
1015 qualities: AttributeQualities::NON_VOLATILE,
1016 reporting: Reporting::OnChange,
1017 conform: Conform {
1018 clauses: &[Clause {
1019 verdict: Conformance::Mandatory,
1020 when: Condition::Feature(1),
1021 }],
1022 },
1023 },
1024 Attribute {
1025 id: 0x0001,
1026 name: "SupportedStreamingProtocols",
1027 kind: "SupportedProtocolsBitmap",
1028 access: Access::read_only(Privilege::View),
1029 qualities: AttributeQualities::NON_VOLATILE,
1030 reporting: Reporting::OnChange,
1031 conform: Conform {
1032 clauses: &[Clause {
1033 verdict: Conformance::Mandatory,
1034 when: Condition::Feature(1),
1035 }],
1036 },
1037 },
1038];
1039
1040pub const COMMANDS: &[Command] = &[
1042 Command {
1043 id: 0x00,
1044 name: "LaunchContent",
1045 to_server: true,
1046 response: Some(0x02),
1047 access: Access::invoke(Privilege::Operate),
1048 conform: Conform {
1049 clauses: &[Clause {
1050 verdict: Conformance::Mandatory,
1051 when: Condition::Feature(0),
1052 }],
1053 },
1054 },
1055 Command {
1056 id: 0x01,
1057 name: "LaunchURL",
1058 to_server: true,
1059 response: Some(0x02),
1060 access: Access::invoke(Privilege::Operate),
1061 conform: Conform {
1062 clauses: &[Clause {
1063 verdict: Conformance::Mandatory,
1064 when: Condition::Feature(1),
1065 }],
1066 },
1067 },
1068 Command {
1069 id: 0x02,
1070 name: "LauncherResponse",
1071 to_server: false,
1072 response: None,
1073 access: Access::invoke(Privilege::Operate),
1074 conform: Conform {
1075 clauses: &[Clause {
1076 verdict: Conformance::Mandatory,
1077 when: Condition::Any(&[Condition::Feature(0), Condition::Feature(1)]),
1078 }],
1079 },
1080 },
1081];
1082
1083pub const EVENTS: &[Event] = &[];
1085
1086pub const CLUSTER: Cluster = Cluster {
1088 id: ID,
1089 name: "Content Launcher",
1090 revision: REVISION,
1091 pics: "CONTENTLAUNCHER",
1092 derived_from: None,
1093 features: FEATURES,
1094 attributes: ATTRIBUTES,
1095 commands: COMMANDS,
1096 events: EVENTS,
1097};