1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include <QtQml/qqmlextensionplugin.h> |
41 | #include <QtQml/qqml.h> |
42 | #include <QtQml/qqmlengine.h> |
43 | #include <QtQml/qqmlcomponent.h> |
44 | #include "qsoundeffect.h" |
45 | |
46 | #include <private/qdeclarativevideooutput_p.h> |
47 | #include "qabstractvideofilter.h" |
48 | |
49 | #include "qdeclarativemultimediaglobal_p.h" |
50 | #include "qdeclarativemediametadata_p.h" |
51 | #include "qdeclarativeaudio_p.h" |
52 | #include "qdeclarativeradio_p.h" |
53 | #include "qdeclarativeradiodata_p.h" |
54 | #include "qdeclarativeplaylist_p.h" |
55 | #include "qdeclarativecamera_p.h" |
56 | #include "qdeclarativecamerapreviewprovider_p.h" |
57 | #include "qdeclarativecameraexposure_p.h" |
58 | #include "qdeclarativecameraflash_p.h" |
59 | #include "qdeclarativecamerafocus_p.h" |
60 | #include "qdeclarativecameraimageprocessing_p.h" |
61 | #include "qdeclarativecameraviewfinder_p.h" |
62 | #include "qdeclarativetorch_p.h" |
63 | #include <QAbstractVideoSurface> |
64 | |
65 | QML_DECLARE_TYPE(QSoundEffect) |
66 | |
67 | QT_BEGIN_NAMESPACE |
68 | |
69 | static QObject *multimedia_global_object(QQmlEngine *qmlEngine, QJSEngine *jsEngine) |
70 | { |
71 | Q_UNUSED(qmlEngine) |
72 | return new QDeclarativeMultimediaGlobal(jsEngine); |
73 | } |
74 | |
75 | class QMultimediaDeclarativeModule : public QQmlExtensionPlugin |
76 | { |
77 | Q_OBJECT |
78 | Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) |
79 | |
80 | public: |
81 | QMultimediaDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { } |
82 | void registerTypes(const char *uri) override |
83 | { |
84 | Q_ASSERT(QLatin1String(uri) == QLatin1String("QtMultimedia" )); |
85 | |
86 | // 5.0 types |
87 | qmlRegisterType<QSoundEffect>(uri, versionMajor: 5, versionMinor: 0, qmlName: "SoundEffect" ); |
88 | qmlRegisterType<QDeclarativeAudio>(uri, versionMajor: 5, versionMinor: 0, qmlName: "Audio" ); |
89 | qmlRegisterType<QDeclarativeAudio>(uri, versionMajor: 5, versionMinor: 0, qmlName: "MediaPlayer" ); |
90 | qmlRegisterType<QDeclarativeVideoOutput>(uri, versionMajor: 5, versionMinor: 0, qmlName: "VideoOutput" ); |
91 | qmlRegisterType<QDeclarativeRadio>(uri, versionMajor: 5, versionMinor: 0, qmlName: "Radio" ); |
92 | qmlRegisterType<QDeclarativeRadioData>(uri, versionMajor: 5, versionMinor: 0, qmlName: "RadioData" ); |
93 | qmlRegisterType<QDeclarativeCamera>(uri, versionMajor: 5, versionMinor: 0, qmlName: "Camera" ); |
94 | qmlRegisterType<QDeclarativeTorch>(uri, versionMajor: 5, versionMinor: 0, qmlName: "Torch" ); |
95 | qmlRegisterUncreatableType<QDeclarativeCameraCapture>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraCapture" , |
96 | reason: tr(s: "CameraCapture is provided by Camera" )); |
97 | qmlRegisterUncreatableType<QDeclarativeCameraRecorder>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraRecorder" , |
98 | reason: tr(s: "CameraRecorder is provided by Camera" )); |
99 | qmlRegisterUncreatableType<QDeclarativeCameraExposure>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraExposure" , |
100 | reason: tr(s: "CameraExposure is provided by Camera" )); |
101 | qmlRegisterUncreatableType<QDeclarativeCameraFocus>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraFocus" , |
102 | reason: tr(s: "CameraFocus is provided by Camera" )); |
103 | qmlRegisterUncreatableType<QDeclarativeCameraFlash>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraFlash" , |
104 | reason: tr(s: "CameraFlash is provided by Camera" )); |
105 | qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing>(uri, versionMajor: 5, versionMinor: 0, qmlName: "CameraImageProcessing" , |
106 | reason: tr(s: "CameraImageProcessing is provided by Camera" )); |
107 | |
108 | // 5.2 types |
109 | qmlRegisterType<QDeclarativeVideoOutput, 2>(uri, versionMajor: 5, versionMinor: 2, qmlName: "VideoOutput" ); |
110 | |
111 | // 5.3 types |
112 | // Nothing changed, but adding "import QtMultimedia 5.3" in QML will fail unless at |
113 | // least one type is registered for that version. |
114 | qmlRegisterType<QSoundEffect>(uri, versionMajor: 5, versionMinor: 3, qmlName: "SoundEffect" ); |
115 | |
116 | // 5.4 types |
117 | qmlRegisterSingletonType<QDeclarativeMultimediaGlobal>(uri, versionMajor: 5, versionMinor: 4, typeName: "QtMultimedia" , callback: multimedia_global_object); |
118 | qmlRegisterType<QDeclarativeCamera, 1>(uri, versionMajor: 5, versionMinor: 4, qmlName: "Camera" ); |
119 | qmlRegisterUncreatableType<QDeclarativeCameraViewfinder>(uri, versionMajor: 5, versionMinor: 4, qmlName: "CameraViewfinder" , |
120 | reason: tr(s: "CameraViewfinder is provided by Camera" )); |
121 | |
122 | // 5.5 types |
123 | qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 1>(uri, versionMajor: 5, versionMinor: 5, qmlName: "CameraImageProcessing" , reason: tr(s: "CameraImageProcessing is provided by Camera" )); |
124 | qmlRegisterType<QDeclarativeCamera, 2>(uri, versionMajor: 5, versionMinor: 5, qmlName: "Camera" ); |
125 | |
126 | // 5.6 types |
127 | qmlRegisterType<QDeclarativeAudio, 1>(uri, versionMajor: 5, versionMinor: 6, qmlName: "Audio" ); |
128 | qmlRegisterType<QDeclarativeAudio, 1>(uri, versionMajor: 5, versionMinor: 6, qmlName: "MediaPlayer" ); |
129 | qmlRegisterType<QDeclarativePlaylist>(uri, versionMajor: 5, versionMinor: 6, qmlName: "Playlist" ); |
130 | qmlRegisterType<QDeclarativePlaylistItem>(uri, versionMajor: 5, versionMinor: 6, qmlName: "PlaylistItem" ); |
131 | |
132 | // 5.7 types |
133 | qmlRegisterType<QDeclarativePlaylist, 1>(uri, versionMajor: 5, versionMinor: 7, qmlName: "Playlist" ); |
134 | qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 2>(uri, versionMajor: 5, versionMinor: 7, qmlName: "CameraImageProcessing" , |
135 | reason: tr(s: "CameraImageProcessing is provided by Camera" )); |
136 | |
137 | // 5.8 types (nothing new, re-register one of the types) |
138 | qmlRegisterType<QSoundEffect>(uri, versionMajor: 5, versionMinor: 8, qmlName: "SoundEffect" ); |
139 | |
140 | // 5.9 types |
141 | qmlRegisterType<QDeclarativeAudio, 2>(uri, versionMajor: 5, versionMinor: 9, qmlName: "Audio" ); |
142 | qmlRegisterType<QDeclarativeAudio, 2>(uri, versionMajor: 5, versionMinor: 9, qmlName: "MediaPlayer" ); |
143 | qmlRegisterUncreatableType<QDeclarativeCameraCapture, 1>(uri, versionMajor: 5, versionMinor: 9, qmlName: "CameraCapture" , |
144 | reason: tr(s: "CameraCapture is provided by Camera" )); |
145 | qmlRegisterUncreatableType<QDeclarativeCameraFlash, 1>(uri, versionMajor: 5, versionMinor: 9, qmlName: "CameraFlash" , |
146 | reason: tr(s: "CameraFlash is provided by Camera" )); |
147 | |
148 | // 5.11 types |
149 | qmlRegisterType<QDeclarativeAudio, 3>(uri, versionMajor: 5, versionMinor: 11, qmlName: "Audio" ); |
150 | qmlRegisterType<QDeclarativeAudio, 3>(uri, versionMajor: 5, versionMinor: 11, qmlName: "MediaPlayer" ); |
151 | qmlRegisterUncreatableType<QDeclarativeCameraFocus, 1>(uri, versionMajor: 5, versionMinor: 11, qmlName: "CameraFocus" , |
152 | reason: tr(s: "CameraFocus is provided by Camera" )); |
153 | qmlRegisterUncreatableType<QDeclarativeCameraExposure, 1>(uri, versionMajor: 5, versionMinor: 11, qmlName: "CameraExposure" , |
154 | reason: tr(s: "CameraExposure is provided by Camera" )); |
155 | qmlRegisterUncreatableType<QDeclarativeCameraImageProcessing, 3>(uri, versionMajor: 5, versionMinor: 11, qmlName: "CameraImageProcessing" , |
156 | reason: tr(s: "CameraImageProcessing is provided by Camera" )); |
157 | |
158 | qmlRegisterType<QDeclarativeMediaMetaData>(); |
159 | qmlRegisterType<QAbstractVideoFilter>(); |
160 | |
161 | // 5.13 types |
162 | qmlRegisterType<QDeclarativeVideoOutput, 13>(uri, versionMajor: 5, versionMinor: 13, qmlName: "VideoOutput" ); |
163 | |
164 | // 5.15 types |
165 | qmlRegisterType<QDeclarativeAudio, 15>(uri, versionMajor: 5, versionMinor: 15, qmlName: "MediaPlayer" ); |
166 | qmlRegisterType<QDeclarativeVideoOutput, 15>(uri, versionMajor: 5, versionMinor: 15, qmlName: "VideoOutput" ); |
167 | qmlRegisterType<QAbstractVideoSurface>(); |
168 | |
169 | // Auto-increment the import to stay in sync with ALL future QtQuick minor versions from 5.11 onward |
170 | qmlRegisterModule(uri, versionMajor: 5, QT_VERSION_MINOR); |
171 | } |
172 | |
173 | void initializeEngine(QQmlEngine *engine, const char *uri) override |
174 | { |
175 | Q_UNUSED(uri); |
176 | engine->addImageProvider(id: "camera" , new QDeclarativeCameraPreviewProvider); |
177 | } |
178 | }; |
179 | |
180 | QT_END_NAMESPACE |
181 | |
182 | #include "multimedia.moc" |
183 | |
184 | |