File indexing completed on 2025-02-09 05:31:46
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 0023 #include "backendcapabilities.h" 0024 #include "backendcapabilities_p.h" 0025 0026 #include "phonondefs_p.h" 0027 #include "backendinterface.h" 0028 #include "factory_p.h" 0029 #include "globalconfig.h" 0030 #include "globalstatic_p.h" 0031 #include "objectdescription.h" 0032 0033 #include <QList> 0034 #include <QSet> 0035 #include <QStringList> 0036 0037 PHONON_GLOBAL_STATIC(Phonon::BackendCapabilitiesPrivate, globalBCPrivate) 0038 0039 namespace Phonon 0040 { 0041 0042 BackendCapabilities::Notifier *BackendCapabilities::notifier() 0043 { 0044 return globalBCPrivate; 0045 } 0046 0047 QStringList BackendCapabilities::availableMimeTypes() 0048 { 0049 if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) 0050 return backendIface->availableMimeTypes(); 0051 else 0052 return QStringList(); 0053 } 0054 0055 bool BackendCapabilities::isMimeTypeAvailable(const QString &mimeType) 0056 { 0057 QObject *m_backendObject = Factory::backend(false); 0058 if (!m_backendObject) { 0059 if (!Factory::isMimeTypeAvailable(mimeType)) { 0060 return false; 0061 } 0062 // without loading the backend we found out that the MIME type might be supported, now we 0063 // want to know for certain. For that we need to load the backend. 0064 m_backendObject = Factory::backend(true); 0065 } 0066 if (!m_backendObject) { 0067 // no backend == no MIME type supported at all 0068 return false; 0069 } 0070 return availableMimeTypes().contains(mimeType); 0071 } 0072 0073 QList<AudioOutputDevice> BackendCapabilities::availableAudioOutputDevices() 0074 { 0075 QList<AudioOutputDevice> ret; 0076 #ifndef QT_NO_PHONON_SETTINGSGROUP 0077 const QList<int> deviceIndexes = GlobalConfig().audioOutputDeviceListFor(Phonon::NoCategory, GlobalConfig::ShowAdvancedDevices); 0078 for (int i = 0; i < deviceIndexes.count(); ++i) { 0079 ret.append(AudioOutputDevice::fromIndex(deviceIndexes.at(i))); 0080 } 0081 #endif //QT_NO_PHONON_SETTINGSGROUP 0082 return ret; 0083 } 0084 0085 0086 #ifndef PHONON_NO_AUDIOCAPTURE 0087 QList<AudioCaptureDevice> BackendCapabilities::availableAudioCaptureDevices() 0088 { 0089 QList<AudioCaptureDevice> ret; 0090 const QList<int> deviceIndexes = GlobalConfig().audioCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); 0091 for (int i = 0; i < deviceIndexes.count(); ++i) { 0092 ret.append(AudioCaptureDevice::fromIndex(deviceIndexes.at(i))); 0093 } 0094 return ret; 0095 } 0096 #endif //PHONON_NO_AUDIOCAPTURE 0097 0098 #ifndef PHONON_NO_VIDEOCAPTURE 0099 QList<VideoCaptureDevice> BackendCapabilities::availableVideoCaptureDevices() 0100 { 0101 QList<VideoCaptureDevice> ret; 0102 const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); 0103 for (int i = 0; i < deviceIndexes.count(); ++i) { 0104 ret.append(VideoCaptureDevice::fromIndex(deviceIndexes.at(i))); 0105 } 0106 return ret; 0107 } 0108 #endif //PHONON_NO_VIDEOCAPTURE 0109 0110 #if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE) 0111 QList<VideoCaptureDevice> BackendCapabilities::availableAVCaptureDevices() 0112 { 0113 QList<VideoCaptureDevice> ret; 0114 const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices); 0115 for (int i = 0; i < deviceIndexes.count(); ++i) { 0116 VideoCaptureDevice vcd = VideoCaptureDevice::fromIndex(deviceIndexes.at(i)); 0117 if (vcd.propertyNames().contains("hasaudio") && vcd.property("hasaudio").isValid()) 0118 ret.append(vcd); 0119 } 0120 return ret; 0121 } 0122 #endif // NOT PHONON_NO_VIDEOCAPTURE AND NOT PHONON_NO_AUDIOCAPTURE 0123 0124 #ifndef QT_NO_PHONON_EFFECT 0125 QList<EffectDescription> BackendCapabilities::availableAudioEffects() 0126 { 0127 BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend()); 0128 QList<EffectDescription> ret; 0129 if (backendIface) { 0130 const QList<int> deviceIndexes = backendIface->objectDescriptionIndexes(Phonon::EffectType); 0131 for (int i = 0; i < deviceIndexes.count(); ++i) { 0132 ret.append(EffectDescription::fromIndex(deviceIndexes.at(i))); 0133 } 0134 } 0135 return ret; 0136 } 0137 #endif //QT_NO_PHONON_EFFECT 0138 0139 } // namespace Phonon 0140 0141 #include "moc_backendcapabilities.cpp" 0142 0143 // vim: sw=4 ts=4 0144 0145