1/*
2 Copyright (C) 2007-2008 Tanguy Krotoff <tkrotoff@gmail.com>
3 Copyright (C) 2008 Lukas Durfina <lukas.durfina@gmail.com>
4 Copyright (C) 2009 Fathi Boudra <fabo@kde.org>
5 Copyright (C) 2009-2011 vlc-phonon AUTHORS <kde-multimedia@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef PHONON_VLC_MEDIACONTROLLER_H
22#define PHONON_VLC_MEDIACONTROLLER_H
23
24#include <phonon/AddonInterface>
25#include <phonon/MediaSource>
26#include <phonon/ObjectDescription>
27
28#include <QtGui/QFont>
29
30class QTimer;
31
32namespace Phonon {
33namespace VLC {
34
35class MediaPlayer;
36
37/**
38 * \brief Interface for AddonInterface.
39 *
40 * Provides a bridge between Phonon's AddonInterface and MediaController.
41 *
42 * This class cannot inherit from QObject has MediaObject already inherit from QObject.
43 * This is a Qt limitation: there is no possibility to inherit virtual Qobject :/
44 * See http://doc.trolltech.com/qq/qq15-academic.html
45 * Phonon implementation got the same problem.
46 *
47 * \see MediaObject
48 */
49class MediaController : public AddonInterface
50{
51public:
52
53 MediaController();
54 virtual ~MediaController();
55
56 bool hasInterface(Interface iface) const override;
57
58 QVariant interfaceCall(Interface iface, int i_command, const QList<QVariant> & arguments = QList<QVariant>()) override;
59
60 /**
61 * Overloaded by MediaObject through MediaObjectInterface.
62 * Access to the media source is necessary to identify the type of the source
63 * and behave accordingly.
64 *
65 * For example setTitle calls need to work on both DVDs and CDs, however
66 * in libvlc titles and tracks are two different concepts.
67 */
68 virtual MediaSource source() const = 0;
69
70 // MediaController signals
71 virtual void availableSubtitlesChanged() = 0;
72 virtual void availableAudioChannelsChanged() = 0;
73
74 virtual void availableChaptersChanged(int) = 0;
75 virtual void availableTitlesChanged(int) = 0;
76
77 void titleAdded(int id, const QString &name);
78 void chapterAdded(int titleId, const QString &name);
79
80protected:
81 // AudioChannel
82 void setCurrentAudioChannel(const Phonon::AudioChannelDescription &audioChannel);
83 QList<Phonon::AudioChannelDescription> availableAudioChannels() const;
84 Phonon::AudioChannelDescription currentAudioChannel() const;
85 void refreshAudioChannels();
86
87 // Subtitle
88 void setCurrentSubtitle(const Phonon::SubtitleDescription &subtitle);
89 void setCurrentSubtitleFile(const QUrl &url);
90 QList<Phonon::SubtitleDescription> availableSubtitles() const;
91 Phonon::SubtitleDescription currentSubtitle() const;
92 void refreshSubtitles();
93 bool subtitleAutodetect() const;
94 void setSubtitleAutodetect(bool enabled);
95 QString subtitleEncoding() const;
96 void setSubtitleEncoding(const QString &encoding);
97 QFont subtitleFont() const;
98 void setSubtitleFont(const QFont &font);
99
100 // Chapter
101 void setCurrentChapter(int chapterNumber);
102 int availableChapters() const;
103 int currentChapter() const;
104 void refreshChapters(int title);
105
106 // Title
107 void setCurrentTitle(int titleNumber);
108 int availableTitles() const;
109 int currentTitle() const;
110 void setAutoplayTitles(bool autoplay);
111 bool autoplayTitles() const;
112 void refreshTitles();
113
114 /**
115 * Clear all member variables and emit appropriate signals.
116 * This is used each time we restart the video.
117 *
118 * \see resetMembers
119 */
120 void resetMediaController();
121
122 /**
123 * Reset all member variables.
124 *
125 * \see resetMediaController
126 */
127 void resetMembers();
128
129 Phonon::AudioChannelDescription m_currentAudioChannel;
130 Phonon::SubtitleDescription m_currentSubtitle;
131
132 int m_currentChapter;
133 int m_availableChapters;
134
135 int m_currentTitle;
136 int m_availableTitles;
137
138 bool m_autoPlayTitles;
139
140 bool m_subtitleAutodetect;
141 QString m_subtitleEncoding;
142 bool m_subtitleFontChanged;
143 QFont m_subtitleFont;
144
145 // MediaPlayer
146 MediaPlayer *m_player;
147
148 QTimer *m_refreshTimer;
149
150 bool m_attemptingAutoplay;
151};
152
153} // namespace VLC
154} // namespace Phonon
155
156#endif // PHONON_VLC_MEDIACONTROLLER_H
157

source code of phonon-vlc/src/mediacontroller.h