1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Copyright (C) 2016 Research In Motion
5** Contact: https://www.qt.io/licensing/
6**
7** This file is part of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial License Usage
11** Licensees holding valid commercial Qt licenses may use this file in
12** accordance with the commercial license agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and The Qt Company. For licensing terms
15** and conditions see https://www.qt.io/terms-conditions. For further
16** information use the contact form at https://www.qt.io/contact-us.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 3 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL3 included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 3 requirements
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25**
26** GNU General Public License Usage
27** Alternatively, this file may be used under the terms of the GNU
28** General Public License version 2.0 or (at your option) the GNU General
29** Public license version 3 or any later version approved by the KDE Free
30** Qt Foundation. The licenses are as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32** included in the packaging of this file. Please review the following
33** information to ensure the GNU General Public License requirements will
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35** https://www.gnu.org/licenses/gpl-3.0.html.
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#ifndef QDECLARATIVEVIDEOOUTPUT_BACKEND_P_H
42#define QDECLARATIVEVIDEOOUTPUT_BACKEND_P_H
43
44//
45// W A R N I N G
46// -------------
47//
48// This file is not part of the Qt API. It exists purely as an
49// implementation detail. This header file may change from version to
50// version without notice, or even be removed.
51//
52// We mean it.
53//
54
55#include <QtCore/qpointer.h>
56#include <QtCore/qsize.h>
57#include <QtQuick/qquickitem.h>
58#include <QtQuick/qsgnode.h>
59#include <private/qtmultimediaquickdefs_p.h>
60
61QT_BEGIN_NAMESPACE
62
63class QAbstractVideoSurface;
64class QDeclarativeVideoOutput;
65class QMediaService;
66class QAbstractVideoFilter;
67
68class Q_MULTIMEDIAQUICK_EXPORT QDeclarativeVideoBackend
69{
70public:
71 explicit QDeclarativeVideoBackend(QDeclarativeVideoOutput *parent)
72 : q(parent)
73 {}
74
75 virtual ~QDeclarativeVideoBackend()
76 {}
77
78 virtual bool init(QMediaService *service) = 0;
79 virtual void releaseSource() = 0;
80 virtual void releaseControl() = 0;
81 virtual void itemChange(QQuickItem::ItemChange change,
82 const QQuickItem::ItemChangeData &changeData) = 0;
83 virtual QSize nativeSize() const = 0;
84 virtual void updateGeometry() = 0;
85 virtual QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) = 0;
86 virtual QAbstractVideoSurface *videoSurface() const = 0;
87
88 // The viewport, adjusted for the pixel aspect ratio
89 virtual QRectF adjustedViewport() const = 0;
90
91 virtual void appendFilter(QAbstractVideoFilter *filter) { Q_UNUSED(filter); }
92 virtual void clearFilters() { }
93
94 virtual void releaseResources() { }
95 virtual void invalidateSceneGraph() { }
96
97protected:
98 QDeclarativeVideoOutput *q;
99 QPointer<QMediaService> m_service;
100};
101
102class QDeclarativeVideoBackendFactoryInterface
103{
104public:
105 virtual QDeclarativeVideoBackend *create(QDeclarativeVideoOutput *parent) = 0;
106};
107
108#define QDeclarativeVideoBackendFactoryInterface_iid "org.qt-project.qt.declarativevideobackendfactory/5.2"
109Q_DECLARE_INTERFACE(QDeclarativeVideoBackendFactoryInterface, QDeclarativeVideoBackendFactoryInterface_iid)
110
111/*
112 * Helper - returns true if the given orientation has the same aspect as the default (e.g. 180*n)
113 */
114namespace {
115
116inline bool qIsDefaultAspect(int o)
117{
118 return (o % 180) == 0;
119}
120
121/*
122 * Return the orientation normalized to 0-359
123 */
124inline int qNormalizedOrientation(int o)
125{
126 // Negative orientations give negative results
127 int o2 = o % 360;
128 if (o2 < 0)
129 o2 += 360;
130 return o2;
131}
132
133}
134
135QT_END_NAMESPACE
136
137#endif
138

source code of qtmultimedia/src/qtmultimediaquicktools/qdeclarativevideooutput_backend_p.h