summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/gstreamer/medianode.h
blob: 6e3850a48307ff1d312e9a6ff1579b4d9c8bc5bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*  This file is part of the KDE project.

    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).

    This library is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 2.1 or 3 of the License.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this library.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef Phonon_GSTREAMER_MEDIANODE_H
#define Phonon_GSTREAMER_MEDIANODE_H

#include "common.h"
#include "medianodeevent.h"

#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QSize>

#include <gst/gst.h>

QT_BEGIN_NAMESPACE

namespace Phonon {
namespace Gstreamer {

class Message;
class MediaObject;
class Backend;

class MediaNode {
public:
    enum NodeDescriptionEnum {
        AudioSource     = 0x1,
        AudioSink       = 0x2,
        VideoSource     = 0x4,
        VideoSink       = 0x8
    };
    Q_DECLARE_FLAGS(NodeDescription, NodeDescriptionEnum)

    MediaNode(Backend *backend, NodeDescription description);

    virtual ~MediaNode();

    bool connectNode(QObject *other);
    bool disconnectNode(QObject *other);

    bool buildGraph();
    bool breakGraph();

    virtual bool link();
    virtual bool unlink();

    NodeDescription description() const {
        return m_description;
    }

    bool isValid() {
        return m_isValid;
    }

    MediaObject *root() {
        return m_root;
    }

    void setRoot(MediaObject *mediaObject) {
        m_root = mediaObject;
    }

    void notify(const MediaNodeEvent *event);

    Backend *backend() {
        return m_backend;
    }

    const QString &name() {
        return m_name;
    }

    virtual GstElement *audioElement() {
        return m_audioTee;
    }

    virtual GstElement *videoElement() {
        return m_videoTee;
    }

protected:
    bool connectToFakeSink(GstElement *tee, GstElement *sink, GstElement *bin);
    bool releaseFakeSinkIfConnected(GstElement *tee, GstElement *sink, GstElement *bin);
    bool linkMediaNodeList(QList<QObject *> &list, GstElement *bin, GstElement *tee, GstElement *sink, GstElement *src);

    virtual void mediaNodeEvent(const MediaNodeEvent *event);
    QList<QObject *> m_audioSinkList;
    QList<QObject *> m_videoSinkList;

    bool m_isValid;
    MediaObject *m_root;
    GstElement *m_audioTee;
    GstElement *m_videoTee;
    GstElement *m_fakeAudioSink;
    GstElement *m_fakeVideoSink;
   Backend *m_backend;
    QString m_name;
 
private:
    bool addOutput(MediaNode *, GstElement *tee);
    NodeDescription m_description;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(MediaNode::NodeDescription)

} // ns Gstreamer
} // ns Phonon

Q_DECLARE_INTERFACE(Phonon::Gstreamer::MediaNode, "org.phonon.gstreamer.MediaNode")

QT_END_NAMESPACE

#endif // Phonon_GSTREAMER_MEDIANODE_H