Ported gstreamer camera backend from camerabin to camerabin2.
Change-Id: Ieb08df492e7b9cbfe35e93a056685cfdac6e704e Reviewed-on: http://codereview.qt.nokia.com/2994 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
abee3a6548
commit
da9b436cd1
@@ -84,7 +84,6 @@ CameraBinImageCapture::CameraBinImageCapture(CameraBinSession *session)
|
||||
connect(m_session, SIGNAL(imageCaptured(int,QImage)), this, SIGNAL(imageCaptured(int,QImage)));
|
||||
|
||||
m_session->bus()->installMessageFilter(this);
|
||||
g_signal_connect(G_OBJECT(m_session->cameraBin()), IMAGE_DONE_SIGNAL, G_CALLBACK(handleImageSaved), this);
|
||||
}
|
||||
|
||||
CameraBinImageCapture::~CameraBinImageCapture()
|
||||
@@ -127,39 +126,9 @@ void CameraBinImageCapture::updateState()
|
||||
}
|
||||
}
|
||||
|
||||
gboolean CameraBinImageCapture::handleImageSaved(GstElement *camera,
|
||||
const gchar *filename,
|
||||
CameraBinImageCapture *self)
|
||||
{
|
||||
#ifdef DEBUG_CAPTURE
|
||||
qDebug() << "Image saved" << filename;
|
||||
#endif
|
||||
|
||||
Q_UNUSED(camera);
|
||||
|
||||
if (self->m_session->captureDestinationControl()->captureDestination() & QCameraImageCapture::CaptureToFile) {
|
||||
QMetaObject::invokeMethod(self, "imageSaved",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(int, self->m_requestId),
|
||||
Q_ARG(QString, QString::fromUtf8(filename)));
|
||||
} else {
|
||||
#ifdef DEBUG_CAPTURE
|
||||
qDebug() << Q_FUNC_INFO << "Dropped saving file" << filename;
|
||||
#endif
|
||||
//camerabin creates an empty file when captured buffer is dropped,
|
||||
//let's remove it
|
||||
QFileInfo info(QString::fromUtf8(filename));
|
||||
if (info.isFile() &&
|
||||
info.filePath().startsWith("/home") &&
|
||||
info.size() == 0) {
|
||||
QFile(info.absoluteFilePath()).remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
gboolean CameraBinImageCapture::metadataEventProbe(GstPad *pad, GstEvent *event, CameraBinImageCapture *self)
|
||||
{
|
||||
Q_UNUSED(pad);
|
||||
|
||||
if (GST_EVENT_TYPE(event) == GST_EVENT_TAG) {
|
||||
GstTagList *gstTags;
|
||||
@@ -338,7 +307,33 @@ bool CameraBinImageCapture::processBusMessage(const QGstreamerMessage &message)
|
||||
gst_object_unref(srcpad);
|
||||
}
|
||||
}
|
||||
} else if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT) {
|
||||
if (GST_MESSAGE_SRC(gm) == (GstObject *)m_session->cameraBin()) {
|
||||
const GstStructure *structure = gst_message_get_structure(gm);
|
||||
|
||||
if (gst_structure_has_name (structure, "image-done")) {
|
||||
const gchar *fileName = gst_structure_get_string (structure, "filename");
|
||||
#ifdef DEBUG_CAPTURE
|
||||
qDebug() << "Image saved" << fileName;
|
||||
#endif
|
||||
|
||||
if (m_session->captureDestinationControl()->captureDestination() & QCameraImageCapture::CaptureToFile) {
|
||||
emit imageSaved(m_requestId, QString::fromUtf8(fileName));
|
||||
} else {
|
||||
#ifdef DEBUG_CAPTURE
|
||||
qDebug() << Q_FUNC_INFO << "Dropped saving file" << fileName;
|
||||
#endif
|
||||
//camerabin creates an empty file when captured buffer is dropped,
|
||||
//let's remove it
|
||||
QFileInfo info(QString::fromUtf8(fileName));
|
||||
if (info.exists() && info.isFile() && info.size() == 0) {
|
||||
QFile(info.absoluteFilePath()).remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user