void QAndroidCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) { if (m_flashMode == mode || !m_session->camera() || !isFlashModeSupported(mode)) return; // if torch was enabled, it first needs to be turned off before setting another mode if (m_flashMode == QCameraExposure::FlashVideoLight) m_session->camera()->setFlashMode(QLatin1String("off")); m_flashMode = mode; QString flashMode; if (mode.testFlag(QCameraExposure::FlashAuto)) flashMode = QLatin1String("auto"); else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = QLatin1String("on"); else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) flashMode = QLatin1String("red-eye"); else if (mode.testFlag(QCameraExposure::FlashVideoLight)) flashMode = QLatin1String("torch"); else // FlashOff flashMode = QLatin1String("off"); m_session->camera()->setFlashMode(flashMode); }
void BbCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode) { if (m_flashMode == mode) return; if (m_session->status() != QCamera::ActiveStatus) // can only be changed when viewfinder is active return; if (m_flashMode == QCameraExposure::FlashVideoLight) { const camera_error_t result = camera_config_videolight(m_session->handle(), CAMERA_VIDEOLIGHT_OFF); if (result != CAMERA_EOK) qWarning() << "Unable to switch off video light:" << result; } m_flashMode = mode; if (m_flashMode == QCameraExposure::FlashVideoLight) { const camera_error_t result = camera_config_videolight(m_session->handle(), CAMERA_VIDEOLIGHT_ON); if (result != CAMERA_EOK) qWarning() << "Unable to switch on video light:" << result; } else { camera_flashmode_t flashMode = CAMERA_FLASH_AUTO; if (m_flashMode.testFlag(QCameraExposure::FlashAuto)) flashMode = CAMERA_FLASH_AUTO; else if (mode.testFlag(QCameraExposure::FlashOff)) flashMode = CAMERA_FLASH_OFF; else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = CAMERA_FLASH_ON; const camera_error_t result = camera_config_flash(m_session->handle(), flashMode); if (result != CAMERA_EOK) qWarning() << "Unable to configure flash:" << result; } }
void CameraBinFlash::setFlashMode(QCameraExposure::FlashModes mode) { GstFlashMode flashMode; gst_photography_get_flash_mode(m_session->photography(), &flashMode); if (mode.testFlag(QCameraExposure::FlashAuto)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_AUTO; else if (mode.testFlag(QCameraExposure::FlashOff)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_OFF; else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_ON; else if (mode.testFlag(QCameraExposure::FlashFill)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN; else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE; gst_photography_set_flash_mode(m_session->photography(), flashMode); }
void CameraBinFlash::setFlashMode(QCameraExposure::FlashModes mode) { GstFlashMode flashMode; gst_photography_get_flash_mode(m_session->photography(), &flashMode); if (mode.testFlag(QCameraExposure::FlashAuto)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_AUTO; else if (mode.testFlag(QCameraExposure::FlashOff)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_OFF; else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_ON; else if (mode.testFlag(QCameraExposure::FlashFill)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN; else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE; gst_photography_set_flash_mode(m_session->photography(), flashMode); #ifdef Q_WS_MAEMO_6 gboolean torchEnabled = false; g_object_get(G_OBJECT(m_session->cameraSourceElement()), "video-torch", &torchEnabled, NULL); gboolean enableTorch = mode.testFlag(QCameraExposure::FlashTorch); if (bool(enableTorch) != bool(torchEnabled)) { g_object_set(G_OBJECT(m_session->cameraSourceElement()), "video-torch", enableTorch, NULL); //it's necessary to restart source element to toggle torch if (m_session->captureMode() == QCamera::CaptureVideo) emit torchModeChanged(bool(torchEnabled)); } #endif }