1
/*  This file is part of the KDE project.
2
3
    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5
    This library is free software: you can redistribute it and/or modify
6
    it under the terms of the GNU Lesser General Public License as published by
7
    the Free Software Foundation, either version 2.1 or 3 of the License.
8
9
    This library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef Phonon_GSTREAMER_DEVICEMANAGER_H
19
#define Phonon_GSTREAMER_DEVICEMANAGER_H
20
21
#include "common.h"
22
23
#include <phonon/audiooutputinterface.h>
24
25
#include <QtCore/QObject>
26
#include <QtCore/QTimer>
27
28
#include <gst/gst.h>
29
30
QT_BEGIN_NAMESPACE
31
32
namespace Phonon {
33
namespace Gstreamer {
34
class Backend;
35
class DeviceManager;
36
class AbstractRenderer;
37
class VideoWidget;
38
39
class AudioDevice {
40
public :
41
    AudioDevice(DeviceManager *s, const QByteArray &deviceId);
42
    int id;
43
    QByteArray gstId;
44
    QByteArray description;
45
    QString icon;
46
};
47
48
class DeviceManager : public QObject {
49
    Q_OBJECT
50
public:
51
    DeviceManager(Backend *parent);
52
    virtual ~DeviceManager();
53
    const QList<AudioDevice> audioOutputDevices() const;
54
    GstPad *requestPad(int device) const;
55
    int allocateDeviceId();
56
    int deviceId(const QByteArray &gstId) const;
57
    const QByteArray gstId(int id);
58
    AudioDevice* audioDevice(int id);
59
    GstElement *createGNOMEAudioSink(Category category);
60
    GstElement *createAudioSink(Category category = NoCategory);
61
    AbstractRenderer *createVideoRenderer(VideoWidget *parent);
62
63
signals:
64
    void deviceAdded(int);
65
    void deviceRemoved(int);
66
67
public slots:
68
    void updateDeviceList();
69
70
private:
71
    bool canOpenDevice(GstElement *element) const;
72
    Backend *m_backend;
73
    QList <AudioDevice> m_audioDeviceList;
74
    int m_audioDeviceCounter;
75
    QTimer m_devicePollTimer;
76
    QByteArray m_audioSink;
77
    QByteArray m_videoSinkWidget;
78
};
79
}
80
} // namespace Phonon::Gstreamer
81
82
QT_END_NAMESPACE
83
84
#endif // Phonon_GSTREAMER_DEVICEMANAGER_H