streaming-agent: C++ refactoring

Submitted by Christophe Fergeau on Feb. 28, 2018, 3:43 p.m.

Details

Reviewer None
Submitted Feb. 28, 2018, 3:43 p.m.
Last Updated March 6, 2018, 4:15 p.m.
Revision 2

Cover Letter(s)

Revision 1
      From: Christophe de Dinechin <dinechin@redhat.com>

The streaming agent started as C code. This series converts
the style to something that is more usual for C++, notably:

- Adds encapsulation and RAII for resources such as the stream
- Splits functionality into several classes with clear roles
- Create exception handling classes dealing with exception
  identification and message formatting
- Puts message formatting and writing in a template Message class
- Isolate what's specific to each message in four derived classes
- Isolate X11-specific code in separate classes, one for cursor messages,
  one for the thread polling the data.

Changes since WIP:

- Took into account the many comments on the WIP
  (if I forgot any, my apologies, let me know)
- Finished the error handling work, extended to all 'throw' points
- Avoid any allocation in exception handling (and made it noexcept)
- Split X11 cursor class into two classes, "updater" and "thread"
- Added final patches to move the classes in separate files
- Tested with both MJPEG and H264 encoders, verified cursor fix
- Tested exception handling and message reporting

Christophe de Dinechin (22):
  Eliminate signed/unsigned warning
  Reorder headers according to style guide
  Reformat 'if' statments according to style guide
  Use RAII to cleanup stream in case of exception or return
  Replace C-style initialization with shorter C++-style
  Get rid of C-style memset initializations, use C++ style aggregates
  Since we use a namespace, simplify name of local classes
  Use C++ style for cursor message initialization instead of C style
  Move read, write, handle and locking into the 'Stream' class
  Remove client_codecs global variable, moved inside the 'Stream' class
  Make streaming_requested a method in Stream
  Add exception handling classes
  Convert message writing from C style to C++ style
  Create classes encapsulating the X11 display cursor capture
  Create FrameLog class to encapsulate logging of frames
  Move the capture loop in the ConcreteAgent
  Catch all std::exception derivatives
  Convert existing std::runtime_error to the new Error classes
  Put Stream and Message classes in separate files
  Move the X11CursorUpdater and X11CursorThread classes in a separate
    file
  Moving FrameLog into a separate file
  Move capture loop into concrete-agent.cpp

 include/spice-streaming-agent/Makefile.am |   2 +-
 include/spice-streaming-agent/errors.hpp  |  95 +++++++
 src/Makefile.am                           |   7 +
 src/concrete-agent.cpp                    | 106 ++++++-
 src/concrete-agent.hpp                    |   4 +
 src/errors.cpp                            |  74 +++++
 src/frame-log.cpp                         |  45 +++
 src/frame-log.hpp                         |  43 +++
 src/message.hpp                           |  43 +++
 src/mjpeg-fallback.cpp                    |  12 +-
 src/spice-streaming-agent.cpp             | 451 ++----------------------------
 src/stream.cpp                            | 172 ++++++++++++
 src/stream.hpp                            |  55 ++++
 src/unittests/Makefile.am                 |   1 +
 src/unittests/test-mjpeg-fallback.cpp     |   4 +-
 src/x11-cursor.cpp                        |  65 +++++
 src/x11-cursor.hpp                        |  91 ++++++
 17 files changed, 840 insertions(+), 430 deletions(-)
 create mode 100644 include/spice-streaming-agent/errors.hpp
 create mode 100644 src/errors.cpp
 create mode 100644 src/frame-log.cpp
 create mode 100644 src/frame-log.hpp
 create mode 100644 src/message.hpp
 create mode 100644 src/stream.cpp
 create mode 100644 src/stream.hpp
 create mode 100644 src/x11-cursor.cpp
 create mode 100644 src/x11-cursor.hpp
    

Revisions

Patches download mbox

# Name Submitter State A F R T
[01/22] Eliminate signed/unsigned warning Christophe de Dinechin Superseded
[02/22] Reorder headers according to style guide Christophe de Dinechin Accepted 1
[03/22] Reformat 'if' statments according to style guide Christophe de Dinechin Accepted 1
[04/22] Use RAII to cleanup stream in case of exception or return Christophe de Dinechin New
[05/22] Replace C-style initialization with shorter C++-style Christophe de Dinechin New 1
[06/22] Get rid of C-style memset initializations, use C++ style aggregates Christophe de Dinechin New
[07/22] Since we use a namespace, simplify name of local classes Christophe de Dinechin New
[08/22] Use C++ style for cursor message initialization instead of C style Christophe de Dinechin New
[09/22] Move read, write, handle and locking into the 'Stream' class Christophe de Dinechin New
[10/22] Remove client_codecs global variable, moved inside the 'Stream' class Christophe de Dinechin New
[11/22] Make streaming_requested a method in Stream Christophe de Dinechin New
[12/22] Add exception handling classes Christophe de Dinechin Superseded
[13/22] Convert message writing from C style to C++ style Christophe de Dinechin New
[14/22] Create classes encapsulating the X11 display cursor capture Christophe de Dinechin New
[15/22] Create FrameLog class to encapsulate logging of frames Christophe de Dinechin New
[16/22] Move the capture loop in the ConcreteAgent Christophe de Dinechin New
[17/22] Catch all std::exception derivatives Christophe de Dinechin New
[18/22] Convert existing std::runtime_error to the new Error classes Christophe de Dinechin New
[19/22] Put Stream and Message classes in separate files Christophe de Dinechin New
[20/22] Move the X11CursorUpdater and X11CursorThread classes in a separate file Christophe de Dinechin New
[21/22] Moving FrameLog into a separate file Christophe de Dinechin New
[22/22] Move capture loop into concrete-agent.cpp Christophe de Dinechin New

Patches download mbox

# Name Submitter State A F R T
[01/22] Eliminate signed/unsigned warning Christophe de Dinechin Superseded
[02/22] Reorder headers according to style guide Christophe de Dinechin Accepted 1
[03/22] Reformat 'if' statments according to style guide Christophe de Dinechin Accepted 1
[04/22] Use RAII to cleanup stream in case of exception or return Christophe de Dinechin New
[05/22] Replace C-style initialization with shorter C++-style Christophe de Dinechin New 1
[06/22] Get rid of C-style memset initializations, use C++ style aggregates Christophe Fergeau Rejected
[07/22] Since we use a namespace, simplify name of local classes Christophe de Dinechin New
[08/22] Use C++ style for cursor message initialization instead of C style Christophe de Dinechin New
[09/22] Move read, write, handle and locking into the 'Stream' class Christophe de Dinechin New
[10/22] Remove client_codecs global variable, moved inside the 'Stream' class Christophe de Dinechin New
[11/22] Make streaming_requested a method in Stream Christophe de Dinechin New
[12/22] Add exception handling classes Christophe de Dinechin Superseded
[13/22] Convert message writing from C style to C++ style Christophe de Dinechin New
[14/22] Create classes encapsulating the X11 display cursor capture Christophe de Dinechin New
[15/22] Create FrameLog class to encapsulate logging of frames Christophe de Dinechin New
[16/22] Move the capture loop in the ConcreteAgent Christophe de Dinechin New
[17/22] Catch all std::exception derivatives Christophe de Dinechin New
[18/22] Convert existing std::runtime_error to the new Error classes Christophe de Dinechin New
[19/22] Put Stream and Message classes in separate files Christophe de Dinechin New
[20/22] Move the X11CursorUpdater and X11CursorThread classes in a separate file Christophe de Dinechin New
[21/22] Moving FrameLog into a separate file Christophe de Dinechin New
[22/22] Move capture loop into concrete-agent.cpp Christophe de Dinechin New