File indexing completed on 2024-05-19 04:49:32

0001 /****************************************************************************************
0002  * Copyright (c) 2010 Téo Mrnjavac <teo@kde.org>                                        *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef TRANSCODING_FORMAT_H
0018 #define TRANSCODING_FORMAT_H
0019 
0020 #include "core/amarokcore_export.h"
0021 #include "core/transcoding/TranscodingDefines.h"
0022 #include "core/transcoding/TranscodingProperty.h"
0023 #include "core/transcoding/TranscodingConfiguration.h"
0024 
0025 #include <QIcon>
0026 
0027 #include <QStringList>
0028 
0029 namespace Transcoding
0030 {
0031 
0032 /**
0033  * This is an abstract base class that defines what an Amarok Transcoding Format should
0034  * look like.
0035  * All transcoding format descriptor classes must inherit from this class.
0036  * @author Téo Mrnjavac <teo@kde.org>
0037  */
0038 class AMAROKCORE_EXPORT Format //: public QObject
0039 {
0040 public:
0041     /**
0042      * Destructor.
0043      */
0044     virtual ~Format() {}
0045 
0046     /**
0047      * Returns the encoder identifier of the current format.
0048      * @note You should not need to reimplement this method when subclassing as long as you
0049      * initialize m_encoder in the constructor.
0050      * @return the encoder enum item
0051      */
0052     /*final*/ virtual Encoder encoder() { return m_encoder; }
0053 
0054     /**
0055      * Returns the file extension suggested by the current format. The string should be
0056      * compatible with Meta::Track::type()
0057      * @note You should not need to reimplement this method when subclassing as long as you
0058      * initialize m_fileExtension in the constructor.
0059      *
0060      * @return a QString with the file extension
0061      */
0062     /*final*/ virtual QString fileExtension() const { return m_fileExtension; }
0063 
0064     /**
0065      * Returns a human readable and translated name of the format.
0066      * @return a QString with the pretty name
0067      */
0068     virtual QString prettyName() const = 0;
0069 
0070     /**
0071      * Returns a human readable and translated description of the format.
0072      * @return a QString with the description
0073      */
0074     virtual QString description() const = 0;
0075 
0076     /**
0077      * Returns an icon that represents this format.
0078      * @return a QIcon with the icon
0079      */
0080     virtual QIcon icon() const = 0;
0081 
0082     /**
0083      * Returns a list of parameters to be passed to the FFmpeg binary to perform the
0084      * transcoding operation.
0085      * @return a QStringList with the parameters
0086      */
0087     virtual QStringList ffmpegParameters( const Configuration &configuration ) const = 0;
0088 
0089     /**
0090      * Checks if FFmpeg supports the current format.
0091      * @param ffmpegOutput one line of the output of the command "ffmpeg -codecs"
0092      * @return true if the format is supported by an encoder in FFmpeg on this output line,
0093      *         otherwise false
0094      */
0095     virtual bool verifyAvailability( const QString &ffmpegOutput ) const = 0;
0096 
0097     /**
0098      * Returns a list of properties that must be set in order to perform the transcoding
0099      * operation.
0100      * @note You should not need to reimplement this method when subclassing as long as you
0101      * initialize m_propertyList in the constructor.
0102      * @return the Transcodng::PropertyList with the Transcoding::Propertys
0103      */
0104     virtual const PropertyList & propertyList() const { return m_propertyList; }
0105 
0106 protected:
0107     Encoder m_encoder;
0108     QString m_fileExtension;
0109     PropertyList m_propertyList;
0110 };
0111 
0112 }
0113 
0114 #endif // TRANSCODING_FORMAT_H