From c93d83c4b7a5d1a5d7b35d93141d96abaf58ed7e Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 8 Jan 2015 14:10:20 +0100 Subject: Add resolution and fps on mfw_v4lsrc Add support for changing resolution and frame rate with mfw_v4lsrc. This is essential for embedded applications that are not happy with the default VGA@30. This makes constructs like the following functional on devices like i.MX6 with MIPI cameras: Camera { viewfinder { resolution: "320x240"; maximumFrameRate: 15 } } Change-Id: Ia297afdb5ca51c6e55ad45dce37fdab7da3a5cfb Reviewed-by: Yoann Lopes --- .../gstreamer/camerabin/camerabinsession.cpp | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/plugins/gstreamer/camerabin/camerabinsession.cpp') diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp index a4038c589..1ed663b9b 100644 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinsession.cpp @@ -338,6 +338,17 @@ void CameraBinSession::setupCaptureResolution() g_object_set(m_camerabin, VIDEO_CAPTURE_CAPS_PROPERTY, NULL, NULL); } + GstElement *mfw_v4lsrc = 0; + if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_videoSrc), "video-source")) { + GstElement *videoSrc = 0; + g_object_get(G_OBJECT(m_videoSrc), "video-source", &videoSrc, NULL); + if (videoSrc) { + const char *name = gst_plugin_feature_get_name(GST_PLUGIN_FEATURE(gst_element_get_factory(videoSrc))); + if (!qstrcmp(name, "mfw_v4lsrc")) + mfw_v4lsrc = videoSrc; + } + } + resolution = m_viewfinderSettingsControl->resolution(); if (!resolution.isEmpty()) { GstCaps *caps = resolutionToCaps(resolution); @@ -346,10 +357,35 @@ void CameraBinSession::setupCaptureResolution() #endif g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, caps, NULL); gst_caps_unref(caps); + + if (mfw_v4lsrc) { + int capMode = 0; + if (resolution == QSize(320, 240)) + capMode = 1; + else if (resolution == QSize(720, 480)) + capMode = 2; + else if (resolution == QSize(720, 576)) + capMode = 3; + else if (resolution == QSize(1280, 720)) + capMode = 4; + else if (resolution == QSize(1920, 1080)) + capMode = 5; + g_object_set(G_OBJECT(mfw_v4lsrc), "capture-mode", capMode, NULL); + } } else { g_object_set(m_camerabin, VIEWFINDER_CAPS_PROPERTY, NULL, NULL); } + const qreal maxFps = m_viewfinderSettingsControl->maximumFrameRate(); + if (!qFuzzyIsNull(maxFps)) { + if (mfw_v4lsrc) { + int n, d; + gst_util_double_to_fraction(maxFps, &n, &d); + g_object_set(G_OBJECT(mfw_v4lsrc), "fps-n", n, NULL); + g_object_set(G_OBJECT(mfw_v4lsrc), "fps-d", d, NULL); + } + } + if (m_videoEncoder) m_videoEncodeControl->applySettings(m_videoEncoder); } -- cgit v1.2.1