2018-02-04 Fred Gleason <fredg@paravelsystems.com>

* Refactored the RDAudioConvert class to use RDApplication.
	* Converted rdcatchd(8) to use RDApplication.
This commit is contained in:
Fred Gleason 2018-02-04 06:18:52 -05:00
parent fb4dc43033
commit e305344e6b
15 changed files with 160 additions and 206 deletions

View File

@ -16663,3 +16663,6 @@
* Fixed a bug that broke command processing in rdimport(1).
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDRenderer class to use RDApplication.
2018-02-04 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDAudioConvert class to use RDApplication.
* Converted rdcatchd(8) to use RDApplication.

View File

@ -48,17 +48,19 @@
#include <id3/tag.h>
#include <qfile.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdcart.h>
#include <rdconf.h>
#include <rd.h>
#include <rdlibrary_conf.h>
//#include <rdlibrary_conf.h>
#include <rdtempdirectory.h>
#define STAGE2_XFER_SIZE 2048
#define STAGE2_BUFFER_SIZE 49152
RDAudioConvert::RDAudioConvert(const QString &station_name,QObject *parent)
//RDAudioConvert::RDAudioConvert(const QString &station_name,QObject *parent)
RDAudioConvert::RDAudioConvert(QObject *parent)
: QObject(parent)
{
conv_start_point=-1;
@ -68,9 +70,9 @@ RDAudioConvert::RDAudioConvert(const QString &station_name,QObject *parent)
conv_settings=NULL;
conv_src_wavedata=new RDWaveData();
conv_dst_wavedata=NULL;
RDLibraryConf *conf=new RDLibraryConf(station_name);
conv_src_converter=conf->srcConverter();
delete conf;
// RDLibraryConf *conf=new RDLibraryConf(station_name);
conv_src_converter=rda->libraryConf()->srcConverter();
// delete conf;
//
// Load MPEG Libraries

View File

@ -48,7 +48,8 @@ class RDAudioConvert : public QObject
ErrorNoDestination=3,ErrorInvalidSource=4,ErrorInternal=5,
ErrorFormatNotSupported=6,ErrorNoDisc=7,ErrorNoTrack=8,
ErrorInvalidSpeed=9,ErrorFormatError=10,ErrorNoSpace=11};
RDAudioConvert(const QString &station_name,QObject *parent=0);
// RDAudioConvert(const QString &station_name,QObject *parent=0);
RDAudioConvert(QObject *parent=0);
~RDAudioConvert();
void setSourceFile(const QString &filename);
void setDestinationFile(const QString &filename);

View File

@ -660,7 +660,7 @@ unsigned RDFeed::postFile(RDStation *station,const QString &srcfile,Error *err,
// Convert Cut
//
tmpfile=GetTempFilename();
RDAudioConvert *conv=new RDAudioConvert(station->name(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(srcfile);
conv->setDestinationFile(tmpfile);
RDSettings *settings=new RDSettings();

View File

@ -580,7 +580,7 @@ bool RDRenderer::ConvertAudio(const QString &srcfile,const QString &dstfile,
{
RDAudioConvert::ErrorCode err_code;
RDAudioConvert *conv=new RDAudioConvert(rda->station()->name(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(srcfile);
conv->setDestinationFile(dstfile);
conv->setDestinationSettings(s);

View File

@ -39,6 +39,7 @@
#include <qsignalmapper.h>
#include <qsessionmanager.h>
#include <rdapplication.h>
#include <rdaudioconvert.h>
#include <rdcatchd_socket.h>
#include <rdcatchd.h>
@ -99,7 +100,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
{
bool ok=false;
int id=-1;
unsigned schema=0;
// unsigned schema=0;
//
// Set Process Priority
@ -134,19 +135,6 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
//
catch_temp_dir=RDTempDirectory::basePath();
//
// Open Database
//
QString err (tr("ERROR rdcatchd aborting - "));
catch_db=RDInitDb (&schema,&err);
if(!catch_db) {
printf(err.ascii());
exit(1);
}
connect (RDDbStatus(),SIGNAL(logText(RDConfig::LogPriority,const QString &)),
this,SLOT(log(RDConfig::LogPriority,const QString &)));
//
// Load Event
//
@ -157,7 +145,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
fprintf(stderr,"rdcatchd: id %d not found\n",id);
exit(256);
}
batch_event=new CatchEvent(catch_rdstation,RDConfiguration());
batch_event=new CatchEvent(rda->station(),RDConfiguration());
LoadEvent(q,batch_event,false);
delete q;
@ -168,7 +156,7 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
connect(catch_connect,SIGNAL(connected(int,bool)),
this,SLOT(catchConnectedData(int,bool)));
catch_connect->
connectHost("localhost",RDCATCHD_TCP_PORT,catch_config->password());
connectHost("localhost",RDCATCHD_TCP_PORT,rda->config()->password());
}
@ -187,7 +175,7 @@ void MainObject::RunDownload(CatchEvent *evt)
//
// Resolve Wildcards
//
RDStation *station=new RDStation(catch_config->stationName());
RDStation *station=new RDStation(rda->config()->stationName());
evt->resolveUrl(station->timeOffset());
delete station;
@ -200,7 +188,7 @@ void MainObject::RunDownload(CatchEvent *evt)
(const char *)evt->resolvedUrl(),
(const char *)evt->tempName(),
evt->id()));
RDDownload *conv=new RDDownload(catch_config,this);
RDDownload *conv=new RDDownload(rda->config(),this);
conv->setSourceUrl(RDUrlEscape(evt->resolvedUrl()));
conv->setDestinationFile(evt->tempName());
@ -212,7 +200,7 @@ void MainObject::RunDownload(CatchEvent *evt)
url_password=QString(RD_ANON_FTP_PASSWORD)+"-"+VERSION;
}
switch((conv_err=conv->runDownload(url_username,url_password,
catch_config->logXloadDebugData()))) {
rda->config()->logXloadDebugData()))) {
case RDDownload::ErrorOk:
LogLine(RDConfig::LogInfo,QString().
sprintf("finished download of %s to %s, id=%d",
@ -269,7 +257,7 @@ void MainObject::RunUpload(CatchEvent *evt)
//
// Resolve Wildcards
//
RDStation *station=new RDStation(catch_config->stationName());
RDStation *station=new RDStation(rda->config()->stationName());
evt->resolveUrl(station->timeOffset());
delete station;
@ -322,7 +310,7 @@ void MainObject::RunUpload(CatchEvent *evt)
(const char *)evt->
resolvedUrl(),
evt->id()));
RDUpload *conv=new RDUpload(catch_config,this);
RDUpload *conv=new RDUpload(rda->config(),this);
conv->setSourceFile(evt->tempName());
conv->setDestinationUrl(evt->resolvedUrl());
QString url_username=evt->urlUsername();
@ -333,7 +321,7 @@ void MainObject::RunUpload(CatchEvent *evt)
url_password=QString(RD_ANON_FTP_PASSWORD)+"-"+VERSION;
}
switch((conv_err=conv->runUpload(url_username,url_password,
catch_config->logXloadDebugData()))) {
rda->config()->logXloadDebugData()))) {
case RDUpload::ErrorOk:
catch_connect->setExitCode(evt->id(),RDRecording::Ok,tr("Ok"));
qApp->processEvents();
@ -380,8 +368,8 @@ void MainObject::RunUpload(CatchEvent *evt)
(const char *)evt->tempName()));
}
else {
chown(evt->tempName(),catch_config->uid(),
catch_config->gid());
chown(evt->tempName(),rda->config()->uid(),
rda->config()->gid());
}
}
@ -400,7 +388,7 @@ bool MainObject::Export(CatchEvent *evt)
return false;
}
RDCart *cart=new RDCart(cut->cartNumber());
RDAudioConvert *conv=new RDAudioConvert(catch_config->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(RDCut::pathName(evt->cutName()));
conv->setRange(cut->startPoint(),cut->endPoint());
conv->setDestinationFile(RDEscapeString(evt->tempName()));
@ -472,7 +460,7 @@ bool MainObject::Import(CatchEvent *evt)
unsigned msecs=wave->getExtTimeLength();
delete wave;
RDCart *cart=new RDCart(cut->cartNumber());
RDAudioConvert *conv=new RDAudioConvert(catch_config->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(RDEscapeString(evt->tempName()));
conv->setDestinationFile(RDCut::pathName(evt->cutName()));
RDSettings *settings=new RDSettings();
@ -492,7 +480,7 @@ bool MainObject::Import(CatchEvent *evt)
break;
}
settings->setChannels(evt->channels());
settings->setSampleRate(catch_system->sampleRate());
settings->setSampleRate(rda->system()->sampleRate());
settings->setBitRate(evt->bitrate());
settings->setNormalizationLevel(evt->normalizeLevel()/100);
LogLine(RDConfig::LogInfo,QString().

View File

@ -2,7 +2,7 @@
//
// Local macros for the Rivendell netcatcher daemon
//
// (C) Copyright 2002-2009,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2009,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -18,10 +18,11 @@
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <rdapplication.h>
#include <rdcart.h>
#include <rduser.h>
#include <rdcatchd.h>
#include "rdcatchd.h"
void MainObject::RunLocalMacros(RDMacro *rml)
{
@ -39,7 +40,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
QDateTime dt;
RDUser *user;
bool ok=false;
CatchEvent e(catch_rdstation,RDConfiguration());
CatchEvent e(rda->station(),RDConfiguration());
unsigned event_ptr=0;
QString sql;
RDSqlQuery *q;
@ -67,7 +68,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
}
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -75,7 +76,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
}
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
break;
@ -88,22 +89,22 @@ void MainObject::RunLocalMacros(RDMacro *rml)
(dst_cartnum<1)||(dst_cartnum>RD_MAX_CART_NUMBER)||
(cutnum<1)||(cutnum>RD_MAX_CUT_NUMBER)||
(dst_cutnum<1)||(dst_cutnum>RD_MAX_CUT_NUMBER)||
(catch_ripc->user().isEmpty())) {
(rda->ripc()->user().isEmpty())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
user=new RDUser(catch_ripc->user());
user=new RDUser(rda->ripc()->user());
cut=new RDCut(cartnum,cutnum);
ok=cut->copyTo(catch_rdstation,user,RDCut::cutName(dst_cartnum,dst_cutnum),
catch_config);
ok=cut->copyTo(rda->station(),user,RDCut::cutName(dst_cartnum,dst_cutnum),
rda->config());
delete cut;
delete user;
if(rml->echoRequested()) {
rml->acknowledge(ok);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
break;
@ -113,7 +114,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
if(ExecuteMacroCart(cart)) {
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
delete cart;
return;
@ -122,7 +123,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
else {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
}
delete cart;
@ -136,7 +137,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
if(rml->argQuantity()!=4) {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -148,18 +149,18 @@ void MainObject::RunLocalMacros(RDMacro *rml)
||len==0) {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
cut=new RDCut(cartnum,cutnum);
deck=new RDDeck(catch_config->stationName(),chan);
deck=new RDDeck(rda->config()->stationName(),chan);
if((!cut->exists())||(!deck->isActive())) {
delete cut;
delete deck;
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -174,7 +175,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
catch_record_pending_maxlen[chan-1]=len;
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -184,7 +185,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
chan));
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -196,7 +197,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
StartRmlRecording(chan,cartnum,cutnum,len);
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
break;
@ -204,7 +205,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
if(rml->argQuantity()!=1) {
if(rml->echoRequested()) {
rml->acknowledge(false);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
return;
}
@ -213,8 +214,8 @@ void MainObject::RunLocalMacros(RDMacro *rml)
switch(catch_record_deck_status[chan-1]) {
case RDDeck::Recording:
catch_record_aborting[chan-1]=true;
catch_cae->stopRecord(catch_record_card[chan-1],
catch_record_stream[chan-1]);
rda->cae()->stopRecord(catch_record_card[chan-1],
catch_record_stream[chan-1]);
break;
case RDDeck::Waiting:
@ -227,7 +228,7 @@ void MainObject::RunLocalMacros(RDMacro *rml)
}
if(rml->echoRequested()) {
rml->acknowledge(true);
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
}
break;

View File

@ -2,7 +2,7 @@
//
// The Rivendell Netcatcher Daemon
//
// (C) Copyright 2002-2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -42,8 +42,8 @@
#include <qsessionmanager.h>
#include <dbversion.h>
#include <rdapplication.h>
#include <rdcatchd_socket.h>
#include <rdcatchd.h>
#include <rdcheck_daemons.h>
#include <rdconf.h>
#include <rdcut.h>
@ -63,8 +63,7 @@
#include <rdurl.h>
#include <rdwavefile.h>
RDConfig *catch_config;
#include "rdcatchd.h"
// Logging function that works within and outside the MainObject.
//static RDConfig *rd_config = NULL;
@ -72,18 +71,18 @@ void LogLine(RDConfig::LogPriority prio,const QString &line)
{
FILE *logfile;
catch_config->log("rdcatchd",prio,line);
rda->config()->log("rdcatchd",prio,line);
if(catch_config->catchdLogname().isEmpty()) {
if(rda->config()->catchdLogname().isEmpty()) {
return;
}
QDateTime current=QDateTime::currentDateTime();
logfile=fopen(catch_config->catchdLogname(),"a");
logfile=fopen(rda->config()->catchdLogname(),"a");
if(logfile==NULL) {
return;
}
chmod(catch_config->catchdLogname(),S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
chmod(rda->config()->catchdLogname(),S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
fprintf(logfile,"%02d/%02d/%4d - %02d:%02d:%02d.%03d : %s\n",
current.date().month(),
current.date().day(),
@ -106,7 +105,6 @@ void SigHandler(int signum)
case SIGTERM:
RDDeletePid(RD_PID_DIR,"rdcatchd.pid");
LogLine(RDConfig::LogNotice,"rdcatchd exiting");
delete catch_config;
exit(0);
break;
@ -126,28 +124,29 @@ MainObject::MainObject(QObject *parent)
{
QString sql;
RDSqlQuery *q;
bool skip_db_check=false;
unsigned schema=0;
QString err_msg;
//
// Load the config
// Open the Database
//
catch_config=new RDConfig();
catch_config->load();
catch_config->setModuleName("rdcatchd");
rda=new RDApplication("rdcatchd","rdcatchd",RDCATCHD_USAGE,this);
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdcatchd: %s\n",(const char *)err_msg);
exit(1);
}
//
// Read Command Options
//
RDCmdSwitch *cmd=
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcatchd",RDCATCHD_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--event-id") {
RunBatch(cmd);
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
if(rda->cmdSwitch()->key(i)=="--event-id") {
RunBatch(rda->cmdSwitch());
return;
}
if(cmd->key(i)=="--skip-db-check") {
skip_db_check=true;
if(!rda->cmdSwitch()->processed(i)) {
fprintf(stderr,"rdcatchdd: unknown command option \"%s\"\n",
(const char *)rda->cmdSwitch()->key(i));
exit(2);
}
}
@ -215,29 +214,13 @@ MainObject::MainObject(QObject *parent)
}
connect(server,SIGNAL(connection(int)),this,SLOT(newConnection(int)));
//
// Open Database
//
QString err (tr("ERROR rdcatchd aborting - "));
catch_db=RDInitDb(&schema,&err);
if(!catch_db) {
printf(err.ascii());
exit(1);
}
if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) {
fprintf(stderr,
"rdcatchd: database version mismatch, should be %u, is %u\n",
RD_VERSION_DATABASE,schema);
exit(256);
}
connect (RDDbStatus(),SIGNAL(logText(RDConfig::LogPriority,const QString &)),
this,SLOT(log(RDConfig::LogPriority,const QString &)));
//
// Create RDCatchConf
//
catch_conf=new RDCatchConf(catch_config->stationName());
catch_conf=new RDCatchConf(rda->config()->stationName());
//
// GPI Mappers
@ -255,58 +238,46 @@ MainObject::MainObject(QObject *parent)
catch_xload_timer=new QTimer(this);
connect(catch_xload_timer,SIGNAL(timeout()),this,SLOT(updateXloadsData()));
//
// Station Configuration
//
catch_rdstation=new RDStation(catch_config->stationName());
//
// RIPCD Connection
//
catch_ripc=new RDRipc(catch_rdstation,catch_config,this);
catch_ripc->connectHost("localhost",RIPCD_TCP_PORT,catch_config->password());
connect(catch_ripc,SIGNAL(rmlReceived(RDMacro *)),
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
connect(rda->ripc(),SIGNAL(rmlReceived(RDMacro *)),
this,SLOT(rmlReceivedData(RDMacro *)));
connect(catch_ripc,SIGNAL(gpiStateChanged(int,int,bool)),
connect(rda->ripc(),SIGNAL(gpiStateChanged(int,int,bool)),
this,SLOT(gpiStateChangedData(int,int,bool)));
//
// System Configuration
//
catch_system=new RDSystem();
//
// CAE Connection
//
catch_cae=new RDCae(catch_rdstation,catch_config,this);
connect(catch_cae,SIGNAL(isConnected(bool)),
connect(rda->cae(),SIGNAL(isConnected(bool)),
this,SLOT(isConnectedData(bool)));
connect(catch_cae,SIGNAL(recordLoaded(int,int)),
connect(rda->cae(),SIGNAL(recordLoaded(int,int)),
this,SLOT(recordLoadedData(int,int)));
connect(catch_cae,SIGNAL(recording(int,int)),
connect(rda->cae(),SIGNAL(recording(int,int)),
this,SLOT(recordingData(int,int)));
connect(catch_cae,SIGNAL(recordStopped(int,int)),
connect(rda->cae(),SIGNAL(recordStopped(int,int)),
this,SLOT(recordStoppedData(int,int)));
connect(catch_cae,SIGNAL(recordUnloaded(int,int,unsigned)),
connect(rda->cae(),SIGNAL(recordUnloaded(int,int,unsigned)),
this,SLOT(recordUnloadedData(int,int,unsigned)));
connect(catch_cae,SIGNAL(playLoaded(int)),
connect(rda->cae(),SIGNAL(playLoaded(int)),
this,SLOT(playLoadedData(int)));
connect(catch_cae,SIGNAL(playing(int)),
connect(rda->cae(),SIGNAL(playing(int)),
this,SLOT(playingData(int)));
connect(catch_cae,SIGNAL(playStopped(int)),
connect(rda->cae(),SIGNAL(playStopped(int)),
this,SLOT(playStoppedData(int)));
connect(catch_cae,SIGNAL(playUnloaded(int)),
connect(rda->cae(),SIGNAL(playUnloaded(int)),
this,SLOT(playUnloadedData(int)));
catch_cae->connectHost();
rda->cae()->connectHost();
//
// Sound Initialization
//
RDSetMixerPorts(catch_config->stationName(),catch_cae);
RDSetMixerPorts(rda->config()->stationName(),rda->cae());
sql=QString().sprintf("select CHANNEL,CARD_NUMBER,PORT_NUMBER from DECKS \
where (STATION_NAME=\"%s\")&&\
(CARD_NUMBER!=-1)&&(CHANNEL>0)&&(CHANNEL<9)",
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
q=new RDSqlQuery(sql);
while(q->next()) {
if((q->value(1).toInt()>=0)&&(q->value(2).toInt()>=0)) {
@ -324,11 +295,11 @@ MainObject::MainObject(QObject *parent)
where (STATION_NAME=\"%s\")&&(CHANNEL<=%d)&&\
(CARD_NUMBER>=0)&&(MON_PORT_NUMBER>=0)&&\
(DEFAULT_MONITOR_ON=\"Y\")",
(const char *)catch_config->stationName(),
(const char *)rda->config()->stationName(),
MAX_DECKS);
q=new RDSqlQuery(sql);
while(q->next()) {
catch_cae->setPassthroughVolume(q->value(0).toInt(),q->value(1).toInt(),
rda->cae()->setPassthroughVolume(q->value(0).toInt(),q->value(1).toInt(),
q->value(2).toInt(),0);
catch_monitor_state[q->value(3).toUInt()-1]=true;
}
@ -340,7 +311,7 @@ MainObject::MainObject(QObject *parent)
// Playout Event Players
//
for(unsigned i=0;i<MAX_DECKS;i++) {
catch_playout_event_player[i]=new EventPlayer(catch_rdstation,i+129,this);
catch_playout_event_player[i]=new EventPlayer(rda->station(),i+129,this);
connect(catch_playout_event_player[i],SIGNAL(runCart(int,int,unsigned)),
this,SLOT(runCartData(int,int,unsigned)));
}
@ -349,12 +320,12 @@ MainObject::MainObject(QObject *parent)
// Time Engine
//
catch_engine=new RDTimeEngine(this);
catch_engine->setTimeOffset(catch_rdstation->timeOffset());
catch_engine->setTimeOffset(rda->station()->timeOffset());
connect(catch_engine,SIGNAL(timeout(int)),this,SLOT(engineData(int)));
LoadEngine();
if(qApp->argc()==1) {
RDDetach(catch_config->logCoreDumpDirectory());
RDDetach(rda->config()->logCoreDumpDirectory());
}
else {
debug=true;
@ -400,7 +371,7 @@ MainObject::MainObject(QObject *parent)
RDRecording::Uploading,
RDRecording::Downloading,
RDRecording::RecordActive,
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
q=new RDSqlQuery(sql);
delete q;
sql=QString().sprintf("update RECORDINGS set EXIT_CODE=%d\
@ -409,7 +380,7 @@ MainObject::MainObject(QObject *parent)
RDRecording::Ok,
RDRecording::Waiting,
RDRecording::PlayActive,
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
q=new RDSqlQuery(sql);
delete q;
@ -423,11 +394,11 @@ MainObject::MainObject(QObject *parent)
//
// Set Realtime Permissions
//
if(catch_config->useRealtime()) {
if(rda->config()->useRealtime()) {
struct sched_param sp;
memset(&sp,0,sizeof(sp));
if(catch_config->realtimePriority()>0) {
sp.sched_priority=catch_config->realtimePriority()-1;
if(rda->config()->realtimePriority()>0) {
sp.sched_priority=rda->config()->realtimePriority()-1;
}
if(sched_setscheduler(getpid(),SCHED_FIFO,&sp)!=0) {
LogLine(RDConfig::LogWarning,
@ -533,7 +504,7 @@ void MainObject::gpiStateChangedData(int matrix,int line,bool state)
}
}
if(!handled) {
catch_cae->
rda->cae()->
stopRecord(catch_record_card[catch_events[i].channel()-1],
catch_record_stream[catch_events[i].channel()-1]);
}
@ -658,7 +629,7 @@ void MainObject::engineData(int id)
SWITCH_STATION,SWITCH_MATRIX,SWITCH_OUTPUT, \
SWITCH_DELAY from DECKS \
where (STATION_NAME=\"%s\")&&(CHANNEL=%d)",
(const char *)catch_config->stationName(),
(const char *)rda->config()->stationName(),
catch_events[event].channel());
q=new RDSqlQuery(sql);
if(q->first()) {
@ -741,7 +712,7 @@ void MainObject::engineData(int id)
catch_playout_stream[catch_events[event].channel()-129]=-1;
sql=QString().sprintf("select CARD_NUMBER,PORT_NUMBER,PORT_NUMBER \
from DECKS where (STATION_NAME=\"%s\")&&(CHANNEL=%d)",
(const char *)catch_config->stationName(),
(const char *)rda->config()->stationName(),
catch_events[event].channel());
q=new RDSqlQuery(sql);
if(q->first()) {
@ -801,7 +772,7 @@ void MainObject::engineData(int id)
DEFAULT_SAMPRATE,DEFAULT_LAYER,DEFAULT_BITRATE, \
RIPPER_LEVEL \
from RDLIBRARY where STATION=\"%s\"",
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
q=new RDSqlQuery(sql);
if(q->first())
{
@ -822,7 +793,7 @@ void MainObject::engineData(int id)
catch_events[event].
setResolvedUrl(RDDateTimeDecode(catch_events[event].url(),
QDateTime(date.addDays(catch_events[event].eventdateOffset()),
current_time),catch_rdstation,RDConfiguration()));
current_time),rda->station(),RDConfiguration()));
StartDownloadEvent(event);
break;
@ -912,7 +883,7 @@ void MainObject::recordStoppedData(int card,int stream)
printf("Stopped - Card: %d Stream: %d\n",card,stream);
}
SendMeterLevel(deck-1,levels);
catch_cae->unloadRecord(card,stream);
rda->cae()->unloadRecord(card,stream);
}
@ -1034,7 +1005,7 @@ void MainObject::playStoppedData(int handle)
catch_playout_stream[deck-129]);
}
SendMeterLevel(deck,levels);
catch_cae->unloadPlay(handle);
rda->cae()->unloadPlay(handle);
}
@ -1080,12 +1051,12 @@ void MainObject::meterData()
for(int i=0;i<MAX_DECKS;i++) {
if(catch_record_deck_status[i]==RDDeck::Recording) {
catch_cae->inputMeterUpdate(catch_record_card[i],catch_record_stream[i],
rda->cae()->inputMeterUpdate(catch_record_card[i],catch_record_stream[i],
levels);
SendMeterLevel(i+1,levels);
}
if(catch_playout_deck_status[i]==RDDeck::Recording) {
catch_cae->
rda->cae()->
outputMeterUpdate(catch_playout_card[i],catch_playout_port[i],
levels);
SendMeterLevel(i+129,levels);
@ -1175,7 +1146,7 @@ void MainObject::updateXloadsData()
void MainObject::startupCartData()
{
unsigned cartnum=catch_rdstation->startupCart();
unsigned cartnum=rda->station()->startupCart();
if(cartnum>0) {
RDCart *cart=new RDCart(cartnum);
if(cart->exists()) {
@ -1270,7 +1241,7 @@ bool MainObject::StartRecording(int event)
rml->setArg(2,catch_swoutput[deck-1]);
char str[RD_RML_MAX_LENGTH];
if(rml->generateString(str,RD_RML_MAX_LENGTH)) {
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
LogLine(RDConfig::LogDebug,QString().
sprintf("sending switcher command: %s",str));
}
@ -1299,14 +1270,14 @@ bool MainObject::StartRecording(int event)
//
// Start the recording
//
catch_cae->loadRecord(catch_record_card[deck-1],
rda->cae()->loadRecord(catch_record_card[deck-1],
catch_record_stream[deck-1],
cut_name,
format,
catch_events[event].channels(),
catch_events[event].sampleRate(),
catch_events[event].bitrate());
catch_cae->record(catch_record_card[deck-1],catch_record_stream[deck-1],
rda->cae()->record(catch_record_card[deck-1],catch_record_stream[deck-1],
length,0);
catch_events[event].setStatus(RDDeck::Recording);
@ -1330,7 +1301,7 @@ bool MainObject::StartRecording(int event)
//
RDCut *cut=new RDCut(catch_events[event].cutName());
cut->setOriginDatetime(QDateTime::currentDateTime());
cut->setOriginName(catch_config->stationName());
cut->setOriginName(rda->config()->stationName());
switch(catch_events[event].format()) {
case RDCae::Pcm16:
cut->setCodingFormat(0);
@ -1405,18 +1376,18 @@ void MainObject::StartPlayout(int event)
// Start the playout
//
catch_playout_event_player[deck-129]->load(catch_events[event].cutName());
catch_cae->loadPlay(catch_playout_card[deck-129],
rda->cae()->loadPlay(catch_playout_card[deck-129],
catch_events[event].cutName(),
&catch_playout_stream[deck-129],
&catch_playout_handle[deck-129]);
RDSetMixerOutputPort(catch_cae,catch_playout_card[deck-129],
RDSetMixerOutputPort(rda->cae(),catch_playout_card[deck-129],
catch_playout_stream[deck-129],
catch_playout_port[deck-129]);
catch_cae->positionPlay(catch_playout_handle[deck-129],start);
rda->cae()->positionPlay(catch_playout_handle[deck-129],start);
catch_playout_event_player[deck-129]->start(start);
catch_cae->
rda->cae()->
play(catch_playout_handle[deck-129],end-start,RD_TIMESCALE_DIVISOR,0);
catch_cae->setPlayPortActive(catch_playout_card[deck-129],
rda->cae()->setPlayPortActive(catch_playout_card[deck-129],
catch_playout_port[deck-129],
catch_playout_stream[deck-129]);
catch_events[event].setStatus(RDDeck::Recording);
@ -1468,7 +1439,7 @@ void MainObject::StartSwitchEvent(int event)
char cmd[RD_RML_MAX_LENGTH];
RDMacro *rml=new RDMacro();
rml->setAddress(catch_rdstation->address());
rml->setAddress(rda->station()->address());
rml->setRole(RDMacro::Cmd);
rml->setEchoRequested(false);
rml->setCommand(RDMacro::ST);
@ -1479,7 +1450,7 @@ void MainObject::StartSwitchEvent(int event)
rml->generateString(cmd,RD_RML_MAX_LENGTH);
LogLine(RDConfig::LogInfo,QString().
sprintf("sent switch event, rml: %s",cmd));
catch_ripc->sendRml(rml);
rda->ripc()->sendRml(rml);
delete rml;
if(catch_events[event].oneShot()) {
PurgeEvent(event);
@ -1529,7 +1500,7 @@ bool MainObject::ExecuteMacroCart(RDCart *cart,int id,int event)
}
catch_macro_event_id[event_id]=id;
catch_event_pool[event_id]=
new RDMacroEvent(catch_rdstation->address(),catch_ripc,this,"event");
new RDMacroEvent(rda->station()->address(),rda->ripc(),this,"event");
catch_event_mapper->setMapping(catch_event_pool[event_id],event_id);
connect(catch_event_pool[event_id],SIGNAL(finished()),
catch_event_mapper,SLOT(map()));
@ -1655,7 +1626,7 @@ void MainObject::DispatchCommand(int ch)
return;
}
if(!strcmp(args[ch][0],"PW")) { // Password Authenticate
if(!strcmp(args[ch][1],catch_config->password())) {
if(!strcmp(args[ch][1],rda->config()->password())) {
auth[ch]=true;
EchoCommand(ch,"PW +!");
return;
@ -1713,7 +1684,7 @@ void MainObject::DispatchCommand(int ch)
if(!strcmp(args[ch][0],"RO")) { // Reload Time Offset
EchoArgs(ch,'+');
catch_engine->setTimeOffset(catch_rdstation->timeOffset());
catch_engine->setTimeOffset(rda->station()->timeOffset());
}
if(!strcmp(args[ch][0],"RE")) { // Request Status
@ -1770,7 +1741,7 @@ void MainObject::DispatchCommand(int ch)
switch(catch_record_deck_status[chan-1]) {
case RDDeck::Recording:
catch_record_aborting[chan-1]=true;
catch_cae->stopRecord(catch_record_card[chan-1],
rda->cae()->stopRecord(catch_record_card[chan-1],
catch_record_stream[chan-1]);
break;
@ -1785,7 +1756,7 @@ void MainObject::DispatchCommand(int ch)
if((chan>128)&&(chan<(MAX_DECKS+129))) {
switch(catch_playout_deck_status[chan-129]) {
case RDDeck::Recording:
catch_cae->stopPlay(catch_playout_handle[chan-129]);
rda->cae()->stopPlay(catch_playout_handle[chan-129]);
break;
default:
@ -1809,14 +1780,14 @@ void MainObject::DispatchCommand(int ch)
if((chan>0)&&(chan<(MAX_DECKS+1))) {
if(catch_monitor_port[chan-1]>=0) {
if(args[ch][2][0]=='1') {
catch_cae->setPassthroughVolume(catch_record_card[chan-1],
rda->cae()->setPassthroughVolume(catch_record_card[chan-1],
catch_record_stream[chan-1],
catch_monitor_port[chan-1],0);
catch_monitor_state[chan-1]=true;
BroadcastCommand(QString().sprintf("MN %d 1!",chan));
}
else {
catch_cae->setPassthroughVolume(catch_record_card[chan-1],
rda->cae()->setPassthroughVolume(catch_record_card[chan-1],
catch_record_stream[chan-1],
catch_monitor_port[chan-1],
RD_MUTE_DEPTH);
@ -1916,10 +1887,10 @@ void MainObject::LoadEngine(bool adv_day)
catch_events.clear();
LogLine(RDConfig::LogInfo,"rdcatchd engine load starts...");
sql=LoadEventSql()+QString().sprintf(" where STATION_NAME=\"%s\"",
(const char *)catch_rdstation->name());
(const char *)rda->station()->name());
q=new RDSqlQuery(sql);
while(q->next()) {
catch_events.push_back(CatchEvent(catch_rdstation,RDConfiguration()));
catch_events.push_back(CatchEvent(rda->station(),RDConfiguration()));
LoadEvent(q,&catch_events.back(),true);
}
LogLine(RDConfig::LogInfo,QString().sprintf("loaded %d events",(int)catch_events.size()));
@ -2028,7 +1999,7 @@ void MainObject::LoadEvent(RDSqlQuery *q,CatchEvent *e,bool add)
break;
}
e->setChannels(q->value(20).toInt());
e->setSampleRate(catch_system->sampleRate());
e->setSampleRate(rda->system()->sampleRate());
//e->setSampleRate(q->value(21).toInt());
e->setBitrate(q->value(22).toInt());
e->setMacroCart(q->value(23).toInt());
@ -2088,7 +2059,7 @@ void MainObject::LoadDeckList()
MON_PORT_NUMBER from DECKS \
where (STATION_NAME=\"%s\")&&\
(CARD_NUMBER!=-1)&&(CHANNEL>0)&&(CHANNEL<9)",
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
status[q->value(0).toUInt()-1]=RDDeck::Idle;
@ -2103,7 +2074,7 @@ void MainObject::LoadDeckList()
catch_record_deck_status[i]=RDDeck::Recording;
}
else {
catch_cae->stopRecord(catch_record_card[i],catch_record_stream[i]);
rda->cae()->stopRecord(catch_record_card[i],catch_record_stream[i]);
catch_record_deck_status[i]=RDDeck::Offline;
}
}
@ -2120,7 +2091,7 @@ void MainObject::LoadDeckList()
}
sql=QString().sprintf("select CHANNEL from DECKS \
where (STATION_NAME=\"%s\")&&(CARD_NUMBER!=-1)&&(CHANNEL>128)&&(CHANNEL<137)",
(const char *)catch_config->stationName());
(const char *)rda->config()->stationName());
q=new RDSqlQuery(sql);
while(q->next()) {
status[q->value(0).toUInt()-129]=RDDeck::Idle;
@ -2132,7 +2103,7 @@ where (STATION_NAME=\"%s\")&&(CARD_NUMBER!=-1)&&(CHANNEL>128)&&(CHANNEL<137)",
catch_playout_deck_status[i]=RDDeck::Recording;
}
else {
catch_cae->stopPlay(catch_playout_handle[i]);
rda->cae()->stopPlay(catch_playout_handle[i]);
catch_playout_deck_status[i]=RDDeck::Offline;
}
}
@ -2189,10 +2160,10 @@ bool MainObject::AddEvent(int id)
//
sql=LoadEventSql()+
QString().sprintf(" where (STATION_NAME=\"%s\")&&(ID=%d)",
(const char *)catch_rdstation->name(),id);
(const char *)rda->station()->name(),id);
q=new RDSqlQuery(sql);
if(q->first()) {
catch_events.push_back(CatchEvent(catch_rdstation,RDConfiguration()));
catch_events.push_back(CatchEvent(rda->station(),RDConfiguration()));
LoadEvent(q,&catch_events.back(),true);
switch((RDRecording::Type)q->value(2).toInt()) {
case RDRecording::Recording:
@ -2389,7 +2360,7 @@ void MainObject::LoadHeartbeat()
}
QString sql=QString().sprintf("select HEARTBEAT_CART,HEARTBEAT_INTERVAL\
from STATIONS where NAME=\"%s\"",
(const char *)catch_rdstation->name());
(const char *)rda->station()->name());
RDSqlQuery *q=new RDSqlQuery(sql);
if(q->first()) {
if((q->value(0).toUInt()!=0)&&(q->value(1).toUInt()!=0)) {
@ -2411,8 +2382,8 @@ void MainObject::CheckInRecording(QString cutname,CatchEvent *evt,
s->setSampleRate(evt->sampleRate());
s->setBitRate(evt->bitrate());
s->setChannels(evt->channels());
cut->checkInRecording(catch_config->stationName(),"",
catch_config->stationName(),s,msecs);
cut->checkInRecording(rda->config()->stationName(),"",
rda->config()->stationName(),s,msecs);
cut->setSha1Hash(RDSha1Hash(RDCut::pathName(cut->cutName())));
delete s;
cut->autoTrim(RDCut::AudioBoth,-threshold);
@ -2420,7 +2391,7 @@ void MainObject::CheckInRecording(QString cutname,CatchEvent *evt,
cart->updateLength();
delete cart;
delete cut;
chown(RDCut::pathName(cutname),catch_config->uid(),catch_config->gid());
chown(RDCut::pathName(cutname),rda->config()->uid(),rda->config()->gid());
}
@ -2610,7 +2581,7 @@ bool MainObject::SendErrorMessage(CatchEvent *event,const QString &err_desc,
}
catch_macro_event_id[event_id]=event->id()+RDCATCHD_ERROR_ID_OFFSET;
catch_event_pool[event_id]=
new RDMacroEvent(catch_rdstation->address(),catch_ripc,this,"event");
new RDMacroEvent(rda->station()->address(),rda->ripc(),this,"event");
catch_event_mapper->setMapping(catch_event_pool[event_id],event_id);
connect(catch_event_pool[event_id],SIGNAL(finished()),
catch_event_mapper,SLOT(map()));
@ -2701,10 +2672,10 @@ void MainObject::RunRmlRecordingCache(int chan)
void MainObject::StartRmlRecording(int chan,int cartnum,int cutnum,int maxlen)
{
RDDeck *deck=new RDDeck(catch_config->stationName(),chan);
RDDeck *deck=new RDDeck(rda->config()->stationName(),chan);
RDCut *cut=new RDCut(cartnum,cutnum);
QDateTime dt=QDateTime(QDate::currentDate(),QTime::currentTime());
catch_events.push_back(CatchEvent(catch_rdstation,RDConfiguration()));
catch_events.push_back(CatchEvent(rda->station(),RDConfiguration()));
catch_events.back().setId(GetNextDynamicId());
catch_events.back().setIsActive(true);
catch_events.back().setOneShot(true);
@ -2718,7 +2689,7 @@ void MainObject::StartRmlRecording(int chan,int cartnum,int cutnum,int maxlen)
catch_events.back().
setFormat((RDCae::AudioCoding)deck->defaultFormat());
catch_events.back().setChannels(deck->defaultChannels());
catch_events.back().setSampleRate(catch_system->sampleRate());
catch_events.back().setSampleRate(rda->system()->sampleRate());
catch_events.back().setBitrate(deck->defaultBitrate());
catch_events.back().setNormalizeLevel(0);
StartRecording(catch_events.size()-1);

View File

@ -35,23 +35,17 @@
#include <qhostaddress.h>
#include <qsignalmapper.h>
#include <rdsocket.h>
#include <rdtimeengine.h>
#include <rd.h>
#include <rdcae.h>
#include <rdcart.h>
#include <rddeck.h>
#include <rdtty.h>
#include <rdripc.h>
#include <rdsystem.h>
#include <rdstation.h>
#include <rdmacro_event.h>
#include <rdconfig.h>
#include <rdcatch_conf.h>
#include <rdconfig.h>
#include <rdcmd_switch.h>
#include <rdcatch_connect.h>
#include <rdcmd_switch.h>
#include <rddeck.h>
#include <rdmacro_event.h>
#include <rdsocket.h>
#include <rdsettings.h>
#include <rdtimeengine.h>
#include <rdtty.h>
#include "catch_event.h"
#include "event_player.h"
@ -67,14 +61,12 @@
#define RDCATCHD_FREE_EVENTS_INTERVAL 1000
#define RDCATCHD_HEARTBEAT_INTERVAL 10000
#define RDCATCHD_ERROR_ID_OFFSET 1000000
extern RDConfig *catch_config;
//
// Function Prototypes
//
void LogLine(RDConfig::LogPriority prio,const QString &line);
class MainObject : public QObject
{
Q_OBJECT
@ -186,15 +178,10 @@ class MainObject : public QObject
void StartRmlRecording(int chan,int cartnum,int cutnum,int maxlen);
void StartBatch(int id);
QString GetTempRecordingName(int id) const;
QSqlDatabase *catch_db;
RDSystem *catch_system;
RDStation *catch_rdstation;
RDRipc *catch_ripc;
QString catch_default_user;
QString catch_host;
bool debug;
RDTimeEngine *catch_engine;
RDCae *catch_cae;
Q_INT16 tcp_port;
QServerSocket *server;
RDCatchConnect *catch_connect;

View File

@ -2,7 +2,7 @@
//
// The Rivendell Netcatcher Daemon Dropbox methods
//
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@ -20,6 +20,7 @@
#include <stdlib.h>
#include <rdapplication.h>
#include <rddb.h>
#include <rdescape_string.h>
@ -64,7 +65,7 @@ void MainObject::StartDropboxes()
"SEGUE_LEVEL,"+ // 21
"SEGUE_LENGTH "+ // 22
"from DROPBOXES where "+
"STATION_NAME=\""+RDEscapeString(catch_config->stationName())+"\"";
"STATION_NAME=\""+RDEscapeString(rda->config()->stationName())+"\"";
q=new RDSqlQuery(sql);
while(q->next()) {
QString cmd=QString().

View File

@ -348,7 +348,7 @@ bool CitadelXds::PostCut(const QString &cutname,const QString &filename)
}
RDSettings *settings=new RDSettings();
QString tempfile=RDTempDirectory::basePath()+"/"+filename;
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
RDAudioConvert *conv=new RDAudioConvert();
conv->setSourceFile(RDCut::pathName(cutname));
conv->setDestinationFile(tempfile);
conv->setRange(cut->startPoint(),cut->endPoint());

View File

@ -179,7 +179,7 @@ MainObject::MainObject(QObject *parent)
exit(256);
}
RDAudioConvert *conv=new RDAudioConvert(rdconfig->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(source_filename);
conv->setDestinationFile(destination_filename);
conv->setDestinationSettings(destination_settings);

View File

@ -186,7 +186,7 @@ MainObject::MainObject(QObject *parent)
exit(256);
}
RDAudioConvert *conv=new RDAudioConvert(rdconfig->stationName(),this);
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(source_filename);
conv->setDestinationFile(destination_filename);
conv->setDestinationSettings(destination_settings);

View File

@ -146,7 +146,7 @@ void Xport::Export()
XmlExit("unable to create temporary directory ["+err_msg+"]",500);
}
QString tmpfile=tempdir->path()+"/exported_audio";
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(RDCut::pathName(cartnum,cutnum));
conv->setDestinationFile(tmpfile);
conv->setDestinationSettings(settings);

View File

@ -201,7 +201,7 @@ void Xport::Import()
XmlExit("Duplicate Cart Title Not Allowed",404,"import.cpp",LINE_NUMBER);
}
}
RDAudioConvert *conv=new RDAudioConvert(rda->config()->stationName());
RDAudioConvert *conv=new RDAudioConvert(this);
conv->setSourceFile(filename);
conv->setDestinationFile(RDCut::pathName(cartnum,cutnum));
conv->setDestinationSettings(settings);