1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMEDIAPLAYER_P_H
5#define QMEDIAPLAYER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qmediaplayer.h"
19#include "qmediametadata.h"
20#include "qvideosink.h"
21#include "qaudiooutput.h"
22#include "qaudiobufferoutput.h"
23#include "qplaybackoptions.h"
24#include <private/qplatformmediaplayer_p.h>
25#include <private/qerrorinfo_p.h>
26
27#include "private/qobject_p.h"
28#include <QtCore/qobject.h>
29#include <QtCore/qpointer.h>
30#include <QtCore/qurl.h>
31#include <QtCore/qfile.h>
32#include <QtCore/qtimer.h>
33
34#include <memory>
35
36QT_BEGIN_NAMESPACE
37
38class QPlatformMediaPlayer;
39
40class QMediaPlayerPrivate : public QObjectPrivate
41{
42 Q_DECLARE_PUBLIC(QMediaPlayer)
43
44public:
45 static QMediaPlayerPrivate *get(QMediaPlayer *session)
46 {
47 return reinterpret_cast<QMediaPlayerPrivate *>(QObjectPrivate::get(o: session));
48 }
49
50 QMediaPlayerPrivate() = default;
51 QPlatformMediaPlayer *control = nullptr;
52
53 QPointer<QAudioBufferOutput> audioBufferOutput;
54 QPointer<QAudioOutput> audioOutput;
55 QPointer<QVideoSink> videoSink;
56 QPointer<QObject> videoOutput;
57 QUrl qrcMedia;
58 std::unique_ptr<QFile> qrcFile;
59 QUrl source;
60 QIODevice *stream = nullptr;
61 QPlaybackOptions playbackOptions;
62
63 QMediaPlayer::PlaybackState state = QMediaPlayer::StoppedState;
64 QErrorInfo<QMediaPlayer::Error> error;
65
66 void setMedia(const QUrl &media, QIODevice *stream = nullptr);
67
68 QList<QMediaMetaData> trackMetaData(QPlatformMediaPlayer::TrackType s) const;
69
70 void setState(QMediaPlayer::PlaybackState state);
71 void setStatus(QMediaPlayer::MediaStatus status);
72 void setError(QMediaPlayer::Error error, const QString &errorString);
73
74 void setVideoSink(QVideoSink *sink)
75 {
76 Q_Q(QMediaPlayer);
77 if (sink == videoSink)
78 return;
79 if (videoSink)
80 videoSink->setSource(nullptr);
81 videoSink = sink;
82 if (sink)
83 sink->setSource(q);
84 if (control)
85 control->setVideoSink(sink);
86 emit q->videoOutputChanged();
87 }
88};
89
90QT_END_NAMESPACE
91
92#endif
93

source code of qtmultimedia/src/multimedia/playback/qmediaplayer_p.h