1 // Copyright 2020 The Chromium OS Authors. All rights reserved. 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 DecResChanged = VIRTIO_VIDEO_EVENT_DECODER_RESOLUTION_CHANGED as isize, 20 } 21 22 #[derive(Debug, Clone)] 23 pub struct VideoEvt { 24 pub typ: EvtType, 25 pub stream_id: u32, 26 } 27 28 impl Response for VideoEvt { write(&self, w: &mut Writer) -> Result<(), io::Error>29 fn write(&self, w: &mut Writer) -> Result<(), io::Error> { 30 w.write_obj(virtio_video_event { 31 event_type: Le32::from(self.typ as u32), 32 stream_id: Le32::from(self.stream_id), 33 }) 34 } 35 } 36