mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-10 09:27:44 +02:00
2018-02-04 Fred Gleason <fredg@paravelsystems.com>
* Refactored the RDAudioImport class to use RDApplication.
This commit is contained in:
parent
69817c1941
commit
957772c5e6
@ -16668,3 +16668,5 @@
|
||||
* Converted rdcatchd(8) to use RDApplication.
|
||||
2018-02-04 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored the RDAudioExport class to use RDApplication.
|
||||
2018-02-04 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored the RDAudioImport class to use RDApplication.
|
||||
|
@ -32,10 +32,11 @@
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <rd.h>
|
||||
#include <rdxport_interface.h>
|
||||
#include <rdformpost.h>
|
||||
#include <rdapplication.h>
|
||||
#include <rdaudioimport.h>
|
||||
#include <rdformpost.h>
|
||||
#include <rdwebresult.h>
|
||||
#include <rdxport_interface.h>
|
||||
|
||||
//
|
||||
// CURL Callbacks
|
||||
@ -62,12 +63,9 @@ int ImportProgressCallback(void *clientp,double dltotal,double dlnow,
|
||||
}
|
||||
|
||||
|
||||
RDAudioImport::RDAudioImport(RDStation *station,RDConfig *config,
|
||||
QObject *parent)
|
||||
RDAudioImport::RDAudioImport(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
conv_station=station;
|
||||
conv_config=config;
|
||||
conv_cart_number=0;
|
||||
conv_cut_number=0;
|
||||
conv_settings=NULL;
|
||||
@ -170,7 +168,7 @@ RDAudioImport::ErrorCode RDAudioImport::runImport(const QString &username,
|
||||
curl_easy_setopt(curl,CURLOPT_WRITEDATA,stdout);
|
||||
curl_easy_setopt(curl,CURLOPT_HTTPPOST,first);
|
||||
curl_easy_setopt(curl,CURLOPT_USERAGENT,
|
||||
(const char *)conv_config->userAgent());
|
||||
(const char *)rda->config()->userAgent());
|
||||
curl_easy_setopt(curl,CURLOPT_TIMEOUT,RD_CURL_TIMEOUT);
|
||||
curl_easy_setopt(curl,CURLOPT_PROGRESSFUNCTION,ImportProgressCallback);
|
||||
curl_easy_setopt(curl,CURLOPT_PROGRESSDATA,this);
|
||||
@ -182,7 +180,7 @@ RDAudioImport::ErrorCode RDAudioImport::runImport(const QString &username,
|
||||
// otherwise some versions of LibCurl will throw a 'bad/illegal format'
|
||||
// error.
|
||||
//
|
||||
strncpy(url,conv_station->webServiceUrl(conv_config),1024);
|
||||
strncpy(url,rda->station()->webServiceUrl(rda->config()),1024);
|
||||
curl_easy_setopt(curl,CURLOPT_URL,url);
|
||||
|
||||
//
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Import an Audio File using the RdXport Web Service
|
||||
//
|
||||
// (C) Copyright 2010-2014,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010-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
|
||||
@ -23,8 +23,6 @@
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdstation.h>
|
||||
#include <rdsettings.h>
|
||||
#include <rdaudioconvert.h>
|
||||
|
||||
@ -36,7 +34,7 @@ class RDAudioImport : public QObject
|
||||
ErrorNoDestination=3,ErrorInternal=5,ErrorUrlInvalid=7,
|
||||
ErrorService=8,ErrorInvalidUser=9,ErrorAborted=10,
|
||||
ErrorConverter=11};
|
||||
RDAudioImport(RDStation *station,RDConfig *config,QObject *parent=0);
|
||||
RDAudioImport(QObject *parent=0);
|
||||
void setCartNumber(unsigned cartnum);
|
||||
void setCutNumber(unsigned cutnum);
|
||||
void setSourceFile(const QString &filename);
|
||||
@ -53,8 +51,6 @@ class RDAudioImport : public QObject
|
||||
void abort();
|
||||
|
||||
private:
|
||||
RDStation *conv_station;
|
||||
RDConfig *conv_config;
|
||||
unsigned conv_cart_number;
|
||||
unsigned conv_cut_number;
|
||||
QString conv_src_filename;
|
||||
|
@ -577,7 +577,7 @@ void RDCartDialog::loadFileData()
|
||||
// Import Audio
|
||||
//
|
||||
cart_busy_dialog->show(tr("Importing"),tr("Importing..."));
|
||||
conv=new RDAudioImport(cart_station,cart_config,this);
|
||||
conv=new RDAudioImport(this);
|
||||
conv->setCartNumber(cartnum);
|
||||
conv->setCutNumber(1);
|
||||
conv->setSourceFile(filename);
|
||||
|
@ -544,7 +544,7 @@ void RDImportAudio::Import()
|
||||
//
|
||||
StartBar();
|
||||
RDCut *cut=new RDCut(import_cutname);
|
||||
import_import_conv=new RDAudioImport(import_station,import_config,this);
|
||||
import_import_conv=new RDAudioImport(this);
|
||||
import_import_conv->setCartNumber(cut->cartNumber());
|
||||
import_import_conv->setCutNumber(cut->cutNumber());
|
||||
import_import_conv->setSourceFile(import_in_filename_edit->text());
|
||||
|
@ -602,7 +602,7 @@ bool RDRenderer::ImportCart(const QString &srcfile,unsigned cartnum,int cutnum,
|
||||
settings.setChannels(chans);
|
||||
settings.setNormalizationLevel(0);
|
||||
|
||||
RDAudioImport *conv=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
RDAudioImport *conv=new RDAudioImport(this);
|
||||
conv->setCartNumber(cartnum);
|
||||
conv->setCutNumber(cutnum);
|
||||
conv->setSourceFile(srcfile);
|
||||
|
@ -499,7 +499,7 @@ void CdRipper::ripTrackButtonData()
|
||||
}
|
||||
switch((ripper_err=ripper->rip(rip_track[0],rip_track[1]))) {
|
||||
case RDCdRipper::ErrorOk:
|
||||
conv=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
conv=new RDAudioImport(this);
|
||||
conv->setSourceFile(tmpfile);
|
||||
conv->setCartNumber(rip_cut->cartNumber());
|
||||
conv->setCutNumber(rip_cut->cutNumber());
|
||||
|
@ -1038,7 +1038,7 @@ void DiskRipper::RipTrack(int track,int end_track,QString cutname,QString title)
|
||||
ripper->setDestinationFile(tmpfile);
|
||||
switch((ripper_err=ripper->rip(rip_track_number-1,end_track-1))) {
|
||||
case RDCdRipper::ErrorOk:
|
||||
conv=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
conv=new RDAudioImport(this);
|
||||
conv->setSourceFile(tmpfile);
|
||||
conv->setCartNumber(cut->cartNumber());
|
||||
conv->setCutNumber(cut->cutNumber());
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Test Rivendell file importing.
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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,13 +18,15 @@
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
|
||||
#include <rdapplication.h>
|
||||
#include <rddb.h>
|
||||
#include <rdcmd_switch.h>
|
||||
#include <rdaudioimport.h>
|
||||
|
||||
#include <audio_import_test.h>
|
||||
#include "audio_import_test.h"
|
||||
|
||||
MainObject::MainObject(QObject *parent)
|
||||
:QObject(parent)
|
||||
@ -38,75 +40,91 @@ MainObject::MainObject(QObject *parent)
|
||||
bool ok=false;
|
||||
RDAudioConvert::ErrorCode audio_conv_err;
|
||||
RDAudioImport::ErrorCode conv_err;
|
||||
unsigned schema=0;
|
||||
QString err_msg;
|
||||
|
||||
//
|
||||
// Open the Database
|
||||
//
|
||||
rda=new RDApplication("audio_import_test","audio_import_test",
|
||||
AUDIO_IMPORT_TEST_USAGE,this);
|
||||
if(!rda->open(&err_msg)) {
|
||||
fprintf(stderr,"audio_import_test: %s\n",(const char *)err_msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// Read Command Options
|
||||
//
|
||||
RDCmdSwitch *cmd=
|
||||
new RDCmdSwitch(qApp->argc(),qApp->argv(),"audio_import_test",
|
||||
AUDIO_IMPORT_TEST_USAGE);
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)=="--username") {
|
||||
username=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||
if(rda->cmdSwitch()->key(i)=="--username") {
|
||||
username=rda->cmdSwitch()->value(i);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--password") {
|
||||
password=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
if(rda->cmdSwitch()->key(i)=="--password") {
|
||||
password=rda->cmdSwitch()->value(i);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--cart-number") {
|
||||
cart_number=cmd->value(i).toUInt(&ok);
|
||||
if(rda->cmdSwitch()->key(i)=="--cart-number") {
|
||||
cart_number=rda->cmdSwitch()->value(i).toUInt(&ok);
|
||||
if((!ok)||(cart_number>999999)) {
|
||||
fprintf(stderr,"audio_import_test: invalid cart number\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--cut-number") {
|
||||
cut_number=cmd->value(i).toUInt(&ok);
|
||||
if(rda->cmdSwitch()->key(i)=="--cut-number") {
|
||||
cut_number=rda->cmdSwitch()->value(i).toUInt(&ok);
|
||||
if((!ok)||(cut_number>999)) {
|
||||
fprintf(stderr,"audio_import_test: invalid cut number\n");
|
||||
exit(256);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--source-file") {
|
||||
source_filename=cmd->value(i);
|
||||
cmd->setProcessed(i,true);
|
||||
if(rda->cmdSwitch()->key(i)=="--source-file") {
|
||||
source_filename=rda->cmdSwitch()->value(i);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--destination-channels") {
|
||||
unsigned channels=cmd->value(i).toInt(&ok);
|
||||
if(rda->cmdSwitch()->key(i)=="--destination-channels") {
|
||||
unsigned channels=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,"audio_import_test: invalid destination channels\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setChannels(channels);
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--normalization-level") {
|
||||
int normalization_level=cmd->value(i).toInt(&ok);
|
||||
if(rda->cmdSwitch()->key(i)=="--normalization-level") {
|
||||
int normalization_level=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||
if((!ok)||(normalization_level>0)) {
|
||||
fprintf(stderr,"audio_import_test: invalid normalization level\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setNormalizationLevel(normalization_level);
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--autotrim-level") {
|
||||
int autotrim_level=cmd->value(i).toInt(&ok);
|
||||
if(rda->cmdSwitch()->key(i)=="--autotrim-level") {
|
||||
int autotrim_level=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||
if((!ok)||(autotrim_level>0)) {
|
||||
fprintf(stderr,"audio_import_test: invalid autotrim level\n");
|
||||
exit(256);
|
||||
}
|
||||
destination_settings->setAutotrimLevel(autotrim_level);
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)=="--use-metadata") {
|
||||
if(rda->cmdSwitch()->key(i)=="--use-metadata") {
|
||||
use_metadata=true;
|
||||
cmd->setProcessed(i,true);
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(!rda->cmdSwitch()->processed(i)) {
|
||||
fprintf(stderr,"audio_import_test: unknown command option \"%s\"\n",
|
||||
(const char *)rda->cmdSwitch()->key(i));
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Sanity Checks
|
||||
//
|
||||
if(cart_number==0) {
|
||||
fprintf(stderr,"audio_import_test: missing cart-number\n");
|
||||
exit(256);
|
||||
@ -121,25 +139,9 @@ MainObject::MainObject(QObject *parent)
|
||||
}
|
||||
|
||||
//
|
||||
// Read Configuration
|
||||
// Run Test
|
||||
//
|
||||
rdconfig=new RDConfig();
|
||||
rdconfig->load();
|
||||
rdconfig->setModuleName("audio_import_test");
|
||||
|
||||
//
|
||||
// Open Database
|
||||
//
|
||||
QString err (tr("audio_import_test: "));
|
||||
QSqlDatabase *db=RDInitDb(&schema,&err);
|
||||
if(!db) {
|
||||
fprintf(stderr,err.ascii());
|
||||
delete cmd;
|
||||
exit(256);
|
||||
}
|
||||
|
||||
RDStation *station=new RDStation(rdconfig->stationName());
|
||||
RDAudioImport *conv=new RDAudioImport(station,rdconfig,this);
|
||||
RDAudioImport *conv=new RDAudioImport(this);
|
||||
conv->setCartNumber(cart_number);
|
||||
conv->setCutNumber(cut_number);
|
||||
conv->setSourceFile(source_filename);
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Test Rivendell file importing
|
||||
//
|
||||
// (C) Copyright 2010,2016 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2010,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
|
||||
@ -24,20 +24,11 @@
|
||||
#include <list>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qsqldatabase.h>
|
||||
|
||||
#include <rdconfig.h>
|
||||
#include <rdsettings.h>
|
||||
#include <rdcmd_switch.cpp>
|
||||
|
||||
#define AUDIO_IMPORT_TEST_USAGE "[options]\n\nTest the Rivendell audio importer routines\n\nOptions are:\n--username=<username>\n\n--password=<password>\n\n--cart-number=<cartnum>\n\n--cut-number=<cutnum>\n\n--source-file=<filename>\n\n--destination-channels=<chans>\n\n--normalization-level=<dbfs>\n\n--autotrim-level=<dbfs>\n\n--use-metadata\n\n"
|
||||
|
||||
//
|
||||
// Global Variables
|
||||
//
|
||||
RDConfig *rdconfig;
|
||||
|
||||
|
||||
class MainObject : public QObject
|
||||
{
|
||||
public:
|
||||
|
@ -508,7 +508,7 @@ bool MainWidget::ImportSpot(Event *evt,QString *err_msg)
|
||||
addDays(RDDGIMPORT_KILLDATE_OFFSET),
|
||||
QTime(23,59,59)),true);
|
||||
|
||||
conv=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
conv=new RDAudioImport(this);
|
||||
conv->setCartNumber(dg_carts[evt->isci()]);
|
||||
conv->setCutNumber(cutnum);
|
||||
conv->setSourceFile(audiofile);
|
||||
|
@ -118,7 +118,7 @@ MainWidget::MainWidget(QWidget *parent)
|
||||
dg_ripper=new RDCdRipper(NULL,this);
|
||||
dg_ripper->setDevice(rda->libraryConf()->ripperDevice());
|
||||
dg_ripper->setDestinationFile(dg_tempfile);
|
||||
dg_importer=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
dg_importer=new RDAudioImport(this);
|
||||
dg_importer->setSourceFile(dg_tempfile);
|
||||
dg_importer->setUseMetadata(false);
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
|
||||
return MainObject::NoCut;
|
||||
}
|
||||
RDCut *cut=new RDCut(*cartnum,cutnum);
|
||||
RDAudioImport *conv=new RDAudioImport(rda->station(),rda->config(),this);
|
||||
RDAudioImport *conv=new RDAudioImport(this);
|
||||
conv->setCartNumber(cart->number());
|
||||
conv->setCutNumber(cutnum);
|
||||
conv->setSourceFile(wavefile->getName());
|
||||
|
Loading…
x
Reference in New Issue
Block a user