Pool Video Switch v2
Software video switch for distributed remote display in a lecture environment
Signals | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
VncThread Class Reference

VncThread - communicate with VNC server, scale image if necessary. More...

#include "vncthread.h"

+ Inheritance diagram for VncThread:
+ Collaboration diagram for VncThread:

Signals

void imageUpdated (const int x, const int y, const int w, const int h)
 
void projectionStarted ()
 
void projectionStopped ()
 

Public Member Functions

 VncThread (QString host, int port, QString passwd, int quality)
 Initialize this VNC client connection worker thread. More...
 
 ~VncThread () override
 
QString getDesktopName () const
 Get name of the VNC server's desktop. More...
 
bool isConnected () const
 
void stop ()
 
const QSharedPointer< QImage > & getFrameBuffer ()
 
void run () override
 Worker thread's mainloop, connecting to the VNC server and handling the connection. More...
 

Static Public Attributes

int static const HIGH = 0
 
int static const MEDIUM = 1
 
int static const LOW = 2
 

Private Member Functions

void calcScaling ()
 
void processImageUpdate (int x, int y, int w, int h)
 Handle update of an area of the VNC framebuffer. More...
 
void emitStarted ()
 

Static Private Member Functions

static void updateImage (rfbClient *client, int x, int y, int w, int h)
 Callback for the vnc client lib: A part of the frame buffer has changed. More...
 
static char * passwdHandler (rfbClient *client)
 Callback for the vnc client lib: The VNC server is requesting a password. More...
 
static rfbBool frameBufferHandler (rfbClient *client)
 Callback for the vnc client lib: The size of the remote screen has been changed, so we're supposed to reallocate the local frame buffer. More...
 

Private Attributes

rfbClient * _client
 
QString _host
 
int _port
 
QString _passwd
 
int _quality
 
QSharedPointer< QImage > _img
 
volatile bool _connected {}
 
volatile bool _run
 
bool _started
 

Detailed Description

VncThread - communicate with VNC server, scale image if necessary.

As this class is derived from QThread and overrides the run() method, it does not have an event-loop. Do NOT try to add any slots to it. It will NOT be able to receive signals. Emitting signals is fine though.

Definition at line 36 of file vncthread.h.

Constructor & Destructor Documentation

VncThread::VncThread ( QString  host,
int  port,
QString  passwd,
int  quality 
)

Initialize this VNC client connection worker thread.

Parameters
hostThe IP address of the VNC server we're going to connect to
portThe port of the VNC server
passwdThe password of the VNC server
qualityThe desired quality level for the VNC stream

Definition at line 34 of file vncthread.cpp.

VncThread::~VncThread ( )
override

Definition at line 46 of file vncthread.cpp.

Member Function Documentation

void VncThread::calcScaling ( )
private
void VncThread::emitStarted ( )
private

Definition at line 161 of file vncthread.cpp.

rfbBool VncThread::frameBufferHandler ( rfbClient *  client)
staticprivate

Callback for the vnc client lib: The size of the remote screen has been changed, so we're supposed to reallocate the local frame buffer.

Parameters
clientStruct representing the connection to the server.
Returns
true (signaling the vnc client that we successfully allocated a buffer)

Definition at line 188 of file vncthread.cpp.

+ Here is the caller graph for this function:

QString VncThread::getDesktopName ( ) const

Get name of the VNC server's desktop.

Returns
Name of the remote desktop

Definition at line 139 of file vncthread.cpp.

const QSharedPointer<QImage>& VncThread::getFrameBuffer ( )
inline

Definition at line 71 of file vncthread.h.

+ Here is the caller graph for this function:

void VncThread::imageUpdated ( const int  x,
const int  y,
const int  w,
const int  h 
)
signal

+ Here is the caller graph for this function:

bool VncThread::isConnected ( ) const
inline

Definition at line 69 of file vncthread.h.

+ Here is the caller graph for this function:

char * VncThread::passwdHandler ( rfbClient *  client)
staticprivate

Callback for the vnc client lib: The VNC server is requesting a password.

Parameters
clientStruct representing the connection to the server.
Returns
A strdup()ed copy of the password we'll try to connect with. The memory if free()d by the vnc client library.

Definition at line 175 of file vncthread.cpp.

+ Here is the caller graph for this function:

void VncThread::processImageUpdate ( int  x,
int  y,
int  w,
int  h 
)
private

Handle update of an area of the VNC framebuffer.

Will do any scaling if necessary and then emit the imageUpdated signal, so the VncWindow knows that it needs to redraw.

Parameters
xX offset of the area in the framebuffer that changed
yY offset of the area in the framebuffer that changed
wwidth of the area in the framebuffer that changed
hheight of the area in the framebuffer that changed

Definition at line 156 of file vncthread.cpp.

void VncThread::projectionStarted ( )
signal

+ Here is the caller graph for this function:

void VncThread::projectionStopped ( )
signal

+ Here is the caller graph for this function:

void VncThread::run ( )
override

Worker thread's mainloop, connecting to the VNC server and handling the connection.

The vnc client library is written in a blocking manner, so we just do everything in our own thread and just hand over the image updates to the vnc client window, which resides in the application's main thread.

This thread checks if the vnc window signaled us to stop and if so, it deletes itself. This means that you should never delete this thread from anywhere. Just call VncThread::stop() and wait for it to delete itself.

Definition at line 71 of file vncthread.cpp.

+ Here is the call graph for this function:

void VncThread::stop ( )
inline

Definition at line 70 of file vncthread.h.

+ Here is the caller graph for this function:

void VncThread::updateImage ( rfbClient *  client,
int  x,
int  y,
int  w,
int  h 
)
staticprivate

Callback for the vnc client lib: A part of the frame buffer has changed.

That means we have to apply scaling if necessary, and then cause the vnc window to redraw the corresponding area.

Parameters
clientStruct representing the connection to the server.
xX offset of the area in the framebuffer that changed
yY offset of the area in the framebuffer that changed
wwidth of the area in the framebuffer that changed
hheight of the area in the framebuffer that changed

Definition at line 263 of file vncthread.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

rfbClient* VncThread::_client
private

Definition at line 41 of file vncthread.h.

volatile bool VncThread::_connected {}
private

Definition at line 50 of file vncthread.h.

QString VncThread::_host
private

Definition at line 43 of file vncthread.h.

QSharedPointer<QImage> VncThread::_img
private

Definition at line 48 of file vncthread.h.

QString VncThread::_passwd
private

Definition at line 45 of file vncthread.h.

int VncThread::_port
private

Definition at line 44 of file vncthread.h.

int VncThread::_quality
private

Definition at line 46 of file vncthread.h.

volatile bool VncThread::_run
private

Definition at line 51 of file vncthread.h.

bool VncThread::_started
private

Definition at line 52 of file vncthread.h.

int static const VncThread::HIGH = 0
static

Definition at line 74 of file vncthread.h.

int static const VncThread::LOW = 2
static

Definition at line 76 of file vncthread.h.

int static const VncThread::MEDIUM = 1
static

Definition at line 75 of file vncthread.h.


The documentation for this class was generated from the following files: