File indexing completed on 2024-12-01 04:21:25
0001 /* 0002 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com> 0003 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com> 0004 Copyright (C) 2009 Fathi Boudra <fabo@kde.org> 0005 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org> 0006 0007 This library is free software; you can redistribute it and/or 0008 modify it under the terms of the GNU Lesser General Public 0009 License as published by the Free Software Foundation; either 0010 version 2.1 of the License, or (at your option) any later version. 0011 0012 This library is distributed in the hope that it will be useful, 0013 but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 Lesser General Public License for more details. 0016 0017 You should have received a copy of the GNU Lesser General Public 0018 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 */ 0020 0021 #ifndef PHONON_VLC_MEDIACONTROLLER_H 0022 #define PHONON_VLC_MEDIACONTROLLER_H 0023 0024 #include <phonon/AddonInterface> 0025 #include <phonon/MediaSource> 0026 #include <phonon/ObjectDescription> 0027 0028 #include <QtGui/QFont> 0029 0030 class QTimer; 0031 0032 namespace Phonon { 0033 namespace VLC { 0034 0035 class MediaPlayer; 0036 0037 /** 0038 * \brief Interface for AddonInterface. 0039 * 0040 * Provides a bridge between Phonon's AddonInterface and MediaController. 0041 * 0042 * This class cannot inherit from QObject has MediaObject already inherit from QObject. 0043 * This is a Qt limitation: there is no possibility to inherit virtual Qobject :/ 0044 * See http://doc.trolltech.com/qq/qq15-academic.html 0045 * Phonon implementation got the same problem. 0046 * 0047 * \see MediaObject 0048 */ 0049 class MediaController : public AddonInterface 0050 { 0051 public: 0052 0053 MediaController(); 0054 virtual ~MediaController(); 0055 0056 bool hasInterface(Interface iface) const override; 0057 0058 QVariant interfaceCall(Interface iface, int i_command, const QList<QVariant> & arguments = QList<QVariant>()) override; 0059 0060 /** 0061 * Overloaded by MediaObject through MediaObjectInterface. 0062 * Access to the media source is necessary to identify the type of the source 0063 * and behave accordingly. 0064 * 0065 * For example setTitle calls need to work on both DVDs and CDs, however 0066 * in libvlc titles and tracks are two different concepts. 0067 */ 0068 virtual MediaSource source() const = 0; 0069 0070 // MediaController signals 0071 virtual void availableSubtitlesChanged() = 0; 0072 virtual void availableAudioChannelsChanged() = 0; 0073 0074 virtual void availableChaptersChanged(int) = 0; 0075 virtual void availableTitlesChanged(int) = 0; 0076 0077 void titleAdded(int id, const QString &name); 0078 void chapterAdded(int titleId, const QString &name); 0079 0080 protected: 0081 // AudioChannel 0082 void setCurrentAudioChannel(const Phonon::AudioChannelDescription &audioChannel); 0083 QList<Phonon::AudioChannelDescription> availableAudioChannels() const; 0084 Phonon::AudioChannelDescription currentAudioChannel() const; 0085 void refreshAudioChannels(); 0086 0087 // Subtitle 0088 void setCurrentSubtitle(const Phonon::SubtitleDescription &subtitle); 0089 void setCurrentSubtitleFile(const QUrl &url); 0090 QList<Phonon::SubtitleDescription> availableSubtitles() const; 0091 Phonon::SubtitleDescription currentSubtitle() const; 0092 void refreshSubtitles(); 0093 bool subtitleAutodetect() const; 0094 void setSubtitleAutodetect(bool enabled); 0095 QString subtitleEncoding() const; 0096 void setSubtitleEncoding(const QString &encoding); 0097 QFont subtitleFont() const; 0098 void setSubtitleFont(const QFont &font); 0099 0100 // Chapter 0101 void setCurrentChapter(int chapterNumber); 0102 int availableChapters() const; 0103 int currentChapter() const; 0104 void refreshChapters(int title); 0105 0106 // Title 0107 void setCurrentTitle(int titleNumber); 0108 int availableTitles() const; 0109 int currentTitle() const; 0110 void setAutoplayTitles(bool autoplay); 0111 bool autoplayTitles() const; 0112 void refreshTitles(); 0113 0114 /** 0115 * Clear all member variables and emit appropriate signals. 0116 * This is used each time we restart the video. 0117 * 0118 * \see resetMembers 0119 */ 0120 void resetMediaController(); 0121 0122 /** 0123 * Reset all member variables. 0124 * 0125 * \see resetMediaController 0126 */ 0127 void resetMembers(); 0128 0129 Phonon::AudioChannelDescription m_currentAudioChannel; 0130 Phonon::SubtitleDescription m_currentSubtitle; 0131 0132 int m_currentChapter; 0133 int m_availableChapters; 0134 0135 int m_currentTitle; 0136 int m_availableTitles; 0137 0138 bool m_autoPlayTitles; 0139 0140 bool m_subtitleAutodetect; 0141 QString m_subtitleEncoding; 0142 bool m_subtitleFontChanged; 0143 QFont m_subtitleFont; 0144 0145 // MediaPlayer 0146 MediaPlayer *m_player; 0147 0148 QTimer *m_refreshTimer; 0149 0150 bool m_attemptingAutoplay; 0151 }; 0152 0153 } // namespace VLC 0154 } // namespace Phonon 0155 0156 #endif // PHONON_VLC_MEDIACONTROLLER_H