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 <private/qplatformmediaplayer_p.h>
23
24#include "private/qobject_p.h"
25#include <QtCore/qobject.h>
26#include <QtCore/qpointer.h>
27#include <QtCore/qurl.h>
28#include <QtCore/qfile.h>
29#include <QtCore/qtimer.h>
30
31#include <memory>
32
33QT_BEGIN_NAMESPACE
34
35class QPlatformMediaPlayer;
36
37class QMediaPlayerPrivate : public QObjectPrivate
38{
39 Q_DECLARE_PUBLIC(QMediaPlayer)
40
41public:
42 QMediaPlayerPrivate() = default;
43 QPlatformMediaPlayer* control = nullptr;
44 QString errorString;
45
46 QAudioOutput *audioOutput = nullptr;
47 QVideoSink *videoSink = nullptr;
48 QPointer<QObject> videoOutput;
49 QUrl qrcMedia;
50 std::unique_ptr<QFile> qrcFile;
51 QUrl source;
52 QIODevice *stream = nullptr;
53
54 QMediaPlayer::PlaybackState state = QMediaPlayer::StoppedState;
55 QMediaPlayer::Error error = QMediaPlayer::NoError;
56
57 void setMedia(const QUrl &media, QIODevice *stream = nullptr);
58
59 QList<QMediaMetaData> trackMetaData(QPlatformMediaPlayer::TrackType s) const;
60
61 void setState(QMediaPlayer::PlaybackState state);
62 void setStatus(QMediaPlayer::MediaStatus status);
63 void setError(QMediaPlayer::Error error, const QString &errorString);
64
65 void setVideoSink(QVideoSink *sink)
66 {
67 Q_Q(QMediaPlayer);
68 if (sink == videoSink)
69 return;
70 if (videoSink)
71 videoSink->setSource(nullptr);
72 videoSink = sink;
73 if (sink)
74 sink->setSource(q);
75 if (control)
76 control->setVideoSink(sink);
77 emit q->videoOutputChanged();
78 }
79};
80
81QT_END_NAMESPACE
82
83#endif
84

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