File indexing completed on 2024-05-19 04:52:38

0001 /*
0002     SPDX-FileCopyrightText: 2003-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl>
0004     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #ifndef _K3B_EXTERNAL_ENCODER_H_
0010 #define _K3B_EXTERNAL_ENCODER_H_
0011 
0012 #include "k3baudioencoder.h"
0013 
0014 #include "k3bprocess.h"
0015 
0016 class K3bExternalEncoder : public K3b::AudioEncoder
0017 {
0018     Q_OBJECT
0019 
0020 public:
0021     K3bExternalEncoder( QObject* parent, const QVariantList& );
0022     ~K3bExternalEncoder() override;
0023 
0024     QStringList extensions() const override;
0025 
0026     QString fileTypeComment( const QString& ) const override;
0027 
0028     int pluginSystemVersion() const override { return K3B_PLUGIN_SYSTEM_VERSION; }
0029 
0030     /**
0031      * reimplemented since the external program is intended to write the file
0032      * TODO: allow writing to stdout.
0033      */
0034     bool openFile( const QString& ext, const QString& filename, const K3b::Msf& length, const MetaData& metaData ) override;
0035     bool isOpen() const override;
0036     void closeFile() override;
0037 
0038 private Q_SLOTS:
0039     void slotExternalProgramFinished( int, QProcess::ExitStatus );
0040     void slotExternalProgramOutput( const QString& line );
0041 
0042 private:
0043     bool initEncoderInternal( const QString& extension, const K3b::Msf& length, const MetaData& metaData ) override;
0044     void finishEncoderInternal() override;
0045     qint64 encodeInternal( const char* data, qint64 len ) override;
0046     bool writeWaveHeader();
0047 
0048     class Private;
0049     Private* d;
0050 };
0051 
0052 #endif