Phonon

experimental/factory.cpp
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
31namespace Phonon
32{
33namespace Experimental
34{
35
36class 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
47PHONON_GLOBAL_STATIC(Phonon::Experimental::FactoryPrivate, globalFactory)
48
49FactoryPrivate::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(backendObj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)),
60 SLOT(objectDescriptionChanged(ObjectDescriptionType)));
61 connect(Phonon::Factory::sender(), SIGNAL(availableVideoCaptureDevicesChanged()), Factory::sender(),
62 SLOT(availableVideoCaptureDevicesChanged()));
63}
64
65FactoryPrivate::~FactoryPrivate()
66{
67}
68
69void FactoryPrivate::objectDescriptionChanged(ObjectDescriptionType type)
70{
71 qDebug() << Q_FUNC_INFO << type;
72 switch (type) {
73 default:
74 break;
75 }
76}
77
78Factory::Sender *Factory::sender()
79{
80 return globalFactory;
81}
82
83QObject *Factory::createAudioDataOutput(QObject *parent)
84{
85 Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
86 if (b) {
87 return Phonon::Factory::registerQObject(b->createObject(
89 parent));
90 }
91 return nullptr;
92}
93
94QObject *Factory::createVideoDataOutput(QObject *parent)
95{
96 Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
97 if (b) {
98 return Phonon::Factory::registerQObject(b->createObject(
100 parent));
101 }
102 return nullptr;
103}
104
105QObject *Factory::createAvCapture(QObject *parent)
106{
107 Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
108 if (b) {
109 return Phonon::Factory::registerQObject(b->createObject(
110 static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::AvCaptureClass),
111 parent));
112 }
113 return nullptr;
114}
115
116QObject *Factory::createVisualization(QObject *parent)
117{
118 Phonon::BackendInterface *b = qobject_cast<Phonon::BackendInterface *>(Phonon::Factory::backend());
119 if (b) {
120 return Phonon::Factory::registerQObject(b->createObject(
121 static_cast<Phonon::BackendInterface::Class>(Phonon::Experimental::BackendInterface::VisualizationClass),
122 parent));
123 }
124 return nullptr;
125}
126
127} // namespace Experimental
128} // namespace Phonon
Main Backend class interface.
virtual QObject * createObject(Class c, QObject *parent, const QList< QVariant > &args=QList< QVariant >())=0
Returns a new instance of the requested class.
Class
Classes that the createObject function has to handle.
@ VideoDataOutputClass
Request to return a VideoDataOutput object.
@ AudioDataOutputClass
Request to return a AudioDataOutput object.
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.