diff --git a/src/multimedia/camera/qcameraexposure.h b/src/multimedia/camera/qcameraexposure.h index fc81a44b..8b96b671 100644 --- a/src/multimedia/camera/qcameraexposure.h +++ b/src/multimedia/camera/qcameraexposure.h @@ -95,6 +95,10 @@ public: ExposureParty = 18, ExposureCandlelight = 19, ExposureBarcode = 20, + ExposureFlowers = 21, + ExposureAR = 22, + ExposureHDR = 23, + ExposureCloseup = 24, ExposureModeVendor = 1000 }; diff --git a/src/multimedia/camera/qcameraimageprocessing.h b/src/multimedia/camera/qcameraimageprocessing.h index 2247b33f..4e3e37be 100644 --- a/src/multimedia/camera/qcameraimageprocessing.h +++ b/src/multimedia/camera/qcameraimageprocessing.h @@ -66,6 +66,7 @@ public: WhiteBalanceFluorescent = 6, WhiteBalanceFlash = 7, WhiteBalanceSunset = 8, + WhiteBalanceWarmFluorescent = 9, WhiteBalanceVendor = 1000 }; @@ -79,6 +80,9 @@ public: ColorFilterWhiteboard, ColorFilterBlackboard, ColorFilterAqua, + ColorFilterEmboss, + ColorFilterSketch, + ColorFilterNeon, ColorFilterVendor = 1000 }; diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp b/src/plugins/gstreamer/camerabin/camerabinexposure.cpp index 22b9a8ae..52e83f48 100644 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinexposure.cpp @@ -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() @@ -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; @@ -73,6 +102,7 @@ QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parame *continuous = false; QVariantList res; + switch (parameter) { case QCameraExposureControl::ExposureCompensation: if (continuous) @@ -80,11 +110,52 @@ QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parame 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(g_variant_get_int32(mode))]; + g_variant_unref(mode); + } + } + } + break; +#endif default: break; } @@ -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); @@ -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; } diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.h b/src/plugins/gstreamer/camerabin/camerabinexposure.h index 1e317017..4879dbff 100644 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.h +++ b/src/plugins/gstreamer/camerabin/camerabinexposure.h @@ -40,6 +40,10 @@ #include #include +#ifdef HAVE_GST_PHOTOGRAPHY +# include +#endif + QT_BEGIN_NAMESPACE class CameraBinSession; @@ -62,6 +66,10 @@ public: private: CameraBinSession *m_session; QHash m_requestedValues; + +#ifdef HAVE_GST_PHOTOGRAPHY + QMap m_mappedExposureValues; +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/gstreamer/camerabin/camerabinflash.cpp b/src/plugins/gstreamer/camerabin/camerabinflash.cpp index d363a100..5fbf89eb 100644 --- a/src/plugins/gstreamer/camerabin/camerabinflash.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinflash.cpp @@ -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() @@ -111,6 +118,30 @@ bool CameraBinFlash::isFlashModeSupported(QCameraExposure::FlashModes mode) cons return true; } +#ifdef HAVE_GST_PHOTOGRAPHY + //QList 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(g_variant_get_int32(mode))]; + g_variant_unref(mode); + } + } + return mode & supportedModes; + } + +#endif + return mode == QCameraExposure::FlashOff || mode == QCameraExposure::FlashOn || mode == QCameraExposure::FlashAuto || diff --git a/src/plugins/gstreamer/camerabin/camerabinflash.h b/src/plugins/gstreamer/camerabin/camerabinflash.h index c29df650..b84b217c 100644 --- a/src/plugins/gstreamer/camerabin/camerabinflash.h +++ b/src/plugins/gstreamer/camerabin/camerabinflash.h @@ -39,6 +39,9 @@ #include #include +#ifdef HAVE_GST_PHOTOGRAPHY +# include +#endif QT_BEGIN_NAMESPACE @@ -59,6 +62,10 @@ public: private: CameraBinSession *m_session; + +#ifdef HAVE_GST_PHOTOGRAPHY + QMap m_flashMap; +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp b/src/plugins/gstreamer/camerabin/camerabinfocus.cpp index 32b8d945..f384a5f1 100644 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinfocus.cpp @@ -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() @@ -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(g_variant_get_int32(mode))]; + g_variant_unref(mode); + } + } + return mode & supportedFocusModes; + } +#endif switch (mode) { case QCameraFocus::AutoFocus: case QCameraFocus::HyperfocalFocus: diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.h b/src/plugins/gstreamer/camerabin/camerabinfocus.h index 667e6b67..d193edf1 100644 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.h +++ b/src/plugins/gstreamer/camerabin/camerabinfocus.h @@ -46,6 +46,10 @@ #include #include +#ifdef HAVE_GST_PHOTOGRAPHY +#include +#endif + QT_BEGIN_NAMESPACE class CameraBinSession; @@ -121,6 +125,9 @@ private: QVector m_faceFocusRects; QBasicTimer m_faceResetTimer; mutable QMutex m_mutex; +#ifdef HAVE_GST_PHOTOGRAPHY + QMap m_focusMap; +#endif }; QT_END_NAMESPACE diff --git a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp index 2d165990..b506f126 100644 --- a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp +++ b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp @@ -62,6 +62,10 @@ CameraBinImageProcessing::CameraBinImageProcessing(CameraBinSession *session) m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_SUNSET] = QCameraImageProcessing::WhiteBalanceSunset; m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_TUNGSTEN] = QCameraImageProcessing::WhiteBalanceTungsten; m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_FLUORESCENT] = QCameraImageProcessing::WhiteBalanceFluorescent; +#if GST_CHECK_VERSION(1, 14, 0) + m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_WARM_FLUORESCENT] = QCameraImageProcessing::WhiteBalanceWarmFluorescent; + m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_SHADE] = QCameraImageProcessing::WhiteBalanceShade; +#endif unlockWhiteBalance(); } @@ -77,6 +81,11 @@ CameraBinImageProcessing::CameraBinImageProcessing(CameraBinSession *session) m_filterMap.insert(QCameraImageProcessing::ColorFilterWhiteboard, GST_PHOTOGRAPHY_COLOR_TONE_MODE_WHITEBOARD); m_filterMap.insert(QCameraImageProcessing::ColorFilterBlackboard, GST_PHOTOGRAPHY_COLOR_TONE_MODE_BLACKBOARD); m_filterMap.insert(QCameraImageProcessing::ColorFilterAqua, GST_PHOTOGRAPHY_COLOR_TONE_MODE_AQUA); +#endif +#if GST_CHECK_VERSION(1, 14, 0) + m_filterMap.insert(QCameraImageProcessing::ColorFilterEmboss, GST_PHOTOGRAPHY_COLOR_TONE_MODE_EMBOSS); + m_filterMap.insert(QCameraImageProcessing::ColorFilterSketch, GST_PHOTOGRAPHY_COLOR_TONE_MODE_SKETCH); + m_filterMap.insert(QCameraImageProcessing::ColorFilterNeon, GST_PHOTOGRAPHY_COLOR_TONE_MODE_NEON); #endif } #else @@ -197,6 +206,26 @@ bool CameraBinImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::White bool CameraBinImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const { #ifdef HAVE_GST_PHOTOGRAPHY + // get supported modes from GStreamer + QList supportedWbModes; + 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-wb-modes")) { + + GVariant *supported_wb_modes; + g_object_get(G_OBJECT(m_session->cameraSource()), "supported-wb-modes", &supported_wb_modes, NULL); + + if (supported_wb_modes) { + int wb_count = g_variant_n_children(supported_wb_modes); + + for (int i = 0; i < wb_count; i++) { + GVariant *mode = g_variant_get_child_value(supported_wb_modes, i); + supportedWbModes << m_mappedWbValues[static_cast(g_variant_get_int32(mode))]; + g_variant_unref(mode); + } + } + return supportedWbModes.contains(mode); + } return m_mappedWbValues.values().contains(mode); #else Q_UNUSED(mode); @@ -270,6 +299,25 @@ bool CameraBinImageProcessing::isParameterValueSupported(QCameraImageProcessingC case ColorFilter: { const QCameraImageProcessing::ColorFilter filter = value.value(); #ifdef HAVE_GST_PHOTOGRAPHY + // get supported effects from GStreamer + QList supportedEffects; + 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-color-tones")) { + + GVariant *supported_effects; + g_object_get(G_OBJECT(m_session->cameraSource()), "supported-color-tones", &supported_effects, NULL); + + if (supported_effects) { + int effect_count = g_variant_n_children(supported_effects); + + for (int i = 0; i < effect_count; i++) { + GVariant *mode = g_variant_get_child_value(supported_effects, i); + supportedEffects << m_filterMap.keys().at(m_filterMap.values().indexOf((GstPhotographyColorToneMode)g_variant_get_int32(mode))); + } + } + return supportedEffects.contains(filter); + } return m_filterMap.contains(filter); #else return filter == QCameraImageProcessing::ColorFilterNone;