Enable camera on the Playbook
Change-Id: I61537899bee63150861df57f9140316eca6a6eed Reviewed-by: Bernd Weimer <bweimer@blackberry.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
This commit is contained in:
committed by
The Qt Project
parent
4cd39cc52f
commit
2e1d38a3c7
@@ -40,10 +40,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "bbserviceplugin.h"
|
#include "bbserviceplugin.h"
|
||||||
|
|
||||||
#ifndef Q_OS_BLACKBERRY_TABLET
|
|
||||||
#include "bbcameraservice.h"
|
#include "bbcameraservice.h"
|
||||||
#include "bbvideodeviceselectorcontrol.h"
|
#include "bbvideodeviceselectorcontrol.h"
|
||||||
#endif
|
|
||||||
#include "bbmediaplayerservice.h"
|
#include "bbmediaplayerservice.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -56,10 +54,8 @@ BbServicePlugin::BbServicePlugin()
|
|||||||
|
|
||||||
QMediaService *BbServicePlugin::create(const QString &key)
|
QMediaService *BbServicePlugin::create(const QString &key)
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_BLACKBERRY_TABLET
|
|
||||||
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
|
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
|
||||||
return new BbCameraService();
|
return new BbCameraService();
|
||||||
#endif
|
|
||||||
|
|
||||||
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
|
if (key == QLatin1String(Q_MEDIASERVICE_MEDIAPLAYER))
|
||||||
return new BbMediaPlayerService();
|
return new BbMediaPlayerService();
|
||||||
@@ -106,9 +102,7 @@ QString BbServicePlugin::deviceDescription(const QByteArray &service, const QByt
|
|||||||
|
|
||||||
void BbServicePlugin::updateDevices() const
|
void BbServicePlugin::updateDevices() const
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_BLACKBERRY_TABLET
|
|
||||||
BbVideoDeviceSelectorControl::enumerateDevices(&m_cameraDevices, &m_cameraDescriptions);
|
BbVideoDeviceSelectorControl::enumerateDevices(&m_cameraDevices, &m_cameraDescriptions);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_cameraDevices.isEmpty()) {
|
if (m_cameraDevices.isEmpty()) {
|
||||||
qWarning() << "No camera devices found";
|
qWarning() << "No camera devices found";
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ SOURCES += bbserviceplugin.cpp
|
|||||||
|
|
||||||
include(common/common.pri)
|
include(common/common.pri)
|
||||||
|
|
||||||
!blackberry-playbook {
|
include(camera/camera.pri)
|
||||||
include(camera/camera.pri)
|
|
||||||
}
|
|
||||||
|
|
||||||
include(mediaplayer/mediaplayer.pri)
|
include(mediaplayer/mediaplayer.pri)
|
||||||
|
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ QVariant BbCameraExposureControl::requestedValue(ExposureParameter parameter) co
|
|||||||
|
|
||||||
QVariant BbCameraExposureControl::actualValue(ExposureParameter parameter) const
|
QVariant BbCameraExposureControl::actualValue(ExposureParameter parameter) const
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment
|
if (parameter != QCameraExposureControl::ExposureMode) // no other parameter supported by BB10 API at the moment
|
||||||
return QVariantList();
|
return QVariantList();
|
||||||
|
|
||||||
@@ -170,6 +171,9 @@ QVariant BbCameraExposureControl::actualValue(ExposureParameter parameter) const
|
|||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
return QVariant();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BbCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value)
|
bool BbCameraExposureControl::setValue(ExposureParameter parameter, const QVariant& value)
|
||||||
|
|||||||
@@ -45,11 +45,14 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
#include <audio/audio_manager_device.h>
|
#include <audio/audio_manager_device.h>
|
||||||
#include <audio/audio_manager_volume.h>
|
#include <audio/audio_manager_volume.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
static audio_manager_device_t currentAudioInputDevice()
|
static audio_manager_device_t currentAudioInputDevice()
|
||||||
{
|
{
|
||||||
audio_manager_device_t device = AUDIO_DEVICE_HEADSET;
|
audio_manager_device_t device = AUDIO_DEVICE_HEADSET;
|
||||||
@@ -62,6 +65,7 @@ static audio_manager_device_t currentAudioInputDevice()
|
|||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BbCameraMediaRecorderControl::BbCameraMediaRecorderControl(BbCameraSession *session, QObject *parent)
|
BbCameraMediaRecorderControl::BbCameraMediaRecorderControl(BbCameraSession *session, QObject *parent)
|
||||||
: QMediaRecorderControl(parent)
|
: QMediaRecorderControl(parent)
|
||||||
@@ -103,12 +107,13 @@ bool BbCameraMediaRecorderControl::isMuted() const
|
|||||||
{
|
{
|
||||||
bool muted = false;
|
bool muted = false;
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
const int result = audio_manager_get_input_mute(currentAudioInputDevice(), &muted);
|
const int result = audio_manager_get_input_mute(currentAudioInputDevice(), &muted);
|
||||||
if (result != EOK) {
|
if (result != EOK) {
|
||||||
emit const_cast<BbCameraMediaRecorderControl*>(this)->error(QMediaRecorder::ResourceError, tr("Unable to retrieve mute status"));
|
emit const_cast<BbCameraMediaRecorderControl*>(this)->error(QMediaRecorder::ResourceError, tr("Unable to retrieve mute status"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return muted;
|
return muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,11 +121,13 @@ qreal BbCameraMediaRecorderControl::volume() const
|
|||||||
{
|
{
|
||||||
double level = 0.0;
|
double level = 0.0;
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
const int result = audio_manager_get_input_level(currentAudioInputDevice(), &level);
|
const int result = audio_manager_get_input_level(currentAudioInputDevice(), &level);
|
||||||
if (result != EOK) {
|
if (result != EOK) {
|
||||||
emit const_cast<BbCameraMediaRecorderControl*>(this)->error(QMediaRecorder::ResourceError, tr("Unable to retrieve audio input volume"));
|
emit const_cast<BbCameraMediaRecorderControl*>(this)->error(QMediaRecorder::ResourceError, tr("Unable to retrieve audio input volume"));
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return (level / 100);
|
return (level / 100);
|
||||||
}
|
}
|
||||||
@@ -137,22 +144,26 @@ void BbCameraMediaRecorderControl::setState(QMediaRecorder::State state)
|
|||||||
|
|
||||||
void BbCameraMediaRecorderControl::setMuted(bool muted)
|
void BbCameraMediaRecorderControl::setMuted(bool muted)
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
const int result = audio_manager_set_input_mute(currentAudioInputDevice(), muted);
|
const int result = audio_manager_set_input_mute(currentAudioInputDevice(), muted);
|
||||||
if (result != EOK) {
|
if (result != EOK) {
|
||||||
emit error(QMediaRecorder::ResourceError, tr("Unable to set mute status"));
|
emit error(QMediaRecorder::ResourceError, tr("Unable to set mute status"));
|
||||||
} else {
|
} else {
|
||||||
emit mutedChanged(muted);
|
emit mutedChanged(muted);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void BbCameraMediaRecorderControl::setVolume(qreal volume)
|
void BbCameraMediaRecorderControl::setVolume(qreal volume)
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
const int result = audio_manager_set_input_level(currentAudioInputDevice(), (volume * 100));
|
const int result = audio_manager_set_input_level(currentAudioInputDevice(), (volume * 100));
|
||||||
if (result != EOK) {
|
if (result != EOK) {
|
||||||
emit error(QMediaRecorder::ResourceError, tr("Unable to set audio input volume"));
|
emit error(QMediaRecorder::ResourceError, tr("Unable to set audio input volume"));
|
||||||
} else {
|
} else {
|
||||||
emit volumeChanged(volume);
|
emit volumeChanged(volume);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|||||||
@@ -70,9 +70,11 @@ BbCameraOrientationHandler::BbCameraOrientationHandler(QObject *parent)
|
|||||||
|
|
||||||
BbCameraOrientationHandler::~BbCameraOrientationHandler()
|
BbCameraOrientationHandler::~BbCameraOrientationHandler()
|
||||||
{
|
{
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
const int result = orientation_stop_events(0);
|
const int result = orientation_stop_events(0);
|
||||||
if (result == BPS_FAILURE)
|
if (result == BPS_FAILURE)
|
||||||
qWarning() << "Unable to unregister for orientation change events";
|
qWarning() << "Unable to unregister for orientation change events";
|
||||||
|
#endif
|
||||||
|
|
||||||
QCoreApplication::eventDispatcher()->removeNativeEventFilter(this);
|
QCoreApplication::eventDispatcher()->removeNativeEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,16 +85,18 @@ static QString errorToString(camera_error_t error)
|
|||||||
return QLatin1String("Communication timeout");
|
return QLatin1String("Communication timeout");
|
||||||
case CAMERA_EALREADY:
|
case CAMERA_EALREADY:
|
||||||
return QLatin1String("Operation already in progress");
|
return QLatin1String("Operation already in progress");
|
||||||
case CAMERA_ENOSPC:
|
|
||||||
return QLatin1String("Disk is full");
|
|
||||||
case CAMERA_EUNINIT:
|
case CAMERA_EUNINIT:
|
||||||
return QLatin1String("Camera library not initialized");
|
return QLatin1String("Camera library not initialized");
|
||||||
case CAMERA_EREGFAULT:
|
case CAMERA_EREGFAULT:
|
||||||
return QLatin1String("Callback registration failed");
|
return QLatin1String("Callback registration failed");
|
||||||
case CAMERA_EMICINUSE:
|
case CAMERA_EMICINUSE:
|
||||||
return QLatin1String("Microphone in use already");
|
return QLatin1String("Microphone in use already");
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
case CAMERA_EDESKTOPCAMERAINUSE:
|
case CAMERA_EDESKTOPCAMERAINUSE:
|
||||||
return QLatin1String("Desktop camera in use already");
|
return QLatin1String("Desktop camera in use already");
|
||||||
|
case CAMERA_ENOSPC:
|
||||||
|
return QLatin1String("Disk is full");
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return QLatin1String("Unknown error");
|
return QLatin1String("Unknown error");
|
||||||
}
|
}
|
||||||
@@ -648,6 +650,9 @@ void BbCameraSession::applyVideoSettings()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QSize resolution = m_videoEncoderSettings.resolution();
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
QString videoCodec = m_videoEncoderSettings.codec();
|
QString videoCodec = m_videoEncoderSettings.codec();
|
||||||
if (videoCodec.isEmpty())
|
if (videoCodec.isEmpty())
|
||||||
videoCodec = QLatin1String("h264");
|
videoCodec = QLatin1String("h264");
|
||||||
@@ -660,8 +665,6 @@ void BbCameraSession::applyVideoSettings()
|
|||||||
else if (videoCodec == QLatin1String("h264"))
|
else if (videoCodec == QLatin1String("h264"))
|
||||||
cameraVideoCodec = CAMERA_VIDEOCODEC_H264;
|
cameraVideoCodec = CAMERA_VIDEOCODEC_H264;
|
||||||
|
|
||||||
const QSize resolution = m_videoEncoderSettings.resolution();
|
|
||||||
|
|
||||||
qreal frameRate = m_videoEncoderSettings.frameRate();
|
qreal frameRate = m_videoEncoderSettings.frameRate();
|
||||||
if (frameRate == 0) {
|
if (frameRate == 0) {
|
||||||
const QList<qreal> frameRates = supportedFrameRates(QVideoEncoderSettings(), 0);
|
const QList<qreal> frameRates = supportedFrameRates(QVideoEncoderSettings(), 0);
|
||||||
@@ -680,12 +683,16 @@ void BbCameraSession::applyVideoSettings()
|
|||||||
cameraAudioCodec = CAMERA_AUDIOCODEC_AAC;
|
cameraAudioCodec = CAMERA_AUDIOCODEC_AAC;
|
||||||
else if (audioCodec == QLatin1String("raw"))
|
else if (audioCodec == QLatin1String("raw"))
|
||||||
cameraAudioCodec = CAMERA_AUDIOCODEC_RAW;
|
cameraAudioCodec = CAMERA_AUDIOCODEC_RAW;
|
||||||
|
|
||||||
result = camera_set_video_property(m_handle,
|
result = camera_set_video_property(m_handle,
|
||||||
CAMERA_IMGPROP_WIDTH, resolution.width(),
|
CAMERA_IMGPROP_WIDTH, resolution.width(),
|
||||||
CAMERA_IMGPROP_HEIGHT, resolution.height(),
|
CAMERA_IMGPROP_HEIGHT, resolution.height(),
|
||||||
CAMERA_IMGPROP_VIDEOCODEC, cameraVideoCodec,
|
CAMERA_IMGPROP_VIDEOCODEC, cameraVideoCodec,
|
||||||
CAMERA_IMGPROP_AUDIOCODEC, cameraAudioCodec);
|
CAMERA_IMGPROP_AUDIOCODEC, cameraAudioCodec);
|
||||||
|
#else
|
||||||
|
result = camera_set_video_property(m_handle,
|
||||||
|
CAMERA_IMGPROP_WIDTH, resolution.width(),
|
||||||
|
CAMERA_IMGPROP_HEIGHT, resolution.height());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (result != CAMERA_EOK) {
|
if (result != CAMERA_EOK) {
|
||||||
qWarning() << "Unable to apply video settings:" << result;
|
qWarning() << "Unable to apply video settings:" << result;
|
||||||
@@ -969,10 +976,14 @@ static void viewFinderStatusCallback(camera_handle_t handle, camera_devstatus_t
|
|||||||
if (status == CAMERA_STATUS_FOCUS_CHANGE) {
|
if (status == CAMERA_STATUS_FOCUS_CHANGE) {
|
||||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||||
QMetaObject::invokeMethod(session, "handleFocusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
QMetaObject::invokeMethod(session, "handleFocusStatusChanged", Qt::QueuedConnection, Q_ARG(int, value));
|
||||||
} else if (status == CAMERA_STATUS_POWERUP) {
|
return;
|
||||||
|
}
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
|
else if (status == CAMERA_STATUS_POWERUP) {
|
||||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||||
QMetaObject::invokeMethod(session, "handleCameraPowerUp", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(session, "handleCameraPowerUp", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BbCameraSession::startViewFinder()
|
bool BbCameraSession::startViewFinder()
|
||||||
@@ -1149,6 +1160,7 @@ static void videoRecordingStatusCallback(camera_handle_t handle, camera_devstatu
|
|||||||
Q_UNUSED(handle)
|
Q_UNUSED(handle)
|
||||||
Q_UNUSED(value)
|
Q_UNUSED(value)
|
||||||
|
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
if (status == CAMERA_STATUS_VIDEO_PAUSE) {
|
if (status == CAMERA_STATUS_VIDEO_PAUSE) {
|
||||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||||
QMetaObject::invokeMethod(session, "handleVideoRecordingPaused", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(session, "handleVideoRecordingPaused", Qt::QueuedConnection);
|
||||||
@@ -1156,6 +1168,7 @@ static void videoRecordingStatusCallback(camera_handle_t handle, camera_devstatu
|
|||||||
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
BbCameraSession *session = static_cast<BbCameraSession*>(context);
|
||||||
QMetaObject::invokeMethod(session, "handleVideoRecordingResumed", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(session, "handleVideoRecordingResumed", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BbCameraSession::startVideoRecording()
|
bool BbCameraSession::startVideoRecording()
|
||||||
|
|||||||
@@ -156,10 +156,12 @@ QVariant BbCameraViewfinderSettingsControl::viewfinderParameter(ViewfinderParame
|
|||||||
return QVideoFrame::Format_Invalid;
|
return QVideoFrame::Format_Invalid;
|
||||||
case CAMERA_FRAMETYPE_CBYCRY:
|
case CAMERA_FRAMETYPE_CBYCRY:
|
||||||
return QVideoFrame::Format_Invalid;
|
return QVideoFrame::Format_Invalid;
|
||||||
|
#ifndef Q_OS_BLACKBERRY_TABLET
|
||||||
case CAMERA_FRAMETYPE_COMPRESSEDVIDEO:
|
case CAMERA_FRAMETYPE_COMPRESSEDVIDEO:
|
||||||
return QVideoFrame::Format_Invalid;
|
return QVideoFrame::Format_Invalid;
|
||||||
case CAMERA_FRAMETYPE_COMPRESSEDAUDIO:
|
case CAMERA_FRAMETYPE_COMPRESSEDAUDIO:
|
||||||
return QVideoFrame::Format_Invalid;
|
return QVideoFrame::Format_Invalid;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return QVideoFrame::Format_Invalid;
|
return QVideoFrame::Format_Invalid;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,8 @@ SOURCES += \
|
|||||||
$$PWD/bbvideodeviceselectorcontrol.cpp \
|
$$PWD/bbvideodeviceselectorcontrol.cpp \
|
||||||
$$PWD/bbvideorenderercontrol.cpp
|
$$PWD/bbvideorenderercontrol.cpp
|
||||||
|
|
||||||
LIBS += -lcamapi -laudio_manager
|
LIBS += -lcamapi
|
||||||
|
|
||||||
|
!blackberry-playbook {
|
||||||
|
LIBS += -laudio_manager
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user