File indexing completed on 2025-02-09 05:31:45
0001 /* This file is part of the KDE project 0002 Copyright (C) 2007-2008 Matthias Kretz <kretz@kde.org> 0003 Copyright (C) 2011 Harald Sitter <sitter@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Lesser General Public 0007 License as published by the Free Software Foundation; either 0008 version 2.1 of the License, or (at your option) version 3, or any 0009 later version accepted by the membership of KDE e.V. (or its 0010 successor approved by the membership of KDE e.V.), Nokia Corporation 0011 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0012 act as a proxy defined in Section 6 of version 3 of the license. 0013 0014 This library is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 Lesser General Public License for more details. 0018 0019 You should have received a copy of the GNU Lesser General Public 0020 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0021 0022 */ 0023 0024 #ifndef PHONON_ADDONINTERFACE_H 0025 #define PHONON_ADDONINTERFACE_H 0026 0027 #include "phononnamespace.h" 0028 0029 #include <QList> 0030 #include <QVariant> 0031 0032 0033 #ifndef QT_NO_PHONON_MEDIACONTROLLER 0034 0035 namespace Phonon 0036 { 0037 /** \class AddonInterface addoninterface.h phonon/AddonInterface 0038 * \short Interface for Menu, Chapter, Angle and Title/Track control. 0039 * 0040 * \author Matthias Kretz <kretz@kde.org> 0041 */ 0042 class AddonInterface 0043 { 0044 public: 0045 virtual ~AddonInterface() {} 0046 0047 enum Interface { 0048 NavigationInterface = 1, /**< Interface for (menu) navigation */ 0049 ChapterInterface = 2, /**< Interface for chapter control */ 0050 AngleInterface = 3, /**< Interface for angle control */ 0051 TitleInterface = 4, /**< Interface for title control */ 0052 SubtitleInterface = 5, /**< Interface for subtitle control */ 0053 AudioChannelInterface = 6 /**< Interface for audio channel control */ 0054 }; 0055 0056 enum NavigationCommand { 0057 availableMenus, /**< \returns a QList<MediaController::NavigationMenu> 0058 containing all supported navigation menu types */ 0059 setMenu /**< Sets the current menu to the first 0060 \c MediaController::NavigationMenu in a QList */ 0061 }; 0062 0063 enum ChapterCommand { 0064 availableChapters, /**< \returns an \c int representing the amount of 0065 available chapters on the media source */ 0066 chapter, /**< \returns an \c int representing the current chapter */ 0067 setChapter /**< Sets the current chapter to the first \c int in the QList */ 0068 }; 0069 0070 enum AngleCommand { 0071 availableAngles, /**< \returns \c int representing the amount of 0072 available angles on the media source */ 0073 angle, /**< \returns an \c int representing the current angle */ 0074 setAngle /**< Sets the current angle to the first \c int in the QList */ 0075 }; 0076 0077 enum TitleCommand { 0078 availableTitles, /**< \returns \c int representing the amount of 0079 available titles on the media source */ 0080 title, /**< \returns \c int representing the current title */ 0081 setTitle, /**< Sets the current title to the first \c int in the QList */ 0082 autoplayTitles, /**< \returns \c bool whether autoplay of titles is on */ 0083 setAutoplayTitles /**< Sets autoplay to \c true or \c false as 0084 indicated in the first \c bool in the QList */ 0085 }; 0086 0087 enum SubtitleCommand { 0088 availableSubtitles, /**< \returns \c int representing the amount of 0089 available subtitles on the media source */ 0090 currentSubtitle, /**< \returns \c int representing the current subtitle */ 0091 setCurrentSubtitle, /**< Sets the current subtitle to the first 0092 \c int in the QList */ 0093 setCurrentSubtitleFile, /**< Sets the current subtitle to the first QUrl \since 4.7.0 */ 0094 subtitleAutodetect, /**< \returns \c bool representing if subtitles 0095 autodetection is enabled \since 4.7.0 */ 0096 setSubtitleAutodetect, /**< Sets/Unsets subtitles autodetection \since 4.7.0 */ 0097 subtitleEncoding, /**< \returns a QString representing the current encoding 0098 used to render subtitles \since 4.7.0 */ 0099 setSubtitleEncoding, /** Sets the current encoding used to render subtitles \since 4.7.0 */ 0100 subtitleFont, /**< \returns a QFont representing the current font used 0101 to render subtitles \since 4.7.0 */ 0102 setSubtitleFont /**< Sets the current font used to render subtitles \since 4.7.0 */ 0103 }; 0104 0105 enum AudioChannelCommand { 0106 availableAudioChannels, /**< \returns \c int representing the amount 0107 of all available audio channels on the 0108 media source */ 0109 currentAudioChannel, /**< \returns \c int representing the current 0110 audio channel */ 0111 setCurrentAudioChannel /**< Sets the current audio channel to the first 0112 \c int in the QList */ 0113 }; 0114 0115 /** 0116 * Queries whether the backend supports a specific interface. 0117 * 0118 * \param iface The interface to query support information about 0119 * \returns \c true when the backend supports the interface, \c false otherwise 0120 * 0121 * \ingroup backend 0122 **/ 0123 virtual bool hasInterface(Interface iface) const = 0; 0124 0125 /** 0126 * Calls an interface on the backend. 0127 * 0128 * \param iface The interface to call. 0129 * \param command The command the interface shall execute. This can be 0130 * any value of the Command enumeration associated with the command. The 0131 * backend casts this appropriately. 0132 * \param arguments The arguments for the command. This list can contain 0133 * a QVariant supported format + additions specific to Phonon. The 0134 * content entirely depends on the command (e.g. a getter may simply use 0135 * an empty list). 0136 * 0137 * \return \c QVariant, as with the arguments this can be anything ranging 0138 * from an empty QVariant to custom types used within Phonon 0139 * 0140 * Setting the chapter of a Media could be done like this: 0141 * \code 0142 * AddonInterface *iface = d->iface(); 0143 * iface->interfaceCall(AddonInterface::ChapterInterface, 0144 * AddonInterface::setChapter, 0145 * QList<QVariant>() << QVariant(titleNumber)); 0146 * \endcode 0147 * 0148 * Handling such a request in the backend is done as follows: 0149 * \code 0150 * switch (iface) { 0151 * case AddonInterface::ChapterInterface: 0152 * switch (static_cast<AddonInterface::ChapterCommand>(command)) { 0153 * case setChapter: 0154 * setCurrentChapter(arguments.first().toInt()); 0155 * return QVariant(); 0156 * } 0157 * } 0158 * \endcode 0159 * 0160 * \see Interface 0161 * \see NavigationCommand 0162 * \see ChapterCommand 0163 * \see AngleCommand 0164 * \see TitleCommand 0165 * \see SubtitleCommand 0166 * \see AudioChannelCommand 0167 * 0168 * \ingroup backend 0169 **/ 0170 virtual QVariant interfaceCall(Interface iface, int command, 0171 const QList<QVariant> &arguments = QList<QVariant>()) = 0; 0172 }; 0173 0174 } // namespace Phonon 0175 0176 Q_DECLARE_INTERFACE(Phonon::AddonInterface, "AddonInterface0.2.phonon.kde.org") 0177 0178 #endif //QT_NO_PHONON_MEDIACONTROLLER 0179 0180 0181 #endif // PHONON_ADDONINTERFACE_H