summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2014-10-02 14:21:20 +0200
committerYoann Lopes <yoann.lopes@theqtcompany.com>2014-10-03 11:38:49 +0200
commitca94dc79b6f0e57ba7446a87c70398a178fbcac8 (patch)
treee3788d7eed190decde903c7ff3fe7f3e7b7d7746
parentf02d9e934322fbf9af8a5503c1bda37552988b2b (diff)
GStreamer: fix QMediaRecorder::duration() when recording with a camerav5.4.0-beta1
To get the recording duration, we were using the camerabin's position, which represents the time since it was started, not the time it's been recording to a file. We now retrieve the camerabin's filesink position. Change-Id: I68eeb25d1718666288655d22deea23e25de73b90 Reviewed-by: Andrew den Exter <andrew.den.exter@qinetic.com.au>
-rw-r--r--src/plugins/gstreamer/camerabin/camerabinsession.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
index 850f8c16..01978397 100644
--- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp
+++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp
@@ -98,6 +98,8 @@
#define CAPTURE_START "start-capture"
#define CAPTURE_STOP "stop-capture"
+#define FILESINK_BIN_NAME "videobin-filesink"
+
#define CAMERABIN_IMAGE_MODE 1
#define CAMERABIN_VIDEO_MODE 2
@@ -721,13 +723,19 @@ void CameraBinSession::updateBusyStatus(GObject *o, GParamSpec *p, gpointer d)
qint64 CameraBinSession::duration() const
{
- GstFormat format = GST_FORMAT_TIME;
- gint64 duration = 0;
+ if (m_camerabin) {
+ GstElement *fileSink = gst_bin_get_by_name(GST_BIN(m_camerabin), FILESINK_BIN_NAME);
+ if (fileSink) {
+ GstFormat format = GST_FORMAT_TIME;
+ gint64 duration = 0;
+ bool ret = gst_element_query_position(fileSink, &format, &duration);
+ gst_object_unref(GST_OBJECT(fileSink));
+ if (ret)
+ return duration / 1000000;
+ }
+ }
- if ( m_camerabin && gst_element_query_position(m_camerabin, &format, &duration))
- return duration / 1000000;
- else
- return 0;
+ return 0;
}
bool CameraBinSession::isMuted() const