Music Hub ..
A session-wide music playback service
 
Loading...
Searching...
No Matches
player.h
Go to the documentation of this file.
1/*
2 * Copyright © 2021-2022 UBports Foundation.
3 *
4 * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef LOMIRI_MEDIAHUB_PLAYER_H
20#define LOMIRI_MEDIAHUB_PLAYER_H
21
22#include "track.h"
23
24#include <QObject>
25#include <QScopedPointer>
26#include <QString>
27
28class QUrl;
29
30namespace lomiri {
31namespace MediaHub {
32
33class Error;
34class Service;
35class TrackList;
36class VideoSink;
37
38class PlayerPrivate;
40{
41 Q_OBJECT
42 Q_DISABLE_COPY(Player)
43 Q_PROPERTY(bool canPlay READ canPlay NOTIFY controlsChanged)
44 Q_PROPERTY(bool canPause READ canPause NOTIFY controlsChanged)
45 Q_PROPERTY(bool canSeek READ canSeek NOTIFY controlsChanged)
46 Q_PROPERTY(bool canGoPrevious READ canGoPrevious NOTIFY controlsChanged)
47 Q_PROPERTY(bool canGoNext READ canGoNext NOTIFY controlsChanged)
48
49 Q_PROPERTY(bool isVideoSource READ isVideoSource NOTIFY sourceTypeChanged)
50 Q_PROPERTY(bool isAudioSource READ isAudioSource NOTIFY sourceTypeChanged)
51
52 Q_PROPERTY(PlaybackStatus playbackStatus READ playbackStatus
53 NOTIFY playbackStatusChanged)
54 Q_PROPERTY(bool shuffle READ shuffle WRITE setShuffle
55 NOTIFY shuffleChanged)
56 Q_PROPERTY(Volume volume READ volume WRITE setVolume NOTIFY volumeChanged)
57 Q_PROPERTY(Track::MetaData metaDataForCurrentTrack
58 READ metaDataForCurrentTrack
59 NOTIFY metaDataForCurrentTrackChanged)
60
61 Q_PROPERTY(PlaybackRate playbackRate
62 READ playbackRate WRITE setPlaybackRate
63 NOTIFY playbackRateChanged)
64 Q_PROPERTY(PlaybackRate minimumPlaybackRate READ minimumPlaybackRate
65 NOTIFY minimumPlaybackRateChanged)
66 Q_PROPERTY(PlaybackRate maximumPlaybackRate READ maximumPlaybackRate
67 NOTIFY maximumPlaybackRateChanged)
68
69 Q_PROPERTY(quint64 position READ position NOTIFY positionChanged)
70 Q_PROPERTY(quint64 duration READ duration NOTIFY durationChanged)
71 Q_PROPERTY(Orientation orientation READ orientation
72 NOTIFY orientationChanged)
73
74 Q_PROPERTY(LoopStatus loopStatus READ loopStatus WRITE setLoopStatus
75 NOTIFY loopStatusChanged)
76 Q_PROPERTY(AudioStreamRole audioStreamRole
77 READ audioStreamRole WRITE setAudioStreamRole
78 NOTIFY audioStreamRoleChanged)
79
80public:
81 typedef double PlaybackRate;
82 typedef double Volume;
83 typedef QMap<QString, QString> Headers;
84
92 Q_ENUM(PlaybackStatus)
93
99 Q_ENUM(LoopStatus)
100
101
112 Q_ENUM(AudioStreamRole)
113
120 Q_ENUM(Orientation)
121
122 /* Do we need a link to the Service? We could call CreateSession
123 * internally.
124 */
125 Player(QObject *parent = nullptr);
126 virtual ~Player();
127
128 QString uuid() const;
129
130 /*
131 * Unused methods:
132 * - reconnect
133 * - abandon
134 */
135
136 void setTrackList(TrackList *trackList);
137 TrackList *trackList() const;
138
139 // The returned object is owned by the Player
140 VideoSink &createGLTextureVideoSink(uint32_t textureId);
141
142 void openUri(const QUrl &uri, const Headers &headers = {});
143 void goToNext();
144 void goToPrevious();
145 void play();
146 void pause();
147 void stop();
148 void seekTo(uint64_t microseconds);
149
150 /*
151 * Property accessors
152 */
153 bool canPlay() const;
154 bool canPause() const;
155 bool canSeek() const;
156 bool canGoPrevious() const;
157 bool canGoNext() const;
158
159 bool isVideoSource() const;
160 bool isAudioSource() const;
161
162 PlaybackStatus playbackStatus() const;
163 void setPlaybackRate(PlaybackRate rate);
164 PlaybackRate playbackRate() const;
165 void setShuffle(bool shuffle);
166 bool shuffle() const;
167 void setVolume(Volume volume);
168 Volume volume() const;
169 Track::MetaData metaDataForCurrentTrack() const;
170 PlaybackRate minimumPlaybackRate() const;
171 PlaybackRate maximumPlaybackRate() const;
172 quint64 position() const;
173 quint64 duration() const;
174 Orientation orientation() const;
175 void setLoopStatus(LoopStatus loopStatus);
176 LoopStatus loopStatus() const;
177 void setAudioStreamRole(AudioStreamRole role);
178 AudioStreamRole audioStreamRole() const;
179
180Q_SIGNALS:
192 void positionChanged(quint64 microseconds);
193 void durationChanged(quint64 microseconds);
196
197 void seekedTo(quint64 microseconds);
200 void videoDimensionChanged(const QSize &size);
202 void errorOccurred(const Error &error);
203 void bufferingChanged(int percent);
206
207private:
208 Q_DECLARE_PRIVATE(Player)
209 QScopedPointer<PlayerPrivate> d_ptr;
210};
211
212} // namespace MediaHub
213} // namespace lomiri
214
215#endif // LOMIRI_MEDIAHUB_PLAYER_H
void positionChanged(quint64 microseconds)
QMap< QString, QString > Headers
Definition player.h:83
void durationChanged(quint64 microseconds)
void videoDimensionChanged(const QSize &size)
void errorOccurred(const Error &error)
void bufferingChanged(int percent)
void seekedTo(quint64 microseconds)
A video sink abstracts a queue of buffers, that receives a stream of decoded video buffers from an ar...
Definition video_sink.h:35
#define MH_EXPORT
Definition global.h:27