diff options
Diffstat (limited to 'src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp')
-rw-r--r-- | src/plugins/gstreamer/mediaplayer/qgstreamerplayersession.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
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); |