| 1 | /* This file is part of the KDE project |
| 2 | Copyright (C) 2008 Matthias Kretz <kretz@kde.org> |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License as |
| 6 | published by the Free Software Foundation; either version 2 of |
| 7 | the License or (at your option) version 3 or any later version |
| 8 | accepted by the membership of KDE e.V. (or its successor approved |
| 9 | by the membership of KDE e.V.), Nokia Corporation (or its successors, |
| 10 | if any) and the KDE Free Qt Foundation, which shall act as a proxy |
| 11 | defined in Section 14 of version 3 of the license. |
| 12 | |
| 13 | This program 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 |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #include "factory_p.h" |
| 24 | #include "objectdescription.h" |
| 25 | #include "../factory_p.h" |
| 26 | #include "../globalstatic_p.h" |
| 27 | #include "../backendinterface.h" |
| 28 | #include "backendinterface.h" |
| 29 | #include <QtDebug> |
| 30 | |
| 31 | namespace Phonon |
| 32 | { |
| 33 | namespace Experimental |
| 34 | { |
| 35 | |
| 36 | class FactoryPrivate : public Phonon::Experimental::Factory::Sender |
| 37 | { |
| 38 | public: |
| 39 | FactoryPrivate(); |
| 40 | ~FactoryPrivate() override; |
| 41 | //QPointer<QObject> m_backendObject; |
| 42 | |
| 43 | private Q_SLOTS: |
| 44 | void objectDescriptionChanged(ObjectDescriptionType); |
| 45 | }; |
| 46 | |
| 47 | PHONON_GLOBAL_STATIC(Phonon::Experimental::FactoryPrivate, globalFactory) |
| 48 | |
| 49 | FactoryPrivate::FactoryPrivate() |
| 50 | { |
| 51 | QObject *backendObj = Phonon::Factory::backend(); |
| 52 | Q_ASSERT(backendObj); |
| 53 | //QMetaObject::invokeMethod(backendObj, "experimentalBackend", Qt::DirectConnection, |
| 54 | //Q_RETURN_ARG(QObject *, m_backendObject)); |
| 55 | //if (!m_backendObject) { |
| 56 | //qDebug() << "The backend does not support Phonon::Experimental"; |
| 57 | //return; |
| 58 | //} |
| 59 | connect(asender: backendObj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), |
| 60 | SLOT(objectDescriptionChanged(ObjectDescriptionType))); |
| 61 | connect(sender: Phonon::Factory::sender(), SIGNAL(availableVideoCaptureDevicesChanged()), receiver: Factory::sender(), |
| 62 | SLOT(availableVideoCaptureDevicesChanged())); |
| 63 | } |
| 64 | |
| 65 | FactoryPrivate::~FactoryPrivate() |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type) |
| 70 | { |
| 71 | qDebug() << Q_FUNC_INFO << type; |
| 72 | switch (type) { |
| 73 | default: |
| 74 | break; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | Factory::Sender *Factory::sender() |
| 79 | { |
| 80 | return globalFactory; |
| 81 | } |
| 82 | |
| 83 | QObject *Factory::createAudioDataOutput(QObject *parent) |
| 84 | { |
| 85 | Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(object: Phonon::Factory::backend()); |
| 86 | if (b) { |
| 87 | return Phonon::Factory::registerQObject(o: b->createObject( |
| 88 | c: static_cast<Phonon::BackendInterface::Class>(Phonon::BackendInterface::AudioDataOutputClass), |
| 89 | parent)); |
| 90 | } |
| 91 | return nullptr; |
| 92 | } |
| 93 | |
| 94 | QObject *Factory::createVideoDataOutput(QObject *parent) |
| 95 | { |
| 96 | Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(object: Phonon::Factory::backend()); |
| 97 | if (b) { |
| 98 | return Phonon::Factory::registerQObject(o: b->createObject( |
| 99 | c: static_cast<Phonon::BackendInterface::Class>(Phonon::BackendInterface::VideoDataOutputClass), |
| 100 | parent)); |
| 101 | } |
| 102 | return nullptr; |
| 103 | } |
| 104 | |
| 105 | QObject *Factory::createAvCapture(QObject *parent) |
| 106 | { |
| 107 | Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(object: Phonon::Factory::backend()); |
| 108 | if (b) { |
| 109 | return Phonon::Factory::registerQObject(o: b->createObject( |
| 110 | c: static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::AvCaptureClass), |
| 111 | parent)); |
| 112 | } |
| 113 | return nullptr; |
| 114 | } |
| 115 | |
| 116 | QObject *Factory::createVisualization(QObject *parent) |
| 117 | { |
| 118 | Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(object: Phonon::Factory::backend()); |
| 119 | if (b) { |
| 120 | return Phonon::Factory::registerQObject(o: b->createObject( |
| 121 | c: static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::VisualizationClass), |
| 122 | parent)); |
| 123 | } |
| 124 | return nullptr; |
| 125 | } |
| 126 | |
| 127 | } // namespace Experimental |
| 128 | } // namespace Phonon |
| 129 | |