Skip to content

Commit

Permalink
Merge pull request #21 from rdumusc/master
Browse files Browse the repository at this point in the history
Deflect cleanups (part1)
  • Loading branch information
Raphael Dumusc committed Jun 9, 2015
2 parents b90fcd7 + 7f0376d commit 5066e52
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .gitexternals
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- mode: cmake -*-
# CMake/common https://github.com/Eyescale/CMake.git a9c3537
# CMake/common https://github.com/Eyescale/CMake.git 5734155
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ CMake/common
Makefile
CMakeLists.txt.user*
build/
Lunchbox/
Servus/
___*
8 changes: 0 additions & 8 deletions CMake/CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
# Info: http://www.itk.org/Wiki/CMake:Component_Install_With_CPack

set(CPACK_PACKAGE_EXECUTABLES "${DESKTOPSTREAMER_APP_NAME}")
set(CPACK_PACKAGE_NAME "${DESKTOPSTREAMER_APP_NAME}")
set(CPACK_PACKAGE_CONTACT "Daniel Nachbaur <[email protected]>")
set(CPACK_PACKAGE_VENDOR "https://github.com/BlueBrain/Deflect")

set(CPACK_COMPONENT_DESKTOPSTREAMER_DISPLAY_NAME "DesktopStreamer Application")
set(CPACK_COMPONENT_DESKTOPSTREAMER_DESCRIPTION "DesktopStreamer is an application that lets you stream your desktop to a running DisplayCluster instance.")
set(CPACK_COMPONENT_DESKTOPSTREAMER_DEPENDS Deflect)

# Currently we only package desktopstreamer and the Deflect library
set(CPACK_COMPONENTS_ALL desktopstreamer lib)

# Linux Debian specific settings
set(CPACK_DEBIAN_PACKAGE_DEPENDS "qtbase5-dev, libturbojpeg" )
set(CPACK_DEB_COMPONENT_INSTALL ON) # Set this to package only components in CPACK_COMPONENTS_ALL
Expand Down
55 changes: 14 additions & 41 deletions apps/DesktopStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,42 @@
# Raphael Dumusc <[email protected]>

set(DESKTOPSTREAMER_MOC_HEADERS
MainWindow.h
DesktopSelectionWindow.h
DesktopSelectionRectangle.h
MainWindow.h
)

set(DESKTOPSTREAMER_SOURCES
DesktopSelectionRectangle.cpp
DesktopSelectionWindow.cpp
DesktopSelectionView.cpp
main.cpp
MainWindow.cpp
main.cpp
)

set(DESKTOPSTREAMER_LINK_LIBRARIES Deflect ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES})
set(DESKTOPSTREAMER_LINK_LIBRARIES
Deflect
${Qt5Core_LIBRARIES}
${Qt5Widgets_LIBRARIES}
)

set(DESKTOPSTREAMER_APP_NAME desktopstreamer)
set(DESKTOPSTREAMER_RESOURCES resources.qrc)

qt5_wrap_cpp(MOC_OUTFILES ${DESKTOPSTREAMER_MOC_HEADERS})
qt5_add_resources(QRC_SOURCES ${DESKTOPSTREAMER_RESOURCES})

if(APPLE)
set(DESKTOPSTREAMER_APP_NAME DesktopStreamer)
set(DESKTOPSTREAMER_ICON_FILE desktopstreamer.icns)
string(TIMESTAMP _CURRENT_YEAR "%Y")
set(DESKTOPSTREAMER_COPYRIGHT "EPFL/Blue Brain Project ${_CURRENT_YEAR}")
set(DESKTOPSTREAMER_ICON desktopstreamer.icns)

list(APPEND DESKTOPSTREAMER_SOURCES AppNapSuspender.mm)
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES
"-framework Foundation -framework CoreGraphics")
list(APPEND DESKTOPSTREAMER_SOURCES AppNapSuspender.mm)

# set where in the bundle to put the icns file
set_source_files_properties(${DESKTOPSTREAMER_ICON_FILE}
PROPERTIES MACOSX_PACKAGE_LOCATION Resources)

add_executable(${DESKTOPSTREAMER_APP_NAME} MACOSX_BUNDLE
${DESKTOPSTREAMER_SOURCES} ${MOC_OUTFILES} ${QRC_SOURCES}
${DESKTOPSTREAMER_ICON_FILE}) # include the icns file in the target

# Configure the bundle property file using current version and year
string(TIMESTAMP CURRENT_YEAR "%Y")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in
${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
set_target_properties(${DESKTOPSTREAMER_APP_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)

elseif(WIN32)
set(DESKTOPSTREAMER_APP_NAME desktopstreamer)
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES ${QT_QTMAIN_LIBRARY} Ws2_32)

add_executable(${DESKTOPSTREAMER_APP_NAME} WIN32
${DESKTOPSTREAMER_SOURCES} ${MOC_OUTFILES} ${QRC_SOURCES})

else()
set(DESKTOPSTREAMER_APP_NAME desktopstreamer)

add_executable(${DESKTOPSTREAMER_APP_NAME}
${DESKTOPSTREAMER_SOURCES} ${MOC_OUTFILES} ${QRC_SOURCES})
list(APPEND DESKTOPSTREAMER_LINK_LIBRARIES Ws2_32)
endif()

target_link_libraries(${DESKTOPSTREAMER_APP_NAME} ${DESKTOPSTREAMER_LINK_LIBRARIES})

install(TARGETS ${DESKTOPSTREAMER_APP_NAME}
RUNTIME DESTINATION bin COMPONENT desktopstreamer
BUNDLE DESTINATION . COMPONENT desktopstreamer
)
common_gui_application(${DESKTOPSTREAMER_APP_NAME})

set(CPACK_PACKAGE_LICENSE "LGPL")
include(CPackConfig)
40 changes: 0 additions & 40 deletions apps/DesktopStreamer/Info.plist.in

This file was deleted.

5 changes: 1 addition & 4 deletions apps/SimpleStreamer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@
set(SIMPLESTREAMER_SOURCES main.cpp)
set(SIMPLESTREAMER_LINK_LIBRARIES Deflect ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})

add_executable(simplestreamer ${SIMPLESTREAMER_SOURCES})
target_link_libraries(simplestreamer ${SIMPLESTREAMER_LINK_LIBRARIES})

INSTALL(TARGETS simplestreamer RUNTIME DESTINATION bin COMPONENT simplestreamer)
common_application(simplestreamer)
20 changes: 7 additions & 13 deletions deflect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ set(DEFLECT_PUBLIC_HEADERS
AbstractCommandHandler.h
config.h
Command.h
CommandHandler.h
CommandType.h
Event.h
EventReceiver.h
ImageWrapper.h
NetworkListener.h
PixelStreamBuffer.h
PixelStreamFrame.h
PixelStreamDispatcher.h
PixelStreamSegment.h
PixelStreamSegmentParameters.h
Socket.h
Stream.h
types.h
)

set(DEFLECT_MOC_PUBLIC_HEADERS
CommandHandler.h
EventReceiver.h
NetworkListener.h
PixelStreamDispatcher.h
)

set(DEFLECT_HEADERS
${COMMON_INCLUDES}
ImageJpegCompressor.h
ImageJpegDecompressor.h
ImageSegmenter.h
Expand All @@ -36,19 +37,12 @@ set(DEFLECT_HEADERS
)

set(DEFLECT_MOC_HEADERS
CommandHandler.h
EventReceiver.h
NetworkListener.h
NetworkListenerWorker.h
PixelStreamDispatcher.h
Socket.h
StreamPrivate.h
)

qt5_wrap_cpp(MOC_OUTFILES ${DEFLECT_MOC_HEADERS})

set(DEFLECT_SOURCES
${MOC_OUTFILES}
Command.cpp
CommandHandler.cpp
CommandType.cpp
Expand Down
26 changes: 10 additions & 16 deletions deflect/MessageHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,16 @@ namespace deflect
/** The message types. */
enum MessageType
{
MESSAGE_TYPE_NONE,
MESSAGE_TYPE_CONTENTS,
MESSAGE_TYPE_CONTENTS_DIMENSIONS,
MESSAGE_TYPE_PIXELSTREAM_OPEN,
MESSAGE_TYPE_PIXELSTREAM_FINISH_FRAME,
MESSAGE_TYPE_PIXELSTREAM,
MESSAGE_TYPE_BIND_EVENTS,
MESSAGE_TYPE_BIND_EVENTS_EX,
MESSAGE_TYPE_BIND_EVENTS_REPLY,
MESSAGE_TYPE_EVENT,
MESSAGE_TYPE_FRAME_CLOCK,
MESSAGE_TYPE_COMMAND,
MESSAGE_TYPE_QUIT,
MESSAGE_TYPE_ACK,
MESSAGE_TYPE_OPTIONS,
MESSAGE_TYPE_MARKERS
MESSAGE_TYPE_NONE = 0,
MESSAGE_TYPE_PIXELSTREAM_OPEN = 3,
MESSAGE_TYPE_PIXELSTREAM_FINISH_FRAME = 4,
MESSAGE_TYPE_PIXELSTREAM = 5,
MESSAGE_TYPE_BIND_EVENTS = 6,
MESSAGE_TYPE_BIND_EVENTS_EX = 7,
MESSAGE_TYPE_BIND_EVENTS_REPLY = 8,
MESSAGE_TYPE_EVENT = 9,
MESSAGE_TYPE_COMMAND = 11,
MESSAGE_TYPE_QUIT = 12
};

#define MESSAGE_HEADER_URI_LENGTH 64
Expand Down
19 changes: 8 additions & 11 deletions deflect/NetworkListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@

#include "NetworkListener.h"

#include "CommandHandler.h"
#include "NetworkListenerWorker.h"
#include "NetworkProtocol.h"
#include "PixelStreamDispatcher.h"
#include "CommandHandler.h"

#ifdef DEFLECT_USE_SERVUS
# include <servus/servus.h>
Expand All @@ -52,17 +53,15 @@

namespace deflect
{
const int NetworkListener::defaultPortNumber = 1701;
const std::string NetworkListener::serviceName = "_displaycluster._tcp";
const int NetworkListener::defaultPortNumber = DEFAULT_PORT_NUMBER;
const std::string NetworkListener::serviceName = SERVUS_SERVICE_NAME;

namespace detail
{
class NetworkListener
class NetworkListener::Impl
{
public:
NetworkListener()
Impl()
#ifdef DEFLECT_USE_SERVUS
: servus( deflect::NetworkListener::serviceName )
: servus( NetworkListener::serviceName )
#endif
{}

Expand All @@ -72,11 +71,9 @@ class NetworkListener
servus::Servus servus;
#endif
};
}


NetworkListener::NetworkListener( const int port )
: _impl( new detail::NetworkListener )
: _impl( new Impl )
{
if( !listen( QHostAddress::Any, port ))
{
Expand Down
4 changes: 2 additions & 2 deletions deflect/NetworkListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

namespace deflect
{
namespace detail{ class NetworkListener; }

/**
* Listen to incoming PixelStream connections from Stream clients.
Expand Down Expand Up @@ -86,7 +85,8 @@ public slots:
void onEventRegistrationReply( QString uri, bool success );

private:
detail::NetworkListener* _impl;
class Impl;
Impl* _impl;

/** Re-implemented handling of connections from QTCPSocket. */
void incomingConnection( qintptr socketHandle ) final;
Expand Down
5 changes: 3 additions & 2 deletions deflect/NetworkProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#ifndef DEFLECT_NETWORK_PROTOCOL_H
#define DEFLECT_NETWORK_PROTOCOL_H

// increment this every time the network protocol changes in a major way
#define NETWORK_PROTOCOL_VERSION 8
#define NETWORK_PROTOCOL_VERSION 8
#define DEFAULT_PORT_NUMBER 1701
#define SERVUS_SERVICE_NAME "_displaycluster._tcp"

#endif
13 changes: 7 additions & 6 deletions deflect/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,26 @@
#include <QtNetwork/QTcpSocket>
#include <iostream>

#define INVALID_NETWORK_PROTOCOL_VERSION -1
#define RECEIVE_TIMEOUT_MS 1000
#define WAIT_FOR_BYTES_WRITTEN_TIMEOUT_MS 1000

namespace deflect
{

const unsigned short Socket::defaultPortNumber_ = 1701;
const unsigned short Socket::defaultPortNumber = DEFAULT_PORT_NUMBER;

Socket::Socket(const std::string &hostname, const unsigned short port)
: socket_(new QTcpSocket())
, remoteProtocolVersion_(-1)
Socket::Socket( const std::string &hostname, const unsigned short port )
: socket_( new QTcpSocket( ))
, remoteProtocolVersion_( INVALID_NETWORK_PROTOCOL_VERSION )
{
if( !connect( hostname, port ))
{
std::cerr << "could not connect to host " << hostname << ":" << port
<< std::endl;
}
// Forward disconnection events
QObject::connect(socket_, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
QObject::connect( socket_, SIGNAL( disconnected( )),
this, SIGNAL( disconnected( )));
}

Socket::~Socket()
Expand Down
Loading

0 comments on commit 5066e52

Please sign in to comment.