author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
parent 3 | 41300fa6a67c |
permissions | -rw-r--r-- |
0 | 1 |
/* This file is part of the KDE project |
2 |
Copyright (C) 2007 Matthias Kretz <kretz@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) version 3, or any |
|
8 |
later version accepted by the membership of KDE e.V. (or its |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
9 |
successor approved by the membership of KDE e.V.), Nokia Corporation |
0 | 10 |
(or its successors, if any) and the KDE Free Qt Foundation, which shall |
11 |
act as a proxy defined in Section 6 of version 3 of the license. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
20 |
||
21 |
*/ |
|
22 |
||
23 |
#ifndef PHONON_PATH_H |
|
24 |
#define PHONON_PATH_H |
|
25 |
||
26 |
#include "phonon_export.h" |
|
27 |
#include "objectdescription.h" |
|
28 |
||
29 |
#include <QtCore/QExplicitlySharedDataPointer> |
|
30 |
||
31 |
QT_BEGIN_HEADER |
|
32 |
QT_BEGIN_NAMESPACE |
|
33 |
||
34 |
template<class T> class QList; |
|
35 |
||
36 |
namespace Phonon |
|
37 |
{ |
|
38 |
||
39 |
class PathPrivate; |
|
40 |
class Effect; |
|
41 |
class MediaNode; |
|
42 |
||
43 |
/** \class Path path.h Phonon/Path |
|
44 |
* \short Connection object providing convenient effect insertion |
|
45 |
* |
|
46 |
* \code |
|
47 |
MediaObject *media = new MediaObject; |
|
48 |
AudioOutput *output = new AudioOutput(Phonon::MusicCategory); |
|
49 |
Path path = Phonon::createPath(media, output); |
|
50 |
Q_ASSERT(path.isValid()); // for this simple case the path should always be |
|
51 |
//valid - there are unit tests to ensure it |
|
52 |
// insert an effect |
|
53 |
QList<EffectDescription> effectList = BackendCapabilities::availableAudioEffects(); |
|
54 |
if (!effectList.isEmpty()) { |
|
55 |
Effect *effect = path.insertEffect(effectList.first()); |
|
56 |
} |
|
57 |
* \endcode |
|
58 |
* \ingroup Playback |
|
59 |
* \ingroup Recording |
|
60 |
* \author Matthias Kretz <kretz@kde.org> |
|
61 |
* \author Thierry Bastian <thierry.bastian@trolltech.com> |
|
62 |
*/ |
|
63 |
class PHONON_EXPORT Path |
|
64 |
{ |
|
65 |
friend class FactoryPrivate; |
|
66 |
public: |
|
67 |
/** |
|
68 |
* Destroys this reference to the Path. If the path was valid the connection is not broken |
|
69 |
* as both the source and the sink MediaNodes still keep a reference to the Path. |
|
70 |
* |
|
71 |
* \see disconnect |
|
72 |
*/ |
|
73 |
~Path(); |
|
74 |
||
75 |
/** |
|
76 |
* Creates an invalid path. |
|
77 |
* |
|
78 |
* You can still make it a valid path by calling reconnect. To create a path you should use |
|
79 |
* createPath, though. |
|
80 |
* |
|
81 |
* \see createPath |
|
82 |
* \see isValid |
|
83 |
*/ |
|
84 |
Path(); |
|
85 |
||
86 |
/** |
|
87 |
* Constructs a copy of the given path. |
|
88 |
* |
|
89 |
* This constructor is fast thanks to explicit sharing. |
|
90 |
*/ |
|
91 |
Path(const Path &); |
|
92 |
||
93 |
/** |
|
94 |
* Returns whether the path object connects two MediaNodes or not. |
|
95 |
* |
|
96 |
* \return \p true when the path connects two MediaNodes |
|
97 |
* \return \p false when the path is disconnected |
|
98 |
*/ |
|
99 |
bool isValid() const; |
|
100 |
//MediaStreamTypes mediaStreamTypes() const; |
|
101 |
||
102 |
#ifndef QT_NO_PHONON_EFFECT |
|
103 |
/** |
|
104 |
* Creates and inserts an effect into the path. |
|
105 |
* |
|
106 |
* You may insert effects of the same class as often as you like, |
|
107 |
* but if you insert the same object, the call will fail. |
|
108 |
* |
|
109 |
* \param desc The EffectDescription object for the effect to be inserted. |
|
110 |
* |
|
111 |
* \param insertBefore If you already inserted an effect you can |
|
112 |
* tell with this parameter in which order the data gets |
|
113 |
* processed. If this is \c 0 the effect is appended at the end of |
|
114 |
* the processing list. If the effect has not been inserted before |
|
115 |
* the method will do nothing and return \c false. |
|
116 |
* |
|
117 |
* \return Returns a pointer to the effect object if it could be inserted |
|
118 |
* at the specified position. If \c 0 is returned the effect was not |
|
119 |
* inserted. |
|
120 |
* |
|
121 |
* \see removeEffect |
|
122 |
* \see effects |
|
123 |
*/ |
|
124 |
Effect *insertEffect(const EffectDescription &desc, Effect *insertBefore = 0); |
|
125 |
||
126 |
/** |
|
127 |
* Inserts an effect into the path. |
|
128 |
* |
|
129 |
* You may insert effects of the same class as often as you like, |
|
130 |
* but if you insert the same object, the call will fail. |
|
131 |
* |
|
132 |
* \param newEffect An Effect object. |
|
133 |
* |
|
134 |
* \param insertBefore If you already inserted an effect you can |
|
135 |
* tell with this parameter in which order the data gets |
|
136 |
* processed. If this is \c 0 the effect is appended at the end of |
|
137 |
* the processing list. If the effect has not been inserted before |
|
138 |
* the method will do nothing and return \c false. |
|
139 |
* |
|
140 |
* \return Returns whether the effect could be inserted at the |
|
141 |
* specified position. If \c false is returned the effect was not |
|
142 |
* inserted. |
|
143 |
* |
|
144 |
* \see removeEffect |
|
145 |
* \see effects |
|
146 |
*/ |
|
147 |
bool insertEffect(Effect *newEffect, Effect *insertBefore = 0); |
|
148 |
||
149 |
/** |
|
150 |
* Removes an effect from the path. |
|
151 |
* |
|
152 |
* If the effect gets deleted while it is still connected the effect |
|
153 |
* will be removed automatically. |
|
154 |
* |
|
155 |
* \param effect The effect to be removed. |
|
156 |
* |
|
157 |
* \return Returns whether the call was successful. If it returns |
|
158 |
* \c false the effect could not be found in the path, meaning it |
|
159 |
* has not been inserted before. |
|
160 |
* |
|
161 |
* \see insertEffect |
|
162 |
* \see effects |
|
163 |
*/ |
|
164 |
bool removeEffect(Effect *effect); |
|
165 |
||
166 |
/** |
|
167 |
* Returns a list of Effect objects that are currently |
|
168 |
* used as effects. The order in the list determines the order the |
|
169 |
* signal is sent through the effects. |
|
170 |
* |
|
171 |
* \return A list with all current effects. |
|
172 |
* |
|
173 |
* \see insertEffect |
|
174 |
* \see removeEffect |
|
175 |
*/ |
|
176 |
QList<Effect *> effects() const; |
|
177 |
#endif //QT_NO_PHONON_EFFECT |
|
178 |
||
179 |
/** |
|
180 |
* Tries to change the MediaNodes the path is connected to. |
|
181 |
* |
|
182 |
* If reconnect fails the old connection is kept. |
|
183 |
*/ |
|
184 |
bool reconnect(MediaNode *source, MediaNode *sink); |
|
185 |
||
186 |
/** |
|
187 |
* Disconnects the path from the MediaNodes it was connected to. This invalidates the path |
|
188 |
* (isValid returns \p false then). |
|
189 |
*/ |
|
190 |
bool disconnect(); |
|
191 |
||
192 |
/** |
|
193 |
* Assigns \p p to this Path and returns a reference to this Path. |
|
194 |
* |
|
195 |
* This operation is fast thanks to explicit sharing. |
|
196 |
*/ |
|
197 |
Path &operator=(const Path &p); |
|
198 |
||
199 |
/** |
|
200 |
* Returns \p true if this Path is equal to \p p; otherwise returns \p false; |
|
201 |
*/ |
|
202 |
bool operator==(const Path &p) const; |
|
203 |
||
204 |
/** |
|
205 |
* Returns \p true if this Path is not equal to \p p; otherwise returns \p false; |
|
206 |
*/ |
|
207 |
bool operator!=(const Path &p) const; |
|
208 |
||
209 |
/** |
|
210 |
* Returns the source MediaNode used by the path. |
|
211 |
*/ |
|
212 |
MediaNode *source() const; |
|
213 |
||
214 |
/** |
|
215 |
* Returns the sink MediaNode used by the path. |
|
216 |
*/ |
|
217 |
MediaNode *sink() const; |
|
218 |
||
219 |
||
220 |
protected: |
|
221 |
friend class PathPrivate; |
|
222 |
QExplicitlySharedDataPointer<PathPrivate> d; |
|
223 |
}; |
|
224 |
||
225 |
/** |
|
226 |
* \relates Path |
|
227 |
* Creates a new Path connecting two MediaNodes. |
|
228 |
* |
|
229 |
* The implementation will automatically select the right format and media type. E.g. connecting a |
|
230 |
* MediaObject and AudioOutput will create a Path object connecting the audio. This might be |
|
231 |
* represented as PCM or perhaps even AC3 depending on the AudioOutput object. |
|
232 |
* |
|
233 |
* \param source The MediaNode to connect an output from |
|
234 |
* \param sink The MediaNode to connect to. |
|
235 |
*/ |
|
236 |
PHONON_EXPORT Path createPath(MediaNode *source, MediaNode *sink); |
|
237 |
||
238 |
} // namespace Phonon |
|
239 |
||
240 |
QT_END_NAMESPACE |
|
241 |
QT_END_HEADER |
|
242 |
||
243 |
#endif // PHONON_PATH_H |