1 /*
2   Copyright (C) 2005 Benjamin Meyer <ben at meyerhome dot net>
3   Copyright (C) 2018 Yuri Chornoivan <yurchor@mageia.org>
4 
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9 
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU General Public License for more details.
14 
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
18   USA.
19 */
20 
21 #ifndef ENCODER_OPUS_H
22 #define ENCODER_OPUS_H
23 
24 #include "audiocdencoder.h"
25 #include "ui_encoderopusconfig.h"
26 
27 #include <KProcess>
28 
29 class EncoderOpusConfig : public QWidget, public Ui::EncoderOpusConfig
30 {
31 public:
32     EncoderOpusConfig(QWidget *parent = nullptr)
QWidget(parent)33         : QWidget(parent)
34     {
35         setupUi(this);
36     }
37 };
38 
39 /**
40  * Opus encoder.
41  * Check out https://opus-codec.org/ for lots of information.
42  */
43 class EncoderOpus : public QObject, public AudioCDEncoder {
44     Q_OBJECT
45 
46 public:
47     explicit EncoderOpus(KIO::SlaveBase *slave);
48     ~EncoderOpus();
49 
type()50     virtual QString type() const override
51     {
52         return QStringLiteral("Opus");
53     }
54     virtual bool init() override;
55     virtual void loadSettings() override;
56     virtual unsigned long size(long time_secs) const override;
fileType()57     virtual const char *fileType() const override
58     {
59         return "opus";
60     }
mimeType()61     virtual const char *mimeType() const override
62     {
63         return "audio/x-opus+ogg";
64     }
65     virtual void fillSongInfo(KCDDB::CDInfo info, int track, const QString &comment) override;
66     virtual long readInit(long size) override;
67     virtual long read(qint16 *buf, int frames) override;
68     virtual long readCleanup() override;
69     virtual QString lastErrorMessage() const override;
70 
71     virtual QWidget *getConfigureWidget(KConfigSkeleton **manager) const override;
72 
73 protected Q_SLOTS:
74     void receivedStdout();
75     void receivedStderr();
76     void processExited(int exitCode, QProcess::ExitStatus /*status*/);
77 
78 private:
79     class Private;
80     Private *d;
81 
82     QStringList args;
83     QStringList trackInfo;
84 };
85 
86 #endif // ENCODER_OPUS_H
87