- Menus
- Open/Save file - Add CITP/MSEx menu - Make Thumbs - Init CITP/MSEx
This commit is contained in:
parent
62947ac256
commit
ef52ae20d8
10 changed files with 278 additions and 265 deletions
|
|
@ -37,7 +37,10 @@
|
|||
#define PDPORTW_AUDIO 9197
|
||||
#define PDPORTR_AUDIO 9198
|
||||
|
||||
#define SOCKET "/tmp/pmspipe"
|
||||
#define SOCKET "/tmp/pmspipe" // Pipe wicho PD sends the files for preview in the GUI
|
||||
|
||||
#define CONF_FILE "lms.conf" // File when save/restore the configuration on exit/open
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Struct for the configuration files
|
||||
|
|
@ -95,9 +98,6 @@ bool layer8Check_audio;
|
|||
bool dmx_audio;
|
||||
quint8 universe_audio;
|
||||
bool audioCheck;
|
||||
|
||||
// Path to Media Files
|
||||
QString path;
|
||||
};
|
||||
|
||||
// Constructor
|
||||
|
|
@ -137,10 +137,13 @@ libreMediaServer::libreMediaServer(QWidget *parent)
|
|||
m_ola = new QProcess(this);
|
||||
olastart();
|
||||
// Conectamos los menus
|
||||
connect(ui.actionOpen_conf, SIGNAL(triggered()), this, SLOT(open()));
|
||||
connect(ui.actionSave_conf, SIGNAL(triggered()), this, SLOT(save()));
|
||||
connect(ui.actionOpen_conf, SIGNAL(triggered()), this, SLOT(openFile()));
|
||||
connect(ui.actionSave_conf, SIGNAL(triggered()), this, SLOT(saveFile()));
|
||||
connect(ui.actionChange_Media_Path, SIGNAL(triggered()), this, SLOT(ChangeMediaPath()));
|
||||
connect(ui.actionInitMSEX, SIGNAL(triggered()), this, SLOT(InitMSEX()));
|
||||
// Load the configuration
|
||||
open();
|
||||
open_start();
|
||||
// Connect MSEx
|
||||
connect(m_msex,SIGNAL(frameRequest()), this, SLOT(sendFrame()));
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +152,7 @@ libreMediaServer::libreMediaServer(QWidget *parent)
|
|||
|
||||
libreMediaServer::~libreMediaServer()
|
||||
{
|
||||
save();
|
||||
save_finish();
|
||||
QFile socket(SOCKET);
|
||||
socket.remove();
|
||||
if (m_pd_write_video != NULL) {
|
||||
|
|
@ -184,28 +187,100 @@ libreMediaServer::~libreMediaServer()
|
|||
if (m_pd_write_audio != NULL)
|
||||
{
|
||||
m_pd_read_audio->close();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// File Configuration Stuff
|
||||
// open/save the last configuration known
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
// Load the last configuration from the file pms.conf
|
||||
|
||||
void libreMediaServer::open()
|
||||
// Load the last configuration from the configuration file
|
||||
void libreMediaServer::open_start()
|
||||
{
|
||||
QFile file("lms.conf");
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<("Can not find the conf file");
|
||||
QFile file(CONF_FILE);
|
||||
open(&file);
|
||||
}
|
||||
|
||||
// Save the last configuration to the conf file
|
||||
void libreMediaServer::save_finish()
|
||||
{
|
||||
QFile file(CONF_FILE);
|
||||
save(&file);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Menu File
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
// Open a configuration File
|
||||
void libreMediaServer::openFile()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
}
|
||||
unsigned char * fileconf = new unsigned char[file.size()];
|
||||
memset(fileconf, 0, file.size());
|
||||
fileconf = file.map(0x00, file.size());
|
||||
QStringList fileNames;
|
||||
fileNames = dialog.selectedFiles();
|
||||
QFile file(fileNames.at(0));
|
||||
open(&file);
|
||||
}
|
||||
// Save configuration File
|
||||
void libreMediaServer::saveFile()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
QStringList fileNames;
|
||||
fileNames = dialog.selectedFiles();
|
||||
QFile file(fileNames.at(0));
|
||||
save(&file);
|
||||
}
|
||||
// Change Media path
|
||||
void libreMediaServer::ChangeMediaPath()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
dialog.setFileMode(QFileDialog::Directory);
|
||||
QStringList fileNames;
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
fileNames = dialog.selectedFiles();
|
||||
QString file = fileNames.at(0);
|
||||
m_pathmedia = file;
|
||||
QString desc = tr("0000 0000 %1;").arg(file);
|
||||
if (ui.video->checkState())
|
||||
{
|
||||
if (!sendPacket(desc.toAscii().constData(),desc.size()))
|
||||
{
|
||||
errorsending();
|
||||
}
|
||||
}
|
||||
if (ui.audio->checkState())
|
||||
{
|
||||
if (!sendPacket_audio(desc.toAscii().constData(),desc.size()))
|
||||
{
|
||||
errorsending_audio();
|
||||
}
|
||||
}
|
||||
desc = tr("Media Path Changed to: %1").arg(m_pathmedia);
|
||||
ui.textEdit->appendPlainText(desc.toAscii());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Open/save Subroutines. The real work.
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
void libreMediaServer::open(QFile *file)
|
||||
{
|
||||
if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<("Can not find the configuration file");
|
||||
return;
|
||||
}
|
||||
int size = file->size();
|
||||
unsigned char * fileconf = new unsigned char[size];
|
||||
memset(fileconf, 0, size);
|
||||
fileconf = file->map(0x00, size);
|
||||
if (fileconf == 0){
|
||||
qDebug()<<("Cannot map the file");
|
||||
return;
|
||||
|
|
@ -240,7 +315,6 @@ void libreMediaServer::open()
|
|||
ui.ipAddress3->setValue(packet->ipadd3);
|
||||
ui.ipAddress4->setValue(packet->ipadd4);
|
||||
ui.video->setChecked(packet->videoCheck);
|
||||
|
||||
// Audio Configuration
|
||||
ui.layer1Add_audio->setValue(packet->layer1Add_audio);
|
||||
ui.layer1Check_audio->setChecked(packet->layer1Check_audio);
|
||||
|
|
@ -261,29 +335,32 @@ void libreMediaServer::open()
|
|||
ui.readDMX_audio->setChecked(packet->dmx_audio);
|
||||
ui.universe_audio->setValue(packet->universe_audio);
|
||||
ui.audio->setChecked(packet->audioCheck);
|
||||
|
||||
// Path to media
|
||||
int offset = sizeof(struct conf) - 4;
|
||||
int size = file.size() - offset;
|
||||
// Path to media
|
||||
int offset = sizeof(struct conf);
|
||||
size = size - offset;
|
||||
char * buffer = new char[size];
|
||||
memset(buffer, 0, size);
|
||||
memcpy(buffer, fileconf+offset, size);
|
||||
m_pathmedia = buffer;
|
||||
QString desc = tr("Media Path Changed to: %1").arg(m_pathmedia);
|
||||
qDebug()<<(desc);
|
||||
file.close();
|
||||
file->close();
|
||||
delete buffer;
|
||||
// delete fileconf; // Comment due to Seg Fault
|
||||
}
|
||||
|
||||
// Save the configuration to pms.conf file
|
||||
void libreMediaServer::save()
|
||||
void libreMediaServer::save(QFile *file)
|
||||
{
|
||||
if (!file->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<("Can not open file pms.conf");
|
||||
return;
|
||||
}
|
||||
int bufferLen = sizeof(struct conf) + m_pathmedia.size();
|
||||
unsigned char *buffer = new unsigned char[bufferLen];
|
||||
memset(buffer, 0, bufferLen);
|
||||
conf *packet = (conf *)buffer;
|
||||
|
||||
// Video Configuration
|
||||
|
||||
packet->window = ui.window->checkState();
|
||||
packet->winpositionx = ui.winpositionx->value();
|
||||
packet->winpositiony = ui.winpositiony->value();
|
||||
|
|
@ -312,9 +389,7 @@ void libreMediaServer::save()
|
|||
packet->ipadd3 = ui.ipAddress3->value();
|
||||
packet->ipadd4 = ui.ipAddress4->value();
|
||||
packet->videoCheck = ui.video->checkState();
|
||||
|
||||
// Audio Configuration
|
||||
|
||||
packet->layer1Add_audio = ui.layer1Add_audio->value();
|
||||
packet->layer1Check_audio = ui.layer1Check_audio->checkState();
|
||||
packet->layer2Add_audio = ui.layer2Add_audio->value();
|
||||
|
|
@ -334,21 +409,13 @@ void libreMediaServer::save()
|
|||
packet->dmx_audio = ui.readDMX_audio->checkState();
|
||||
packet->universe_audio = ui.universe_audio->value();
|
||||
packet->audioCheck = ui.audio->checkState();
|
||||
|
||||
// Path to media
|
||||
|
||||
int offset = sizeof (struct conf) - 4;
|
||||
int offset = sizeof (struct conf);
|
||||
memcpy(buffer+offset, m_pathmedia.toAscii().constData(), m_pathmedia.size());
|
||||
QFile file("lms.conf");
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qDebug()<<("Can not open file pms.conf");
|
||||
return;
|
||||
}
|
||||
int error = file.write((const char *)buffer, bufferLen);
|
||||
int error = file->write((const char *)buffer, bufferLen);
|
||||
QString errorstring = tr("Bytes Write to file %1").arg(error);
|
||||
qDebug()<<"Saved file complete:"<<(errorstring);
|
||||
file.close();
|
||||
file->close();
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
|
|
@ -367,51 +434,14 @@ void libreMediaServer::olastart()
|
|||
* User Interface Stuff
|
||||
*/
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Global Controls
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
// Change Media path
|
||||
|
||||
void libreMediaServer::on_ChangePath_clicked()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
dialog.setFileMode(QFileDialog::Directory);
|
||||
QStringList fileNames;
|
||||
if (!dialog.exec())
|
||||
return;
|
||||
fileNames = dialog.selectedFiles();
|
||||
QString file = fileNames.at(0);
|
||||
m_pathmedia = file;
|
||||
QString desc = tr("0000 0000 %1;").arg(file);
|
||||
if (ui.video->checkState())
|
||||
{
|
||||
if (!sendPacket(desc.toAscii().constData(),desc.size()))
|
||||
{
|
||||
errorsending();
|
||||
}
|
||||
}
|
||||
if (ui.audio->checkState())
|
||||
{
|
||||
if (!sendPacket_audio(desc.toAscii().constData(),desc.size()))
|
||||
{
|
||||
errorsending_audio();
|
||||
}
|
||||
}
|
||||
desc = tr("Media Path Changed to: %1").arg(m_pathmedia);
|
||||
ui.textEdit->appendPlainText(desc.toAscii());
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Video Controls
|
||||
// Menu CITP/MSEx
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
// Init the CITP/MSEx protocol.
|
||||
// Begins the CITP/MSEx protocol
|
||||
// ToDo: Include thumbs generation here
|
||||
|
||||
void libreMediaServer::on_updateButton_clicked()
|
||||
void libreMediaServer::initMSEX()
|
||||
{
|
||||
// Chequeamos si existe el path a los medias
|
||||
QDir dir(m_pathmedia);
|
||||
|
|
@ -441,9 +471,21 @@ void libreMediaServer::on_updateButton_clicked()
|
|||
ipadd = ipadd + i;
|
||||
m_msex->startCitp(ipadd);
|
||||
}
|
||||
//void setIPAdd();
|
||||
// Generates the thumbs to transmit by CITP/MSEx
|
||||
void libreMediaServer::makeThumbs()
|
||||
{
|
||||
QProcess *script = new QProcess ();
|
||||
QStringList arguments;
|
||||
arguments << m_pathmedia;
|
||||
script->execute("./scripts/make_thumbs.sh", arguments);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Video Controls
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
// Window Configuration
|
||||
|
||||
void libreMediaServer::on_window_stateChanged(int state)
|
||||
{
|
||||
if ((state == 2)) {
|
||||
|
|
@ -897,7 +939,7 @@ void libreMediaServer::pdrestart()
|
|||
{
|
||||
return;
|
||||
}
|
||||
save();
|
||||
save_finish();
|
||||
qDebug()<<"Restarting PD";
|
||||
ui.textEdit->appendPlainText("PD Restarting...");
|
||||
disconnect(m_pd_video, SIGNAL(finished(int)), this, SLOT(pdrestart()));
|
||||
|
|
@ -926,7 +968,7 @@ void libreMediaServer::newmessage()
|
|||
QByteArray byteArray;
|
||||
byteArray.resize(m_read_vid->bytesAvailable());
|
||||
byteArray = m_read_vid->readAll();
|
||||
if (byteArray == NULL)
|
||||
if (byteArray.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -1424,7 +1466,7 @@ void libreMediaServer::stdout_audio() {
|
|||
|
||||
void libreMediaServer::pdrestart_audio()
|
||||
{
|
||||
save();
|
||||
save_finish();
|
||||
qDebug()<<"Restarting PD audio";
|
||||
ui.textEdit->appendPlainText("PD audio Restarting...");
|
||||
int state = m_pd_audio->state();
|
||||
|
|
@ -1593,7 +1635,7 @@ void libreMediaServer::sendFrame()
|
|||
qDebug()<<"sendFrame: Can not convert screen capture to image";
|
||||
return;
|
||||
}
|
||||
image = image.scaledToWidth(88);http://palmadores.net/index.php
|
||||
image = image.scaledToWidth(88);
|
||||
image = image.convertToFormat(QImage::Format_RGB888);
|
||||
int bufferLen = image.byteCount();
|
||||
int bufferLenTot = sizeof(struct CITP_MSEX_10_StFr ) + bufferLen;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue