Reset playbin state to NULL on end of stream signal.
According to GStreamer documentation "playbin should be set back to READY or NULL state, then the "uri" property should be set to the new location and then playbin be set to PLAYING state again." We reset playbin to NULL state and then call setMedia() again in case playback is restarted. Change-Id: If7efbf8d88e0aad461c3d1d8b802c6621af221f7 Reviewed-by: Mithra Pattison <mithra.pattison@nokia.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com> Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
5eefb83589
commit
cc33b63fa5
@@ -69,6 +69,7 @@ QGstreamerPlayerControl::QGstreamerPlayerControl(QGstreamerPlayerSession *sessio
|
|||||||
, m_bufferProgress(-1)
|
, m_bufferProgress(-1)
|
||||||
, m_seekToStartPending(false)
|
, m_seekToStartPending(false)
|
||||||
, m_pendingSeekPosition(-1)
|
, m_pendingSeekPosition(-1)
|
||||||
|
, m_setMediaPending(false)
|
||||||
, m_stream(0)
|
, m_stream(0)
|
||||||
, m_fifoNotifier(0)
|
, m_fifoNotifier(0)
|
||||||
, m_fifoCanWrite(false)
|
, m_fifoCanWrite(false)
|
||||||
@@ -238,6 +239,12 @@ void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
pushState();
|
pushState();
|
||||||
|
|
||||||
|
if (m_setMediaPending) {
|
||||||
|
m_mediaStatus = QMediaPlayer::LoadingMedia;
|
||||||
|
setMedia(m_currentResource, m_stream);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_MAEMO_6
|
#ifdef Q_WS_MAEMO_6
|
||||||
//this is a work around for the gstreamer bug,
|
//this is a work around for the gstreamer bug,
|
||||||
//should be remove once it get fixed
|
//should be remove once it get fixed
|
||||||
@@ -246,11 +253,6 @@ void QGstreamerPlayerControl::playOrPause(QMediaPlayer::State newState)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_mediaStatus == QMediaPlayer::EndOfMedia) {
|
|
||||||
m_mediaStatus = QMediaPlayer::BufferedMedia;
|
|
||||||
m_seekToStartPending = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_resources->isGranted())
|
if (!m_resources->isGranted())
|
||||||
m_resources->acquire();
|
m_resources->acquire();
|
||||||
|
|
||||||
@@ -356,6 +358,7 @@ void QGstreamerPlayerControl::setMedia(const QMediaContent &content, QIODevice *
|
|||||||
QMediaContent oldMedia = m_currentResource;
|
QMediaContent oldMedia = m_currentResource;
|
||||||
m_pendingSeekPosition = -1;
|
m_pendingSeekPosition = -1;
|
||||||
m_session->showPrerollFrames(false); // do not show prerolled frames until pause() or play() explicitly called
|
m_session->showPrerollFrames(false); // do not show prerolled frames until pause() or play() explicitly called
|
||||||
|
m_setMediaPending = false;
|
||||||
|
|
||||||
if (!content.isNull() || stream) {
|
if (!content.isNull() || stream) {
|
||||||
if (!m_resources->isGranted())
|
if (!m_resources->isGranted())
|
||||||
@@ -552,7 +555,14 @@ void QGstreamerPlayerControl::processEOS()
|
|||||||
pushState();
|
pushState();
|
||||||
m_mediaStatus = QMediaPlayer::EndOfMedia;
|
m_mediaStatus = QMediaPlayer::EndOfMedia;
|
||||||
emit positionChanged(position());
|
emit positionChanged(position());
|
||||||
stop();
|
m_session->endOfMediaReset();
|
||||||
|
m_setMediaPending = true;
|
||||||
|
|
||||||
|
if (m_state != QMediaPlayer::StoppedState) {
|
||||||
|
m_state = QMediaPlayer::StoppedState;
|
||||||
|
m_session->showPrerollFrames(false); // stop showing prerolled frames in stop state
|
||||||
|
}
|
||||||
|
|
||||||
popAndNotifyState();
|
popAndNotifyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ private:
|
|||||||
int m_bufferProgress;
|
int m_bufferProgress;
|
||||||
bool m_seekToStartPending;
|
bool m_seekToStartPending;
|
||||||
qint64 m_pendingSeekPosition;
|
qint64 m_pendingSeekPosition;
|
||||||
|
bool m_setMediaPending;
|
||||||
QMediaContent m_currentResource;
|
QMediaContent m_currentResource;
|
||||||
QIODevice *m_stream;
|
QIODevice *m_stream;
|
||||||
QSocketNotifier *m_fifoNotifier;
|
QSocketNotifier *m_fifoNotifier;
|
||||||
|
|||||||
@@ -1772,6 +1772,26 @@ gboolean QGstreamerPlayerSession::padAudioBufferProbe(GstPad *pad, GstBuffer *bu
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function is similar to stop(),
|
||||||
|
// but does not set m_everPlayed, m_lastPosition,
|
||||||
|
// and setSeekable() values.
|
||||||
|
void QGstreamerPlayerSession::endOfMediaReset()
|
||||||
|
{
|
||||||
|
if (m_renderer)
|
||||||
|
m_renderer->stopRenderer();
|
||||||
|
|
||||||
|
flushVideoProbes();
|
||||||
|
gst_element_set_state(m_playbin, GST_STATE_NULL);
|
||||||
|
|
||||||
|
QMediaPlayer::State oldState = m_state;
|
||||||
|
m_pendingState = m_state = QMediaPlayer::StoppedState;
|
||||||
|
|
||||||
|
finishVideoOutputChange();
|
||||||
|
|
||||||
|
if (oldState != m_state)
|
||||||
|
emit stateChanged(m_state);
|
||||||
|
}
|
||||||
|
|
||||||
void QGstreamerPlayerSession::removeVideoBufferProbe()
|
void QGstreamerPlayerSession::removeVideoBufferProbe()
|
||||||
{
|
{
|
||||||
if (m_videoBufferProbeId == -1)
|
if (m_videoBufferProbeId == -1)
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ public:
|
|||||||
void removeProbe(QGstreamerAudioProbeControl* probe);
|
void removeProbe(QGstreamerAudioProbeControl* probe);
|
||||||
static gboolean padAudioBufferProbe(GstPad *pad, GstBuffer *buffer, gpointer user_data);
|
static gboolean padAudioBufferProbe(GstPad *pad, GstBuffer *buffer, gpointer user_data);
|
||||||
|
|
||||||
|
void endOfMediaReset();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadFromUri(const QNetworkRequest &url);
|
void loadFromUri(const QNetworkRequest &url);
|
||||||
void loadFromStream(const QNetworkRequest &url, QIODevice *stream);
|
void loadFromStream(const QNetworkRequest &url, QIODevice *stream);
|
||||||
|
|||||||
Reference in New Issue
Block a user