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_MEDIANODE_H
19
#define Phonon_GSTREAMER_MEDIANODE_H
20
21
#include "common.h"
22
#include "medianodeevent.h"
23
24
#include <QtCore/QObject>
25
#include <QtCore/QList>
26
#include <QtCore/QSize>
27
28
#include <gst/gst.h>
29
30
QT_BEGIN_NAMESPACE
31
32
namespace Phonon {
33
namespace Gstreamer {
34
35
class Message;
36
class MediaObject;
37
class Backend;
38
39
class MediaNode {
40
public:
41
    enum NodeDescriptionEnum {
42
        AudioSource     = 0x1,
43
        AudioSink       = 0x2,
44
        VideoSource     = 0x4,
45
        VideoSink       = 0x8
46
    };
47
    Q_DECLARE_FLAGS(NodeDescription, NodeDescriptionEnum)
48
49
    MediaNode(Backend *backend, NodeDescription description);
50
51
    virtual ~MediaNode();
52
53
    bool connectNode(QObject *other);
54
    bool disconnectNode(QObject *other);
55
56
    bool buildGraph();
57
    bool breakGraph();
58
59
    virtual bool link();
60
    virtual bool unlink();
61
62
    NodeDescription description() const {
63
        return m_description;
64
    }
65
66
    bool isValid() {
67
        return m_isValid;
68
    }
69
70
    MediaObject *root() {
71
        return m_root;
72
    }
73
74
    void setRoot(MediaObject *mediaObject) {
75
        m_root = mediaObject;
76
    }
77
78
    void notify(const MediaNodeEvent *event);
79
80
    Backend *backend() {
81
        return m_backend;
82
    }
83
84
    const QString &name() {
85
        return m_name;
86
    }
87
88
    virtual GstElement *audioElement() {
89
        return m_audioTee;
90
    }
91
92
    virtual GstElement *videoElement() {
93
        return m_videoTee;
94
    }
95
96
protected:
97
    bool connectToFakeSink(GstElement *tee, GstElement *sink, GstElement *bin);
98
    bool releaseFakeSinkIfConnected(GstElement *tee, GstElement *sink, GstElement *bin);
99
    bool linkMediaNodeList(QList<QObject *> &list, GstElement *bin, GstElement *tee, GstElement *sink, GstElement *src);
100
101
    virtual void mediaNodeEvent(const MediaNodeEvent *event);
102
    QList<QObject *> m_audioSinkList;
103
    QList<QObject *> m_videoSinkList;
104
105
    bool m_isValid;
106
    MediaObject *m_root;
107
    GstElement *m_audioTee;
108
    GstElement *m_videoTee;
109
    GstElement *m_fakeAudioSink;
110
    GstElement *m_fakeVideoSink;
111
   Backend *m_backend;
112
    QString m_name;
113
 
114
private:
115
    bool addOutput(MediaNode *, GstElement *tee);
116
    NodeDescription m_description;
117
};
118
119
Q_DECLARE_OPERATORS_FOR_FLAGS(MediaNode::NodeDescription)
120
121
} // ns Gstreamer
122
} // ns Phonon
123
124
Q_DECLARE_INTERFACE(Phonon::Gstreamer::MediaNode, "org.phonon.gstreamer.MediaNode")
125
126
QT_END_NAMESPACE
127
128
#endif // Phonon_GSTREAMER_MEDIANODE_H