diff options
author | Ling Hu <ling.hu@nokia.com> | 2011-06-28 13:49:57 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-05 06:50:04 +0200 |
commit | ca25844e528432dfa55e5136bf56faeb0b47c937 (patch) | |
tree | c9c701c424f5374e2c683ec4db2df450c608e393 /src/plugins/gstreamer/mediaplayer | |
parent | d502dec45604ba77d997061bc7f4f6f688c42f9f (diff) |
Fix playback problem with RTSP streaming for QMediaPlayer(gstreamer)
Change-Id: Ie920cbb5a377e810aee3e106bb50deb46365ce3b
Reviewed-by:Michael Goddard
(cherry picked from commit 05841ae6a9e0ffac623f9b00565bf33a52a22ecd)
Reviewed-on: http://codereview.qt.nokia.com/983
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/plugins/gstreamer/mediaplayer')
3 files changed, 34 insertions, 3 deletions
diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp index f36dd08a3..6c18fed15 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayercontrol.cpp @@ -551,7 +551,7 @@ void QGstreamerPlayerControl::setBufferProgress(int progress) m_session->state() != QMediaPlayer::PlayingState) m_session->play(); - if (m_bufferProgress < 100 && + if (!m_session->isLiveSource() && m_bufferProgress < 100 && (m_session->state() == QMediaPlayer::PlayingState || m_session->pendingState() == QMediaPlayer::PlayingState)) m_session->pause(); diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp index ccb84d15a..4bb967558 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp @@ -47,6 +47,7 @@ #include "qgstutils.h" #include <gst/gstvalue.h> +#include <gst/base/gstbasesrc.h> #include <QtCore/qdatetime.h> #include <QtCore/qdebug.h> @@ -103,7 +104,8 @@ QGstreamerPlayerSession::QGstreamerPlayerSession(QObject *parent) m_duration(-1), m_durationQueries(0), m_everPlayed(false) , - m_sourceType(UnknownSrc) + m_sourceType(UnknownSrc), + m_isLiveSource(false) { #ifdef USE_PLAYBIN2 m_playbin = gst_element_factory_make("playbin2", NULL); @@ -1421,22 +1423,47 @@ void QGstreamerPlayerSession::playbinNotifySource(GObject *o, GParamSpec *p, gpo const int timeout = 30; if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstUDPSrc") == 0) { //udpsrc timeout unit = microsecond + //The udpsrc is always a live source. g_object_set(G_OBJECT(source), "timeout", G_GUINT64_CONSTANT(timeout*1000000), NULL); self->m_sourceType = UDPSrc; + self->m_isLiveSource = true; } else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstSoupHTTPSrc") == 0) { //souphttpsrc timeout unit = second g_object_set(G_OBJECT(source), "timeout", guint(timeout), NULL); self->m_sourceType = SoupHTTPSrc; + //since gst_base_src_is_live is not reliable, so we check the source property directly + gboolean isLive = false; + g_object_get(G_OBJECT(source), "is-live", &isLive, NULL); + self->m_isLiveSource = isLive; } else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstMMSSrc") == 0) { self->m_sourceType = MMSSrc; + self->m_isLiveSource = gst_base_src_is_live(GST_BASE_SRC(source)); g_object_set(G_OBJECT(source), "tcp-timeout", G_GUINT64_CONSTANT(timeout*1000000), NULL); + } else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstRTSPSrc") == 0) { + //rtspsrc acts like a live source and will therefore only generate data in the PLAYING state. + self->m_sourceType = RTSPSrc; + self->m_isLiveSource = true; } else { self->m_sourceType = UnknownSrc; + self->m_isLiveSource = gst_base_src_is_live(GST_BASE_SRC(source)); } +#ifdef DEBUG_PLAYBIN + if (self->m_isLiveSource) + qDebug() << "Current source is a live source"; + else + qDebug() << "Current source is a non-live source"; +#endif + + gst_object_unref(source); } +bool QGstreamerPlayerSession::isLiveSource() const +{ + return m_isLiveSource; +} + void QGstreamerPlayerSession::handleVolumeChange(GObject *o, GParamSpec *p, gpointer d) { Q_UNUSED(o); diff --git a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h index e6fa996b0..26b027a41 100644 --- a/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h +++ b/src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.h @@ -112,6 +112,8 @@ public: static void configureAppSrcElement(GObject*, GObject*, GParamSpec*,QGstreamerPlayerSession* _this); #endif + bool isLiveSource() const; + public slots: void loadFromUri(const QNetworkRequest &url); void loadFromStream(const QNetworkRequest &url, QIODevice *stream); @@ -208,10 +210,12 @@ private: UnknownSrc, SoupHTTPSrc, UDPSrc, - MMSSrc + MMSSrc, + RTSPSrc, }; SourceType m_sourceType; bool m_everPlayed; + bool m_isLiveSource; }; #endif // QGSTREAMERPLAYERSESSION_H |