summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/gstreamer
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-05-12 12:45:32 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-05-12 12:45:32 (GMT)
commit1898c46452beae9e28cf9be7851099b4b4d2779e (patch)
tree00477e689bf1bd867fb3428476029b47817a9db8 /src/3rdparty/phonon/gstreamer
parentf15b8a83e2e51955776a3f07cb85ebfc342dd8ef (diff)
parent4d5a5149b716c67f031a3a40e23370f90542c92f (diff)
downloadQt-1898c46452beae9e28cf9be7851099b4b4d2779e.zip
Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.gz
Qt-1898c46452beae9e28cf9be7851099b4b4d2779e.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-statemachine
Conflicts: src/gui/graphicsview/qgraphicsitem.cpp
Diffstat (limited to 'src/3rdparty/phonon/gstreamer')
-rw-r--r--src/3rdparty/phonon/gstreamer/audiooutput.cpp1
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.cpp100
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.h49
-rw-r--r--src/3rdparty/phonon/gstreamer/x11renderer.cpp1
4 files changed, 133 insertions, 18 deletions
diff --git a/src/3rdparty/phonon/gstreamer/audiooutput.cpp b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
index fcadac2..138a7e4 100644
--- a/src/3rdparty/phonon/gstreamer/audiooutput.cpp
+++ b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
@@ -42,6 +42,7 @@ AudioOutput::AudioOutput(Backend *backend, QObject *parent)
static int count = 0;
m_name = "AudioOutput" + QString::number(count++);
if (m_backend->isValid()) {
+ g_set_application_name(qApp->applicationName().toUtf8());
m_audioBin = gst_bin_new (NULL);
gst_object_ref (GST_OBJECT (m_audioBin));
gst_object_sink (GST_OBJECT (m_audioBin));
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
index 5398f0c..74fc1b4 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
@@ -14,7 +14,6 @@
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/>.
*/
-
#include <cmath>
#include <gst/interfaces/propertyprobe.h>
#include "common.h"
@@ -24,7 +23,6 @@
#include "backend.h"
#include "streamreader.h"
#include "phononsrc.h"
-
#include <QtCore>
#include <QtCore/QTimer>
#include <QtCore/QVector>
@@ -78,6 +76,9 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
, m_videoGraph(0)
, m_previousTickTime(-1)
, m_resetNeeded(false)
+ , m_autoplayTitles(true)
+ , m_availableTitles(0)
+ , m_currentTitle(1)
{
qRegisterMetaType<GstCaps*>("GstCaps*");
qRegisterMetaType<State>("State");
@@ -902,8 +903,13 @@ void MediaObject::setSource(const MediaSource &source)
break;
case MediaSource::Disc: // CD tracks can be specified by setting the url in the following way uri=cdda:4
- m_backend->logMessage("Source type Disc not currently supported", Backend::Warning, this);
- setError(tr("Could not open media source."), Phonon::NormalError);
+ {
+ QUrl cdurl(QLatin1String("cdda://"));
+ if (createPipefromURL(cdurl))
+ m_loading = true;
+ else
+ setError(tr("Could not open media source."));
+ }
break;
default:
@@ -954,6 +960,19 @@ void MediaObject::getStreamInfo()
m_hasVideo = m_videoStreamFound;
emit hasVideoChanged(m_hasVideo);
}
+
+ m_availableTitles = 1;
+ gint64 titleCount;
+ GstFormat format = gst_format_get_by_nick("track");
+ if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
+ int oldAvailableTitles = m_availableTitles;
+ m_availableTitles = (int)titleCount;
+ if (m_availableTitles != oldAvailableTitles) {
+ emit availableTitlesChanged(m_availableTitles);
+ m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ }
+ }
+
}
void MediaObject::setPrefinishMark(qint32 newPrefinishMark)
@@ -1351,6 +1370,13 @@ void MediaObject::handleEndOfStream()
if (!m_seekable)
m_atEndOfStream = true;
+ if (m_autoplayTitles &&
+ m_availableTitles > 1 &&
+ m_currentTitle < m_availableTitles) {
+ _iface_setCurrentTitle(m_currentTitle + 1);
+ return;
+ }
+
if (m_nextSource.type() != MediaSource::Invalid
&& m_nextSource.type() != MediaSource::Empty) { // We only emit finish when the queue is actually empty
QTimer::singleShot (qMax(0, transitionTime()), this, SLOT(beginPlay()));
@@ -1379,6 +1405,72 @@ void MediaObject::notifyStateChange(Phonon::State newstate, Phonon::State oldsta
notify(&event);
}
+#ifndef QT_NO_PHONON_MEDIACONTROLLER
+//interface management
+bool MediaObject::hasInterface(Interface iface) const
+{
+ return iface == AddonInterface::TitleInterface;
+}
+
+QVariant MediaObject::interfaceCall(Interface iface, int command, const QList<QVariant> &params)
+{
+ if (hasInterface(iface)) {
+
+ switch (iface)
+ {
+ case TitleInterface:
+ switch (command)
+ {
+ case availableTitles:
+ return _iface_availableTitles();
+ case title:
+ return _iface_currentTitle();
+ case setTitle:
+ _iface_setCurrentTitle(params.first().toInt());
+ break;
+ case autoplayTitles:
+ return m_autoplayTitles;
+ case setAutoplayTitles:
+ m_autoplayTitles = params.first().toBool();
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return QVariant();
+}
+#endif
+
+int MediaObject::_iface_availableTitles() const
+{
+ return m_availableTitles;
+}
+
+int MediaObject::_iface_currentTitle() const
+{
+ return m_currentTitle;
+}
+
+void MediaObject::_iface_setCurrentTitle(int title)
+{
+ GstFormat trackFormat = gst_format_get_by_nick("track");
+ m_backend->logMessage(QString("setCurrentTitle %0").arg(title), Backend::Info, this);
+ if ((title == m_currentTitle) || (title < 1) || (title > m_availableTitles))
+ return;
+
+ m_currentTitle = title;
+
+ //let's seek to the beginning of the song
+ if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, m_currentTitle - 1)) {
+ updateTotalTime();
+ m_atEndOfStream = false;
+ emit titleChanged(title);
+ emit totalTimeChanged(totalTime());
+ }
+}
+
} // ns Gstreamer
} // ns Phonon
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.h b/src/3rdparty/phonon/gstreamer/mediaobject.h
index 4dc3f12..64b3510 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.h
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.h
@@ -21,7 +21,6 @@
#include "backend.h"
#include "common.h"
#include "medianode.h"
-
#include <phonon/mediaobjectinterface.h>
#include <phonon/addoninterface.h>
@@ -32,7 +31,6 @@
#include <QtCore/QDate>
#include <QtCore/QEvent>
#include <QtCore/QUrl>
-
#include <gst/gst.h>
QT_BEGIN_NAMESPACE
@@ -50,11 +48,20 @@ class AudioPath;
class VideoPath;
class AudioOutput;
-class MediaObject : public QObject, public MediaObjectInterface, public AddonInterface, public MediaNode
+class MediaObject : public QObject, public MediaObjectInterface
+#ifndef QT_NO_PHONON_MEDIACONTROLLER
+ , public AddonInterface
+#endif
+ , public MediaNode
{
friend class Stream;
Q_OBJECT
- Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface Phonon::Gstreamer::MediaNode)
+ Q_INTERFACES(Phonon::MediaObjectInterface
+#ifndef QT_NO_PHONON_MEDIACONTROLLER
+ Phonon::AddonInterface
+#endif
+ Phonon::Gstreamer::MediaNode
+ )
public:
@@ -93,16 +100,10 @@ public:
MediaSource source() const;
// No additional interfaces currently supported
- bool hasInterface(Interface) const
- {
- return false;
- }
-
- QVariant interfaceCall(Interface, int, const QList<QVariant> &)
- {
- return QVariant();
- }
-
+#ifndef QT_NO_PHONON_MEDIACONTROLLER
+ bool hasInterface(Interface) const;
+ QVariant interfaceCall(Interface, int, const QList<QVariant> &);
+#endif
bool isLoading()
{
return m_loading;
@@ -176,6 +177,19 @@ Q_SIGNALS:
QMultiMap<QString, QString> metaData();
void setMetaData(QMultiMap<QString, QString> newData);
+ // AddonInterface:
+ void titleChanged(int);
+ void availableTitlesChanged(int);
+
+ // Not implemented
+ void chapterChanged(int);
+ void availableChaptersChanged(int);
+ void angleChanged(int);
+ void availableAnglesChanged(int);
+
+ void availableSubtitlesChanged();
+ void availableAudioChannelsChanged();
+
protected:
void beginLoad();
void loadingComplete();
@@ -219,6 +233,10 @@ private:
void updateSeekable();
qint64 getPipelinePos() const;
+ int _iface_availableTitles() const;
+ int _iface_currentTitle() const;
+ void _iface_setCurrentTitle(int title);
+
bool m_resumeState;
State m_oldState;
quint64 m_oldPos;
@@ -264,6 +282,9 @@ private:
bool m_resetNeeded;
QStringList m_missingCodecs;
QMultiMap<QString, QString> m_metaData;
+ bool m_autoplayTitles;
+ int m_availableTitles;
+ int m_currentTitle;
};
}
} //namespace Phonon::Gstreamer
diff --git a/src/3rdparty/phonon/gstreamer/x11renderer.cpp b/src/3rdparty/phonon/gstreamer/x11renderer.cpp
index 1de58b6..73877a8 100644
--- a/src/3rdparty/phonon/gstreamer/x11renderer.cpp
+++ b/src/3rdparty/phonon/gstreamer/x11renderer.cpp
@@ -137,6 +137,7 @@ void X11Renderer::scaleModeChanged(Phonon::VideoWidget::ScaleMode)
void X11Renderer::movieSizeChanged(const QSize &movieSize)
{
+ Q_UNUSED(movieSize);
if (m_renderWidget) {
m_renderWidget->setGeometry(m_videoWidget->calculateDrawFrameRect());
}