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 //! Events can happen in virtio video devices. 6 7 use std::io; 8 9 use data_model::Le32; 10 use enumn::N; 11 12 use crate::virtio::video::protocol::*; 13 use crate::virtio::video::response::Response; 14 use crate::virtio::Writer; 15 16 #[derive(Debug, Copy, Clone, N)] 17 pub enum EvtType { 18 Error = VIRTIO_VIDEO_EVENT_ERROR as isize, 19 #[cfg(feature = "video-decoder")] 20 DecResChanged = VIRTIO_VIDEO_EVENT_DECODER_RESOLUTION_CHANGED as isize, 21 } 22 23 #[derive(Debug, Clone)] 24 pub struct VideoEvt { 25 pub typ: EvtType, 26 pub stream_id: u32, 27 } 28 29 impl Response for VideoEvt { write(&self, w: &mut Writer) -> Result<(), io::Error>30 fn write(&self, w: &mut Writer) -> Result<(), io::Error> { 31 w.write_obj(virtio_video_event { 32 event_type: Le32::from(self.typ as u32), 33 stream_id: Le32::from(self.stream_id), 34 }) 35 } 36 } 37