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