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 MOCKMEDIASERVICEPROVIDER_H
30#define MOCKMEDIASERVICEPROVIDER_H
31
32#include "qmediaserviceprovider_p.h"
33#include "qmediaservice.h"
34#include "mockvideodeviceselectorcontrol.h"
35#include "mockcamerainfocontrol.h"
36
37// Simple provider that lets you set the service
38class MockMediaServiceProvider : public QMediaServiceProvider
39{
40public:
41 MockMediaServiceProvider(QMediaService* s = 0, bool del=false)
42 : service(s), deleteServiceOnRelease(del)
43 {
44 }
45
46 QMediaService *requestService(const QByteArray &, const QMediaServiceProviderHint &)
47 {
48 return service;
49 }
50
51 void releaseService(QMediaService *service)
52 {
53 if (deleteServiceOnRelease) {
54 delete service;
55 this->service = 0;
56 }
57 }
58
59 QMediaServiceProviderHint::Features supportedFeatures(const QMediaService *) const
60 {
61 return features;
62 }
63
64 void setSupportedFeatures(QMediaServiceProviderHint::Features f)
65 {
66 features = f;
67 }
68
69 QByteArray defaultDevice(const QByteArray &serviceType) const
70 {
71 if (serviceType == Q_MEDIASERVICE_CAMERA)
72 return MockVideoDeviceSelectorControl::defaultCamera();
73
74 return QByteArray();
75 }
76
77 QList<QByteArray> devices(const QByteArray &serviceType) const
78 {
79 if (serviceType == Q_MEDIASERVICE_CAMERA)
80 return MockVideoDeviceSelectorControl::availableCameras();
81
82 return QList<QByteArray>();
83 }
84
85 QString deviceDescription(const QByteArray &serviceType, const QByteArray &device)
86 {
87 if (serviceType == Q_MEDIASERVICE_CAMERA)
88 return MockVideoDeviceSelectorControl::cameraDescription(camera: device);
89
90 return QString();
91 }
92
93 QCamera::Position cameraPosition(const QByteArray &device) const
94 {
95 return MockCameraInfoControl::position(camera: device);
96 }
97
98 int cameraOrientation(const QByteArray &device) const
99 {
100 return MockCameraInfoControl::orientation(camera: device);
101 }
102
103 QMediaService *service;
104 bool deleteServiceOnRelease;
105 QMediaServiceProviderHint::Features features;
106};
107
108#endif // MOCKMEDIASERVICEPROVIDER_H
109

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