| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "camerabinflash.h" |
| 41 | #include "camerabinsession.h" |
| 42 | #include <gst/interfaces/photography.h> |
| 43 | |
| 44 | #include <QDebug> |
| 45 | |
| 46 | #if !GST_CHECK_VERSION(1,0,0) |
| 47 | typedef GstFlashMode GstPhotographyFlashMode; |
| 48 | #endif |
| 49 | |
| 50 | QT_BEGIN_NAMESPACE |
| 51 | |
| 52 | CameraBinFlash::CameraBinFlash(CameraBinSession *session) |
| 53 | :QCameraFlashControl(session), |
| 54 | m_session(session) |
| 55 | { |
| 56 | } |
| 57 | |
| 58 | CameraBinFlash::~CameraBinFlash() |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | QCameraExposure::FlashModes CameraBinFlash::flashMode() const |
| 63 | { |
| 64 | GstPhotographyFlashMode flashMode; |
| 65 | gst_photography_get_flash_mode(photo: m_session->photography(), flash_mode: &flashMode); |
| 66 | |
| 67 | QCameraExposure::FlashModes modes; |
| 68 | switch (flashMode) { |
| 69 | case GST_PHOTOGRAPHY_FLASH_MODE_AUTO: modes |= QCameraExposure::FlashAuto; break; |
| 70 | case GST_PHOTOGRAPHY_FLASH_MODE_OFF: modes |= QCameraExposure::FlashOff; break; |
| 71 | case GST_PHOTOGRAPHY_FLASH_MODE_ON: modes |= QCameraExposure::FlashOn; break; |
| 72 | case GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN: modes |= QCameraExposure::FlashFill; break; |
| 73 | case GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE: modes |= QCameraExposure::FlashRedEyeReduction; break; |
| 74 | default: |
| 75 | modes |= QCameraExposure::FlashAuto; |
| 76 | break; |
| 77 | } |
| 78 | return modes; |
| 79 | } |
| 80 | |
| 81 | void CameraBinFlash::setFlashMode(QCameraExposure::FlashModes mode) |
| 82 | { |
| 83 | GstPhotographyFlashMode flashMode; |
| 84 | gst_photography_get_flash_mode(photo: m_session->photography(), flash_mode: &flashMode); |
| 85 | |
| 86 | if (mode.testFlag(flag: QCameraExposure::FlashAuto)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_AUTO; |
| 87 | else if (mode.testFlag(flag: QCameraExposure::FlashOff)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_OFF; |
| 88 | else if (mode.testFlag(flag: QCameraExposure::FlashOn)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_ON; |
| 89 | else if (mode.testFlag(flag: QCameraExposure::FlashFill)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN; |
| 90 | else if (mode.testFlag(flag: QCameraExposure::FlashRedEyeReduction)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE; |
| 91 | |
| 92 | gst_photography_set_flash_mode(photo: m_session->photography(), flash_mode: flashMode); |
| 93 | } |
| 94 | |
| 95 | bool CameraBinFlash::isFlashModeSupported(QCameraExposure::FlashModes mode) const |
| 96 | { |
| 97 | return mode == QCameraExposure::FlashOff || |
| 98 | mode == QCameraExposure::FlashOn || |
| 99 | mode == QCameraExposure::FlashAuto || |
| 100 | mode == QCameraExposure::FlashRedEyeReduction || |
| 101 | mode == QCameraExposure::FlashFill; |
| 102 | } |
| 103 | |
| 104 | bool CameraBinFlash::isFlashReady() const |
| 105 | { |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | QT_END_NAMESPACE |
| 110 | |