Commit 5e6fe57e authored by Val Doroshchuk's avatar Val Doroshchuk

readFrame

parent c924cdc8
......@@ -59,17 +59,18 @@ void AppSrc::imageReady()
m_grabResult.reset();
}
QVideoFrame AppSrc::readFrame() const
bool AppSrc::readFrame(QVideoFrame &frame) const
{
if (!m_frame.isValid() && m_streamer->item()) {
m_grabResult = qobject_cast<QQuickItem*>(m_streamer->item())->grabToImage();
connect(m_grabResult.data(), &QQuickItemGrabResult::ready, this, &AppSrc::imageReady);
return false;
}
auto frame = m_frame;
frame = m_frame;
m_frame = QVideoFrame();
return frame;
return true;
}
Streamer::Streamer(QObject *parent)
......
......@@ -70,7 +70,7 @@ public:
}
protected:
QVideoFrame readFrame() const override;
bool readFrame(QVideoFrame &frame) const override;
private Q_SLOTS:
void imageReady();
......
......@@ -122,9 +122,10 @@ void QGstreamerAppSrc::stopFeed()
d->timerId = 0;
}
QVideoFrame QGstreamerAppSrc::readFrame() const
bool QGstreamerAppSrc::readFrame(QVideoFrame &frame) const
{
return QVideoFrame();
Q_UNUSED(frame);
return false;
}
void QGstreamerAppSrc::timerEvent(QTimerEvent *event)
......@@ -134,8 +135,8 @@ void QGstreamerAppSrc::timerEvent(QTimerEvent *event)
if (event->timerId() != d->timerId)
return;
QVideoFrame frame = readFrame();
if (!frame.isValid() || (d->size != frame.size() && !d->restart(frame)))
QVideoFrame frame;
if (!readFrame(frame) || !frame.isValid() || (d->size != frame.size() && !d->restart(frame)))
return;
if (!frame.map(QAbstractVideoBuffer::ReadOnly))
......
......@@ -54,7 +54,7 @@ public:
~QGstreamerAppSrc();
protected:
virtual QVideoFrame readFrame() const;
virtual bool readFrame(QVideoFrame &frame) const;
private Q_SLOTS:
void startFeed();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment