summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/mmf_medianode.h
blob: 0ed21c4b6bea36c06f6ed008bcc54f4bca24c5f4 (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
/*  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_MMF_MEDIANODE_H
#define PHONON_MMF_MEDIANODE_H

#include <QObject>
#include <Phonon/EffectInterface>
#include "audioplayer.h"

QT_BEGIN_NAMESPACE

/**
 * @file mmf_medianode.h mmf_medianode.cpp
 *
 * This file starts with mmf_ in order to avoid clash with Phonon's
 * medianode.h. The GStreamer backend has a file named medianode.h, but it
 * isn't compiled with ABLD build system, which have problems with separating
 * user and system include paths.
 */

namespace Phonon
{
namespace MMF
{
class MediaObject;

/**
 * @short Base class for all nodes in the MMF backend.
 *
 * MediaNode is the base class for all nodes created by the MMF
 * backend.
 *
 * These nodes may be one of the following types:
 *
 * - MediaObject
 *      This represents the source of media data.  It encapsulates the
 *      appropriate MMF client API for playing audio or video.
 * - AudioOutput
 *      This represents the audio output device.  Since the MMF client API
 *      does not expose the output device directly, this backend node
 *      simply forwards volume control commands to the MediaObject.
 * - VideoWidget
 *      A native widget on which video will be rendered.
 * - An audio effect, derived form AbstractAudioEffect
 *
 * Because the MMF API does not support the concept of a media filter graph,
 * this class must ensure the following:
 *
 * - Each media graph contains at most one MediaObject instance.
 * - Every non-MediaObject node holds a reference to the MediaObject.  This
 * allows commands to be sent through the graph to the encapsulated MMF client
 * API.
 */
class MediaNode : public QObject
{
    Q_OBJECT
public:
    MediaNode(QObject *parent);
    ~MediaNode();

    bool connectOutput(MediaNode *output);
    bool disconnectOutput(MediaNode *output);

    virtual void connectMediaObject(MediaObject *mediaObject) = 0;
    virtual void disconnectMediaObject(MediaObject *mediaObject) = 0;

private:
    bool isMediaObject() const;

    void updateMediaObject();
    void setMediaObject(MediaObject *mediaObject);

    typedef QList<const MediaNode *> NodeList;
    void visit(QList<MediaNode *>& visited, MediaObject*& mediaObject);

private:
    MediaObject *       m_mediaObject;

    // All nodes except MediaObject may have an input
    MediaNode *         m_input;

    // Only MediaObject can have more than one output
    QList<MediaNode *>  m_outputs;
};

}
}

QT_END_NAMESPACE

#endif