Phonon

backendcapabilities.cpp
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
37PHONON_GLOBAL_STATIC(Phonon::BackendCapabilitiesPrivate, globalBCPrivate)
38
39namespace Phonon
40{
41
46
48{
49 if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend()))
50 return backendIface->availableMimeTypes();
51 else
52 return QStringList();
53}
54
56{
57 QObject *m_backendObject = Factory::backend(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(true);
65 }
66 if (!m_backendObject) {
67 // no backend == no MIME type supported at all
68 return false;
69 }
70 return availableMimeTypes().contains(mimeType);
71}
72
74{
76#ifndef QT_NO_PHONON_SETTINGSGROUP
77 const QList<int> deviceIndexes = GlobalConfig().audioOutputDeviceListFor(Phonon::NoCategory, GlobalConfig::ShowAdvancedDevices);
78 for (int i = 0; i < deviceIndexes.count(); ++i) {
79 ret.append(AudioOutputDevice::fromIndex(deviceIndexes.at(i)));
80 }
81#endif //QT_NO_PHONON_SETTINGSGROUP
82 return ret;
83}
84
85
86#ifndef PHONON_NO_AUDIOCAPTURE
88{
90 const QList<int> deviceIndexes = GlobalConfig().audioCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices);
91 for (int i = 0; i < deviceIndexes.count(); ++i) {
92 ret.append(AudioCaptureDevice::fromIndex(deviceIndexes.at(i)));
93 }
94 return ret;
95}
96#endif //PHONON_NO_AUDIOCAPTURE
97
98#ifndef PHONON_NO_VIDEOCAPTURE
100{
102 const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices);
103 for (int i = 0; i < deviceIndexes.count(); ++i) {
104 ret.append(VideoCaptureDevice::fromIndex(deviceIndexes.at(i)));
105 }
106 return ret;
107}
108#endif //PHONON_NO_VIDEOCAPTURE
109
110#if !defined(PHONON_NO_VIDEOCAPTURE) && !defined(PHONON_NO_AUDIOCAPTURE)
112{
114 const QList<int> deviceIndexes = GlobalConfig().videoCaptureDeviceListFor(Phonon::NoCaptureCategory, GlobalConfig::ShowAdvancedDevices);
115 for (int i = 0; i < deviceIndexes.count(); ++i) {
117 if (vcd.propertyNames().contains("hasaudio") && vcd.property("hasaudio").isValid())
118 ret.append(vcd);
119 }
120 return ret;
121}
122#endif // NOT PHONON_NO_VIDEOCAPTURE AND NOT PHONON_NO_AUDIOCAPTURE
123
124#ifndef QT_NO_PHONON_EFFECT
126{
127 BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend());
129 if (backendIface) {
130 const QList<int> deviceIndexes = backendIface->objectDescriptionIndexes(Phonon::EffectType);
131 for (int i = 0; i < deviceIndexes.count(); ++i) {
132 ret.append(EffectDescription::fromIndex(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
Notifications about backend capabilities.
Main Backend class interface.
virtual QList< int > objectDescriptionIndexes(ObjectDescriptionType type) const =0
Returns the unique identifiers for the devices/effects/codecs of the given type.
Provides a tuple of enduser visible name and description.
QList< QByteArray > propertyNames() const
Returns all names that return valid data when property() is called.
static ObjectDescription< T > fromIndex(int index)
Returns a new description object that describes the device/effect/codec/... with the given index.
QVariant property(const char *name) const
Returns a named property.
PHONON_EXPORT QList< EffectDescription > availableAudioEffects()
Returns the visualization effects the backend supports.
PHONON_EXPORT bool isMimeTypeAvailable(const QString &mimeType)
Often all you want to know is whether one given MIME type can be decoded by the backend.
PHONON_EXPORT QList< AudioCaptureDevice > availableAudioCaptureDevices()
Returns the audio capture devices the backend supports.
PHONON_EXPORT QList< VideoCaptureDevice > availableVideoCaptureDevices()
Returns the video output devices the backend supports.
PHONON_EXPORT QStringList availableMimeTypes()
Returns a list of mime types that the Backend can decode.
PHONON_EXPORT QList< VideoCaptureDevice > availableAVCaptureDevices()
Returns the video capture devices that have audio capture capabilities that the backend supports.
PHONON_EXPORT Notifier * notifier()
Use this function to get a QObject pointer to connect to one of the Notifier signals.
PHONON_EXPORT QList< AudioOutputDevice > availableAudioOutputDevices()
Returns the audio output devices the backend supports.
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
bool contains(const AT &value) const const
qsizetype count() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.