void MediaImpl::resetMovie() { // XXX: There used to be an issue that when we reached EOS (_eos() == true) we could not seek anymore. if (_seekEnabled) { qDebug() << "Seeking at position 0."; GstEvent* seek_event; if (_rate > 0) { seek_event = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, 0); } else { seek_event = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_END, 0); } /* Send the event */ gst_element_send_event (_appsink0, seek_event); // gst_element_seek_simple (_pipeline, GST_FORMAT_TIME, // (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), 0); // this->_currentFrameSample = NULL; _setMovieReady(true); } else { // Just reload movie. qDebug() << "Reloading the movie" << _seekEnabled; loadMovie(_uri); } }
void VideoImpl::_updateRate() { // Check different things. if (_pipeline == NULL) { qWarning() << "Cannot set rate: no pipeline!" << endl; return; } if (!_seekEnabled) { qWarning() << "Cannot set rate: seek not working" << endl; return; } if (!_isMovieReady()) { qWarning() << "Movie is not yet ready to play, cannot seek yet." << endl; } // Obtain the current position, needed for the seek event. gint64 position; if (!gst_element_query_position (_pipeline, GST_FORMAT_TIME, &position)) { qWarning() << "Unable to retrieve current position." << endl; return; } // Create the seek event. GstEvent *seekEvent; if (_rate > 0.0) { // Rate is positive (playing the video in normal direction) // Set new rate as a first argument. Provide position 0 so that we go to 0:00 seekEvent = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, 0); // Go to 0:00 } else { // Rate is negative // Set new rate as a first arguemnt. Provide the position we were already at. seekEvent = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, position); } // If we have not done so, obtain the sink through which we will send the seek events. if (_appsink0 == NULL) { g_object_get (_pipeline, "video-sink", &_appsink0, NULL); } // Send the event. if (!gst_element_send_event (_appsink0, seekEvent)) { qWarning() << "Cannot perform seek event" << endl; } qDebug() << "Current rate: " << _rate << "." << endl; }
bool GstVideoPlayerBackend::setSpeed(double speed) { if (!m_pipeline) return false; if (speed == m_playbackSpeed) return true; if (speed == 0) return false; gboolean re = gst_element_seek(m_pipeline, speed, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SKIP), GST_SEEK_TYPE_SET, position(), GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE); if (!re) { qDebug() << "gstreamer: Setting playback speed failed"; emit nonFatalError(tr("Playback speed failed")); } else { m_playbackSpeed = speed; m_lastspeed = speed; qDebug() << "gstreamer: set playback speed to" << m_playbackSpeed; emit playbackSpeedChanged(m_playbackSpeed); } return re ? true : false; }
bool VideoImpl::seekTo(guint64 positionNanoSeconds) { if (!_appsink0 || !_seekEnabled) { return false; } else { lockMutex(); // Free the current sample and reset. _freeCurrentSample(); _bitsChanged = false; // Seek to position. bool result = gst_element_seek_simple( _appsink0, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), positionNanoSeconds); unlockMutex(); return result; } }
void MediaImpl::_updateRate() { if (_pipeline == NULL) { qDebug() << "Cannot set rate: no pipeline!" << endl; return; } if (!_seekEnabled) { qDebug() << "Cannot set rate: seek not working" << endl; return; } if (!_isMovieReady()) { qDebug() << "Movie is not yet ready to play, cannot seek yet." << endl; } gint64 position; GstEvent *seekEvent; /* Obtain the current position, needed for the seek event */ if (!gst_element_query_position (_pipeline, GST_FORMAT_TIME, &position)) { g_printerr ("Unable to retrieve current position.\n"); return; } /* Create the seek event */ if (_rate > 0) { seekEvent = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, 0); } else { seekEvent = gst_event_new_seek (_rate, GST_FORMAT_TIME, GstSeekFlags( GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE ), GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, position); } if (_appsink0 == NULL) { /* If we have not done so, obtain the sink through which we will send the seek events */ g_object_get (_pipeline, "video-sink", &_appsink0, NULL); } /* Send the event */ gst_element_send_event (_appsink0, seekEvent); g_print ("Current rate: %g\n", _rate); }
void NPlaybackEngineGStreamer::jump(qint64 msec) { if (!hasMedia()) return; gst_element_seek_simple(m_playbin, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), position() * m_durationNsec + msec * NSEC_IN_MSEC); }
void QGstreamerPlayerSession::setPlaybackRate(qreal rate) { if (!qFuzzyCompare(m_playbackRate, rate)) { m_playbackRate = rate; if (m_playbin) { gst_element_seek(m_playbin, rate, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH), GST_SEEK_TYPE_NONE,0, GST_SEEK_TYPE_NONE,0 ); } } }
void NPlaybackEngineGStreamer::setPosition(qreal pos) { if (!hasMedia() || pos < 0 || pos > 1) return; if (m_durationNsec > 0) { gst_element_seek_simple(m_playbin, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), pos * m_durationNsec); } else { m_posponedPosition = pos; } }
/////////////////////////////////////////////////////////////////////////////// // virtual bool LLMediaImplGStreamer::seek(double time) { bool success = false; if (mPlaybin) { success = gst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); } LL_DEBUGS("MediaImpl") << "MEDIA SEEK REQUEST to " << float(time) << "sec result was " << int(success) << LL_ENDL; return success; }
bool MediaPluginGStreamer010::seek(double time_sec) { bool success = false; if (mDoneInit && mPlaybin) { success = gst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET, gint64(time_sec*GST_SECOND), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); } DEBUGMSG("MEDIA SEEK REQUEST to %fsec result was %d", float(time_sec), int(success)); return success; }
bool QGstreamerPlayerSession::seek(qint64 ms) { //seek locks when the video output sink is changing and pad is blocked if (m_playbin && !m_pendingVideoSink && m_state != QMediaPlayer::StoppedState) { gint64 position = qMax(ms,qint64(0)) * 1000000; return gst_element_seek(m_playbin, m_playbackRate, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH), GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, 0); } return false; }
/////////////////////////////////////////////////////////////////////////////// // virtual bool LLMediaImplGStreamer:: seek( double time ) { bool success = false; if (mPlaybin) { success = llgst_element_seek(mPlaybin, 1.0F, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET, gint64(time*1000000000.0F), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); } DEBUGMSG("MEDIA SEEK REQUEST to %fsec result was %d", float(time), int(success)); return success; }
void GStreamerImageStream::seek(double time) { OSGGST_INFO<<"GStreamerImageStream::seek("<<time<<")"<<std::endl; gst_element_seek_simple(_pipeline, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), time * GST_MSECOND); }
void GStreamerImageStream::rewind() { OSGGST_INFO<<"GStreamerImageStream::rewind()"<<std::endl; gst_element_seek_simple(_pipeline, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), 0); }