File indexing completed on 2024-05-05 04:44:40

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
0003 
0004     This program is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU General Public License as
0006     published by the Free Software Foundation; either version 2 of
0007     the License or (at your option) version 3 or any later version
0008     accepted by the membership of KDE e.V. (or its successor approved
0009     by the membership of KDE e.V.), Nokia Corporation (or its successors, 
0010     if any) and the KDE Free Qt Foundation, which shall act as a proxy 
0011     defined in Section 14 of version 3 of the license.
0012 
0013     This program 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
0016     GNU General Public License for more details.
0017 
0018     You should have received a copy of the GNU General Public License
0019     along with this program.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 
0023 #include "factory_p.h"
0024 #include "objectdescription.h"
0025 #include "../factory_p.h"
0026 #include "../globalstatic_p.h"
0027 #include "../backendinterface.h"
0028 #include "backendinterface.h"
0029 #include <QtDebug>
0030 
0031 namespace Phonon
0032 {
0033 namespace Experimental
0034 {
0035 
0036 class FactoryPrivate : public Phonon::Experimental::Factory::Sender
0037 {
0038     public:
0039         FactoryPrivate();
0040         ~FactoryPrivate() override;
0041         //QPointer<QObject> m_backendObject;
0042 
0043     private Q_SLOTS:
0044         void objectDescriptionChanged(ObjectDescriptionType);
0045 };
0046 
0047 PHONON_GLOBAL_STATIC(Phonon::Experimental::FactoryPrivate, globalFactory)
0048 
0049 FactoryPrivate::FactoryPrivate()
0050 {
0051     QObject *backendObj = Phonon::Factory::backend();
0052     Q_ASSERT(backendObj);
0053     //QMetaObject::invokeMethod(backendObj, "experimentalBackend", Qt::DirectConnection,
0054             //Q_RETURN_ARG(QObject *, m_backendObject));
0055     //if (!m_backendObject) {
0056         //qDebug() << "The backend does not support Phonon::Experimental";
0057         //return;
0058     //}
0059     connect(backendObj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)),
0060             SLOT(objectDescriptionChanged(ObjectDescriptionType)));
0061     connect(Phonon::Factory::sender(), SIGNAL(availableVideoCaptureDevicesChanged()), Factory::sender(),
0062             SLOT(availableVideoCaptureDevicesChanged()));
0063 }
0064 
0065 FactoryPrivate::~FactoryPrivate()
0066 {
0067 }
0068 
0069 void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type)
0070 {
0071     qDebug() << Q_FUNC_INFO << type;
0072     switch (type) {
0073     default:
0074         break;
0075     }
0076 }
0077 
0078 Factory::Sender *Factory::sender()
0079 {
0080     return globalFactory;
0081 }
0082 
0083 QObject *Factory::createAudioDataOutput(QObject *parent)
0084 {
0085     Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
0086     if (b) {
0087         return Phonon::Factory::registerQObject(b->createObject(
0088                     static_cast<Phonon::BackendInterface::Class>(Phonon::BackendInterface::AudioDataOutputClass),
0089                     parent));
0090     }
0091     return nullptr;
0092 }
0093 
0094 QObject *Factory::createVideoDataOutput(QObject *parent)
0095 {
0096     Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
0097     if (b) {
0098         return Phonon::Factory::registerQObject(b->createObject(
0099                     static_cast<Phonon::BackendInterface::Class>(Phonon::BackendInterface::VideoDataOutputClass),
0100                     parent));
0101     }
0102     return nullptr;
0103 }
0104 
0105 QObject *Factory::createAvCapture(QObject *parent)
0106 {
0107     Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
0108     if (b) {
0109         return Phonon::Factory::registerQObject(b->createObject(
0110                     static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::AvCaptureClass),
0111                     parent));
0112     }
0113     return nullptr;
0114 }
0115 
0116 QObject *Factory::createVisualization(QObject *parent)
0117 {
0118     Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
0119     if (b) {
0120         return Phonon::Factory::registerQObject(b->createObject(
0121                     static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::VisualizationClass),
0122                     parent));
0123     }
0124     return nullptr;
0125 }
0126 
0127 } // namespace Experimental
0128 } // namespace Phonon