1 // Copyright 2020 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 //! Errors that can happen while encoding or decoding. 6 7 use remain::sorted; 8 use thiserror::Error as ThisError; 9 10 use crate::virtio::video::control::CtrlType; 11 12 /// An error indicating something went wrong while encoding or decoding. 13 /// Unlike `virtio::video::Error`, `VideoError` is not fatal for `Worker`. 14 #[sorted] 15 #[derive(Debug, ThisError)] 16 pub enum VideoError { 17 /// Backend-specific error. 18 #[error("backend failure: {0:#}")] 19 BackendFailure(anyhow::Error), 20 /// Invalid argument. 21 #[error("invalid argument")] 22 InvalidArgument, 23 /// No suitable format is supported. 24 #[error("invalid format")] 25 InvalidFormat, 26 /// Invalid operation. 27 #[error("invalid operation")] 28 InvalidOperation, 29 /// Invalid parameters are specified. 30 #[error("invalid parameter")] 31 InvalidParameter, 32 /// Invalid resource ID is specified. 33 #[error("invalid resource ID {resource_id} for stream {stream_id}")] 34 InvalidResourceId { stream_id: u32, resource_id: u32 }, 35 /// Invalid stream ID is specified. 36 #[error("invalid stream ID {0}")] 37 InvalidStreamId(u32), 38 /// Unsupported control type is specified. 39 /// This is only used by the encoder for now, ignore warning if it is compiled out. 40 #[allow(dead_code)] 41 #[error("unsupported control: {0:?}")] 42 UnsupportedControl(CtrlType), 43 } 44 45 pub type VideoResult<T> = Result<T, VideoError>; 46