lms-video/src/olainterface.h
Santi Noreña bbe8a169f2 - Moved DMX reading and file selection from Pure Data to the GUI.
- Added udserver external. All the communication between pure data
process and GUI now is done through Unix Domain Sockets.
- Only video files are working at the moment.
- Creating thumbnails now is done in the start routine.
- CITP/MSEx and DMX reading is started automatically in the start
routine.
- The dmx settings are reading from an xml file. Support for edit
through the GUI and save and open files in next commits. Also it should
integrates the window configuration.
- Audio has been cutted. It will be supported in a separate application.
2013-07-02 18:36:25 +02:00

135 lines
4 KiB
C++
Executable file

/* olainterface.h
Santi Noreña 2013
It includes two classes:
olaWorker is the threading class that reads raw DMX from ola daemon
olaInterface controls olaWorker and translates DMX values received from olaWorker into orders to RenderingManager and Source
*/
#ifndef OLAINTERFACE_H
#define OLAINTERFACE_H
// Define the DMX personality to avoid dealing with numbers and change it easy
#define DMX_FOLDER 5
#define DMX_FILE 6
#define DMX_SOURCETYPE 7
#define LAYER_CHANNELS 63 // The numer of control channels per video layer
#define MAX_SOURCE_DMX 8 // Number of maximum Sources controlled by DMX. It should be equal to MAX_SOURCE_COUNT
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <QObject>
#include <QThread>
#include <QDebug>
#include <QXmlStreamReader>
#include <QFile>
#include <QMessageBox>
#include <QProcess>
// The OLA Library
#include <ola/OlaClientWrapper.h>
#include <ola/OlaCallbackClient.h>
#include "CITPDefines.h"
#include "MSEXDefines.h"
#include "msex.h"
#include "QDir"
#include "libremediaserver.h"
using namespace ola;
// struct where save the DMX settings for each layer
struct dmxSettings {
int address;
uint universe;
bool updated;
};
class olaWorker : public QThread
{
Q_OBJECT
friend class olaInterface;
public:
protected:
olaWorker();
virtual ~olaWorker();
OlaCallbackClientWrapper *m_client;
OlaCallbackClient *m_clientpointer;
unsigned int m_counter;
struct timeval m_last_data; // Last DMX frame received
QList<dmxSettings> m_settings;
QList<int> m_universe; // OLA universes binding
// DMX Conf
int m_dmx[MAX_SOURCE_DMX][LAYER_CHANNELS]; // DMX Buffer
int m_layersNumber; // Number of layers in wich divide the dmx frame. Each layer, one source.
private:
void NewDmx(unsigned int universe,const DmxBuffer &buffer,const string &error); // Callback from OlaCallbackCLient when there is new dmx info
bool CheckDataLoss();
void RegisterComplete(const string &error); // Called after completing the register
protected slots:
void olastart(); // Starts the conexion with olad. olad must be running before this
void olastop(); // Close the connection with olad.
signals:
void finished(); // Signal for closing. Not use now.
void dmx(int layer, int channel, int value); // Signal when a channel has changed
};
class msex;
class olaInterface : public QObject
{
Q_OBJECT
public:
explicit olaInterface();
virtual ~olaInterface();
void open(); // Starts the thread and open the connection with olad
void close(); // Close the connection with olad
olaWorker *worker; // The thread of connection with ola.
inline void setPath(QString path) {m_pathmedia = path;} // Set the path to the root media path. The media files are inside this folder tree.
inline QString getPath () {return m_pathmedia;} // Get the path to the medias folder tree.
msex *m_msex;
QList<MediaLibrary> *m_media; // Library to save the folders/media libraries and index each media file inside
// Created here but m_msex acces for reading in this library
protected:
QThread *m_thread; // The thread for olaWorker
private:
void requestNewFile(int layer, int type); // When there is a change in the channels folder, file or type media (5,6,7), this is called. Creates a new source.
void initMediaLibrary();
QList<MediaInformation> getMediaInformation(QDir dir); // Get all the information of each media file in a dir
QString m_pathmedia; // Path to Medias
void readDataFromXML(); // Read the DMX configuration from the file dmx.xml
public slots:
void dmx(int layer, int channel, int value); // Connected with signal dmx from olaWorker. This is the horsepower of all this. Converts DMX orders
// into orders to RenderingManager and Source. Mantains updated the videolayer struct.
signals:
void sendDmx(int layer,int channel, int value);
void newFile(QString file);
};
#endif // OLAINTERFACE_H