1/*
2 Copyright (C) 2013 Harald Sitter <sitter@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
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 GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef PHONON_VLC_SINKNODE_H
19#define PHONON_VLC_SINKNODE_H
20
21#include <QPointer>
22
23namespace Phonon {
24namespace VLC {
25
26class Media;
27class MediaObject;
28class MediaPlayer;
29
30/** \brief The sink node is essentially an output for a media object
31 *
32 * This class handles connections for the sink to a media object. It remembers
33 * the media object and the libVLC media player associated with it.
34 *
35 * \see MediaObject
36 */
37class SinkNode
38{
39public:
40 SinkNode();
41 virtual ~SinkNode();
42
43 /**
44 * Associates the sink node to the provided media object. The m_mediaObject and m_vlcPlayer
45 * attributes are set, and the sink is added to the media object's sinks.
46 *
47 * \param mediaObject The media object to connect to.
48 *
49 * \see disconnectFromMediaObject()
50 */
51 void connectToMediaObject(MediaObject *mediaObject);
52
53 /**
54 * Removes this sink from the specified media object's sinks.
55 *
56 * \param mediaObject The media object to disconnect from
57 *
58 * \see connectToMediaObject()
59 */
60 void disconnectFromMediaObject(MediaObject *mediaObject);
61
62 /**
63 * Does nothing. To be reimplemented in child classes.
64 */
65 void addToMedia(Media *media);
66
67protected:
68 /**
69 * Handling function for derived classes.
70 * \note This handle is executed *after* the global handle.
71 * Meaning the SinkNode base will be done handling the connect.
72 * \see connectToMediaObject
73 */
74 virtual void handleConnectToMediaObject(MediaObject *mediaObject) { Q_UNUSED(mediaObject); }
75
76 /**
77 * Handling function for derived classes.
78 * \note This handle is executed *before* the global handle.
79 * Meaning the SinkNode base will continue handling the disconnect.
80 * \see disconnectFromMediaObject
81 */
82 virtual void handleDisconnectFromMediaObject(MediaObject *mediaObject) { Q_UNUSED(mediaObject); }
83
84 /**
85 * Handling function for derived classes.
86 * \note This handle is executed *after* the global handle.
87 * Meaning the SinkNode base will be done handling the connect.
88 * \see addToMedia
89 */
90 virtual void handleAddToMedia(Media *media) { Q_UNUSED(media); }
91
92 /** Available while connected to a MediaObject (until disconnected) */
93 QPointer<MediaObject> m_mediaObject;
94
95 /** Available while connected to a MediaObject (until disconnected) */
96 MediaPlayer *m_player;
97};
98
99} // namespace VLC
100} // namespace Phonon
101
102#endif // PHONON_VLC_SINKNODE_H
103

source code of phonon-vlc/src/sinknode.h