Commit 7ad6ec0f authored by Val Doroshchuk's avatar Val Doroshchuk

empty caps

parent 6d2c5280
......@@ -54,7 +54,7 @@ public:
{
}
void restart(QVideoFrame &frame);
bool restart(QVideoFrame &frame);
private:
GstElement *appsrc = nullptr;
......@@ -64,11 +64,20 @@ private:
QSize size;
};
void QGstreamerAppSrcPrivate::restart(QVideoFrame &frame)
bool QGstreamerAppSrcPrivate::restart(QVideoFrame &frame)
{
QList<QVideoFrame::PixelFormat> cc;
cc << frame.pixelFormat();
auto format = frame.pixelFormat();
if (format == QVideoFrame::Format_ARGB32_Premultiplied)
format = QVideoFrame::Format_RGB32;
cc << format;
GstCaps *caps = QGstUtils::capsForFormats(cc);
if (!caps || gst_caps_is_empty(caps)) {
qWarning() << "Could not create caps for" << frame.pixelFormat();
return false;
}
gst_caps_set_simple(
caps,
"framerate", GST_TYPE_FRACTION , 30, 1,
......@@ -79,6 +88,7 @@ void QGstreamerAppSrcPrivate::restart(QVideoFrame &frame)
g_object_set(G_OBJECT(appsrc), "caps", caps, NULL);
gst_caps_unref(caps);
size = frame.size();
return true;
}
static void start_feed(GstElement *pipeline, guint size, QGstreamerAppSrc *q)
......@@ -128,11 +138,11 @@ void QGstreamerAppSrc::timerEvent(QTimerEvent *event)
return;
QVideoFrame frame = readFrame();
if (!frame.isValid() || !frame.map(QAbstractVideoBuffer::ReadOnly))
if (d->size != frame.size() && !d->restart(frame))
return;
if (d->size != frame.size())
d->restart(frame);
if (!frame.isValid() || !frame.map(QAbstractVideoBuffer::ReadOnly))
return;
auto app_buffer = gst_buffer_new();
int size = frame.bytesPerLine() * frame.height();
......
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