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 qgstpipeline_p_H |
5 | #define qgstpipeline_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 <QtMultimedia/private/qtmultimediaglobal_p.h> |
19 | #include <QtCore/qobject.h> |
20 | |
21 | #include "qgst_p.h" |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QGstreamerMessage; |
26 | class QGstreamerBusMessageFilter; |
27 | struct QGstPipelinePrivate; |
28 | |
29 | class QGstPipeline : public QGstBin |
30 | { |
31 | static constexpr auto defaultQueryTimeout = std::chrono::seconds{ 5 }; |
32 | |
33 | public: |
34 | constexpr QGstPipeline() = default; |
35 | QGstPipeline(const QGstPipeline &) = default; |
36 | QGstPipeline(QGstPipeline &&) = default; |
37 | QGstPipeline &operator=(const QGstPipeline &) = default; |
38 | QGstPipeline &operator=(QGstPipeline &&) noexcept = default; |
39 | QGstPipeline(GstPipeline *, RefMode mode); |
40 | ~QGstPipeline(); |
41 | |
42 | static QGstPipeline createFromFactory(const char *factory, const char *name); |
43 | static QGstPipeline create(const char *name); |
44 | |
45 | void installMessageFilter(QGstreamerBusMessageFilter *filter); |
46 | void removeMessageFilter(QGstreamerBusMessageFilter *filter); |
47 | |
48 | GstStateChangeReturn setState(GstState state); |
49 | |
50 | GstPipeline *pipeline() const { return GST_PIPELINE_CAST(get()); } |
51 | |
52 | bool processNextPendingMessage(GstMessageType = GST_MESSAGE_ANY, |
53 | std::chrono::nanoseconds timeout = {}); |
54 | bool processNextPendingMessage(std::chrono::nanoseconds timeout); |
55 | |
56 | void flush(); |
57 | |
58 | void setPlaybackRate(double rate, bool forceFlushingSeek = false); |
59 | double playbackRate() const; |
60 | void applyPlaybackRate(bool forceFlushingSeek = false); |
61 | |
62 | void setPosition(std::chrono::nanoseconds pos, bool flush = true); |
63 | std::chrono::nanoseconds position() const; |
64 | std::chrono::milliseconds positionInMs() const; |
65 | |
66 | void setPositionAndRate(std::chrono::nanoseconds pos, double rate); |
67 | |
68 | std::optional<std::chrono::nanoseconds> |
69 | queryPosition(std::chrono::nanoseconds timeout = defaultQueryTimeout) const; |
70 | std::optional<std::chrono::nanoseconds> |
71 | queryDuration(std::chrono::nanoseconds timeout = defaultQueryTimeout) const; |
72 | std::optional<std::pair<std::chrono::nanoseconds, std::chrono::nanoseconds>> |
73 | queryPositionAndDuration(std::chrono::nanoseconds timeout = defaultQueryTimeout) const; |
74 | |
75 | void seekToEndWithEOS(); |
76 | |
77 | private: |
78 | // installs QGstPipelinePrivate as "pipeline-private" gobject property |
79 | static QGstPipeline adopt(GstPipeline *); |
80 | |
81 | void seek(std::chrono::nanoseconds pos, double rate, bool flush); |
82 | void seek(std::chrono::nanoseconds pos, bool flush); |
83 | |
84 | QGstPipelinePrivate *getPrivate() const; |
85 | }; |
86 | |
87 | QT_END_NAMESPACE |
88 | |
89 | #endif |
90 | |