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
54 Q_PROPERTY(bool shuffle READ shuffle WRITE setShuffle
56 Q_PROPERTY(Volume volume READ volume WRITE setVolume NOTIFY volumeChanged)
57 Q_PROPERTY(Track::MetaData metaDataForCurrentTrack
60
68
69 Q_PROPERTY(quint64 position READ position NOTIFY positionChanged)
70 Q_PROPERTY(quint64 duration READ duration NOTIFY durationChanged)
72 NOTIFY orientationChanged)
80public:
81 typedef double PlaybackRate;
82 typedef double Volume;
83 typedef QMap<QString, QString> Headers;
86 Null,
87 Ready,
88 Playing,
89 Paused,
90 Stopped,
91 };
92 Q_ENUM(PlaybackStatus)
93
98 };
99 Q_ENUM(LoopStatus)
100
101
102 * Audio stream role types used to categorize audio playback.
103 * multimedia is the default role type and will be automatically
104 * paused by media-hub when other types need to play.
105 */
107 AlarmRole,
108 AlertRole,
110 PhoneRole,
111 };
112 Q_ENUM(AudioStreamRole)
113
115 Rotate0,
116 Rotate90,
117 Rotate180,
118 Rotate270,
119 };
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;
172 quint64 position() const;
173 quint64 duration() const;
180Q_SIGNALS:
184 void backendChanged();
189 void volumeChanged();
192 void positionChanged(quint64 microseconds);
193 void durationChanged(quint64 microseconds);
195 void orientationChanged();
196
197 void seekedTo(quint64 microseconds);
198 void aboutToFinish();
199 void endOfStream();
200 void videoDimensionChanged(const QSize &size);
202 void errorOccurred(const Error &error);
203 void bufferingChanged(int percent);
204 void serviceDisconnected();
205 void serviceReconnected();
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
PlaybackRate minimumPlaybackRate
Definition player.h:58
Player(QObject *parent=nullptr)
Definition player.cpp:506
void setLoopStatus(LoopStatus loopStatus)
Definition player.cpp:712
AudioStreamRole audioStreamRole
Definition player.h:66
void positionChanged(quint64 microseconds)
QMap< QString, QString > Headers
Definition player.h:71
PlaybackStatus playbackStatus
Definition player.h:52
void durationChanged(quint64 microseconds)
LoopStatus loopStatus
Definition player.h:65
void videoDimensionChanged(const QSize &size)
void errorOccurred(const Error &error)
Track::MetaData metaDataForCurrentTrack
Definition player.h:55
void setPlaybackRate(PlaybackRate rate)
Definition player.cpp:636
Orientation orientation
Definition player.h:63
void setVolume(Volume volume)
Definition player.cpp:662
PlaybackRate playbackRate
Definition player.h:57
void setAudioStreamRole(AudioStreamRole role)
Definition player.cpp:740
PlaybackRate maximumPlaybackRate
Definition player.h:59
void bufferingChanged(int percent)
void setShuffle(bool shuffle)
Definition player.cpp:649
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