mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-11-25 23:00:21 +01:00
2014-10-25 Fred Gleason <fredg@paravelsystems.com>
* Implemented '--set-marker-end-*=' and '--set-marker-start-*=' options for rdimport(1) in 'utils/rdimport/markerset.cpp',, 'utils/rdimport/markerset.h', 'utils/rdimport/rdimport.cpp' and 'utils/rdimport/rdimport.h'.
This commit is contained in:
@@ -31,7 +31,8 @@ moc_%.cpp: %.h
|
||||
|
||||
bin_PROGRAMS = rdimport
|
||||
|
||||
dist_rdimport_SOURCES = rdimport.cpp rdimport.h
|
||||
dist_rdimport_SOURCES = markerset.cpp markerset.h\
|
||||
rdimport.cpp rdimport.h
|
||||
|
||||
nodist_rdimport_SOURCES = moc_rdimport.cpp
|
||||
|
||||
|
||||
143
utils/rdimport/markerset.cpp
Normal file
143
utils/rdimport/markerset.cpp
Normal file
@@ -0,0 +1,143 @@
|
||||
// markerset.cpp
|
||||
//
|
||||
// Abstract a set of marker parameters.
|
||||
//
|
||||
// (C) Copyright 2014 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
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "markerset.h"
|
||||
|
||||
MarkerSet::MarkerSet()
|
||||
{
|
||||
marker_start_valid=false;
|
||||
marker_start_value=0;
|
||||
marker_end_valid=false;
|
||||
marker_end_value=0;
|
||||
marker_audio_length=0;
|
||||
}
|
||||
|
||||
|
||||
bool MarkerSet::hasStartValue() const
|
||||
{
|
||||
return marker_start_valid;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::startValue(int lo_limit,int hi_limit) const
|
||||
{
|
||||
return LimitCheck(marker_start_value,lo_limit,hi_limit);
|
||||
}
|
||||
|
||||
|
||||
bool MarkerSet::hasEndValue() const
|
||||
{
|
||||
return marker_end_valid;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::endValue(int lo_limit,int hi_limit) const
|
||||
{
|
||||
return LimitCheck(marker_end_value,lo_limit,hi_limit);
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::load(RDCmdSwitch *cmd,const QString &marker)
|
||||
{
|
||||
QString start_key="--set-marker-start-"+marker;
|
||||
QString end_key="--set-marker-end-"+marker;
|
||||
marker_marker=marker;
|
||||
for(unsigned i=0;i<cmd->keys();i++) {
|
||||
if(cmd->key(i)==start_key) {
|
||||
marker_start_value=cmd->value(i).toInt(&marker_start_valid);
|
||||
if(!marker_start_valid) {
|
||||
fprintf(stderr,"rdimport: invalid argment to %s\n",
|
||||
(const char *)start_key);
|
||||
exit(255);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
if(cmd->key(i)==end_key) {
|
||||
marker_end_value=cmd->value(i).toInt(&marker_end_valid);
|
||||
if(!marker_end_valid) {
|
||||
fprintf(stderr,"rdimport: invalid argment to %s\n",
|
||||
(const char *)end_key);
|
||||
exit(255);
|
||||
}
|
||||
cmd->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
if(marker_end_valid&&(!marker_start_valid)) {
|
||||
marker_start_value=0;
|
||||
marker_start_valid=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::setAudioLength(int msecs)
|
||||
{
|
||||
if(marker_start_valid&&(!marker_end_valid)) {
|
||||
marker_end_value=msecs;
|
||||
marker_end_valid=true;
|
||||
}
|
||||
marker_audio_length=msecs;
|
||||
}
|
||||
|
||||
|
||||
void MarkerSet::dump()
|
||||
{
|
||||
if(marker_start_valid) {
|
||||
printf(" Marker Start %s: ",(const char *)marker_marker);
|
||||
printf("%d mS\n",marker_start_value);
|
||||
}
|
||||
if(marker_end_valid) {
|
||||
printf(" Marker End %s: ",(const char *)marker_marker);
|
||||
printf("%d mS\n",marker_end_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::LimitCheck(int value,int lo_limit,int hi_limit) const
|
||||
{
|
||||
if(lo_limit!=-1) {
|
||||
if(value<lo_limit) {
|
||||
return lo_limit;
|
||||
}
|
||||
}
|
||||
if(hi_limit!=-1) {
|
||||
if(value>hi_limit) {
|
||||
return hi_limit;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
int MarkerSet::FrontReference(int value) const
|
||||
{
|
||||
if(value>=0) {
|
||||
if(value>marker_audio_length) {
|
||||
return marker_audio_length;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
if((marker_audio_length+value)<0) {
|
||||
return 0;
|
||||
}
|
||||
return marker_audio_length+value;
|
||||
}
|
||||
50
utils/rdimport/markerset.h
Normal file
50
utils/rdimport/markerset.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// markerset.h
|
||||
//
|
||||
// Abstract a set of marker parameters.
|
||||
//
|
||||
// (C) Copyright 2014 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
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef MARKERSET_H
|
||||
#define MARKERSET_H
|
||||
|
||||
#include <rdcmd_switch.h>
|
||||
|
||||
class MarkerSet
|
||||
{
|
||||
public:
|
||||
MarkerSet();
|
||||
bool hasStartValue() const;
|
||||
int startValue(int lo_limit=-1,int hi_limit=-1) const;
|
||||
bool hasEndValue() const;
|
||||
int endValue(int lo_limit=-1,int hi_limit=-1) const;
|
||||
void load(RDCmdSwitch *cmd,const QString &marker);
|
||||
void setAudioLength(int msecs);
|
||||
void dump();
|
||||
|
||||
private:
|
||||
int LimitCheck(int value,int lo_limit,int hi_limit) const;
|
||||
int FrontReference(int value) const;
|
||||
QString marker_marker;
|
||||
bool marker_start_valid;
|
||||
int marker_start_value;
|
||||
bool marker_end_valid;
|
||||
int marker_end_value;
|
||||
int marker_audio_length;
|
||||
};
|
||||
|
||||
|
||||
#endif // MARKERSET_H
|
||||
@@ -246,6 +246,14 @@ MainObject::MainObject(QObject *parent,const char *name)
|
||||
import_create_dates=true;
|
||||
}
|
||||
}
|
||||
import_cut_markers=new MarkerSet();
|
||||
import_cut_markers->load(import_cmd,"cut");
|
||||
import_talk_markers=new MarkerSet();
|
||||
import_talk_markers->load(import_cmd,"talk");
|
||||
import_hook_markers=new MarkerSet();
|
||||
import_hook_markers->load(import_cmd,"hook");
|
||||
import_segue_markers=new MarkerSet();
|
||||
import_segue_markers->load(import_cmd,"segue");
|
||||
|
||||
//
|
||||
// Read Configuration
|
||||
@@ -508,6 +516,10 @@ MainObject::MainObject(QObject *parent,const char *name)
|
||||
if(import_persistent_dropbox_id>=0) {
|
||||
printf(" Persistent DropBox ID = %d\n",import_persistent_dropbox_id);
|
||||
}
|
||||
import_cut_markers->dump();
|
||||
import_talk_markers->dump();
|
||||
import_hook_markers->dump();
|
||||
import_segue_markers->dump();
|
||||
printf(" Files to process:\n");
|
||||
for(unsigned i=import_file_key;i<import_cmd->keys();i++) {
|
||||
printf(" \"%s\"\n",(const char *)import_cmd->key(i));
|
||||
@@ -785,7 +797,6 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
|
||||
return MainObject::FileBad;
|
||||
}
|
||||
}
|
||||
|
||||
if(!import_metadata_pattern.isEmpty()) {
|
||||
QString groupname=effective_group->name();
|
||||
found_cart=RunPattern(import_metadata_pattern,RDGetBasePart(filename),
|
||||
@@ -1006,6 +1017,30 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
|
||||
cut->setStartDaypart(import_dayparts[0],true);
|
||||
cut->setEndDaypart(import_dayparts[1],true);
|
||||
}
|
||||
import_cut_markers->setAudioLength(wavefile->getExtTimeLength());
|
||||
if(import_cut_markers->hasStartValue()) {
|
||||
cut->setStartPoint(import_cut_markers->startValue());
|
||||
cut->setEndPoint(import_cut_markers->endValue());
|
||||
cut->setLength(cut->endPoint()-cut->startPoint());
|
||||
cart->updateLength();
|
||||
}
|
||||
int lo=cut->startPoint();
|
||||
int hi=cut->endPoint();
|
||||
import_talk_markers->setAudioLength(wavefile->getExtTimeLength());
|
||||
if(import_talk_markers->hasStartValue()) {
|
||||
cut->setTalkStartPoint(import_talk_markers->startValue(lo,hi));
|
||||
cut->setTalkEndPoint(import_talk_markers->endValue(lo,hi));
|
||||
}
|
||||
import_hook_markers->setAudioLength(wavefile->getExtTimeLength());
|
||||
if(import_hook_markers->hasStartValue()) {
|
||||
cut->setHookStartPoint(import_hook_markers->startValue(lo,hi));
|
||||
cut->setHookEndPoint(import_hook_markers->endValue(lo,hi));
|
||||
}
|
||||
import_segue_markers->setAudioLength(wavefile->getExtTimeLength());
|
||||
if(import_segue_markers->hasStartValue()) {
|
||||
cut->setSegueStartPoint(import_segue_markers->startValue(lo,hi));
|
||||
cut->setSegueEndPoint(import_segue_markers->endValue(lo,hi));
|
||||
}
|
||||
delete settings;
|
||||
delete conv;
|
||||
delete cut;
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <rdsystem.h>
|
||||
#include <rdstation.h>
|
||||
|
||||
#include "markerset.h"
|
||||
|
||||
#define RDIMPORT_TEMP_BASENAME "rdimp"
|
||||
#define RDIMPORT_STDIN_BUFFER_LENGTH 1024
|
||||
#define RDIMPORT_DROPBOX_SCAN_INTERVAL 5
|
||||
@@ -127,6 +129,10 @@ class MainObject : public QObject
|
||||
QString import_temp_fix_filename;
|
||||
RDSystem *import_system;
|
||||
RDStation *import_station;
|
||||
MarkerSet *import_cut_markers;
|
||||
MarkerSet *import_talk_markers;
|
||||
MarkerSet *import_hook_markers;
|
||||
MarkerSet *import_segue_markers;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user