/* Class to manage the streaming system device * * \copyright * Copyright 2017 Red Hat Inc. All rights reserved. */ #ifndef SPICE_STREAMING_AGENT_SPICE_STREAM_HPP #define SPICE_STREAMING_AGENT_SPICE_STREAM_HPP #include #include #include #include #include "file-util.h" namespace SpiceStreamingAgent { class SpiceStream { public: SpiceStream(const char *name): streamfd(open(name, O_RDWR)) { if (streamfd < 0) throw std::runtime_error("failed to open streaming device"); } ~SpiceStream() { close(streamfd); } public: /*! * Return file descriptor to poll from */ int eventFd() const { return streamfd; } int read_command(int &streaming_requested); int send_format(unsigned w, unsigned h, unsigned c); int send_frame(const void *buf, const unsigned size); void send_cursor(unsigned width, unsigned height, int hotspot_x, int hotspot_y, std::function fill_cursor); private: size_t write_all(const void *buf, const size_t len) { return ::write_all(streamfd, buf, len); } SpiceStream(const SpiceStream &) = delete; SpiceStream &operator=(const SpiceStream &) = delete; private: std::mutex stream_mtx; int streamfd; }; } #endif