1
/* This file is part of the KDE project.
3
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
5
This library is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation, either version 2.1 or 3 of the License.
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
12
GNU Lesser General Public License for more details.
14
You should have received a copy of the GNU Lesser General Public License
15
along with this library. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef Phonon_GSTREAMER_MEDIAOBJECT_H
19
#define Phonon_GSTREAMER_MEDIAOBJECT_H
21
#include "medianode.h"
22
#include <phonon/mediaobjectinterface.h>
23
#include <phonon/addoninterface.h>
25
#include <QtCore/QObject>
26
#include <QtCore/QString>
27
#include <QtCore/QStringList>
28
#include <QtCore/QUrl>
29
#include <QtCore/QVariant>
31
#include <gst/pbutils/install-plugins.h>
33
#include "phonon-config-gstreamer.h"
38
typedef QMultiMap<QString, QString> TagMap;
50
class MediaObject : public QObject, public MediaObjectInterface
51
#ifndef QT_NO_PHONON_MEDIACONTROLLER
52
, public AddonInterface
57
friend class AudioDataOutput;
59
Q_INTERFACES(Phonon::MediaObjectInterface
60
#ifndef QT_NO_PHONON_MEDIACONTROLLER
61
Phonon::AddonInterface
63
Phonon::Gstreamer::MediaNode
67
MediaObject(Backend *backend, QObject *parent);
69
Phonon::State state() const;
71
bool hasVideo() const;
72
bool isSeekable() const;
74
qint64 currentTime() const;
75
qint32 tickInterval() const;
77
void setTickInterval(qint32 newTickInterval);
82
void seek(qint64 time);
84
QString errorString() const;
85
Phonon::ErrorType errorType() const;
88
qint64 totalTime() const;
90
qint32 prefinishMark() const;
91
void setPrefinishMark(qint32 newPrefinishMark);
93
qint32 transitionTime() const;
94
void setTransitionTime(qint32);
95
qint64 remainingTime() const;
97
void setSource(const MediaSource &source);
98
void setNextSource(const MediaSource &source);
99
MediaSource source() const;
101
// No additional interfaces currently supported
102
#ifndef QT_NO_PHONON_MEDIACONTROLLER
103
bool hasInterface(Interface) const;
104
QVariant interfaceCall(Interface, int, const QList<QVariant> &);
111
bool audioAvailable()
116
bool videoAvailable()
121
GstElement *audioGraph()
126
GstElement *videoGraph()
131
GstElement *pipeline()
138
return m_capsHandler;
141
void connectVideo(GstPad *videoPad);
142
void connectAudio(GstPad *audioPad);
143
void handleBusMessage(const Message &msg);
144
void handleTagMessage(GstMessage *msg);
145
void handleStateMessage(GstMessage *msg);
146
void handleErrorMessage(GstMessage *msg);
147
void handleWarningMessage(GstMessage *msg);
148
void handleBufferingMessage(GstMessage *msg);
149
void handleElementMessage(GstMessage *msg);
150
void handleDurationMessage(GstMessage *msg);
151
void handleEOSMessage(GstMessage *msg);
152
void handleEndOfStream();
153
void addMissingCodecName(const QString &codec) { m_missingCodecs.append(codec); }
154
void invalidateGraph();
156
static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data);
157
static void cb_pad_added (GstElement *decodebin, GstPad *pad, gpointer data);
158
static void cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps *caps, gpointer data);
163
void setState(State);
166
void currentSourceChanged(const MediaSource &newSource);
167
void stateChanged(Phonon::State newstate, Phonon::State oldstate);
168
void tick(qint64 time);
169
void metaDataChanged(QMultiMap<QString, QString>);
170
void seekableChanged(bool);
171
void hasVideoChanged(bool);
174
void prefinishMarkReached(qint32);
175
void aboutToFinish();
176
void totalTimeChanged(qint64 length);
177
void bufferStatus(int percentFilled);
179
QMultiMap<QString, QString> metaData();
180
void setMetaData(QMultiMap<QString, QString> newData);
183
void titleChanged(int);
184
void availableTitlesChanged(int);
187
void chapterChanged(int);
188
void availableChaptersChanged(int);
189
void angleChanged(int);
190
void availableAnglesChanged(int);
192
void availableSubtitlesChanged();
193
void availableAudioChannelsChanged();
197
void loadingComplete();
198
void newPadAvailable (GstPad *pad);
199
void changeState(State);
200
void setError(const QString &errorString, Phonon::ErrorType error = NormalError);
202
* @param encodedUrl percent-encoded QString for source compat reasons. Should change to QUrl
204
bool createPipefromURL(const QUrl &url);
205
bool createPipefromStream(const MediaSource &);
206
bool createPipefromDevice(const MediaSource &);
207
bool createV4lPipe(const DeviceAccess &access, const MediaSource &);
209
GstElement *audioElement()
211
Q_ASSERT(m_audioPipe);
215
GstElement *videoElement()
217
Q_ASSERT(m_videoPipe);
222
void installMissingCodecs();
223
void getStreamInfo();
226
void setVideoCaps(GstCaps *caps);
227
void notifyStateChange(Phonon::State newstate, Phonon::State oldstate);
228
#ifdef PLUGIN_INSTALL_API
229
void pluginInstallationResult(GstInstallPluginsReturn result);
230
#endif // PLUGIN_INSTALL_API
233
// GStreamer specific :
234
void createPipeline();
235
bool addToPipeline(GstElement *elem);
236
void setTotalTime(qint64 newTime);
237
void getStreamsInfo();
238
bool updateTotalTime();
239
void updateSeekable();
240
qint64 getPipelinePos() const;
242
int _iface_availableTitles() const;
243
int _iface_currentTitle() const;
244
void _iface_setCurrentTitle(int title);
245
void setTrack(int title);
247
// Plugin API callback
248
static void pluginInstallationDone(GstInstallPluginsReturn result, gpointer userData);
255
State m_pendingState;
257
qint32 m_tickInterval;
259
MediaSource m_source;
260
MediaSource m_nextSource;
261
qint32 m_prefinishMark;
262
qint32 m_transitionTime;
267
bool m_prefinishMarkReachedNotEmitted;
268
bool m_aboutToFinishEmitted;
270
gulong m_capsHandler;
272
GstElement *m_datasource;
273
GstElement *m_decodebin;
275
GstElement *m_audioPipe;
276
GstElement *m_videoPipe;
281
bool m_videoStreamFound;
284
bool m_atEndOfStream;
285
bool m_atStartOfStream;
286
Phonon::ErrorType m_error;
287
QString m_errorString;
289
GstElement *m_pipeline;
290
GstElement *m_audioGraph;
291
GstElement *m_videoGraph;
292
int m_previousTickTime;
294
QStringList m_missingCodecs;
295
QMultiMap<QString, QString> m_metaData;
296
bool m_autoplayTitles;
297
int m_availableTitles;
300
bool m_installingPlugin;
303
} //namespace Phonon::Gstreamer
307
#endif // Phonon_GSTREAMER_MEDIAOBJECT_H