devices/virtio/video/decoder/
capability.rs1use std::collections::BTreeMap;
8
9use crate::virtio::video::control::*;
10use crate::virtio::video::format::*;
11
12#[derive(Clone)]
13pub struct Capability {
14 in_fmts: Vec<FormatDesc>,
15 out_fmts: Vec<FormatDesc>,
16
17 profiles: BTreeMap<Format, Vec<Profile>>,
19 levels: BTreeMap<Format, Vec<Level>>,
20}
21
22impl Capability {
23 pub(super) fn new(
25 in_fmts: Vec<FormatDesc>,
26 out_fmts: Vec<FormatDesc>,
27 profiles: BTreeMap<Format, Vec<Profile>>,
28 levels: BTreeMap<Format, Vec<Level>>,
29 ) -> Self {
30 Self {
31 in_fmts,
32 out_fmts,
33 profiles,
34 levels,
35 }
36 }
37
38 pub fn input_formats(&self) -> &Vec<FormatDesc> {
39 &self.in_fmts
40 }
41
42 pub fn output_formats(&self) -> &Vec<FormatDesc> {
43 &self.out_fmts
44 }
45
46 pub fn query_control(&self, t: &QueryCtrlType) -> Option<QueryCtrlResponse> {
47 use QueryCtrlType::*;
48 match *t {
49 Profile(fmt) => {
50 let profiles = self.profiles.get(&fmt)?;
51 Some(QueryCtrlResponse::Profile(profiles.to_vec()))
52 }
53 Level(fmt) => {
54 let levels = self.levels.get(&fmt)?;
55 Some(QueryCtrlResponse::Level(levels.to_vec()))
56 }
57 }
58 }
59}