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>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user