Exemple #1
0
bool BbCameraSession::isCaptureModeSupported(QCamera::CaptureModes mode) const
{
    if (m_handle == CAMERA_HANDLE_INVALID) {
        // the camera has not been loaded yet via QCamera::load(), so
        // we open it temporarily to peek for the supported capture modes

        camera_unit_t unit = CAMERA_UNIT_REAR;
        if (m_device == cameraIdentifierFront())
            unit = CAMERA_UNIT_FRONT;
        else if (m_device == cameraIdentifierRear())
            unit = CAMERA_UNIT_REAR;
        else if (m_device == cameraIdentifierDesktop())
            unit = CAMERA_UNIT_DESKTOP;

        camera_handle_t handle;
        const camera_error_t result = camera_open(unit, CAMERA_MODE_RW, &handle);
        if (result != CAMERA_EOK)
            return true;

        const bool supported = isCaptureModeSupported(handle, mode);

        camera_close(handle);

        return supported;
    } else {
        return isCaptureModeSupported(m_handle, mode);
    }
}
void DSCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
    if (m_captureMode != mode && isCaptureModeSupported(mode)) {
        m_captureMode = mode;
        emit captureModeChanged(mode);
    }
}
void QAndroidCameraSession::setCaptureMode(QCamera::CaptureModes mode)
{
    if (m_captureMode == mode || !isCaptureModeSupported(mode))
        return;

    m_captureMode = mode;
    emit captureModeChanged(m_captureMode);

    if (m_previewStarted && m_captureMode.testFlag(QCamera::CaptureStillImage))
        adjustViewfinderSize(m_imageSettings.resolution());
}
void QGstreamerCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
    if (m_captureMode == mode || !isCaptureModeSupported(mode))
        return;

    m_captureMode = mode;

    switch (mode) {
    case QCamera::CaptureViewfinder:
    case QCamera::CaptureStillImage:
        m_session->setCaptureMode(QGstreamerCaptureSession::Image);
        break;
    case QCamera::CaptureVideo:
        m_session->setCaptureMode(QGstreamerCaptureSession::AudioAndVideo);
        break;
    case QCamera::CaptureVideo | QCamera::CaptureStillImage:
        m_session->setCaptureMode(QGstreamerCaptureSession::AudioAndVideoAndImage);
        break;
    }

    emit captureModeChanged(mode);
    updateStatus();
    reloadLater();
}