Path: blob/main/devices/src/virtio/video/decoder/capability.rs
5394 views
// Copyright 2020 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34//! Capablities of the virtio video decoder device.56use std::collections::BTreeMap;78use crate::virtio::video::control::*;9use crate::virtio::video::format::*;1011#[derive(Clone)]12pub struct Capability {13in_fmts: Vec<FormatDesc>,14out_fmts: Vec<FormatDesc>,1516// Stores supporterd profiles and levels for each format.17profiles: BTreeMap<Format, Vec<Profile>>,18levels: BTreeMap<Format, Vec<Level>>,19}2021impl Capability {22// Make this method pub(super) so backends can create capabilities.23pub(super) fn new(24in_fmts: Vec<FormatDesc>,25out_fmts: Vec<FormatDesc>,26profiles: BTreeMap<Format, Vec<Profile>>,27levels: BTreeMap<Format, Vec<Level>>,28) -> Self {29Self {30in_fmts,31out_fmts,32profiles,33levels,34}35}3637pub fn input_formats(&self) -> &Vec<FormatDesc> {38&self.in_fmts39}4041pub fn output_formats(&self) -> &Vec<FormatDesc> {42&self.out_fmts43}4445pub fn query_control(&self, t: &QueryCtrlType) -> Option<QueryCtrlResponse> {46use QueryCtrlType::*;47match *t {48Profile(fmt) => {49let profiles = self.profiles.get(&fmt)?;50Some(QueryCtrlResponse::Profile(profiles.to_vec()))51}52Level(fmt) => {53let levels = self.levels.get(&fmt)?;54Some(QueryCtrlResponse::Level(levels.to_vec()))55}56}57}58}596061