~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to phonon/mediaproducerinterface.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
namespace Phonon
31
31
{
32
32
 
33
 
class MediaProducerInterface
 
33
/**
 
34
 * \short Backend interface for media source classes.
 
35
 *
 
36
 * Backend classes providing MediaObject, MediaQueue, ByteStream, AvCapture,
 
37
 * etc. need to implement this interface.
 
38
 *
 
39
 * The backend implementation has to provide two signals, that are not defined
 
40
 * in this interface:
 
41
 * <ul>
 
42
 * <li>\anchor phonon_MediaProducerInterface_stateChanged
 
43
 * <b>void stateChanged(\ref Phonon::State newstate, \ref Phonon::State oldstate)</b>
 
44
 *
 
45
 * Emitted when the state of the MediaObject has changed.
 
46
 * In case you're not interested in the old state you can also
 
47
 * connect to a slot that only has one State argument.
 
48
 *
 
49
 * \param newstate The state the Player is in now.
 
50
 * \param oldstate The state the Player was in before.
 
51
 * </li>
 
52
 * <li>\anchor phonon_MediaProducerInterface_tick
 
53
 * <b>void tick(qint64 time)</b>
 
54
 *
 
55
 * This signal gets emitted every tickInterval milliseconds.
 
56
 *
 
57
 * \param time The position of the media file in milliseconds.
 
58
 *
 
59
 * \see setTickInterval()
 
60
 * \see tickInterval()
 
61
 * </li>
 
62
 * </ul>
 
63
 *
 
64
 * \author Matthias Kretz <kretz@kde.org>
 
65
 * \see AbstractMediaProducer
 
66
 */
 
67
class PHONONCORE_EXPORT MediaProducerInterface
34
68
{
35
 
        public:
36
 
                virtual ~MediaProducerInterface() {}
37
 
 
38
 
                virtual bool addAudioPath(QObject*) = 0;
39
 
                virtual bool addVideoPath(QObject*) = 0;
40
 
                virtual void removeAudioPath(QObject*) = 0;
41
 
                virtual void removeVideoPath(QObject*) = 0;
42
 
 
43
 
                virtual QStringList availableAudioStreams() const = 0;
44
 
                virtual QStringList availableVideoStreams() const = 0;
45
 
                virtual QStringList availableSubtitleStreams() const = 0;
46
 
 
47
 
                virtual QString selectedAudioStream(const QObject*) const = 0;
48
 
                virtual QString selectedVideoStream(const QObject*) const = 0;
49
 
                virtual QString selectedSubtitleStream(const QObject*) const = 0;
50
 
 
51
 
                virtual void selectAudioStream(const QString&,const QObject*) = 0;
52
 
                virtual void selectVideoStream(const QString&,const QObject*) = 0;
53
 
                virtual void selectSubtitleStream(const QString&,const QObject*) = 0;
54
 
 
55
 
                virtual void play() = 0;
56
 
                virtual void pause() = 0;
57
 
                virtual void stop() = 0;
58
 
                virtual void seek(qint64) = 0;
59
 
 
60
 
                virtual qint32 tickInterval() const = 0;
61
 
                virtual void setTickInterval(qint32) = 0;
62
 
 
63
 
                virtual bool hasVideo() const = 0;
64
 
                virtual bool isSeekable() const = 0;
65
 
                virtual qint64 currentTime() const = 0;
66
 
                virtual Phonon::State state() const = 0;
 
69
    public:
 
70
        virtual ~MediaProducerInterface() {}
 
71
 
 
72
        /**
 
73
         * Adds an AudioPath object to tell where to send the audio data.
 
74
         *
 
75
         * The frontend class ensures that the \p audioPath is unique,
 
76
         * meaning the AudioPath object has not been added to this object.
 
77
         */
 
78
        virtual bool addAudioPath(QObject *audioPath) = 0;
 
79
        /**
 
80
         * Adds a VideoPath object to tell where to send the video data (and
 
81
         * render the subtitle if one is selected).
 
82
         *
 
83
         * The frontend class ensures that the \p videoPath is unique,
 
84
         * meaning the VideoPath object has not been added to this object.
 
85
         */
 
86
        virtual bool addVideoPath(QObject *videoPath) = 0;
 
87
        /**
 
88
         * Removes the AudioPath object from the flow graph. This function will
 
89
         * only be called with a valid \p audioPath, meaning that the path has been
 
90
         * added to this object before.
 
91
         */
 
92
        virtual void removeAudioPath(QObject *audioPath) = 0;
 
93
        /**
 
94
         * Removes the VideoPath object from the flow graph. This function will
 
95
         * only be called with a valid \p videoPath, meaning that the path has been
 
96
         * added to this object before.
 
97
         */
 
98
        virtual void removeVideoPath(QObject *videoPath) = 0;
 
99
 
 
100
        /**
 
101
         * Lists the available audio streams the media provides. The strings are
 
102
         * what is shown to the user and often just consist of the stream name
 
103
         * encoded into the media file.
 
104
         *
 
105
         * Be prepared to change the audio stream when \ref
 
106
         * phonon_AbstractMediaProducer_selectAudioStream is called with one of the
 
107
         * strings of this list. If the media has multiple audio streams but the
 
108
         * backend cannot switch then the list of available audio streams should be
 
109
         * empty.
 
110
         *
 
111
         * \returns A list of names for the available audio streams.
 
112
         */
 
113
        virtual QStringList availableAudioStreams() const = 0;
 
114
        /**
 
115
         * Lists the available video streams the media provides. The strings are
 
116
         * what is shown to the user and often just consist of the stream name
 
117
         * encoded into the media file.
 
118
         *
 
119
         * Be prepared to change the video stream when \ref
 
120
         * phonon_AbstractMediaProducer_selectVideoStream is called with one of the
 
121
         * strings of this list. If the media has multiple video streams but the
 
122
         * backend cannot switch then the list of available video streams should be
 
123
         * empty.
 
124
         *
 
125
         * \returns A list of names for the available video streams.
 
126
         */
 
127
        virtual QStringList availableVideoStreams() const = 0;
 
128
        /**
 
129
         * Lists the available subtitle streams the media provides. The strings are
 
130
         * what is shown to the user and often just consist of the stream name
 
131
         * encoded into the media file.
 
132
         *
 
133
         * Be prepared to change the subtitle stream when \ref
 
134
         * phonon_AbstractMediaProducer_selectSubtitleStream is called with one of the
 
135
         * strings of this list. If the media has multiple subtitle streams but the
 
136
         * backend cannot switch then the list of available subtitle streams should be
 
137
         * empty.
 
138
         *
 
139
         * \returns A list of names for the available subtitle streams.
 
140
         */
 
141
        virtual QStringList availableSubtitleStreams() const = 0;
 
142
 
 
143
        /**
 
144
         * Returns the selected audio stream for the given AudioPath object.
 
145
         */
 
146
        virtual QString selectedAudioStream(const QObject *audioPath) const = 0;
 
147
        /**
 
148
         * Returns the selected video stream for the given VideoPath object.
 
149
         */
 
150
        virtual QString selectedVideoStream(const QObject *videoPath) const = 0;
 
151
        /**
 
152
         * Returns the selected subtitle stream for the given VideoPath object.
 
153
         */
 
154
        virtual QString selectedSubtitleStream(const QObject *videoPath) const = 0;
 
155
 
 
156
        /**
 
157
         * Selects one audio stream for the selected AudioPath object.
 
158
         *
 
159
         * \param audioPath If \p 0 the audio stream should be used for all
 
160
         * connected AudioPath objects. Else the audio stream selection should only
 
161
         * be made for the one specified AudioPath. This way the user can request
 
162
         * different audio streams for different audio paths/outputs.
 
163
         */
 
164
        virtual void selectAudioStream(const QString &streamName,const QObject *audioPath) = 0;
 
165
        /**
 
166
         * Selects one video stream for the selected VideoPath object.
 
167
         *
 
168
         * \param videoPath If \p 0 the video stream should be used for all
 
169
         * connected VideoPath objects. Else the video stream selection should only
 
170
         * be made for the one specified VideoPath. This way the user can request
 
171
         * different video streams for different video paths/outputs.
 
172
         */
 
173
        virtual void selectVideoStream(const QString &streamName,const QObject *videoPath) = 0;
 
174
        /**
 
175
         * Selects one subtitle stream for the selected VideoPath object. By
 
176
         * default normally no subtitle is selected, but depending on the media
 
177
         * this may be different.
 
178
         *
 
179
         * \param videoPath If \p 0 the video stream should be used for all
 
180
         * connected VideoPath objects. Else the video stream selection should only
 
181
         * be made for the one specified VideoPath. This way the user can request
 
182
         * different video streams for different video paths/outputs.
 
183
         */
 
184
        virtual void selectSubtitleStream(const QString &streamName,const QObject *videoPath) = 0;
 
185
 
 
186
        /**
 
187
         * Requests the playback to start.
 
188
         *
 
189
         * This method is only called if the state transition to \ref PlayingState is possible.
 
190
         *
 
191
         * The backend should react immediately
 
192
         * by either going into \ref PlayingState or \ref BufferingState if the
 
193
         * former is not possible.
 
194
         */
 
195
        virtual void play() = 0;
 
196
 
 
197
        /**
 
198
         * Requests the playback to pause.
 
199
         *
 
200
         * This method is only called if the state transition to \ref PausedState is possible.
 
201
         *
 
202
         * The backend should react as fast as possible. Go to \ref PausedState
 
203
         * as soon as playback is paused.
 
204
         */
 
205
        virtual void pause() = 0;
 
206
 
 
207
        /**
 
208
         * Requests the playback to be stopped.
 
209
         *
 
210
         * This method is only called if the state transition to \ref StoppedState is possible.
 
211
         *
 
212
         * The backend should react as fast as possible. Go to \ref StoppedState
 
213
         * as soon as playback is stopped.
 
214
         *
 
215
         * A subsequent call to play() will start playback at the beginning of
 
216
         * the media.
 
217
         */
 
218
        virtual void stop() = 0;
 
219
 
 
220
        /**
 
221
         * Requests the playback to be seeked to the given time.
 
222
         *
 
223
         * The backend does not have to finish seeking while in this function
 
224
         * (i.e. the backend does not need to block the thread until the seek is
 
225
         * finished; even worse it might lead to deadlocks when using a
 
226
         * ByteStream which gets its data from the thread this function would
 
227
         * block).
 
228
         *
 
229
         * As soon as the seek is done the currentTime() function and
 
230
         * the tick() signal will report it.
 
231
         *
 
232
         * \param milliseconds The time where playback should seek to in
 
233
         * milliseconds.
 
234
         */
 
235
        virtual void seek(qint64 milliseconds) = 0;
 
236
 
 
237
        /**
 
238
         * Return the time interval in milliseconds between two ticks.
 
239
         *
 
240
         * \returns Returns the tick interval that it was set to (might not
 
241
         * be the same as you asked for).
 
242
         */
 
243
        virtual qint32 tickInterval() const = 0;
 
244
        /**
 
245
         * Change the interval the tick signal is emitted. If you set \p
 
246
         * interval to 0 the signal gets disabled.
 
247
         *
 
248
         * \param interval tick interval in milliseconds
 
249
         *
 
250
         * \returns Returns the tick interval that it was set to (might not
 
251
         *          be the same as you asked for).
 
252
         */
 
253
        virtual void setTickInterval(qint32 interval) = 0;
 
254
 
 
255
        /**
 
256
         * Check whether the media data includes a video stream.
 
257
         *
 
258
         * \return returns \p true if the media contains video data
 
259
         */
 
260
        virtual bool hasVideo() const = 0;
 
261
        /**
 
262
         * If the current media may be seeked returns true.
 
263
         *
 
264
         * \returns whether the current media may be seeked.
 
265
         */
 
266
        virtual bool isSeekable() const = 0;
 
267
        /**
 
268
         * Get the current time (in milliseconds) of the file currently being played.
 
269
         */
 
270
        virtual qint64 currentTime() const = 0;
 
271
        /**
 
272
         * Get the current state.
 
273
         */
 
274
        virtual Phonon::State state() const = 0;
 
275
 
 
276
        /**
 
277
         * A translated string describing the error.
 
278
         */
 
279
        virtual QString errorString() const = 0;
 
280
 
 
281
        /**
 
282
         * Tells your program what to do about the error.
 
283
         *
 
284
         * \see Phonon::ErrorType
 
285
         */
 
286
        virtual Phonon::ErrorType errorType() const = 0;
67
287
};
68
288
 
69
289
} // namespace Phonon
70
290
 
71
 
Q_DECLARE_INTERFACE( Phonon::MediaProducerInterface, "org.kde.Phonon.MediaProducerInterface/0.1" )
 
291
Q_DECLARE_INTERFACE( Phonon::MediaProducerInterface, "org.kde.Phonon.MediaProducerInterface/0.2" )
72
292
 
73
293
#endif // PHONON_MEDIAPRODUCERINTERFACE_H
74
 
// vim: sw=4 ts=4 noet tw=80
 
294
// vim: sw=4 ts=4 tw=80