QTime GStreamerPipeline::getPosition() { QGst::PositionQueryPtr quary = QGst::PositionQuery::create( QGst::FormatTime ); if( mPipeline->query(quary) ) { mPosition = QGst::ClockTime(quary->position()).toTime(); } else { //qDebug() << "Failed to quary position of pipeline!"; } return mPosition; }
QTime Player::position() const { if (m_pipeline) { //here we query the pipeline about its position //and we request that the result is returned in time format QGst::PositionQueryPtr query = QGst::PositionQuery::create(QGst::FormatTime); m_pipeline->query(query); return QGst::ClockTime(query->position()).toTime(); } else { return QTime(); } }
void GstExporter::progressPercent() { float result = -1; // if not active if (m_pipeline) { QGst::PositionQueryPtr currentPosition = QGst::PositionQuery::create(QGst::FormatPercent); m_pipeline->query(currentPosition); qint64 currentPos = currentPosition->position(); result = 1.0 * currentPos / 10000; } emit progressChanged(result); qDebug() << "Querying time, result: " << result << "%"; return; }
void QueryTest::positionTest() { QGst::PositionQueryPtr query = QGst::PositionQuery::create(QGst::FormatBytes); QVERIFY(query->type()==QGst::QueryPosition); QCOMPARE(query->typeName(), QString("position")); QVERIFY(query->format()==QGst::FormatBytes); query->setValues(QGst::FormatBytes, 1234567); QCOMPARE(query->position(), static_cast<qint64>(1234567)); }
void QueryTest::baseTest() { QGst::PositionQueryPtr query = QGst::PositionQuery::create(QGst::FormatBytes); QGst::StructureConstPtr ss = query->internalStructure(); QVERIFY(ss->isValid()); }