Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[camerabin] Implement retrieval of supported camera features MER#1976
scene-modes
flash-modes
focus-modes
effects
white-balance-modes
iso-values
  • Loading branch information
piggz committed Dec 12, 2018
1 parent 1428794 commit 662f758
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/multimedia/camera/qcameraexposure.h
Expand Up @@ -95,6 +95,10 @@ class Q_MULTIMEDIA_EXPORT QCameraExposure : public QObject
ExposureParty = 18,
ExposureCandlelight = 19,
ExposureBarcode = 20,
ExposureFlowers = 21,
ExposureAR = 22,
ExposureHDR = 23,
ExposureCloseup = 24,
ExposureModeVendor = 1000
};

Expand Down
4 changes: 4 additions & 0 deletions src/multimedia/camera/qcameraimageprocessing.h
Expand Up @@ -66,6 +66,7 @@ class Q_MULTIMEDIA_EXPORT QCameraImageProcessing : public QObject
WhiteBalanceFluorescent = 6,
WhiteBalanceFlash = 7,
WhiteBalanceSunset = 8,
WhiteBalanceWarmFluorescent = 9,
WhiteBalanceVendor = 1000
};

Expand All @@ -79,6 +80,9 @@ class Q_MULTIMEDIA_EXPORT QCameraImageProcessing : public QObject
ColorFilterWhiteboard,
ColorFilterBlackboard,
ColorFilterAqua,
ColorFilterEmboss,
ColorFilterSketch,
ColorFilterNeon,
ColorFilterVendor = 1000
};

Expand Down
99 changes: 98 additions & 1 deletion src/plugins/gstreamer/camerabin/camerabinexposure.cpp
Expand Up @@ -47,6 +47,32 @@ CameraBinExposure::CameraBinExposure(CameraBinSession *session)
:QCameraExposureControl(session),
m_session(session)
{
if (m_session->photography()) {
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_MANUAL] = QCameraExposure::ExposureManual;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_AUTO] = QCameraExposure::ExposureAuto;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP] = QCameraExposure::ExposureCloseup;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT] = QCameraExposure::ExposurePortrait;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE] = QCameraExposure::ExposureLandscape;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_SPORT] = QCameraExposure::ExposureSports;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_NIGHT] = QCameraExposure::ExposureNight;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_ACTION] = QCameraExposure::ExposureAction;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_NIGHT_PORTRAIT] = QCameraExposure::ExposureNightPortrait;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_THEATRE] = QCameraExposure::ExposureTheatre;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_BEACH] = QCameraExposure::ExposureBeach;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_SNOW] = QCameraExposure::ExposureSnow;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_SUNSET] = QCameraExposure::ExposureSunset;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_STEADY_PHOTO] = QCameraExposure::ExposureSteadyPhoto;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_FIREWORKS] = QCameraExposure::ExposureFireworks;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_PARTY] = QCameraExposure::ExposureParty;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_CANDLELIGHT] = QCameraExposure::ExposureCandlelight;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_BARCODE] = QCameraExposure::ExposureBarcode;
#if GST_CHECK_VERSION(1, 14, 0)
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_BACKLIGHT] = QCameraExposure::ExposureBacklight;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_FLOWERS] = QCameraExposure::ExposureFlowers;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_AR] = QCameraExposure::ExposureAR;
m_mappedExposureValues[GST_PHOTOGRAPHY_SCENE_MODE_HDR] = QCameraExposure::ExposureHDR;
#endif
}
}

CameraBinExposure::~CameraBinExposure()
Expand All @@ -60,6 +86,9 @@ bool CameraBinExposure::isParameterSupported(ExposureParameter parameter) const
case QCameraExposureControl::ISO:
case QCameraExposureControl::Aperture:
case QCameraExposureControl::ShutterSpeed:
#ifdef HAVE_GST_PHOTOGRAPHY
case QCameraExposureControl::ExposureMode:
#endif
return true;
default:
return false;
Expand All @@ -73,18 +102,60 @@ QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parame
*continuous = false;

QVariantList res;

switch (parameter) {
case QCameraExposureControl::ExposureCompensation:
if (continuous)
*continuous = true;
res << -2.0 << 2.0;
break;
case QCameraExposureControl::ISO:
#ifdef HAVE_GST_PHOTOGRAPHY
if (G_IS_OBJECT(m_session->cameraSource()) &&
G_IS_OBJECT_CLASS(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource()))) &&
g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource())), "supported-iso-speeds")) {
GVariant *iso_modes;
g_object_get(G_OBJECT(m_session->cameraSource()), "supported-iso-speeds", &iso_modes, NULL);

if (iso_modes) {
int iso_mode_count = g_variant_n_children(iso_modes);

for (int i = 0; i < iso_mode_count; i++) {
GVariant *mode = g_variant_get_child_value(iso_modes, i);
res << g_variant_get_int32(mode);
g_variant_unref(mode);
}
}
} else {
res << 100 << 200 << 400;
}
#else
res << 100 << 200 << 400;
#endif
break;
case QCameraExposureControl::Aperture:
res << 2.8;
break;
#ifdef HAVE_GST_PHOTOGRAPHY
case QCameraExposureControl::ExposureMode:
if (G_IS_OBJECT(m_session->cameraSource()) &&
G_IS_OBJECT_CLASS(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource()))) &&
g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource())), "supported-scene-modes")) {
GVariant *exposure_modes;
g_object_get(G_OBJECT(m_session->cameraSource()), "supported-scene-modes", &exposure_modes, NULL);

if (exposure_modes) {
int exposure_mode_count = g_variant_n_children(exposure_modes);

for (int i = 0; i < exposure_mode_count; i++) {
GVariant *mode = g_variant_get_child_value(exposure_modes, i);
res << m_mappedExposureValues[static_cast<GstPhotographySceneMode>(g_variant_get_int32(mode))];
g_variant_unref(mode);
}
}
}
break;
#endif
default:
break;
}
Expand Down Expand Up @@ -161,8 +232,18 @@ QVariant CameraBinExposure::actualValue(ExposureParameter parameter) const
case GST_PHOTOGRAPHY_SCENE_MODE_BARCODE:
return QVariant::fromValue(QCameraExposure::ExposureBarcode);
#endif
//no direct mapping available so mapping to auto mode
#if GST_CHECK_VERSION(1, 14, 0)
case GST_PHOTOGRAPHY_SCENE_MODE_BACKLIGHT:
return QVariant::fromValue(QCameraExposure::ExposureBacklight);
case GST_PHOTOGRAPHY_SCENE_MODE_FLOWERS:
return QVariant::fromValue(QCameraExposure::ExposureFlowers);
case GST_PHOTOGRAPHY_SCENE_MODE_AR:
return QVariant::fromValue(QCameraExposure::ExposureAR);
case GST_PHOTOGRAPHY_SCENE_MODE_HDR:
return QVariant::fromValue(QCameraExposure::ExposureHDR);
#endif
case GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP:
return QVariant::fromValue(QCameraExposure::ExposureCloseup);
case GST_PHOTOGRAPHY_SCENE_MODE_AUTO:
default:
return QVariant::fromValue(QCameraExposure::ExposureAuto);
Expand Down Expand Up @@ -252,8 +333,24 @@ bool CameraBinExposure::setValue(ExposureParameter parameter, const QVariant& va
case QCameraExposure::ExposureBarcode:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_BARCODE;
break;
#endif
#if GST_CHECK_VERSION(1, 14, 0)
case QCameraExposure::ExposureFlowers:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_FLOWERS;
break;
case QCameraExposure::ExposureBacklight:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_BACKLIGHT;
break;
case QCameraExposure::ExposureAR:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AR;
break;
case QCameraExposure::ExposureHDR:
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_HDR;
break;
#endif
default:
//Best option is probably to set auto mode for anything unknown
sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AUTO;
break;
}

Expand Down
8 changes: 8 additions & 0 deletions src/plugins/gstreamer/camerabin/camerabinexposure.h
Expand Up @@ -40,6 +40,10 @@
#include <gst/gst.h>
#include <glib.h>

#ifdef HAVE_GST_PHOTOGRAPHY
# include <gst/interfaces/photography.h>
#endif

QT_BEGIN_NAMESPACE

class CameraBinSession;
Expand All @@ -62,6 +66,10 @@ class Q_MULTIMEDIA_EXPORT CameraBinExposure : public QCameraExposureControl
private:
CameraBinSession *m_session;
QHash<ExposureParameter, QVariant> m_requestedValues;

#ifdef HAVE_GST_PHOTOGRAPHY
QMap<GstPhotographySceneMode, QCameraExposure::ExposureMode> m_mappedExposureValues;
#endif
};

QT_END_NAMESPACE
Expand Down
31 changes: 31 additions & 0 deletions src/plugins/gstreamer/camerabin/camerabinflash.cpp
Expand Up @@ -47,6 +47,13 @@ CameraBinFlash::CameraBinFlash(CameraBinSession *session)
:QCameraFlashControl(session),
m_session(session)
{
#ifdef HAVE_GST_PHOTOGRAPHY
m_flashMap[GST_PHOTOGRAPHY_FLASH_MODE_AUTO] = QCameraExposure::FlashAuto;
m_flashMap[GST_PHOTOGRAPHY_FLASH_MODE_OFF] = QCameraExposure::FlashOff;
m_flashMap[GST_PHOTOGRAPHY_FLASH_MODE_ON] = QCameraExposure::FlashOn;
m_flashMap[GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN] = QCameraExposure::FlashFill;
m_flashMap[GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE] = QCameraExposure::FlashRedEyeReduction;
#endif
}

CameraBinFlash::~CameraBinFlash()
Expand Down Expand Up @@ -111,6 +118,30 @@ bool CameraBinFlash::isFlashModeSupported(QCameraExposure::FlashModes mode) cons
return true;
}

#ifdef HAVE_GST_PHOTOGRAPHY
//QList<QCameraExposure::FlashMode> supportedFlash;
QCameraExposure::FlashModes supportedModes;
if (G_IS_OBJECT(m_session->cameraSource()) &&
G_IS_OBJECT_CLASS(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource()))) &&
g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource())), "supported-flash-modes")) {

GVariant *flash_modes;
g_object_get(G_OBJECT(m_session->cameraSource()), "supported-flash-modes", &flash_modes, NULL);

if (flash_modes) {
int flash_count = g_variant_n_children(flash_modes);

for (int i = 0; i < flash_count; i++) {
GVariant *mode = g_variant_get_child_value(flash_modes, i);
supportedModes |= m_flashMap[static_cast<GstPhotographyFlashMode>(g_variant_get_int32(mode))];
g_variant_unref(mode);
}
}
return mode & supportedModes;
}

#endif

return mode == QCameraExposure::FlashOff ||
mode == QCameraExposure::FlashOn ||
mode == QCameraExposure::FlashAuto ||
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/gstreamer/camerabin/camerabinflash.h
Expand Up @@ -39,6 +39,9 @@

#include <gst/gst.h>
#include <glib.h>
#ifdef HAVE_GST_PHOTOGRAPHY
# include <gst/interfaces/photography.h>
#endif

QT_BEGIN_NAMESPACE

Expand All @@ -59,6 +62,10 @@ class Q_MULTIMEDIA_EXPORT CameraBinFlash : public QCameraFlashControl

private:
CameraBinSession *m_session;

#ifdef HAVE_GST_PHOTOGRAPHY
QMap<GstPhotographyFlashMode, QCameraExposure::FlashMode> m_flashMap;
#endif
};

QT_END_NAMESPACE
Expand Down
34 changes: 34 additions & 0 deletions src/plugins/gstreamer/camerabin/camerabinfocus.cpp
Expand Up @@ -70,6 +70,18 @@ CameraBinFocus::CameraBinFocus(CameraBinSession *session)

connect(m_session, SIGNAL(statusChanged(QCamera::Status)),
this, SLOT(_q_handleCameraStatusChange(QCamera::Status)));

#ifdef HAVE_GST_PHOTOGRAPHY
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_AUTO] = QCameraFocus::AutoFocus;
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_MACRO] = QCameraFocus::MacroFocus;
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_PORTRAIT] = QCameraFocus::AutoFocus; //No direct mappint
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_INFINITY] = QCameraFocus::InfinityFocus;
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_HYPERFOCAL] = QCameraFocus::HyperfocalFocus;
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_EXTENDED] = QCameraFocus::AutoFocus; //No direct mapping
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_NORMAL] = QCameraFocus::ContinuousFocus;
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_EXTENDED] = QCameraFocus::ContinuousFocus; //No direct mapping
m_focusMap[GST_PHOTOGRAPHY_FOCUS_MODE_MANUAL] = QCameraFocus::ManualFocus;
#endif
}

CameraBinFocus::~CameraBinFocus()
Expand Down Expand Up @@ -116,6 +128,28 @@ void CameraBinFocus::setFocusMode(QCameraFocus::FocusModes mode)

bool CameraBinFocus::isFocusModeSupported(QCameraFocus::FocusModes mode) const
{
#ifdef HAVE_GST_PHOTOGRAPHY
QCameraFocus::FocusModes supportedFocusModes;

if (G_IS_OBJECT(m_session->cameraSource()) &&
G_IS_OBJECT_CLASS(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource()))) &&
g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(m_session->cameraSource())), "supported-focus-modes")) {

GVariant *focus_modes;
g_object_get(G_OBJECT(m_session->cameraSource()), "supported-focus-modes", &focus_modes, NULL);

if (focus_modes){
int focus_count = g_variant_n_children(focus_modes);

for (int i = 0; i < focus_count; i++) {
GVariant *mode = g_variant_get_child_value(focus_modes, i);
supportedFocusModes |= m_focusMap[static_cast<GstPhotographyFocusMode>(g_variant_get_int32(mode))];
g_variant_unref(mode);
}
}
return mode & supportedFocusModes;
}
#endif
switch (mode) {
case QCameraFocus::AutoFocus:
case QCameraFocus::HyperfocalFocus:
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/gstreamer/camerabin/camerabinfocus.h
Expand Up @@ -46,6 +46,10 @@
#include <gst/gst.h>
#include <glib.h>

#ifdef HAVE_GST_PHOTOGRAPHY
#include <gst/interfaces/photography.h>
#endif

QT_BEGIN_NAMESPACE

class CameraBinSession;
Expand Down Expand Up @@ -121,6 +125,9 @@ private Q_SLOTS:
QVector<QRect> m_faceFocusRects;
QBasicTimer m_faceResetTimer;
mutable QMutex m_mutex;
#ifdef HAVE_GST_PHOTOGRAPHY
QMap<GstPhotographyFocusMode, QCameraFocus::FocusMode> m_focusMap;
#endif
};

QT_END_NAMESPACE
Expand Down

0 comments on commit 662f758

Please sign in to comment.