File: convert.h

package info (click to toggle)
soundkonverter 3.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,012 kB
  • sloc: cpp: 30,779; sh: 59; xml: 50; makefile: 7
file content (138 lines) | stat: -rw-r--r-- 4,152 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138


#ifndef CONVERT_H
#define CONVERT_H

#include "filelistitem.h"

#include <QProcess>
#include <QList>
#include <QMap>
#include <QObject>
#include <QTimer>

class BackendPlugin;
class CDManager;
class Config;
class ConvertItem;
class FileList;
class Logger;

class KJob;


/**
 * @short The conversion engine
 * @author Daniel Faust <hessijames@gmail.com>
 */
class Convert : public QObject
{
    Q_OBJECT
public:
    Convert( Config *_config, FileList *_fileList, Logger *_logger, QObject *parent );
    ~Convert();

    void cleanUp();

private:
    /** Copy the file with the file list item @p item to a temporary directory and download if necessary */
    void get( ConvertItem *item );

    /** Convert the file */
    void convert( ConvertItem *item );

    /** Apply a filter to the file after it has been decoded in convert() */
    void convertNextBackend( ConvertItem *item );

    /** Calculate replaygain tags of the file with the convert item @p item */
    void replaygain( ConvertItem *item );

    /** Write the tags of the file with the convert item @p item */
    void writeTags( ConvertItem *item );

//     /** Run the userscript for the convert item @p item */
//     void executeUserScript( ConvertItem *item );

    /** Decide, what to do next with out item @p item */
    void executeNextStep( ConvertItem *item );

    /** Make another try for @p item */
    void executeSameStep( ConvertItem *item );

    /** Remove item @p item and emit the state @p state */
    void remove( ConvertItem *item, FileListItem::ReturnCode returnCode = FileListItem::Succeeded );

    /** holds all active files */
    QList<ConvertItem*> items;

    /** holds all items that are waiting for album gain QMap< album name,convert items list > */
    QMap< QString, QList<ConvertItem*> > albumGainItems;

    Config *config;
    CDManager* cdManager;
    FileList *fileList;
    Logger* logger;
    QMap<int,QString> usedOutputNames;

    QStringList activeVorbisGainDirectories; // vorbisgain creates temporary files with the fixed name "vorbisgain.tmp", so it must run only once per directory (https://github.com/dfaust/soundkonverter/issues/12)

    struct LogQueue {
        int id;
        BackendPlugin *plugin;
        QStringList messages;
    };

    QList<LogQueue> pluginLogQueue;

    QTimer updateTimer;

private slots:
    /** The file is being moved */
    void kioJobProgress( KJob *job, unsigned long percent );

    /** The file has been moved */
    void kioJobFinished( KJob *job );

    /** Get the process' output */
    void processOutput();

    /** The process has exited */
    void processExit( int exitCode, QProcess::ExitStatus exitStatus );

    /** A plugin has finished converting a file */
    void pluginProcessFinished( int id, int exitCode );
    /** A plugin has something to log */
    void pluginLog( int id, const QString& message );

    /** sums up the progresses of all processes and sends it to the ProgressIndicator */
    void updateProgress();

public slots:
    // connected to FileList
    /** Add a new @p item to the item list and start */
    void add( FileListItem *fileListItem );
    /** Stop the item with the file list item @p item in the item list and remove it */
    void kill( FileListItem *fileListItem );
    /** the file list item @p item will get removed */
    void itemRemoved( FileListItem *fileListItem );

    /** Change the process priorities */
//     void priorityChanged( int );

signals:
    // connected to FileList
    /** The conversion of an item has finished and the state is reported */
    void finished( FileListItem *fileListItem, FileListItem::ReturnCode returnCode, bool waitingForAlbumGain = false );
    /** The next track from the device can be ripped while the track is being encoded */
    void rippingFinished( const QString& device );

    // connected to Logger
    /** Tell the logger that the process has finished */
    void finishedProcess( int id, bool succeeded, bool waitingForAlbumGain = false );

    // connected to ProgressIndicator
    void updateTime( float timeProgress );
    void timeFinished( float timeDelta );
};

#endif // CONVERT_H