Commit 2af2d835 authored by VaL Doroshchuk's avatar VaL Doroshchuk
Browse files

Gstreamer: Fix crash when resolution or frame rates are requested


When either resolution or frame rates have been requested when
the camera is in unloaded state, caps might not have some values.

Change-Id: Ie935c62d02e10f762957ecd9f89255ad0e8fbd0b
Reviewed-by: default avatarChristian Stromme <christian.stromme@qt.io>
Showing with 11 additions and 0 deletions
......@@ -1294,6 +1294,9 @@ QList< QPair<int,int> > CameraBinSession::supportedFrameRates(const QSize &frame
GstStructure *structure = gst_caps_get_structure(caps, i);
gst_structure_set_name(structure, "video/x-raw");
const GValue *oldRate = gst_structure_get_value(structure, "framerate");
if (!oldRate)
continue;
GValue rate;
memset(&rate, 0, sizeof(rate));
g_value_init(&rate, G_VALUE_TYPE(oldRate));
......@@ -1310,6 +1313,9 @@ QList< QPair<int,int> > CameraBinSession::supportedFrameRates(const QSize &frame
for (uint i=0; i<gst_caps_get_size(caps); i++) {
GstStructure *structure = gst_caps_get_structure(caps, i);
const GValue *rateValue = gst_structure_get_value(structure, "framerate");
if (!rateValue)
continue;
readValue(rateValue, &res, continuous);
}
......@@ -1401,6 +1407,9 @@ QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate,
gst_structure_set_name(structure, "video/x-raw");
const GValue *oldW = gst_structure_get_value(structure, "width");
const GValue *oldH = gst_structure_get_value(structure, "height");
if (!oldW || !oldH)
continue;
GValue w;
memset(&w, 0, sizeof(GValue));
GValue h;
......@@ -1425,6 +1434,8 @@ QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate,
GstStructure *structure = gst_caps_get_structure(caps, i);
const GValue *wValue = gst_structure_get_value(structure, "width");
const GValue *hValue = gst_structure_get_value(structure, "height");
if (!wValue || !hValue)
continue;
QPair<int,int> wRange = valueRange(wValue, &isContinuous);
QPair<int,int> hRange = valueRange(hValue, &isContinuous);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment