// Copyright 2020 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Events can happen in virtio video devices. use std::io; use data_model::Le32; use enumn::N; use crate::virtio::video::protocol::*; use crate::virtio::video::response::Response; use crate::virtio::Writer; #[allow(dead_code)] // TODO(keiichiw): Remove this attribute #[derive(Debug, Copy, Clone, N)] pub enum EvtType { Error = VIRTIO_VIDEO_EVENT_ERROR as isize, DecResChanged = VIRTIO_VIDEO_EVENT_DECODER_RESOLUTION_CHANGED as isize, } #[derive(Debug, Clone)] pub struct VideoEvt { pub typ: EvtType, pub stream_id: u32, } impl Response for VideoEvt { fn write(&self, w: &mut Writer) -> Result<(), io::Error> { w.write_obj(virtio_video_event { event_type: Le32::from(self.typ as u32), stream_id: Le32::from(self.stream_id), }) } }