File indexing completed on 2024-05-19 12:32:59
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_CONTROLLER_H 0018 #define TRANSCODING_CONTROLLER_H 0019 0020 #include "core/amarokcore_export.h" 0021 #include "core/support/Components.h" 0022 #include "core/transcoding/TranscodingDefines.h" 0023 #include "core/transcoding/TranscodingFormat.h" 0024 0025 #include <KProcess> 0026 0027 #include <QList> 0028 #include <QMap> 0029 #include <QObject> 0030 #include <QSet> 0031 0032 0033 namespace Transcoding 0034 { 0035 0036 /** 0037 * Singleton class that handles and wraps around the Transcoding architecture. 0038 * @author Téo Mrnjavac <teo@kde.org> 0039 */ 0040 class AMAROKCORE_EXPORT Controller : public QObject 0041 { 0042 Q_OBJECT 0043 public: 0044 explicit Controller( QObject *parent = nullptr ); 0045 ~Controller() override; 0046 0047 /** 0048 * Return set of all encoders, available or not. 0049 */ 0050 QSet<Encoder> allEncoders() const { const QList<Transcoding::Encoder> uniqkeys = m_formats.uniqueKeys(); return QSet<Encoder>(uniqkeys.begin(), uniqkeys.end()); } 0051 0052 /** 0053 * Return a set of all available encoders. You can use @see format() to get all 0054 * available formats. 0055 */ 0056 QSet<Encoder> availableEncoders() const { return m_availableEncoders; } 0057 0058 /** 0059 * Return pointer to format that encodes using @p encoder. You must ensure that 0060 * @param encoder is in @see allEncoders(). Always returns non-null pointer which 0061 * remains owned by Transcoding::Controller. 0062 */ 0063 Format *format( Encoder encoder ) const; 0064 0065 private Q_SLOTS: 0066 void onAvailabilityVerified( int exitCode, QProcess::ExitStatus exitStatus ); 0067 0068 private: 0069 QMultiMap<Encoder, Format *> m_formats; // due to Format being polymorphic, we must store pointers 0070 QSet<Encoder> m_availableEncoders; 0071 }; 0072 0073 } //namespace Transcoding 0074 0075 #endif //TRANSCODING_CONTROLLER_H