1 | /* This file is part of the KDE project |
2 | Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Lesser General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2.1 of the License, or (at your option) version 3, or any |
8 | later version accepted by the membership of KDE e.V. (or its |
9 | successor approved by the membership of KDE e.V.), Nokia Corporation |
10 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
11 | act as a proxy defined in Section 6 of version 3 of the license. |
12 | |
13 | This library is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | Lesser General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Lesser General Public |
19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
20 | |
21 | */ |
22 | |
23 | #include "backendcapabilities.h" |
24 | #include "backendcapabilities_p.h" |
25 | |
26 | #include "phonondefs_p.h" |
27 | #include "backendinterface.h" |
28 | #include "factory_p.h" |
29 | #include "globalconfig.h" |
30 | #include "globalstatic_p.h" |
31 | #include "objectdescription.h" |
32 | |
33 | #include <QList> |
34 | #include <QSet> |
35 | #include <QStringList> |
36 | |
37 | PHONON_GLOBAL_STATIC(Phonon::BackendCapabilitiesPrivate, globalBCPrivate) |
38 | |
39 | namespace Phonon |
40 | { |
41 | |
42 | BackendCapabilities::Notifier *BackendCapabilities::notifier() |
43 | { |
44 | return globalBCPrivate; |
45 | } |
46 | |
47 | QStringList BackendCapabilities::availableMimeTypes() |
48 | { |
49 | if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(object: Factory::backend())) |
50 | return backendIface->availableMimeTypes(); |
51 | else |
52 | return QStringList(); |
53 | } |
54 | |
55 | bool BackendCapabilities::isMimeTypeAvailable(const QString &mimeType) |
56 | { |
57 | QObject *m_backendObject = Factory::backend(createWhenNull: false); |
58 | if (!m_backendObject) { |
59 | if (!Factory::isMimeTypeAvailable(mimeType)) { |
60 | return false; |
61 | } |
62 | // without loading the backend we found out that the MIME type might be supported, now we |
63 | // want to know for certain. For that we need to load the backend. |
64 | m_backendObject = Factory::backend(createWhenNull: true); |
65 | } |
66 | if (!m_backendObject) { |
67 | // no backend == no MIME type supported at all |
68 | return false; |
69 | } |
70 | return availableMimeTypes().contains(str: mimeType); |
71 | } |
72 | |
73 | QList<AudioOutputDevice> BackendCapabilities::availableAudioOutputDevices() |
74 | { |
75 | QList<AudioOutputDevice> ret; |
76 | #ifndef QT_NO_PHONON_SETTINGSGROUP |
77 | const QList<int> deviceIndexes = GlobalConfig().audioOutputDeviceListFor(category: Phonon::NoCategory, override: GlobalConfig::ShowAdvancedDevices); |
78 | for (int i = 0; i < deviceIndexes.count(); ++i) { |
79 | ret.append(t: AudioOutputDevice::fromIndex(index: deviceIndexes.at(i))); |
80 | } |
81 | #endif //QT_NO_PHONON_SETTINGSGROUP |
82 | return ret; |
83 | } |
84 | |
85 | |
86 | #ifndef PHONON_NO_AUDIOCAPTURE |
87 | QList<AudioCaptureDevice> BackendCapabilities::availableAudioCaptureDevices() |
88 | { |
89 | QList<AudioCaptureDevice> ret; |
90 | const QList<int> deviceIndexes = GlobalConfig().audioCaptureDeviceListFor(category: Phonon::NoCaptureCategory, override: GlobalConfig::ShowAdvancedDevices); |
91 | for (int i = 0; i < deviceIndexes.count(); ++i) { |
92 | ret.append(t: AudioCaptureDevice::fromIndex(index: deviceIndexes.at(i))); |
93 | } |
94 | return ret; |
95 | } |
96 | #endif //PHONON_NO_AUDIOCAPTURE |
97 | |
98 | #ifndef PHONON_NO_VIDEOCAPTURE |
99 | QList<VideoCaptureDevice> BackendCapabilities::availableVideoCaptureDevices() |
100 | { |
101 | QList<VideoCaptureDevice> ret; |
102 | const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(category: Phonon::NoCaptureCategory, override: GlobalConfig::ShowAdvancedDevices); |
103 | for (int i = 0; i < deviceIndexes.count(); ++i) { |
104 | ret.append(t: VideoCaptureDevice::fromIndex(index: deviceIndexes.at(i))); |
105 | } |
106 | return ret; |
107 | } |
108 | #endif //PHONON_NO_VIDEOCAPTURE |
109 | |
110 | #if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) |
111 | QList<VideoCaptureDevice> BackendCapabilities::availableAVCaptureDevices() |
112 | { |
113 | QList<VideoCaptureDevice> ret; |
114 | const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(category: Phonon::NoCaptureCategory, override: GlobalConfig::ShowAdvancedDevices); |
115 | for (int i = 0; i < deviceIndexes.count(); ++i) { |
116 | VideoCaptureDevice vcd = VideoCaptureDevice::fromIndex(index: deviceIndexes.at(i)); |
117 | if (vcd.propertyNames().contains(t: "hasaudio" ) && vcd.property(name: "hasaudio" ).isValid()) |
118 | ret.append(t: vcd); |
119 | } |
120 | return ret; |
121 | } |
122 | #endif // NOT PHONON_NO_VIDEOCAPTURE AND NOT PHONON_NO_AUDIOCAPTURE |
123 | |
124 | #ifndef QT_NO_PHONON_EFFECT |
125 | QList<EffectDescription> BackendCapabilities::availableAudioEffects() |
126 | { |
127 | BackendInterface *backendIface = qobject_cast<BackendInterface *>(object: Factory::backend()); |
128 | QList<EffectDescription> ret; |
129 | if (backendIface) { |
130 | const QList<int> deviceIndexes = backendIface->objectDescriptionIndexes(type: Phonon::EffectType); |
131 | for (int i = 0; i < deviceIndexes.count(); ++i) { |
132 | ret.append(t: EffectDescription::fromIndex(index: deviceIndexes.at(i))); |
133 | } |
134 | } |
135 | return ret; |
136 | } |
137 | #endif //QT_NO_PHONON_EFFECT |
138 | |
139 | } // namespace Phonon |
140 | |
141 | #include "moc_backendcapabilities.cpp" |
142 | |
143 | // vim: sw=4 ts=4 |
144 | |
145 | |
146 | |