mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-25 14:50:11 +01:00
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted rdmarkerset(8) to use RDApplication.
This commit is contained in:
@@ -16639,3 +16639,5 @@
|
|||||||
* Converted rdimport(1) to use RDApplication.
|
* Converted rdimport(1) to use RDApplication.
|
||||||
2018-02-02 Fred Gleason <fredg@paravelsystems.com>
|
2018-02-02 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Converted rdmaint(1) to use RDApplication.
|
* Converted rdmaint(1) to use RDApplication.
|
||||||
|
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Converted rdmarkerset(8) to use RDApplication.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Command-line tool for setting Rivendell Cut Markers
|
// Command-line tool for setting Rivendell Cut Markers
|
||||||
//
|
//
|
||||||
// (C) Copyright 2014,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2014,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -30,73 +30,78 @@
|
|||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
|
|
||||||
#include <rddb.h>
|
|
||||||
#include <rd.h>
|
#include <rd.h>
|
||||||
#include <rdmarkerset.h>
|
#include <rdapplication.h>
|
||||||
|
#include <rdaudioinfo.h>
|
||||||
|
#include <rddb.h>
|
||||||
#include <rdcart.h>
|
#include <rdcart.h>
|
||||||
#include <rdcut.h>
|
|
||||||
#include <rdlog.h>
|
|
||||||
#include <rdcreate_log.h>
|
#include <rdcreate_log.h>
|
||||||
|
#include <rdcut.h>
|
||||||
#include <rdescape_string.h>
|
#include <rdescape_string.h>
|
||||||
#include <rdgroup.h>
|
#include <rdgroup.h>
|
||||||
#include <rdwavefile.h>
|
#include <rdlog.h>
|
||||||
#include <rdaudioinfo.h>
|
|
||||||
#include <rdtrimaudio.h>
|
#include <rdtrimaudio.h>
|
||||||
#include <dbversion.h>
|
#include <rdwavefile.h>
|
||||||
|
|
||||||
|
#include "rdmarkerset.h"
|
||||||
|
|
||||||
MainObject::MainObject(QObject *parent)
|
MainObject::MainObject(QObject *parent)
|
||||||
:QObject(parent)
|
:QObject(parent)
|
||||||
{
|
{
|
||||||
bool ok=false;
|
bool ok=false;
|
||||||
bool skip_db_check=false;
|
QString err_msg;
|
||||||
unsigned schema=0;
|
|
||||||
set_all_groups=false;
|
set_all_groups=false;
|
||||||
set_auto_trim=1;
|
set_auto_trim=1;
|
||||||
set_verbose=false;
|
set_verbose=false;
|
||||||
set_auto_trim=1;
|
set_auto_trim=1;
|
||||||
set_auto_segue=1;
|
set_auto_segue=1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the Database
|
||||||
|
//
|
||||||
|
rda=new RDApplication("rdmarkerset","rdmarkerset",RDMARKERSET_USAGE,this);
|
||||||
|
if(!rda->open(&err_msg)) {
|
||||||
|
fprintf(stderr,"rdmarkerset: %s\n",(const char *)err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
//
|
//
|
||||||
RDCmdSwitch *cmd=
|
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdmarkerset",RDMARKERSET_USAGE);
|
if(rda->cmdSwitch()->key(i)=="--all-groups") {
|
||||||
for(unsigned i=0;i<cmd->keys();i++) {
|
|
||||||
if(cmd->key(i)=="--skip-db-check") {
|
|
||||||
skip_db_check=true;
|
|
||||||
cmd->setProcessed(i,true);
|
|
||||||
}
|
|
||||||
if(cmd->key(i)=="--all-groups") {
|
|
||||||
set_all_groups=true;
|
set_all_groups=true;
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--group") {
|
if(rda->cmdSwitch()->key(i)=="--group") {
|
||||||
set_group_names.push_back(cmd->value(i));
|
set_group_names.push_back(rda->cmdSwitch()->value(i));
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--auto-trim") {
|
if(rda->cmdSwitch()->key(i)=="--auto-trim") {
|
||||||
set_auto_trim=cmd->value(i).toInt(&ok);
|
set_auto_trim=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if((!ok)||(set_auto_trim>0)) {
|
if((!ok)||(set_auto_trim>0)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"rdmarkerset: invalid level value specified for --auto-trim\n");
|
"rdmarkerset: invalid level value specified for --auto-trim\n");
|
||||||
}
|
}
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--auto-segue") {
|
if(rda->cmdSwitch()->key(i)=="--auto-segue") {
|
||||||
set_auto_segue=cmd->value(i).toInt(&ok);
|
set_auto_segue=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||||
if((!ok)||(set_auto_segue>0)) {
|
if((!ok)||(set_auto_segue>0)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"rdmarkerset: invalid level value specified for --auto-segue\n");
|
"rdmarkerset: invalid level value specified for --auto-segue\n");
|
||||||
}
|
}
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(cmd->key(i)=="--verbose") {
|
if(rda->cmdSwitch()->key(i)=="--verbose") {
|
||||||
set_verbose=true;
|
set_verbose=true;
|
||||||
cmd->setProcessed(i,true);
|
rda->cmdSwitch()->setProcessed(i,true);
|
||||||
}
|
}
|
||||||
if(!cmd->processed(i)) {
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
fprintf(stderr,"rdmarkerset: unrecognized option \"%s\"\n",
|
fprintf(stderr,"rdmarkerset: unknown command option \"%s\"\n",
|
||||||
(const char *)cmd->key(i));
|
(const char *)rda->cmdSwitch()->key(i));
|
||||||
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,37 +129,13 @@ MainObject::MainObject(QObject *parent)
|
|||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Read Configuration
|
|
||||||
//
|
|
||||||
set_config=new RDConfig();
|
|
||||||
set_config->load();
|
|
||||||
set_config->setModuleName("rdmarkerset");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open Database
|
|
||||||
//
|
|
||||||
QString err (tr("rdmarkerset: "));
|
|
||||||
QSqlDatabase *db=RDInitDb(&schema,&err);
|
|
||||||
if(!db) {
|
|
||||||
fprintf(stderr,err.ascii());
|
|
||||||
delete cmd;
|
|
||||||
exit(256);
|
|
||||||
}
|
|
||||||
if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"rdmarkerset: database version mismatch, should be %u, is %u\n",
|
|
||||||
RD_VERSION_DATABASE,schema);
|
|
||||||
exit(256);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Station
|
// Validate Station
|
||||||
//
|
//
|
||||||
set_station=new RDStation(set_config->stationName());
|
// set_station=new RDStation(set_config->stationName());
|
||||||
if(!set_station->exists()) {
|
if(!rda->station()->exists()) {
|
||||||
fprintf(stderr,"rdmarkerset: no such host [\"%s\"]\n",
|
fprintf(stderr,"rdmarkerset: no such host [\"%s\"]\n",
|
||||||
(const char *)set_config->stationName());
|
(const char *)rda->config()->stationName());
|
||||||
exit(256);
|
exit(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,21 +169,13 @@ MainObject::MainObject(QObject *parent)
|
|||||||
//
|
//
|
||||||
// RIPCD Connection
|
// RIPCD Connection
|
||||||
//
|
//
|
||||||
set_user=NULL;
|
connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
|
||||||
set_ripc=new RDRipc(set_station,set_config,this);
|
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
||||||
connect(set_ripc,SIGNAL(userChanged()),this,SLOT(userChangedData()));
|
|
||||||
set_ripc->connectHost("localhost",RIPCD_TCP_PORT,set_config->password());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainObject::userChangedData()
|
void MainObject::userChangedData()
|
||||||
{
|
{
|
||||||
if(set_user!=NULL) {
|
|
||||||
fprintf(stderr,"rdmarkerset: change of user context ignored\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
set_user=new RDUser(set_ripc->user());
|
|
||||||
|
|
||||||
for(unsigned i=0;i<set_group_names.size();i++) {
|
for(unsigned i=0;i<set_group_names.size();i++) {
|
||||||
Print("Processing group \""+set_group_names[i]+"\"...");
|
Print("Processing group \""+set_group_names[i]+"\"...");
|
||||||
ProcessGroup(set_group_names[i]);
|
ProcessGroup(set_group_names[i]);
|
||||||
@@ -260,11 +233,11 @@ void MainObject::SetAutoTrim(unsigned cartnum,int cutnum,const QString &title,
|
|||||||
RDTrimAudio::ErrorCode err;
|
RDTrimAudio::ErrorCode err;
|
||||||
RDCart *cart=new RDCart(cartnum);
|
RDCart *cart=new RDCart(cartnum);
|
||||||
RDCut *cut=new RDCut(cartnum,cutnum);
|
RDCut *cut=new RDCut(cartnum,cutnum);
|
||||||
RDTrimAudio *trimmer=new RDTrimAudio(set_station,set_config,this);
|
RDTrimAudio *trimmer=new RDTrimAudio(rda->station(),rda->config(),this);
|
||||||
trimmer->setCartNumber(cartnum);
|
trimmer->setCartNumber(cartnum);
|
||||||
trimmer->setCutNumber(cutnum);
|
trimmer->setCutNumber(cutnum);
|
||||||
trimmer->setTrimLevel(100*set_auto_trim);
|
trimmer->setTrimLevel(100*set_auto_trim);
|
||||||
if((err=trimmer->runTrim(set_user->name(),set_user->password()))==
|
if((err=trimmer->runTrim(rda->user()->name(),rda->user()->password()))==
|
||||||
RDTrimAudio::ErrorOk) {
|
RDTrimAudio::ErrorOk) {
|
||||||
int start=trimmer->startPoint();
|
int start=trimmer->startPoint();
|
||||||
int end=trimmer->endPoint();
|
int end=trimmer->endPoint();
|
||||||
@@ -335,10 +308,10 @@ void MainObject::ClearAutoTrim(unsigned cartnum,int cutnum,const QString &title,
|
|||||||
RDAudioInfo::ErrorCode err;
|
RDAudioInfo::ErrorCode err;
|
||||||
RDCart *cart=new RDCart(cartnum);
|
RDCart *cart=new RDCart(cartnum);
|
||||||
RDCut *cut=new RDCut(cartnum,cutnum);
|
RDCut *cut=new RDCut(cartnum,cutnum);
|
||||||
RDAudioInfo *info=new RDAudioInfo(set_station,set_config,this);
|
RDAudioInfo *info=new RDAudioInfo(rda->station(),rda->config(),this);
|
||||||
info->setCartNumber(cartnum);
|
info->setCartNumber(cartnum);
|
||||||
info->setCutNumber(cutnum);
|
info->setCutNumber(cutnum);
|
||||||
if((err=info->runInfo(set_user->name(),set_user->password()))==
|
if((err=info->runInfo(rda->user()->name(),rda->user()->password()))==
|
||||||
RDAudioInfo::ErrorOk) {
|
RDAudioInfo::ErrorOk) {
|
||||||
cut->setStartPoint(0);
|
cut->setStartPoint(0);
|
||||||
cut->setEndPoint(info->length());
|
cut->setEndPoint(info->length());
|
||||||
@@ -366,11 +339,11 @@ void MainObject::SetAutoSegue(unsigned cartnum,int cutnum,const QString &title,
|
|||||||
RDTrimAudio::ErrorCode err;
|
RDTrimAudio::ErrorCode err;
|
||||||
RDCart *cart=new RDCart(cartnum);
|
RDCart *cart=new RDCart(cartnum);
|
||||||
RDCut *cut=new RDCut(cartnum,cutnum);
|
RDCut *cut=new RDCut(cartnum,cutnum);
|
||||||
RDTrimAudio *trimmer=new RDTrimAudio(set_station,set_config,this);
|
RDTrimAudio *trimmer=new RDTrimAudio(rda->station(),rda->config(),this);
|
||||||
trimmer->setCartNumber(cartnum);
|
trimmer->setCartNumber(cartnum);
|
||||||
trimmer->setCutNumber(cutnum);
|
trimmer->setCutNumber(cutnum);
|
||||||
trimmer->setTrimLevel(100*set_auto_segue);
|
trimmer->setTrimLevel(100*set_auto_segue);
|
||||||
if((err=trimmer->runTrim(set_user->name(),set_user->password()))==
|
if((err=trimmer->runTrim(rda->user()->name(),rda->user()->password()))==
|
||||||
RDTrimAudio::ErrorOk) {
|
RDTrimAudio::ErrorOk) {
|
||||||
int end=trimmer->endPoint();
|
int end=trimmer->endPoint();
|
||||||
if(end<cut->endPoint()) {
|
if(end<cut->endPoint()) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Command-line tool for setting Rivendell Cut Markers
|
// Command-line tool for setting Rivendell Cut Markers
|
||||||
//
|
//
|
||||||
// (C) Copyright 2014,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2014,2016-2018 Fred Gleason <fredg@paravelsystems.com>
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// 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
|
// it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -27,13 +27,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <qobject.h>
|
#include <qobject.h>
|
||||||
#include <qsqldatabase.h>
|
|
||||||
|
|
||||||
#include <rdripc.h>
|
|
||||||
#include <rduser.h>
|
|
||||||
#include <rdconfig.h>
|
|
||||||
#include <rdcmd_switch.h>
|
|
||||||
#include <rdstation.h>
|
|
||||||
|
|
||||||
#define RDMARKERSET_USAGE "[options]\nThe following options are recognized:\n\n--group=<group>\n Apply marker changes to the group specified by <group>. This\n option may be given multiple times.\n\n--all-groups\n Apply marker changes to ALL groups.\n\n--auto-trim=<level>\n Auto-trim the specified cuts to the level indicated by <level> dBFS.\n Specifying a '0' for <level> will remove auto-trim --i.e. move the\n Start and End markers to the extreme start and end of the audio data.\n Default action is to leave the Start and End markers unaltered.\n\n--auto-segue=<level>\n Set the Segue Start marker on the specified cuts to the level indicated\n by <level> dBFS and the Segue End marker to the position of the End\n marker. Specifying a '0' for <level> will remove the segue markers.\n Default action is to leave the segue markers unaltered.\n\n--verbose\n Print messages to stdout describing progress.\n\n"
|
#define RDMARKERSET_USAGE "[options]\nThe following options are recognized:\n\n--group=<group>\n Apply marker changes to the group specified by <group>. This\n option may be given multiple times.\n\n--all-groups\n Apply marker changes to ALL groups.\n\n--auto-trim=<level>\n Auto-trim the specified cuts to the level indicated by <level> dBFS.\n Specifying a '0' for <level> will remove auto-trim --i.e. move the\n Start and End markers to the extreme start and end of the audio data.\n Default action is to leave the Start and End markers unaltered.\n\n--auto-segue=<level>\n Set the Segue Start marker on the specified cuts to the level indicated\n by <level> dBFS and the Segue End marker to the position of the End\n marker. Specifying a '0' for <level> will remove the segue markers.\n Default action is to leave the segue markers unaltered.\n\n--verbose\n Print messages to stdout describing progress.\n\n"
|
||||||
|
|
||||||
@@ -62,10 +55,6 @@ class MainObject : public QObject
|
|||||||
int set_auto_trim;
|
int set_auto_trim;
|
||||||
int set_auto_segue;
|
int set_auto_segue;
|
||||||
bool set_verbose;
|
bool set_verbose;
|
||||||
RDStation *set_station;
|
|
||||||
RDRipc *set_ripc;
|
|
||||||
RDUser *set_user;
|
|
||||||
RDConfig *set_config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user