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 test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef MOCKCAMERASERVICE_H
30#define MOCKCAMERASERVICE_H
31
32#include "qmediaservice.h"
33#include "../qmultimedia_common/mockcameraflashcontrol.h"
34#include "../qmultimedia_common/mockcameralockscontrol.h"
35#include "../qmultimedia_common/mockcamerafocuscontrol.h"
36#include "../qmultimedia_common/mockcamerazoomcontrol.h"
37#include "../qmultimedia_common/mockcameraimageprocessingcontrol.h"
38#include "../qmultimedia_common/mockcameraimagecapturecontrol.h"
39#include "../qmultimedia_common/mockcameraexposurecontrol.h"
40#include "../qmultimedia_common/mockcameracapturedestinationcontrol.h"
41#include "../qmultimedia_common/mockcameracapturebuffercontrol.h"
42#include "../qmultimedia_common/mockimageencodercontrol.h"
43#include "../qmultimedia_common/mockcameracontrol.h"
44#include "../qmultimedia_common/mockvideosurface.h"
45#include "../qmultimedia_common/mockvideorenderercontrol.h"
46#include "../qmultimedia_common/mockvideowindowcontrol.h"
47#include "../qmultimedia_common/mockvideodeviceselectorcontrol.h"
48#include "../qmultimedia_common/mockcamerainfocontrol.h"
49#include "../qmultimedia_common/mockcameraviewfindersettingscontrol.h"
50
51class MockSimpleCameraService : public QMediaService
52{
53 Q_OBJECT
54
55public:
56 MockSimpleCameraService(): QMediaService(0)
57 {
58 mockControl = new MockCameraControl(this);
59 }
60
61 ~MockSimpleCameraService()
62 {
63 }
64
65 QMediaControl* requestControl(const char *iid)
66 {
67 if (qstrcmp(str1: iid, QCameraControl_iid) == 0)
68 return mockControl;
69 return 0;
70 }
71
72 void releaseControl(QMediaControl*) {}
73
74 MockCameraControl *mockControl;
75};
76
77
78class MockCameraService : public QMediaService
79{
80 Q_OBJECT
81
82public:
83 MockCameraService(): QMediaService(0)
84 {
85 mockControl = new MockCameraControl(this);
86 mockLocksControl = new MockCameraLocksControl(this);
87 mockExposureControl = new MockCameraExposureControl(this);
88 mockFlashControl = new MockCameraFlashControl(this);
89 mockFocusControl = new MockCameraFocusControl(this);
90 mockZoomControl = new MockCameraZoomControl(this);
91 mockCaptureControl = new MockCaptureControl(mockControl, this);
92 mockCaptureBufferControl = new MockCaptureBufferFormatControl(this);
93 mockCaptureDestinationControl = new MockCaptureDestinationControl(this);
94 mockImageProcessingControl = new MockImageProcessingControl(this);
95 mockImageEncoderControl = new MockImageEncoderControl(this);
96 rendererControl = new MockVideoRendererControl(this);
97 windowControl = new MockVideoWindowControl(this);
98 mockVideoDeviceSelectorControl = new MockVideoDeviceSelectorControl(this);
99 mockCameraInfoControl = new MockCameraInfoControl(this);
100 mockViewfinderSettingsControl = new MockCameraViewfinderSettingsControl(this);
101 rendererRef = 0;
102 windowRef = 0;
103 }
104
105 ~MockCameraService()
106 {
107 }
108
109 QMediaControl* requestControl(const char *iid)
110 {
111 if (qstrcmp(str1: iid, QCameraControl_iid) == 0)
112 return mockControl;
113
114 if (qstrcmp(str1: iid, QCameraLocksControl_iid) == 0)
115 return mockLocksControl;
116
117 if (qstrcmp(str1: iid, QCameraExposureControl_iid) == 0)
118 return mockExposureControl;
119
120 if (qstrcmp(str1: iid, QCameraFlashControl_iid) == 0)
121 return mockFlashControl;
122
123 if (qstrcmp(str1: iid, QCameraFocusControl_iid) == 0)
124 return mockFocusControl;
125
126 if (qstrcmp(str1: iid, QCameraZoomControl_iid) == 0)
127 return mockZoomControl;
128
129 if (qstrcmp(str1: iid, QCameraImageCaptureControl_iid) == 0)
130 return mockCaptureControl;
131
132 if (qstrcmp(str1: iid, QCameraCaptureBufferFormatControl_iid) == 0)
133 return mockCaptureBufferControl;
134
135 if (qstrcmp(str1: iid, QCameraCaptureDestinationControl_iid) == 0)
136 return mockCaptureDestinationControl;
137
138 if (qstrcmp(str1: iid, QCameraImageProcessingControl_iid) == 0)
139 return mockImageProcessingControl;
140
141 if (qstrcmp(str1: iid, QImageEncoderControl_iid) == 0)
142 return mockImageEncoderControl;
143
144 if (qstrcmp(str1: iid, QVideoDeviceSelectorControl_iid) == 0)
145 return mockVideoDeviceSelectorControl;
146
147 if (qstrcmp(str1: iid, QCameraInfoControl_iid) == 0)
148 return mockCameraInfoControl;
149
150 if (qstrcmp(str1: iid, QVideoRendererControl_iid) == 0) {
151 if (rendererRef == 0) {
152 rendererRef += 1;
153 return rendererControl;
154 }
155 }
156 if (qstrcmp(str1: iid, QVideoWindowControl_iid) == 0) {
157 if (windowRef == 0) {
158 windowRef += 1;
159 return windowControl;
160 }
161 }
162
163 if (qstrcmp(str1: iid, QCameraViewfinderSettingsControl2_iid) == 0) {
164 return mockViewfinderSettingsControl;
165 }
166
167 return 0;
168 }
169
170 void releaseControl(QMediaControl *control)
171 {
172 if (control == rendererControl)
173 rendererRef -= 1;
174 if (control == windowControl)
175 windowRef -= 1;
176 }
177
178 MockCameraControl *mockControl;
179 MockCameraLocksControl *mockLocksControl;
180 MockCaptureControl *mockCaptureControl;
181 MockCaptureBufferFormatControl *mockCaptureBufferControl;
182 MockCaptureDestinationControl *mockCaptureDestinationControl;
183 MockCameraExposureControl *mockExposureControl;
184 MockCameraFlashControl *mockFlashControl;
185 MockCameraFocusControl *mockFocusControl;
186 MockCameraZoomControl *mockZoomControl;
187 MockImageProcessingControl *mockImageProcessingControl;
188 MockImageEncoderControl *mockImageEncoderControl;
189 MockVideoRendererControl *rendererControl;
190 MockVideoWindowControl *windowControl;
191 MockVideoDeviceSelectorControl *mockVideoDeviceSelectorControl;
192 MockCameraInfoControl *mockCameraInfoControl;
193 MockCameraViewfinderSettingsControl *mockViewfinderSettingsControl;
194 int rendererRef;
195 int windowRef;
196};
197
198#endif // MOCKCAMERASERVICE_H
199

source code of qtmultimedia/tests/auto/unit/qmultimedia_common/mockcameraservice.h