Re: [PATCH v2 24/24] Rename 'Stream' to 'IOChannel'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 22 Feb 2018, at 09:29, Frediano Ziglio <fziglio@xxxxxxxxxx> wrote:
> 
>> 
>> From: Christophe de Dinechin <dinechin@xxxxxxxxxx>
>> 
>> Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
>> ---
>> src/concrete-agent.hpp        |  4 +--
>> src/spice-streaming-agent.cpp | 64
>> +++++++++++++++++++++----------------------
>> 2 files changed, 34 insertions(+), 34 deletions(-)
>> 
>> diff --git a/src/concrete-agent.hpp b/src/concrete-agent.hpp
>> index 346ba6c..418ccd9 100644
>> --- a/src/concrete-agent.hpp
>> +++ b/src/concrete-agent.hpp
>> @@ -14,7 +14,7 @@
>> namespace spice {
>> namespace streaming_agent {
>> 
>> -class Stream;
>> +class IOChannel;
>> class FrameLog;
>> 
>> struct ConcreteConfigureOption: ConfigureOption
>> @@ -36,7 +36,7 @@ public:
>>     void Register(Plugin& plugin) override;
>>     const ConfigureOption* Options() const override;
>>     void LoadPlugins(const std::string &directory);
>> -    void CaptureLoop(Stream &stream, FrameLog &frame_log);
>> +    void CaptureLoop(IOChannel &channel, FrameLog &frame_log);
>>     // pointer must remain valid
>>     void AddOption(const char *name, const char *value);
>>     FrameCapture *GetBestFrameCapture(const std::set<SpiceVideoCodecType>&
>>     codecs);
>> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
>> index b889acc..f6a0bf6 100644
>> --- a/src/spice-streaming-agent.cpp
>> +++ b/src/spice-streaming-agent.cpp
>> @@ -66,7 +66,7 @@ public:
>>     virtual std::string message() { return what(); }
>> };
>> 
>> -class Stream
>> +class IOChannel
>> {
>>     typedef std::set<SpiceVideoCodecType> codecs_t;
>> 
>> @@ -86,7 +86,7 @@ public:
>>     };
>> 
>> public:
>> -    Stream(const char *name)
>> +    IOChannel(const char *name)
>>         : codecs()
>>     {
>>         streamfd = open(name, O_RDWR);
>> @@ -94,7 +94,7 @@ public:
>>             throw std::runtime_error("failed to open streaming device");
>>         }
>>     }
>> -    ~Stream()
>> +    ~IOChannel()
>>     {
>>         close(streamfd);
>>     }
>> @@ -159,9 +159,9 @@ struct FormatMessage : Message<StreamMsgFormat,
>> FormatMessage>
>>     {
>>         return StreamMsgFormat{ .width = w, .height = h, .codec = c,
>>         .padding1 = {} };
>>     }
>> -    void write(Stream &stream, unsigned w, unsigned h, uint8_t c)
>> +    void write(IOChannel &channel, unsigned w, unsigned h, uint8_t c)
>>     {
>> -        stream.write_all("FormatMessage", this, sizeof(message_t));
>> +        channel.write_all("FormatMessage", this, sizeof(message_t));
>>     }
>> };
>> 
>> @@ -178,10 +178,10 @@ struct FrameMessage : Message<StreamMsgData,
>> FrameMessage>
>>     {
>>         return StreamMsgData();
>>     }
>> -    void write(Stream &stream, const void *frame, size_t length)
>> +    void write(IOChannel &channel, const void *frame, size_t length)
>>     {
>> -        stream.write_all("FrameMessage header", this, sizeof(message_t));
>> -        stream.write_all("FrameMessage frame", frame, length);
>> +        channel.write_all("FrameMessage header", this, sizeof(message_t));
>> +        channel.write_all("FrameMessage frame", frame, length);
>>     }
>> };
>> 
>> @@ -216,11 +216,11 @@ struct X11CursorMessage : Message<StreamMsgCursorSet,
>> X11CursorMessage>
>>             .data = { }
>>         };
>>     }
>> -    void write(Stream &stream, XFixesCursorImage *cursor)
>> +    void write(IOChannel &channel, XFixesCursorImage *cursor)
>>     {
>>         unsigned pixel_size = pixel_count(cursor) * sizeof(uint32_t);
>> -        stream.write_all("X11CursorMessage header", this,
>> sizeof(message_t));
>> -        stream.write_all("X11CursorMessage pixels", pixels.get(),
>> pixel_size);
>> +        channel.write_all("X11CursorMessage header", this,
>> sizeof(message_t));
>> +        channel.write_all("X11CursorMessage pixels", pixels.get(),
>> pixel_size);
>>     }
>>     void fill_pixels(XFixesCursorImage *cursor)
>>     {
>> @@ -279,21 +279,21 @@ void FrameLog::dump(const void *buffer, size_t length)
>> class X11CursorThread
>> {
>> public:
>> -    X11CursorThread(Stream &stream);
>> +    X11CursorThread(IOChannel &channel);
>>     ~X11CursorThread();
>> 
>>     static void record_cursor_changes(X11CursorThread *self) {
>>     self->cursor_changes(); }
>>     void cursor_changes();
>> 
>> private:
>> -    Stream &stream;
>> +    IOChannel &channel;
>>     Display *display;
>>     std::thread thread;
>> };
>> 
>> 
>> -X11CursorThread::X11CursorThread(Stream &stream)
>> -    : stream(stream),
>> +X11CursorThread::X11CursorThread(IOChannel &channel)
>> +    : channel(channel),
>>       display(XOpenDisplay(NULL)),
>>       thread(record_cursor_changes, this)
>> {
>> @@ -337,14 +337,14 @@ void X11CursorThread::cursor_changes()
>>         }
>> 
>>         last_serial = cursor->cursor_serial;
>> -        stream.send<X11CursorMessage>(cursor);
>> +        channel.send<X11CursorMessage>(cursor);
>>     }
>> }
>> 
>> }} // namespace spice::streaming_agent
>> 
>> 
>> -int Stream::have_something_to_read(int timeout)
>> +int IOChannel::have_something_to_read(int timeout)
>> {
>>     struct pollfd pollfd = {streamfd, POLLIN, 0};
>> 
>> @@ -360,7 +360,7 @@ int Stream::have_something_to_read(int timeout)
>>     return 0;
>> }
>> 
>> -void Stream::handle_stream_start_stop(uint32_t len)
>> +void IOChannel::handle_stream_start_stop(uint32_t len)
>> {
>>     uint8_t msg[256];
>> 
>> @@ -382,7 +382,7 @@ void Stream::handle_stream_start_stop(uint32_t len)
>>     }
>> }
>> 
>> -void Stream::handle_stream_capabilities(uint32_t len)
>> +void IOChannel::handle_stream_capabilities(uint32_t len)
>> {
>>     uint8_t caps[STREAM_MSG_CAPABILITIES_MAX_BYTES];
>> 
>> @@ -407,13 +407,13 @@ void Stream::handle_stream_capabilities(uint32_t len)
>>     }
>> }
>> 
>> -void Stream::handle_stream_error(uint32_t len)
>> +void IOChannel::handle_stream_error(uint32_t len)
>> {
>>     // TODO read message and use it
>>     throw std::runtime_error("got an error message from server");
>> }
>> 
>> -void Stream::read_command_from_device()
>> +void IOChannel::read_command_from_device()
>> {
>>     StreamDevHeader hdr;
>>     int n;
>> @@ -440,7 +440,7 @@ void Stream::read_command_from_device()
>>     throw std::runtime_error("UNKNOWN msg of type " +
>>     std::to_string(hdr.type));
>> }
>> 
>> -int Stream::read_command(bool blocking)
>> +int IOChannel::read_command(bool blocking)
>> {
>>     int timeout = blocking?-1:0;
>>     while (!quit_requested) {
>> @@ -458,7 +458,7 @@ int Stream::read_command(bool blocking)
>>     return 1;
>> }
>> 
>> -size_t Stream::write_all(const char *what, const void *buf, const size_t
>> len)
>> +size_t IOChannel::write_all(const char *what, const void *buf, const size_t
>> len)
>> {
>>     size_t written = 0;
>>     while (written < len) {
>> @@ -509,12 +509,12 @@ static void usage(const char *progname)
>> }
>> 
>> 
>> -void ConcreteAgent::CaptureLoop(Stream &stream, FrameLog &frame_log)
>> +void ConcreteAgent::CaptureLoop(IOChannel &channel, FrameLog &frame_log)
>> {
>>     unsigned int frame_count = 0;
>>     while (!quit_requested) {
>> -        while (!quit_requested && !stream.streaming_requested()) {
>> -            if (stream.read_command(true) < 0) {
>> +        while (!quit_requested && !channel.streaming_requested()) {
>> +            if (channel.read_command(true) < 0) {
>>                 syslog(LOG_ERR, "FAILED to read command\n");
>>                 return;
>>             }
>> @@ -527,12 +527,12 @@ void ConcreteAgent::CaptureLoop(Stream &stream,
>> FrameLog &frame_log)
>>         syslog(LOG_INFO, "streaming starts now\n");
>>         uint64_t time_last = 0;
>> 
>> -        std::unique_ptr<FrameCapture>
>> capture(GetBestFrameCapture(stream.client_codecs()));
>> +        std::unique_ptr<FrameCapture>
>> capture(GetBestFrameCapture(channel.client_codecs()));
>>         if (!capture) {
>>             throw std::runtime_error("cannot find a suitable capture
>>             system");
>>         }
>> 
>> -        while (!quit_requested && stream.streaming_requested()) {
>> +        while (!quit_requested && channel.streaming_requested()) {
>>             if (++frame_count % 100 == 0) {
>>                 syslog(LOG_DEBUG, "SENT %d frames\n", frame_count);
>>             }
>> @@ -559,15 +559,15 @@ void ConcreteAgent::CaptureLoop(Stream &stream,
>> FrameLog &frame_log)
>> 
>>                 syslog(LOG_DEBUG, "wXh %uX%u  codec=%u\n", width, height,
>>                 codec);
>> 
>> -                stream.send<FormatMessage>(width, height, codec);
>> +                channel.send<FormatMessage>(width, height, codec);
>>             }
>>             if (frame_log) {
>>                 frame_log.dump(frame.buffer, frame.buffer_size);
>>             }
>> -            stream.send<FrameMessage>(frame.buffer, frame.buffer_size);
>> +            channel.send<FrameMessage>(frame.buffer, frame.buffer_size);
>> 
>>             //usleep(1);
>> -            if (stream.read_command(false) < 0) {
>> +            if (channel.read_command(false) < 0) {
>>                 syslog(LOG_ERR, "FAILED to read command\n");
>>                 return;
>>             }
>> @@ -638,7 +638,7 @@ int main(int argc, char* argv[])
>>         // register built-in plugins
>>         MjpegPlugin::Register(&agent);
>>         agent.LoadPlugins(PLUGINSDIR);
>> -        Stream stream(streamport);
>> +        IOChannel stream(streamport);
>>         X11CursorThread cursor_thread(stream);
>>         FrameLog frame_log(log_filename, log_binary);
>>         agent.CaptureLoop(stream, frame_log);
> 
> Beside both "Stream" and "IOChannel" are too generic for what this
> class is doing the class was inserted in this series, you should
> squash this patch into the patch that introduced this class.

Well, I didn’t precisely because I wasn’t sure there was a general agreement on the name. So there is no point churning if it’s to undo it later.

> 
> Frediano

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]