Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqnxmediaplayer_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 Research In Motion
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QQnxMediaPlayer_H
4#define QQnxMediaPlayer_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
19
20#include <private/qplatformmediaplayer_p.h>
21#include <QtCore/qabstractnativeeventfilter.h>
22#include <QtCore/qpointer.h>
23#include <QtCore/qtimer.h>
24
25#include <mm/renderer.h>
26#include <mm/renderer/types.h>
27
28#include <optional>
29
30QT_BEGIN_NAMESPACE
31
32class QQnxVideoSink;
35
38{
40public:
41 explicit QQnxMediaPlayer(QMediaPlayer *parent = nullptr);
43
44 qint64 duration() const override;
45
46 qint64 position() const override;
47 void setPosition(qint64 position) override;
48
49 void setAudioOutput(QPlatformAudioOutput *) override;
50
51 float bufferProgress() const override;
52
53 bool isAudioAvailable() const override;
54 bool isVideoAvailable() const override;
55
56 bool isSeekable() const override;
57
59
60 qreal playbackRate() const override;
61 void setPlaybackRate(qreal rate) override;
62
63 QUrl media() const override;
64 const QIODevice *mediaStream() const override;
65 void setMedia(const QUrl &media, QIODevice *stream) override;
66
67 void play() override;
68 void pause() override;
69 void stop() override;
70
71 void setVideoSink(QVideoSink *videoSink);
72
73private Q_SLOTS:
74 void setVolume(float volume);
75 void setMuted(bool muted);
76 void readEvents();
77
78private:
79 void startMonitoring();
80 void stopMonitoring();
81 void resetMonitoring();
82
83 void openConnection();
84 void emitMmError(const char *msg);
85 void emitMmError(const QString &msg);
86 void emitPError(const QString &msg);
87
88 void handleMmPositionChanged(qint64 newPosition);
89 void updateBufferLevel(int level, int capacity);
90 void updateMetaData(const strm_dict_t *dict);
91
92 void handleMmEventState(const mmr_event_t *event);
93 void handleMmEventStatus(const mmr_event_t *event);
94 void handleMmEventStatusData(const strm_dict_t *data);
95 void handleMmEventError(const mmr_event_t *event);
96
97 QByteArray resourcePathForUrl(const QUrl &url);
98
99 void closeConnection();
100 void attach();
101
102 bool attachVideoOutput();
103 bool attachAudioOutput();
104 bool attachInput();
105
106 void detach();
107 void detachVideoOutput();
108 void detachAudioOutput();
109 void detachInput();
110
111 bool isVideoOutputAttached() const;
112 bool isAudioOutputAttached() const;
113 bool isInputAttached() const;
114
115 void updateScene(const QSize &size);
116
117 void updateVolume();
118
119 void setPositionInternal(qint64 position);
120 void flushPosition();
121
122 bool isPendingPositionFlush() const;
123
124 void setDeferredSpeedEnabled(bool enabled);
125 bool isDeferredSpeedEnabled() const;
126
127 mmr_context_t *m_context = nullptr;
128 mmr_connection_t *m_connection = nullptr;
129
130 QString m_contextName;
131
132 int m_id = -1;
133 int m_audioId = -1;
134 int m_volume = 50; // range is 0-100
135
136 QUrl m_media;
137 QPointer<QAudioOutput> m_audioOutput;
138 QPointer<QQnxVideoSink> m_platformVideoSink;
139
140 QQnxMediaMetaData m_metaData;
141
142 qint64 m_position = 0;
143 qint64 m_pendingPosition = 0;
144
145 int m_bufferLevel = 0;
146
147 int m_videoId = -1;
148
149 QTimer m_flushPositionTimer;
150
151 QQnxMediaEventThread *m_eventThread = nullptr;
152
153 int m_speed = 1000;
154 int m_configuredSpeed = 1000;
155
156 std::optional<int> m_deferredSpeed;
157
158 QQnxWindowGrabber* m_windowGrabber = nullptr;
159
160 bool m_inputAttached = false;
161 bool m_muted = false;
162 bool m_deferredSpeedEnabled = false;
163};
164
165QT_END_NAMESPACE
166
167#endif
QObject * parent
Definition qobject.h:73
void pause() override
const QIODevice * mediaStream() const override
bool isSeekable() const override
void setVideoSink(QVideoSink *videoSink)
void setAudioOutput(QPlatformAudioOutput *) override
void play() override
void setPlaybackRate(qreal rate) override
qint64 position() const override
QMediaTimeRange availablePlaybackRanges() const override
bool isAudioAvailable() const override
float bufferProgress() const override
void setPosition(qint64 position) override
qint64 duration() const override
void stop() override
qreal playbackRate() const override
QUrl media() const override
bool isVideoAvailable() const override
void setMedia(const QUrl &media, QIODevice *stream) override
MapData map(QVideoFrame::MapMode mode) override
Maps the planes of a video buffer to memory.
QnxRasterBuffer(QQnxWindowGrabber *windowGrabber)
void unmap() override
Releases the memory mapped by the map() function.
QVideoFrameFormat format() const override
Gets \l QVideoFrameFormat of the underlying video buffer.
quint64 textureHandle(QRhi &, int plane) override
QnxTextureBuffer(QQnxWindowGrabber *QQnxWindowGrabber)
MapData map(QVideoFrame::MapMode) override
Maps the planes of a video buffer to memory.
void unmap() override
Releases the memory mapped by the map() function.
struct strm_dict strm_dict_t
static constexpr int normalizeVolume(float volume)
static std::tuple< int, int, bool > parseBufferLevel(const QString &value)
static constexpr qreal speedToRate(int speed)
static constexpr int rateToSpeed(qreal rate)