return m_video ? m_video->startRecording(fileName, tmpFileName) : false;
}
-void VideoMode::stopRecording() {
+void VideoMode::stopRecording(bool sync) {
if (m_video) {
- m_video->stopRecording();
+ m_video->stopRecording(sync);
}
}
bool isRecording();
public slots:
- void stopRecording();
+ void stopRecording(bool sync);
signals:
void recordingStateChanged();
gst_message_unref(message);
}
}
+
+GstMessage *QtCamGStreamerMessageListener::waitForMessage(const QLatin1String& name) {
+ GstMessage *message = 0;
+
+ while (!message) {
+ message = gst_bus_timed_pop_filtered(d_ptr->bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ELEMENT);
+ if (!message) {
+ // Hmmm, what to do here??
+ continue;
+ }
+
+ d_ptr->handleMessage(message);
+ const GstStructure *s = gst_message_get_structure(message);
+ const gchar *n = s ? gst_structure_get_name(s) : 0;
+ if (s && n && n == name) {
+ return message;
+ }
+
+ gst_message_unref(message);
+ message = 0;
+ }
+
+ return 0;
+}
void flushMessages();
+ GstMessage *waitForMessage(const QLatin1String& name);
+
signals:
void error(const QString& message, int code, const QString& debug);
void started();
#include "qtcamdevice.h"
#include "qtcamvideosettings.h"
#include "qtcamnotifications.h"
+#include "qtcamgstreamermessagelistener.h"
class QtCamVideoModePrivate : public QtCamModePrivate {
public:
void QtCamVideoMode::stop() {
if (isRecording()) {
- stopRecording();
+ stopRecording(true);
}
}
return true;
}
-void QtCamVideoMode::stopRecording() {
+void QtCamVideoMode::stopRecording(bool sync) {
if (isRecording()) {
g_signal_emit_by_name(d_ptr->dev->cameraBin, "stop-capture", NULL);
+
+ if (sync) {
+ GstMessage *msg = d_ptr->dev->listener->waitForMessage(QLatin1String("video-done"));
+ if (msg) {
+ gst_message_unref(msg);
+ }
+ }
}
}
QtCamVideoSettings *settings();
public slots:
- void stopRecording();
+ void stopRecording(bool sync);
signals:
void recordingStateChanged();