5#include <private/qplatformcamera_p.h>
6#include <private/qplatformimagecapture_p.h>
11#include <private/qmediastoragelocation_p.h>
13#include <QtCore/QDebug>
26 QGstElement videoconvert(
"videoconvert",
"imageCaptureConvert");
45 videoConvert(
std::move(videoconvert)),
46 encoder(
std::move(jpegenc)),
47 muxer(
std::move(jifmux))
53 queue.set(
"leaky", 2 );
54 queue.set(
"silent",
true);
63 sink.set(
"async",
false);
69 addProbeToPad(
queue.staticPad(
"src").pad(),
false);
71 sink.set(
"signal-handoffs",
true);
72 g_signal_connect(
sink.object(),
"handoff", G_CALLBACK(&QGstreamerImageCapture::saveImageFilter),
this);
82 return m_session && !passImage && cameraActive;
88 return doCapture(
path);
98 qCDebug(qLcImageCaptureGst) <<
"do capture";
107 qCDebug(qLcImageCaptureGst) <<
"error 1";
110 if (!m_session->
camera()) {
118 qCDebug(qLcImageCaptureGst) <<
"error 2";
129 qCDebug(qLcImageCaptureGst) <<
"error 3";
142void QGstreamerImageCapture::setResolution(
const QSize &resolution)
145 if (padCaps.isNull()) {
146 qDebug() <<
"Camera not ready";
153 gst_caps_set_simple(caps.get(),
154 "width", G_TYPE_INT, resolution.
width(),
155 "height", G_TYPE_INT, resolution.
height(),
164 qCDebug(qLcImageCaptureGst) <<
"probe buffer";
171 GstVideoInfo previewInfo;
172 gst_video_info_from_caps(&previewInfo, caps.get());
174 auto memoryFormat = caps.memoryFormat();
175 auto fmt = caps.formatForCaps(&previewInfo);
181 qDebug() <<
"received a null image";
189 qCDebug(qLcImageCaptureGst) <<
"Image available!";
211 if (m_session == captureSession)
216 disconnect(m_session,
nullptr,
this,
nullptr);
218 pendingImages.
clear();
220 cameraActive =
false;
223 m_session = captureSession;
236 qCDebug(qLcImageCaptureGst) <<
"cameraActiveChanged" << cameraActive << active;
237 if (cameraActive == active)
239 cameraActive = active;
246 if (m_session->
camera()) {
254gboolean QGstreamerImageCapture::saveImageFilter(GstElement *element,
265 if (
capture->pendingImages.isEmpty()) {
279 if (gst_buffer_map(
buffer, &
info, GST_MAP_READ)) {
280 f.write(
reinterpret_cast<const char *
>(
info.data),
info.
size);
291 qCDebug(qLcImageCaptureGst) <<
" could not open image file for writing";
307 setResolution(resolution);
315#include "moc_qgstreamerimagecapture_p.cpp"
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
qint64 size() const
Returns the file size in bytes.
GstElement * element() const
bool setStateSync(GstState state)
QGstPad staticPad(const char *name) const
int capture(const QString &fileName) override
bool isReadyForCapture() const override
virtual ~QGstreamerImageCapture()
bool probeBuffer(GstBuffer *buffer) override
QImageEncoderSettings imageSettings() const override
int captureToBuffer() override
void setImageSettings(const QImageEncoderSettings &settings) override
void cameraActiveChanged(bool active)
void setCaptureSession(QPlatformMediaCaptureSession *session)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void enqueue(const T &t)
Adds value t to the tail of the queue.
T & head()
Returns a reference to the queue's head item.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QVideoFrame class represents a frame of video data.
Combined button and popup list for selecting options.
QTextStream & bin(QTextStream &stream)
Calls QTextStream::setIntegerBase(2) on stream and returns stream.
QString errorMessageCannotFindElement(std::string_view element)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
#define Q_ARG(Type, data)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLsizei const GLchar *const * path
GLsizei GLenum GLboolean sink
QLatin1StringView QLatin1String
unsigned long long quint64
QVideoFrameFormat::PixelFormat fmt
QFileInfo info(fileName)
[8]
QSettings settings("MySoft", "Star Runner")
[0]
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent