Debian Codegraph @

tests/examples/qt/qmlsink-multisink/videoitem/videoitem.h

raw
1 // SPDX-License-Identifier: BSD-2-Clause
2 //
3 // Copyright (C) 2015, Matthew Waters <[email protected]>
4 // Copyright (C) 2021, Dmitry Shusharin <[email protected]>
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 //
9 // a) Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 //
12 // b) Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in
14 // the documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26 // THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef VIDEOITEM_H
29 #define VIDEOITEM_H
30
31 #include <QQuickItem>
32
33 struct VideoItemPrivate;
34
35 class VideoItem : public QQuickItem
36 {
37 Q_OBJECT
38 Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
39 Q_PROPERTY(State state READ state NOTIFY stateChanged)
40 Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged)
41 Q_PROPERTY(QRect rect READ rect NOTIFY rectChanged)
42 Q_PROPERTY(QSize resolution READ resolution NOTIFY resolutionChanged)
43
44 public:
45 enum State {
46 STATE_VOID_PENDING = 0,
47 STATE_NULL = 1,
48 STATE_READY = 2,
49 STATE_PAUSED = 3,
50 STATE_PLAYING = 4
51 };
52 Q_ENUM(State);
53
54 explicit VideoItem(QQuickItem *parent = nullptr);
55 ~VideoItem();
56
57 bool hasVideo() const;
58
59 QString source() const;
60 void setSource(const QString &source);
61
62 State state() const;
63 void setState(State state);
64
65 QRect rect() const;
66
67 QSize resolution() const;
68
69 Q_INVOKABLE void play();
70 Q_INVOKABLE void stop();
71
72 signals:
73 void hasVideoChanged(bool hasVideo);
74 void stateChanged(VideoItem::State state);
75 void sourceChanged(const QString &source);
76 void rectChanged(const QRect &rect);
77 void resolutionChanged(const QSize &resolution);
78
79 void errorOccurred(const QString &error);
80
81 protected:
82 void componentComplete() override;
83 void releaseResources() override;
84
85 private:
86 void updateRect();
87 void setRect(const QRect &rect);
88 void setResolution(const QSize &resolution);
89
90 private:
91 QSharedPointer<VideoItemPrivate> _priv;
92 };
93
94 #endif // VIDEOITEM_H