Remove some obsolete bits.
They can be updated again later when things are more stable, if needed. Change-Id: I73bdacdd3d1fd43a60cd3a0c14b925fa9c32ee27 Reviewed-on: http://codereview.qt.nokia.com/1724 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jonas Rabbe <jonas.rabbe@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
7085775a11
commit
1403a1c7be
@@ -200,7 +200,7 @@ QDir AudioCaptureSession::defaultDir() const
|
||||
{
|
||||
QStringList dirCandidates;
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
dirCandidates << QLatin1String("/home/user/MyDocs");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ CameraBinAudioEncoder::CameraBinAudioEncoder(QObject *parent)
|
||||
{
|
||||
QList<QByteArray> codecCandidates;
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
codecCandidates << "audio/AAC" << "audio/PCM" << "audio/AMR" << "audio/AMR-WB" << "audio/speex"
|
||||
<< "audio/ADPCM" << "audio/iLBC" << "audio/vorbis" << "audio/mpeg" << "audio/FLAC";
|
||||
|
||||
|
||||
@@ -129,12 +129,6 @@ void CameraBinControl::setCaptureMode(QCamera::CaptureMode mode)
|
||||
|
||||
bool CameraBinControl::isCaptureModeSupported(QCamera::CaptureMode mode) const
|
||||
{
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
//Front camera on N900 supports only video capture
|
||||
if (m_session->cameraRole() == CameraBinSession::FrontCamera)
|
||||
return mode == QCamera::CaptureVideo;
|
||||
#endif
|
||||
|
||||
return mode == QCamera::CaptureStillImage || mode == QCamera::CaptureVideo;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,26 +101,16 @@ qreal CameraBinFocus::opticalZoom() const
|
||||
|
||||
qreal CameraBinFocus::digitalZoom() const
|
||||
{
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
gint zoomFactor = 0;
|
||||
g_object_get(GST_BIN(m_session->cameraBin()), "zoom", &zoomFactor, NULL);
|
||||
return zoomFactor/100.0;
|
||||
#else
|
||||
gfloat zoomFactor = 1.0;
|
||||
g_object_get(GST_BIN(m_session->cameraBin()), "zoom", &zoomFactor, NULL);
|
||||
return zoomFactor;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CameraBinFocus::zoomTo(qreal optical, qreal digital)
|
||||
{
|
||||
Q_UNUSED(optical);
|
||||
digital = qBound(qreal(1.0), digital, qreal(10.0));
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
g_object_set(GST_BIN(m_session->cameraBin()), "zoom", qRound(digital*100.0), NULL);
|
||||
#else
|
||||
g_object_set(GST_BIN(m_session->cameraBin()), "zoom", digital, NULL);
|
||||
#endif
|
||||
emit digitalZoomChanged(digital);
|
||||
}
|
||||
|
||||
@@ -223,13 +213,6 @@ void CameraBinFocus::_q_handleCameraStateChange(QCamera::State state)
|
||||
|
||||
void CameraBinFocus::_q_handleCapturedImage()
|
||||
{
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
//N900 lost focus after image capture
|
||||
if (m_focusStatus != QCamera::Unlocked) {
|
||||
m_focusStatus = QCamera::Unlocked;
|
||||
emit _q_focusStatusChanged(QCamera::Unlocked, QCamera::LockLost);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CameraBinFocus::_q_startFocusing()
|
||||
|
||||
@@ -52,12 +52,7 @@
|
||||
|
||||
//#define DEBUG_CAPTURE
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
#define IMAGE_DONE_SIGNAL "img-done"
|
||||
#else
|
||||
#define IMAGE_DONE_SIGNAL "image-done"
|
||||
#endif
|
||||
|
||||
|
||||
Q_DECLARE_METATYPE(QVideoFrame)
|
||||
Q_DECLARE_METATYPE(QtMultimediaKit::MetaData)
|
||||
|
||||
@@ -76,10 +76,6 @@
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qprocess.h>
|
||||
|
||||
#if defined(Q_WS_MAEMO_5)
|
||||
#include "camerabuttonlistener_maemo.h"
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
#include "camerabuttonlistener_meego.h"
|
||||
#endif
|
||||
@@ -145,22 +141,13 @@ CameraBinService::CameraBinService(const QString &service, QObject *parent):
|
||||
connect(m_metaDataControl, SIGNAL(metaDataChanged(QMap<QByteArray,QVariant>)),
|
||||
m_captureSession, SLOT(setMetaData(QMap<QByteArray,QVariant>)));
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
new CameraButtonListener(this);
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_MAEMO_5)
|
||||
//disable the system camera application
|
||||
QProcess::execute("/usr/sbin/dsmetool -k /usr/bin/camera-ui");
|
||||
#endif
|
||||
}
|
||||
|
||||
CameraBinService::~CameraBinService()
|
||||
{
|
||||
#if defined(Q_WS_MAEMO_5)
|
||||
//restore the system camera application
|
||||
QProcess::execute("/usr/sbin/dsmetool -U user -o /usr/bin/camera-ui");
|
||||
#endif
|
||||
}
|
||||
|
||||
QMediaControl *CameraBinService::requestControl(const char *name)
|
||||
|
||||
@@ -68,33 +68,6 @@
|
||||
//#define CAMERABIN_DEBUG 1
|
||||
#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v)))
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
#define FILENAME_PROPERTY "filename"
|
||||
#define MODE_PROPERTY "mode"
|
||||
#define MUTE_PROPERTY "mute"
|
||||
#define ZOOM_PROPERTY "zoom"
|
||||
#define IMAGE_PP_PROPERTY "imagepp"
|
||||
#define IMAGE_ENCODER_PROPERTY "imageenc"
|
||||
#define VIDEO_PP_PROPERTY "videopp"
|
||||
#define VIDEO_ENCODER_PROPERTY "videoenc"
|
||||
#define AUDIO_ENCODER_PROPERTY "audioenc"
|
||||
#define VIDEO_MUXER_PROPERTY "videomux"
|
||||
#define VIEWFINDER_SINK_PROPERTY "vfsink"
|
||||
#define VIDEO_SOURCE_PROPERTY "videosrc"
|
||||
#define AUDIO_SOURCE_PROPERTY "audiosrc"
|
||||
#define VIDEO_SOURCE_CAPS_PROPERTY "inputcaps"
|
||||
#define FILTER_CAPS_PROPERTY "filter-caps"
|
||||
#define PREVIEW_CAPS_PROPERTY "preview-caps"
|
||||
|
||||
#define IMAGE_DONE_SIGNAL "img-done"
|
||||
#define CAPTURE_START "user-start"
|
||||
#define CAPTURE_STOP "user-stop"
|
||||
#define CAPTURE_PAUSE "user-pause"
|
||||
#define SET_VIDEO_RESOLUTION_FPS "user-res-fps"
|
||||
#define SET_IMAGE_RESOLUTION "user-image-res"
|
||||
|
||||
#else
|
||||
|
||||
#define FILENAME_PROPERTY "filename"
|
||||
#define MODE_PROPERTY "mode"
|
||||
#define MUTE_PROPERTY "mute"
|
||||
@@ -118,7 +91,6 @@
|
||||
#define CAPTURE_PAUSE "capture-pause"
|
||||
#define SET_VIDEO_RESOLUTION_FPS "set-video-resolution-fps"
|
||||
#define SET_IMAGE_RESOLUTION "set-image-resolution"
|
||||
#endif
|
||||
|
||||
#define CAMERABIN_IMAGE_MODE 0
|
||||
#define CAMERABIN_VIDEO_MODE 1
|
||||
@@ -135,7 +107,7 @@
|
||||
|
||||
//using GST_STATE_READY for QCamera::LoadedState
|
||||
//doesn't work reliably at least with some webcams.
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
#define USE_READY_STATE_ON_LOADED
|
||||
#endif
|
||||
|
||||
@@ -228,11 +200,6 @@ GstPhotography *CameraBinSession::photography()
|
||||
|
||||
CameraBinSession::CameraRole CameraBinSession::cameraRole() const
|
||||
{
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
return m_inputDevice == QLatin1String("/dev/video1") ?
|
||||
FrontCamera : BackCamera;
|
||||
#endif
|
||||
|
||||
return BackCamera;
|
||||
}
|
||||
|
||||
@@ -475,7 +442,7 @@ QDir CameraBinSession::defaultDir(QCamera::CaptureMode mode) const
|
||||
{
|
||||
QStringList dirCandidates;
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
dirCandidates << QLatin1String("/home/user/MyDocs/DCIM");
|
||||
dirCandidates << QLatin1String("/home/user/MyDocs/");
|
||||
#endif
|
||||
@@ -1218,12 +1185,7 @@ QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate,
|
||||
QSize minSize = res.first();
|
||||
QSize maxSize = res.last();
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
if (mode == QCamera::CaptureVideo && cameraRole() == BackCamera)
|
||||
maxSize = QSize(848, 480);
|
||||
if (mode == QCamera::CaptureStillImage)
|
||||
minSize = QSize(640, 480);
|
||||
#elif defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
if (cameraRole() == FrontCamera && maxSize.width() > 640)
|
||||
maxSize = QSize(640, 480);
|
||||
else if (mode == QCamera::CaptureVideo && maxSize.width() > 1280)
|
||||
|
||||
@@ -49,22 +49,7 @@ CameraBinVideoEncoder::CameraBinVideoEncoder(CameraBinSession *session)
|
||||
:QVideoEncoderControl(session), m_session(session)
|
||||
{
|
||||
QList<QByteArray> codecCandidates;
|
||||
#if defined(Q_WS_MAEMO_5)
|
||||
codecCandidates << "video/mpeg4" << "video/h264" << "video/h263" << "video/theora"
|
||||
<< "video/mpeg2" << "video/mpeg1" << "video/mjpeg" << "video/VP8" << "video/h261";
|
||||
|
||||
m_elementNames["video/h264"] = "dsph264enc";
|
||||
m_elementNames["video/mpeg4"] = "dspmp4venc";
|
||||
m_elementNames["video/h263"] = "dsph263enc";
|
||||
m_elementNames["video/theora"] = "theoraenc";
|
||||
m_elementNames["video/mpeg2"] = "ffenc_mpeg2video";
|
||||
m_elementNames["video/mpeg1"] = "ffenc_mpeg1video";
|
||||
m_elementNames["video/mjpeg"] = "ffenc_mjpeg";
|
||||
m_elementNames["video/VP8"] = "vp8enc";
|
||||
m_elementNames["video/h261"] = "ffenc_h261";
|
||||
|
||||
m_codecOptions["video/mpeg4"] = QStringList() << "mode" << "keyframe-interval";
|
||||
#elif defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
codecCandidates << "video/mpeg4" << "video/h264" << "video/h263";
|
||||
|
||||
m_elementNames["video/h264"] = "dsph264enc";
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "camerabuttonlistener_maemo.h"
|
||||
|
||||
#include <QtDBus/qdbusconnection.h>
|
||||
#include <QtDBus/qdbusinterface.h>
|
||||
|
||||
#include <QtGui/qapplication.h>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
|
||||
|
||||
CameraButtonListener::CameraButtonListener(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_focusPressed(false),
|
||||
m_shutterPressed(false)
|
||||
{
|
||||
QDBusConnection::systemBus().connect(
|
||||
QString(),
|
||||
"/org/freedesktop/Hal/devices/platform_cam_launch",
|
||||
"org.freedesktop.Hal.Device",
|
||||
"PropertyModified",
|
||||
this,
|
||||
SLOT(updateShuterButtonState()));
|
||||
|
||||
QDBusConnection::systemBus().connect(
|
||||
QString(),
|
||||
"/org/freedesktop/Hal/devices/platform_cam_focus",
|
||||
"org.freedesktop.Hal.Device",
|
||||
"PropertyModified",
|
||||
this,
|
||||
SLOT(updateFocusButtonState()));
|
||||
}
|
||||
|
||||
|
||||
CameraButtonListener::~CameraButtonListener()
|
||||
{
|
||||
}
|
||||
|
||||
void CameraButtonListener::updateFocusButtonState()
|
||||
{
|
||||
QDBusInterface propertyInterface("org.freedesktop.Hal",
|
||||
"/org/freedesktop/Hal/devices/platform_cam_focus",
|
||||
"org.freedesktop.Hal.Device",
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
bool pressed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool();
|
||||
|
||||
if (m_focusPressed != pressed) {
|
||||
m_focusPressed = pressed;
|
||||
QWidget *window = QApplication::focusWidget();
|
||||
|
||||
if (window) {
|
||||
QApplication::postEvent(window,
|
||||
new QKeyEvent(pressed ? QEvent::KeyPress : QEvent::KeyRelease,
|
||||
0x01100021, //Qt::Key_CameraFocus since Qt 4.7.0
|
||||
Qt::NoModifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CameraButtonListener::updateShuterButtonState()
|
||||
{
|
||||
QDBusInterface propertyInterface("org.freedesktop.Hal",
|
||||
"/org/freedesktop/Hal/devices/platform_cam_launch",
|
||||
"org.freedesktop.Hal.Device",
|
||||
QDBusConnection::systemBus());
|
||||
|
||||
bool pressed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool();
|
||||
|
||||
if (m_shutterPressed != pressed) {
|
||||
m_shutterPressed = pressed;
|
||||
QWidget *window = QApplication::focusWidget();
|
||||
|
||||
if (window) {
|
||||
QApplication::postEvent(window,
|
||||
new QKeyEvent(pressed ? QEvent::KeyPress : QEvent::KeyRelease,
|
||||
0x01100020, //Qt::Key_Camera since Qt 4.7.0
|
||||
Qt::NoModifier));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef CAMERABUTTONLISTENER_MAEMO_H
|
||||
#define CAMERABUTTONLISTENER_MAEMO_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class CameraButtonListener : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CameraButtonListener(QObject *parent = 0);
|
||||
virtual ~CameraButtonListener();
|
||||
|
||||
private slots:
|
||||
void updateFocusButtonState();
|
||||
void updateShuterButtonState();
|
||||
|
||||
private:
|
||||
bool m_focusPressed;
|
||||
bool m_shutterPressed;
|
||||
};
|
||||
|
||||
#endif // CAMERABUTTONLISTENER_MAEMO_H
|
||||
@@ -26,13 +26,6 @@ PKGCONFIG += \
|
||||
maemo*:PKGCONFIG +=gstreamer-plugins-bad-0.10
|
||||
contains(gstreamer-appsrc_enabled, yes): PKGCONFIG += gstreamer-app-0.10
|
||||
|
||||
maemo5 {
|
||||
HEADERS += camerabuttonlistener_maemo.h
|
||||
SOURCES += camerabuttonlistener_maemo.cpp
|
||||
|
||||
QT += dbus
|
||||
}
|
||||
|
||||
maemo6 {
|
||||
HEADERS += camerabuttonlistener_meego.h
|
||||
SOURCES += camerabuttonlistener_meego.cpp
|
||||
@@ -76,7 +69,7 @@ SOURCES += \
|
||||
qgstutils.cpp
|
||||
|
||||
|
||||
!win32:!contains(QT_CONFIG,embedded):!mac:!symbian:!simulator:!contains(QT_CONFIG, qpa) {
|
||||
!win32:!contains(QT_CONFIG,embedded):!mac:!simulator:!contains(QT_CONFIG, qpa) {
|
||||
LIBS += -lXv -lX11 -lXext
|
||||
|
||||
HEADERS += \
|
||||
|
||||
@@ -52,9 +52,7 @@ QGstreamerAudioEncode::QGstreamerAudioEncode(QObject *parent)
|
||||
{
|
||||
QList<QByteArray> codecCandidates;
|
||||
|
||||
#if defined(Q_WS_MAEMO_5)
|
||||
codecCandidates << "audio/PCM"; //<< "audio/AMR" << "audio/AMR-WB" << "audio/speex";
|
||||
#elif defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
codecCandidates << "audio/AAC" << "audio/mpeg" << "audio/vorbis" << "audio/speex" << "audio/GSM"
|
||||
<< "audio/PCM" << "audio/AMR" << "audio/AMR-WB" << "audio/FLAC";
|
||||
#else
|
||||
@@ -62,7 +60,7 @@ QGstreamerAudioEncode::QGstreamerAudioEncode(QObject *parent)
|
||||
<< "audio/PCM" << "audio/AMR" << "audio/AMR-WB" << "audio/FLAC";
|
||||
#endif
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
m_elementNames["audio/AMR"] = "nokiaamrnbenc";
|
||||
m_elementNames["audio/AMR-WB"] = "nokiaamrwbenc";
|
||||
m_elementNames["audio/AAC"] = "nokiaaacenc";
|
||||
|
||||
@@ -202,12 +202,7 @@ GstElement *QGstreamerCaptureSession::buildAudioSrc()
|
||||
if (m_audioInputFactory)
|
||||
audioSrc = m_audioInputFactory->buildElement();
|
||||
else {
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
audioSrc = gst_element_factory_make("pulsesrc", "audio_src");
|
||||
#elif defined(QT_QWS_N810)
|
||||
audioSrc = gst_element_factory_make("dsppcmsrc", "audio_src");
|
||||
#else
|
||||
QString elementName = "alsasrc";
|
||||
QString device;
|
||||
|
||||
@@ -225,7 +220,6 @@ GstElement *QGstreamerCaptureSession::buildAudioSrc()
|
||||
audioSrc = gst_element_factory_make(elementName.toAscii().constData(), "audio_src");
|
||||
if (audioSrc && !device.isEmpty())
|
||||
g_object_set(G_OBJECT(audioSrc), "device", device.toLocal8Bit().constData(), NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!audioSrc) {
|
||||
|
||||
@@ -252,7 +252,7 @@ QDir QGstreamerRecorderControl::defaultDir() const
|
||||
{
|
||||
QStringList dirCandidates;
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
|
||||
#if defined(Q_WS_MAEMO_6)
|
||||
dirCandidates << QLatin1String("/home/user/MyDocs");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -76,11 +76,7 @@ QGstreamerV4L2Input::~QGstreamerV4L2Input()
|
||||
|
||||
GstElement *QGstreamerV4L2Input::buildElement()
|
||||
{
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
GstElement *camera = gst_element_factory_make("v4l2src", "camera_source");
|
||||
#else
|
||||
GstElement *camera = gst_element_factory_make("v4l2camsrc", "camera_source");
|
||||
#endif
|
||||
if (camera && !m_device.isEmpty() )
|
||||
g_object_set(G_OBJECT(camera), "device", m_device.constData(), NULL);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtGui/qdesktopservices.h>
|
||||
|
||||
#if defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) || (GST_VERSION_MICRO > 20)
|
||||
#if defined(Q_WS_MAEMO_6) || (GST_VERSION_MICRO > 20)
|
||||
#define USE_PLAYBIN2
|
||||
#endif
|
||||
|
||||
|
||||
@@ -104,10 +104,8 @@ void QGstreamerAudioInputEndpointSelector::update()
|
||||
{
|
||||
m_names.clear();
|
||||
m_descriptions.clear();
|
||||
#ifndef Q_WS_MAEMO_5
|
||||
updateAlsaDevices();
|
||||
updateOssDevices();
|
||||
#endif
|
||||
updatePulseDevices();
|
||||
if (m_names.size() > 0)
|
||||
m_audioInput = m_names.at(0);
|
||||
@@ -151,16 +149,11 @@ void QGstreamerAudioInputEndpointSelector::updateOssDevices()
|
||||
{
|
||||
QDir devDir("/dev");
|
||||
devDir.setFilter(QDir::System);
|
||||
#ifndef QT_QWS_N810
|
||||
QFileInfoList entries = devDir.entryInfoList(QStringList() << "dsp*");
|
||||
foreach(const QFileInfo& entryInfo, entries) {
|
||||
m_names.append(QLatin1String("oss:")+entryInfo.filePath());
|
||||
m_descriptions.append(QString("OSS device %1").arg(entryInfo.fileName()));
|
||||
}
|
||||
#else
|
||||
m_names.append("dsppcm");
|
||||
m_descriptions.append("PCM audio input");
|
||||
#endif
|
||||
}
|
||||
|
||||
void QGstreamerAudioInputEndpointSelector::updatePulseDevices()
|
||||
|
||||
@@ -178,12 +178,6 @@ void QGstreamerServicePlugin::updateDevices() const
|
||||
m_cameraDevices.clear();
|
||||
m_cameraDescriptions.clear();
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
m_cameraDevices << "/dev/video0" << "/dev/video1";
|
||||
m_cameraDescriptions << tr("Main Camera") << tr("Front Camera");
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAEMO_6
|
||||
m_cameraDevices << "primary" << "secondary";
|
||||
m_cameraDescriptions << tr("Main camera") << tr("Front camera");
|
||||
|
||||
@@ -132,11 +132,6 @@ void QGstreamerVideoWidgetControl::createVideoWidget()
|
||||
gst_element_set_state(m_videoSink, GST_STATE_NULL);
|
||||
|
||||
g_object_set(G_OBJECT(m_videoSink), "force-aspect-ratio", 1, (const char*)NULL);
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
//the overlay xvideo adapter fails to switch winId,
|
||||
//use "SGX Textured Video" adapter instead
|
||||
g_object_set(G_OBJECT(m_videoSink), "device", "1", NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -457,13 +457,7 @@ bool QX11VideoSurface::findPort()
|
||||
bool portFound = false;
|
||||
|
||||
if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) {
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
//the overlay xvideo adapter fails to switch winId,
|
||||
//prefer the "SGX Textured Video" adapter instead
|
||||
for (int i = count-1; i >= 0 && !portFound; --i) {
|
||||
#else
|
||||
for (unsigned int i = 0; i < count && !portFound; ++i) {
|
||||
#endif
|
||||
if (adaptors[i].type & XvImageMask) {
|
||||
m_portId = adaptors[i].base_id;
|
||||
|
||||
|
||||
@@ -11,13 +11,3 @@ DESTDIR = $$QT.multimediakit.plugins/$${PLUGIN_TYPE}
|
||||
HEADERS += qm3uhandler.h
|
||||
SOURCES += main.cpp \
|
||||
qm3uhandler.cpp
|
||||
symbian {
|
||||
TARGET.UID3 = 0x2002BFC7
|
||||
TARGET.CAPABILITY = ALL -TCB
|
||||
TARGET.EPOCALLOWDLLDATA = 1
|
||||
|
||||
#make a sis package from plugin + stub (plugin)
|
||||
pluginDep.sources = $${TARGET}.dll
|
||||
pluginDep.path = $${QT_PLUGINS_BASE_DIR}/$${PLUGIN_TYPE}
|
||||
DEPLOYMENT += pluginDep
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ win32 {
|
||||
SUBDIRS += audiocapture
|
||||
}
|
||||
|
||||
win32:!wince* {
|
||||
win32 {
|
||||
contains(directshow_enabled, yes): SUBDIRS += directshow
|
||||
}
|
||||
|
||||
simulator: SUBDIRS += simulator
|
||||
|
||||
unix:!mac:!symbian {
|
||||
unix:!mac {
|
||||
TMP_GST_LIBS = \
|
||||
gstreamer-0.10 >= 0.10.19 \
|
||||
gstreamer-base-0.10 >= 0.10.19 \
|
||||
@@ -42,5 +42,3 @@ unix:!mac:!symbian {
|
||||
mac:!simulator {
|
||||
SUBDIRS += audiocapture qt7
|
||||
}
|
||||
|
||||
symbian:SUBDIRS += symbian
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
include (../videooutput/videooutput.pri)
|
||||
|
||||
# Camera Service
|
||||
DEFINES += QMEDIA_SYMBIAN_CAMERA
|
||||
|
||||
# S60 3.1 platform
|
||||
contains(S60_VERSION, 3.1) {
|
||||
DEFINES += S60_31_PLATFORM
|
||||
DEFINES *= S60_3X_PLATFORM
|
||||
}
|
||||
|
||||
# S60 3.2 platform
|
||||
contains(S60_VERSION, 3.2) {
|
||||
DEFINES += S60_32_PLATFORM
|
||||
DEFINES *= S60_3X_PLATFORM
|
||||
}
|
||||
|
||||
# S60 5.0 platform
|
||||
!contains(DEFINES, S60_31_PLATFORM) {
|
||||
!contains(DEFINES, S60_32_PLATFORM) {
|
||||
!contains(DEFINES, SYMBIAN_3_PLATFORM) {
|
||||
DEFINES += S60_50_PLATFORM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Symbian 3 platform
|
||||
contains(DEFINES, VIDEOOUTPUT_GRAPHICS_SURFACES) {
|
||||
DEFINES += SYMBIAN_3_PLATFORM
|
||||
}
|
||||
|
||||
# AutoFocusing (CamAutoFocus) from ForumNokia example
|
||||
contains(symbian_camera_camautofocus_enabled, yes) {
|
||||
exists($${EPOCROOT}epoc32\\include\\CCamAutoFocus.h) {
|
||||
message ("CameraBE: Using S60 3.1 autofocusing")
|
||||
MMP_RULES += \
|
||||
"$${LITERAL_HASH}ifdef WINSCW" \
|
||||
"LIBRARY camautofocus.lib" \
|
||||
"$${LITERAL_HASH}else" \
|
||||
"STATICLIBRARY camautofocus_s.lib" \
|
||||
"$${LITERAL_HASH}endif // WINS" \
|
||||
"MACRO S60_CAM_AUTOFOCUS_SUPPORT"
|
||||
}
|
||||
}
|
||||
|
||||
# ECam AdvancedSettings
|
||||
contains(symbian_camera_ecamadvsettings_enabled, yes) {
|
||||
exists($${EPOCROOT}epoc32\\include\\ecamadvancedsettings.h) {
|
||||
MMP_RULES += \
|
||||
"$${LITERAL_HASH}ifndef WINSCW" \
|
||||
"LIBRARY ecamadvsettings.lib" \
|
||||
"MACRO USE_S60_32_ECAM_ADVANCED_SETTINGS_HEADER" \
|
||||
"$${LITERAL_HASH}endif"
|
||||
message("CameraBE: Using from S60 3.2 CCameraAdvancedSettings header")
|
||||
}
|
||||
exists($${EPOCROOT}epoc32\\include\\ecamadvsettings.h) {
|
||||
symbian:LIBS += -lecamadvsettings
|
||||
DEFINES += USE_S60_50_ECAM_ADVANCED_SETTINGS_HEADER
|
||||
message("CameraBE: Using CCameraAdvancedSettings header from S60 5.0 or later")
|
||||
}
|
||||
}
|
||||
|
||||
# DevVideo API Check (Requires both, DevVideoPlay and DevVideoRecord plugins):
|
||||
# DevVideoConstants has been problematic since not being included in SDK plugins
|
||||
# For S60 5.0 this has changed with plugin extension 1.1
|
||||
# But for S60 3.2 this is still a problem
|
||||
contains(symbian_camera_devvideorecord_enabled, yes) {
|
||||
exists($${EPOCROOT}epoc32\\include\\mmf\\devvideo\\devvideorecord.h) {
|
||||
exists($${EPOCROOT}epoc32\\include\\mmf\\devvideo\\devvideobase.h) {
|
||||
exists($${EPOCROOT}epoc32\\include\\mmf\\devvideo\\devvideoconstants.h) {
|
||||
symbian:LIBS += -ldevvideo
|
||||
DEFINES += S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
message("CameraBE: Devvideo API supported")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ECam Snapshot API:
|
||||
contains(symbian_camera_snapshot_enabled, yes) {
|
||||
exists($${EPOCROOT}epoc32\\include\\platform\\ecam\\camerasnapshot.h) {
|
||||
DEFINES += ECAM_PREVIEW_API
|
||||
message("CameraBE: Using CCameraSnapshot API")
|
||||
symbian:LIBS += -lecamsnapshot
|
||||
} else {
|
||||
message("CameraBE: Using custom snapshot proving methods")
|
||||
}
|
||||
} else {
|
||||
message("CameraBE: Using custom snapshot proving methods")
|
||||
}
|
||||
|
||||
# Libraries:
|
||||
symbian:LIBS += -lfbscli \
|
||||
-lmediaclientvideo \
|
||||
-lecam \
|
||||
-lbafl \
|
||||
-lPlatformEnv \
|
||||
-lcharconv \
|
||||
-lconvnames \
|
||||
-lgb2312_shared \
|
||||
-ljisx0201 \
|
||||
-ljisx0208 \
|
||||
-lmmfcontrollerframework \
|
||||
-lfbscli \
|
||||
-lefsrv \
|
||||
-lcone \
|
||||
-lws32 \
|
||||
-limageconversion
|
||||
|
||||
# Source:
|
||||
HEADERS += $$PWD/s60cameraconstants.h \
|
||||
$$PWD/s60cameralockscontrol.h \
|
||||
$$PWD/s60camerafocuscontrol.h \
|
||||
$$PWD/s60cameraexposurecontrol.h \
|
||||
$$PWD/s60cameraflashcontrol.h \
|
||||
$$PWD/s60cameracontrol.h \
|
||||
$$PWD/s60mediarecordercontrol.h \
|
||||
$$PWD/s60videocapturesession.h \
|
||||
$$PWD/s60imagecapturesession.h \
|
||||
$$PWD/s60mediacontainercontrol.h \
|
||||
$$PWD/s60videoencodercontrol.h \
|
||||
$$PWD/s60audioencodercontrol.h \
|
||||
$$PWD/s60cameraservice.h \
|
||||
$$PWD/s60cameraimageprocessingcontrol.h \
|
||||
$$PWD/s60cameraimagecapturecontrol.h \
|
||||
$$PWD/s60videodevicecontrol.h \
|
||||
$$PWD/s60imageencodercontrol.h \
|
||||
$$PWD/s60camerasettings.h \
|
||||
$$PWD/s60cameraengine.h \
|
||||
$$PWD/s60cameraviewfinderengine.h \
|
||||
$$PWD/s60cameraengineobserver.h \
|
||||
$$PWD/s60videorenderercontrol.h
|
||||
|
||||
SOURCES += $$PWD/s60cameralockscontrol.cpp \
|
||||
$$PWD/s60camerafocuscontrol.cpp \
|
||||
$$PWD/s60cameraexposurecontrol.cpp \
|
||||
$$PWD/s60cameraflashcontrol.cpp \
|
||||
$$PWD/s60cameracontrol.cpp \
|
||||
$$PWD/s60mediarecordercontrol.cpp \
|
||||
$$PWD/s60videocapturesession.cpp \
|
||||
$$PWD/s60imagecapturesession.cpp \
|
||||
$$PWD/s60mediacontainercontrol.cpp \
|
||||
$$PWD/s60videoencodercontrol.cpp \
|
||||
$$PWD/s60audioencodercontrol.cpp \
|
||||
$$PWD/s60cameraservice.cpp \
|
||||
$$PWD/s60cameraimageprocessingcontrol.cpp \
|
||||
$$PWD/s60cameraimagecapturecontrol.cpp \
|
||||
$$PWD/s60videodevicecontrol.cpp \
|
||||
$$PWD/s60imageencodercontrol.cpp \
|
||||
$$PWD/s60camerasettings.cpp \
|
||||
$$PWD/s60cameraengine.cpp \
|
||||
$$PWD/s60cameraviewfinderengine.cpp \
|
||||
$$PWD/s60videorenderercontrol.cpp
|
||||
|
||||
# End of file
|
||||
@@ -1,40 +0,0 @@
|
||||
######################################################################
|
||||
#
|
||||
# Mobility API project - Symbian Camera backend
|
||||
#
|
||||
######################################################################
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
|
||||
TARGET = $$qtLibraryTarget(qtmultimediakit_ecamengine)
|
||||
PLUGIN_TYPE = mediaservice
|
||||
include (../../../../common.pri)
|
||||
|
||||
CONFIG += mobility
|
||||
MOBILITY += multimedia
|
||||
|
||||
# Include here so that all defines are added here also
|
||||
include(camera_s60.pri)
|
||||
|
||||
DEPENDPATH += .
|
||||
|
||||
INCLUDEPATH += . \
|
||||
$${SOURCE_DIR}/include \
|
||||
$${SOURCE_DIR}/src/multimedia \
|
||||
$${SOURCE_DIR}/src/multimedia/audio \
|
||||
$${SOURCE_DIR}/src/multimedia/video \
|
||||
$${SOURCE_DIR}
|
||||
|
||||
HEADERS += s60cameraserviceplugin.h
|
||||
SOURCES += s60cameraserviceplugin.cpp
|
||||
|
||||
load(data_caging_paths)
|
||||
TARGET.EPOCALLOWDLLDATA = 1
|
||||
TARGET.UID3 = 0x2002BFC2
|
||||
TARGET.CAPABILITY = ALL -TCB
|
||||
|
||||
# Make a sis package from plugin + api + stub (plugin)
|
||||
pluginDep.sources = $${TARGET}.dll
|
||||
pluginDep.path = $${QT_PLUGINS_BASE_DIR}/$${PLUGIN_TYPE}
|
||||
DEPLOYMENT += pluginDep
|
||||
@@ -1,159 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60audioencodercontrol.h"
|
||||
#include "s60videocapturesession.h"
|
||||
|
||||
S60AudioEncoderControl::S60AudioEncoderControl(QObject *parent) :
|
||||
QAudioEncoderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60AudioEncoderControl::S60AudioEncoderControl(S60VideoCaptureSession *session, QObject *parent) :
|
||||
QAudioEncoderControl(parent)
|
||||
{
|
||||
m_session = session;
|
||||
}
|
||||
|
||||
S60AudioEncoderControl::~S60AudioEncoderControl()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList S60AudioEncoderControl::supportedAudioCodecs() const
|
||||
{
|
||||
return m_session->supportedAudioCaptureCodecs();
|
||||
}
|
||||
|
||||
QString S60AudioEncoderControl::codecDescription(const QString &codecName) const
|
||||
{
|
||||
// According to ForumNokia MMF camcorder plugin supports AAC, AMR and QCELP
|
||||
// QCELP is speech codec and can be discarded
|
||||
if (qstrcmp(codecName.toLocal8Bit().constData(), "audio/aac") == 0)
|
||||
return QLatin1String("Advanced Audio Coding");
|
||||
else if (qstrcmp(codecName.toLocal8Bit().constData(), "audio/amr") == 0)
|
||||
return QLatin1String("Adaptive Multi-Rate Audio Codec");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QStringList S60AudioEncoderControl::supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
// Possible settings: EncodingMode, Codec, BitRate, ChannelCount, SampleRate, Quality
|
||||
// Possible (codec specific) Options: None
|
||||
Q_UNUSED(codec);
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QVariant S60AudioEncoderControl::encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
// Possible settings: EncodingMode, Codec, BitRate, ChannelCount, SampleRate, Quality
|
||||
// Possible (codec specific) Options: None
|
||||
Q_UNUSED(codec);
|
||||
Q_UNUSED(name);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void S60AudioEncoderControl::setEncodingOption(
|
||||
const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
m_session->setError(KErrNotSupported, tr("Audio encoding option is not supported"));
|
||||
|
||||
// The audio settings can currently be set only using setAudioSettings() function
|
||||
Q_UNUSED(value)
|
||||
Q_UNUSED(codec)
|
||||
Q_UNUSED(name)
|
||||
}
|
||||
|
||||
QList<int> S60AudioEncoderControl::supportedSampleRates(
|
||||
const QAudioEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
return m_session->supportedSampleRates(settings, continuous);
|
||||
}
|
||||
|
||||
QAudioEncoderSettings S60AudioEncoderControl::audioSettings() const
|
||||
{
|
||||
QAudioEncoderSettings settings;
|
||||
m_session->audioEncoderSettings(settings);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
void S60AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
|
||||
{
|
||||
// Notify that settings have been implicitly set and there's no need to
|
||||
// initialize them in case camera is changed
|
||||
m_session->notifySettingsSet();
|
||||
|
||||
// Quality defines SampleRate/BitRate combination if either or both are missing
|
||||
if (settings.codec().isEmpty()) { // Empty settings
|
||||
m_session->setAudioCaptureQuality(settings.quality(), S60VideoCaptureSession::EOnlyAudioQuality);
|
||||
|
||||
} else if (settings.bitRate() == -1 && settings.sampleRate() != -1) { // Only SampleRate set
|
||||
m_session->setAudioCaptureCodec(settings.codec());
|
||||
m_session->setAudioChannelCount(settings.channelCount());
|
||||
m_session->setAudioSampleRate(settings.sampleRate());
|
||||
m_session->setAudioEncodingMode(settings.encodingMode());
|
||||
m_session->setAudioCaptureQuality(settings.quality(), S60VideoCaptureSession::EAudioQualityAndSampleRate);
|
||||
|
||||
} else if (settings.bitRate() != -1 && settings.sampleRate() == -1) { // Only BitRate set
|
||||
m_session->setAudioCaptureCodec(settings.codec());
|
||||
m_session->setAudioChannelCount(settings.channelCount());
|
||||
m_session->setAudioBitRate(settings.bitRate());
|
||||
m_session->setAudioEncodingMode(settings.encodingMode());
|
||||
m_session->setAudioCaptureQuality(settings.quality(), S60VideoCaptureSession::EAudioQualityAndBitRate);
|
||||
|
||||
} else if (settings.bitRate() == -1 && settings.sampleRate() == -1) { // No BitRate or SampleRate set
|
||||
m_session->setAudioCaptureCodec(settings.codec());
|
||||
m_session->setAudioChannelCount(settings.channelCount());
|
||||
m_session->setAudioEncodingMode(settings.encodingMode());
|
||||
m_session->setAudioCaptureQuality(settings.quality(), S60VideoCaptureSession::EOnlyAudioQuality);
|
||||
|
||||
} else { // Both SampleRate and BitRate set
|
||||
m_session->setAudioCaptureCodec(settings.codec());
|
||||
m_session->setAudioChannelCount(settings.channelCount());
|
||||
m_session->setAudioSampleRate(settings.sampleRate());
|
||||
m_session->setAudioBitRate(settings.bitRate());
|
||||
m_session->setAudioEncodingMode(settings.encodingMode());
|
||||
m_session->setAudioCaptureQuality(settings.quality(), S60VideoCaptureSession::ENoAudioQuality);
|
||||
}
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,90 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOENCODERCONTROL_H
|
||||
#define S60AUDIOENCODERCONTROL_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
|
||||
#include <qaudioencodercontrol.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60VideoCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for audio settings when recording video using QMediaRecorder.
|
||||
*/
|
||||
class S60AudioEncoderControl : public QAudioEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
S60AudioEncoderControl(QObject *parent = 0);
|
||||
S60AudioEncoderControl(S60VideoCaptureSession *session, QObject *parent = 0);
|
||||
virtual ~S60AudioEncoderControl();
|
||||
|
||||
public: // QAudioEncoderControl
|
||||
|
||||
// Audio Codec
|
||||
QStringList supportedAudioCodecs() const;
|
||||
QString codecDescription(const QString &codecName) const;
|
||||
|
||||
// Sample Rate
|
||||
QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = 0) const;
|
||||
|
||||
// Audio Settings
|
||||
QAudioEncoderSettings audioSettings() const;
|
||||
void setAudioSettings(const QAudioEncoderSettings &settings);
|
||||
|
||||
// Encoding Option
|
||||
QStringList supportedEncodingOptions(const QString &codec) const;
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const;
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60VideoCaptureSession* m_session;
|
||||
};
|
||||
|
||||
#endif // S60AUDIOENCODERCONTROL_H
|
||||
@@ -1,257 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERACONSTANTS_H
|
||||
#define S60CAMERACONSTANTS_H
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// GENERAL SETTINGS
|
||||
|
||||
#define KDefaultCameraDevice 0
|
||||
#define KECamCameraPriority 0
|
||||
#define KInactivityTimerTimeout 30000 // msec
|
||||
#define KSymbianFineResolutionFactor 100.0
|
||||
#define KDefaultOpticalZoom 1.0
|
||||
#define KDefaultDigitalZoom 1.0
|
||||
#define KSmoothZoomStep 1
|
||||
#define KDefaultFocusMode QCameraFocus::AutoFocus
|
||||
|
||||
#define KDefaultViewfinderSize QSize(320,240)
|
||||
#define KDefaultSizePreview_Normal TSize(640,480)
|
||||
#define KDefaultSizePreview_Wide TSize(640,360)
|
||||
#define KDefaultSizePreview_CIF TSize(352,288)
|
||||
#define KDefaultSizePreview_PAL TSize(640,512)
|
||||
#define KDefaultSizePreview_NTSC TSize(640,426)
|
||||
#define KDefaultFormatPreview CCamera::EFormatFbsBitmapColor16MU
|
||||
#define KViewfinderFrameRate 30
|
||||
#define KMaxVFErrorsSignalled 3
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// IMAGE SETTINGS
|
||||
|
||||
#define KDefaultImagePath QLatin1String("c:\\Data\\Images")
|
||||
#define KDefaultImageFileName QLatin1String("image.jpg")
|
||||
#define KDefaultImageCodec QLatin1String("image/jpeg")
|
||||
#define KDefaultImageFormatPrimaryCam CCamera::EFormatExif
|
||||
#ifdef SYMBIAN_3_PLATFORM
|
||||
#define KDefaultImageFormatSecondaryCam CCamera::EFormatExif
|
||||
#define KDefaultImageResolution QSize(3264, 2448)
|
||||
#else // Pre-Symbian3 Platforms
|
||||
#define KDefaultImageFormatSecondaryCam CCamera::EFormatFbsBitmapColor64K
|
||||
#define KDefaultImageResolution QSize(2048, 1536)
|
||||
#endif // SYMBIAN_3_PLATFORM
|
||||
#define KSymbianImageQualityCoefficient 25
|
||||
// This must be divisible by 4 and creater or equal to 8
|
||||
#define KSnapshotDownScaleFactor 8
|
||||
#define KSnapshotMinWidth 640
|
||||
#define KSnapshotMinHeight 360
|
||||
#define KJpegQualityVeryLow 40
|
||||
#define KJpegQualityLow 50
|
||||
#define KJpegQualityNormal 75
|
||||
#define KJpegQualityHigh 85
|
||||
#define KJpegQualityVeryHigh 95
|
||||
#define KDefaultImageQuality KJpegQualityHigh
|
||||
|
||||
//=============================================================================
|
||||
|
||||
// VIDEO SETTINGS
|
||||
|
||||
// ================
|
||||
// General settings
|
||||
// ================
|
||||
|
||||
// Dummy file name to execute CVideoRecorderUtility::OpenFileL() without
|
||||
// knowing the actual outputLocation. This is needed to be able to query/set
|
||||
// supported video settings.
|
||||
_LIT(KDummyVideoFile, "c:\\data\\temp");
|
||||
|
||||
// Default container MIME type
|
||||
#define KMimeTypeDefaultContainer QLatin1String("video/mp4")
|
||||
#define KDefaultVideoPath QLatin1String("c:\\Data\\Videos")
|
||||
#define KDefaultVideoFileName QLatin1String("video.mp4")
|
||||
#define KDurationChangedInterval 1000 // 1 second
|
||||
|
||||
// ==============
|
||||
// Audio Settings
|
||||
// ==============
|
||||
|
||||
// Default audio codec MIME type
|
||||
#define KMimeTypeDefaultAudioCodec QLatin1String("audio/aac")
|
||||
|
||||
// Default audio settings for video recording
|
||||
#define KDefaultChannelCount -1 // Not Supported on Symbian
|
||||
#define KDefaultBitRate 32000 // 32kbps
|
||||
#define KDefaultSampleRate -1 // Not Supported on Symbian
|
||||
|
||||
// ==============
|
||||
// Video Settings
|
||||
// ==============
|
||||
|
||||
// Default video codec MIME type
|
||||
#ifdef SYMBIAN_3_PLATFORM
|
||||
// H.264: BaselineProfile Level 3.1, Max resolution: 1280x720
|
||||
#define KMimeTypeDefaultVideoCodec QLatin1String("video/H264; profile-level-id=42801F")
|
||||
#else
|
||||
// MPEG-4: Simple Profile, Level 4, Max resolution: 640x480
|
||||
#define KMimeTypeDefaultVideoCodec QLatin1String("video/mp4v-es; profile-level-id=4")
|
||||
#endif
|
||||
|
||||
// Maximum resolutions for encoder MIME Types
|
||||
// H.263
|
||||
#define KResH263 QSize(176,144);
|
||||
#define KResH263_Profile0 QSize(176,144);
|
||||
#define KResH263_Profile0_Level10 QSize(176,144);
|
||||
#define KResH263_Profile0_Level20 QSize(352,288);
|
||||
#define KResH263_Profile0_Level30 QSize(352,288);
|
||||
#define KResH263_Profile0_Level40 QSize(352,288);
|
||||
#define KResH263_Profile0_Level45 QSize(176,144);
|
||||
#define KResH263_Profile0_Level50 QSize(352,288);
|
||||
#define KResH263_Profile3 QSize(176,144);
|
||||
// MPEG-4
|
||||
#define KResMPEG4 QSize(176,144);
|
||||
#define KResMPEG4_PLID_1 QSize(176,144);
|
||||
#define KResMPEG4_PLID_2 QSize(352,288);
|
||||
#define KResMPEG4_PLID_3 QSize(352,288);
|
||||
#define KResMPEG4_PLID_4 QSize(640,480);
|
||||
#define KResMPEG4_PLID_5 QSize(720,576);
|
||||
#define KResMPEG4_PLID_6 QSize(1280,720);
|
||||
#define KResMPEG4_PLID_8 QSize(176,144);
|
||||
#define KResMPEG4_PLID_9 QSize(176,144);
|
||||
// H.264 (Baseline Profile, same resolutions apply to Main and High Profile)
|
||||
#define KResH264 QSize(176,144);
|
||||
#define KResH264_PLID_42800A QSize(176,144);
|
||||
#define KResH264_PLID_42900B QSize(176,144);
|
||||
#define KResH264_PLID_42800B QSize(352,288);
|
||||
#define KResH264_PLID_42800C QSize(352,288);
|
||||
#define KResH264_PLID_42800D QSize(352,288);
|
||||
#define KResH264_PLID_428014 QSize(352,288);
|
||||
#define KResH264_PLID_428015 QSize(352,288);
|
||||
#define KResH264_PLID_428016 QSize(640,480);
|
||||
#define KResH264_PLID_42801E QSize(640,480);
|
||||
#define KResH264_PLID_42801F QSize(1280,720);
|
||||
#define KResH264_PLID_428020 QSize(1280,720);
|
||||
#define KResH264_PLID_428028 QSize(1920,1080);
|
||||
|
||||
// Maximum framerates for encoder MIME Types
|
||||
// H.263
|
||||
#define KFrR_H263 qreal(15);
|
||||
#define KFrR_H263_Profile0 qreal(15);
|
||||
#define KFrR_H263_Profile0_Level10 qreal(15);
|
||||
#define KFrR_H263_Profile0_Level20 qreal(15);
|
||||
#define KFrR_H263_Profile0_Level30 qreal(30);
|
||||
#define KFrR_H263_Profile0_Level40 qreal(30);
|
||||
#define KFrR_H263_Profile0_Level45 qreal(15);
|
||||
#define KFrR_H263_Profile0_Level50 qreal(15);
|
||||
#define KFrR_H263_Profile3 qreal(15);
|
||||
// MPEG-4
|
||||
#define KFrR_MPEG4 qreal(15);
|
||||
#define KFrR_MPEG4_PLID_1 qreal(15);
|
||||
#define KFrR_MPEG4_PLID_2 qreal(15);
|
||||
#define KFrR_MPEG4_PLID_3 qreal(30);
|
||||
// This is a workaround for a known platform bug
|
||||
#if (defined(S60_31_PLATFORM) | defined(S60_32_PLATFORM))
|
||||
#define KFrR_MPEG4_PLID_4 qreal(15);
|
||||
#else // All other platforms
|
||||
#define KFrR_MPEG4_PLID_4 qreal(30);
|
||||
#endif // S60 3.1 or 3.2
|
||||
#define KFrR_MPEG4_PLID_5 qreal(30);
|
||||
#define KFrR_MPEG4_PLID_6 qreal(30);
|
||||
#define KFrR_MPEG4_PLID_8 qreal(15);
|
||||
#define KFrR_MPEG4_PLID_9 qreal(15);
|
||||
// H.264 (Baseline Profile, same framerates apply to Main and High Profile)
|
||||
#define KFrR_H264 qreal(15);
|
||||
#define KFrR_H264_PLID_42800A qreal(15);
|
||||
#define KFrR_H264_PLID_42900B qreal(15);
|
||||
#define KFrR_H264_PLID_42800B qreal(7.5);
|
||||
#define KFrR_H264_PLID_42800C qreal(15);
|
||||
#define KFrR_H264_PLID_42800D qreal(30);
|
||||
#define KFrR_H264_PLID_428014 qreal(30);
|
||||
#define KFrR_H264_PLID_428015 qreal(50);
|
||||
#define KFrR_H264_PLID_428016 qreal(16.9);
|
||||
#define KFrR_H264_PLID_42801E qreal(33.8);
|
||||
#define KFrR_H264_PLID_42801F qreal(30);
|
||||
#define KFrR_H264_PLID_428020 qreal(60);
|
||||
#define KFrR_H264_PLID_428028 qreal(30);
|
||||
|
||||
// Maximum bitrates for encoder MIME Types
|
||||
// H.263
|
||||
#define KBiR_H263 int(64000);
|
||||
#define KBiR_H263_Profile0 int(64000);
|
||||
#define KBiR_H263_Profile0_Level10 int(64000);
|
||||
#define KBiR_H263_Profile0_Level20 int(128000);
|
||||
#define KBiR_H263_Profile0_Level30 int(384000);
|
||||
#define KBiR_H263_Profile0_Level40 int(2048000);
|
||||
#define KBiR_H263_Profile0_Level45 int(128000);
|
||||
#define KBiR_H263_Profile0_Level50 int(4096000);
|
||||
#define KBiR_H263_Profile3 int(64000);
|
||||
// MPEG-4
|
||||
#define KBiR_MPEG4 int(64000);
|
||||
#define KBiR_MPEG4_PLID_1 int(64000);
|
||||
#define KBiR_MPEG4_PLID_2 int(128000);
|
||||
#define KBiR_MPEG4_PLID_3 int(384000);
|
||||
// This is a workaround for a known platform bug
|
||||
#if (defined(S60_31_PLATFORM) | defined(S60_32_PLATFORM))
|
||||
#define KBiR_MPEG4_PLID_4 int(2000000);
|
||||
#else // All other platforms
|
||||
#define KBiR_MPEG4_PLID_4 int(4000000);
|
||||
#endif // S60 3.1 or 3.2
|
||||
#define KBiR_MPEG4_PLID_5 int(8000000);
|
||||
#define KBiR_MPEG4_PLID_6 int(12000000);
|
||||
#define KBiR_MPEG4_PLID_8 int(64000);
|
||||
#define KBiR_MPEG4_PLID_9 int(128000);
|
||||
// H.264 (Baseline Profile, same bitrates apply to Main and High Profile)
|
||||
#define KBiR_H264 int(64000);
|
||||
#define KBiR_H264_PLID_42800A int(64000);
|
||||
#define KBiR_H264_PLID_42900B int(128000);
|
||||
#define KBiR_H264_PLID_42800B int(192000);
|
||||
#define KBiR_H264_PLID_42800C int(384000);
|
||||
#define KBiR_H264_PLID_42800D int(768000);
|
||||
#define KBiR_H264_PLID_428014 int(2000000);
|
||||
#define KBiR_H264_PLID_428015 int(4000000);
|
||||
#define KBiR_H264_PLID_428016 int(4000000);
|
||||
#define KBiR_H264_PLID_42801E int(10000000);
|
||||
#define KBiR_H264_PLID_42801F int(14000000);
|
||||
#define KBiR_H264_PLID_428020 int(20000000);
|
||||
#define KBiR_H264_PLID_428028 int(20000000);
|
||||
|
||||
#endif // S60CAMERACONSTANTS_H
|
||||
@@ -1,983 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QTimer>
|
||||
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60cameraengine.h"
|
||||
#include "s60cameracontrol.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
#include "s60videowidgetcontrol.h"
|
||||
#include "s60cameraviewfinderengine.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
S60CameraControl::S60CameraControl(QObject *parent) :
|
||||
QCameraControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraControl::S60CameraControl(S60VideoCaptureSession *videosession,
|
||||
S60ImageCaptureSession *imagesession,
|
||||
QObject *parent):
|
||||
QCameraControl(parent),
|
||||
m_cameraEngine(0),
|
||||
m_viewfinderEngine(0),
|
||||
m_imageSession(0),
|
||||
m_videoSession(0),
|
||||
m_advancedSettings(0),
|
||||
m_videoOutput(0),
|
||||
m_inactivityTimer(0),
|
||||
m_captureMode(QCamera::CaptureStillImage), // Default CaptureMode
|
||||
m_requestedCaptureMode(QCamera::CaptureStillImage),
|
||||
m_settingCaptureModeInternally(false),
|
||||
m_internalState(QCamera::UnloadedStatus), // Default Status
|
||||
m_requestedState(QCamera::UnloadedState), // Default State
|
||||
m_deviceIndex(KDefaultCameraDevice),
|
||||
m_error(KErrNone),
|
||||
m_changeCaptureModeWhenReady(false),
|
||||
m_rotateCameraWhenReady(false),
|
||||
m_videoCaptureState(S60VideoCaptureSession::ENotInitialized)
|
||||
{
|
||||
m_videoSession = videosession;
|
||||
m_imageSession = imagesession;
|
||||
|
||||
m_inactivityTimer = new QTimer;
|
||||
if (m_inactivityTimer)
|
||||
m_inactivityTimer->setSingleShot(true);
|
||||
|
||||
TRAPD(err, m_cameraEngine = CCameraEngine::NewL(m_deviceIndex, KECamCameraPriority, this));
|
||||
if (err) {
|
||||
m_error = err;
|
||||
if (err == KErrPermissionDenied)
|
||||
qWarning("Failed to create camera. Possibly missing capabilities.");
|
||||
else
|
||||
qWarning("Failed to create camera.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_viewfinderEngine = new S60CameraViewfinderEngine(this, m_cameraEngine, this);
|
||||
if (m_viewfinderEngine == 0) {
|
||||
m_error = KErrNoMemory;
|
||||
qWarning("Failed to create viewfinder engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Connect signals
|
||||
connect(m_inactivityTimer, SIGNAL(timeout()), this, SLOT(toStandByStatus()));
|
||||
connect(this, SIGNAL(statusChanged(QCamera::Status)),
|
||||
m_imageSession, SLOT(cameraStatusChanged(QCamera::Status)));
|
||||
connect(this, SIGNAL(statusChanged(QCamera::Status)),
|
||||
m_videoSession, SLOT(cameraStatusChanged(QCamera::Status)));
|
||||
connect(m_videoSession, SIGNAL(stateChanged(S60VideoCaptureSession::TVideoCaptureState)),
|
||||
this, SLOT(videoStateChanged(S60VideoCaptureSession::TVideoCaptureState)));
|
||||
connect(m_imageSession, SIGNAL(advancedSettingChanged()), this, SLOT(advancedSettingsCreated()));
|
||||
connect(this, SIGNAL(cameraReadyChanged(bool)), m_imageSession, SIGNAL(readyForCaptureChanged(bool)));
|
||||
connect(m_viewfinderEngine, SIGNAL(error(int, const QString&)), this, SIGNAL(error(int,const QString&)));
|
||||
connect(m_imageSession, SIGNAL(cameraError(int, const QString&)), this, SIGNAL(error(int, const QString&)));
|
||||
connect(m_imageSession, SIGNAL(captureSizeChanged(const QSize&)),
|
||||
m_viewfinderEngine, SLOT(handleContentAspectRatioChange(const QSize&)));
|
||||
connect(m_videoSession, SIGNAL(captureSizeChanged(const QSize&)),
|
||||
m_viewfinderEngine, SLOT(handleContentAspectRatioChange(const QSize&)));
|
||||
|
||||
setCameraHandles();
|
||||
}
|
||||
|
||||
S60CameraControl::~S60CameraControl()
|
||||
{
|
||||
unloadCamera();
|
||||
|
||||
if (m_viewfinderEngine) {
|
||||
delete m_viewfinderEngine;
|
||||
m_viewfinderEngine = 0;
|
||||
}
|
||||
|
||||
// Make sure AdvancedSettings are destructed
|
||||
m_imageSession->deleteAdvancedSettings();
|
||||
|
||||
if (m_cameraEngine) {
|
||||
delete m_cameraEngine;
|
||||
m_cameraEngine = 0;
|
||||
}
|
||||
|
||||
if (m_inactivityTimer) {
|
||||
delete m_inactivityTimer;
|
||||
m_inactivityTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraControl::setState(QCamera::State state)
|
||||
{
|
||||
if (m_error) { // Most probably failure in contructor
|
||||
setError(m_error, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_requestedState == state)
|
||||
return;
|
||||
|
||||
if (m_inactivityTimer->isActive())
|
||||
m_inactivityTimer->stop();
|
||||
|
||||
// Save the target state
|
||||
m_requestedState = state;
|
||||
emit stateChanged(m_requestedState);
|
||||
|
||||
switch (state) {
|
||||
case QCamera::UnloadedState: // To UnloadedState - Release resources
|
||||
switch (m_internalState) {
|
||||
case QCamera::UnloadedStatus:
|
||||
// Do nothing
|
||||
break;
|
||||
case QCamera::LoadingStatus:
|
||||
case QCamera::StartingStatus:
|
||||
// Release resources when ready (setting state handles this)
|
||||
return;
|
||||
case QCamera::LoadedStatus:
|
||||
case QCamera::StandbyStatus:
|
||||
// Unload
|
||||
unloadCamera();
|
||||
break;
|
||||
case QCamera::ActiveStatus:
|
||||
// Stop and Unload
|
||||
stopCamera();
|
||||
unloadCamera();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unrecognized internal state (Status)
|
||||
setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case QCamera::LoadedState: // To LoadedState - Reserve resources OR Stop ViewFinder and Cancel Capture
|
||||
switch (m_internalState) {
|
||||
case QCamera::UnloadedStatus:
|
||||
case QCamera::StandbyStatus:
|
||||
// Load
|
||||
loadCamera();
|
||||
break;
|
||||
case QCamera::LoadingStatus:
|
||||
// Discard, already moving to LoadedStatus
|
||||
return;
|
||||
case QCamera::StartingStatus:
|
||||
// Stop when ready (setting state handles this)
|
||||
return;
|
||||
case QCamera::LoadedStatus:
|
||||
m_inactivityTimer->start(KInactivityTimerTimeout);
|
||||
break;
|
||||
case QCamera::ActiveStatus:
|
||||
// Stop
|
||||
stopCamera();
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unregocnized internal state (Status)
|
||||
setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case QCamera::ActiveState: // To ActiveState - (Reserve Resources and) Start ViewFinder
|
||||
switch (m_internalState) {
|
||||
case QCamera::UnloadedStatus:
|
||||
case QCamera::StandbyStatus:
|
||||
// Load and Start (setting state handles starting)
|
||||
loadCamera();
|
||||
break;
|
||||
case QCamera::LoadingStatus:
|
||||
// Start when loaded (setting state handles this)
|
||||
break;
|
||||
case QCamera::StartingStatus:
|
||||
// Discard, already moving to ActiveStatus
|
||||
return;
|
||||
case QCamera::LoadedStatus:
|
||||
// Start
|
||||
startCamera();
|
||||
break;
|
||||
case QCamera::ActiveStatus:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unregocnized internal state (Status)
|
||||
setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
setError(KErrNotSupported, tr("Requested state is not supported."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QCamera::State S60CameraControl::state() const
|
||||
{
|
||||
return m_requestedState;
|
||||
}
|
||||
|
||||
QCamera::Status S60CameraControl::status() const
|
||||
{
|
||||
return m_internalState;
|
||||
}
|
||||
|
||||
QCamera::CaptureMode S60CameraControl::captureMode() const
|
||||
{
|
||||
return m_captureMode;
|
||||
}
|
||||
|
||||
void S60CameraControl::setCaptureMode(QCamera::CaptureMode mode)
|
||||
{
|
||||
if (m_error) { // Most probably failure in contructor
|
||||
setError(m_error, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_captureMode == mode)
|
||||
return;
|
||||
|
||||
// Setting CaptureMode Internally or Externally (Client)
|
||||
if (!m_settingCaptureModeInternally) {
|
||||
// Save the requested mode
|
||||
m_requestedCaptureMode = mode;
|
||||
|
||||
// CaptureMode change pending (backend busy), wait
|
||||
if (m_changeCaptureModeWhenReady)
|
||||
return;
|
||||
} else {
|
||||
m_changeCaptureModeWhenReady = false; // Reset
|
||||
}
|
||||
m_settingCaptureModeInternally = false; // Reset
|
||||
|
||||
if (!isCaptureModeSupported(mode)) {
|
||||
setError(KErrNotSupported, tr("Requested capture mode is not supported."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_inactivityTimer->isActive())
|
||||
m_inactivityTimer->stop();
|
||||
|
||||
switch (m_internalState) {
|
||||
case QCamera::UnloadedStatus:
|
||||
case QCamera::LoadedStatus:
|
||||
case QCamera::StandbyStatus:
|
||||
switch (mode) {
|
||||
case QCamera::CaptureStillImage:
|
||||
m_videoSession->releaseVideoRecording();
|
||||
m_captureMode = QCamera::CaptureStillImage;
|
||||
if (m_internalState == QCamera::LoadedStatus)
|
||||
m_inactivityTimer->start(KInactivityTimerTimeout);
|
||||
else if (m_internalState == QCamera::StandbyStatus)
|
||||
loadCamera();
|
||||
break;
|
||||
case QCamera::CaptureVideo:
|
||||
m_imageSession->releaseImageCapture();
|
||||
m_captureMode = QCamera::CaptureVideo;
|
||||
if (m_internalState == QCamera::LoadedStatus) {
|
||||
// Revet InternalState as we need to wait for the video
|
||||
// side initialization to complete
|
||||
m_internalState = QCamera::LoadingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
int prepareSuccess = m_videoSession->initializeVideoRecording();
|
||||
setError(prepareSuccess, tr("Loading video capture failed."));
|
||||
} else if (m_internalState == QCamera::StandbyStatus)
|
||||
loadCamera();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case QCamera::LoadingStatus:
|
||||
case QCamera::StartingStatus:
|
||||
m_changeCaptureModeWhenReady = true;
|
||||
return;
|
||||
case QCamera::ActiveStatus:
|
||||
// Stop, Change Mode and Start again
|
||||
stopCamera();
|
||||
switch (mode) {
|
||||
case QCamera::CaptureStillImage:
|
||||
m_videoSession->releaseVideoRecording();
|
||||
m_captureMode = QCamera::CaptureStillImage;
|
||||
startCamera();
|
||||
break;
|
||||
case QCamera::CaptureVideo:
|
||||
m_imageSession->releaseImageCapture();
|
||||
m_captureMode = QCamera::CaptureVideo;
|
||||
// Revet InternalState as we need to wait for the video
|
||||
// side initialization to complete
|
||||
m_internalState = QCamera::LoadingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
int prepareSuccess = m_videoSession->initializeVideoRecording();
|
||||
setError(prepareSuccess, tr("Loading video recorder failed."));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unregocnized internal state (Status)
|
||||
setError(KErrNotSupported, tr("Requested capture mode is not supported."));
|
||||
break;
|
||||
}
|
||||
|
||||
emit captureModeChanged(mode);
|
||||
}
|
||||
|
||||
bool S60CameraControl::isCaptureModeSupported(QCamera::CaptureMode mode) const
|
||||
{
|
||||
switch (mode) {
|
||||
case QCamera::CaptureStillImage:
|
||||
return true;
|
||||
case QCamera::CaptureVideo:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool S60CameraControl::canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const
|
||||
{
|
||||
Q_UNUSED(status);
|
||||
|
||||
bool returnValue = false;
|
||||
|
||||
switch (changeType) {
|
||||
case QCameraControl::CaptureMode:
|
||||
case QCameraControl::VideoEncodingSettings:
|
||||
case QCameraControl::ImageEncodingSettings:
|
||||
returnValue = true;
|
||||
break;
|
||||
|
||||
case QCameraControl::Viewfinder:
|
||||
returnValue = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
// Safer to revert state before the unknown operation
|
||||
returnValue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void S60CameraControl::setVideoOutput(QObject *output,
|
||||
S60CameraViewfinderEngine::ViewfinderOutputType type)
|
||||
{
|
||||
if (!m_viewfinderEngine) {
|
||||
setError(KErrGeneral, tr("Failed to set viewfinder"));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case S60CameraViewfinderEngine::OutputTypeVideoWidget:
|
||||
m_viewfinderEngine->setVideoWidgetControl(output);
|
||||
break;
|
||||
case S60CameraViewfinderEngine::OutputTypeRenderer:
|
||||
m_viewfinderEngine->setVideoRendererControl(output);
|
||||
break;
|
||||
case S60CameraViewfinderEngine::OutputTypeVideoWindow:
|
||||
m_viewfinderEngine->setVideoWindowControl(output);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraControl::releaseVideoOutput(const S60CameraViewfinderEngine::ViewfinderOutputType type)
|
||||
{
|
||||
m_viewfinderEngine->releaseControl(type);
|
||||
}
|
||||
|
||||
void S60CameraControl::loadCamera()
|
||||
{
|
||||
if (m_internalState < QCamera::LoadingStatus) {
|
||||
m_internalState = QCamera::LoadingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
} else if (m_internalState == QCamera::LoadedStatus
|
||||
|| m_internalState >= QCamera::StartingStatus) {
|
||||
// Nothing to load (already loaded)
|
||||
return;
|
||||
}
|
||||
// Status = Loading or Standby
|
||||
|
||||
m_cameraEngine->ReserveAndPowerOn();
|
||||
|
||||
// Completion notified in MceoCameraReady()
|
||||
}
|
||||
|
||||
void S60CameraControl::unloadCamera()
|
||||
{
|
||||
if (m_internalState > QCamera::LoadingStatus) {
|
||||
m_internalState = QCamera::LoadingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
} else if (m_internalState < QCamera::LoadingStatus) {
|
||||
// Nothing to unload
|
||||
return;
|
||||
}
|
||||
// Status = Loading
|
||||
|
||||
if (m_inactivityTimer->isActive())
|
||||
m_inactivityTimer->stop();
|
||||
|
||||
m_cameraEngine->ReleaseAndPowerOff();
|
||||
|
||||
m_internalState = QCamera::UnloadedStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
|
||||
void S60CameraControl::startCamera()
|
||||
{
|
||||
if (m_internalState < QCamera::StartingStatus) {
|
||||
m_internalState = QCamera::StartingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
} else if (m_internalState > QCamera::StartingStatus) {
|
||||
// Nothing to start (already started)
|
||||
return;
|
||||
}
|
||||
// Status = Starting
|
||||
|
||||
if (m_inactivityTimer->isActive())
|
||||
m_inactivityTimer->stop();
|
||||
|
||||
if (m_viewfinderEngine)
|
||||
m_viewfinderEngine->startViewfinder();
|
||||
else
|
||||
setError(KErrGeneral, tr("Failed to start viewfinder."));
|
||||
|
||||
m_internalState = QCamera::ActiveStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
|
||||
emit cameraReadyChanged(true);
|
||||
|
||||
#ifdef Q_CC_NOKIAX86 // Emulator
|
||||
MceoCameraReady(); // Signal that we are ready
|
||||
#endif
|
||||
}
|
||||
|
||||
void S60CameraControl::stopCamera()
|
||||
{
|
||||
if (m_internalState > QCamera::StartingStatus) {
|
||||
m_internalState = QCamera::StartingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
} else if (m_internalState < QCamera::StartingStatus) {
|
||||
// Nothing to stop
|
||||
return;
|
||||
}
|
||||
// Status = Starting
|
||||
|
||||
// Cancel ongoing operations if any
|
||||
m_imageSession->cancelCapture();
|
||||
m_videoSession->stopRecording();
|
||||
|
||||
emit cameraReadyChanged(false);
|
||||
if (m_viewfinderEngine)
|
||||
m_viewfinderEngine->stopViewfinder();
|
||||
else
|
||||
setError(KErrGeneral, tr("Failed to stop viewfinder."));
|
||||
|
||||
m_internalState = QCamera::LoadedStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
|
||||
m_inactivityTimer->start(KInactivityTimerTimeout);
|
||||
}
|
||||
|
||||
void S60CameraControl::videoStateChanged(const S60VideoCaptureSession::TVideoCaptureState state)
|
||||
{
|
||||
// Save video state
|
||||
m_videoCaptureState = state;
|
||||
|
||||
if (m_rotateCameraWhenReady) {
|
||||
if (m_videoCaptureState != S60VideoCaptureSession::ERecording &&
|
||||
m_videoCaptureState != S60VideoCaptureSession::EPaused)
|
||||
resetCameraOrientation();
|
||||
}
|
||||
|
||||
// If video recording was stopped, video state reverts back to
|
||||
// Initializing. In that case revert also Camera status to notify that
|
||||
// video initialization needs to be completed.
|
||||
if (state == S60VideoCaptureSession::EInitializing) {
|
||||
if (m_internalState > QCamera::LoadingStatus) {
|
||||
m_internalState = QCamera::LoadingStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
|
||||
// Handle video initialization completion
|
||||
} else if (state == S60VideoCaptureSession::EInitialized) {
|
||||
|
||||
// Make sure state is not downgraded
|
||||
if (m_internalState == QCamera::LoadedStatus
|
||||
|| m_internalState == QCamera::ActiveStatus) {
|
||||
// Do nothing (already in target state)
|
||||
} else if (m_internalState == QCamera::StartingStatus) {
|
||||
m_internalState = QCamera::ActiveStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
} else {
|
||||
m_internalState = QCamera::LoadedStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
|
||||
switch (m_requestedState) {
|
||||
case QCamera::UnloadedState:
|
||||
stopCamera();
|
||||
unloadCamera();
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
m_settingCaptureModeInternally = true;
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
}
|
||||
break;
|
||||
case QCamera::LoadedState:
|
||||
stopCamera();
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
m_settingCaptureModeInternally = true;
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
}
|
||||
m_inactivityTimer->start(KInactivityTimerTimeout);
|
||||
break;
|
||||
case QCamera::ActiveState:
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
m_settingCaptureModeInternally = true;
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
}
|
||||
startCamera();
|
||||
break;
|
||||
|
||||
default:
|
||||
setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraControl::imageCaptured(const int imageId, const QImage& preview)
|
||||
{
|
||||
Q_UNUSED(imageId);
|
||||
Q_UNUSED(preview);
|
||||
|
||||
// Unsubscribe the readyForCaptureChanged notification
|
||||
disconnect(m_imageSession, SIGNAL(imageCaptured(const int, const QImage&)),
|
||||
this, SLOT(imageCaptured(const int, const QImage&)));
|
||||
|
||||
if (m_rotateCameraWhenReady)
|
||||
resetCameraOrientation();
|
||||
}
|
||||
|
||||
void S60CameraControl::advancedSettingsCreated()
|
||||
{
|
||||
m_advancedSettings = m_imageSession->advancedSettings();
|
||||
|
||||
if (m_advancedSettings)
|
||||
connect(m_advancedSettings, SIGNAL(error(int, const QString&)), this, SIGNAL(error(int, const QString&)));
|
||||
}
|
||||
|
||||
void S60CameraControl::MceoCameraReady()
|
||||
{
|
||||
// Rotate camera if requested
|
||||
if (m_rotateCameraWhenReady) {
|
||||
resetCameraOrientation();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_internalState != QCamera::LoadedStatus) {
|
||||
|
||||
switch (m_requestedState) {
|
||||
case QCamera::UnloadedState:
|
||||
m_internalState = QCamera::LoadedStatus;
|
||||
emit statusChanged(QCamera::LoadedStatus);
|
||||
|
||||
stopCamera();
|
||||
unloadCamera();
|
||||
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
m_settingCaptureModeInternally = true;
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
}
|
||||
break;
|
||||
|
||||
case QCamera::LoadedState:
|
||||
if (m_captureMode == QCamera::CaptureVideo) {
|
||||
int prepareSuccess = m_videoSession->initializeVideoRecording();
|
||||
setError(prepareSuccess, tr("Loading video capture failed."));
|
||||
|
||||
// State change signalled when reservation is complete (in videoStateChanged())
|
||||
return;
|
||||
}
|
||||
m_internalState = QCamera::LoadedStatus;
|
||||
emit statusChanged(QCamera::LoadedStatus);
|
||||
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
m_changeCaptureModeWhenReady = false; // Reset
|
||||
}
|
||||
|
||||
if (m_requestedState == QCamera::LoadedStatus &&
|
||||
m_internalState == QCamera::LoadedStatus)
|
||||
m_inactivityTimer->start(KInactivityTimerTimeout);
|
||||
break;
|
||||
|
||||
case QCamera::ActiveState:
|
||||
if (m_captureMode == QCamera::CaptureVideo) {
|
||||
int prepareSuccess = m_videoSession->initializeVideoRecording();
|
||||
setError(prepareSuccess, tr("Loading video capture failed."));
|
||||
|
||||
// State change signalled when reservation is complete (in videoStateChanged())
|
||||
return;
|
||||
}
|
||||
|
||||
m_internalState = QCamera::LoadedStatus;
|
||||
emit statusChanged(QCamera::LoadedStatus);
|
||||
|
||||
if (m_changeCaptureModeWhenReady) {
|
||||
setCaptureMode(m_requestedCaptureMode);
|
||||
m_changeCaptureModeWhenReady = false; // Reset
|
||||
}
|
||||
startCamera();
|
||||
break;
|
||||
|
||||
default:
|
||||
setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraControl::MceoHandleError(TCameraEngineError aErrorType, TInt aError)
|
||||
{
|
||||
Q_UNUSED(aErrorType);
|
||||
|
||||
if (aError == KErrAccessDenied) {
|
||||
setError(KErrGeneral, tr("Access to camera device was rejected."));
|
||||
} else if (aError == KErrHardwareNotAvailable) {
|
||||
setError(aError, tr("Camera resources were lost."));
|
||||
toStandByStatus();
|
||||
}
|
||||
else
|
||||
setError(aError, tr("Unexpected camera error."));
|
||||
}
|
||||
|
||||
void S60CameraControl::setError(const TInt error, const QString &description)
|
||||
{
|
||||
if (error == KErrNone)
|
||||
return;
|
||||
|
||||
m_error = error;
|
||||
QCamera::Error cameraError = fromSymbianErrorToQtMultimediaError(m_error);
|
||||
|
||||
emit this->error(int(cameraError), description);
|
||||
|
||||
// Reset everything, if other than not supported error or resource loss
|
||||
if (error != KErrNotSupported && error != KErrHardwareNotAvailable)
|
||||
resetCamera(true); // Try to recover from error
|
||||
else
|
||||
m_error = KErrNone; // Reset error
|
||||
}
|
||||
|
||||
QCamera::Error S60CameraControl::fromSymbianErrorToQtMultimediaError(int aError)
|
||||
{
|
||||
switch(aError) {
|
||||
case KErrNone:
|
||||
return QCamera::NoError; // No errors have occurred
|
||||
|
||||
case KErrNotSupported:
|
||||
return QCamera::NotSupportedFeatureError; // The feature is not supported
|
||||
case KErrNotFound:
|
||||
case KErrBadHandle:
|
||||
return QCamera::ServiceMissingError; // No camera service available
|
||||
case KErrArgument:
|
||||
case KErrNotReady:
|
||||
return QCamera::InvalidRequestError; // Invalid parameter or state
|
||||
|
||||
default:
|
||||
return QCamera::CameraError; // An error has occurred (i.e. General Error)
|
||||
}
|
||||
}
|
||||
|
||||
// For S60CameraVideoDeviceControl
|
||||
int S60CameraControl::deviceCount()
|
||||
{
|
||||
#ifdef Q_CC_NOKIAX86 // Emulator
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
return CCameraEngine::CamerasAvailable();
|
||||
}
|
||||
|
||||
int S60CameraControl::defaultDevice() const
|
||||
{
|
||||
return KDefaultCameraDevice;
|
||||
}
|
||||
|
||||
int S60CameraControl::selectedDevice() const
|
||||
{
|
||||
return m_deviceIndex;
|
||||
}
|
||||
|
||||
void S60CameraControl::setSelectedDevice(const int index)
|
||||
{
|
||||
if (m_deviceIndex != index) {
|
||||
if (index >= 0 && index < deviceCount()) {
|
||||
m_deviceIndex = index;
|
||||
resetCamera();
|
||||
} else {
|
||||
setError(KErrNotSupported, tr("Requested camera is not available."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString S60CameraControl::name(const int index)
|
||||
{
|
||||
QString cameraName;
|
||||
switch (index) {
|
||||
case 0:
|
||||
cameraName = tr("Primary camera");
|
||||
break;
|
||||
case 1:
|
||||
cameraName = tr("Secondary camera");
|
||||
break;
|
||||
case 2:
|
||||
cameraName = tr("Tertiary camera");
|
||||
break;
|
||||
|
||||
default:
|
||||
cameraName = tr("Unidentified Camera");
|
||||
break;
|
||||
}
|
||||
|
||||
return cameraName;
|
||||
}
|
||||
|
||||
QString S60CameraControl::description(const int index)
|
||||
{
|
||||
QString cameraDesc;
|
||||
switch (index) {
|
||||
case 0:
|
||||
cameraDesc = tr("Device primary camera");
|
||||
break;
|
||||
case 1:
|
||||
cameraDesc = tr("Device secondary camera");
|
||||
break;
|
||||
case 2:
|
||||
cameraDesc = tr("Device tertiary camera");
|
||||
break;
|
||||
|
||||
default:
|
||||
cameraDesc = tr("Unidentified Camera");
|
||||
break;
|
||||
}
|
||||
|
||||
return cameraDesc;
|
||||
}
|
||||
|
||||
void S60CameraControl::resetCamera(bool errorHandling)
|
||||
{
|
||||
if (m_inactivityTimer->isActive())
|
||||
m_inactivityTimer->stop();
|
||||
|
||||
// Cancel ongoing activity
|
||||
m_imageSession->cancelCapture();
|
||||
m_videoSession->stopRecording(false); // Don't re-initialize video
|
||||
|
||||
// Advanced settings must be destructed before the camera
|
||||
m_imageSession->deleteAdvancedSettings();
|
||||
|
||||
// Release resources
|
||||
stopCamera();
|
||||
unloadCamera();
|
||||
|
||||
disconnect(m_viewfinderEngine, SIGNAL(error(int, const QString&)), this, SIGNAL(error(int,const QString&)));
|
||||
if (m_viewfinderEngine) {
|
||||
delete m_viewfinderEngine;
|
||||
m_viewfinderEngine = 0;
|
||||
}
|
||||
|
||||
if (m_cameraEngine) {
|
||||
delete m_cameraEngine;
|
||||
m_cameraEngine = 0;
|
||||
}
|
||||
|
||||
TRAPD(err, m_cameraEngine = CCameraEngine::NewL(m_deviceIndex, 0, this));
|
||||
if (err) {
|
||||
m_cameraEngine = 0;
|
||||
if (errorHandling) {
|
||||
qWarning("Failed to recover from error.");
|
||||
if (err == KErrPermissionDenied)
|
||||
emit error(int(QCamera::ServiceMissingError), tr("Recovering from error failed. Possibly missing capabilities."));
|
||||
else
|
||||
emit error(int(QCamera::CameraError), tr("Recovering from error failed."));
|
||||
} else {
|
||||
if (err == KErrPermissionDenied)
|
||||
setError(err, tr("Camera device creation failed. Possibly missing capabilities."));
|
||||
else
|
||||
setError(err, tr("Camera device creation failed."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify list of available camera devices has been updated
|
||||
emit devicesChanged();
|
||||
|
||||
m_viewfinderEngine = new S60CameraViewfinderEngine(this, m_cameraEngine, this);
|
||||
if (m_viewfinderEngine == 0)
|
||||
setError(KErrNoMemory, tr("Viewfinder device creation failed."));
|
||||
connect(m_viewfinderEngine, SIGNAL(error(int, const QString&)), this, SIGNAL(error(int,const QString&)));
|
||||
|
||||
setCameraHandles();
|
||||
|
||||
// Reset state
|
||||
//setState(QCamera::UnloadedState);
|
||||
if (m_internalState != QCamera::UnloadedStatus) {
|
||||
m_internalState = QCamera::UnloadedStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
if (m_requestedState != QCamera::UnloadedState) {
|
||||
m_requestedState = QCamera::UnloadedState;
|
||||
emit stateChanged(m_requestedState);
|
||||
}
|
||||
|
||||
// Reset error
|
||||
m_error = KErrNone;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset everything else than viewfinder engine and errors.
|
||||
*/
|
||||
void S60CameraControl::resetCameraOrientation()
|
||||
{
|
||||
// If camera has not been created, it will be created automatically to correct orientation
|
||||
if (!m_cameraEngine)
|
||||
return;
|
||||
|
||||
// Check Image/VideoCapture allow rotation
|
||||
if ((!m_cameraEngine->IsCameraReady() && m_internalState != QCamera::UnloadedStatus) ||
|
||||
m_videoCaptureState == S60VideoCaptureSession::ERecording ||
|
||||
m_videoCaptureState == S60VideoCaptureSession::EPaused) {
|
||||
|
||||
// If image capture is ongoing, request notification about the
|
||||
// completion (imageCaptured() is used because that comes asynchronously
|
||||
// after the image is captured)
|
||||
// Obs! If preview creation is changed to be synchnonously done during
|
||||
// the image capture this implementation needs to be changed)
|
||||
if (m_videoCaptureState != S60VideoCaptureSession::ERecording &&
|
||||
m_videoCaptureState != S60VideoCaptureSession::EPaused &&
|
||||
m_internalState == QCamera::ActiveStatus)
|
||||
connect(m_imageSession, SIGNAL(imageCaptured(const int, const QImage&)),
|
||||
this, SLOT(imageCaptured(const int, const QImage&)));
|
||||
|
||||
m_rotateCameraWhenReady = true;
|
||||
return;
|
||||
}
|
||||
|
||||
m_rotateCameraWhenReady = false; // Reset
|
||||
|
||||
QCamera::State originalState = m_requestedState;
|
||||
|
||||
// Cancel ongoing activity
|
||||
m_imageSession->cancelCapture();
|
||||
m_videoSession->stopRecording(false); // Don't re-initialize video
|
||||
|
||||
// Advanced settings must be destructed before the camera
|
||||
m_imageSession->deleteAdvancedSettings();
|
||||
|
||||
// Release resources
|
||||
stopCamera();
|
||||
unloadCamera();
|
||||
|
||||
// Unset CameraEngine to ViewfinderEngine
|
||||
m_viewfinderEngine->setNewCameraEngine(0);
|
||||
if (m_cameraEngine) {
|
||||
delete m_cameraEngine;
|
||||
m_cameraEngine = 0;
|
||||
}
|
||||
|
||||
TRAPD(err, m_cameraEngine = CCameraEngine::NewL(m_deviceIndex, 0, this));
|
||||
if (err) {
|
||||
setError(err, tr("Camera device creation failed."));
|
||||
return;
|
||||
}
|
||||
// Reset CameraEngine to ViewfinderEngine
|
||||
m_viewfinderEngine->setNewCameraEngine(m_cameraEngine);
|
||||
|
||||
// Notify list of available camera devices has been updated
|
||||
emit devicesChanged();
|
||||
|
||||
setCameraHandles();
|
||||
|
||||
// Reset state
|
||||
if (m_internalState != QCamera::UnloadedStatus) {
|
||||
m_internalState = QCamera::UnloadedStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
if (m_requestedState != QCamera::UnloadedState) {
|
||||
m_requestedState = QCamera::UnloadedState;
|
||||
emit stateChanged(m_requestedState);
|
||||
}
|
||||
|
||||
setState(originalState);
|
||||
}
|
||||
|
||||
void S60CameraControl::setCameraHandles()
|
||||
{
|
||||
m_imageSession->setCurrentDevice(m_deviceIndex);
|
||||
m_imageSession->setCameraHandle(m_cameraEngine);
|
||||
m_cameraEngine->SetImageCaptureObserver(m_imageSession);
|
||||
m_videoSession->setCameraHandle(m_cameraEngine);
|
||||
}
|
||||
|
||||
void S60CameraControl::toStandByStatus()
|
||||
{
|
||||
// Cancel ongoing operations if any
|
||||
m_imageSession->cancelCapture();
|
||||
m_videoSession->stopRecording(false); // Don't re-initialize video
|
||||
|
||||
emit cameraReadyChanged(false);
|
||||
if (m_viewfinderEngine)
|
||||
m_viewfinderEngine->stopViewfinder();
|
||||
else
|
||||
setError(KErrGeneral, tr("Failed to stop viewfinder."));
|
||||
|
||||
m_cameraEngine->ReleaseAndPowerOff();
|
||||
|
||||
m_internalState = QCamera::StandbyStatus;
|
||||
emit statusChanged(m_internalState);
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,178 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERACONTROL_H
|
||||
#define S60CAMERACONTROL_H
|
||||
|
||||
#include <qcameracontrol.h>
|
||||
|
||||
#include "s60cameraengineobserver.h" // MCameraEngineObserver
|
||||
#include "s60videocapturesession.h" // TVideoCaptureState
|
||||
#include "s60cameraviewfinderengine.h" // ViewfinderOutputType
|
||||
|
||||
#include <e32base.h>
|
||||
#include <fbs.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
class S60VideoCaptureSession;
|
||||
class S60CameraSettings;
|
||||
class CCameraEngine;
|
||||
class S60CameraViewfinderEngine;
|
||||
class QTimer;
|
||||
|
||||
/*
|
||||
* Control for controlling camera base operations (e.g. start/stop and capture
|
||||
* mode).
|
||||
*/
|
||||
class S60CameraControl : public QCameraControl, public MCameraEngineObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60CameraControl(QObject *parent = 0);
|
||||
S60CameraControl(S60VideoCaptureSession *videosession,
|
||||
S60ImageCaptureSession *imagesession,
|
||||
QObject *parent = 0);
|
||||
~S60CameraControl();
|
||||
|
||||
public: // QCameraControl
|
||||
|
||||
// State
|
||||
QCamera::State state() const;
|
||||
void setState(QCamera::State state);
|
||||
|
||||
// Status
|
||||
QCamera::Status status() const;
|
||||
|
||||
// Capture Mode
|
||||
QCamera::CaptureMode captureMode() const;
|
||||
void setCaptureMode(QCamera::CaptureMode);
|
||||
bool isCaptureModeSupported(QCamera::CaptureMode mode) const;
|
||||
|
||||
// Property Setting
|
||||
bool canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const;
|
||||
|
||||
/*
|
||||
Q_SIGNALS:
|
||||
void stateChanged(QCamera::State);
|
||||
void statusChanged(QCamera::Status);
|
||||
void error(int error, const QString &errorString);
|
||||
void captureModeChanged(QCamera::CaptureMode);
|
||||
*/
|
||||
|
||||
public: // Internal
|
||||
|
||||
void setError(const TInt error, const QString &description);
|
||||
void resetCameraOrientation();
|
||||
|
||||
// To provide QVideoDeviceControl info
|
||||
static int deviceCount();
|
||||
static QString name(const int index);
|
||||
static QString description(const int index);
|
||||
int defaultDevice() const;
|
||||
int selectedDevice() const;
|
||||
void setSelectedDevice(const int index);
|
||||
|
||||
void setVideoOutput(QObject *output,
|
||||
const S60CameraViewfinderEngine::ViewfinderOutputType type);
|
||||
void releaseVideoOutput(const S60CameraViewfinderEngine::ViewfinderOutputType type);
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void videoStateChanged(const S60VideoCaptureSession::TVideoCaptureState state);
|
||||
// Needed to detect image capture completion when trying to rotate the camera
|
||||
void imageCaptured(const int imageId, const QImage& preview);
|
||||
/*
|
||||
* This method moves the camera to the StandBy status:
|
||||
* - If camera access was lost
|
||||
* - If camera has been inactive in LoadedStatus for a long time
|
||||
*/
|
||||
void toStandByStatus();
|
||||
void advancedSettingsCreated();
|
||||
|
||||
protected: // MCameraEngineObserver
|
||||
|
||||
void MceoCameraReady();
|
||||
void MceoHandleError(TCameraEngineError aErrorType, TInt aError);
|
||||
|
||||
private: // Internal
|
||||
|
||||
QCamera::Error fromSymbianErrorToQtMultimediaError(int aError);
|
||||
|
||||
void loadCamera();
|
||||
void unloadCamera();
|
||||
void startCamera();
|
||||
void stopCamera();
|
||||
|
||||
void resetCamera(bool errorHandling = false);
|
||||
void setCameraHandles();
|
||||
|
||||
signals: // Internal Signals
|
||||
|
||||
void cameraReadyChanged(bool);
|
||||
void devicesChanged();
|
||||
|
||||
private: // Data
|
||||
|
||||
CCameraEngine *m_cameraEngine;
|
||||
S60CameraViewfinderEngine *m_viewfinderEngine;
|
||||
S60ImageCaptureSession *m_imageSession;
|
||||
S60VideoCaptureSession *m_videoSession;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
QObject *m_videoOutput;
|
||||
QTimer *m_inactivityTimer;
|
||||
QCamera::CaptureMode m_captureMode;
|
||||
QCamera::CaptureMode m_requestedCaptureMode;
|
||||
bool m_settingCaptureModeInternally;
|
||||
QCamera::Status m_internalState;
|
||||
QCamera::State m_requestedState;
|
||||
int m_deviceIndex;
|
||||
mutable int m_error;
|
||||
bool m_changeCaptureModeWhenReady;
|
||||
bool m_rotateCameraWhenReady;
|
||||
S60VideoCaptureSession::TVideoCaptureState m_videoCaptureState;
|
||||
};
|
||||
|
||||
#endif // S60CAMERACONTROL_H
|
||||
@@ -1,824 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60cameraengine.h"
|
||||
#include "s60cameraengineobserver.h"
|
||||
#include "s60cameraconstants.h"
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <fbs.h> // CFbsBitmap
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
#include <platform/ecam/camerasnapshot.h>
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
CCameraEngine::CCameraEngine()
|
||||
{
|
||||
}
|
||||
|
||||
CCameraEngine::CCameraEngine(TInt aCameraHandle,
|
||||
TInt aPriority,
|
||||
MCameraEngineObserver* aObserver) :
|
||||
// CBase initializes member variables to NULL
|
||||
iObserver(aObserver),
|
||||
iCameraIndex(aCameraHandle),
|
||||
iPriority(aPriority),
|
||||
iEngineState(EEngineNotReady),
|
||||
iCaptureResolution(TSize(0,0)),
|
||||
iNew2LImplementation(false),
|
||||
iLatestImageBufferIndex(1) // Thus we start from index 0
|
||||
{
|
||||
// Observer is mandatory
|
||||
ASSERT(aObserver != NULL);
|
||||
}
|
||||
|
||||
CCameraEngine::~CCameraEngine()
|
||||
{
|
||||
StopViewFinder();
|
||||
ReleaseViewFinderBuffer(); // Releases iViewFinderBuffer
|
||||
ReleaseImageBuffer(); // Releases iImageBuffer + iImageBitmap
|
||||
|
||||
iAdvancedSettingsObserver = NULL;
|
||||
iImageCaptureObserver = NULL;
|
||||
iViewfinderObserver = NULL;
|
||||
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
delete iAutoFocus;
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
|
||||
if (iCamera) {
|
||||
iCamera->Release();
|
||||
delete iCamera;
|
||||
iCamera = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
TInt CCameraEngine::CamerasAvailable()
|
||||
{
|
||||
return CCamera::CamerasAvailable();
|
||||
}
|
||||
|
||||
CCameraEngine* CCameraEngine::NewL(TInt aCameraHandle,
|
||||
TInt aPriority,
|
||||
MCameraEngineObserver* aObserver)
|
||||
{
|
||||
CCameraEngine* self = new (ELeave) CCameraEngine(aCameraHandle, aPriority, aObserver);
|
||||
CleanupStack::PushL(self);
|
||||
self->ConstructL();
|
||||
CleanupStack::Pop(self);
|
||||
return self;
|
||||
}
|
||||
|
||||
void CCameraEngine::ConstructL()
|
||||
{
|
||||
if (!CCamera::CamerasAvailable())
|
||||
User::Leave(KErrHardwareNotAvailable);
|
||||
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
TInt err(KErrNone);
|
||||
#else // Emulator
|
||||
TInt err(KErrNotFound);
|
||||
#endif // !(Q_CC_NOKIAX86)
|
||||
|
||||
#ifdef S60_31_PLATFORM
|
||||
// Construct CCamera object for S60 3.1 (NewL)
|
||||
iNew2LImplementation = false;
|
||||
TRAP(err, iCamera = CCamera::NewL(*this, iCameraIndex));
|
||||
if (err)
|
||||
User::Leave(err);
|
||||
#else // For S60 3.2 onwards - use this constructor (New2L)
|
||||
iNew2LImplementation = true;
|
||||
TRAP(err, iCamera = CCamera::New2L(*this, iCameraIndex, iPriority));
|
||||
if (err)
|
||||
User::Leave(err);
|
||||
#endif // S60_31_PLATFORM
|
||||
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
// Might not be supported for secondary camera, discard errors
|
||||
TRAP(err, iAutoFocus = CCamAutoFocus::NewL(iCamera));
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
|
||||
if (iCamera == NULL)
|
||||
User::Leave(KErrNoMemory);
|
||||
|
||||
iCamera->CameraInfo(iCameraInfo);
|
||||
}
|
||||
|
||||
void CCameraEngine::SetAdvancedObserver(MAdvancedSettingsObserver* aAdvancedSettingsObserver)
|
||||
{
|
||||
iAdvancedSettingsObserver = aAdvancedSettingsObserver;
|
||||
}
|
||||
|
||||
void CCameraEngine::SetImageCaptureObserver(MCameraEngineImageCaptureObserver* aImageCaptureObserver)
|
||||
{
|
||||
iImageCaptureObserver = aImageCaptureObserver;
|
||||
}
|
||||
|
||||
void CCameraEngine::SetViewfinderObserver(MCameraViewfinderObserver* aViewfinderObserver)
|
||||
{
|
||||
iViewfinderObserver = aViewfinderObserver;
|
||||
}
|
||||
|
||||
void CCameraEngine::ReserveAndPowerOn()
|
||||
{
|
||||
if (!iCamera || iEngineState > EEngineNotReady) {
|
||||
iObserver->MceoHandleError(EErrReserve, KErrNotReady);
|
||||
return;
|
||||
}
|
||||
|
||||
iCamera->Reserve();
|
||||
}
|
||||
|
||||
void CCameraEngine::ReleaseAndPowerOff()
|
||||
{
|
||||
if (iEngineState >= EEngineIdle) {
|
||||
CancelCapture();
|
||||
StopViewFinder();
|
||||
FocusCancel();
|
||||
iCamera->PowerOff();
|
||||
iCamera->Release();
|
||||
}
|
||||
iEngineState = EEngineNotReady;
|
||||
}
|
||||
|
||||
void CCameraEngine::StartViewFinderL(TSize& aSize)
|
||||
{
|
||||
if (iEngineState < EEngineIdle)
|
||||
User::Leave(KErrNotReady);
|
||||
|
||||
if (0 == (iCameraInfo.iOptionsSupported & TCameraInfo::EViewFinderBitmapsSupported))
|
||||
User::Leave(KErrNotSupported);
|
||||
|
||||
if (!iCamera->ViewFinderActive()) {
|
||||
if (iCameraIndex != 0)
|
||||
iCamera->SetViewFinderMirrorL(true);
|
||||
iCamera->StartViewFinderBitmapsL(aSize);
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::StopViewFinder()
|
||||
{
|
||||
if (iCamera && iCamera->ViewFinderActive())
|
||||
iCamera->StopViewFinder();
|
||||
}
|
||||
|
||||
void CCameraEngine::StartDirectViewFinderL(RWsSession& aSession,
|
||||
CWsScreenDevice& aScreenDevice,
|
||||
RWindowBase& aWindow,
|
||||
TRect& aScreenRect,
|
||||
TRect& aClipRect)
|
||||
{
|
||||
if (iEngineState < EEngineIdle)
|
||||
User::Leave(KErrNotReady);
|
||||
|
||||
if (0 == (iCameraInfo.iOptionsSupported & TCameraInfo::EViewFinderDirectSupported))
|
||||
User::Leave(KErrNotSupported);
|
||||
|
||||
if (!iCamera->ViewFinderActive()) {
|
||||
// Viewfinder extent needs to be clipped according to the clip rect.
|
||||
// This is because the native camera framework does not support
|
||||
// clipping and starting viewfinder with bigger than the display(S60
|
||||
// 5.0 and older)/window(Symbian^3 and later) would cause viewfinder
|
||||
// starting to fail entirely. This causes shrinking effect in some
|
||||
// cases, but is better than not having the viewfinder at all.
|
||||
if (aScreenRect.Intersects(aClipRect))
|
||||
aScreenRect.Intersection(aClipRect);
|
||||
|
||||
if (iCameraIndex != 0)
|
||||
iCamera->SetViewFinderMirrorL(true);
|
||||
if (aScreenRect.Width() > 0 && aScreenRect.Height() > 0) {
|
||||
iCamera->StartViewFinderDirectL(aSession, aScreenDevice, aWindow, aScreenRect);
|
||||
} else {
|
||||
if (iObserver)
|
||||
iObserver->MceoHandleError(EErrViewFinderReady, KErrArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::PrepareL(TSize& aCaptureSize, CCamera::TFormat aFormat)
|
||||
{
|
||||
iImageCaptureFormat = aFormat;
|
||||
|
||||
TInt closestVar = KMaxTInt, selected = 0;
|
||||
TSize size;
|
||||
|
||||
// Scan through supported capture sizes and select the closest match
|
||||
for (TInt index = 0; index < iCameraInfo.iNumImageSizesSupported; index++) {
|
||||
|
||||
iCamera->EnumerateCaptureSizes(size, index, aFormat);
|
||||
if (size == aCaptureSize) {
|
||||
selected = index;
|
||||
break;
|
||||
}
|
||||
|
||||
TSize varSz = size - aCaptureSize;
|
||||
TInt variation = varSz.iWidth * varSz.iHeight;
|
||||
if (variation < closestVar) {
|
||||
closestVar = variation;
|
||||
selected = index;
|
||||
}
|
||||
}
|
||||
|
||||
iCamera->EnumerateCaptureSizes(aCaptureSize, selected, aFormat);
|
||||
iCaptureResolution = aCaptureSize;
|
||||
iCamera->PrepareImageCaptureL(aFormat, selected);
|
||||
}
|
||||
|
||||
void CCameraEngine::CaptureL()
|
||||
{
|
||||
if (iEngineState < EEngineIdle)
|
||||
User::Leave(KErrNotReady);
|
||||
|
||||
iCamera->CaptureImage();
|
||||
iEngineState = EEngineCapturing;
|
||||
}
|
||||
|
||||
void CCameraEngine::CancelCapture()
|
||||
{
|
||||
if (iEngineState == EEngineCapturing) {
|
||||
iCamera->CancelCaptureImage();
|
||||
iEngineState = EEngineIdle;
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::HandleEvent(const TECAMEvent &aEvent)
|
||||
{
|
||||
if (aEvent.iEventType == KUidECamEventReserveComplete) {
|
||||
ReserveComplete(aEvent.iErrorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aEvent.iEventType == KUidECamEventPowerOnComplete) {
|
||||
PowerOnComplete(aEvent.iErrorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aEvent.iEventType == KUidECamEventCameraNoLongerReserved) {
|
||||
// All camera related operations need to be stopped
|
||||
iObserver->MceoHandleError(EErrReserve, KErrHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
if (aEvent.iEventType == KUidECamEventCameraSnapshot) {
|
||||
HandlePreview();
|
||||
return;
|
||||
}
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
#if !defined(Q_CC_NOKIAX86) // Not Emulator
|
||||
// Other events; Exposure, Zoom, etc. (See ecamadvancedsettings.h)
|
||||
if (iAdvancedSettingsObserver)
|
||||
iAdvancedSettingsObserver->HandleAdvancedEvent(aEvent);
|
||||
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleOtherEvent(aEvent);
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
void CCameraEngine::ReserveComplete(TInt aError)
|
||||
{
|
||||
if (aError == KErrNone) {
|
||||
iCamera->PowerOn();
|
||||
#ifdef S60_31_PLATFORM
|
||||
} else if (aError == KErrAlreadyExists) { // Known Issue on some S60 3.1 devices
|
||||
User::After(500000); // Wait for 0,5 second and try again
|
||||
iCamera->Reserve();
|
||||
#endif // S60_31_PLATFORM
|
||||
} else {
|
||||
iObserver->MceoHandleError(EErrReserve, aError);
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::PowerOnComplete(TInt aError)
|
||||
{
|
||||
if (aError) {
|
||||
iObserver->MceoHandleError(EErrPowerOn, aError);
|
||||
iEngineState = EEngineNotReady;
|
||||
return;
|
||||
}
|
||||
|
||||
// Init AutoFocus
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.1
|
||||
if( iAutoFocus ) {
|
||||
TRAPD(afErr, iAutoFocus->InitL( *this ));
|
||||
if (afErr) {
|
||||
delete iAutoFocus;
|
||||
iAutoFocus = 0;
|
||||
}
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
|
||||
iEngineState = EEngineIdle;
|
||||
iObserver->MceoCameraReady();
|
||||
}
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
/**
|
||||
* This method creates the CCameraPreview object and requests the previews to
|
||||
* be provided during the image or video capture
|
||||
*/
|
||||
void CCameraEngine::EnablePreviewProvider(MCameraPreviewObserver *aPreviewObserver)
|
||||
{
|
||||
// Delete old one if exists
|
||||
if (iCameraSnapshot)
|
||||
delete iCameraSnapshot;
|
||||
|
||||
iPreviewObserver = aPreviewObserver;
|
||||
|
||||
TInt error = KErrNone;
|
||||
|
||||
if (iCamera) {
|
||||
TRAP(error, iCameraSnapshot = CCamera::CCameraSnapshot::NewL(*iCamera));
|
||||
if (error) {
|
||||
if (iObserver)
|
||||
iObserver->MceoHandleError(EErrPreview, error);
|
||||
return;
|
||||
}
|
||||
|
||||
TRAP(error, iCameraSnapshot->PrepareSnapshotL(KDefaultFormatPreview, SelectPreviewResolution(), EFalse));
|
||||
if (error) {
|
||||
if (iObserver)
|
||||
iObserver->MceoHandleError(EErrPreview, error);
|
||||
return;
|
||||
}
|
||||
|
||||
iCameraSnapshot->StartSnapshot();
|
||||
} else {
|
||||
if (iObserver)
|
||||
iObserver->MceoHandleError(EErrPreview, KErrNotReady);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method disables and destroys the CCameraPreview object. Thus previews
|
||||
* will not be provided during the image or video capture.
|
||||
*/
|
||||
void CCameraEngine::DisablePreviewProvider()
|
||||
{
|
||||
if (!iCameraSnapshot)
|
||||
return;
|
||||
|
||||
iCameraSnapshot->StopSnapshot();
|
||||
|
||||
delete iCameraSnapshot;
|
||||
iCameraSnapshot = 0;
|
||||
|
||||
iPreviewObserver = 0;
|
||||
}
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
/*
|
||||
* MCameraObserver2:
|
||||
* New viewfinder frame available
|
||||
*/
|
||||
void CCameraEngine::ViewFinderReady(MCameraBuffer &aCameraBuffer, TInt aError)
|
||||
{
|
||||
iViewFinderBuffer = &aCameraBuffer;
|
||||
|
||||
if (aError == KErrNone) {
|
||||
if (iViewfinderObserver) {
|
||||
TRAPD(err, iViewfinderObserver->MceoViewFinderFrameReady(aCameraBuffer.BitmapL(0)));
|
||||
if (err)
|
||||
iObserver->MceoHandleError(EErrViewFinderReady, err);
|
||||
} else {
|
||||
iObserver->MceoHandleError(EErrViewFinderReady, KErrNotReady);
|
||||
}
|
||||
}
|
||||
else {
|
||||
iObserver->MceoHandleError(EErrViewFinderReady, aError);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* MCameraObserver:
|
||||
* New viewfinder frame available
|
||||
*/
|
||||
void CCameraEngine::ViewFinderFrameReady(CFbsBitmap& aFrame)
|
||||
{
|
||||
if (iViewfinderObserver)
|
||||
iViewfinderObserver->MceoViewFinderFrameReady(aFrame);
|
||||
else
|
||||
iObserver->MceoHandleError(EErrViewFinderReady, KErrNotReady);
|
||||
}
|
||||
|
||||
void CCameraEngine::ReleaseViewFinderBuffer()
|
||||
{
|
||||
if (iNew2LImplementation) { // NewL Implementation does not use MCameraBuffer
|
||||
if (iViewFinderBuffer) {
|
||||
iViewFinderBuffer->Release();
|
||||
iViewFinderBuffer = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::ReleaseImageBuffer()
|
||||
{
|
||||
// Reset Bitmap
|
||||
if (iLatestImageBufferIndex == 1 || iImageBitmap2 == NULL) {
|
||||
if (iImageBitmap1) {
|
||||
if (!iNew2LImplementation) { // NewL - Ownership transferred
|
||||
iImageBitmap1->Reset(); // Reset/Delete Bitmap
|
||||
delete iImageBitmap1;
|
||||
}
|
||||
iImageBitmap1 = NULL;
|
||||
}
|
||||
} else {
|
||||
if (iImageBitmap2) {
|
||||
if (!iNew2LImplementation) { // NewL - Ownership transferred
|
||||
iImageBitmap2->Reset(); // Reset/Delete Bitmap
|
||||
delete iImageBitmap2;
|
||||
}
|
||||
iImageBitmap2 = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset Data pointers
|
||||
if (iLatestImageBufferIndex == 1 || iImageData2 == NULL) {
|
||||
if (!iNew2LImplementation) // NewL - Ownership transfers with buffer
|
||||
delete iImageData1;
|
||||
iImageData1 = NULL;
|
||||
} else {
|
||||
if (!iNew2LImplementation) // NewL - Ownership transfers with buffer
|
||||
delete iImageData2;
|
||||
iImageData2 = NULL;
|
||||
}
|
||||
|
||||
// Reset ImageBuffer - New2L Implementation only
|
||||
if (iLatestImageBufferIndex == 1 || iImageBuffer2 == NULL) {
|
||||
if (iImageBuffer1) {
|
||||
iImageBuffer1->Release();
|
||||
iImageBuffer1 = NULL;
|
||||
}
|
||||
} else {
|
||||
if (iImageBuffer2) {
|
||||
iImageBuffer2->Release();
|
||||
iImageBuffer2 = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* MCameraObserver2
|
||||
* Captured image is ready (New2L version)
|
||||
*/
|
||||
void CCameraEngine::ImageBufferReady(MCameraBuffer &aCameraBuffer, TInt aError)
|
||||
{
|
||||
// Use the buffer that is available
|
||||
if (!iImageBuffer1) {
|
||||
iLatestImageBufferIndex = 0;
|
||||
iImageBuffer1 = &aCameraBuffer;
|
||||
} else {
|
||||
iLatestImageBufferIndex = 1;
|
||||
iImageBuffer2 = &aCameraBuffer;
|
||||
}
|
||||
|
||||
bool isBitmap = true;
|
||||
TInt err = KErrNone;
|
||||
|
||||
switch (iImageCaptureFormat) {
|
||||
case CCamera::EFormatFbsBitmapColor4K:
|
||||
case CCamera::EFormatFbsBitmapColor64K:
|
||||
case CCamera::EFormatFbsBitmapColor16M:
|
||||
case CCamera::EFormatFbsBitmapColor16MU:
|
||||
if (iLatestImageBufferIndex == 0) {
|
||||
TRAP(err, iImageBitmap1 = &iImageBuffer1->BitmapL(0));
|
||||
if (err) {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, err);
|
||||
}
|
||||
} else {
|
||||
TRAP(err, iImageBitmap2 = &iImageBuffer2->BitmapL(0));
|
||||
if (err) {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, err);
|
||||
}
|
||||
}
|
||||
isBitmap = true;
|
||||
break;
|
||||
case CCamera::EFormatExif:
|
||||
if (iLatestImageBufferIndex == 0) {
|
||||
TRAP(err, iImageData1 = iImageBuffer1->DataL(0));
|
||||
if (err) {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, err);
|
||||
}
|
||||
} else {
|
||||
TRAP(err, iImageData2 = iImageBuffer2->DataL(0));
|
||||
if (err) {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, err);
|
||||
}
|
||||
}
|
||||
isBitmap = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, KErrNotSupported);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle captured image
|
||||
HandleImageReady(aError, isBitmap);
|
||||
}
|
||||
|
||||
/*
|
||||
* MCameraObserver
|
||||
* Captured image is ready (NewL version)
|
||||
*/
|
||||
void CCameraEngine::ImageReady(CFbsBitmap* aBitmap, HBufC8* aData, TInt aError)
|
||||
{
|
||||
bool isBitmap = true;
|
||||
|
||||
// Toggle between the 2 buffers
|
||||
if (iLatestImageBufferIndex == 1) {
|
||||
iLatestImageBufferIndex = 0;
|
||||
} else {
|
||||
iLatestImageBufferIndex = 1;
|
||||
}
|
||||
|
||||
switch (iImageCaptureFormat) {
|
||||
case CCamera::EFormatFbsBitmapColor4K:
|
||||
case CCamera::EFormatFbsBitmapColor64K:
|
||||
case CCamera::EFormatFbsBitmapColor16M:
|
||||
case CCamera::EFormatFbsBitmapColor16MU:
|
||||
if (iLatestImageBufferIndex == 0)
|
||||
iImageBitmap1 = aBitmap;
|
||||
else
|
||||
iImageBitmap2 = aBitmap;
|
||||
isBitmap = true;
|
||||
break;
|
||||
case CCamera::EFormatExif:
|
||||
if (iLatestImageBufferIndex == 0)
|
||||
iImageData1 = aData;
|
||||
else
|
||||
iImageData2 = aData;
|
||||
isBitmap = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, KErrNotSupported);
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle captured image
|
||||
HandleImageReady(aError, isBitmap);
|
||||
}
|
||||
|
||||
void CCameraEngine::HandleImageReady(const TInt aError, const bool isBitmap)
|
||||
{
|
||||
iEngineState = EEngineIdle;
|
||||
|
||||
if (aError == KErrNone) {
|
||||
if (isBitmap)
|
||||
if (iImageCaptureObserver) {
|
||||
if (iLatestImageBufferIndex == 0)
|
||||
iImageCaptureObserver->MceoCapturedBitmapReady(iImageBitmap1);
|
||||
else
|
||||
iImageCaptureObserver->MceoCapturedBitmapReady(iImageBitmap2);
|
||||
}
|
||||
else
|
||||
ReleaseImageBuffer();
|
||||
else {
|
||||
if (iImageCaptureObserver) {
|
||||
if (iLatestImageBufferIndex == 0)
|
||||
iImageCaptureObserver->MceoCapturedDataReady(iImageData1);
|
||||
else
|
||||
iImageCaptureObserver->MceoCapturedDataReady(iImageData2);
|
||||
}
|
||||
else
|
||||
ReleaseImageBuffer();
|
||||
}
|
||||
} else {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrImageReady, aError);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
void CCameraEngine::HandlePreview()
|
||||
{
|
||||
if (!iCameraSnapshot) {
|
||||
if (iObserver)
|
||||
iObserver->MceoHandleError(EErrPreview, KErrGeneral);
|
||||
return;
|
||||
}
|
||||
|
||||
RArray<TInt> previewIndices;
|
||||
CleanupClosePushL(previewIndices);
|
||||
|
||||
MCameraBuffer &newPreview = iCameraSnapshot->SnapshotDataL(previewIndices);
|
||||
|
||||
for (TInt i = 0; i < previewIndices.Count(); ++i)
|
||||
iPreviewObserver->MceoPreviewReady(newPreview.BitmapL(0));
|
||||
|
||||
CleanupStack::PopAndDestroy(); // RArray<TInt> previewIndices
|
||||
}
|
||||
|
||||
TSize CCameraEngine::SelectPreviewResolution()
|
||||
{
|
||||
TSize currentResolution(iCaptureResolution);
|
||||
|
||||
TSize previewResolution(0, 0);
|
||||
if (currentResolution == TSize(4000,2248) ||
|
||||
currentResolution == TSize(3264,1832) ||
|
||||
currentResolution == TSize(2592,1456) ||
|
||||
currentResolution == TSize(1920,1080) ||
|
||||
currentResolution == TSize(1280,720)) {
|
||||
previewResolution = KDefaultSizePreview_Wide;
|
||||
} else if (currentResolution == TSize(352,288) ||
|
||||
currentResolution == TSize(176,144)) {
|
||||
previewResolution = KDefaultSizePreview_CIF;
|
||||
} else if (currentResolution == TSize(720,576)) {
|
||||
previewResolution = KDefaultSizePreview_PAL;
|
||||
} else if (currentResolution == TSize(720,480)) {
|
||||
previewResolution = KDefaultSizePreview_NTSC;
|
||||
} else {
|
||||
previewResolution = KDefaultSizePreview_Normal;
|
||||
}
|
||||
|
||||
return previewResolution;
|
||||
}
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
//=============================================================================
|
||||
// S60 3.1 - AutoFocus support (Other platforms, see S60CameraSettings class)
|
||||
//=============================================================================
|
||||
|
||||
void CCameraEngine::InitComplete(TInt aError)
|
||||
{
|
||||
if (aError) {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrAutoFocusInit, aError);
|
||||
}
|
||||
}
|
||||
|
||||
void CCameraEngine::OptimisedFocusComplete(TInt aError)
|
||||
{
|
||||
iEngineState = EEngineIdle;
|
||||
|
||||
if (aError == KErrNone)
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoFocusComplete();
|
||||
else {
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrOptimisedFocusComplete, aError);
|
||||
}
|
||||
}
|
||||
|
||||
TBool CCameraEngine::IsCameraReady() const
|
||||
{
|
||||
// If reserved and powered on, but not focusing or capturing
|
||||
if (iEngineState == EEngineIdle)
|
||||
return ETrue;
|
||||
|
||||
return EFalse;
|
||||
}
|
||||
|
||||
TBool CCameraEngine::IsDirectViewFinderSupported() const
|
||||
{
|
||||
if (iCameraInfo.iOptionsSupported & TCameraInfo::EViewFinderDirectSupported)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
TCameraInfo *CCameraEngine::CameraInfo()
|
||||
{
|
||||
return &iCameraInfo;
|
||||
}
|
||||
|
||||
TBool CCameraEngine::IsAutoFocusSupported() const
|
||||
{
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.1
|
||||
return (iAutoFocus) ? ETrue : EFalse;
|
||||
#else // !S60_CAM_AUTOFOCUS_SUPPORT
|
||||
return EFalse;
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
|
||||
#else // Q_CC_NOKIAX86 - Emulator
|
||||
return EFalse;
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is used for focusing in S60 3.1 platform. Platforms from S60
|
||||
* 3.2 onwards should use the focusing provided by the S60CameraSettings class.
|
||||
*/
|
||||
void CCameraEngine::StartFocusL()
|
||||
{
|
||||
if (iEngineState != EEngineIdle)
|
||||
return;
|
||||
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.1
|
||||
if (iAutoFocus) {
|
||||
if (!iAFRange) {
|
||||
iAFRange = CCamAutoFocus::ERangeNormal;
|
||||
iAutoFocus->SetFocusRangeL(iAFRange);
|
||||
}
|
||||
|
||||
iAutoFocus->AttemptOptimisedFocusL();
|
||||
iEngineState = EEngineFocusing;
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is used for cancelling focusing in S60 3.1 platform. Platforms
|
||||
* from S60 3.2 onwards should use the focusing provided by the
|
||||
* S60CameraSettings class.
|
||||
*/
|
||||
void CCameraEngine::FocusCancel()
|
||||
{
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
if (iAutoFocus) {
|
||||
iAutoFocus->Cancel();
|
||||
iEngineState = EEngineIdle;
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
void CCameraEngine::SupportedFocusRanges(TInt& aSupportedRanges) const
|
||||
{
|
||||
aSupportedRanges = 0;
|
||||
|
||||
#ifndef Q_CC_NOKIAX86 // Not Emulator
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
if (iAutoFocus) {
|
||||
// CCamAutoFocus doesn't provide a method for getting supported ranges!
|
||||
// Assume everything is supported (rather optimistic)
|
||||
aSupportedRanges = CCamAutoFocus::ERangeMacro |
|
||||
CCamAutoFocus::ERangePortrait |
|
||||
CCamAutoFocus::ERangeNormal |
|
||||
CCamAutoFocus::ERangeInfinite;
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
void CCameraEngine::SetFocusRange(TInt aFocusRange)
|
||||
{
|
||||
#if !defined(Q_CC_NOKIAX86) // Not Emulator
|
||||
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
if (iAutoFocus) {
|
||||
TRAPD(focusErr, iAutoFocus->SetFocusRangeL((CCamAutoFocus::TAutoFocusRange)aFocusRange));
|
||||
if (focusErr)
|
||||
iObserver->MceoHandleError(EErrAutoFocusRange, focusErr);
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
|
||||
#else // Q_CC_NOKIAX86 // Emulator
|
||||
Q_UNUSED(aFocusRange);
|
||||
if (iImageCaptureObserver)
|
||||
iImageCaptureObserver->MceoHandleError(EErrAutoFocusRange, KErrNotSupported);
|
||||
#endif // !Q_CC_NOKIAX86
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,407 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef S60CCAMERAENGINE_H
|
||||
#define S60CCAMERAENGINE_H
|
||||
|
||||
// INCLUDES
|
||||
#include <e32base.h>
|
||||
#include <ecam.h> // for MCameraObserver(2)
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
#include <ccamautofocus.h> // for CCamAutoFocus, MCamAutoFocusObserver
|
||||
#endif
|
||||
|
||||
// FORWARD DECLARATIONS
|
||||
class MCameraEngineObserver;
|
||||
class MCameraEngineImageCaptureObserver;
|
||||
class MAdvancedSettingsObserver;
|
||||
class MCameraViewfinderObserver;
|
||||
class MCameraPreviewObserver;
|
||||
|
||||
/*
|
||||
* CameraEngine handling ECam operations needed.
|
||||
*/
|
||||
NONSHARABLE_CLASS( CCameraEngine ) : public CBase,
|
||||
public MCameraObserver,
|
||||
public MCameraObserver2
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
,public MCamAutoFocusObserver
|
||||
#endif
|
||||
|
||||
{
|
||||
public: // Enums
|
||||
|
||||
enum TCameraEngineState
|
||||
{
|
||||
EEngineNotReady = 0, // 0 - No resources reserved
|
||||
EEngineInitializing, // 1 - Reserving and Powering On
|
||||
EEngineIdle, // 2 - Reseved and Powered On
|
||||
EEngineCapturing, // 3 - Capturing Still Image
|
||||
EEngineFocusing // 4 - Focusing
|
||||
};
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
static CCameraEngine* NewL( TInt aCameraHandle,
|
||||
TInt aPriority,
|
||||
MCameraEngineObserver* aObserver );
|
||||
~CCameraEngine();
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* External Advanced Settings callback observer.
|
||||
*/
|
||||
void SetAdvancedObserver(MAdvancedSettingsObserver *aAdvancedSettingsObserver);
|
||||
|
||||
/**
|
||||
* External Image Capture callback observer.
|
||||
*/
|
||||
void SetImageCaptureObserver(MCameraEngineImageCaptureObserver *aImageCaptureObserver);
|
||||
|
||||
/**
|
||||
* External Viewfinder callback observer.
|
||||
*/
|
||||
void SetViewfinderObserver(MCameraViewfinderObserver *aViewfinderObserver);
|
||||
|
||||
/**
|
||||
* Static function that returns the number of cameras on the device.
|
||||
*/
|
||||
static TInt CamerasAvailable();
|
||||
|
||||
/**
|
||||
* Returns the index of the currently active camera device
|
||||
*/
|
||||
TInt CurrentCameraIndex() const { return iCameraIndex; }
|
||||
|
||||
/**
|
||||
* Returns the current state (TCameraEngineState)
|
||||
* of the camera engine.
|
||||
*/
|
||||
TCameraEngineState State() const { return iEngineState; }
|
||||
|
||||
/**
|
||||
* Returns true if the camera has been reserved and
|
||||
* powered on, and not recording or capturing image
|
||||
*/
|
||||
TBool IsCameraReady() const;
|
||||
|
||||
/**
|
||||
* Returns whether DirectScreen ViewFinder is supported by the platform
|
||||
*/
|
||||
TBool IsDirectViewFinderSupported() const;
|
||||
|
||||
/**
|
||||
* Returns true if the camera supports AutoFocus.
|
||||
*/
|
||||
TBool IsAutoFocusSupported() const;
|
||||
|
||||
/**
|
||||
* Returns camera info
|
||||
*/
|
||||
TCameraInfo *CameraInfo();
|
||||
|
||||
/**
|
||||
* Captures an image. When complete, observer will receive
|
||||
* MceoCapturedDataReady() or MceoCapturedBitmapReady() callback,
|
||||
* depending on which image format was used in PrepareL().
|
||||
* @leave May leave with KErrNotReady if camera is not
|
||||
* reserved or prepared for capture.
|
||||
*/
|
||||
void CaptureL();
|
||||
|
||||
/**
|
||||
* Cancels ongoing image capture
|
||||
*/
|
||||
void CancelCapture();
|
||||
|
||||
/**
|
||||
* Reserves and powers on the camera. When complete,
|
||||
* observer will receive MceoCameraReady() callback
|
||||
*
|
||||
*/
|
||||
void ReserveAndPowerOn();
|
||||
|
||||
/**
|
||||
* Releases and powers off the camera
|
||||
*
|
||||
*/
|
||||
void ReleaseAndPowerOff();
|
||||
|
||||
/**
|
||||
* Prepares for image capture.
|
||||
* @param aCaptureSize requested capture size. On return,
|
||||
* contains the selected size (closest match)
|
||||
* @param aFormat Image format to use. Default is JPEG with
|
||||
* EXIF information as provided by the camera module
|
||||
* @leave KErrNotSupported, KErrNoMemory, KErrNotReady
|
||||
*/
|
||||
void PrepareL( TSize& aCaptureSize,
|
||||
CCamera::TFormat aFormat = CCamera::EFormatExif );
|
||||
|
||||
/**
|
||||
* Starts the viewfinder. Observer will receive
|
||||
* MceoViewFinderFrameReady() callbacks periodically.
|
||||
* @param aSize requested viewfinder size. On return,
|
||||
* contains the selected size.
|
||||
*
|
||||
* @leave KErrNotSupported is viewfinding with bitmaps is not
|
||||
* supported, KErrNotReady
|
||||
*/
|
||||
void StartViewFinderL( TSize& aSize );
|
||||
|
||||
/**
|
||||
* Stops the viewfinder if active.
|
||||
*/
|
||||
void StopViewFinder();
|
||||
|
||||
void StartDirectViewFinderL(RWsSession& aSession,
|
||||
CWsScreenDevice& aScreenDevice,
|
||||
RWindowBase& aWindow,
|
||||
TRect& aScreenRect,
|
||||
TRect& aClipRect);
|
||||
|
||||
/**
|
||||
* Releases memory for the last received viewfinder frame.
|
||||
* Client must call this in response to MceoViewFinderFrameReady()
|
||||
* callback, after drawing the viewfinder frame is complete.
|
||||
*/
|
||||
void ReleaseViewFinderBuffer();
|
||||
|
||||
/**
|
||||
* Releases memory for the last captured image.
|
||||
* Client must call this in response to MceoCapturedDataReady()
|
||||
* or MceoCapturedBitmapReady()callback, after processing the
|
||||
* data/bitmap is complete.
|
||||
*/
|
||||
void ReleaseImageBuffer();
|
||||
|
||||
/**
|
||||
* Starts focusing. Does nothing if AutoFocus is not supported.
|
||||
* When complete, observer will receive MceoFocusComplete()
|
||||
* callback.
|
||||
* @leave KErrInUse, KErrNotReady
|
||||
*/
|
||||
void StartFocusL();
|
||||
|
||||
/**
|
||||
* Cancels the ongoing focusing operation.
|
||||
*/
|
||||
void FocusCancel();
|
||||
|
||||
/**
|
||||
* Gets a bitfield of supported focus ranges.
|
||||
* @param aSupportedRanges a bitfield of either TAutoFocusRange
|
||||
* (S60 3.0/3.1 devices) or TFocusRange (S60 3.2 and onwards) values
|
||||
*/
|
||||
void SupportedFocusRanges( TInt& aSupportedRanges ) const;
|
||||
|
||||
/**
|
||||
* Sets the focus range
|
||||
* @param aFocusRange one of the values returned by
|
||||
* SupportedFocusRanges().
|
||||
*/
|
||||
void SetFocusRange( TInt aFocusRange );
|
||||
|
||||
/**
|
||||
* Returns a pointer to CCamera object used by the engine.
|
||||
* Allows getting access to additional functionality
|
||||
* from CCamera - do not use for functionality already provided
|
||||
* by CCameraEngine methods.
|
||||
*/
|
||||
CCamera* Camera() { return iCamera; }
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
/**
|
||||
* This enables the preview creation during the capture (image or video).
|
||||
*/
|
||||
void EnablePreviewProvider(MCameraPreviewObserver *aPreviewObserver);
|
||||
|
||||
/**
|
||||
* This disabled the preview creation during the capture (image or video)
|
||||
*/
|
||||
void DisablePreviewProvider();
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
protected: // Protected constructors
|
||||
|
||||
CCameraEngine();
|
||||
CCameraEngine( TInt aCameraHandle,
|
||||
TInt aPriority,
|
||||
MCameraEngineObserver* aObserver );
|
||||
void ConstructL();
|
||||
|
||||
protected: // MCameraObserver
|
||||
|
||||
/**
|
||||
* From MCameraObserver
|
||||
* Gets called when CCamera::Reserve() is completed.
|
||||
* (V2: Called internally from HandleEvent)
|
||||
*/
|
||||
virtual void ReserveComplete(TInt aError);
|
||||
|
||||
/**
|
||||
* From MCameraObserver.
|
||||
* Gets called when CCamera::PowerOn() is completed.
|
||||
* (V2: Called internally from HandleEvent)
|
||||
*/
|
||||
virtual void PowerOnComplete(TInt aError);
|
||||
|
||||
/**
|
||||
* From MCameraObserver.
|
||||
* Gets called when CCamera::StartViewFinderBitmapsL() is completed.
|
||||
* (V2: Called internally from ViewFinderReady)
|
||||
*/
|
||||
virtual void ViewFinderFrameReady( CFbsBitmap& aFrame );
|
||||
|
||||
/**
|
||||
* From MCameraObserver.
|
||||
* Gets called when CCamera::CaptureImage() is completed.
|
||||
*/
|
||||
virtual void ImageReady( CFbsBitmap* aBitmap, HBufC8* aData, TInt aError );
|
||||
|
||||
/**
|
||||
* From MCameraObserver.
|
||||
* Video capture not implemented.
|
||||
*/
|
||||
virtual void FrameBufferReady( MFrameBuffer* /*aFrameBuffer*/, TInt /*aError*/ ) {}
|
||||
|
||||
protected: // MCameraObserver2
|
||||
|
||||
/**
|
||||
* From MCameraObserver2
|
||||
* Camera event handler
|
||||
*/
|
||||
virtual void HandleEvent(const TECAMEvent &aEvent);
|
||||
|
||||
/**
|
||||
* From MCameraObserver2
|
||||
* Notifies the client of new viewfinder data
|
||||
*/
|
||||
virtual void ViewFinderReady(MCameraBuffer &aCameraBuffer, TInt aError);
|
||||
|
||||
/**
|
||||
* From MCameraObserver2
|
||||
* Notifies the client of a new captured image
|
||||
*/
|
||||
virtual void ImageBufferReady(MCameraBuffer &aCameraBuffer, TInt aError);
|
||||
|
||||
/**
|
||||
* From MCameraObserver2
|
||||
* Video capture not implemented.
|
||||
*/
|
||||
virtual void VideoBufferReady(MCameraBuffer& /*aCameraBuffer*/, TInt /*aError*/) {}
|
||||
|
||||
protected: // MCamAutoFocusObserver
|
||||
|
||||
/**
|
||||
* From MCamAutoFocusObserver.
|
||||
* Delivers notification of completion of auto focus initialisation to
|
||||
* an interested party.
|
||||
* @param aError Reason for completion of focus request.
|
||||
*/
|
||||
virtual void InitComplete( TInt aError );
|
||||
|
||||
/**
|
||||
* From MCamAutoFocusObserver.
|
||||
* Gets called when CCamAutoFocus::AttemptOptimisedFocusL() is
|
||||
* completed.
|
||||
* (V2: Called internally from HandleEvent)
|
||||
*/
|
||||
virtual void OptimisedFocusComplete( TInt aError );
|
||||
|
||||
private: // Internal functions
|
||||
|
||||
/**
|
||||
* Internal function to handle ImageReady callbacks from
|
||||
* both observer (V1 & V2) interfaces
|
||||
*/
|
||||
void HandleImageReady(const TInt aError, const bool isBitmap);
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
/**
|
||||
* Handle preview. Retrieve preview data and notify observer about the
|
||||
* preview availability.
|
||||
*/
|
||||
void HandlePreview();
|
||||
|
||||
/**
|
||||
* Calculate proper resolution for the SnapShot (Preview) image.
|
||||
*/
|
||||
TSize SelectPreviewResolution();
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
private: // Data
|
||||
|
||||
CCamera *iCamera;
|
||||
MCameraEngineObserver *iObserver;
|
||||
MCameraEngineImageCaptureObserver *iImageCaptureObserver;
|
||||
MAdvancedSettingsObserver *iAdvancedSettingsObserver;
|
||||
MCameraViewfinderObserver *iViewfinderObserver;
|
||||
MCameraPreviewObserver *iPreviewObserver;
|
||||
MCameraBuffer *iViewFinderBuffer;
|
||||
/*
|
||||
* Following pointers are for the image buffers:
|
||||
* * Makes buffering of 2 concurrent image buffers possible
|
||||
*/
|
||||
MCameraBuffer *iImageBuffer1;
|
||||
MCameraBuffer *iImageBuffer2;
|
||||
TDesC8 *iImageData1;
|
||||
TDesC8 *iImageData2;
|
||||
CFbsBitmap *iImageBitmap1;
|
||||
CFbsBitmap *iImageBitmap2;
|
||||
TInt iCameraIndex;
|
||||
TInt iPriority;
|
||||
TCameraEngineState iEngineState;
|
||||
TCameraInfo iCameraInfo;
|
||||
CCamera::TFormat iImageCaptureFormat;
|
||||
TSize iCaptureResolution;
|
||||
bool iNew2LImplementation;
|
||||
int iLatestImageBufferIndex; // 0 = Buffer1, 1 = Buffer2
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
CCamera::CCameraSnapshot *iCameraSnapshot;
|
||||
#endif // ECAM_PREVIEW_API
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT
|
||||
CCamAutoFocus* iAutoFocus;
|
||||
CCamAutoFocus::TAutoFocusRange iAFRange;
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
};
|
||||
|
||||
#endif // S60CCAMERAENGINE_H
|
||||
@@ -1,178 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef S60CCAMERAENGINEOBSERVER_H
|
||||
#define S60CCAMERAENGINEOBSERVER_H
|
||||
|
||||
// FORWARD DECLARATIONS
|
||||
class CFbsBitmap;
|
||||
class TECAMEvent;
|
||||
|
||||
enum TCameraEngineError
|
||||
{
|
||||
EErrReserve,
|
||||
EErrPowerOn,
|
||||
EErrViewFinderReady,
|
||||
EErrImageReady,
|
||||
EErrPreview,
|
||||
EErrAutoFocusInit,
|
||||
EErrAutoFocusMode,
|
||||
EErrAutoFocusArea,
|
||||
EErrAutoFocusRange,
|
||||
EErrAutoFocusType,
|
||||
EErrOptimisedFocusComplete,
|
||||
};
|
||||
|
||||
/*
|
||||
* CameraEngine Observer class towards Camera AdvancedSettings
|
||||
*/
|
||||
class MAdvancedSettingsObserver
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void HandleAdvancedEvent( const TECAMEvent &aEvent ) = 0;
|
||||
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
* CameraEngine Observer class towards Camera Control
|
||||
*/
|
||||
class MCameraEngineObserver
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Camera is ready to use for capturing images.
|
||||
*/
|
||||
virtual void MceoCameraReady() = 0;
|
||||
|
||||
/**
|
||||
* Notifies clients about errors in camera engine
|
||||
* @param aErrorType type of error (see TCameraEngineError)
|
||||
* @param aError Symbian system-wide error code
|
||||
*/
|
||||
virtual void MceoHandleError( TCameraEngineError aErrorType, TInt aError ) = 0;
|
||||
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
* CameraEngine Observer class towards Camera ImageCaptureSession
|
||||
*/
|
||||
class MCameraEngineImageCaptureObserver
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Camera AF lens has attained optimal focus
|
||||
*/
|
||||
virtual void MceoFocusComplete() = 0;
|
||||
|
||||
/**
|
||||
* Captured data is ready - call CCameraEngine::ReleaseImageBuffer()
|
||||
* after processing/saving the data (typically, JPG-encoded image)
|
||||
* @param aData Pointer to a descriptor containing a frame of camera data.
|
||||
*/
|
||||
virtual void MceoCapturedDataReady( TDesC8* aData ) = 0;
|
||||
|
||||
/**
|
||||
* Captured bitmap is ready.
|
||||
* after processing/saving the image, call
|
||||
* CCameraEngine::ReleaseImageBuffer() to free the bitmap.
|
||||
* @param aBitmap Pointer to an FBS bitmap containing a captured image.
|
||||
*/
|
||||
virtual void MceoCapturedBitmapReady( CFbsBitmap* aBitmap ) = 0;
|
||||
|
||||
/**
|
||||
* Notifies clients about errors in camera engine
|
||||
* @param aErrorType type of error (see TCameraEngineError)
|
||||
* @param aError Symbian system-wide error code
|
||||
*/
|
||||
virtual void MceoHandleError( TCameraEngineError aErrorType, TInt aError ) = 0;
|
||||
|
||||
/**
|
||||
* Notifies client about other events not recognized by camera engine.
|
||||
* The default implementation is empty.
|
||||
* @param aEvent camera event (see MCameraObserver2::HandleEvent())
|
||||
*/
|
||||
virtual void MceoHandleOtherEvent( const TECAMEvent& /*aEvent*/ ) {}
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
* CameraEngine Observer class towards Camera ViewFinderEngine
|
||||
*/
|
||||
class MCameraViewfinderObserver
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A new viewfinder frame is ready.
|
||||
* after displaying the frame, call
|
||||
* CCameraEngine::ReleaseViewFinderBuffer()
|
||||
* to free the bitmap.
|
||||
* @param aFrame Pointer to an FBS bitmap containing a viewfinder frame.
|
||||
*/
|
||||
virtual void MceoViewFinderFrameReady( CFbsBitmap& aFrame ) = 0;
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
/*
|
||||
* CameraEngine Observer class towards Camera ViewFinderEngine
|
||||
*/
|
||||
class MCameraPreviewObserver
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* A new preview is available.
|
||||
* @param aPreview Pointer to an FBS bitmap containing a preview.
|
||||
*/
|
||||
virtual void MceoPreviewReady( CFbsBitmap& aPreview ) = 0;
|
||||
};
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
#endif // CCAMERAENGINEOBSERVER_H
|
||||
|
||||
// End of file
|
||||
@@ -1,584 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60cameraexposurecontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
|
||||
S60CameraExposureControl::S60CameraExposureControl(QObject *parent) :
|
||||
QCameraExposureControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraExposureControl::S60CameraExposureControl(S60ImageCaptureSession *session, QObject *parent) :
|
||||
QCameraExposureControl(parent),
|
||||
m_session(0),
|
||||
m_service(0),
|
||||
m_advancedSettings(0),
|
||||
m_exposureMode(QCameraExposure::ExposureAuto),
|
||||
m_meteringMode(QCameraExposure::MeteringMatrix)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
connect(m_session, SIGNAL(advancedSettingChanged()), this, SLOT(resetAdvancedSetting()));
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
|
||||
if (m_advancedSettings) {
|
||||
connect(m_advancedSettings, SIGNAL(apertureChanged()), this, SLOT(apertureChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(apertureRangeChanged()), this, SLOT(apertureRangeChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(shutterSpeedChanged()), this, SLOT(shutterSpeedChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(isoSensitivityChanged()), this, SLOT(isoSensitivityChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(evChanged()), this, SLOT(evChanged()));
|
||||
}
|
||||
}
|
||||
|
||||
S60CameraExposureControl::~S60CameraExposureControl()
|
||||
{
|
||||
m_advancedSettings = 0;
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::resetAdvancedSetting()
|
||||
{
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
if (m_advancedSettings) {
|
||||
connect(m_advancedSettings, SIGNAL(apertureChanged()), this, SLOT(apertureChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(apertureRangeChanged()), this, SLOT(apertureRangeChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(shutterSpeedChanged()), this, SLOT(shutterSpeedChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(isoSensitivityChanged()), this, SLOT(isoSensitivityChanged()));
|
||||
connect(m_advancedSettings, SIGNAL(evChanged()), this, SLOT(evChanged()));
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::apertureChanged()
|
||||
{
|
||||
emit exposureParameterChanged(QCameraExposureControl::Aperture);
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::apertureRangeChanged()
|
||||
{
|
||||
emit exposureParameterRangeChanged(QCameraExposureControl::Aperture);
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::shutterSpeedChanged()
|
||||
{
|
||||
emit exposureParameterChanged(QCameraExposureControl::ShutterSpeed);
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::isoSensitivityChanged()
|
||||
{
|
||||
emit exposureParameterChanged(QCameraExposureControl::ISO);
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::evChanged()
|
||||
{
|
||||
emit exposureParameterChanged(QCameraExposureControl::ExposureCompensation);
|
||||
}
|
||||
|
||||
QCameraExposure::ExposureMode S60CameraExposureControl::exposureMode() const
|
||||
{
|
||||
return m_session->exposureMode();
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setExposureMode(QCameraExposure::ExposureMode mode)
|
||||
{
|
||||
if (isExposureModeSupported(mode)) {
|
||||
m_exposureMode = mode;
|
||||
m_session->setExposureMode(m_exposureMode);
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->setError(KErrNotSupported, tr("Requested exposure mode is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isExposureModeSupported(QCameraExposure::ExposureMode mode) const
|
||||
{
|
||||
if (m_session->isExposureModeSupported(mode))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QCameraExposure::MeteringMode S60CameraExposureControl::meteringMode() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->meteringMode();
|
||||
|
||||
return QCameraExposure::MeteringMode();
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setMeteringMode(QCameraExposure::MeteringMode mode)
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
if (isMeteringModeSupported(mode)) {
|
||||
m_meteringMode = mode;
|
||||
m_advancedSettings->setMeteringMode(mode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_session->setError(KErrNotSupported, tr("Requested metering mode is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->isMeteringModeSupported(mode);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isParameterSupported(ExposureParameter parameter) const
|
||||
{
|
||||
// Settings supported only if advanced settings available
|
||||
if (m_advancedSettings) {
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO:
|
||||
if (m_advancedSettings->supportedIsoSensitivities().count() > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposureControl::Aperture:
|
||||
if (m_advancedSettings->supportedApertures().count() > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
if (m_advancedSettings->supportedShutterSpeeds().count() > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
if (m_advancedSettings->supportedExposureCompensationValues().count() > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant S60CameraExposureControl::exposureParameter(ExposureParameter parameter) const
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO:
|
||||
return QVariant(isoSensitivity());
|
||||
case QCameraExposureControl::Aperture:
|
||||
return QVariant(aperture());
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return QVariant(shutterSpeed());
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
return QVariant(exposureCompensation());
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
// Not supported in Symbian
|
||||
return QVariant();
|
||||
|
||||
default:
|
||||
// Not supported in Symbian
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
QCameraExposureControl::ParameterFlags S60CameraExposureControl::exposureParameterFlags(ExposureParameter parameter) const
|
||||
{
|
||||
QCameraExposureControl::ParameterFlags flags;
|
||||
|
||||
/*
|
||||
* ISO, ExposureCompensation:
|
||||
* - Automatic/Manual
|
||||
* - Read/Write
|
||||
* - Discrete range
|
||||
*
|
||||
* Aperture, ShutterSpeed, FlashPower, FlashCompensation:
|
||||
* - Not supported
|
||||
*/
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO:
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
flags |= QCameraExposureControl::AutomaticValue;
|
||||
break;
|
||||
case QCameraExposureControl::Aperture:
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
// Do nothing - no flags
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do nothing - no flags
|
||||
break;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
QVariantList S60CameraExposureControl::supportedParameterRange(ExposureParameter parameter) const
|
||||
{
|
||||
QVariantList valueList;
|
||||
|
||||
if (m_advancedSettings) {
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO: {
|
||||
foreach (int iso, m_advancedSettings->supportedIsoSensitivities())
|
||||
valueList << QVariant(iso);
|
||||
break;
|
||||
}
|
||||
case QCameraExposureControl::Aperture: {
|
||||
foreach (qreal aperture, m_advancedSettings->supportedApertures())
|
||||
valueList << QVariant(aperture);
|
||||
break;
|
||||
}
|
||||
case QCameraExposureControl::ShutterSpeed: {
|
||||
foreach (qreal shutterSpeed, m_advancedSettings->supportedShutterSpeeds())
|
||||
valueList << QVariant(shutterSpeed);
|
||||
break;
|
||||
}
|
||||
case QCameraExposureControl::ExposureCompensation: {
|
||||
foreach (qreal ev, m_advancedSettings->supportedExposureCompensationValues())
|
||||
valueList << QVariant(ev);
|
||||
break;
|
||||
}
|
||||
case QCameraExposureControl::FlashPower:
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
// Not supported in Symbian
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not supported in Symbian
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return valueList;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::setExposureParameter(ExposureParameter parameter, const QVariant& value)
|
||||
{
|
||||
bool useDefaultValue = false;
|
||||
|
||||
if (value.isNull())
|
||||
useDefaultValue = true;
|
||||
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO:
|
||||
if (useDefaultValue) {
|
||||
setAutoIsoSensitivity();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return setManualIsoSensitivity(value.toInt());
|
||||
|
||||
case QCameraExposureControl::Aperture:
|
||||
if (useDefaultValue) {
|
||||
setAutoAperture();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return setManualAperture(value.toFloat());
|
||||
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
if (useDefaultValue) {
|
||||
setAutoShutterSpeed();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return setManualShutterSpeed(value.toFloat());
|
||||
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
if (useDefaultValue) {
|
||||
setAutoExposureCompensation();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return setManualExposureCompensation(value.toFloat());
|
||||
|
||||
case QCameraExposureControl::FlashPower:
|
||||
return false;
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
return false;
|
||||
|
||||
default:
|
||||
// Not supported in Symbian
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString S60CameraExposureControl::extendedParameterName(ExposureParameter parameter)
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraExposureControl::ISO:
|
||||
return QLatin1String("ISO Sensitivity");
|
||||
case QCameraExposureControl::Aperture:
|
||||
return QLatin1String("Aperture");
|
||||
case QCameraExposureControl::ShutterSpeed:
|
||||
return QLatin1String("Shutter Speed");
|
||||
case QCameraExposureControl::ExposureCompensation:
|
||||
return QLatin1String("Exposure Compensation");
|
||||
case QCameraExposureControl::FlashPower:
|
||||
return QLatin1String("Flash Power");
|
||||
case QCameraExposureControl::FlashCompensation:
|
||||
return QLatin1String("Flash Compensation");
|
||||
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
int S60CameraExposureControl::isoSensitivity() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->isoSensitivity();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isIsoSensitivitySupported(const int iso) const
|
||||
{
|
||||
if (m_advancedSettings &&
|
||||
m_advancedSettings->supportedIsoSensitivities().contains(iso))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::setManualIsoSensitivity(int iso)
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
if (isIsoSensitivitySupported(iso)) {
|
||||
m_advancedSettings->setManualIsoSensitivity(iso);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setAutoIsoSensitivity()
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->setAutoIsoSensitivity();
|
||||
}
|
||||
|
||||
qreal S60CameraExposureControl::aperture() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->aperture();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isApertureSupported(const qreal aperture) const
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
QList<qreal> supportedValues = m_advancedSettings->supportedApertures();
|
||||
if(supportedValues.indexOf(aperture) != -1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::setManualAperture(qreal aperture)
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
if (isApertureSupported(aperture)) {
|
||||
m_advancedSettings->setManualAperture(aperture);
|
||||
return true;
|
||||
} else {
|
||||
QList<qreal> supportedApertureValues = m_advancedSettings->supportedApertures();
|
||||
int minAperture = supportedApertureValues.first();
|
||||
int maxAperture = supportedApertureValues.last();
|
||||
|
||||
if (aperture < minAperture) { // Smaller than minimum
|
||||
aperture = minAperture;
|
||||
} else if (aperture > maxAperture) { // Bigger than maximum
|
||||
aperture = maxAperture;
|
||||
} else { // Find closest
|
||||
int indexOfClosest = 0;
|
||||
int smallestDiff = 100000000; // Sensible max diff
|
||||
for(int i = 0; i < supportedApertureValues.count(); ++i) {
|
||||
if((abs((aperture*100) - (supportedApertureValues[i]*100))) < smallestDiff) {
|
||||
smallestDiff = abs((aperture*100) - (supportedApertureValues[i]*100));
|
||||
indexOfClosest = i;
|
||||
}
|
||||
}
|
||||
aperture = supportedApertureValues[indexOfClosest];
|
||||
}
|
||||
m_advancedSettings->setManualAperture(aperture);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setAutoAperture()
|
||||
{
|
||||
// Not supported in Symbian
|
||||
}
|
||||
|
||||
qreal S60CameraExposureControl::shutterSpeed() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->shutterSpeed();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isShutterSpeedSupported(const qreal seconds) const
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
QList<qreal> supportedValues = m_advancedSettings->supportedShutterSpeeds();
|
||||
if(supportedValues.indexOf(seconds) != -1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::setManualShutterSpeed(qreal seconds)
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
if (isShutterSpeedSupported(seconds)) {
|
||||
m_advancedSettings->setManualShutterSpeed(seconds);
|
||||
return true;
|
||||
} else {
|
||||
QList<qreal> supportedShutterSpeeds = m_advancedSettings->supportedShutterSpeeds();
|
||||
|
||||
if (supportedShutterSpeeds.count() == 0)
|
||||
return false;
|
||||
|
||||
int minShutterSpeed = supportedShutterSpeeds.first();
|
||||
int maxShutterSpeed = supportedShutterSpeeds.last();
|
||||
|
||||
if (seconds < minShutterSpeed) { // Smaller than minimum
|
||||
seconds = minShutterSpeed;
|
||||
} else if (seconds > maxShutterSpeed) { // Bigger than maximum
|
||||
seconds = maxShutterSpeed;
|
||||
} else { // Find closest
|
||||
int indexOfClosest = 0;
|
||||
int smallestDiff = 100000000; // Sensible max diff
|
||||
for(int i = 0; i < supportedShutterSpeeds.count(); ++i) {
|
||||
if((abs((seconds*100) - (supportedShutterSpeeds[i]*100))) < smallestDiff) {
|
||||
smallestDiff = abs((seconds*100) - (supportedShutterSpeeds[i]*100));
|
||||
indexOfClosest = i;
|
||||
}
|
||||
}
|
||||
seconds = supportedShutterSpeeds[indexOfClosest];
|
||||
}
|
||||
m_advancedSettings->setManualShutterSpeed(seconds);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setAutoShutterSpeed()
|
||||
{
|
||||
// Not supported in Symbian
|
||||
}
|
||||
|
||||
qreal S60CameraExposureControl::exposureCompensation() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->exposureCompensation();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::isExposureCompensationSupported(const qreal ev) const
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
QList<qreal> supportedValues = m_advancedSettings->supportedExposureCompensationValues();
|
||||
if(supportedValues.indexOf(ev) != -1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60CameraExposureControl::setManualExposureCompensation(qreal ev)
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
if (isExposureCompensationSupported(ev)) {
|
||||
m_advancedSettings->setExposureCompensation(ev);
|
||||
return true;
|
||||
} else {
|
||||
QList<qreal> supportedEVs = m_advancedSettings->supportedExposureCompensationValues();
|
||||
|
||||
if (supportedEVs.count() == 0)
|
||||
return false;
|
||||
|
||||
int minEV = supportedEVs.first();
|
||||
int maxEV = supportedEVs.last();
|
||||
|
||||
if (ev < minEV) { // Smaller than minimum
|
||||
ev = minEV;
|
||||
} else if (ev > maxEV) { // Bigger than maximum
|
||||
ev = maxEV;
|
||||
} else { // Find closest
|
||||
int indexOfClosest = 0;
|
||||
int smallestDiff = 100000000; // Sensible max diff
|
||||
for(int i = 0; i < supportedEVs.count(); ++i) {
|
||||
if((abs((ev*100) - (supportedEVs[i]*100))) < smallestDiff) {
|
||||
smallestDiff = abs((ev*100) - (supportedEVs[i]*100));
|
||||
indexOfClosest = i;
|
||||
}
|
||||
}
|
||||
ev = supportedEVs[indexOfClosest];
|
||||
}
|
||||
m_advancedSettings->setExposureCompensation(ev);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void S60CameraExposureControl::setAutoExposureCompensation()
|
||||
{
|
||||
// Not supported in Symbian
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,138 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERAEXPOSURECONTROL_H
|
||||
#define S60CAMERAEXPOSURECONTROL_H
|
||||
|
||||
#include <qcameraexposurecontrol.h>
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for exposure related camera operation.
|
||||
*/
|
||||
class S60CameraExposureControl : public QCameraExposureControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60CameraExposureControl(QObject *parent = 0);
|
||||
S60CameraExposureControl(S60ImageCaptureSession *session, QObject *parent = 0);
|
||||
~S60CameraExposureControl();
|
||||
|
||||
public: // QCameraExposureControl
|
||||
|
||||
// Exposure Mode
|
||||
QCameraExposure::ExposureMode exposureMode() const;
|
||||
void setExposureMode(QCameraExposure::ExposureMode mode);
|
||||
bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const;
|
||||
|
||||
// Metering Mode
|
||||
QCameraExposure::MeteringMode meteringMode() const;
|
||||
void setMeteringMode(QCameraExposure::MeteringMode mode);
|
||||
bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const;
|
||||
|
||||
// Exposure Parameter
|
||||
bool isParameterSupported(ExposureParameter parameter) const;
|
||||
QVariant exposureParameter(ExposureParameter parameter) const;
|
||||
QCameraExposureControl::ParameterFlags exposureParameterFlags(ExposureParameter parameter) const;
|
||||
QVariantList supportedParameterRange(ExposureParameter parameter) const;
|
||||
bool setExposureParameter(ExposureParameter parameter, const QVariant& value);
|
||||
|
||||
QString extendedParameterName(ExposureParameter parameter);
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QCameraExposureControl
|
||||
void exposureParameterChanged(int parameter);
|
||||
void exposureParameterRangeChanged(int parameter);
|
||||
*/
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void resetAdvancedSetting();
|
||||
void apertureChanged();
|
||||
void apertureRangeChanged();
|
||||
void shutterSpeedChanged();
|
||||
void isoSensitivityChanged();
|
||||
void evChanged();
|
||||
|
||||
private: // Internal - Implementing ExposureParameter
|
||||
|
||||
// ISO Sensitivity
|
||||
int isoSensitivity() const;
|
||||
bool setManualIsoSensitivity(int iso);
|
||||
void setAutoIsoSensitivity();
|
||||
bool isIsoSensitivitySupported(const int iso) const;
|
||||
|
||||
// Aperture
|
||||
qreal aperture() const;
|
||||
bool setManualAperture(qreal aperture);
|
||||
void setAutoAperture();
|
||||
bool isApertureSupported(const qreal aperture) const;
|
||||
|
||||
// Shutter Speed
|
||||
qreal shutterSpeed() const;
|
||||
bool setManualShutterSpeed(qreal seconds);
|
||||
void setAutoShutterSpeed();
|
||||
bool isShutterSpeedSupported(const qreal seconds) const;
|
||||
|
||||
// Exposure Compensation
|
||||
qreal exposureCompensation() const;
|
||||
bool setManualExposureCompensation(qreal ev);
|
||||
void setAutoExposureCompensation();
|
||||
bool isExposureCompensationSupported(const qreal ev) const;
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
QCameraExposure::ExposureMode m_exposureMode;
|
||||
QCameraExposure::MeteringMode m_meteringMode;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAEXPOSURECONTROL_H
|
||||
@@ -1,109 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60cameraflashcontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
|
||||
S60CameraFlashControl::S60CameraFlashControl(QObject *parent) :
|
||||
QCameraFlashControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraFlashControl::S60CameraFlashControl(S60ImageCaptureSession *session, QObject *parent) :
|
||||
QCameraFlashControl(parent),
|
||||
m_session(0),
|
||||
m_service(0),
|
||||
m_advancedSettings(0),
|
||||
m_flashMode(QCameraExposure::FlashOff)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
connect(m_session, SIGNAL(advancedSettingChanged()), this, SLOT(resetAdvancedSetting()));
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
|
||||
if (m_advancedSettings)
|
||||
connect(m_advancedSettings, SIGNAL(flashReady(bool)), this, SIGNAL(flashReady(bool)));
|
||||
}
|
||||
|
||||
S60CameraFlashControl::~S60CameraFlashControl()
|
||||
{
|
||||
m_advancedSettings = 0;
|
||||
}
|
||||
|
||||
void S60CameraFlashControl::resetAdvancedSetting()
|
||||
{
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
if (m_advancedSettings)
|
||||
connect(m_advancedSettings, SIGNAL(flashReady(bool)), this, SIGNAL(flashReady(bool)));
|
||||
}
|
||||
|
||||
QCameraExposure::FlashModes S60CameraFlashControl::flashMode() const
|
||||
{
|
||||
return m_session->flashMode();
|
||||
}
|
||||
|
||||
void S60CameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode)
|
||||
{
|
||||
if (isFlashModeSupported(mode)) {
|
||||
m_flashMode = mode;
|
||||
m_session->setFlashMode(m_flashMode);
|
||||
}
|
||||
else
|
||||
m_session->setError(KErrNotSupported, tr("Requested flash mode is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const
|
||||
{
|
||||
return m_session->supportedFlashModes() & mode;
|
||||
}
|
||||
|
||||
bool S60CameraFlashControl::isFlashReady() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->isFlashReady();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,93 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERAFLASHCONTROL_H
|
||||
#define S60CAMERAFLASHCONTROL_H
|
||||
|
||||
#include <qcameraflashcontrol.h>
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* Control to setup Flash related camera settings.
|
||||
*/
|
||||
class S60CameraFlashControl : public QCameraFlashControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60CameraFlashControl(QObject *parent = 0);
|
||||
S60CameraFlashControl(S60ImageCaptureSession *session, QObject *parent = 0);
|
||||
~S60CameraFlashControl();
|
||||
|
||||
public: // QCameraExposureControl
|
||||
|
||||
// Flash Mode
|
||||
QCameraExposure::FlashModes flashMode() const;
|
||||
void setFlashMode(QCameraExposure::FlashModes mode);
|
||||
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const;
|
||||
|
||||
bool isFlashReady() const;
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QCameraExposureControl
|
||||
void flashReady(bool);
|
||||
*/
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void resetAdvancedSetting();
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
QCameraExposure::FlashModes m_flashMode;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAFLASHCONTROL_H
|
||||
@@ -1,193 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60camerafocuscontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
S60CameraFocusControl::S60CameraFocusControl(QObject *parent) :
|
||||
QCameraFocusControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraFocusControl::S60CameraFocusControl(S60ImageCaptureSession *session, QObject *parent) :
|
||||
QCameraFocusControl(parent),
|
||||
m_session(0),
|
||||
m_service(0),
|
||||
m_advancedSettings(0),
|
||||
m_isFocusLocked(false),
|
||||
m_opticalZoomValue(KDefaultOpticalZoom),
|
||||
m_digitalZoomValue(KDefaultDigitalZoom),
|
||||
m_focusMode(KDefaultFocusMode)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
connect(m_session, SIGNAL(advancedSettingChanged()), this, SLOT(resetAdvancedSetting()));
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
|
||||
TRAPD(err, m_session->doSetZoomFactorL(m_opticalZoomValue, m_digitalZoomValue));
|
||||
if (err)
|
||||
m_session->setError(KErrNotSupported, tr("Setting default zoom factors failed."));
|
||||
}
|
||||
|
||||
S60CameraFocusControl::~S60CameraFocusControl()
|
||||
{
|
||||
}
|
||||
|
||||
QCameraFocus::FocusMode S60CameraFocusControl::focusMode() const
|
||||
{
|
||||
return m_focusMode;
|
||||
}
|
||||
|
||||
void S60CameraFocusControl::setFocusMode(QCameraFocus::FocusMode mode)
|
||||
{
|
||||
if (isFocusModeSupported(mode)) {
|
||||
// FocusMode and FocusRange are set. Focusing is triggered by setting
|
||||
// the corresponding FocusType active by calling searchAndLock in LocksControl.
|
||||
m_focusMode = mode;
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->setFocusMode(m_focusMode);
|
||||
else
|
||||
m_session->setError(KErrGeneral, tr("Unable to set focus mode before camera is started."));
|
||||
} else {
|
||||
m_session->setError(KErrNotSupported, tr("Requested focus mode is not supported."));
|
||||
}
|
||||
}
|
||||
|
||||
bool S60CameraFocusControl::isFocusModeSupported(QCameraFocus::FocusMode mode) const
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
return m_advancedSettings->supportedFocusModes() & mode;
|
||||
} else {
|
||||
if (mode == QCameraFocus::AutoFocus)
|
||||
return m_session->isFocusSupported();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal S60CameraFocusControl::maximumOpticalZoom() const
|
||||
{
|
||||
return m_session->maximumZoom();
|
||||
}
|
||||
|
||||
qreal S60CameraFocusControl::maximumDigitalZoom() const
|
||||
{
|
||||
return m_session->maxDigitalZoom();
|
||||
}
|
||||
|
||||
qreal S60CameraFocusControl::opticalZoom() const
|
||||
{
|
||||
return m_session->opticalZoomFactor();
|
||||
}
|
||||
|
||||
qreal S60CameraFocusControl::digitalZoom() const
|
||||
{
|
||||
return m_session->digitalZoomFactor();
|
||||
}
|
||||
|
||||
void S60CameraFocusControl::zoomTo(qreal optical, qreal digital)
|
||||
{
|
||||
TRAPD(err, m_session->doSetZoomFactorL(optical, digital));
|
||||
if (err)
|
||||
m_session->setError(KErrNotSupported, tr("Requested zoom factor is not supported."));
|
||||
|
||||
// Query new values
|
||||
if (m_opticalZoomValue != m_session->opticalZoomFactor()) {
|
||||
m_opticalZoomValue = m_session->opticalZoomFactor();
|
||||
emit opticalZoomChanged(m_opticalZoomValue);
|
||||
}
|
||||
if (m_digitalZoomValue != m_session->digitalZoomFactor()) {
|
||||
m_digitalZoomValue = m_session->digitalZoomFactor();
|
||||
emit digitalZoomChanged(m_digitalZoomValue);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraFocusControl::resetAdvancedSetting()
|
||||
{
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
}
|
||||
|
||||
QCameraFocus::FocusPointMode S60CameraFocusControl::focusPointMode() const
|
||||
{
|
||||
// Not supported in Symbian
|
||||
return QCameraFocus::FocusPointAuto;
|
||||
}
|
||||
|
||||
void S60CameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode)
|
||||
{
|
||||
if (mode != QCameraFocus::FocusPointAuto)
|
||||
m_session->setError(KErrNotSupported, tr("Requested focus point mode is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
|
||||
{
|
||||
// Not supported in Symbian
|
||||
if (mode == QCameraFocus::FocusPointAuto)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
QPointF S60CameraFocusControl::customFocusPoint() const
|
||||
{
|
||||
// Not supported in Symbian, return image center
|
||||
return QPointF(0.5, 0.5);
|
||||
}
|
||||
|
||||
void S60CameraFocusControl::setCustomFocusPoint(const QPointF &point)
|
||||
{
|
||||
// Not supported in Symbian
|
||||
Q_UNUSED(point);
|
||||
m_session->setError(KErrNotSupported, tr("Setting custom focus point is not supported."));
|
||||
}
|
||||
|
||||
QCameraFocusZoneList S60CameraFocusControl::focusZones() const
|
||||
{
|
||||
// Not supported in Symbian
|
||||
return QCameraFocusZoneList(); // Return empty list
|
||||
}
|
||||
|
||||
// End of file
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERAFOCUSCONTROL_H
|
||||
#define S60CAMERAFOCUSCONTROL_H
|
||||
|
||||
#include <qcamerafocuscontrol.h>
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for focusing related operations (inc. zooming)
|
||||
*/
|
||||
class S60CameraFocusControl : public QCameraFocusControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60CameraFocusControl(QObject *parent = 0);
|
||||
S60CameraFocusControl(S60ImageCaptureSession *session, QObject *parent = 0);
|
||||
~S60CameraFocusControl();
|
||||
|
||||
public: // QCameraFocusControl
|
||||
|
||||
// Focus Mode
|
||||
QCameraFocus::FocusMode focusMode() const;
|
||||
void setFocusMode(QCameraFocus::FocusMode mode);
|
||||
bool isFocusModeSupported(QCameraFocus::FocusMode) const;
|
||||
|
||||
// Zoom
|
||||
qreal maximumOpticalZoom() const;
|
||||
qreal maximumDigitalZoom() const;
|
||||
qreal opticalZoom() const;
|
||||
qreal digitalZoom() const;
|
||||
|
||||
void zoomTo(qreal optical, qreal digital);
|
||||
|
||||
// Focus Point
|
||||
QCameraFocus::FocusPointMode focusPointMode() const;
|
||||
void setFocusPointMode(QCameraFocus::FocusPointMode mode);
|
||||
bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const;
|
||||
QPointF customFocusPoint() const;
|
||||
void setCustomFocusPoint(const QPointF &point);
|
||||
|
||||
QCameraFocusZoneList focusZones() const;
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QCameraFocusControl
|
||||
void opticalZoomChanged(qreal opticalZoom);
|
||||
void digitalZoomChanged(qreal digitalZoom);
|
||||
void focusZonesChanged();
|
||||
*/
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void resetAdvancedSetting();
|
||||
|
||||
private: // Data
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
bool m_isFocusLocked;
|
||||
qreal m_opticalZoomValue;
|
||||
qreal m_digitalZoomValue;
|
||||
QCameraFocus::FocusMode m_focusMode;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAFOCUSCONTROL_H
|
||||
@@ -1,124 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60cameraimagecapturecontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
#include "s60cameracontrol.h"
|
||||
|
||||
S60CameraImageCaptureControl::S60CameraImageCaptureControl(QObject *parent) :
|
||||
QCameraImageCaptureControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraImageCaptureControl::S60CameraImageCaptureControl(S60CameraService *service,
|
||||
S60ImageCaptureSession *session,
|
||||
QObject *parent) :
|
||||
QCameraImageCaptureControl(parent),
|
||||
m_driveMode(QCameraImageCapture::SingleImageCapture) // Default DriveMode
|
||||
{
|
||||
m_session = session;
|
||||
m_service = service;
|
||||
m_cameraControl = qobject_cast<S60CameraControl *>(m_service->requestControl(QCameraControl_iid));
|
||||
|
||||
if (!m_cameraControl)
|
||||
m_session->setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
|
||||
// Chain these signals from session class
|
||||
connect(m_session, SIGNAL(imageCaptured(const int, QImage)),
|
||||
this, SIGNAL(imageCaptured(const int, QImage)));
|
||||
connect(m_session, SIGNAL(readyForCaptureChanged(bool)),
|
||||
this, SIGNAL(readyForCaptureChanged(bool)), Qt::QueuedConnection);
|
||||
connect(m_session, SIGNAL(imageSaved(const int, const QString&)),
|
||||
this, SIGNAL(imageSaved(const int, const QString&)));
|
||||
connect(m_session, SIGNAL(imageExposed(int)),
|
||||
this, SIGNAL(imageExposed(int)));
|
||||
connect(m_session, SIGNAL(captureError(int, int, const QString&)),
|
||||
this, SIGNAL(error(int, int, const QString&)));
|
||||
}
|
||||
|
||||
S60CameraImageCaptureControl::~S60CameraImageCaptureControl()
|
||||
{
|
||||
}
|
||||
|
||||
bool S60CameraImageCaptureControl::isReadyForCapture() const
|
||||
{
|
||||
if (m_cameraControl && m_cameraControl->captureMode() != QCamera::CaptureStillImage)
|
||||
return false;
|
||||
|
||||
return m_session->isDeviceReady();
|
||||
}
|
||||
|
||||
QCameraImageCapture::DriveMode S60CameraImageCaptureControl::driveMode() const
|
||||
{
|
||||
return m_driveMode;
|
||||
}
|
||||
|
||||
void S60CameraImageCaptureControl::setDriveMode(QCameraImageCapture::DriveMode mode)
|
||||
{
|
||||
if (mode != QCameraImageCapture::SingleImageCapture) {
|
||||
emit error((m_session->currentImageId() + 1), QCamera::NotSupportedFeatureError, tr("DriveMode not supported."));
|
||||
return;
|
||||
}
|
||||
|
||||
m_driveMode = mode;
|
||||
}
|
||||
|
||||
int S60CameraImageCaptureControl::capture(const QString &fileName)
|
||||
{
|
||||
if (m_cameraControl && m_cameraControl->captureMode() != QCamera::CaptureStillImage) {
|
||||
emit error((m_session->currentImageId() + 1), QCameraImageCapture::NotReadyError, tr("Incorrect CaptureMode."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int imageId = m_session->capture(fileName);
|
||||
|
||||
return imageId;
|
||||
}
|
||||
|
||||
void S60CameraImageCaptureControl::cancelCapture()
|
||||
{
|
||||
m_session->cancelCapture();
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,99 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERAIMAGECAPTURECONTROL_H
|
||||
#define S60CAMERAIMAGECAPTURECONTROL_H
|
||||
|
||||
#include "qcameraimagecapturecontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
class S60CameraControl;
|
||||
|
||||
/*
|
||||
* Control for image capture operations.
|
||||
*/
|
||||
class S60CameraImageCaptureControl : public QCameraImageCaptureControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destrcutor
|
||||
|
||||
S60CameraImageCaptureControl(QObject *parent = 0);
|
||||
S60CameraImageCaptureControl(S60CameraService *service,
|
||||
S60ImageCaptureSession *session,
|
||||
QObject *parent = 0);
|
||||
~S60CameraImageCaptureControl();
|
||||
|
||||
public: // QCameraImageCaptureControl
|
||||
|
||||
bool isReadyForCapture() const;
|
||||
|
||||
// Drive Mode
|
||||
QCameraImageCapture::DriveMode driveMode() const;
|
||||
void setDriveMode(QCameraImageCapture::DriveMode mode);
|
||||
|
||||
// Capture
|
||||
int capture(const QString &fileName);
|
||||
void cancelCapture();
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QCameraImageCaptureControl
|
||||
void readyForCaptureChanged(bool);
|
||||
|
||||
void imageExposed(int id);
|
||||
void imageCaptured(int id, const QImage &preview);
|
||||
void imageSaved(int id, const QString &fileName);
|
||||
|
||||
void error(int id, int error, const QString &errorString);
|
||||
*/
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraControl *m_cameraControl;
|
||||
QCameraImageCapture::DriveMode m_driveMode;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAIMAGECAPTURECONTROL_H
|
||||
@@ -1,254 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60cameraimageprocessingcontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
|
||||
S60CameraImageProcessingControl::S60CameraImageProcessingControl(QObject *parent) :
|
||||
QCameraImageProcessingControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraImageProcessingControl::S60CameraImageProcessingControl(S60ImageCaptureSession *session, QObject *parent) :
|
||||
QCameraImageProcessingControl(parent),
|
||||
m_session(0),
|
||||
m_advancedSettings(0)
|
||||
{
|
||||
m_session = session;
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
}
|
||||
|
||||
S60CameraImageProcessingControl::~S60CameraImageProcessingControl()
|
||||
{
|
||||
m_advancedSettings = 0;
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::resetAdvancedSetting()
|
||||
{
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
}
|
||||
|
||||
QCameraImageProcessing::WhiteBalanceMode S60CameraImageProcessingControl::whiteBalanceMode() const
|
||||
{
|
||||
return m_session->whiteBalanceMode();
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode)
|
||||
{
|
||||
if (isWhiteBalanceModeSupported(mode))
|
||||
m_session->setWhiteBalanceMode(mode);
|
||||
else
|
||||
m_session->setError(KErrNotSupported, tr("Requested white balance mode is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraImageProcessingControl::isWhiteBalanceModeSupported(
|
||||
QCameraImageProcessing::WhiteBalanceMode mode) const
|
||||
{
|
||||
return m_session->isWhiteBalanceModeSupported(mode);
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::manualWhiteBalance() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setManualWhiteBalance(int colorTemperature)
|
||||
{
|
||||
m_session->setError(KErrNotSupported, tr("Setting manual white balance is not supported."));
|
||||
Q_UNUSED(colorTemperature)
|
||||
}
|
||||
|
||||
bool S60CameraImageProcessingControl::isProcessingParameterSupported(ProcessingParameter parameter) const
|
||||
{
|
||||
// First check settings requiring Adv. Settings
|
||||
if (m_advancedSettings) {
|
||||
switch (parameter) {
|
||||
case QCameraImageProcessingControl::Saturation:
|
||||
return true;
|
||||
case QCameraImageProcessingControl::Sharpening:
|
||||
return isSharpeningSupported();
|
||||
case QCameraImageProcessingControl::Denoising:
|
||||
return isDenoisingSupported();
|
||||
case QCameraImageProcessingControl::ColorTemperature:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Then the rest
|
||||
switch (parameter) {
|
||||
case QCameraImageProcessingControl::Contrast:
|
||||
case QCameraImageProcessingControl::Brightness:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant S60CameraImageProcessingControl::processingParameter(
|
||||
QCameraImageProcessingControl::ProcessingParameter parameter) const
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraImageProcessingControl::Contrast:
|
||||
return QVariant(contrast());
|
||||
case QCameraImageProcessingControl::Saturation:
|
||||
return QVariant(saturation());
|
||||
case QCameraImageProcessingControl::Brightness:
|
||||
return QVariant(brightness());
|
||||
case QCameraImageProcessingControl::Sharpening:
|
||||
return QVariant(sharpeningLevel());
|
||||
case QCameraImageProcessingControl::Denoising:
|
||||
return QVariant(denoisingLevel());
|
||||
case QCameraImageProcessingControl::ColorTemperature:
|
||||
return QVariant(manualWhiteBalance());
|
||||
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setProcessingParameter(
|
||||
QCameraImageProcessingControl::ProcessingParameter parameter, QVariant value)
|
||||
{
|
||||
switch (parameter) {
|
||||
case QCameraImageProcessingControl::Contrast:
|
||||
setContrast(value.toInt());
|
||||
break;
|
||||
case QCameraImageProcessingControl::Saturation:
|
||||
setSaturation(value.toInt());
|
||||
break;
|
||||
case QCameraImageProcessingControl::Brightness:
|
||||
setBrightness(value.toInt());
|
||||
break;
|
||||
case QCameraImageProcessingControl::Sharpening:
|
||||
if (isSharpeningSupported())
|
||||
setSharpeningLevel(value.toInt());
|
||||
break;
|
||||
case QCameraImageProcessingControl::Denoising:
|
||||
if (isDenoisingSupported())
|
||||
setDenoisingLevel(value.toInt());
|
||||
break;
|
||||
case QCameraImageProcessingControl::ColorTemperature:
|
||||
setManualWhiteBalance(value.toInt());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setContrast(int value)
|
||||
{
|
||||
m_session->setContrast(value);
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::contrast() const
|
||||
{
|
||||
return m_session->contrast();
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setBrightness(int value)
|
||||
{
|
||||
m_session->setBrightness(value);
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::brightness() const
|
||||
{
|
||||
return m_session->brightness();
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setSaturation(int value)
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->setSaturation(value);
|
||||
else
|
||||
m_session->setError(KErrNotSupported, tr("Setting saturation is not supported."));
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::saturation() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->saturation();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setDenoisingLevel(int value)
|
||||
{
|
||||
m_session->setError(KErrNotSupported, tr("Setting denoising level is not supported."));
|
||||
Q_UNUSED(value); // Not supported for Symbian
|
||||
}
|
||||
|
||||
bool S60CameraImageProcessingControl::isDenoisingSupported() const
|
||||
{
|
||||
return false; // Not supported for Symbian
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::denoisingLevel() const
|
||||
{
|
||||
return 0; // Not supported for Symbian
|
||||
}
|
||||
|
||||
void S60CameraImageProcessingControl::setSharpeningLevel(int value)
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->setSharpeningLevel(value);
|
||||
else
|
||||
m_session->setError(KErrNotSupported, tr("Setting sharpening level is not supported."));
|
||||
}
|
||||
|
||||
bool S60CameraImageProcessingControl::isSharpeningSupported() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->isSharpeningSupported();
|
||||
return false;
|
||||
}
|
||||
|
||||
int S60CameraImageProcessingControl::sharpeningLevel() const
|
||||
{
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->sharpeningLevel();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,118 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERAIMAGEPROCESSINGCONTROL_H
|
||||
#define S60CAMERAIMAGEPROCESSINGCONTROL_H
|
||||
|
||||
#include <qcameraimageprocessing.h>
|
||||
#include <qcameraimageprocessingcontrol.h>
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for image processing related camera operations (inc. white balance).
|
||||
*/
|
||||
class S60CameraImageProcessingControl : public QCameraImageProcessingControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60CameraImageProcessingControl(QObject *parent = 0);
|
||||
S60CameraImageProcessingControl(S60ImageCaptureSession *session, QObject *parent = 0);
|
||||
~S60CameraImageProcessingControl();
|
||||
|
||||
public: // QCameraImageProcessingControl
|
||||
|
||||
// White Balance
|
||||
QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const;
|
||||
void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode);
|
||||
bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const;
|
||||
|
||||
// Processing Parameter
|
||||
bool isProcessingParameterSupported(ProcessingParameter parameter) const;
|
||||
QVariant processingParameter(QCameraImageProcessingControl::ProcessingParameter parameter) const;
|
||||
void setProcessingParameter(QCameraImageProcessingControl::ProcessingParameter parameter, QVariant value);
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void resetAdvancedSetting();
|
||||
|
||||
private: // Internal operations - Implementing ProcessingParameter
|
||||
|
||||
// Manual White Balance (Color Temperature)
|
||||
int manualWhiteBalance() const;
|
||||
void setManualWhiteBalance(int colorTemperature);
|
||||
|
||||
// Contrast
|
||||
int contrast() const;
|
||||
void setContrast(int value);
|
||||
|
||||
// Brightness
|
||||
int brightness() const;
|
||||
void setBrightness(int value);
|
||||
|
||||
// Saturation
|
||||
int saturation() const;
|
||||
void setSaturation(int value);
|
||||
|
||||
// Sharpening
|
||||
bool isSharpeningSupported() const;
|
||||
int sharpeningLevel() const;
|
||||
void setSharpeningLevel(int value);
|
||||
|
||||
// Denoising
|
||||
bool isDenoisingSupported() const;
|
||||
int denoisingLevel() const;
|
||||
void setDenoisingLevel(int value);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAIMAGEPROCESSINGCONTROL_H
|
||||
@@ -1,263 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <qcamerafocus.h> // FocusMode
|
||||
|
||||
#include "s60cameralockscontrol.h"
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
#include "s60camerasettings.h"
|
||||
#include "s60camerafocuscontrol.h"
|
||||
|
||||
S60CameraLocksControl::S60CameraLocksControl(QObject *parent) :
|
||||
QCameraLocksControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraLocksControl::S60CameraLocksControl(S60CameraService *service,
|
||||
S60ImageCaptureSession *session,
|
||||
QObject *parent) :
|
||||
QCameraLocksControl(parent),
|
||||
m_session(0),
|
||||
m_service(0),
|
||||
m_advancedSettings(0),
|
||||
m_focusControl(0),
|
||||
m_focusStatus(QCamera::Unlocked),
|
||||
m_exposureStatus(QCamera::Unlocked),
|
||||
m_whiteBalanceStatus(QCamera::Unlocked)
|
||||
{
|
||||
m_session = session;
|
||||
m_service = service;
|
||||
m_focusControl = qobject_cast<S60CameraFocusControl *>(m_service->requestControl(QCameraFocusControl_iid));
|
||||
|
||||
connect(m_session, SIGNAL(advancedSettingChanged()), this, SLOT(resetAdvancedSetting()));
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
|
||||
// Exposure Lock Signals
|
||||
if (m_advancedSettings)
|
||||
connect(m_advancedSettings, SIGNAL(exposureStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)),
|
||||
this, SLOT(exposureStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
|
||||
|
||||
// Focus Lock Signal
|
||||
// * S60 3.2 and later (through Adv. Settings)
|
||||
if (m_advancedSettings)
|
||||
connect(m_advancedSettings, SIGNAL(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)),
|
||||
this, SLOT(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
|
||||
// * S60 3.1 (through ImageSession)
|
||||
connect(m_session, SIGNAL(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)),
|
||||
this, SLOT(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
|
||||
}
|
||||
|
||||
S60CameraLocksControl::~S60CameraLocksControl()
|
||||
{
|
||||
m_advancedSettings = 0;
|
||||
}
|
||||
|
||||
QCamera::LockTypes S60CameraLocksControl::supportedLocks() const
|
||||
{
|
||||
QCamera::LockTypes supportedLocks = 0;
|
||||
|
||||
#ifdef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.1
|
||||
if (m_session)
|
||||
if (m_session->isFocusSupported())
|
||||
supportedLocks |= QCamera::LockFocus;
|
||||
#else // S60 3.2 and later
|
||||
if (m_advancedSettings) {
|
||||
QCameraFocus::FocusModes supportedFocusModes = m_advancedSettings->supportedFocusModes();
|
||||
if (supportedFocusModes & QCameraFocus::AutoFocus)
|
||||
supportedLocks |= QCamera::LockFocus;
|
||||
|
||||
// Exposure/WhiteBalance Locking not implemented in Symbian
|
||||
// supportedLocks |= QCamera::LockExposure;
|
||||
// supportedLocks |= QCamera::LockWhiteBalance;
|
||||
}
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
|
||||
return supportedLocks;
|
||||
}
|
||||
|
||||
QCamera::LockStatus S60CameraLocksControl::lockStatus(QCamera::LockType lock) const
|
||||
{
|
||||
switch (lock) {
|
||||
case QCamera::LockExposure:
|
||||
return m_exposureStatus;
|
||||
case QCamera::LockWhiteBalance:
|
||||
return m_whiteBalanceStatus;
|
||||
case QCamera::LockFocus:
|
||||
return m_focusStatus;
|
||||
|
||||
default:
|
||||
// Unsupported lock
|
||||
return QCamera::Unlocked;
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::searchAndLock(QCamera::LockTypes locks)
|
||||
{
|
||||
if (locks & QCamera::LockExposure) {
|
||||
// Not implemented in Symbian
|
||||
//startExposureLocking();
|
||||
}
|
||||
if (locks & QCamera::LockWhiteBalance) {
|
||||
// Not implemented in Symbian
|
||||
}
|
||||
if (locks & QCamera::LockFocus)
|
||||
startFocusing();
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::unlock(QCamera::LockTypes locks)
|
||||
{
|
||||
if (locks & QCamera::LockExposure) {
|
||||
// Not implemented in Symbian
|
||||
//cancelExposureLocking();
|
||||
}
|
||||
|
||||
if (locks & QCamera::LockFocus)
|
||||
cancelFocusing();
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::resetAdvancedSetting()
|
||||
{
|
||||
m_advancedSettings = m_session->advancedSettings();
|
||||
|
||||
// Reconnect Lock Signals
|
||||
if (m_advancedSettings) {
|
||||
connect(m_advancedSettings, SIGNAL(exposureStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)),
|
||||
this, SLOT(exposureStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
|
||||
connect(m_advancedSettings, SIGNAL(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)),
|
||||
this, SLOT(focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)));
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::exposureStatusChanged(QCamera::LockStatus status,
|
||||
QCamera::LockChangeReason reason)
|
||||
{
|
||||
if(status != m_exposureStatus) {
|
||||
m_exposureStatus = status;
|
||||
emit lockStatusChanged(QCamera::LockExposure, status, reason);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::focusStatusChanged(QCamera::LockStatus status,
|
||||
QCamera::LockChangeReason reason)
|
||||
{
|
||||
if(status != m_focusStatus) {
|
||||
m_focusStatus = status;
|
||||
emit lockStatusChanged(QCamera::LockFocus, status, reason);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::startFocusing()
|
||||
{
|
||||
#ifndef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.2 or later
|
||||
// Focusing is triggered on Symbian by setting the FocusType corresponding
|
||||
// to the FocusMode set to FocusControl
|
||||
if (m_focusControl) {
|
||||
if (m_advancedSettings) {
|
||||
m_advancedSettings->startFocusing();
|
||||
m_focusStatus = QCamera::Searching;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
|
||||
#else // S60 3.1
|
||||
if (m_focusControl && m_focusControl->focusMode() == QCameraFocus::AutoFocus) {
|
||||
m_session->startFocus();
|
||||
m_focusStatus = QCamera::Searching;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Searching, QCamera::UserRequest);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::cancelFocusing()
|
||||
{
|
||||
if (m_focusStatus == QCamera::Unlocked)
|
||||
return;
|
||||
|
||||
#ifndef S60_CAM_AUTOFOCUS_SUPPORT // S60 3.2 or later
|
||||
if (m_advancedSettings) {
|
||||
m_advancedSettings->cancelFocusing();
|
||||
m_focusStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::LockFailed);
|
||||
|
||||
#else // S60 3.1
|
||||
m_session->cancelFocus();
|
||||
m_focusStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockFocus, QCamera::Unlocked, QCamera::UserRequest);
|
||||
#endif // S60_CAM_AUTOFOCUS_SUPPORT
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::startExposureLocking()
|
||||
{
|
||||
if (m_advancedSettings) {
|
||||
m_advancedSettings->lockExposure(true);
|
||||
m_exposureStatus = QCamera::Searching;
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Searching, QCamera::UserRequest);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::LockFailed);
|
||||
}
|
||||
|
||||
void S60CameraLocksControl::cancelExposureLocking()
|
||||
{
|
||||
if (m_exposureStatus == QCamera::Unlocked)
|
||||
return;
|
||||
|
||||
if (m_advancedSettings) {
|
||||
m_advancedSettings->lockExposure(false);
|
||||
m_exposureStatus = QCamera::Unlocked;
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::UserRequest);
|
||||
}
|
||||
else
|
||||
emit lockStatusChanged(QCamera::LockExposure, QCamera::Unlocked, QCamera::LockFailed);
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERALOCKSCONTROL_H
|
||||
#define S60CAMERALOCKSCONTROL_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include "qcameralockscontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class S60ImageCaptureSession;
|
||||
class S60CameraSettings;
|
||||
class S60CameraFocusControl;
|
||||
|
||||
/*
|
||||
* Control for searching and locking 3A algorithms (AutoFocus, AutoExposure
|
||||
* and AutoWhitebalance).
|
||||
*/
|
||||
class S60CameraLocksControl : public QCameraLocksControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destrcutor
|
||||
|
||||
S60CameraLocksControl(QObject *parent = 0);
|
||||
S60CameraLocksControl(S60CameraService *service,
|
||||
S60ImageCaptureSession *session,
|
||||
QObject *parent = 0);
|
||||
~S60CameraLocksControl();
|
||||
|
||||
public: // QCameraLocksControl
|
||||
|
||||
QCamera::LockTypes supportedLocks() const;
|
||||
|
||||
QCamera::LockStatus lockStatus(QCamera::LockType lock) const;
|
||||
|
||||
void searchAndLock(QCamera::LockTypes locks);
|
||||
void unlock(QCamera::LockTypes locks);
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QCameraLocksControl
|
||||
|
||||
void lockStatusChanged(QCamera::LockType type,
|
||||
QCamera::LockStatus status,
|
||||
QCamera::LockChangeReason reason);
|
||||
*/
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void exposureStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason);
|
||||
void focusStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason);
|
||||
void resetAdvancedSetting();
|
||||
|
||||
private: // Internal
|
||||
|
||||
// Focus
|
||||
void startFocusing();
|
||||
void cancelFocusing();
|
||||
|
||||
// Exposure
|
||||
void startExposureLocking();
|
||||
void cancelExposureLocking();
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
S60CameraFocusControl *m_focusControl;
|
||||
QCamera::LockStatus m_focusStatus;
|
||||
QCamera::LockStatus m_exposureStatus;
|
||||
QCamera::LockStatus m_whiteBalanceStatus;
|
||||
};
|
||||
|
||||
#endif // S60CAMERALOCKSCONTROL_H
|
||||
@@ -1,259 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60cameracontrol.h"
|
||||
#include "s60videodevicecontrol.h"
|
||||
#include "s60camerafocuscontrol.h"
|
||||
#include "s60cameraexposurecontrol.h"
|
||||
#include "s60cameraflashcontrol.h"
|
||||
#include "s60cameraimageprocessingcontrol.h"
|
||||
#include "s60cameraimagecapturecontrol.h"
|
||||
#include "s60mediarecordercontrol.h"
|
||||
#include "s60videocapturesession.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
#include "s60videowidgetcontrol.h"
|
||||
#include "s60mediacontainercontrol.h"
|
||||
#include "s60videoencodercontrol.h"
|
||||
#include "s60audioencodercontrol.h"
|
||||
#include "s60imageencodercontrol.h"
|
||||
#include "s60cameralockscontrol.h"
|
||||
#include "s60videorenderercontrol.h"
|
||||
#include "s60videowindowcontrol.h"
|
||||
|
||||
#include "s60cameraviewfinderengine.h" // ViewfinderOutputType
|
||||
|
||||
S60CameraService::S60CameraService(QObject *parent) :
|
||||
QMediaService(parent)
|
||||
{
|
||||
// Session classes for video and image capturing
|
||||
m_imagesession = new S60ImageCaptureSession(this);
|
||||
m_videosession = new S60VideoCaptureSession(this);
|
||||
|
||||
if (m_imagesession && m_videosession) {
|
||||
// Different control classes implementing the Camera API
|
||||
m_control = new S60CameraControl(m_videosession, m_imagesession, this);
|
||||
m_videoDeviceControl = new S60VideoDeviceControl(m_control, this);
|
||||
m_focusControl = new S60CameraFocusControl(m_imagesession, this);
|
||||
m_exposureControl = new S60CameraExposureControl(m_imagesession, this);
|
||||
m_flashControl = new S60CameraFlashControl(m_imagesession, this);
|
||||
m_imageProcessingControl = new S60CameraImageProcessingControl(m_imagesession, this);
|
||||
m_imageCaptureControl = new S60CameraImageCaptureControl(this, m_imagesession, this);
|
||||
m_media = new S60MediaRecorderControl(this, m_videosession, this);
|
||||
m_mediaFormat = new S60MediaContainerControl(m_videosession, this);
|
||||
m_videoEncoder = new S60VideoEncoderControl(m_videosession, this);
|
||||
m_audioEncoder = new S60AudioEncoderControl(m_videosession, this);
|
||||
m_viewFinderWidget = new S60VideoWidgetControl(this);
|
||||
m_imageEncoderControl = new S60ImageEncoderControl(m_imagesession, this);
|
||||
m_locksControl = new S60CameraLocksControl(this, m_imagesession, this);
|
||||
m_rendererControl = new S60VideoRendererControl(this);
|
||||
m_windowControl = new S60VideoWindowControl(this);
|
||||
}
|
||||
}
|
||||
|
||||
S60CameraService::~S60CameraService()
|
||||
{
|
||||
// Delete controls
|
||||
if (m_videoDeviceControl)
|
||||
delete m_videoDeviceControl;
|
||||
if (m_focusControl)
|
||||
delete m_focusControl;
|
||||
if (m_exposureControl)
|
||||
delete m_exposureControl;
|
||||
if (m_flashControl)
|
||||
delete m_flashControl;
|
||||
if (m_imageProcessingControl)
|
||||
delete m_imageProcessingControl;
|
||||
if (m_imageCaptureControl)
|
||||
delete m_imageCaptureControl;
|
||||
if (m_media)
|
||||
delete m_media;
|
||||
if (m_mediaFormat)
|
||||
delete m_mediaFormat;
|
||||
if (m_videoEncoder)
|
||||
delete m_videoEncoder;
|
||||
if (m_audioEncoder)
|
||||
delete m_audioEncoder;
|
||||
if (m_imageEncoderControl)
|
||||
delete m_imageEncoderControl;
|
||||
if (m_locksControl)
|
||||
delete m_locksControl;
|
||||
|
||||
// CameraControl destroys:
|
||||
// * ViewfinderEngine
|
||||
// * CameraEngine
|
||||
if (m_control)
|
||||
delete m_control;
|
||||
|
||||
// Delete viewfinder controls after CameraControl to be sure that
|
||||
// ViewFinder gets stopped before widget (and window) is destroyed
|
||||
if (m_viewFinderWidget)
|
||||
delete m_viewFinderWidget;
|
||||
if (m_rendererControl)
|
||||
delete m_rendererControl;
|
||||
if (m_windowControl)
|
||||
delete m_windowControl;
|
||||
|
||||
// Delete sessions
|
||||
if (m_videosession)
|
||||
delete m_videosession;
|
||||
if (m_imagesession)
|
||||
delete m_imagesession;
|
||||
}
|
||||
|
||||
QMediaControl *S60CameraService::requestControl(const char *name)
|
||||
{
|
||||
if (qstrcmp(name, QMediaRecorderControl_iid) == 0)
|
||||
return m_media;
|
||||
|
||||
if (qstrcmp(name, QCameraControl_iid) == 0)
|
||||
return m_control;
|
||||
|
||||
if (qstrcmp(name, QVideoEncoderControl_iid) == 0)
|
||||
return m_videoEncoder;
|
||||
|
||||
if (qstrcmp(name, QAudioEncoderControl_iid) == 0)
|
||||
return m_audioEncoder;
|
||||
|
||||
if (qstrcmp(name, QMediaContainerControl_iid) == 0)
|
||||
return m_mediaFormat;
|
||||
|
||||
if (qstrcmp(name, QCameraExposureControl_iid) == 0)
|
||||
return m_exposureControl;
|
||||
|
||||
if (qstrcmp(name, QCameraFlashControl_iid) == 0)
|
||||
return m_flashControl;
|
||||
|
||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||
if (m_viewFinderWidget) {
|
||||
m_control->setVideoOutput(m_viewFinderWidget,
|
||||
S60CameraViewfinderEngine::OutputTypeVideoWidget);
|
||||
return m_viewFinderWidget;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
||||
if (m_rendererControl) {
|
||||
m_control->setVideoOutput(m_rendererControl,
|
||||
S60CameraViewfinderEngine::OutputTypeRenderer);
|
||||
return m_rendererControl;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
|
||||
if (m_windowControl) {
|
||||
m_control->setVideoOutput(m_windowControl,
|
||||
S60CameraViewfinderEngine::OutputTypeVideoWindow);
|
||||
return m_windowControl;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
if (qstrcmp(name, QCameraFocusControl_iid) == 0)
|
||||
return m_focusControl;
|
||||
|
||||
if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0)
|
||||
return m_imageProcessingControl;
|
||||
|
||||
if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0)
|
||||
return m_imageCaptureControl;
|
||||
|
||||
if (qstrcmp(name, QVideoDeviceControl_iid) == 0)
|
||||
return m_videoDeviceControl;
|
||||
|
||||
if (qstrcmp(name, QImageEncoderControl_iid) == 0)
|
||||
return m_imageEncoderControl;
|
||||
|
||||
if (qstrcmp(name, QCameraLocksControl_iid) == 0)
|
||||
return m_locksControl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S60CameraService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
if (control == 0)
|
||||
return;
|
||||
|
||||
// Release viewfinder output
|
||||
if (control == m_viewFinderWidget) {
|
||||
if (m_viewFinderWidget)
|
||||
m_control->releaseVideoOutput(S60CameraViewfinderEngine::OutputTypeVideoWidget);
|
||||
}
|
||||
|
||||
if (control == m_rendererControl) {
|
||||
if (m_rendererControl)
|
||||
m_control->releaseVideoOutput(S60CameraViewfinderEngine::OutputTypeRenderer);
|
||||
}
|
||||
|
||||
if (control == m_windowControl) {
|
||||
if (m_windowControl)
|
||||
m_control->releaseVideoOutput(S60CameraViewfinderEngine::OutputTypeVideoWindow);
|
||||
}
|
||||
}
|
||||
|
||||
int S60CameraService::deviceCount()
|
||||
{
|
||||
return S60CameraControl::deviceCount();
|
||||
}
|
||||
|
||||
QString S60CameraService::deviceDescription(const int index)
|
||||
{
|
||||
return S60CameraControl::description(index);
|
||||
}
|
||||
|
||||
QString S60CameraService::deviceName(const int index)
|
||||
{
|
||||
return S60CameraControl::name(index);
|
||||
}
|
||||
|
||||
// End of file
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERASERVICE_H
|
||||
#define S60CAMERASERVICE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <qmediaservice.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60MediaContainerControl;
|
||||
class S60VideoEncoderControl;
|
||||
class S60AudioEncoderControl;
|
||||
class S60CameraControl;
|
||||
class S60VideoDeviceControl;
|
||||
class S60MediaRecorderControl;
|
||||
class S60ImageCaptureSession;
|
||||
class S60VideoCaptureSession;
|
||||
class S60CameraFocusControl;
|
||||
class S60CameraExposureControl;
|
||||
class S60CameraFlashControl;
|
||||
class S60CameraImageProcessingControl;
|
||||
class S60CameraImageCaptureControl;
|
||||
class S60VideoWidgetControl;
|
||||
class S60ImageEncoderControl;
|
||||
class S60CameraLocksControl;
|
||||
class S60VideoRendererControl;
|
||||
class S60VideoWindowControl;
|
||||
|
||||
class S60CameraService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructor & Destructor
|
||||
|
||||
S60CameraService(QObject *parent = 0);
|
||||
~S60CameraService();
|
||||
|
||||
public: // QMediaService
|
||||
|
||||
QMediaControl *requestControl(const char *name);
|
||||
void releaseControl(QMediaControl *control);
|
||||
|
||||
public: // Static Device Info
|
||||
|
||||
static int deviceCount();
|
||||
static QString deviceName(const int index);
|
||||
static QString deviceDescription(const int index);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_imagesession;
|
||||
S60VideoCaptureSession *m_videosession;
|
||||
S60MediaContainerControl *m_mediaFormat;
|
||||
S60VideoEncoderControl *m_videoEncoder;
|
||||
S60AudioEncoderControl *m_audioEncoder;
|
||||
S60CameraControl *m_control;
|
||||
S60VideoDeviceControl *m_videoDeviceControl;
|
||||
S60CameraFocusControl *m_focusControl;
|
||||
S60CameraExposureControl *m_exposureControl;
|
||||
S60CameraFlashControl *m_flashControl;
|
||||
S60CameraImageProcessingControl *m_imageProcessingControl;
|
||||
S60CameraImageCaptureControl *m_imageCaptureControl;
|
||||
S60MediaRecorderControl *m_media;
|
||||
S60VideoWidgetControl *m_viewFinderWidget;
|
||||
S60ImageEncoderControl *m_imageEncoderControl;
|
||||
S60CameraLocksControl *m_locksControl;
|
||||
S60VideoRendererControl *m_rendererControl;
|
||||
S60VideoWindowControl *m_windowControl;
|
||||
};
|
||||
|
||||
#endif // S60CAMERASERVICE_H
|
||||
@@ -1,115 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60cameraserviceplugin.h"
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
#include "s60cameraservice.h"
|
||||
#endif
|
||||
|
||||
QStringList S60CameraServicePlugin::keys() const
|
||||
{
|
||||
QStringList list;
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
list << QLatin1String(Q_MEDIASERVICE_CAMERA);
|
||||
#endif
|
||||
return list;
|
||||
}
|
||||
|
||||
QMediaService* S60CameraServicePlugin::create(QString const& key)
|
||||
{
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
|
||||
return new S60CameraService;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S60CameraServicePlugin::release(QMediaService *service)
|
||||
{
|
||||
delete service;
|
||||
}
|
||||
|
||||
QList<QByteArray> S60CameraServicePlugin::devices(const QByteArray &service) const
|
||||
{
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
if (service == Q_MEDIASERVICE_CAMERA) {
|
||||
if (m_cameraDevices.isEmpty())
|
||||
updateDevices();
|
||||
|
||||
return m_cameraDevices;
|
||||
}
|
||||
#endif
|
||||
return QList<QByteArray>();
|
||||
}
|
||||
|
||||
QString S60CameraServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
|
||||
{
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
if (service == Q_MEDIASERVICE_CAMERA) {
|
||||
if (m_cameraDevices.isEmpty())
|
||||
updateDevices();
|
||||
|
||||
for (int i=0; i<m_cameraDevices.count(); i++)
|
||||
if (m_cameraDevices[i] == device)
|
||||
return m_cameraDescriptions[i];
|
||||
}
|
||||
#endif
|
||||
return QString();
|
||||
}
|
||||
|
||||
void S60CameraServicePlugin::updateDevices() const
|
||||
{
|
||||
#ifdef QMEDIA_SYMBIAN_CAMERA
|
||||
m_cameraDevices.clear();
|
||||
m_cameraDescriptions.clear();
|
||||
for (int i=0; i < S60CameraService::deviceCount(); i ++) {
|
||||
m_cameraDevices.append(S60CameraService::deviceName(i).toUtf8());
|
||||
m_cameraDescriptions.append(S60CameraService::deviceDescription(i));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qtmultimedia_ecamngine, S60CameraServicePlugin);
|
||||
|
||||
// End of file
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef S60CAMERASERVICEPLUGIN_H
|
||||
#define S60CAMERASERVICEPLUGIN_H
|
||||
|
||||
#include <qmediaservice.h>
|
||||
#include <qmediaserviceproviderplugin.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*
|
||||
* Plugin implementation for the Camera Service
|
||||
*/
|
||||
class S60CameraServicePlugin : public QMediaServiceProviderPlugin,
|
||||
public QMediaServiceSupportedDevicesInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
|
||||
|
||||
public: // QMediaServiceProviderPlugin
|
||||
|
||||
QStringList keys() const;
|
||||
QMediaService* create(QString const& key);
|
||||
void release(QMediaService *service);
|
||||
|
||||
public: // QMediaServiceSupportedDevicesInterface
|
||||
|
||||
QList<QByteArray> devices(const QByteArray &service) const;
|
||||
QString deviceDescription(const QByteArray &service, const QByteArray &device);
|
||||
|
||||
private: // Internal
|
||||
|
||||
void updateDevices() const;
|
||||
|
||||
private: // Data
|
||||
|
||||
mutable QList<QByteArray> m_cameraDevices;
|
||||
mutable QStringList m_cameraDescriptions;
|
||||
};
|
||||
|
||||
#endif // S60CAMERASERVICEPLUGIN_H
|
||||
@@ -1,986 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
// S60 3.2 Platform
|
||||
#ifdef USE_S60_32_ECAM_ADVANCED_SETTINGS_HEADER
|
||||
#define POST_31_PLATFORM
|
||||
#include <ecamadvancedsettings.h> // CCameraAdvancedSettings (inc. TValueInfo)
|
||||
#endif // S60 3.2
|
||||
|
||||
// S60 5.0 or later
|
||||
#ifdef USE_S60_50_ECAM_ADVANCED_SETTINGS_HEADER
|
||||
#define POST_31_PLATFORM
|
||||
#include <ecamadvsettings.h> // CCameraAdvancedSettings
|
||||
#include <ecam/ecamconstants.h> // TValueInfo
|
||||
#endif // S60 5.0 or later
|
||||
|
||||
S60CameraSettings::S60CameraSettings(QObject *parent, CCameraEngine *engine) :
|
||||
QObject(parent),
|
||||
#ifndef S60_31_PLATFORM // Post S60 3.1 Platforms
|
||||
m_advancedSettings(0),
|
||||
m_imageProcessingSettings(0),
|
||||
#endif // S60_31_PLATFORM
|
||||
m_cameraEngine(engine),
|
||||
m_continuousFocusing(false)
|
||||
{
|
||||
}
|
||||
|
||||
S60CameraSettings::~S60CameraSettings()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
delete m_advancedSettings;
|
||||
m_advancedSettings = 0;
|
||||
}
|
||||
|
||||
if (m_imageProcessingSettings) {
|
||||
delete m_imageProcessingSettings;
|
||||
m_imageProcessingSettings = 0;
|
||||
}
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
/*
|
||||
* This is Symbian NewL kind of consructor, but unlike Symbian version this
|
||||
* constructor will not leave, but instead it will return possible errors in
|
||||
* the error variable. This is to be able to write the class without deriving
|
||||
* it form CBase. Also CleanupStack is cleaned here if the ConstructL leaves.
|
||||
*/
|
||||
S60CameraSettings* S60CameraSettings::New(int &error, QObject *parent, CCameraEngine *engine)
|
||||
{
|
||||
S60CameraSettings* self = new S60CameraSettings(parent, engine);
|
||||
if (!self) {
|
||||
error = KErrNoMemory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
TRAPD(err, self->ConstructL());
|
||||
if (err) {
|
||||
// Clean created object
|
||||
delete self;
|
||||
self = 0;
|
||||
error = err;
|
||||
return 0;
|
||||
}
|
||||
|
||||
error = KErrNone;
|
||||
return self;
|
||||
}
|
||||
|
||||
void S60CameraSettings::ConstructL()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (!m_cameraEngine)
|
||||
User::Leave(KErrGeneral);
|
||||
// From now on it is safe to assume engine exists
|
||||
|
||||
// If no AdvancedSettings is available, there's no benefit of S60CameraSettings
|
||||
// Leave if creation fails
|
||||
m_advancedSettings = CCamera::CCameraAdvancedSettings::NewL(*m_cameraEngine->Camera());
|
||||
CleanupStack::PushL(m_advancedSettings);
|
||||
|
||||
// ImageProcessing module may not be supported, don't Leave
|
||||
TRAPD(err, m_imageProcessingSettings = CCamera::CCameraImageProcessing::NewL(*m_cameraEngine->Camera()));
|
||||
if (err == KErrNone && m_imageProcessingSettings) {
|
||||
CleanupStack::PushL(m_imageProcessingSettings);
|
||||
} else {
|
||||
if (err == KErrNotSupported)
|
||||
m_imageProcessingSettings = 0;
|
||||
else {
|
||||
// Leave with error
|
||||
if (!m_imageProcessingSettings)
|
||||
User::Leave(KErrNoMemory);
|
||||
else
|
||||
User::Leave(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_advancedSettings) {
|
||||
RArray<TInt> digitalZoomFactors;
|
||||
CleanupClosePushL(digitalZoomFactors);
|
||||
|
||||
TValueInfo info = ENotActive;
|
||||
m_advancedSettings->GetDigitalZoomStepsL(digitalZoomFactors, info);
|
||||
|
||||
for (int i = 0; i < digitalZoomFactors.Count(); ++i)
|
||||
m_supportedSymbianDigitalZoomFactors << digitalZoomFactors[i];
|
||||
|
||||
CleanupStack::PopAndDestroy(); // RArray<TInt> digitalZoomFactors
|
||||
}
|
||||
|
||||
// Pop objects from CleanupStack
|
||||
if (m_imageProcessingSettings)
|
||||
CleanupStack::Pop(m_imageProcessingSettings);
|
||||
CleanupStack::Pop(m_advancedSettings);
|
||||
|
||||
#else // S60 3.1
|
||||
// AdvancedSettings are not suppoted on S60 3.1 (There's no use for S60CameraSettings)
|
||||
User::Leave(KErrNotSupported);
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setFocusMode(QCameraFocus::FocusMode mode)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
switch (mode) {
|
||||
case QCameraFocus::ManualFocus: // Manual focus mode
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeManual);
|
||||
m_continuousFocusing = false;
|
||||
break;
|
||||
case QCameraFocus::AutoFocus: // Single-shot AutoFocus mode
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeAuto);
|
||||
m_advancedSettings->SetFocusRange(CCamera::CCameraAdvancedSettings::EFocusRangeAuto);
|
||||
m_continuousFocusing = false;
|
||||
break;
|
||||
case QCameraFocus::HyperfocalFocus:
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeAuto);
|
||||
m_advancedSettings->SetFocusRange(CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal);
|
||||
m_continuousFocusing = false;
|
||||
break;
|
||||
case QCameraFocus::InfinityFocus:
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeAuto);
|
||||
m_advancedSettings->SetFocusRange(CCamera::CCameraAdvancedSettings::EFocusRangeInfinite);
|
||||
m_continuousFocusing = false;
|
||||
break;
|
||||
case QCameraFocus::ContinuousFocus:
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeAuto);
|
||||
m_advancedSettings->SetFocusRange(CCamera::CCameraAdvancedSettings::EFocusRangeAuto);
|
||||
m_continuousFocusing = true;
|
||||
break;
|
||||
case QCameraFocus::MacroFocus:
|
||||
m_advancedSettings->SetFocusMode(CCamera::CCameraAdvancedSettings::EFocusModeAuto);
|
||||
m_advancedSettings->SetFocusRange(CCamera::CCameraAdvancedSettings::EFocusRangeMacro);
|
||||
m_continuousFocusing = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested focus mode is not supported."));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(mode);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Settings focus mode is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::startFocusing()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
// Setting AutoFocusType triggers the focusing on Symbian
|
||||
if (m_advancedSettings) {
|
||||
if (m_continuousFocusing)
|
||||
m_advancedSettings->SetAutoFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeContinuous);
|
||||
else
|
||||
m_advancedSettings->SetAutoFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle);
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unable to focus."));
|
||||
}
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::cancelFocusing()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->SetAutoFocusType(CCamera::CCameraAdvancedSettings::EAutoFocusTypeOff);
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unable to cancel focusing."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
QCameraFocus::FocusMode S60CameraSettings::focusMode()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
// First request needed info
|
||||
CCamera::CCameraAdvancedSettings::TFocusMode mode = m_advancedSettings->FocusMode();
|
||||
CCamera::CCameraAdvancedSettings::TFocusRange range = m_advancedSettings->FocusRange();
|
||||
CCamera::CCameraAdvancedSettings::TAutoFocusType autoType = m_advancedSettings->AutoFocusType();
|
||||
|
||||
switch (mode) {
|
||||
case CCamera::CCameraAdvancedSettings::EFocusModeManual:
|
||||
case CCamera::CCameraAdvancedSettings::EFocusModeFixed:
|
||||
return QCameraFocus::ManualFocus;
|
||||
|
||||
case CCamera::CCameraAdvancedSettings::EFocusModeAuto:
|
||||
if (autoType == CCamera::CCameraAdvancedSettings::EAutoFocusTypeContinuous) {
|
||||
return QCameraFocus::ContinuousFocus;
|
||||
} else {
|
||||
// Single-shot focusing
|
||||
switch (range) {
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeMacro:
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeSuperMacro:
|
||||
return QCameraFocus::MacroFocus;
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal:
|
||||
return QCameraFocus::HyperfocalFocus;
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeInfinite:
|
||||
return QCameraFocus::InfinityFocus;
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeAuto:
|
||||
case CCamera::CCameraAdvancedSettings::EFocusRangeNormal:
|
||||
return QCameraFocus::AutoFocus;
|
||||
|
||||
default:
|
||||
return QCameraFocus::AutoFocus;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return QCameraFocus::AutoFocus; // Return automatic focusing
|
||||
}
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#endif // POST_31_PLATFORM
|
||||
return QCameraFocus::AutoFocus; // Return automatic focusing
|
||||
}
|
||||
|
||||
QCameraFocus::FocusModes S60CameraSettings::supportedFocusModes()
|
||||
{
|
||||
QCameraFocus::FocusModes modes = 0;
|
||||
|
||||
#ifdef POST_31_PLATFORM
|
||||
TInt supportedModes = 0;
|
||||
TInt autoFocusTypes = 0;
|
||||
TInt supportedRanges = 0;
|
||||
|
||||
if (m_advancedSettings) {
|
||||
supportedModes = m_advancedSettings->SupportedFocusModes();
|
||||
autoFocusTypes = m_advancedSettings->SupportedAutoFocusTypes();
|
||||
supportedRanges = m_advancedSettings->SupportedFocusRanges();
|
||||
|
||||
if (supportedModes == 0 || autoFocusTypes == 0 || supportedRanges == 0)
|
||||
return modes;
|
||||
|
||||
// EFocusModeAuto is the only supported on Symbian
|
||||
if (supportedModes & CCamera::CCameraAdvancedSettings::EFocusModeAuto) {
|
||||
// Check supported types (Single-shot Auto vs. Continuous)
|
||||
if (autoFocusTypes & CCamera::CCameraAdvancedSettings::EAutoFocusTypeSingle)
|
||||
modes |= QCameraFocus::AutoFocus;
|
||||
if (autoFocusTypes & CCamera::CCameraAdvancedSettings::EAutoFocusTypeContinuous)
|
||||
modes |= QCameraFocus::ContinuousFocus;
|
||||
|
||||
// Check supported ranges (Note! Some are actually fixed focuses
|
||||
// even though the mode is Auto on Symbian)
|
||||
if (supportedRanges & CCamera::CCameraAdvancedSettings::EFocusRangeMacro)
|
||||
modes |= QCameraFocus::MacroFocus;
|
||||
if (supportedRanges & CCamera::CCameraAdvancedSettings::EFocusRangeHyperfocal)
|
||||
modes |= QCameraFocus::HyperfocalFocus;
|
||||
if (supportedRanges & CCamera::CCameraAdvancedSettings::EFocusRangeInfinite)
|
||||
modes |= QCameraFocus::InfinityFocus;
|
||||
}
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#endif // POST_31_PLATFORM
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
qreal S60CameraSettings::opticalZoomFactorL() const
|
||||
{
|
||||
// Not supported on Symbian
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
void S60CameraSettings::setOpticalZoomFactorL(const qreal zoomFactor)
|
||||
{
|
||||
// Not supported on Symbian
|
||||
Q_UNUSED(zoomFactor);
|
||||
}
|
||||
|
||||
QList<qreal> S60CameraSettings::supportedDigitalZoomFactors() const
|
||||
{
|
||||
QList<qreal> zoomFactors;
|
||||
foreach (int factor, m_supportedSymbianDigitalZoomFactors)
|
||||
zoomFactors << qreal(factor) / KSymbianFineResolutionFactor;
|
||||
|
||||
return zoomFactors;
|
||||
}
|
||||
|
||||
qreal S60CameraSettings::digitalZoomFactorL() const
|
||||
{
|
||||
qreal factor = 1.0;
|
||||
|
||||
#ifdef POST_31_PLATFORM
|
||||
int symbianFactor = 0;
|
||||
if (m_advancedSettings)
|
||||
symbianFactor = m_advancedSettings->DigitalZoom();
|
||||
else
|
||||
User::Leave(KErrNotSupported);
|
||||
|
||||
if (symbianFactor != 0)
|
||||
factor = qreal(symbianFactor) / KSymbianFineResolutionFactor;
|
||||
#endif // POST_31_PLATFORM
|
||||
|
||||
return factor;
|
||||
}
|
||||
|
||||
void S60CameraSettings::setDigitalZoomFactorL(const qreal zoomFactor)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
int symbianFactor = zoomFactor * KSymbianFineResolutionFactor;
|
||||
|
||||
// Find closest supported Symbian ZoomFactor if needed
|
||||
if (!m_supportedSymbianDigitalZoomFactors.contains(symbianFactor)) {
|
||||
int closestIndex = -1;
|
||||
int closestDiff = 1000000; // Sensible maximum
|
||||
for (int i = 0; i < m_supportedSymbianDigitalZoomFactors.count(); ++i) {
|
||||
int diff = abs(m_supportedSymbianDigitalZoomFactors.at(i) - symbianFactor);
|
||||
if (diff < closestDiff) {
|
||||
closestDiff = diff;
|
||||
closestIndex = i;
|
||||
}
|
||||
}
|
||||
if (closestIndex != -1)
|
||||
symbianFactor = m_supportedSymbianDigitalZoomFactors.at(closestIndex);
|
||||
else
|
||||
User::Leave(KErrGeneral);
|
||||
}
|
||||
if (m_advancedSettings)
|
||||
m_advancedSettings->SetDigitalZoom(symbianFactor);
|
||||
else
|
||||
User::Leave(KErrNotSupported);
|
||||
#else // S60 3.1 Platform
|
||||
Q_UNUSED(zoomFactor);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Settings digital zoom factor is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
// MCameraObserver2
|
||||
void S60CameraSettings::HandleAdvancedEvent(const TECAMEvent& aEvent)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
|
||||
if (aEvent.iErrorCode != KErrNone) {
|
||||
switch (aEvent.iErrorCode) {
|
||||
case KErrECamCameraDisabled:
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return;
|
||||
case KErrECamSettingDisabled:
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return;
|
||||
case KErrECamParameterNotInRange:
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested value is not in supported range."));
|
||||
return;
|
||||
case KErrECamSettingNotSupported:
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested setting is not supported."));
|
||||
return;
|
||||
case KErrECamNotOptimalFocus:
|
||||
if (m_continuousFocusing)
|
||||
emit focusStatusChanged(QCamera::Searching, QCamera::LockTemporaryLost);
|
||||
else
|
||||
emit focusStatusChanged(QCamera::Unlocked, QCamera::LockFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aEvent.iEventType == KUidECamEventCameraSettingFocusRange ||
|
||||
aEvent.iEventType == KUidECamEventCameraSettingAutoFocusType2) {
|
||||
emit focusStatusChanged(QCamera::Unlocked, QCamera::LockFailed);
|
||||
return;
|
||||
} else if (aEvent.iEventType == KUidECamEventCameraSettingIsoRate) {
|
||||
if (aEvent.iErrorCode == KErrNotSupported)
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested ISO value is not supported."));
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Setting ISO value failed."));
|
||||
return;
|
||||
} else if (aEvent.iEventType == KUidECamEventCameraSettingAperture) {
|
||||
if (aEvent.iErrorCode == KErrNotSupported)
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested aperture value is not supported."));
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Setting aperture value failed."));
|
||||
return;
|
||||
} else if (aEvent.iEventType == KUidECamEventCameraSettingExposureCompensation) {
|
||||
if (aEvent.iErrorCode == KErrNotSupported)
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested exposure compensation is not supported."));
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Setting exposure compensation failed."));
|
||||
return;
|
||||
} else if (aEvent.iEventType == KUidECamEventCameraSettingOpticalZoom ||
|
||||
aEvent.iEventType == KUidECamEventCameraSettingDigitalZoom) {
|
||||
if (aEvent.iErrorCode == KErrNotSupported)
|
||||
return; // Discard
|
||||
else {
|
||||
emit error(QCamera::CameraError, tr("Setting zoom factor failed."));
|
||||
return;
|
||||
}
|
||||
} else if (aEvent.iEventType == KUidECamEventCameraSettingFocusMode) {
|
||||
if (aEvent.iErrorCode == KErrNotSupported)
|
||||
if (m_cameraEngine && m_cameraEngine->CurrentCameraIndex() != 0)
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Focusing is not supported with this camera."));
|
||||
else
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested focus mode is not supported."));
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Setting focus mode failed."));
|
||||
return;
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (aEvent.iEventType == KUidECamEventCameraSettingExposureLock) {
|
||||
if (m_advancedSettings) {
|
||||
if (m_advancedSettings->ExposureLockOn())
|
||||
emit exposureStatusChanged(QCamera::Locked, QCamera::LockAcquired);
|
||||
else
|
||||
emit exposureStatusChanged(QCamera::Unlocked, QCamera::LockLost);
|
||||
}
|
||||
else
|
||||
emit exposureStatusChanged(QCamera::Unlocked, QCamera::LockLost);
|
||||
}
|
||||
else if (aEvent.iEventType == KUidECamEventCameraSettingAperture)
|
||||
emit apertureChanged();
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventCameraSettingApertureRange)
|
||||
emit apertureRangeChanged();
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventCameraSettingIsoRateType)
|
||||
emit isoSensitivityChanged();
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventCameraSettingShutterSpeed)
|
||||
emit shutterSpeedChanged();
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventCameraSettingExposureCompensationStep)
|
||||
emit evChanged();
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventFlashReady)
|
||||
emit flashReady(true);
|
||||
|
||||
else if (aEvent.iEventType == KUidECamEventFlashNotReady)
|
||||
emit flashReady(false);
|
||||
|
||||
else if (aEvent.iEventType.iUid == KUidECamEventCameraSettingsOptimalFocusUidValue)
|
||||
emit focusStatusChanged(QCamera::Locked, QCamera::LockAcquired);
|
||||
|
||||
#else // S60 3.1 Platform
|
||||
Q_UNUSED(aEvent);
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
bool S60CameraSettings::isFlashReady()
|
||||
{
|
||||
TBool isReady = false;
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
int flashErr = m_advancedSettings->IsFlashReady(isReady);
|
||||
if(flashErr != KErrNone) {
|
||||
if (flashErr != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Unexpected error with flash."));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#endif
|
||||
return isReady;
|
||||
}
|
||||
|
||||
QCameraExposure::MeteringMode S60CameraSettings::meteringMode()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
CCamera::CCameraAdvancedSettings::TMeteringMode mode = m_advancedSettings->MeteringMode();
|
||||
switch (mode) {
|
||||
case CCamera::CCameraAdvancedSettings::EMeteringModeCenterWeighted:
|
||||
return QCameraExposure::MeteringAverage;
|
||||
case CCamera::CCameraAdvancedSettings::EMeteringModeEvaluative:
|
||||
return QCameraExposure::MeteringMatrix;
|
||||
case CCamera::CCameraAdvancedSettings::EMeteringModeSpot:
|
||||
return QCameraExposure::MeteringSpot;
|
||||
|
||||
default:
|
||||
return QCameraExposure::MeteringAverage;
|
||||
}
|
||||
}else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return QCameraExposure::MeteringAverage;
|
||||
}
|
||||
#else // S60 3.1 Platform
|
||||
return QCameraExposure::MeteringAverage;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setMeteringMode(QCameraExposure::MeteringMode mode)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
switch(mode) {
|
||||
case QCameraExposure::MeteringAverage:
|
||||
m_advancedSettings->SetMeteringMode(CCamera::CCameraAdvancedSettings::EMeteringModeCenterWeighted);
|
||||
break;
|
||||
case QCameraExposure::MeteringMatrix:
|
||||
m_advancedSettings->SetMeteringMode(CCamera::CCameraAdvancedSettings::EMeteringModeEvaluative);
|
||||
break;
|
||||
case QCameraExposure::MeteringSpot:
|
||||
m_advancedSettings->SetMeteringMode(CCamera::CCameraAdvancedSettings::EMeteringModeSpot);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(mode);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting metering mode is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
bool S60CameraSettings::isMeteringModeSupported(QCameraExposure::MeteringMode mode)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
TInt supportedModes = 0;
|
||||
|
||||
if (m_advancedSettings) {
|
||||
supportedModes = m_advancedSettings->SupportedMeteringModes();
|
||||
if (supportedModes == 0)
|
||||
return false;
|
||||
|
||||
switch (mode) {
|
||||
case QCameraExposure::MeteringMatrix:
|
||||
if (supportedModes & CCamera::CCameraAdvancedSettings::EMeteringModeEvaluative)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposure::MeteringAverage:
|
||||
if (supportedModes & CCamera::CCameraAdvancedSettings::EMeteringModeCenterWeighted)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
case QCameraExposure::MeteringSpot:
|
||||
if (supportedModes & CCamera::CCameraAdvancedSettings::EMeteringModeSpot)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(mode);
|
||||
#endif // POST_31_PLATFORM
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int S60CameraSettings::isoSensitivity()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
CCamera::CCameraAdvancedSettings::TISORateType isoRateType;
|
||||
TInt param = 0;
|
||||
TInt isoRate = 0;
|
||||
TRAPD(err, m_advancedSettings->GetISORateL(isoRateType, param, isoRate));
|
||||
if (err)
|
||||
return 0;
|
||||
if (isoRate != KErrNotFound)
|
||||
return isoRate;
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#endif // POST_31_PLATFORM
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<int> S60CameraSettings::supportedIsoSensitivities()
|
||||
{
|
||||
QList<int> isoSentitivities;
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
RArray<TInt> supportedIsoRates;
|
||||
CleanupClosePushL(supportedIsoRates);
|
||||
|
||||
TRAPD(err, m_advancedSettings->GetSupportedIsoRatesL(supportedIsoRates));
|
||||
if (err != KErrNone) {
|
||||
if (err != KErrNotSupported) // Don's emit error if ISO is not supported
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported iso sensitivities."));
|
||||
} else {
|
||||
for (int i = 0; i < supportedIsoRates.Count(); ++i)
|
||||
isoSentitivities << supportedIsoRates[i];
|
||||
}
|
||||
CleanupStack::PopAndDestroy(); // RArray<TInt> supportedIsoRates
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
|
||||
return isoSentitivities;
|
||||
#else // S60 3.1 Platform
|
||||
return isoSentitivities;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setManualIsoSensitivity(int iso)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
TRAPD(err, m_advancedSettings->SetISORateL(CCamera::CCameraAdvancedSettings::EISOManual, iso));
|
||||
if (err)
|
||||
emit error(QCamera::CameraError, tr("Setting manual iso sensitivity failed."));
|
||||
return;
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#else // S60 3.1 Platform
|
||||
Q_UNUSED(iso);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting manual iso sensitivity is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setAutoIsoSensitivity()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
TRAPD(err, m_advancedSettings->SetISORateL(CCamera::CCameraAdvancedSettings::EISOAutoUnPrioritised, 0));
|
||||
if (err)
|
||||
emit error(QCamera::CameraError, tr("Setting auto iso sensitivity failed."));
|
||||
return;
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#else // S60 3.1 Platform
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting auto iso sensitivity is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
qreal S60CameraSettings::aperture()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings)
|
||||
return qreal(m_advancedSettings->Aperture()) / KSymbianFineResolutionFactor;
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return 0;
|
||||
#else // S60 3.1 Platform
|
||||
return 0;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
QList<qreal> S60CameraSettings::supportedApertures()
|
||||
{
|
||||
QList<qreal> apertures;
|
||||
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
RArray<TInt> supportedApertures;
|
||||
TValueInfo info = ENotActive;
|
||||
|
||||
TRAPD(err, m_advancedSettings->GetAperturesL(supportedApertures, info));
|
||||
if (err != KErrNone)
|
||||
if (err != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported apertures."));
|
||||
else {
|
||||
for (int i = 0; i < supportedApertures.Count(); i++) {
|
||||
qreal q = qreal(supportedApertures[i]) / KSymbianFineResolutionFactor;
|
||||
apertures.append(q);
|
||||
}
|
||||
}
|
||||
supportedApertures.Close();
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return apertures;
|
||||
#else // S60 3.1 Platform
|
||||
return apertures;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setManualAperture(qreal aperture)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
int symbianAperture = (aperture * KSymbianFineResolutionFactor); // KSymbianFineResolutionFactor = 100
|
||||
m_advancedSettings->SetAperture(symbianAperture);
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(aperture);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting manual aperture is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::lockExposure(bool lock)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
m_advancedSettings->SetExposureLockOn(lock);
|
||||
return;
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(lock);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Locking exposure is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
bool S60CameraSettings::isExposureLocked()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings)
|
||||
return m_advancedSettings->ExposureLockOn();
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
#endif // POST_31_PLATFORM
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal S60CameraSettings::shutterSpeed()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
qreal shutterSpeed = qreal(m_advancedSettings->ShutterSpeed()) / 1000000.0;
|
||||
return shutterSpeed; // In seconds
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
return 0;
|
||||
#else // S60 3.1 Platform
|
||||
return 0;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
QList<qreal> S60CameraSettings::supportedShutterSpeeds()
|
||||
{
|
||||
QList<qreal> speeds;
|
||||
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
RArray<TInt> supportedSpeeds;
|
||||
TValueInfo info = ENotActive;
|
||||
|
||||
TRAPD(err, m_advancedSettings->GetShutterSpeedsL(supportedSpeeds, info));
|
||||
if (err != KErrNone)
|
||||
if (err != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported shutter speeds."));
|
||||
else {
|
||||
for (int i = 0; i < supportedSpeeds.Count(); i++) {
|
||||
qreal q = qreal(supportedSpeeds[i]) / 1000000.0;
|
||||
speeds.append(q); // In seconds
|
||||
}
|
||||
}
|
||||
supportedSpeeds.Close();
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return speeds;
|
||||
#else // S60 3.1 Platform
|
||||
return speeds;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setManualShutterSpeed(qreal speed)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
TInt shutterSpeed = speed * 1000000; // From seconds to microseconds
|
||||
m_advancedSettings->SetShutterSpeed(shutterSpeed);
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#else // S60 3.1
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting manual shutter speed is not supported."));
|
||||
Q_UNUSED(speed);
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setExposureCompensation(qreal ev)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
TInt evStep = ev * KSymbianFineResolutionFactor;
|
||||
m_advancedSettings->SetExposureCompensationStep(evStep);
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
#else // S60 3.1 Platform
|
||||
Q_UNUSED(ev);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting exposure compensation is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
qreal S60CameraSettings::exposureCompensation()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
TInt evStepSymbian = 0;
|
||||
m_advancedSettings->GetExposureCompensationStep(evStepSymbian);
|
||||
qreal evStep = evStepSymbian;
|
||||
evStep /= KSymbianFineResolutionFactor;
|
||||
return evStep;
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
}
|
||||
return 0;
|
||||
#else // S60 3.1 Platform
|
||||
return 0;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
QList<qreal> S60CameraSettings::supportedExposureCompensationValues()
|
||||
{
|
||||
QList<qreal> valueList;
|
||||
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_advancedSettings) {
|
||||
RArray<TInt> evSteps;
|
||||
TValueInfo info;
|
||||
TRAPD(err, m_advancedSettings->GetExposureCompensationStepsL(evSteps, info));
|
||||
if (err) {
|
||||
if (err != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported exposure compensation values."));
|
||||
return valueList;
|
||||
}
|
||||
|
||||
if (info == ENotActive || evSteps.Count() == 0) {
|
||||
// EV not supported, return empty list
|
||||
return valueList;
|
||||
}
|
||||
|
||||
for (int i = 0; i < evSteps.Count(); ++i) {
|
||||
qreal appendValue = evSteps[i];
|
||||
appendValue /= KSymbianFineResolutionFactor;
|
||||
valueList.append(appendValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
emit error(QCamera::CameraError, tr("Unexpected camera error."));
|
||||
return valueList;
|
||||
#else // S60 3.1 Platform
|
||||
return valueList;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setSharpeningLevel(int value)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_imageProcessingSettings && isSharpeningSupported())
|
||||
m_imageProcessingSettings->SetTransformationValue(KUidECamEventImageProcessingAdjustSharpness, value);
|
||||
else
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting sharpening level is not supported."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(value);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting sharpening level is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
bool S60CameraSettings::isSharpeningSupported() const
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_imageProcessingSettings) {
|
||||
RArray<TUid> suppTransforms;
|
||||
TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
if (suppTransforms.Find(KUidECamEventImageProcessingAdjustSharpness))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
#else // S60 3.1 Platform
|
||||
return false;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
int S60CameraSettings::sharpeningLevel() const
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_imageProcessingSettings && isSharpeningSupported())
|
||||
return m_imageProcessingSettings->TransformationValue(KUidECamEventImageProcessingAdjustSharpness);
|
||||
else
|
||||
return 0;
|
||||
#else // S60 3.1 Platform
|
||||
return 0;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
void S60CameraSettings::setSaturation(int value)
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_imageProcessingSettings) {
|
||||
RArray<TUid> suppTransforms;
|
||||
TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
|
||||
if (err)
|
||||
if (err != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported transformations."));
|
||||
|
||||
if (suppTransforms.Find(KUidECamEventtImageProcessingAdjustSaturation))
|
||||
m_imageProcessingSettings->SetTransformationValue(KUidECamEventtImageProcessingAdjustSaturation, value == -1 ? 0 : value*2-100);
|
||||
else
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting saturation is not supported."));
|
||||
}
|
||||
else
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting saturation is not supported."));
|
||||
#else // S60 3.1
|
||||
Q_UNUSED(value);
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Setting saturation is not supported."));
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
int S60CameraSettings::saturation()
|
||||
{
|
||||
#ifdef POST_31_PLATFORM
|
||||
if (m_imageProcessingSettings) {
|
||||
RArray<TUid> suppTransforms;
|
||||
TRAPD(err, m_imageProcessingSettings->GetSupportedTransformationsL(suppTransforms));
|
||||
if (err)
|
||||
if (err != KErrNotSupported)
|
||||
emit error(QCamera::CameraError, tr("Failure while querying supported transformations."));
|
||||
|
||||
if (suppTransforms.Find(KUidECamEventtImageProcessingAdjustSaturation))
|
||||
return m_imageProcessingSettings->TransformationValue(KUidECamEventtImageProcessingAdjustSaturation);
|
||||
}
|
||||
return 0;
|
||||
#else // S60 3.1 Platform
|
||||
return 0;
|
||||
#endif // POST_31_PLATFORM
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,177 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60CAMERASETTINGS_H
|
||||
#define S60CAMERASETTINGS_H
|
||||
|
||||
#include "qcamera.h"
|
||||
|
||||
#include "s60cameraengine.h"
|
||||
#include "s60cameraengineobserver.h"
|
||||
|
||||
#include <e32base.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
/*
|
||||
* Class handling CCamera AdvancedSettings and ImageProcessing operations.
|
||||
*/
|
||||
class S60CameraSettings : public QObject,
|
||||
public MAdvancedSettingsObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Static Contructor & Destructor
|
||||
|
||||
static S60CameraSettings* New(int &error, QObject *parent = 0, CCameraEngine *engine = 0);
|
||||
~S60CameraSettings();
|
||||
|
||||
public: // Methods
|
||||
|
||||
// Focus
|
||||
QCameraFocus::FocusMode focusMode();
|
||||
void setFocusMode(QCameraFocus::FocusMode mode);
|
||||
QCameraFocus::FocusModes supportedFocusModes();
|
||||
void startFocusing();
|
||||
void cancelFocusing();
|
||||
|
||||
// Zoom
|
||||
qreal opticalZoomFactorL() const;
|
||||
void setOpticalZoomFactorL(const qreal zoomFactor);
|
||||
QList<qreal> supportedDigitalZoomFactors() const;
|
||||
qreal digitalZoomFactorL() const;
|
||||
void setDigitalZoomFactorL(const qreal zoomFactor);
|
||||
|
||||
// Flash
|
||||
bool isFlashReady();
|
||||
|
||||
// Exposure
|
||||
void setExposureMode(QCameraExposure::ExposureMode mode);
|
||||
void lockExposure(bool lock);
|
||||
bool isExposureLocked();
|
||||
|
||||
// Metering Mode
|
||||
QCameraExposure::MeteringMode meteringMode();
|
||||
void setMeteringMode(QCameraExposure::MeteringMode mode);
|
||||
bool isMeteringModeSupported(QCameraExposure::MeteringMode mode);
|
||||
|
||||
// ISO Sensitivity
|
||||
int isoSensitivity();
|
||||
void setManualIsoSensitivity(int iso);
|
||||
void setAutoIsoSensitivity();
|
||||
QList<int> supportedIsoSensitivities();
|
||||
|
||||
// Aperture
|
||||
qreal aperture();
|
||||
void setManualAperture(qreal aperture);
|
||||
QList<qreal> supportedApertures();
|
||||
|
||||
// Shutter Speed
|
||||
qreal shutterSpeed();
|
||||
void setManualShutterSpeed(qreal speed);
|
||||
QList<qreal> supportedShutterSpeeds();
|
||||
|
||||
// ExposureCompensation
|
||||
qreal exposureCompensation();
|
||||
void setExposureCompensation(qreal ev);
|
||||
QList<qreal> supportedExposureCompensationValues();
|
||||
|
||||
// Sharpening Level
|
||||
int sharpeningLevel() const;
|
||||
void setSharpeningLevel(int value);
|
||||
bool isSharpeningSupported() const;
|
||||
|
||||
// Saturation
|
||||
int saturation();
|
||||
void setSaturation(int value);
|
||||
|
||||
signals: // Notifications
|
||||
|
||||
// For QCameraExposureControl
|
||||
void flashReady(bool ready);
|
||||
void apertureChanged();
|
||||
void apertureRangeChanged();
|
||||
void shutterSpeedChanged();
|
||||
void isoSensitivityChanged();
|
||||
void evChanged();
|
||||
|
||||
// For QCameraLocksControl
|
||||
void exposureStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason);
|
||||
void focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason);
|
||||
|
||||
// Errors
|
||||
void error(int, const QString&);
|
||||
|
||||
protected: // Protected constructors
|
||||
|
||||
S60CameraSettings(QObject *parent, CCameraEngine *engine);
|
||||
void ConstructL();
|
||||
|
||||
protected: // MAdvancedSettingsObserver
|
||||
|
||||
void HandleAdvancedEvent(const TECAMEvent& aEvent);
|
||||
|
||||
private: // Internal
|
||||
|
||||
bool queryAdvancedSettingsInfo();
|
||||
|
||||
private: // Enums
|
||||
|
||||
enum EcamErrors {
|
||||
KErrECamCameraDisabled = -12100, // The camera has been disabled, hence calls do not succeed
|
||||
KErrECamSettingDisabled = -12101, // This parameter or operation is supported, but presently is disabled.
|
||||
KErrECamParameterNotInRange = -12102, // This value is out of range.
|
||||
KErrECamSettingNotSupported = -12103, // This parameter or operation is not supported.
|
||||
KErrECamNotOptimalFocus = -12104 // The optimum focus is lost
|
||||
};
|
||||
|
||||
private: // Data
|
||||
|
||||
#ifndef S60_31_PLATFORM // Post S60 3.1 Platforms
|
||||
CCamera::CCameraAdvancedSettings *m_advancedSettings;
|
||||
CCamera::CCameraImageProcessing *m_imageProcessingSettings;
|
||||
#endif // S60_31_PLATFORM
|
||||
CCameraEngine *m_cameraEngine;
|
||||
QList<int> m_supportedSymbianDigitalZoomFactors;
|
||||
bool m_continuousFocusing;
|
||||
};
|
||||
|
||||
#endif // S60CAMERASETTINGS_H
|
||||
@@ -1,789 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <qcamera.h>
|
||||
#include <qabstractvideosurface.h>
|
||||
#include <qvideoframe.h>
|
||||
|
||||
#include "s60cameraviewfinderengine.h"
|
||||
#include "s60cameraengine.h"
|
||||
#include "s60cameracontrol.h"
|
||||
#include "s60videowidgetcontrol.h"
|
||||
#include "s60videowidgetdisplay.h"
|
||||
#include "s60videorenderercontrol.h"
|
||||
#include "s60videowindowcontrol.h"
|
||||
#include "s60videowindowdisplay.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
#include <coemain.h> // CCoeEnv
|
||||
#include <coecntrl.h> // CCoeControl
|
||||
#include <w32std.h>
|
||||
|
||||
// Helper function
|
||||
TRect qRect2TRect(const QRect &qr)
|
||||
{
|
||||
return TRect(TPoint(qr.left(), qr.top()), TSize(qr.width(), qr.height()));
|
||||
}
|
||||
|
||||
|
||||
S60CameraViewfinderEngine::S60CameraViewfinderEngine(S60CameraControl *control,
|
||||
CCameraEngine *engine,
|
||||
QObject *parent):
|
||||
QObject(parent),
|
||||
m_cameraEngine(engine),
|
||||
m_cameraControl(0),
|
||||
m_viewfinderOutput(0),
|
||||
m_viewfinderDisplay(0),
|
||||
m_viewfinderSurface(0),
|
||||
m_wsSession(CCoeEnv::Static()->WsSession()),
|
||||
m_screenDevice(*CCoeEnv::Static()->ScreenDevice()),
|
||||
m_window(0),
|
||||
m_desktopWidget(0),
|
||||
m_vfState(EVFNotConnectedNotStarted),
|
||||
m_viewfinderSize(KDefaultViewfinderSize),
|
||||
m_actualViewFinderSize(KDefaultViewfinderSize),
|
||||
m_viewfinderAspectRatio(0.0),
|
||||
m_viewfinderType(OutputTypeNotSet),
|
||||
m_viewfinderNativeType(EBitmapViewFinder), // Default type
|
||||
m_isViewFinderVisible(true), // True by default (only QVideoWidgetControl supports being hidden)
|
||||
m_uiLandscape(true),
|
||||
m_vfErrorsSignalled(0)
|
||||
{
|
||||
m_cameraControl = control;
|
||||
|
||||
// Check whether platform supports DirectScreen ViewFinder
|
||||
if (m_cameraEngine) {
|
||||
if (m_cameraEngine->IsDirectViewFinderSupported())
|
||||
m_viewfinderNativeType = EDirectScreenViewFinder;
|
||||
else
|
||||
m_viewfinderNativeType = EBitmapViewFinder;
|
||||
|
||||
MCameraViewfinderObserver *vfObserver = this;
|
||||
m_cameraEngine->SetViewfinderObserver(vfObserver);
|
||||
}
|
||||
else
|
||||
m_cameraControl->setError(KErrGeneral, tr("Unexpected camera error."));
|
||||
// From now on it is safe to assume engine exists
|
||||
|
||||
// Check the UI orientation
|
||||
QDesktopWidget* desktopWidget = QApplication::desktop();
|
||||
QRect screenRect = desktopWidget->screenGeometry();
|
||||
if (screenRect.width() > screenRect.height())
|
||||
m_uiLandscape = true;
|
||||
else
|
||||
m_uiLandscape = false;
|
||||
|
||||
// Detect UI Rotations
|
||||
m_desktopWidget = QApplication::desktop();
|
||||
if (m_desktopWidget)
|
||||
connect(m_desktopWidget, SIGNAL(resized(int)), this, SLOT(handleDesktopResize(int)));
|
||||
}
|
||||
|
||||
S60CameraViewfinderEngine::~S60CameraViewfinderEngine()
|
||||
{
|
||||
// No need to stop viewfinder:
|
||||
// Engine has stopped it already
|
||||
// Surface will be stopped by VideoRendererControl
|
||||
|
||||
m_viewfinderOutput = 0;
|
||||
m_viewfinderSurface = 0;
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::setNewCameraEngine(CCameraEngine *engine)
|
||||
{
|
||||
m_cameraEngine = engine;
|
||||
|
||||
if (m_cameraEngine) {
|
||||
// And set observer to the new CameraEngine
|
||||
MCameraViewfinderObserver *vfObserver = this;
|
||||
m_cameraEngine->SetViewfinderObserver(vfObserver);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::handleDesktopResize(int screen)
|
||||
{
|
||||
Q_UNUSED(screen);
|
||||
// UI Rotation is handled by the QVideoWidgetControl, thus this is needed
|
||||
// only for the QVideoRendererControl
|
||||
if (m_viewfinderType == OutputTypeRenderer) {
|
||||
QSize newResolution(-1,-1);
|
||||
if (m_viewfinderSurface)
|
||||
newResolution = m_viewfinderSurface->nativeResolution();
|
||||
|
||||
if (newResolution.width() == -1 || newResolution.height() == -1) {
|
||||
QDesktopWidget* desktopWidget = QApplication::desktop();
|
||||
QRect screenRect = desktopWidget->screenGeometry();
|
||||
newResolution = QSize(screenRect.width(), screenRect.height());
|
||||
}
|
||||
|
||||
resetViewfinderSize(newResolution);
|
||||
}
|
||||
|
||||
// Rotate Camera if UI has rotated
|
||||
checkAndRotateCamera();
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::setVideoWidgetControl(QObject *viewfinderOutput)
|
||||
{
|
||||
// Release old control if it has not already been done
|
||||
if (m_viewfinderOutput)
|
||||
releaseControl(m_viewfinderType);
|
||||
|
||||
// Rotate Camera if UI has rotated
|
||||
checkAndRotateCamera();
|
||||
|
||||
S60VideoWidgetControl* viewFinderWidgetControl =
|
||||
qobject_cast<S60VideoWidgetControl*>(viewfinderOutput);
|
||||
|
||||
if (viewFinderWidgetControl) {
|
||||
// Check whether platform supports DirectScreen ViewFinder
|
||||
if (m_cameraEngine) {
|
||||
if (m_cameraEngine->IsDirectViewFinderSupported())
|
||||
m_viewfinderNativeType = EDirectScreenViewFinder;
|
||||
else
|
||||
m_viewfinderNativeType = EBitmapViewFinder;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
m_viewfinderDisplay = viewFinderWidgetControl->display();
|
||||
|
||||
if (m_viewfinderNativeType == EDirectScreenViewFinder) {
|
||||
m_viewfinderDisplay->setPaintingEnabled(false); // No Qt Painter painting - Direct rendering
|
||||
connect(m_viewfinderDisplay, SIGNAL(windowHandleChanged(RWindow *)), this, SLOT(resetViewfinderDisplay()));
|
||||
} else {
|
||||
m_viewfinderDisplay->setPaintingEnabled(true); // Qt Painter painting - Bitmap rendering
|
||||
connect(this, SIGNAL(viewFinderFrameReady(const CFbsBitmap &)), m_viewfinderDisplay, SLOT(setFrame(const CFbsBitmap &)));
|
||||
}
|
||||
|
||||
connect(m_viewfinderDisplay, SIGNAL(visibilityChanged(bool)), this, SLOT(handleVisibilityChange(bool)));
|
||||
connect(m_viewfinderDisplay, SIGNAL(displayRectChanged(QRect, QRect)), this, SLOT(resetVideoWindowSize()));
|
||||
connect(m_viewfinderDisplay, SIGNAL(windowHandleChanged(RWindow*)), this, SLOT(handleWindowChange(RWindow*)));
|
||||
|
||||
m_viewfinderSize = m_viewfinderDisplay->extentRect().size();
|
||||
m_viewfinderOutput = viewfinderOutput;
|
||||
m_viewfinderType = OutputTypeVideoWidget;
|
||||
m_isViewFinderVisible = m_viewfinderDisplay->isVisible();
|
||||
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
m_vfState = EVFIsConnectedNotStarted;
|
||||
break;
|
||||
case EVFNotConnectedIsStarted:
|
||||
if (m_isViewFinderVisible)
|
||||
m_vfState = EVFIsConnectedIsStartedIsVisible;
|
||||
else
|
||||
m_vfState = EVFIsConnectedIsStartedNotVisible;
|
||||
break;
|
||||
case EVFIsConnectedNotStarted:
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
// Already connected, state does not change
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible)
|
||||
startViewfinder(true); // Internal start (i.e. start if started externally)
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::setVideoRendererControl(QObject *viewfinderOutput)
|
||||
{
|
||||
// Release old control if it has not already been done
|
||||
if (m_viewfinderOutput)
|
||||
releaseControl(m_viewfinderType);
|
||||
|
||||
// Rotate Camera if UI has rotated
|
||||
checkAndRotateCamera();
|
||||
|
||||
S60VideoRendererControl* viewFinderRenderControl =
|
||||
qobject_cast<S60VideoRendererControl*>(viewfinderOutput);
|
||||
|
||||
if (viewFinderRenderControl) {
|
||||
m_viewfinderNativeType = EBitmapViewFinder; // Always Bitmap
|
||||
|
||||
connect(viewFinderRenderControl, SIGNAL(viewFinderSurfaceSet()),
|
||||
this, SLOT(rendererSurfaceSet()));
|
||||
|
||||
Q_ASSERT(!viewFinderRenderControl->surface());
|
||||
m_viewfinderOutput = viewfinderOutput;
|
||||
m_viewfinderType = OutputTypeRenderer;
|
||||
// RendererControl viewfinder is "visible" when surface is set
|
||||
m_isViewFinderVisible = false;
|
||||
if (EVFIsConnectedIsStartedIsVisible)
|
||||
m_vfState = EVFIsConnectedIsStartedNotVisible;
|
||||
|
||||
// Use display resolution as default viewfinder resolution
|
||||
m_viewfinderSize = QApplication::desktop()->screenGeometry().size();
|
||||
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
m_vfState = EVFIsConnectedNotStarted;
|
||||
break;
|
||||
case EVFNotConnectedIsStarted:
|
||||
m_vfState = EVFIsConnectedIsStartedIsVisible; // GraphicsItem "always visible" (FrameWork decides to draw/not draw)
|
||||
break;
|
||||
case EVFIsConnectedNotStarted:
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
// Already connected, state does not change
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible)
|
||||
startViewfinder(true);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::setVideoWindowControl(QObject *viewfinderOutput)
|
||||
{
|
||||
// Release old control if it has not already been done
|
||||
if (m_viewfinderOutput)
|
||||
releaseControl(m_viewfinderType);
|
||||
|
||||
// Rotate Camera if UI has rotated
|
||||
checkAndRotateCamera();
|
||||
|
||||
S60VideoWindowControl* viewFinderWindowControl =
|
||||
qobject_cast<S60VideoWindowControl*>(viewfinderOutput);
|
||||
|
||||
if (viewFinderWindowControl) {
|
||||
// Check whether platform supports DirectScreen ViewFinder
|
||||
if (m_cameraEngine) {
|
||||
if (m_cameraEngine->IsDirectViewFinderSupported())
|
||||
m_viewfinderNativeType = EDirectScreenViewFinder;
|
||||
else
|
||||
m_viewfinderNativeType = EBitmapViewFinder;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
m_viewfinderDisplay = viewFinderWindowControl->display();
|
||||
|
||||
if (m_viewfinderNativeType == EDirectScreenViewFinder) {
|
||||
m_viewfinderDisplay->setPaintingEnabled(false); // No Qt Painter painting - Direct rendering
|
||||
connect(m_viewfinderDisplay, SIGNAL(windowHandleChanged(RWindow *)), this, SLOT(resetViewfinderDisplay()));
|
||||
} else {
|
||||
m_viewfinderDisplay->setPaintingEnabled(true); // Qt Painter painting - Bitmap rendering
|
||||
connect(this, SIGNAL(viewFinderFrameReady(const CFbsBitmap &)), m_viewfinderDisplay, SLOT(setFrame(const CFbsBitmap &)));
|
||||
}
|
||||
|
||||
connect(m_viewfinderDisplay, SIGNAL(displayRectChanged(QRect, QRect)), this, SLOT(resetVideoWindowSize()));
|
||||
connect(m_viewfinderDisplay, SIGNAL(visibilityChanged(bool)), this, SLOT(handleVisibilityChange(bool)));
|
||||
connect(m_viewfinderDisplay, SIGNAL(windowHandleChanged(RWindow*)), this, SLOT(handleWindowChange(RWindow*)));
|
||||
|
||||
m_viewfinderSize = m_viewfinderDisplay->extentRect().size();
|
||||
m_viewfinderOutput = viewfinderOutput;
|
||||
m_viewfinderType = OutputTypeVideoWindow;
|
||||
m_isViewFinderVisible = m_viewfinderDisplay->isVisible();
|
||||
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
m_vfState = EVFIsConnectedNotStarted;
|
||||
break;
|
||||
case EVFNotConnectedIsStarted:
|
||||
if (m_isViewFinderVisible)
|
||||
m_vfState = EVFIsConnectedIsStartedIsVisible;
|
||||
else
|
||||
m_vfState = EVFIsConnectedIsStartedNotVisible;
|
||||
break;
|
||||
case EVFIsConnectedNotStarted:
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
// Already connected, state does not change
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible)
|
||||
startViewfinder(true); // Internal start (i.e. start if started externally)
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::releaseControl(ViewfinderOutputType type)
|
||||
{
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible)
|
||||
stopViewfinder(true);
|
||||
|
||||
if (m_viewfinderOutput) {
|
||||
switch (type) {
|
||||
case OutputTypeNotSet:
|
||||
return;
|
||||
case OutputTypeVideoWidget:
|
||||
if (m_viewfinderType != OutputTypeVideoWidget)
|
||||
return;
|
||||
disconnect(m_viewfinderOutput);
|
||||
m_viewfinderOutput->disconnect(this);
|
||||
Q_ASSERT(m_viewfinderDisplay);
|
||||
disconnect(m_viewfinderDisplay);
|
||||
m_viewfinderDisplay->disconnect(this);
|
||||
m_viewfinderDisplay = 0;
|
||||
// Invalidate the extent rect
|
||||
qobject_cast<S60VideoWidgetControl*>(m_viewfinderOutput)->setExtentRect(QRect());
|
||||
break;
|
||||
case OutputTypeVideoWindow:
|
||||
if (m_viewfinderType != OutputTypeVideoWindow)
|
||||
return;
|
||||
disconnect(m_viewfinderOutput);
|
||||
m_viewfinderOutput->disconnect(this);
|
||||
Q_ASSERT(m_viewfinderDisplay);
|
||||
disconnect(m_viewfinderDisplay);
|
||||
m_viewfinderDisplay->disconnect(this);
|
||||
m_viewfinderDisplay = 0;
|
||||
break;
|
||||
case OutputTypeRenderer:
|
||||
if (m_viewfinderType != OutputTypeRenderer)
|
||||
return;
|
||||
disconnect(m_viewfinderOutput);
|
||||
m_viewfinderOutput->disconnect(this);
|
||||
if (m_viewfinderSurface)
|
||||
m_viewfinderSurface->disconnect(this);
|
||||
disconnect(this, SIGNAL(viewFinderFrameReady(const CFbsBitmap &)),
|
||||
this, SLOT(viewFinderBitmapReady(const CFbsBitmap &)));
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("Unexpected viewfinder error."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT(!m_viewfinderDisplay);
|
||||
m_viewfinderOutput = 0;
|
||||
m_viewfinderType = OutputTypeNotSet;
|
||||
|
||||
// Update state
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
case EVFNotConnectedIsStarted:
|
||||
// Do nothing
|
||||
break;
|
||||
case EVFIsConnectedNotStarted:
|
||||
m_vfState = EVFNotConnectedNotStarted;
|
||||
break;
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
m_vfState = EVFNotConnectedIsStarted;
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::startViewfinder(const bool internalStart)
|
||||
{
|
||||
if (!internalStart) {
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
m_vfState = EVFNotConnectedIsStarted;
|
||||
break;
|
||||
case EVFIsConnectedNotStarted:
|
||||
if (m_isViewFinderVisible)
|
||||
m_vfState = EVFIsConnectedIsStartedIsVisible;
|
||||
else
|
||||
m_vfState = EVFIsConnectedIsStartedNotVisible;
|
||||
break;
|
||||
case EVFNotConnectedIsStarted:
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
// Already started, state does not change
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Start viewfinder
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible) {
|
||||
|
||||
if (!m_cameraEngine)
|
||||
return;
|
||||
|
||||
if (m_viewfinderNativeType == EDirectScreenViewFinder) {
|
||||
|
||||
if (RWindow *window = m_viewfinderDisplay ? m_viewfinderDisplay->windowHandle() : 0) {
|
||||
m_window = window;
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Requesting window for viewfinder failed."));
|
||||
return;
|
||||
}
|
||||
|
||||
const QRect extentRect = m_viewfinderDisplay ? m_viewfinderDisplay->extentRect() : QRect();
|
||||
const QRect clipRect = m_viewfinderDisplay ? m_viewfinderDisplay->clipRect() : QRect();
|
||||
|
||||
TRect extentRectSymbian = qRect2TRect(extentRect);
|
||||
TRect clipRectSymbian = qRect2TRect(clipRect);
|
||||
TRAPD(err, m_cameraEngine->StartDirectViewFinderL(m_wsSession, m_screenDevice, *m_window, extentRectSymbian, clipRectSymbian));
|
||||
if (err) {
|
||||
if (err == KErrNotSupported) {
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested viewfinder size is not supported."));
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Starting viewfinder failed."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_actualViewFinderSize = QSize(extentRectSymbian.Size().iWidth, extentRectSymbian.Size().iHeight);
|
||||
m_viewfinderAspectRatio = qreal(m_actualViewFinderSize.width()) / qreal(m_actualViewFinderSize.height());
|
||||
|
||||
} else { // Bitmap ViewFinder
|
||||
TSize size = TSize(m_viewfinderSize.width(), m_viewfinderSize.height());
|
||||
|
||||
if( m_viewfinderType == OutputTypeRenderer && m_viewfinderSurface) {
|
||||
if (!m_surfaceFormat.isValid()) {
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Invalid surface format."));
|
||||
return;
|
||||
}
|
||||
|
||||
// Start rendering to surface with correct size and format
|
||||
if (!m_viewfinderSurface->isFormatSupported(m_surfaceFormat) ||
|
||||
!m_viewfinderSurface->start(m_surfaceFormat)) {
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Failed to start surface."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_viewfinderSurface->isActive())
|
||||
return;
|
||||
}
|
||||
|
||||
TRAPD(vfErr, m_cameraEngine->StartViewFinderL(size));
|
||||
if (vfErr) {
|
||||
if (vfErr == KErrNotSupported) {
|
||||
emit error(QCamera::NotSupportedFeatureError, tr("Requested viewfinder size is not supported."));
|
||||
} else {
|
||||
emit error(QCamera::CameraError, tr("Starting viewfinder failed."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_actualViewFinderSize = QSize(size.iWidth, size.iHeight);
|
||||
m_viewfinderAspectRatio = qreal(m_actualViewFinderSize.width()) / qreal(m_actualViewFinderSize.height());
|
||||
|
||||
// Notify control about the frame size (triggers frame position calculation)
|
||||
if (m_viewfinderDisplay) {
|
||||
m_viewfinderDisplay->setNativeSize(m_actualViewFinderSize);
|
||||
} else {
|
||||
if (m_viewfinderType == OutputTypeRenderer && m_viewfinderSurface) {
|
||||
m_viewfinderSurface->stop();
|
||||
QVideoSurfaceFormat format = m_viewfinderSurface->surfaceFormat();
|
||||
format.setFrameSize(QSize(m_actualViewFinderSize));
|
||||
format.setViewport(QRect(0, 0, m_actualViewFinderSize.width(), m_actualViewFinderSize.height()));
|
||||
m_viewfinderSurface->start(format);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::stopViewfinder(const bool internalStop)
|
||||
{
|
||||
// Stop if viewfinder is started
|
||||
if (m_vfState == EVFIsConnectedIsStartedIsVisible) {
|
||||
if (m_viewfinderOutput && m_viewfinderType == OutputTypeRenderer && m_viewfinderSurface) {
|
||||
// Stop surface if one still exists
|
||||
m_viewfinderSurface->stop();
|
||||
}
|
||||
|
||||
if (m_cameraEngine)
|
||||
m_cameraEngine->StopViewFinder();
|
||||
}
|
||||
|
||||
// Update state
|
||||
if (!internalStop) {
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
case EVFIsConnectedNotStarted:
|
||||
// Discard
|
||||
break;
|
||||
case EVFNotConnectedIsStarted:
|
||||
m_vfState = EVFNotConnectedNotStarted;
|
||||
break;
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
m_vfState = EVFIsConnectedNotStarted;
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::MceoViewFinderFrameReady(CFbsBitmap& aFrame)
|
||||
{
|
||||
emit viewFinderFrameReady(aFrame);
|
||||
if (m_cameraEngine)
|
||||
m_cameraEngine->ReleaseViewFinderBuffer();
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::resetViewfinderSize(const QSize size)
|
||||
{
|
||||
m_viewfinderSize = size;
|
||||
|
||||
if(m_vfState != EVFIsConnectedIsStartedIsVisible) {
|
||||
// Set native size to Window/Renderer Control
|
||||
if (m_viewfinderDisplay)
|
||||
m_viewfinderDisplay->setNativeSize(m_actualViewFinderSize);
|
||||
return;
|
||||
}
|
||||
|
||||
stopViewfinder(true);
|
||||
|
||||
startViewfinder(true);
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::resetVideoWindowSize()
|
||||
{
|
||||
if (m_viewfinderDisplay)
|
||||
resetViewfinderSize(m_viewfinderDisplay->extentRect().size());
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::resetViewfinderDisplay()
|
||||
{
|
||||
if (m_viewfinderNativeType == EDirectScreenViewFinder) {
|
||||
|
||||
switch (m_viewfinderType) {
|
||||
case OutputTypeVideoWidget: {
|
||||
if (!m_viewfinderOutput)
|
||||
return;
|
||||
|
||||
// First stop viewfinder
|
||||
stopViewfinder(true);
|
||||
|
||||
RWindow *window = m_viewfinderDisplay->windowHandle();
|
||||
if (!window) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Then start it with the new WindowID
|
||||
startViewfinder(true);
|
||||
break;
|
||||
}
|
||||
case OutputTypeRenderer:
|
||||
case OutputTypeVideoWindow:
|
||||
// Do nothing
|
||||
break;
|
||||
|
||||
default:
|
||||
// Not ViewFinder Output has been set, Discard
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::rendererSurfaceSet()
|
||||
{
|
||||
S60VideoRendererControl* viewFinderRenderControl =
|
||||
qobject_cast<S60VideoRendererControl*>(m_viewfinderOutput);
|
||||
|
||||
// Reset old surface if needed
|
||||
if (m_viewfinderSurface) {
|
||||
handleVisibilityChange(false);
|
||||
disconnect(m_viewfinderSurface);
|
||||
if (viewFinderRenderControl->surface())
|
||||
stopViewfinder(true); // Temporary stop
|
||||
else
|
||||
stopViewfinder(); // Stop for good
|
||||
m_viewfinderSize = QApplication::desktop()->screenGeometry().size();
|
||||
m_viewfinderSurface = 0;
|
||||
}
|
||||
|
||||
// Set new surface
|
||||
m_viewfinderSurface = viewFinderRenderControl->surface();
|
||||
if (!m_viewfinderSurface)
|
||||
return;
|
||||
if (!m_viewfinderSurface->nativeResolution().isEmpty()) {
|
||||
if (m_viewfinderSurface->nativeResolution() != m_viewfinderSize)
|
||||
resetViewfinderSize(m_viewfinderSurface->nativeResolution());
|
||||
}
|
||||
|
||||
connect(m_viewfinderSurface, SIGNAL(nativeResolutionChanged(const QSize&)),
|
||||
this, SLOT(resetViewfinderSize(QSize)));
|
||||
|
||||
// Set Surface Properties
|
||||
if (m_viewfinderSurface->supportedPixelFormats().contains(QVideoFrame::Format_RGB32))
|
||||
m_surfaceFormat = QVideoSurfaceFormat(m_actualViewFinderSize, QVideoFrame::Format_RGB32);
|
||||
else if (m_viewfinderSurface->supportedPixelFormats().contains(QVideoFrame::Format_ARGB32))
|
||||
m_surfaceFormat = QVideoSurfaceFormat(m_actualViewFinderSize, QVideoFrame::Format_ARGB32);
|
||||
else {
|
||||
return;
|
||||
}
|
||||
m_surfaceFormat.setFrameRate(KViewfinderFrameRate);
|
||||
m_surfaceFormat.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_Undefined); // EColor16MU (compatible with EColor16MA)
|
||||
m_surfaceFormat.setPixelAspectRatio(1,1); // PAR 1:1
|
||||
|
||||
|
||||
connect(this, SIGNAL(viewFinderFrameReady(const CFbsBitmap &)),
|
||||
this, SLOT(viewFinderBitmapReady(const CFbsBitmap &)));
|
||||
|
||||
// Surface set, viewfinder is "visible"
|
||||
handleVisibilityChange(true);
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::viewFinderBitmapReady(const CFbsBitmap &bitmap)
|
||||
{
|
||||
CFbsBitmap *bitmapPtr = const_cast<CFbsBitmap*>(&bitmap);
|
||||
QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(bitmapPtr);
|
||||
|
||||
QImage newImage = pixmap.toImage();
|
||||
if (newImage.format() != QImage::Format_ARGB32 &&
|
||||
newImage.format() != QImage::Format_RGB32) {
|
||||
newImage = newImage.convertToFormat(QImage::Format_RGB32);
|
||||
}
|
||||
|
||||
if (!newImage.isNull()) {
|
||||
QVideoFrame newFrame(newImage);
|
||||
if (newFrame.isValid()) {
|
||||
if (!m_viewfinderSurface->present(newFrame)) {
|
||||
// Presenting may fail even if there are no errors (e.g. busy)
|
||||
if (m_viewfinderSurface->error()) {
|
||||
if (m_vfErrorsSignalled < KMaxVFErrorsSignalled) {
|
||||
emit error(QCamera::CameraError, tr("Presenting viewfinder frame failed."));
|
||||
++m_vfErrorsSignalled;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_vfErrorsSignalled < KMaxVFErrorsSignalled) {
|
||||
emit error(QCamera::CameraError, tr("Invalid viewfinder frame was received."));
|
||||
++m_vfErrorsSignalled;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (m_vfErrorsSignalled < KMaxVFErrorsSignalled) {
|
||||
emit error(QCamera::CameraError, tr("Failed to convert viewfinder frame to presentable image."));
|
||||
++m_vfErrorsSignalled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::handleVisibilityChange(const bool isVisible)
|
||||
{
|
||||
if (m_isViewFinderVisible == isVisible)
|
||||
return;
|
||||
|
||||
m_isViewFinderVisible = isVisible;
|
||||
|
||||
if (m_isViewFinderVisible) {
|
||||
switch (m_vfState) {
|
||||
case EVFNotConnectedNotStarted:
|
||||
case EVFIsConnectedNotStarted:
|
||||
case EVFNotConnectedIsStarted:
|
||||
case EVFIsConnectedIsStartedIsVisible:
|
||||
// Discard
|
||||
break;
|
||||
case EVFIsConnectedIsStartedNotVisible:
|
||||
m_vfState = EVFIsConnectedIsStartedIsVisible;
|
||||
break;
|
||||
default:
|
||||
emit error(QCamera::CameraError, tr("General viewfinder error."));
|
||||
break;
|
||||
}
|
||||
startViewfinder(true);
|
||||
} else {
|
||||
// Stopping takes care of the state change
|
||||
stopViewfinder(true);
|
||||
}
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::handleWindowChange(RWindow *handle)
|
||||
{
|
||||
stopViewfinder(true);
|
||||
|
||||
if (handle) // New handle available, start viewfinder
|
||||
startViewfinder(true);
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::checkAndRotateCamera()
|
||||
{
|
||||
bool isUiNowLandscape = false;
|
||||
QDesktopWidget* desktopWidget = QApplication::desktop();
|
||||
QRect screenRect = desktopWidget->screenGeometry();
|
||||
|
||||
if (screenRect.width() > screenRect.height())
|
||||
isUiNowLandscape = true;
|
||||
else
|
||||
isUiNowLandscape = false;
|
||||
|
||||
// Rotate camera if possible
|
||||
if (isUiNowLandscape != m_uiLandscape) {
|
||||
stopViewfinder(true);
|
||||
|
||||
// Request orientation reset
|
||||
m_cameraControl->resetCameraOrientation();
|
||||
}
|
||||
m_uiLandscape = isUiNowLandscape;
|
||||
}
|
||||
|
||||
void S60CameraViewfinderEngine::handleContentAspectRatioChange(const QSize& newSize)
|
||||
{
|
||||
qreal newAspectRatio = qreal(newSize.width()) / qreal(newSize.height());
|
||||
// Check if aspect ratio changed
|
||||
if (qFuzzyCompare(newAspectRatio, m_viewfinderAspectRatio))
|
||||
return;
|
||||
|
||||
// Resize viewfinder by reducing either width or height to comply with the new aspect ratio
|
||||
QSize newNativeResolution;
|
||||
if (newAspectRatio > m_viewfinderAspectRatio) { // New AspectRatio is wider => Reduce height
|
||||
newNativeResolution = QSize(m_actualViewFinderSize.width(), (m_actualViewFinderSize.width() / newAspectRatio));
|
||||
} else { // New AspectRatio is higher => Reduce width
|
||||
newNativeResolution = QSize((m_actualViewFinderSize.height() * newAspectRatio), m_actualViewFinderSize.height());
|
||||
}
|
||||
|
||||
// Notify aspect ratio change (use actual content size to notify that)
|
||||
// This triggers item size/position re-calculation
|
||||
if (m_viewfinderDisplay)
|
||||
m_viewfinderDisplay->setNativeSize(newNativeResolution);
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,182 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef S60CAMERAVIEWFINDERENGINE_H
|
||||
#define S60CAMERAVIEWFINDERENGINE_H
|
||||
|
||||
#include <QtCore/qsize.h>
|
||||
#include <QtGui/qpixmap.h>
|
||||
|
||||
#include <qvideosurfaceformat.h>
|
||||
|
||||
#include "s60cameraengineobserver.h"
|
||||
|
||||
class CCameraEngine;
|
||||
class S60CameraControl;
|
||||
class QAbstractVideoSurface;
|
||||
|
||||
// For DirectScreen ViewFinder
|
||||
class RWsSession;
|
||||
class CWsScreenDevice;
|
||||
class RWindowBase;
|
||||
class RWindow;
|
||||
class QDesktopWidget;
|
||||
|
||||
class S60VideoDisplay;
|
||||
|
||||
/*
|
||||
* Class implementing video output selection for the viewfinder and the handler of
|
||||
* all common viewfinder operations.
|
||||
*/
|
||||
class S60CameraViewfinderEngine : public QObject, public MCameraViewfinderObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Enums
|
||||
|
||||
/*
|
||||
* Defines whether viewfinder output backend control is of type
|
||||
* QVideoWidgetControl, QVideoRendererControl or QVideoWindowControl
|
||||
*/
|
||||
enum ViewfinderOutputType {
|
||||
OutputTypeNotSet = 0, // No viewfinder output connected
|
||||
OutputTypeVideoWidget, // Using QVideoWidget
|
||||
OutputTypeRenderer, // (Using QGraphicsVideoItem with) QVideoRendererControl
|
||||
OutputTypeVideoWindow // Using QGraphicsVideoItem with QVideoWindow
|
||||
};
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
S60CameraViewfinderEngine(S60CameraControl *control,
|
||||
CCameraEngine *engine,
|
||||
QObject *parent = 0);
|
||||
~S60CameraViewfinderEngine();
|
||||
|
||||
public: // Methods
|
||||
|
||||
// Setting Viewfinder Output
|
||||
void setVideoWidgetControl(QObject *viewfinderOutput);
|
||||
void setVideoRendererControl(QObject *viewfinderOutput);
|
||||
void setVideoWindowControl(QObject *viewfinderOutput);
|
||||
void releaseControl(ViewfinderOutputType type);
|
||||
|
||||
// Controls
|
||||
void startViewfinder(const bool internalStart = false);
|
||||
void stopViewfinder(const bool internalStop = false);
|
||||
|
||||
// Start using new CameraEngine
|
||||
void setNewCameraEngine(CCameraEngine *engine);
|
||||
|
||||
protected: // MCameraViewfinderObserver
|
||||
|
||||
void MceoViewFinderFrameReady(CFbsBitmap& aFrame);
|
||||
|
||||
private: // Internal operation
|
||||
|
||||
void checkAndRotateCamera();
|
||||
|
||||
signals:
|
||||
|
||||
void error(int error, const QString &errorString);
|
||||
void viewFinderFrameReady(const CFbsBitmap &bitmap);
|
||||
|
||||
private slots:
|
||||
|
||||
void resetViewfinderSize(const QSize size);
|
||||
void resetVideoWindowSize();
|
||||
void resetViewfinderDisplay();
|
||||
void viewFinderBitmapReady(const CFbsBitmap &bitmap);
|
||||
void handleVisibilityChange(const bool isVisible);
|
||||
void handleWindowChange(RWindow *handle);
|
||||
void handleDesktopResize(int screen);
|
||||
void handleContentAspectRatioChange(const QSize& newSize);
|
||||
void rendererSurfaceSet();
|
||||
|
||||
private: // Enums
|
||||
|
||||
/*
|
||||
* Defines the internal state of the viewfinder. ViewFinder will only be
|
||||
* started if output is connected to Camera and Camera is started (and
|
||||
* ViewFinder widget is visible in case of QVideoWidget).
|
||||
*/
|
||||
enum ViewFinderState {
|
||||
EVFNotConnectedNotStarted = 0, // 0 - No output connected, viewfinder is not started
|
||||
EVFNotConnectedIsStarted, // 1 - No output connected, viewfinder is started
|
||||
EVFIsConnectedNotStarted, // 2 - Output is connected, viewfinder is not started
|
||||
EVFIsConnectedIsStartedNotVisible, // 3 - Output is connected, viewfinder is started but is not visible
|
||||
EVFIsConnectedIsStartedIsVisible // 4 - Output is connected, viewfinder is started and is visible
|
||||
};
|
||||
|
||||
/*
|
||||
* The native type of ViewFinder. DirectScreen ViewFinder is used with
|
||||
* QVideoWidget if support for it is available in the platform. For
|
||||
* QGraphicsVideoItem Bitmap ViewFinder is always used.
|
||||
*/
|
||||
enum NativeViewFinderType {
|
||||
EBitmapViewFinder = 0,
|
||||
EDirectScreenViewFinder
|
||||
};
|
||||
|
||||
private: // Data
|
||||
|
||||
CCameraEngine *m_cameraEngine;
|
||||
S60CameraControl *m_cameraControl;
|
||||
QObject *m_viewfinderOutput;
|
||||
S60VideoDisplay *m_viewfinderDisplay;
|
||||
QAbstractVideoSurface *m_viewfinderSurface; // Used only by QVideoRendererControl
|
||||
RWsSession &m_wsSession;
|
||||
CWsScreenDevice &m_screenDevice;
|
||||
RWindowBase *m_window;
|
||||
QDesktopWidget *m_desktopWidget;
|
||||
ViewFinderState m_vfState;
|
||||
QSize m_viewfinderSize;
|
||||
// Actual viewfinder size, which may differ from requested
|
||||
// (m_viewfinderSize), if the size/aspect ratio was not supported.
|
||||
QSize m_actualViewFinderSize;
|
||||
qreal m_viewfinderAspectRatio;
|
||||
ViewfinderOutputType m_viewfinderType;
|
||||
NativeViewFinderType m_viewfinderNativeType;
|
||||
QVideoSurfaceFormat m_surfaceFormat; // Used only by QVideoRendererControl
|
||||
bool m_isViewFinderVisible;
|
||||
bool m_uiLandscape; // For detecting UI rotation
|
||||
int m_vfErrorsSignalled;
|
||||
};
|
||||
|
||||
#endif // S60CAMERAVIEWFINDERENGINE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,359 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60IMAGECAPTURESESSION_H
|
||||
#define S60IMAGECAPTURESESSION_H
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <QtGui/qicon.h>
|
||||
|
||||
#include <qcamera.h>
|
||||
#include <qcamerafocus.h>
|
||||
#include <qcameraimagecapture.h>
|
||||
#include <qvideoframe.h>
|
||||
|
||||
#include "s60camerasettings.h"
|
||||
#include "s60cameraengine.h"
|
||||
#include "s60cameraengineobserver.h"
|
||||
#include "s60cameraconstants.h" // Default Jpeg Quality
|
||||
|
||||
#include <icl/imagedata.h> // TFrameInfo
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraService;
|
||||
class CImageDecoder;
|
||||
class CImageEncoder;
|
||||
class CFrameImageData;
|
||||
class RFs;
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* This class implements asynchronous image decoding service for the
|
||||
* S60ImageCaptureSession.
|
||||
*/
|
||||
class S60ImageCaptureDecoder : public CActive
|
||||
{
|
||||
public: // Static Contructor & Destructor
|
||||
|
||||
static S60ImageCaptureDecoder* FileNewL(S60ImageCaptureSession *imageSession = 0,
|
||||
RFs *fileSystemAccess = 0,
|
||||
const TDesC16 *fileName = 0);
|
||||
static S60ImageCaptureDecoder* DataNewL(S60ImageCaptureSession *imageSession = 0,
|
||||
RFs *fileSystemAccess = 0,
|
||||
const TDesC8 *data = 0);
|
||||
~S60ImageCaptureDecoder();
|
||||
|
||||
public: // Operations
|
||||
|
||||
void decode(CFbsBitmap *destBitmap);
|
||||
TFrameInfo *frameInfo();
|
||||
|
||||
protected: // CActive
|
||||
|
||||
void RunL();
|
||||
void DoCancel();
|
||||
TInt RunError(TInt aError);
|
||||
|
||||
protected: // Protected constructors
|
||||
|
||||
S60ImageCaptureDecoder(S60ImageCaptureSession *imageSession,
|
||||
RFs *fileSystemAccess,
|
||||
const TDesC8 *data,
|
||||
const TDesC16 *fileName);
|
||||
void ConstructL(const bool fileInput = false);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_imageSession;
|
||||
CImageDecoder *m_imageDecoder;
|
||||
RFs *m_fs;
|
||||
const TDesC8 *m_jpegImageData;
|
||||
const TDesC16 *m_jpegImageFile;
|
||||
bool m_fileInput;
|
||||
TFrameInfo m_frameInfo;
|
||||
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
* This class implements asynchronous image encoding service for the
|
||||
* S60ImageCaptureSession.
|
||||
*/
|
||||
class S60ImageCaptureEncoder : public CActive
|
||||
{
|
||||
public: // Static Contructor & Destructor
|
||||
|
||||
static S60ImageCaptureEncoder* NewL(S60ImageCaptureSession *imageSession = 0,
|
||||
RFs *fileSystemAccess = 0,
|
||||
const TDesC16 *fileName = 0,
|
||||
TInt jpegQuality = KDefaultImageQuality);
|
||||
~S60ImageCaptureEncoder();
|
||||
|
||||
public: // Operations
|
||||
|
||||
void encode(CFbsBitmap *sourceBitmap);
|
||||
|
||||
protected: // CActive
|
||||
|
||||
void RunL();
|
||||
void DoCancel();
|
||||
TInt RunError(TInt aError);
|
||||
|
||||
protected: // Protected constructors
|
||||
|
||||
S60ImageCaptureEncoder(S60ImageCaptureSession *imageSession,
|
||||
RFs *fileSystemAccess,
|
||||
const TDesC16 *fileName,
|
||||
TInt jpegQuality);
|
||||
void ConstructL();
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_imageSession;
|
||||
CImageEncoder *m_imageEncoder;
|
||||
RFs *m_fileSystemAccess;
|
||||
const TDesC16 *m_fileName;
|
||||
CFrameImageData *m_frameImageData;
|
||||
TInt m_jpegQuality;
|
||||
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*
|
||||
* Session handling all image capture activities.
|
||||
*/
|
||||
class S60ImageCaptureSession : public QObject,
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
public MCameraPreviewObserver,
|
||||
#endif // ECAM_PREVIEW_API
|
||||
public MCameraEngineImageCaptureObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Enums
|
||||
|
||||
enum ImageCaptureState {
|
||||
EImageCaptureNotPrepared = 0, // 0 - ImageCapture has not been prepared
|
||||
EImageCapturePrepared, // 1 - ImageCapture has been prepared
|
||||
EImageCaptureCapturing, // 2 - Image capture ongoing
|
||||
EImageCaptureWritingImage // 3 - Image captured and image writing to file ongoing
|
||||
};
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
S60ImageCaptureSession(QObject *parent = 0);
|
||||
~S60ImageCaptureSession();
|
||||
|
||||
public: // Methods
|
||||
|
||||
void setError(const TInt error, const QString &description, const bool captureError = false);
|
||||
int currentImageId() const;
|
||||
|
||||
bool isDeviceReady();
|
||||
void setCameraHandle(CCameraEngine* camerahandle);
|
||||
void setCurrentDevice(TInt deviceindex);
|
||||
void notifySettingsSet();
|
||||
|
||||
// Ecam Advanced Settings
|
||||
S60CameraSettings* advancedSettings();
|
||||
void deleteAdvancedSettings();
|
||||
|
||||
// Controls
|
||||
int prepareImageCapture();
|
||||
void releaseImageCapture();
|
||||
int capture(const QString &fileName);
|
||||
void cancelCapture();
|
||||
void releaseImageBuffer();
|
||||
|
||||
// Image Resolution
|
||||
QSize captureSize() const;
|
||||
QSize minimumCaptureSize();
|
||||
QSize maximumCaptureSize();
|
||||
QList<QSize> supportedCaptureSizesForCodec(const QString &codecName);
|
||||
void setCaptureSize(const QSize &size);
|
||||
|
||||
// Image Codec
|
||||
QStringList supportedImageCaptureCodecs();
|
||||
QString imageCaptureCodec();
|
||||
void setImageCaptureCodec(const QString &codecName);
|
||||
QString imageCaptureCodecDescription(const QString &codecName);
|
||||
|
||||
// Image Quality
|
||||
QtMultimediaKit::EncodingQuality captureQuality() const;
|
||||
void setCaptureQuality(const QtMultimediaKit::EncodingQuality &quality);
|
||||
|
||||
// S60 3.1 Focus Control (S60 3.2 and later via S60CameraSettings class)
|
||||
bool isFocusSupported() const;
|
||||
void startFocus();
|
||||
void cancelFocus();
|
||||
|
||||
// Zoom Control
|
||||
qreal maximumZoom();
|
||||
qreal minZoom();
|
||||
qreal maxDigitalZoom();
|
||||
void doSetZoomFactorL(qreal optical, qreal digital);
|
||||
qreal opticalZoomFactor();
|
||||
qreal digitalZoomFactor();
|
||||
|
||||
// Exposure Mode Control
|
||||
QCameraExposure::ExposureMode exposureMode();
|
||||
void setExposureMode(QCameraExposure::ExposureMode mode);
|
||||
bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const;
|
||||
|
||||
// Flash Mode Control
|
||||
QCameraExposure::FlashMode flashMode();
|
||||
void setFlashMode(QCameraExposure::FlashModes mode);
|
||||
QCameraExposure::FlashModes supportedFlashModes();
|
||||
|
||||
// Contrast Control
|
||||
int contrast() const;
|
||||
void setContrast(int value);
|
||||
|
||||
// Brightness Control
|
||||
int brightness() const;
|
||||
void setBrightness(int value);
|
||||
|
||||
// White Balance Mode Control
|
||||
QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode();
|
||||
void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode);
|
||||
bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const;
|
||||
|
||||
public: // Image Decoding & Encoding Notifications
|
||||
|
||||
void handleImageDecoded(int error);
|
||||
void handleImageEncoded(int error);
|
||||
|
||||
protected: // MCameraEngineObserver
|
||||
|
||||
void MceoFocusComplete();
|
||||
void MceoCapturedDataReady(TDesC8* aData);
|
||||
void MceoCapturedBitmapReady(CFbsBitmap* aBitmap);
|
||||
void MceoHandleError(TCameraEngineError aErrorType, TInt aError);
|
||||
|
||||
#ifdef ECAM_PREVIEW_API
|
||||
protected: // MCameraPreviewObserver
|
||||
|
||||
void MceoPreviewReady(CFbsBitmap& aPreview);
|
||||
#endif // ECAM_PREVIEW_API
|
||||
|
||||
private: // Internal
|
||||
|
||||
QCameraImageCapture::Error fromSymbianErrorToQtMultimediaError(int aError);
|
||||
|
||||
void initializeImageCaptureSettings();
|
||||
void resetSession(bool errorHandling = false);
|
||||
|
||||
CCamera::TFormat selectFormatForCodec(const QString &codec);
|
||||
CCamera::TFormat defaultImageFormat();
|
||||
bool queryCurrentCameraInfo();
|
||||
QMap<QString, int> formatMap();
|
||||
QMap<QString, QString> codecDescriptionMap();
|
||||
void updateImageCaptureFormats();
|
||||
|
||||
void doSetWhiteBalanceModeL(QCameraImageProcessing::WhiteBalanceMode mode);
|
||||
|
||||
void doSetFlashModeL(QCameraExposure::FlashModes mode);
|
||||
void doSetExposureModeL(QCameraExposure::ExposureMode mode);
|
||||
|
||||
void saveImageL(TDesC8 *aData, TFileName &aPath);
|
||||
void processFileName(const QString &fileName);
|
||||
TFileName convertImagePath();
|
||||
|
||||
signals: // Notifications
|
||||
|
||||
void stateChanged(QCamera::State);
|
||||
void advancedSettingChanged();
|
||||
void captureSizeChanged(const QSize&);
|
||||
|
||||
// Error signals
|
||||
void cameraError(int, const QString&); // For QCamera::error
|
||||
void captureError(int, int, const QString&); // For QCameraImageCapture::error
|
||||
|
||||
// Capture notifications
|
||||
void readyForCaptureChanged(bool);
|
||||
void imageExposed(int);
|
||||
void imageCaptured(const int, const QImage&);
|
||||
void imageSaved(const int, const QString&);
|
||||
|
||||
// Focus notifications
|
||||
void focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason);
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void cameraStatusChanged(QCamera::Status);
|
||||
|
||||
private: // Data
|
||||
|
||||
CCameraEngine *m_cameraEngine;
|
||||
S60CameraSettings *m_advancedSettings;
|
||||
mutable TCameraInfo *m_cameraInfo;
|
||||
CFbsBitmap *m_previewBitmap;
|
||||
CActiveScheduler *m_activeScheduler;
|
||||
RFs *m_fileSystemAccess;
|
||||
S60ImageCaptureDecoder *m_imageDecoder;
|
||||
S60ImageCaptureEncoder *m_imageEncoder;
|
||||
mutable int m_error; // Symbian ErrorCode
|
||||
TInt m_activeDeviceIndex;
|
||||
bool m_cameraStarted;
|
||||
ImageCaptureState m_icState;
|
||||
QStringList m_supportedImageCodecs;
|
||||
QString m_currentCodec;
|
||||
CCamera::TFormat m_currentFormat;
|
||||
QSize m_captureSize;
|
||||
int m_symbianImageQuality;
|
||||
bool m_captureSettingsSet;
|
||||
QString m_stillCaptureFileName;
|
||||
QString m_requestedStillCaptureFileName;
|
||||
mutable int m_currentImageId;
|
||||
QList<uint> m_formats;
|
||||
// This indicates that image capture should be triggered right after
|
||||
// camera and image setting initialization has completed
|
||||
bool m_captureWhenReady;
|
||||
bool m_previewDecodingOngoing;
|
||||
bool m_previewInWaitLoop;
|
||||
};
|
||||
|
||||
#endif // S60IMAGECAPTURESESSION_H
|
||||
@@ -1,128 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
|
||||
#include "s60imageencodercontrol.h"
|
||||
#include "s60imagecapturesession.h"
|
||||
|
||||
S60ImageEncoderControl::S60ImageEncoderControl(QObject *parent) :
|
||||
QImageEncoderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60ImageEncoderControl::S60ImageEncoderControl(S60ImageCaptureSession *session, QObject *parent) :
|
||||
QImageEncoderControl(parent)
|
||||
{
|
||||
m_session = session;
|
||||
}
|
||||
|
||||
S60ImageEncoderControl::~S60ImageEncoderControl()
|
||||
{
|
||||
}
|
||||
|
||||
QList<QSize> S60ImageEncoderControl::supportedResolutions(
|
||||
const QImageEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
QList<QSize> resolutions = m_session->supportedCaptureSizesForCodec(settings.codec());
|
||||
|
||||
// Discrete resolutions are returned
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return resolutions;
|
||||
}
|
||||
QStringList S60ImageEncoderControl::supportedImageCodecs() const
|
||||
{
|
||||
return m_session->supportedImageCaptureCodecs();
|
||||
}
|
||||
|
||||
QString S60ImageEncoderControl::imageCodecDescription(const QString &codec) const
|
||||
{
|
||||
return m_session->imageCaptureCodecDescription(codec);
|
||||
}
|
||||
|
||||
QImageEncoderSettings S60ImageEncoderControl::imageSettings() const
|
||||
{
|
||||
// Update setting values from session
|
||||
QImageEncoderSettings settings;
|
||||
settings.setCodec(m_session->imageCaptureCodec());
|
||||
settings.setResolution(m_session->captureSize());
|
||||
settings.setQuality(m_session->captureQuality());
|
||||
|
||||
return settings;
|
||||
}
|
||||
void S60ImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
|
||||
{
|
||||
// Notify that settings have been implicitly set and there's no need to
|
||||
// initialize them in case camera is changed
|
||||
m_session->notifySettingsSet();
|
||||
|
||||
if (!settings.isNull()) {
|
||||
if (!settings.codec().isEmpty()) {
|
||||
if (settings.resolution() != QSize(-1,-1)) { // Codec, Resolution & Quality
|
||||
m_session->setImageCaptureCodec(settings.codec());
|
||||
m_session->setCaptureSize(settings.resolution());
|
||||
m_session->setCaptureQuality(settings.quality());
|
||||
} else { // Codec and Quality
|
||||
m_session->setImageCaptureCodec(settings.codec());
|
||||
m_session->setCaptureQuality(settings.quality());
|
||||
}
|
||||
} else {
|
||||
if (settings.resolution() != QSize(-1,-1)) { // Resolution & Quality
|
||||
m_session->setCaptureSize(settings.resolution());
|
||||
m_session->setCaptureQuality(settings.quality());
|
||||
}
|
||||
else // Only Quality
|
||||
m_session->setCaptureQuality(settings.quality());
|
||||
}
|
||||
|
||||
// Prepare ImageCapture with the settings and set error if needed
|
||||
int prepareSuccess = m_session->prepareImageCapture();
|
||||
|
||||
// Preparation fails with KErrNotReady if camera has not been started.
|
||||
// That can be ignored since settings are set internally in that case.
|
||||
if (prepareSuccess != KErrNotReady && prepareSuccess != KErrNone)
|
||||
m_session->setError(prepareSuccess, tr("Failure in preparation of image capture."));
|
||||
}
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,84 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60IMAGEENCODERCONTROL_H
|
||||
#define S60IMAGEENCODERCONTROL_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include "qimageencodercontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60ImageCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for setting encoding settings for the captured image.
|
||||
*/
|
||||
class S60ImageEncoderControl : public QImageEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destructor
|
||||
|
||||
S60ImageEncoderControl(QObject *parent = 0);
|
||||
S60ImageEncoderControl(S60ImageCaptureSession *session, QObject *parent = 0);
|
||||
~S60ImageEncoderControl();
|
||||
|
||||
public: // QImageEncoderControl
|
||||
|
||||
// Codec
|
||||
QStringList supportedImageCodecs() const;
|
||||
QString imageCodecDescription(const QString &codec) const;
|
||||
|
||||
// Resolution
|
||||
QList<QSize> supportedResolutions(const QImageEncoderSettings &settings,
|
||||
bool *continuous = 0) const;
|
||||
|
||||
// Settings
|
||||
QImageEncoderSettings imageSettings() const;
|
||||
void setImageSettings(const QImageEncoderSettings &settings);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60ImageCaptureSession *m_session;
|
||||
};
|
||||
|
||||
#endif // S60IMAGEENCODERCONTROL_H
|
||||
@@ -1,97 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60mediacontainercontrol.h"
|
||||
#include "s60videocapturesession.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
S60MediaContainerControl::S60MediaContainerControl(QObject *parent):
|
||||
QMediaContainerControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60MediaContainerControl::S60MediaContainerControl(S60VideoCaptureSession *session, QObject *parent):
|
||||
QMediaContainerControl(parent)
|
||||
{
|
||||
m_session = session;
|
||||
|
||||
// Set default video container
|
||||
m_supportedContainers = m_session->supportedVideoContainers();
|
||||
|
||||
if (!m_supportedContainers.isEmpty()) {
|
||||
// Check if default container is supported
|
||||
if (m_supportedContainers.indexOf(KMimeTypeDefaultContainer) != -1)
|
||||
setContainerMimeType(KMimeTypeDefaultContainer);
|
||||
// Otherwise use first in the list
|
||||
else
|
||||
setContainerMimeType(m_supportedContainers[0]); // First as default
|
||||
} else {
|
||||
m_session->setError(KErrGeneral, tr("No supported video containers found."));
|
||||
}
|
||||
}
|
||||
|
||||
S60MediaContainerControl::~S60MediaContainerControl()
|
||||
{
|
||||
m_supportedContainers.clear();
|
||||
m_containerDescriptions.clear();
|
||||
}
|
||||
|
||||
QStringList S60MediaContainerControl::supportedContainers() const
|
||||
{
|
||||
return m_session->supportedVideoContainers();
|
||||
}
|
||||
|
||||
QString S60MediaContainerControl::containerMimeType() const
|
||||
{
|
||||
return m_session->videoContainer();
|
||||
}
|
||||
|
||||
void S60MediaContainerControl::setContainerMimeType(const QString &containerMimeType)
|
||||
{
|
||||
m_session->setVideoContainer(containerMimeType);
|
||||
}
|
||||
|
||||
QString S60MediaContainerControl::containerDescription(const QString &containerMimeType) const
|
||||
{
|
||||
return m_session->videoContainerDescription(containerMimeType);
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIACONTAINERCONTROL_H
|
||||
#define S60MEDIACONTAINERCONTROL_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
#include <qmediacontainercontrol.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60VideoCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for setting container (file format) for video recorded using
|
||||
* QMediaRecorder.
|
||||
*/
|
||||
class S60MediaContainerControl : public QMediaContainerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destructor
|
||||
|
||||
S60MediaContainerControl(QObject *parent = 0);
|
||||
S60MediaContainerControl(S60VideoCaptureSession *session, QObject *parent = 0);
|
||||
virtual ~S60MediaContainerControl();
|
||||
|
||||
public: // QMediaContainerControl
|
||||
|
||||
QStringList supportedContainers() const;
|
||||
QString containerMimeType() const;
|
||||
void setContainerMimeType(const QString &containerMimeType);
|
||||
|
||||
QString containerDescription(const QString &containerMimeType) const;
|
||||
|
||||
private: // Data
|
||||
|
||||
S60VideoCaptureSession *m_session;
|
||||
QStringList m_supportedContainers;
|
||||
QMap<QString, QString> m_containerDescriptions;
|
||||
};
|
||||
|
||||
#endif // S60MEDIACONTAINERCONTROL_H
|
||||
@@ -1,187 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60cameraservice.h"
|
||||
#include "s60mediarecordercontrol.h"
|
||||
#include "s60cameracontrol.h"
|
||||
#include "s60videocapturesession.h"
|
||||
|
||||
S60MediaRecorderControl::S60MediaRecorderControl(QObject *parent) :
|
||||
QMediaRecorderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60MediaRecorderControl::S60MediaRecorderControl(S60CameraService *service,
|
||||
S60VideoCaptureSession *session,
|
||||
QObject *parent):
|
||||
QMediaRecorderControl(parent),
|
||||
m_state(QMediaRecorder::StoppedState) // Default RecorderState
|
||||
{
|
||||
m_session = session;
|
||||
m_service = service;
|
||||
m_cameraControl = qobject_cast<S60CameraControl *>(m_service->requestControl(QCameraControl_iid));
|
||||
|
||||
// Connect signals
|
||||
connect(m_session, SIGNAL(stateChanged(S60VideoCaptureSession::TVideoCaptureState)),
|
||||
this, SLOT(updateState(S60VideoCaptureSession::TVideoCaptureState)));
|
||||
connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
|
||||
connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool)));
|
||||
connect(m_session, SIGNAL(error(int,const QString &)), this, SIGNAL(error(int,const QString &)));
|
||||
}
|
||||
|
||||
S60MediaRecorderControl::~S60MediaRecorderControl()
|
||||
{
|
||||
// Release requested control
|
||||
if (m_cameraControl)
|
||||
m_service->releaseControl(m_cameraControl);
|
||||
}
|
||||
|
||||
QUrl S60MediaRecorderControl::outputLocation() const
|
||||
{
|
||||
return m_session->outputLocation();
|
||||
}
|
||||
|
||||
bool S60MediaRecorderControl::setOutputLocation(const QUrl& sink)
|
||||
{
|
||||
// Output location can only be set in StoppedState
|
||||
if (m_state == QMediaRecorder::StoppedState)
|
||||
return m_session->setOutputLocation(sink);
|
||||
|
||||
// Do not signal error, but notify that setting was not effective
|
||||
return false;
|
||||
}
|
||||
|
||||
QMediaRecorder::State S60MediaRecorderControl::convertInternalStateToQtState(S60VideoCaptureSession::TVideoCaptureState aState) const
|
||||
{
|
||||
QMediaRecorder::State state;
|
||||
|
||||
switch (aState) {
|
||||
case S60VideoCaptureSession::ERecording:
|
||||
state = QMediaRecorder::RecordingState;
|
||||
break;
|
||||
case S60VideoCaptureSession::EPaused:
|
||||
state = QMediaRecorder::PausedState;
|
||||
break;
|
||||
|
||||
default:
|
||||
// All others
|
||||
state = QMediaRecorder::StoppedState;
|
||||
break;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void S60MediaRecorderControl::updateState(S60VideoCaptureSession::TVideoCaptureState state)
|
||||
{
|
||||
QMediaRecorder::State newState = convertInternalStateToQtState(state);
|
||||
|
||||
if (m_state != newState) {
|
||||
m_state = newState;
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
}
|
||||
|
||||
QMediaRecorder::State S60MediaRecorderControl::state() const
|
||||
{
|
||||
return m_state;
|
||||
}
|
||||
|
||||
qint64 S60MediaRecorderControl::duration() const
|
||||
{
|
||||
return m_session->position();
|
||||
}
|
||||
|
||||
/*
|
||||
This method is called after encoder configuration is done.
|
||||
Encoder can load necessary resources at this point,
|
||||
to reduce delay before recording is started. Calling this method reduces the
|
||||
latency when calling record() to start video recording.
|
||||
*/
|
||||
void S60MediaRecorderControl::applySettings()
|
||||
{
|
||||
m_session->applyAllSettings();
|
||||
}
|
||||
|
||||
void S60MediaRecorderControl::record()
|
||||
{
|
||||
if (m_state == QMediaRecorder::RecordingState)
|
||||
return;
|
||||
|
||||
if (m_cameraControl && m_cameraControl->captureMode() != QCamera::CaptureVideo) {
|
||||
emit error(QCamera::CameraError, tr("Video capture mode is not selected."));
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->startRecording();
|
||||
}
|
||||
|
||||
void S60MediaRecorderControl::pause()
|
||||
{
|
||||
if (m_state != QMediaRecorder::RecordingState) {
|
||||
// Discard
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->pauseRecording();
|
||||
}
|
||||
|
||||
void S60MediaRecorderControl::stop()
|
||||
{
|
||||
if (m_state == QMediaRecorder::StoppedState) {
|
||||
// Ignore
|
||||
return;
|
||||
}
|
||||
|
||||
m_session->stopRecording();
|
||||
}
|
||||
|
||||
bool S60MediaRecorderControl::isMuted() const
|
||||
{
|
||||
return m_session->isMuted();
|
||||
}
|
||||
|
||||
void S60MediaRecorderControl::setMuted(bool muted)
|
||||
{
|
||||
m_session->setMuted(muted);
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,118 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIARECORDERCONTROL_H
|
||||
#define S60MEDIARECORDERCONTROL_H
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <qmediarecorder.h>
|
||||
#include <qmediarecordercontrol.h>
|
||||
|
||||
#include "s60videocapturesession.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60VideoCaptureSession;
|
||||
class S60CameraService;
|
||||
class S60CameraControl;
|
||||
|
||||
/*
|
||||
* Control for video recording operations.
|
||||
*/
|
||||
class S60MediaRecorderControl : public QMediaRecorderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destructor
|
||||
|
||||
S60MediaRecorderControl(QObject *parent = 0);
|
||||
S60MediaRecorderControl(S60CameraService *service,
|
||||
S60VideoCaptureSession *session,
|
||||
QObject *parent = 0);
|
||||
~S60MediaRecorderControl();
|
||||
|
||||
public: // QMediaRecorderControl
|
||||
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl &sink);
|
||||
|
||||
QMediaRecorder::State state() const;
|
||||
|
||||
qint64 duration() const;
|
||||
|
||||
bool isMuted() const;
|
||||
|
||||
void applySettings();
|
||||
|
||||
/*
|
||||
Q_SIGNALS: // QMediaRecorderControl
|
||||
void stateChanged(QMediaRecorder::State state);
|
||||
void durationChanged(qint64 position);
|
||||
void mutedChanged(bool muted);
|
||||
void error(int error, const QString &errorString);
|
||||
*/
|
||||
|
||||
public slots: // QMediaRecorderControl
|
||||
|
||||
void record();
|
||||
void pause();
|
||||
void stop();
|
||||
void setMuted(bool);
|
||||
|
||||
private:
|
||||
|
||||
QMediaRecorder::State convertInternalStateToQtState(
|
||||
S60VideoCaptureSession::TVideoCaptureState aState) const;
|
||||
|
||||
private slots:
|
||||
|
||||
void updateState(S60VideoCaptureSession::TVideoCaptureState state);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60VideoCaptureSession *m_session;
|
||||
S60CameraService *m_service;
|
||||
S60CameraControl *m_cameraControl;
|
||||
QMediaRecorder::State m_state;
|
||||
|
||||
};
|
||||
|
||||
#endif // S60MEDIARECORDERCONTROL_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,414 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60VIDEOCAPTURESESSION_H
|
||||
#define S60VIDEOCAPTURESESSION_H
|
||||
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qhash.h>
|
||||
|
||||
#include <qmediaencodersettings.h>
|
||||
#include <qcamera.h>
|
||||
#include <qmediarecorder.h>
|
||||
|
||||
#include "s60cameraengine.h"
|
||||
|
||||
#include <e32base.h>
|
||||
#include <videorecorder.h> // CVideoRecorderUtility
|
||||
#ifdef S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
#include <mmf/devvideo/devvideorecord.h>
|
||||
#endif // S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class QTimer;
|
||||
|
||||
/*
|
||||
* VideoSession is the main class handling all video recording related
|
||||
* operations. It uses mainly CVideoRecorderUtility to do it's tasks, but if
|
||||
* DevVideoRecord is available it is used to provide more detailed
|
||||
* information of the supported video settings.
|
||||
*/
|
||||
class S60VideoCaptureSession : public QObject,
|
||||
public MVideoRecorderUtilityObserver
|
||||
#ifdef S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
,public MMMFDevVideoRecordObserver
|
||||
#endif // S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Error)
|
||||
Q_ENUMS(EcamErrors)
|
||||
Q_ENUMS(TVideoCaptureState)
|
||||
|
||||
public: // Enums
|
||||
|
||||
enum TVideoCaptureState
|
||||
{
|
||||
ENotInitialized = 0, // 0 - VideoRecording is not initialized, instance may or may not be created
|
||||
EInitializing, // 1 - Initialization is ongoing
|
||||
EInitialized, // 2 - VideoRecording is initialized, OpenFile is called with dummy file
|
||||
EOpening, // 3 - OpenFile called with actual output location, waiting completion
|
||||
EOpenComplete, // 4 - OpenFile completed with the actual output location
|
||||
EPreparing, // 5 - Preparing VideoRecording to use set video settings
|
||||
EPrepared, // 6 - VideoRecording is prepared with the set settings, ready to record
|
||||
ERecording, // 7 - Video recording is ongoing
|
||||
EPaused // 8 - Video recording has been started and paused
|
||||
};
|
||||
|
||||
enum AudioQualityDefinition
|
||||
{
|
||||
ENoAudioQuality = 0, // 0 - Both BitRate and SampleRate settings available
|
||||
EOnlyAudioQuality, // 1 - No BitRate or SampleRate settings available, use Quality to set them
|
||||
EAudioQualityAndBitRate, // 2 - BitRate setting available, use Quality to set SampleRate
|
||||
EAudioQualityAndSampleRate, // 3 - SampleRate setting available, use Quality to set BitRate
|
||||
};
|
||||
|
||||
enum VideoQualityDefinition
|
||||
{
|
||||
ENoVideoQuality = 0, // 0 - All, Resolution, FrameRate and BitRate available
|
||||
EOnlyVideoQuality, // 1 - None available, use Quality to set Resolution, FrameRate and BitRate
|
||||
EVideoQualityAndResolution, // 2 - Only Resolution available, use Quality to set FrameRate and BitRate
|
||||
EVideoQualityAndFrameRate, // 3 - Only FrameRate available, use Quality to set Resolution and BitRate
|
||||
EVideoQualityAndBitRate, // 4 - Only BitRate available, use Quality to set Resolution and FrameRate
|
||||
EVideoQualityAndResolutionAndBitRate, // 5 - No FrameRate available, use Quality to set it
|
||||
EVideoQualityAndResolutionAndFrameRate, // 6 - No BitRate available, use Quality to set it
|
||||
EVideoQualityAndFrameRateAndBitRate // 7 - No Resolution available, use Quality to set it
|
||||
};
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
S60VideoCaptureSession(QObject *parent = 0);
|
||||
~S60VideoCaptureSession();
|
||||
|
||||
public: // MVideoRecorderUtilityObserver
|
||||
|
||||
void MvruoOpenComplete(TInt aError);
|
||||
void MvruoPrepareComplete(TInt aError);
|
||||
void MvruoRecordComplete(TInt aError);
|
||||
void MvruoEvent(const TMMFEvent& aEvent);
|
||||
|
||||
#ifdef S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
public: // MMMFDevVideoRecordObserver
|
||||
void MdvroReturnPicture(TVideoPicture *aPicture);
|
||||
void MdvroSupplementalInfoSent();
|
||||
void MdvroNewBuffers();
|
||||
void MdvroFatalError(TInt aError);
|
||||
void MdvroInitializeComplete(TInt aError);
|
||||
void MdvroStreamEnd();
|
||||
#endif // S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
|
||||
public: // Methods
|
||||
|
||||
void setError(const TInt error, const QString &description);
|
||||
void setCameraHandle(CCameraEngine* cameraHandle);
|
||||
void notifySettingsSet();
|
||||
|
||||
qint64 position();
|
||||
TVideoCaptureState state() const;
|
||||
bool isMuted() const;
|
||||
|
||||
// Controls
|
||||
int initializeVideoRecording();
|
||||
void releaseVideoRecording();
|
||||
void applyAllSettings();
|
||||
|
||||
void startRecording();
|
||||
void pauseRecording();
|
||||
void stopRecording(const bool reInitialize = true);
|
||||
void setMuted(const bool muted);
|
||||
|
||||
// Output Location
|
||||
bool setOutputLocation(const QUrl &sink);
|
||||
QUrl outputLocation() const;
|
||||
|
||||
// Resolution
|
||||
void setVideoResolution(const QSize &resolution);
|
||||
QList<QSize> supportedVideoResolutions(bool *continuous);
|
||||
QList<QSize> supportedVideoResolutions(const QVideoEncoderSettings &settings, bool *continuous);
|
||||
|
||||
// Framerate
|
||||
void setFrameRate(const qreal rate);
|
||||
QList<qreal> supportedVideoFrameRates(bool *continuous);
|
||||
QList<qreal> supportedVideoFrameRates(const QVideoEncoderSettings &settings, bool *continuous);
|
||||
|
||||
// Other Video Settings
|
||||
void setBitrate(const int bitrate);
|
||||
void setVideoEncodingMode(const QtMultimediaKit::EncodingMode mode);
|
||||
|
||||
// Video Codecs
|
||||
void setVideoCaptureCodec(const QString &codecName);
|
||||
QStringList supportedVideoCaptureCodecs();
|
||||
QString videoCaptureCodecDescription(const QString &codecName);
|
||||
|
||||
// Audio Codecs
|
||||
void setAudioCaptureCodec(const QString &codecName);
|
||||
QStringList supportedAudioCaptureCodecs();
|
||||
|
||||
// Encoder Settings
|
||||
void videoEncoderSettings(QVideoEncoderSettings &videoSettings);
|
||||
void audioEncoderSettings(QAudioEncoderSettings &audioSettings);
|
||||
|
||||
// Quality
|
||||
void setVideoCaptureQuality(const QtMultimediaKit::EncodingQuality quality,
|
||||
const VideoQualityDefinition mode);
|
||||
void setAudioCaptureQuality(const QtMultimediaKit::EncodingQuality quality,
|
||||
const AudioQualityDefinition mode);
|
||||
|
||||
// Video Containers
|
||||
QString videoContainer() const;
|
||||
void setVideoContainer(const QString &containerName);
|
||||
QStringList supportedVideoContainers();
|
||||
bool isSupportedVideoContainer(const QString &containerName);
|
||||
QString videoContainerDescription(const QString &containerName);
|
||||
|
||||
// Audio Settings
|
||||
QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous);
|
||||
void setAudioSampleRate(const int sampleRate);
|
||||
void setAudioBitRate(const int bitRate);
|
||||
void setAudioChannelCount(const int channelCount);
|
||||
void setAudioEncodingMode(const QtMultimediaKit::EncodingMode mode);
|
||||
|
||||
// Video Options
|
||||
QSize pixelAspectRatio();
|
||||
void setPixelAspectRatio(const QSize par);
|
||||
int gain();
|
||||
void setGain(const int gain);
|
||||
int maxClipSizeInBytes() const;
|
||||
void setMaxClipSizeInBytes(const int size);
|
||||
|
||||
private: // Internal
|
||||
|
||||
QMediaRecorder::Error fromSymbianErrorToQtMultimediaError(int aError);
|
||||
|
||||
void initializeVideoCaptureSettings();
|
||||
void doInitializeVideoRecorderL();
|
||||
void commitVideoEncoderSettings();
|
||||
void queryAudioEncoderSettings();
|
||||
void queryVideoEncoderSettings();
|
||||
void validateRequestedCodecs();
|
||||
void resetSession(bool errorHandling = false);
|
||||
|
||||
void doSetCodecsL();
|
||||
QString determineProfileAndLevel();
|
||||
void doSetVideoResolution(const QSize &resolution);
|
||||
void doSetFrameRate(qreal rate);
|
||||
void doSetBitrate(const int &bitrate);
|
||||
|
||||
void updateVideoCaptureContainers();
|
||||
void doUpdateVideoCaptureContainersL();
|
||||
void selectController(const QString &format,
|
||||
TUid &controllerUid,
|
||||
TUid &formatUid);
|
||||
|
||||
void doPopulateVideoCodecsDataL();
|
||||
void doPopulateVideoCodecsL();
|
||||
#ifndef S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
void doPopulateMaxVideoParameters();
|
||||
#endif // S60_DEVVIDEO_RECORDING_SUPPORTED
|
||||
void doPopulateAudioCodecsL();
|
||||
|
||||
QList<int> doGetSupportedSampleRatesL(const QAudioEncoderSettings &settings,
|
||||
bool *continuous);
|
||||
QSize maximumResolutionForMimeType(const QString &mimeType) const;
|
||||
qreal maximumFrameRateForMimeType(const QString &mimeType) const;
|
||||
int maximumBitRateForMimeType(const QString &mimeType) const;
|
||||
|
||||
signals: // Notification Signals
|
||||
|
||||
void stateChanged(S60VideoCaptureSession::TVideoCaptureState);
|
||||
void positionChanged(qint64);
|
||||
void mutedChanged(bool);
|
||||
void captureSizeChanged(const QSize&);
|
||||
void error(int, const QString&);
|
||||
|
||||
private slots: // Internal Slots
|
||||
|
||||
void cameraStatusChanged(QCamera::Status);
|
||||
void durationTimerTriggered();
|
||||
|
||||
private: // Structs
|
||||
|
||||
/*
|
||||
* This structure holds the information of supported video mime types for
|
||||
* the format and also description for it.
|
||||
*/
|
||||
struct VideoFormatData {
|
||||
QString description;
|
||||
QStringList supportedMimeTypes;
|
||||
};
|
||||
|
||||
/*
|
||||
* This structure is used to define supported resolutions and framerate
|
||||
* (depending on each other) for each supported encoder mime type (defining
|
||||
* encoder, profile and level)
|
||||
*/
|
||||
struct SupportedFrameRatePictureSize {
|
||||
SupportedFrameRatePictureSize() {}
|
||||
SupportedFrameRatePictureSize(qreal rate, QSize size):
|
||||
frameRate(rate),
|
||||
frameSize(size) {}
|
||||
qreal frameRate;
|
||||
QSize frameSize;
|
||||
};
|
||||
|
||||
/*
|
||||
* This structure defines supported resolution/framerate pairs and maximum
|
||||
* bitrate for a single encodec device. It also the supported mime types
|
||||
* (codec, profile and level) of the encoder device.
|
||||
*
|
||||
* Structure defines 2 contructors:
|
||||
* - First with no attributes
|
||||
* - Second, which will construct the sructure appending one
|
||||
* resolution/framerate pair to the list of
|
||||
* SupportedFrameRatePictureSizes and setting the given bitrate as
|
||||
* maximum. This second constructor is for convenience.
|
||||
*
|
||||
* This struct is used in m_videoParametersForEncoder (QList).
|
||||
*
|
||||
* Here's a visualization of an example strcuture:
|
||||
* STRUCT:
|
||||
* |-- Resolution/FrameRate Pairs:
|
||||
* | |- VGA / 30fps
|
||||
* | |- 720p / 25fps
|
||||
* | |- Etc.
|
||||
* |
|
||||
* |-- MimeTypes:
|
||||
* | |- video/mp4v-es; profile-level-id=1
|
||||
* | |- video/mp4v-es; profile-level-id=2
|
||||
* | |- Etc.
|
||||
* |
|
||||
* |-- Max BitRate: 1Mbps
|
||||
*/
|
||||
struct MaxResolutionRatesAndTypes {
|
||||
MaxResolutionRatesAndTypes() {}
|
||||
MaxResolutionRatesAndTypes(QSize size, qreal fRate, int bRate):
|
||||
bitRate(bRate)
|
||||
{
|
||||
frameRatePictureSizePair.append(SupportedFrameRatePictureSize(fRate,size));
|
||||
}
|
||||
QList<SupportedFrameRatePictureSize> frameRatePictureSizePair;
|
||||
QStringList mimeTypes;
|
||||
int bitRate;
|
||||
};
|
||||
|
||||
private: // Data
|
||||
|
||||
CCameraEngine *m_cameraEngine;
|
||||
CVideoRecorderUtility *m_videoRecorder;
|
||||
QTimer *m_durationTimer;
|
||||
qint64 m_position;
|
||||
// Symbian ErrorCode
|
||||
mutable int m_error;
|
||||
// This defines whether Camera is in ActiveStatus or not
|
||||
bool m_cameraStarted;
|
||||
// Internal state of the video recorder
|
||||
TVideoCaptureState m_captureState;
|
||||
// Actual output file name/path
|
||||
QUrl m_sink;
|
||||
// Requested output file name/path, this may be different from m_sink if
|
||||
// asynchronous operation was ongoing in the CVideoRecorderUtility when new
|
||||
// outputLocation was set.
|
||||
QUrl m_requestedSink;
|
||||
// Requested videoSettings. The may not be active settings before those are
|
||||
// committed (with commitVideoEncoderSettings())
|
||||
QVideoEncoderSettings m_videoSettings;
|
||||
// Requested audioSettings. The may not be active settings before those are
|
||||
// committed (with commitVideoEncoderSettings())
|
||||
QAudioEncoderSettings m_audioSettings;
|
||||
// Tells whether settings should be initialized when changing the camera
|
||||
bool m_captureSettingsSet;
|
||||
// Active container
|
||||
QString m_container;
|
||||
// Requested container, this may be different from m_container if
|
||||
// asynchronous operation was ongoing in the CVideoRecorderUtility when new
|
||||
// container was set.
|
||||
QString m_requestedContainer;
|
||||
// Requested muted value. This may not be active value before settings are
|
||||
// committed (with commitVideoEncoderSettings())
|
||||
bool m_muted;
|
||||
// Maximum ClipSize in Bytes
|
||||
int m_maxClipSize;
|
||||
// List of supported video codec mime types
|
||||
QStringList m_videoCodecList;
|
||||
// Hash of supported video codec mime types and corresponding FourCC codes
|
||||
QHash<QString, TFourCC> m_audioCodecList;
|
||||
// Map of video capture controllers information. It is populated during
|
||||
// doUpdateVideoCaptureContainersL().
|
||||
//
|
||||
// Here's a visualization of an example strcuture:
|
||||
// m_videoControllerMap(HASH):
|
||||
// |
|
||||
// |-- Controller 1 : HASH
|
||||
// | |- Container 1 (UID) : FormatData
|
||||
// | | |- Description
|
||||
// | | |- List of supported MimeTypes
|
||||
// | |- Container 2 (UID) : FormatData
|
||||
// | | |- Description
|
||||
// | | |- List of supported MimeTypes
|
||||
// | |- Etc.
|
||||
// |
|
||||
// |-- Controller 2: HASH
|
||||
// | |- Container 1 (UID) : FormatData
|
||||
// | | |- Description
|
||||
// | | |- List of supported MimeTypes
|
||||
// | |- Etc.
|
||||
//
|
||||
QHash<TInt, QHash<TInt,VideoFormatData> > m_videoControllerMap;
|
||||
// List of Encoder information. If DevVideoRecord is available info is
|
||||
// gathered during doPopulateVideoCodecsDataL() for each encoder (hw
|
||||
// accelerated and supporting camera input) found. If DevVideoRecord is not
|
||||
// available, the info is set in doPopulateMaxVideoParameters() based on
|
||||
// supported codec list received from CVideoRecorderUtility.
|
||||
QList<MaxResolutionRatesAndTypes> m_videoParametersForEncoder;
|
||||
// Set if OpenFileL should be executed when currently ongoing operation
|
||||
// is completed.
|
||||
bool m_openWhenReady;
|
||||
// Set if video capture should be prepared after OpenFileL has completed
|
||||
bool m_prepareAfterOpenComplete;
|
||||
// Set if video capture should be started when Prepare has completed
|
||||
bool m_startAfterPrepareComplete;
|
||||
// Tells if settings have been set after last Prepare()
|
||||
bool m_uncommittedSettings;
|
||||
// Tells if settings need to be applied after ongoing operation has finished
|
||||
bool m_commitSettingsWhenReady;
|
||||
};
|
||||
|
||||
#endif // S60VIDEOCAPTURESESSION_H
|
||||
@@ -1,108 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtGui/qicon.h>
|
||||
|
||||
#include "s60videodevicecontrol.h"
|
||||
#include "s60cameracontrol.h"
|
||||
#include "s60cameraconstants.h"
|
||||
|
||||
S60VideoDeviceControl::S60VideoDeviceControl(QObject *parent) :
|
||||
QVideoDeviceControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60VideoDeviceControl::S60VideoDeviceControl(S60CameraControl *control, QObject *parent) :
|
||||
QVideoDeviceControl(parent),
|
||||
m_selectedDevice(KDefaultCameraDevice)
|
||||
{
|
||||
m_control = control;
|
||||
connect(m_control, SIGNAL(devicesChanged()), this, SIGNAL(devicesChanged()));
|
||||
}
|
||||
|
||||
S60VideoDeviceControl::~S60VideoDeviceControl()
|
||||
{
|
||||
}
|
||||
|
||||
int S60VideoDeviceControl::deviceCount() const
|
||||
{
|
||||
return S60CameraControl::deviceCount();
|
||||
}
|
||||
|
||||
QString S60VideoDeviceControl::deviceName(int index) const
|
||||
{
|
||||
return S60CameraControl::name(index);
|
||||
}
|
||||
|
||||
QString S60VideoDeviceControl::deviceDescription(int index) const
|
||||
{
|
||||
return S60CameraControl::description(index);
|
||||
}
|
||||
|
||||
QIcon S60VideoDeviceControl::deviceIcon(int index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
int S60VideoDeviceControl::defaultDevice() const
|
||||
{
|
||||
return KDefaultCameraDevice;
|
||||
}
|
||||
|
||||
int S60VideoDeviceControl::selectedDevice() const
|
||||
{
|
||||
return m_selectedDevice;
|
||||
}
|
||||
|
||||
void S60VideoDeviceControl::setSelectedDevice(int index)
|
||||
{
|
||||
// Inform that we selected new device
|
||||
if (m_selectedDevice != index) {
|
||||
m_control->setSelectedDevice(index);
|
||||
m_selectedDevice = index;
|
||||
emit selectedDeviceChanged(m_selectedDevice);
|
||||
emit selectedDeviceChanged(deviceName(m_selectedDevice));
|
||||
}
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,95 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60VIDEODEVICECONTROL_H
|
||||
#define S60VIDEODEVICECONTROL_H
|
||||
|
||||
#include "qvideodevicecontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60CameraControl;
|
||||
class QString;
|
||||
class QIcon;
|
||||
|
||||
/*
|
||||
* Control for providing information of the video device (r. camera) and to
|
||||
* enable other camera device (e.g. secondary camera if one exists).
|
||||
*/
|
||||
class S60VideoDeviceControl : public QVideoDeviceControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructors & Destructor
|
||||
|
||||
S60VideoDeviceControl(QObject *parent);
|
||||
S60VideoDeviceControl(S60CameraControl *control, QObject *parent = 0);
|
||||
virtual ~S60VideoDeviceControl();
|
||||
|
||||
public: // QVideoDeviceControl
|
||||
|
||||
int deviceCount() const;
|
||||
|
||||
QString deviceName(int index) const;
|
||||
QString deviceDescription(int index) const;
|
||||
QIcon deviceIcon(int index) const;
|
||||
|
||||
int defaultDevice() const;
|
||||
int selectedDevice() const;
|
||||
|
||||
public slots: // QVideoDeviceControl
|
||||
|
||||
void setSelectedDevice(int index);
|
||||
|
||||
/*
|
||||
Q_SIGNALS:
|
||||
void selectedDeviceChanged(int index);
|
||||
void selectedDeviceChanged(const QString &deviceName);
|
||||
void devicesChanged();
|
||||
*/
|
||||
|
||||
private: // Data
|
||||
|
||||
S60CameraControl *m_control;
|
||||
int m_selectedDevice;
|
||||
};
|
||||
|
||||
#endif // S60VIDEODEVICECONTROL_H
|
||||
@@ -1,204 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60videoencodercontrol.h"
|
||||
#include "s60videocapturesession.h"
|
||||
|
||||
S60VideoEncoderControl::S60VideoEncoderControl(QObject *parent) :
|
||||
QVideoEncoderControl(parent)
|
||||
{
|
||||
}
|
||||
|
||||
S60VideoEncoderControl::S60VideoEncoderControl(S60VideoCaptureSession *session, QObject *parent) :
|
||||
QVideoEncoderControl(parent)
|
||||
{
|
||||
m_session = session;
|
||||
}
|
||||
|
||||
S60VideoEncoderControl::~S60VideoEncoderControl()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList S60VideoEncoderControl::supportedVideoCodecs() const
|
||||
{
|
||||
return m_session->supportedVideoCaptureCodecs();
|
||||
}
|
||||
|
||||
QString S60VideoEncoderControl::videoCodecDescription(const QString &codecName) const
|
||||
{
|
||||
return m_session->videoCaptureCodecDescription(codecName);
|
||||
}
|
||||
|
||||
QList<qreal> S60VideoEncoderControl::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
if (!settings.isNull())
|
||||
return m_session->supportedVideoFrameRates(settings, continuous);
|
||||
return m_session->supportedVideoFrameRates(continuous);
|
||||
}
|
||||
|
||||
QList<QSize> S60VideoEncoderControl::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
if (!settings.isNull())
|
||||
return m_session->supportedVideoResolutions(settings, continuous);
|
||||
return m_session->supportedVideoResolutions(continuous);
|
||||
}
|
||||
|
||||
QStringList S60VideoEncoderControl::supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
// Possible settings: EncodingMode, Codec, Resolution, FrameRate, BitRate, Quality
|
||||
// Possible (codec specific) options: PixelAspectRatio, Gain, MaxClipSizeInBytes
|
||||
|
||||
// Following options are valid for all codecs
|
||||
Q_UNUSED(codec);
|
||||
|
||||
QStringList options;
|
||||
options.append("pixelAspectRatio");
|
||||
options.append("gain");
|
||||
options.append("maxClipSizeInBytes");
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
QVariant S60VideoEncoderControl::encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
Q_UNUSED(codec);
|
||||
|
||||
// Possible settings: EncodingMode, Codec, Resolution, FrameRate, BitRate, Quality
|
||||
// Possible (codec specific) options: PixelAspectRatio, Gain, MaxClipSizeInBytes
|
||||
|
||||
QVariant returnValue;
|
||||
|
||||
if (qstrcmp(name.toLocal8Bit().constData(), "pixelAspectRatio") == 0)
|
||||
returnValue.setValue(m_session->pixelAspectRatio());
|
||||
else if (qstrcmp(name.toLocal8Bit().constData(), "gain") == 0)
|
||||
returnValue.setValue((int)m_session->gain());
|
||||
else if (qstrcmp(name.toLocal8Bit().constData(), "maxClipSizeInBytes") == 0)
|
||||
returnValue.setValue(m_session->maxClipSizeInBytes());
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
void S60VideoEncoderControl::setEncodingOption(
|
||||
const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
// Set the codec first if not already set
|
||||
m_session->setVideoCaptureCodec(codec);
|
||||
|
||||
if (qstrcmp(name.toLocal8Bit().constData(), "pixelAspectRatio") == 0)
|
||||
m_session->setPixelAspectRatio(value.toSize());
|
||||
else if (qstrcmp(name.toLocal8Bit().constData(), "gain") == 0)
|
||||
m_session->setGain(value.toInt());
|
||||
else if (qstrcmp(name.toLocal8Bit().constData(), "maxClipSizeInBytes") == 0)
|
||||
m_session->setMaxClipSizeInBytes(value.toInt());
|
||||
else
|
||||
m_session->setError(KErrNotSupported, tr("Requested encoding option is not supported"));
|
||||
}
|
||||
|
||||
QVideoEncoderSettings S60VideoEncoderControl::videoSettings() const
|
||||
{
|
||||
QVideoEncoderSettings settings;
|
||||
m_session->videoEncoderSettings(settings);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
void S60VideoEncoderControl::setVideoSettings(const QVideoEncoderSettings &settings)
|
||||
{
|
||||
// Notify that settings have been implicitly set and there's no need to
|
||||
// initialize them in case camera is changed
|
||||
m_session->notifySettingsSet();
|
||||
|
||||
if (settings.codec().isEmpty()
|
||||
|| (settings.resolution() == QSize(-1,-1) && settings.frameRate() == 0 && settings.bitRate() == -1)) {
|
||||
if (!settings.codec().isEmpty())
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EOnlyVideoQuality);
|
||||
} else if (settings.resolution() != QSize(-1,-1) && settings.frameRate() == 0 && settings.bitRate() == -1) { // Only Resolution
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setVideoResolution(settings.resolution());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndResolution);
|
||||
|
||||
} else if (settings.resolution() == QSize(-1,-1) && settings.frameRate() != 0 && settings.bitRate() == -1) { // Only Framerate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setFrameRate(settings.frameRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndFrameRate);
|
||||
|
||||
} else if (settings.resolution() == QSize(-1,-1) && settings.frameRate() == 0 && settings.bitRate() != -1) { // Only BitRate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setBitrate(settings.bitRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndBitRate);
|
||||
|
||||
} else if (settings.resolution() != QSize(-1,-1) && settings.frameRate() != 0 && settings.bitRate() == -1) { // Resolution and FrameRate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setVideoResolution(settings.resolution());
|
||||
m_session->setFrameRate(settings.frameRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndResolutionAndFrameRate);
|
||||
|
||||
} else if (settings.resolution() != QSize(-1,-1) && settings.frameRate() == 0 && settings.bitRate() != -1) { // Resolution and BitRate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setVideoResolution(settings.resolution());
|
||||
m_session->setBitrate(settings.bitRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndResolutionAndBitRate);
|
||||
|
||||
} else if (settings.resolution() == QSize(-1,-1) && settings.frameRate() != 0 && settings.bitRate() != -1) { // FrameRate and BitRate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setFrameRate(settings.frameRate());
|
||||
m_session->setBitrate(settings.bitRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::EVideoQualityAndFrameRateAndBitRate);
|
||||
|
||||
} else { // All: Resolution, BitRate and FrameRate
|
||||
m_session->setVideoCaptureCodec(settings.codec());
|
||||
m_session->setVideoEncodingMode(settings.encodingMode());
|
||||
m_session->setVideoResolution(settings.resolution());
|
||||
m_session->setFrameRate(settings.frameRate());
|
||||
m_session->setBitrate(settings.bitRate());
|
||||
m_session->setVideoCaptureQuality(settings.quality(), S60VideoCaptureSession::ENoVideoQuality);
|
||||
}
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,94 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60VIDEOENCODERCONTROL_H
|
||||
#define S60VIDEOENCODERCONTROL_H
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qmap.h>
|
||||
|
||||
#include "qvideoencodercontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60VideoCaptureSession;
|
||||
|
||||
/*
|
||||
* Control for video settings when recording video using QMediaRecorder.
|
||||
*/
|
||||
class S60VideoEncoderControl : public QVideoEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Contructors & Destructor
|
||||
|
||||
S60VideoEncoderControl(QObject *parent = 0);
|
||||
S60VideoEncoderControl(S60VideoCaptureSession *session, QObject *parent = 0);
|
||||
virtual ~S60VideoEncoderControl();
|
||||
|
||||
public: // QVideoEncoderControl
|
||||
|
||||
// Resolution
|
||||
QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous = 0) const;
|
||||
|
||||
// Framerate
|
||||
QList<qreal> supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous = 0) const;
|
||||
|
||||
// Video Codec
|
||||
QStringList supportedVideoCodecs() const;
|
||||
QString videoCodecDescription(const QString &codecName) const;
|
||||
|
||||
// Video Settings
|
||||
QVideoEncoderSettings videoSettings() const;
|
||||
void setVideoSettings(const QVideoEncoderSettings &settings);
|
||||
|
||||
// Encoding Options
|
||||
QStringList supportedEncodingOptions(const QString &codec) const;
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const;
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value);
|
||||
|
||||
private: // Data
|
||||
|
||||
S60VideoCaptureSession* m_session;
|
||||
|
||||
};
|
||||
|
||||
#endif // S60VIDEOENCODERCONTROL_H
|
||||
@@ -1,78 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <qabstractvideosurface.h>
|
||||
|
||||
#include "s60videorenderercontrol.h"
|
||||
|
||||
S60VideoRendererControl::S60VideoRendererControl(QObject *parent) :
|
||||
QVideoRendererControl(parent),
|
||||
m_surface(0)
|
||||
{
|
||||
}
|
||||
|
||||
S60VideoRendererControl::~S60VideoRendererControl()
|
||||
{
|
||||
// Stop surface if still active
|
||||
if (m_surface)
|
||||
if (m_surface->isActive())
|
||||
m_surface->stop();
|
||||
}
|
||||
|
||||
QAbstractVideoSurface *S60VideoRendererControl::surface() const
|
||||
{
|
||||
return m_surface;
|
||||
}
|
||||
|
||||
void S60VideoRendererControl::setSurface(QAbstractVideoSurface *surface)
|
||||
{
|
||||
if (surface == 0) {
|
||||
// Stop current surface if needed
|
||||
if (m_surface)
|
||||
if (m_surface->isActive())
|
||||
m_surface->stop();
|
||||
}
|
||||
|
||||
m_surface = surface;
|
||||
emit viewFinderSurfaceSet();
|
||||
}
|
||||
|
||||
// End of file
|
||||
@@ -1,76 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60VIDEORENDERERCONTROL_H
|
||||
#define S60VIDEORENDERERCONTROL_H
|
||||
|
||||
#include <qvideorenderercontrol.h>
|
||||
|
||||
/*
|
||||
* Control for QGraphicsVideoItem. Viewfinder frames are streamed to a surface
|
||||
* which is drawn to the display by the Qt Graphics Vide Framework.
|
||||
* VideoRendererControl uses only Bitmap Viewfinder.
|
||||
*/
|
||||
class S60VideoRendererControl : public QVideoRendererControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public: // Constructor & Destructor
|
||||
|
||||
S60VideoRendererControl(QObject *parent = 0);
|
||||
virtual ~S60VideoRendererControl();
|
||||
|
||||
public: // S60VideoRendererControl
|
||||
|
||||
QAbstractVideoSurface *surface() const;
|
||||
void setSurface(QAbstractVideoSurface *surface);
|
||||
|
||||
signals: // Internal Signals
|
||||
|
||||
void viewFinderSurfaceSet();
|
||||
|
||||
private: // Data
|
||||
|
||||
QAbstractVideoSurface *m_surface;
|
||||
|
||||
};
|
||||
|
||||
#endif // S60VIDEORENDERERCONTROL_H
|
||||
@@ -1,31 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
DEFINES += AUDIOSOURCEUSED
|
||||
|
||||
symbian:LIBS += -lmediaclientaudio \
|
||||
-lmmfcontrollerframework \
|
||||
-lefsrv \
|
||||
-lbafl \
|
||||
|
||||
!contains(S60_VERSION, 3.1) {
|
||||
contains(audiorouting_s60_enabled,yes) {
|
||||
#We use audioinputrouting.lib for recording audio from different sources -lmediaclientaudioinputstream \ -lcone \
|
||||
DEFINES += AUDIOINPUT_ROUTING
|
||||
message("Audio Input Routing enabled onwards 3.2 SDK")
|
||||
LIBS += -laudioinputrouting
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += $$PWD/s60audioencodercontrol.h \
|
||||
$$PWD/s60audiomediarecordercontrol.h \
|
||||
$$PWD/s60audioendpointselector.h \
|
||||
$$PWD/s60audiocaptureservice.h \
|
||||
$$PWD/s60audiocapturesession.h \
|
||||
$$PWD/S60audiocontainercontrol.h
|
||||
|
||||
SOURCES += $$PWD/s60audioencodercontrol.cpp \
|
||||
$$PWD/s60audiomediarecordercontrol.cpp \
|
||||
$$PWD/s60audioendpointselector.cpp \
|
||||
$$PWD/s60audiocaptureservice.cpp \
|
||||
$$PWD/s60audiocapturesession.cpp \
|
||||
$$PWD/S60audiocontainercontrol.cpp
|
||||
@@ -1,98 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include "s60audiocaptureservice.h"
|
||||
#include "s60audiocapturesession.h"
|
||||
#include "s60audioendpointselector.h"
|
||||
#include "s60audioencodercontrol.h"
|
||||
#include "s60audiomediarecordercontrol.h"
|
||||
#include "s60audiocontainercontrol.h"
|
||||
|
||||
S60AudioCaptureService::S60AudioCaptureService(QObject *parent):
|
||||
QMediaService(parent)
|
||||
{
|
||||
DP0("S60AudioCaptureService::S60AudioCaptureService +++");
|
||||
|
||||
m_session = new S60AudioCaptureSession(this);
|
||||
m_encoderControl = new S60AudioEncoderControl(m_session,this);
|
||||
m_recorderControl = new S60AudioMediaRecorderControl(m_session,this);
|
||||
m_endpointSelector = new S60AudioEndpointSelector(m_session,this);
|
||||
m_containerControl = new S60AudioContainerControl(m_session, this);
|
||||
|
||||
DP0("S60AudioCaptureService::S60AudioCaptureService ---");
|
||||
}
|
||||
|
||||
S60AudioCaptureService::~S60AudioCaptureService()
|
||||
{
|
||||
DP0("S60AudioCaptureService::~S60AudioCaptureService +++");
|
||||
DP0("S60AudioCaptureService::~S60AudioCaptureService ---");
|
||||
}
|
||||
|
||||
QMediaControl *S60AudioCaptureService::requestControl(const char *name)
|
||||
{
|
||||
DP0("S60AudioCaptureService::requestControl");
|
||||
|
||||
if (qstrcmp(name,QMediaRecorderControl_iid) == 0)
|
||||
return m_recorderControl;
|
||||
|
||||
if (qstrcmp(name,QAudioEncoderControl_iid) == 0)
|
||||
return m_encoderControl;
|
||||
|
||||
if (qstrcmp(name,QAudioEndpointSelector_iid) == 0)
|
||||
return m_endpointSelector;
|
||||
|
||||
if (qstrcmp(name,QMediaContainerControl_iid) == 0)
|
||||
return m_containerControl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void S60AudioCaptureService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
DP0("S60AudioCaptureService::releaseControl +++");
|
||||
|
||||
Q_UNUSED(control)
|
||||
|
||||
DP0("S60AudioCaptureService::releaseControl ---");
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOCAPTURESERVICE_H
|
||||
#define S60AUDIOCAPTURESERVICE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#include <qmediaservice.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60AudioCaptureSession;
|
||||
class S60AudioEncoderControl;
|
||||
class S60AudioMediaRecorderControl;
|
||||
class S60AudioEndpointSelector;
|
||||
class S60AudioContainerControl;
|
||||
|
||||
|
||||
class S60AudioCaptureService : public QMediaService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
S60AudioCaptureService(QObject *parent = 0);
|
||||
~S60AudioCaptureService();
|
||||
|
||||
QMediaControl *requestControl(const char *name);
|
||||
void releaseControl(QMediaControl *control);
|
||||
private:
|
||||
S60AudioCaptureSession *m_session;
|
||||
S60AudioEncoderControl *m_encoderControl;
|
||||
S60AudioEndpointSelector *m_endpointSelector;
|
||||
S60AudioMediaRecorderControl *m_recorderControl;
|
||||
S60AudioContainerControl *m_containerControl;
|
||||
};
|
||||
|
||||
#endif // S60AUDIOCAPTURESERVICE_H
|
||||
@@ -1,937 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audiocapturesession.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QDir>
|
||||
|
||||
#include <mda/common/audio.h>
|
||||
#include <mda/common/resource.h>
|
||||
#include <mda/client/utility.h>
|
||||
#include <mdaaudiosampleeditor.h>
|
||||
#include <mmf/common/mmfcontrollerpluginresolver.h>
|
||||
#include <mmf/common/mmfcontroller.h>
|
||||
#include <badesca.h>
|
||||
#include <bautils.h>
|
||||
#include <f32file.h>
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
const QString S60AudioCaptureSession::microPhone("Microphone");
|
||||
const QString S60AudioCaptureSession::voiceCall("Voice Call");
|
||||
const QString S60AudioCaptureSession::fmRadio("FM Radio");
|
||||
#endif
|
||||
|
||||
S60AudioCaptureSession::S60AudioCaptureSession(QObject *parent):
|
||||
QObject(parent)
|
||||
, m_recorderUtility(NULL)
|
||||
, m_captureState(ENotInitialized)
|
||||
, m_controllerIdMap(QHash<QString, ControllerData>())
|
||||
, m_audioCodeclist(QHash<QString, CodecData>())
|
||||
, m_error(QMediaRecorder::NoError)
|
||||
, m_isMuted(false)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::S60AudioCaptureSession +++");
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
m_audioInput = NULL;
|
||||
m_setActiveEndPoint = FALSE;
|
||||
m_audioEndpoint = S60AudioCaptureSession::microPhone;
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
TRAPD(err, initializeSessionL());
|
||||
setError(err);
|
||||
|
||||
DP0("S60AudioCaptureSession::S60AudioCaptureSession ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::initializeSessionL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::initializeSessionL +++");
|
||||
|
||||
m_recorderUtility = CMdaAudioRecorderUtility::NewL(*this, 0, EMdaPriorityNormal, EMdaPriorityPreferenceTimeAndQuality);
|
||||
updateAudioContainersL();
|
||||
populateAudioCodecsDataL();
|
||||
setDefaultSettings();
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
initAudioInputs();
|
||||
#endif
|
||||
User::LeaveIfError(m_fsSession.Connect());
|
||||
m_captureState = EInitialized;
|
||||
emit stateChanged(m_captureState);
|
||||
|
||||
DP0("S60AudioCaptureSession::initializeSessionL ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::setError(TInt aError)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setError +++");
|
||||
|
||||
DP1("S60AudioCaptureSession::setError:", aError);
|
||||
|
||||
if (aError == KErrNone)
|
||||
return;
|
||||
|
||||
m_error = aError;
|
||||
QMediaRecorder::Error recorderError = fromSymbianErrorToMultimediaError(m_error);
|
||||
|
||||
// TODO: fix to user friendly string at some point
|
||||
// These error string are only dev usable
|
||||
QString symbianError;
|
||||
symbianError.append("Symbian:");
|
||||
symbianError.append(QString::number(m_error));
|
||||
stop();
|
||||
emit error(recorderError, symbianError);
|
||||
|
||||
DP0("S60AudioCaptureSession::setError ---");
|
||||
}
|
||||
|
||||
QMediaRecorder::Error S60AudioCaptureSession::fromSymbianErrorToMultimediaError(int error)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::fromSymbianErrorToMultimediaError +++");
|
||||
|
||||
DP1("S60AudioCaptureSession::fromSymbianErrorToMultimediaError:", error);
|
||||
|
||||
switch(error) {
|
||||
case KErrNoMemory:
|
||||
case KErrNotFound:
|
||||
case KErrBadHandle:
|
||||
case KErrAbort:
|
||||
case KErrCorrupt:
|
||||
case KErrGeneral:
|
||||
case KErrPathNotFound:
|
||||
case KErrUnknown:
|
||||
case KErrNotReady:
|
||||
case KErrInUse:
|
||||
case KErrAccessDenied:
|
||||
case KErrLocked:
|
||||
case KErrPermissionDenied:
|
||||
case KErrAlreadyExists:
|
||||
return QMediaRecorder::ResourceError;
|
||||
case KErrNotSupported:
|
||||
case KErrArgument:
|
||||
return QMediaRecorder::FormatError;
|
||||
case KErrNone:
|
||||
default:
|
||||
DP0("S60AudioCaptureSession::fromSymbianErrorToMultimediaError: ---");
|
||||
return QMediaRecorder::NoError;
|
||||
}
|
||||
}
|
||||
|
||||
S60AudioCaptureSession::~S60AudioCaptureSession()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::~S60AudioCaptureSession +++");
|
||||
//stop the utility before deleting it
|
||||
stop();
|
||||
if (m_recorderUtility)
|
||||
delete m_recorderUtility;
|
||||
m_fsSession.Close();
|
||||
DP0("S60AudioCaptureSession::~S60AudioCaptureSession ---");
|
||||
}
|
||||
|
||||
QAudioFormat S60AudioCaptureSession::format() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::format");
|
||||
|
||||
return m_format;
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::setFormat(const QAudioFormat &format)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setFormat +++");
|
||||
|
||||
m_format = format;
|
||||
|
||||
DP0("S60AudioCaptureSession::setFormat ---");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QAudioEncoderSettings S60AudioCaptureSession::settings() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::settings");
|
||||
|
||||
return m_audioEncoderSettings;
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::setEncoderSettings(const QAudioEncoderSettings &setting)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setEncoderSettings +++");
|
||||
|
||||
m_audioEncoderSettings = setting;
|
||||
|
||||
DP0("S60AudioCaptureSession::setEncoderSettings ---");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QStringList S60AudioCaptureSession::supportedAudioCodecs() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::supportedAudioCodecs");
|
||||
|
||||
return m_audioCodeclist.keys();
|
||||
}
|
||||
|
||||
QStringList S60AudioCaptureSession::supportedAudioContainers() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::supportedAudioContainers");
|
||||
|
||||
return m_controllerIdMap.keys();
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::codecDescription(const QString &codecName)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::codecDescription +++");
|
||||
|
||||
if (m_audioCodeclist.keys().contains(codecName)) {
|
||||
|
||||
DP0("S60AudioCaptureSession::codecDescription ---");
|
||||
return m_audioCodeclist.value(codecName).codecDescription;
|
||||
}
|
||||
else {
|
||||
DP0("S60AudioCaptureSession::codecDescription ---");
|
||||
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::audioContainerDescription(const QString &containerName)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::audioContainerDescription +++");
|
||||
|
||||
if (m_controllerIdMap.keys().contains(containerName)) {
|
||||
DP0("S60AudioCaptureSession::audioContainerDescription ---");
|
||||
|
||||
return m_controllerIdMap.value(containerName).destinationFormatDescription;
|
||||
}
|
||||
else {
|
||||
DP0("S60AudioCaptureSession::audioContainerDescription ---");
|
||||
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::setAudioCodec(const QString &codecName)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setAudioCodec");
|
||||
|
||||
QStringList codecs = supportedAudioCodecs();
|
||||
if(codecs.contains(codecName)) {
|
||||
m_format.setCodec(codecName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::setAudioContainer(const QString &containerMimeType)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setAudioContainer");
|
||||
|
||||
QStringList containers = supportedAudioContainers();
|
||||
if (containerMimeType == "audio/mpeg")
|
||||
{
|
||||
m_container = "audio/mp4";
|
||||
return true;
|
||||
}
|
||||
if(containers.contains(containerMimeType)) {
|
||||
m_container = containerMimeType;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::audioCodec() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::audioCodec");
|
||||
|
||||
return m_format.codec();
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::audioContainer() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::audioContainer");
|
||||
|
||||
return m_container;
|
||||
}
|
||||
|
||||
QUrl S60AudioCaptureSession::outputLocation() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::outputLocation");
|
||||
|
||||
return m_sink;
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::setOutputLocation(const QUrl& sink)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setOutputLocation");
|
||||
|
||||
QString filename = QDir::toNativeSeparators(sink.toString());
|
||||
TPtrC16 path(reinterpret_cast<const TUint16*>(filename.utf16()));
|
||||
TRAPD(err, BaflUtils::EnsurePathExistsL(m_fsSession,path));
|
||||
if (err == KErrNone) {
|
||||
m_sink = sink;
|
||||
setError(err);
|
||||
return true;
|
||||
}else {
|
||||
setError(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 S60AudioCaptureSession::position() const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::position");
|
||||
|
||||
if ((m_captureState != ERecording) || !m_recorderUtility)
|
||||
return 0;
|
||||
|
||||
return m_recorderUtility->Duration().Int64() / 1000;
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::prepareSinkL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::prepareSinkL +++");
|
||||
|
||||
/* If m_outputLocation is null, set a default location */
|
||||
if (m_sink.isEmpty()) {
|
||||
QDir outputDir(QDir::rootPath());
|
||||
int lastImage = 0;
|
||||
int fileCount = 0;
|
||||
foreach(QString fileName, outputDir.entryList(QStringList() << "recordclip_*")) {
|
||||
int imgNumber = fileName.mid(5, fileName.size() - 9).toInt();
|
||||
lastImage = qMax(lastImage, imgNumber);
|
||||
if (outputDir.exists(fileName))
|
||||
fileCount += 1;
|
||||
}
|
||||
lastImage += fileCount;
|
||||
m_sink = QUrl(QDir::toNativeSeparators(outputDir.canonicalPath() + QString("/recordclip_%1").arg(lastImage + 1, 4, 10, QLatin1Char('0'))));
|
||||
}
|
||||
|
||||
QString sink = QDir::toNativeSeparators(m_sink.toString());
|
||||
TPtrC16 path(reinterpret_cast<const TUint16*>(sink.utf16()));
|
||||
if (BaflUtils::FileExists(m_fsSession, path))
|
||||
BaflUtils::DeleteFile(m_fsSession, path);
|
||||
|
||||
int index = sink.lastIndexOf('.');
|
||||
if (index != -1)
|
||||
sink.chop(sink.length()-index);
|
||||
|
||||
sink.append(m_controllerIdMap.value(m_container).fileExtension);
|
||||
m_sink.setUrl(sink);
|
||||
|
||||
DP0("S60AudioCaptureSession::prepareSinkL ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::record()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::record +++");
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
if (m_captureState == EInitialized || m_captureState == ERecordComplete) {
|
||||
prepareSinkL();
|
||||
QString filename = m_sink.toString();
|
||||
TPtrC16 sink(reinterpret_cast<const TUint16*>(filename.utf16()));
|
||||
TUid controllerUid(TUid::Uid(m_controllerIdMap.value(m_container).controllerUid));
|
||||
TUid formatUid(TUid::Uid(m_controllerIdMap.value(m_container).destinationFormatUid));
|
||||
|
||||
TRAPD(err,m_recorderUtility->OpenFileL(sink));
|
||||
setError(err);
|
||||
}else if (m_captureState == EPaused) {
|
||||
m_recorderUtility->SetPosition(m_pausedPosition);
|
||||
TRAPD(error, m_recorderUtility->RecordL());
|
||||
setError(error);
|
||||
m_captureState = ERecording;
|
||||
emit stateChanged(m_captureState);
|
||||
}
|
||||
|
||||
DP0("S60AudioCaptureSession::record ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::mute(bool muted)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::mute +++");
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
if (muted)
|
||||
m_recorderUtility->SetGain(0);
|
||||
else
|
||||
m_recorderUtility->SetGain(m_recorderUtility->MaxGain());
|
||||
|
||||
m_isMuted = muted;
|
||||
|
||||
DP0("S60AudioCaptureSession::mute ---");
|
||||
}
|
||||
|
||||
bool S60AudioCaptureSession::muted()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::muted");
|
||||
|
||||
return m_isMuted;
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::setDefaultSettings()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::setDefaultSettings +++");
|
||||
|
||||
// Setting AMR to default format if supported
|
||||
if (m_controllerIdMap.count() > 0) {
|
||||
if ( m_controllerIdMap.contains("audio/amr"))
|
||||
m_container = QString("audio/amr");
|
||||
else
|
||||
m_container = m_controllerIdMap.keys()[0];
|
||||
}
|
||||
if (m_audioCodeclist.keys().count() > 0) {
|
||||
if (m_audioCodeclist.keys().contains("AMR")) {
|
||||
m_format.setSampleSize(8);
|
||||
m_format.setChannels(1);
|
||||
m_format.setFrequency(8000);
|
||||
m_format.setSampleType(QAudioFormat::SignedInt);
|
||||
m_format.setCodec("AMR");
|
||||
}else
|
||||
m_format.setCodec(m_audioCodeclist.keys()[0]);
|
||||
}
|
||||
|
||||
DP0("S60AudioCaptureSession::setDefaultSettings ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::pause()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::pause +++");
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
m_pausedPosition = m_recorderUtility->Position();
|
||||
m_recorderUtility->Stop();
|
||||
m_captureState = EPaused;
|
||||
emit stateChanged(m_captureState);
|
||||
|
||||
DP0("S60AudioCaptureSession::pause ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::stop()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::stop +++");
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
m_recorderUtility->Stop();
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
//delete audio input instance before closing the utility.
|
||||
if (m_audioInput)
|
||||
{
|
||||
delete m_audioInput;
|
||||
m_audioInput = NULL;
|
||||
}
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
m_recorderUtility->Close();
|
||||
m_captureState = ERecordComplete;
|
||||
emit stateChanged(m_captureState);
|
||||
}
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
|
||||
void S60AudioCaptureSession::initAudioInputs()
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::initAudioInputs +++");
|
||||
|
||||
m_audioInputs[S60AudioCaptureSession::microPhone] = QString("Microphone associated with the currently active speaker.");
|
||||
m_audioInputs[S60AudioCaptureSession::voiceCall] = QString("Audio stream associated with the current phone call.");
|
||||
m_audioInputs[S60AudioCaptureSession::fmRadio] = QString("Audio of the currently tuned FM radio station.");
|
||||
|
||||
DP0(" S60AudioCaptureSession::initAudioInputs ---");
|
||||
}
|
||||
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
void S60AudioCaptureSession::setActiveEndpoint(const QString& audioEndpoint)
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::setActiveEndpoint +++");
|
||||
|
||||
if (!m_audioInputs.keys().contains(audioEndpoint))
|
||||
return;
|
||||
|
||||
if (activeEndpoint().compare(audioEndpoint) != 0) {
|
||||
m_audioEndpoint = audioEndpoint;
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
m_setActiveEndPoint = TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
DP0(" S60AudioCaptureSession::setActiveEndpoint ---");
|
||||
}
|
||||
|
||||
QList<QString> S60AudioCaptureSession::availableEndpoints() const
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::availableEndpoints");
|
||||
|
||||
return m_audioInputs.keys();
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::endpointDescription(const QString& name) const
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::endpointDescription +++");
|
||||
|
||||
if (m_audioInputs.keys().contains(name))
|
||||
return m_audioInputs.value(name);
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::activeEndpoint() const
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::activeEndpoint");
|
||||
|
||||
QString inputSourceName = NULL;
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
if (m_audioInput) {
|
||||
CAudioInput::TAudioInputArray input = m_audioInput->AudioInput();
|
||||
inputSourceName = qStringFromTAudioInputPreference(input[0]);
|
||||
}
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
return inputSourceName;
|
||||
}
|
||||
|
||||
QString S60AudioCaptureSession::defaultEndpoint() const
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::defaultEndpoint");
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
return QString(S60AudioCaptureSession::microPhone);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
|
||||
void S60AudioCaptureSession::doSetAudioInputL(const QString& name)
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::doSetAudioInputL +++");
|
||||
DP1(" S60AudioCaptureSession::doSetAudioInputL:", name);
|
||||
TInt err(KErrNone);
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
CAudioInput::TAudioInputPreference input = CAudioInput::EDefaultMic;
|
||||
|
||||
if (name.compare(S60AudioCaptureSession::voiceCall) == 0)
|
||||
input = CAudioInput::EVoiceCall;
|
||||
// commented because they are not supported on 9.2
|
||||
else if (name.compare(S60AudioCaptureSession::fmRadio) == 0)
|
||||
input = CAudioInput::EFMRadio;
|
||||
else // S60AudioCaptureSession::microPhone
|
||||
input = CAudioInput::EDefaultMic;
|
||||
|
||||
RArray<CAudioInput::TAudioInputPreference> inputArray;
|
||||
inputArray.Append(input);
|
||||
|
||||
if (m_audioInput){
|
||||
TRAP(err,m_audioInput->SetAudioInputL(inputArray.Array()));
|
||||
|
||||
if (err == KErrNone) {
|
||||
emit activeEndpointChanged(name);
|
||||
}
|
||||
else{
|
||||
setError(err);
|
||||
}
|
||||
}
|
||||
inputArray.Close();
|
||||
|
||||
DP0(" S60AudioCaptureSession::doSetAudioInputL ---");
|
||||
}
|
||||
|
||||
|
||||
QString S60AudioCaptureSession::qStringFromTAudioInputPreference(CAudioInput::TAudioInputPreference input) const
|
||||
{
|
||||
DP0(" S60AudioCaptureSession::qStringFromTAudioInputPreference");
|
||||
|
||||
if (input == CAudioInput::EVoiceCall)
|
||||
return S60AudioCaptureSession::voiceCall;
|
||||
else if (input == CAudioInput::EFMRadio)
|
||||
return S60AudioCaptureSession::fmRadio;
|
||||
else
|
||||
return S60AudioCaptureSession::microPhone; // CAudioInput::EDefaultMic
|
||||
}
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
|
||||
void S60AudioCaptureSession::MoscoStateChangeEvent(CBase* aObject,
|
||||
TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::MoscoStateChangeEvent +++");
|
||||
|
||||
if (aErrorCode==KErrNone) {
|
||||
TRAPD(err, MoscoStateChangeEventL(aObject, aPreviousState, aCurrentState, NULL));
|
||||
setError(err);
|
||||
}
|
||||
else {
|
||||
setError(aErrorCode);
|
||||
}
|
||||
DP1("S60AudioCaptureSession::MoscoStateChangeEvent, aErrorCode:", aErrorCode);
|
||||
DP0("S60AudioCaptureSession::MoscoStateChangeEvent ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::MoscoStateChangeEventL(CBase* aObject,
|
||||
TInt aPreviousState, TInt aCurrentState, TInt aErrorCode)
|
||||
{
|
||||
DP0("S60AudioCaptureSession::MoscoStateChangeEventL +++");
|
||||
|
||||
DP5("S60AudioCaptureSession::MoscoStateChangeEventL - aPreviousState:", aPreviousState,
|
||||
"aCurrentState:", aCurrentState, "aErrorCode:", aErrorCode);
|
||||
if (aObject != m_recorderUtility)
|
||||
return;
|
||||
|
||||
switch(aCurrentState) {
|
||||
case CMdaAudioClipUtility::EOpen: {
|
||||
if(aPreviousState == CMdaAudioClipUtility::ENotReady) {
|
||||
applyAudioSettingsL();
|
||||
m_recorderUtility->SetGain(m_recorderUtility->MaxGain());
|
||||
TRAPD(err, m_recorderUtility->RecordL());
|
||||
setError(err);
|
||||
m_captureState = EOpenCompelete;
|
||||
emit stateChanged(m_captureState);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CMdaAudioClipUtility::ENotReady: {
|
||||
m_captureState = EInitialized;
|
||||
emit stateChanged(m_captureState);
|
||||
break;
|
||||
}
|
||||
case CMdaAudioClipUtility::ERecording: {
|
||||
m_captureState = ERecording;
|
||||
emit stateChanged(m_captureState);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DP0("S60AudioCaptureSession::MoscoStateChangeEventL ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::updateAudioContainersL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::updateAudioContainersL +++");
|
||||
|
||||
CMMFControllerPluginSelectionParameters* pluginParameters =
|
||||
CMMFControllerPluginSelectionParameters::NewLC();
|
||||
CMMFFormatSelectionParameters* formatParameters =
|
||||
CMMFFormatSelectionParameters::NewLC();
|
||||
|
||||
pluginParameters->SetRequiredRecordFormatSupportL(*formatParameters);
|
||||
|
||||
RArray<TUid> ids;
|
||||
CleanupClosePushL(ids);
|
||||
User::LeaveIfError(ids.Append(KUidMediaTypeAudio));
|
||||
|
||||
pluginParameters->SetMediaIdsL(ids,
|
||||
CMMFPluginSelectionParameters::EAllowOnlySuppliedMediaIds);
|
||||
|
||||
RMMFControllerImplInfoArray controllers;
|
||||
CleanupResetAndDestroyPushL(controllers);
|
||||
|
||||
//Get all audio record controllers/formats that are supported
|
||||
pluginParameters->ListImplementationsL(controllers);
|
||||
|
||||
for (TInt index=0; index<controllers.Count(); index++) {
|
||||
const RMMFFormatImplInfoArray& recordFormats =
|
||||
controllers[index]->RecordFormats();
|
||||
for (TInt j=0; j<recordFormats.Count(); j++) {
|
||||
const CDesC8Array& mimeTypes = recordFormats[j]->SupportedMimeTypes();
|
||||
const CDesC8Array& fileExtensions = recordFormats[j]->SupportedFileExtensions();
|
||||
TInt mimeCount = mimeTypes.Count();
|
||||
TInt fileExtCount = fileExtensions.Count();
|
||||
|
||||
if (mimeCount > 0 && fileExtCount > 0) {
|
||||
TPtrC8 extension = fileExtensions[0];
|
||||
TPtrC8 mimeType = mimeTypes[0];
|
||||
QString type = QString::fromUtf8((char *)mimeType.Ptr(), mimeType.Length());
|
||||
|
||||
if (type != "audio/basic") {
|
||||
ControllerData data;
|
||||
data.controllerUid = controllers[index]->Uid().iUid;
|
||||
data.destinationFormatUid = recordFormats[j]->Uid().iUid;
|
||||
data.destinationFormatDescription = QString::fromUtf16(
|
||||
recordFormats[j]->DisplayName().Ptr(),
|
||||
recordFormats[j]->DisplayName().Length());
|
||||
data.fileExtension = QString::fromUtf8((char *)extension.Ptr(), extension.Length());
|
||||
m_controllerIdMap[type] = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CleanupStack::PopAndDestroy(4);//controllers, ids, formatParameters, pluginParameters
|
||||
|
||||
DP0("S60AudioCaptureSession::updateAudioContainersL ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::retrieveSupportedAudioSampleRatesL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::retrieveSupportedAudioSampleRatesL +++");
|
||||
|
||||
if (!m_recorderUtility) {
|
||||
DP0("No RecorderUtility");
|
||||
return;
|
||||
}
|
||||
|
||||
m_supportedSampleRates.clear();
|
||||
|
||||
RArray<TUint> supportedSampleRates;
|
||||
CleanupClosePushL(supportedSampleRates);
|
||||
m_recorderUtility->GetSupportedSampleRatesL(supportedSampleRates);
|
||||
for (TInt j = 0; j < supportedSampleRates.Count(); j++ )
|
||||
m_supportedSampleRates.append(supportedSampleRates[j]);
|
||||
|
||||
CleanupStack::PopAndDestroy(&supportedSampleRates);
|
||||
|
||||
DP0("S60AudioCaptureSession::retrieveSupportedAudioSampleRatesL ---");
|
||||
}
|
||||
|
||||
QList<int> S60AudioCaptureSession::supportedAudioSampleRates(const QAudioEncoderSettings &settings) const
|
||||
{
|
||||
DP0("S60AudioCaptureSession::supportedAudioSampleRates +++");
|
||||
|
||||
QList<int> supportedSampleRates;
|
||||
|
||||
if (!settings.codec().isEmpty()) {
|
||||
if (settings.codec() == "AMR")
|
||||
supportedSampleRates.append(8000);
|
||||
else
|
||||
supportedSampleRates = m_supportedSampleRates;
|
||||
}else
|
||||
supportedSampleRates = m_supportedSampleRates;
|
||||
|
||||
DP0("S60AudioCaptureSession::supportedAudioSampleRates ---");
|
||||
|
||||
return supportedSampleRates;
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::populateAudioCodecsDataL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::populateAudioCodecsDataL +++");
|
||||
|
||||
if (!m_recorderUtility) {
|
||||
DP0("No RecorderUtility");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_controllerIdMap.contains("audio/amr")) {
|
||||
CodecData data;
|
||||
data.codecDescription = QString("GSM AMR Codec");
|
||||
m_audioCodeclist[QString("AMR")]=data;
|
||||
}
|
||||
if (m_controllerIdMap.contains("audio/basic")) {
|
||||
CodecData data;
|
||||
data.fourCC = KMMFFourCCCodeALAW;
|
||||
data.codecDescription = QString("Sun/Next ""Au"" audio codec");
|
||||
m_audioCodeclist[QString("AULAW")]=data;
|
||||
}
|
||||
if (m_controllerIdMap.contains("audio/wav")) {
|
||||
CodecData data;
|
||||
data.fourCC = KMMFFourCCCodePCM16;
|
||||
data.codecDescription = QString("Pulse code modulation");
|
||||
m_audioCodeclist[QString("PCM")]=data;
|
||||
}
|
||||
if (m_controllerIdMap.contains("audio/mp4")) {
|
||||
CodecData data;
|
||||
data.fourCC = KMMFFourCCCodeAAC;
|
||||
data.codecDescription = QString("Advanced Audio Codec");
|
||||
m_audioCodeclist[QString("AAC")]=data;
|
||||
}
|
||||
|
||||
// default samplerates
|
||||
m_supportedSampleRates << 96000 << 88200 << 64000 << 48000 << 44100 << 32000 << 24000 << 22050 << 16000 << 12000 << 11025 << 8000;
|
||||
|
||||
DP0("S60AudioCaptureSession::populateAudioCodecsDataL ---");
|
||||
}
|
||||
|
||||
void S60AudioCaptureSession::applyAudioSettingsL()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::applyAudioSettingsL +++");
|
||||
|
||||
if (!m_recorderUtility)
|
||||
return;
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
//CAudioInput needs to be re-initialized every time recording starts
|
||||
if (m_audioInput) {
|
||||
delete m_audioInput;
|
||||
m_audioInput = NULL;
|
||||
}
|
||||
|
||||
if (m_setActiveEndPoint) {
|
||||
m_audioInput = CAudioInput::NewL(*m_recorderUtility);
|
||||
doSetAudioInputL(m_audioEndpoint);
|
||||
}
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
if (m_format.codec() == "AMR")
|
||||
return;
|
||||
|
||||
TFourCC fourCC = m_audioCodeclist.value(m_format.codec()).fourCC;
|
||||
|
||||
if (m_format.codec() == "PCM")
|
||||
fourCC = determinePCMFormat();
|
||||
|
||||
RArray<TFourCC> supportedDataTypes;
|
||||
CleanupClosePushL(supportedDataTypes);
|
||||
TRAPD(err,m_recorderUtility->GetSupportedDestinationDataTypesL(supportedDataTypes));
|
||||
TInt num = supportedDataTypes.Count();
|
||||
if (num > 0 ) {
|
||||
supportedDataTypes.SortUnsigned();
|
||||
int index = supportedDataTypes.Find(fourCC.FourCC());
|
||||
if (index != KErrNotFound) {
|
||||
TRAPD(err,m_recorderUtility->SetDestinationDataTypeL(supportedDataTypes[index]));
|
||||
}
|
||||
}
|
||||
|
||||
supportedDataTypes.Reset();
|
||||
CleanupStack::PopAndDestroy(&supportedDataTypes);
|
||||
|
||||
if (m_recorderUtility->DestinationSampleRateL() != m_format.frequency()) {
|
||||
|
||||
RArray<TUint> supportedSampleRates;
|
||||
CleanupClosePushL(supportedSampleRates);
|
||||
m_recorderUtility->GetSupportedSampleRatesL(supportedSampleRates);
|
||||
for (TInt i = 0; i < supportedSampleRates.Count(); i++ ) {
|
||||
TUint supportedSampleRate = supportedSampleRates[i];
|
||||
if (supportedSampleRate == m_format.frequency()) {
|
||||
m_recorderUtility->SetDestinationSampleRateL(m_format.frequency());
|
||||
break;
|
||||
}
|
||||
}
|
||||
supportedSampleRates.Reset();
|
||||
CleanupStack::PopAndDestroy(&supportedSampleRates);
|
||||
}
|
||||
|
||||
/* If requested channel setting is different than current one */
|
||||
if (m_recorderUtility->DestinationNumberOfChannelsL() != m_format.channels()) {
|
||||
RArray<TUint> supportedChannels;
|
||||
CleanupClosePushL(supportedChannels);
|
||||
m_recorderUtility->GetSupportedNumberOfChannelsL(supportedChannels);
|
||||
for (TInt l = 0; l < supportedChannels.Count(); l++ ) {
|
||||
if (supportedChannels[l] == m_format.channels()) {
|
||||
m_recorderUtility->SetDestinationNumberOfChannelsL(m_format.channels());
|
||||
break;
|
||||
}
|
||||
}
|
||||
supportedChannels.Reset();
|
||||
CleanupStack::PopAndDestroy(&supportedChannels);
|
||||
}
|
||||
|
||||
if (!(m_format.codec().compare("pcm",Qt::CaseInsensitive) == 0)) {
|
||||
if (m_recorderUtility->DestinationBitRateL() != m_audioEncoderSettings.bitRate()) {
|
||||
RArray<TUint> supportedBitRates;
|
||||
CleanupClosePushL(supportedBitRates);
|
||||
m_recorderUtility->GetSupportedBitRatesL(supportedBitRates);
|
||||
for (TInt l = 0; l < supportedBitRates.Count(); l++ ) {
|
||||
if (supportedBitRates[l] == m_audioEncoderSettings.bitRate()) {
|
||||
m_recorderUtility->SetDestinationBitRateL(m_audioEncoderSettings.bitRate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
supportedBitRates.Reset();
|
||||
CleanupStack::PopAndDestroy(&supportedBitRates);
|
||||
}
|
||||
}
|
||||
|
||||
DP0("S60AudioCaptureSession::applyAudioSettingsL ---");
|
||||
}
|
||||
|
||||
TFourCC S60AudioCaptureSession::determinePCMFormat()
|
||||
{
|
||||
DP0("S60AudioCaptureSession::determinePCMFormat +++");
|
||||
|
||||
TFourCC fourCC;
|
||||
|
||||
if (m_format.sampleSize() == 8) {
|
||||
// 8 bit
|
||||
switch (m_format.sampleType()) {
|
||||
case QAudioFormat::SignedInt: {
|
||||
fourCC.Set(KMMFFourCCCodePCM8);
|
||||
break;
|
||||
}
|
||||
case QAudioFormat::UnSignedInt: {
|
||||
fourCC.Set(KMMFFourCCCodePCMU8);
|
||||
break;
|
||||
}
|
||||
case QAudioFormat::Float:
|
||||
case QAudioFormat::Unknown:
|
||||
default: {
|
||||
fourCC.Set(KMMFFourCCCodePCM8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (m_format.sampleSize() == 16) {
|
||||
// 16 bit
|
||||
switch (m_format.sampleType()) {
|
||||
case QAudioFormat::SignedInt: {
|
||||
fourCC.Set(m_format.byteOrder()==QAudioFormat::BigEndian?
|
||||
KMMFFourCCCodePCM16B:KMMFFourCCCodePCM16);
|
||||
break;
|
||||
}
|
||||
case QAudioFormat::UnSignedInt: {
|
||||
fourCC.Set(m_format.byteOrder()==QAudioFormat::BigEndian?
|
||||
KMMFFourCCCodePCMU16B:KMMFFourCCCodePCMU16);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
fourCC.Set(KMMFFourCCCodePCM16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DP0("S60AudioCaptureSession::determinePCMFormat ---");
|
||||
|
||||
return fourCC;
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOCAPTURESESSION_H
|
||||
#define S60AUDIOCAPTURESESSION_H
|
||||
|
||||
#include <qmobilityglobal.h>
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QFile>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include "qaudioformat.h"
|
||||
#include <qmediarecorder.h>
|
||||
|
||||
#include <mda/common/audio.h>
|
||||
#include <mda/common/resource.h>
|
||||
#include <mda/client/utility.h>
|
||||
#include <mdaaudiosampleeditor.h>
|
||||
#include <mmf/common/mmfutilities.h>
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
#include <audioinput.h>
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
struct ControllerData
|
||||
{
|
||||
int controllerUid;
|
||||
int destinationFormatUid;
|
||||
QString destinationFormatDescription;
|
||||
QString fileExtension;
|
||||
};
|
||||
|
||||
struct CodecData
|
||||
{
|
||||
TFourCC fourCC;
|
||||
QString codecDescription;
|
||||
};
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60AudioCaptureSession : public QObject, public MMdaObjectStateChangeObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(qint64 position READ position NOTIFY positionChanged)
|
||||
Q_ENUMS(TAudioCaptureState)
|
||||
public:
|
||||
|
||||
enum TAudioCaptureState
|
||||
{
|
||||
ENotInitialized = 0,
|
||||
EInitialized,
|
||||
EOpenCompelete,
|
||||
ERecording,
|
||||
EPaused,
|
||||
ERecordComplete
|
||||
};
|
||||
|
||||
S60AudioCaptureSession(QObject *parent = 0);
|
||||
~S60AudioCaptureSession();
|
||||
|
||||
QAudioFormat format() const;
|
||||
bool setFormat(const QAudioFormat &format);
|
||||
QAudioEncoderSettings settings() const;
|
||||
bool setEncoderSettings(const QAudioEncoderSettings &setting);
|
||||
QStringList supportedAudioCodecs() const;
|
||||
QString codecDescription(const QString &codecName);
|
||||
bool setAudioCodec(const QString &codecName);
|
||||
QString audioCodec() const;
|
||||
QString audioContainer() const;
|
||||
QStringList supportedAudioContainers() const;
|
||||
bool setAudioContainer(const QString &containerMimeType);
|
||||
QString audioContainerDescription(const QString &containerName);
|
||||
QList<int> supportedAudioSampleRates(const QAudioEncoderSettings &settings) const;
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl& sink);
|
||||
qint64 position() const;
|
||||
void record();
|
||||
void pause();
|
||||
void stop();
|
||||
void mute(bool muted);
|
||||
bool muted();
|
||||
|
||||
QString activeEndpoint() const;
|
||||
QString defaultEndpoint() const;
|
||||
QList<QString> availableEndpoints() const;
|
||||
QString endpointDescription(const QString& name) const;
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
static const QString microPhone;
|
||||
static const QString voiceCall;
|
||||
static const QString fmRadio;
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
private:
|
||||
void initializeSessionL();
|
||||
void setError(TInt aError);
|
||||
QMediaRecorder::Error fromSymbianErrorToMultimediaError(int error);
|
||||
void prepareSinkL();
|
||||
void updateAudioContainersL();
|
||||
void populateAudioCodecsDataL();
|
||||
void retrieveSupportedAudioSampleRatesL();
|
||||
void applyAudioSettingsL();
|
||||
TFourCC determinePCMFormat();
|
||||
void setDefaultSettings();
|
||||
// MMdaObjectStateChangeObserver
|
||||
void MoscoStateChangeEvent(CBase* aObject, TInt aPreviousState,
|
||||
TInt aCurrentState, TInt aErrorCode);
|
||||
void MoscoStateChangeEventL(CBase* aObject, TInt aPreviousState,
|
||||
TInt aCurrentState, TInt aErrorCode);
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
QString qStringFromTAudioInputPreference(CAudioInput::TAudioInputPreference input) const;
|
||||
void initAudioInputs();
|
||||
void doSetAudioInputL(const QString& name);
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
|
||||
public Q_SLOTS:
|
||||
void setActiveEndpoint(const QString& audioEndpoint);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void stateChanged(S60AudioCaptureSession::TAudioCaptureState);
|
||||
void positionChanged(qint64 position);
|
||||
void error(int error, const QString &errorString);
|
||||
void activeEndpointChanged(const QString &audioEndpoint);
|
||||
private:
|
||||
QString m_container;
|
||||
QUrl m_sink;
|
||||
TTimeIntervalMicroSeconds m_pausedPosition;
|
||||
CMdaAudioRecorderUtility *m_recorderUtility;
|
||||
TAudioCaptureState m_captureState;
|
||||
QAudioFormat m_format;
|
||||
QAudioEncoderSettings m_audioEncoderSettings;
|
||||
QHash<QString, ControllerData> m_controllerIdMap;
|
||||
QHash<QString, CodecData> m_audioCodeclist;
|
||||
QList<int> m_supportedSampleRates;
|
||||
int m_error;
|
||||
bool m_isMuted;
|
||||
RFs m_fsSession;
|
||||
|
||||
#ifdef AUDIOINPUT_ROUTING
|
||||
bool m_setActiveEndPoint;
|
||||
CAudioInput *m_audioInput;
|
||||
|
||||
#endif //AUDIOINPUT_ROUTING
|
||||
QMap<QString, QString> m_audioInputs;
|
||||
QString m_audioEndpoint;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // S60AUDIOCAPTURESESSION_H
|
||||
@@ -1,96 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audiocontainercontrol.h"
|
||||
#include "s60audiocapturesession.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
S60AudioContainerControl::S60AudioContainerControl(QObject *parent)
|
||||
: QMediaContainerControl(parent)
|
||||
{
|
||||
DP0("S60AudioContainerControl::S60AudioContainerControl(QObject *parent) +++");
|
||||
|
||||
DP0("S60AudioContainerControl::S60AudioContainerControl(QObject *parent) ---");
|
||||
|
||||
}
|
||||
|
||||
S60AudioContainerControl::S60AudioContainerControl(QObject *session, QObject *parent)
|
||||
: QMediaContainerControl(parent)
|
||||
{
|
||||
DP0("S60AudioContainerControl::S60AudioContainerControl(QObject *session, QObject *parent) +++");
|
||||
|
||||
m_session = qobject_cast<S60AudioCaptureSession*>(session);
|
||||
|
||||
DP0("S60AudioContainerControl::S60AudioContainerControl(QObject *session, QObject *parent) ---");
|
||||
}
|
||||
|
||||
QStringList S60AudioContainerControl::supportedContainers() const
|
||||
{
|
||||
DP0("S60AudioContainerControl::supportedContainers");
|
||||
|
||||
return m_session->supportedAudioContainers();
|
||||
}
|
||||
|
||||
QString S60AudioContainerControl::containerMimeType() const
|
||||
{
|
||||
DP0("S60AudioContainerControl::containerMimeType");
|
||||
|
||||
return m_session->audioContainer();
|
||||
}
|
||||
|
||||
void S60AudioContainerControl::setContainerMimeType(const QString &containerMimeType)
|
||||
{
|
||||
DP0("S60AudioContainerControl::setContainerMimeType +++");
|
||||
|
||||
m_session->setAudioContainer(containerMimeType);
|
||||
|
||||
DP0("S60AudioContainerControl::setContainerMimeType ---");
|
||||
}
|
||||
|
||||
QString S60AudioContainerControl::containerDescription(const QString &containerMimeType) const
|
||||
{
|
||||
DP0("S60AudioContainerControl::containerDescription");
|
||||
|
||||
return m_session->audioContainerDescription(containerMimeType);
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOFORMATCONTROL_H
|
||||
#define S60AUDIOFORMATCONTROL_H
|
||||
|
||||
#include "qmediacontainercontrol.h"
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60AudioCaptureSession;
|
||||
|
||||
class S60AudioContainerControl : public QMediaContainerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
S60AudioContainerControl(QObject *parent = 0);
|
||||
S60AudioContainerControl(QObject *session, QObject *parent = 0);
|
||||
virtual ~S60AudioContainerControl() {};
|
||||
|
||||
QStringList supportedContainers() const;
|
||||
QString containerMimeType() const;
|
||||
void setContainerMimeType(const QString &containerMimeType);
|
||||
QString containerDescription(const QString &containerMimeType) const;
|
||||
|
||||
private:
|
||||
S60AudioCaptureSession* m_session;
|
||||
};
|
||||
|
||||
#endif // S60AUDIOFORMATCONTROL_H
|
||||
@@ -1,235 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audioencodercontrol.h"
|
||||
#include "s60audiocapturesession.h"
|
||||
|
||||
#include "qaudioformat.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
S60AudioEncoderControl::S60AudioEncoderControl(QObject *session, QObject *parent)
|
||||
:QAudioEncoderControl(parent), m_quality(QtMultimediaKit::NormalQuality)
|
||||
{
|
||||
DP0("S60AudioEncoderControl::S60AudioEncoderControl +++");
|
||||
|
||||
m_session = qobject_cast<S60AudioCaptureSession*>(session);
|
||||
QAudioFormat fmt = m_session->format();
|
||||
// medium, 22050Hz mono S16
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
if (fmt.codec().compare("PCM", Qt::CaseInsensitive) == 0) {
|
||||
fmt.setSampleSize(16);
|
||||
fmt.setFrequency(22050);
|
||||
}
|
||||
fmt.setChannels(1);
|
||||
m_session->setFormat(fmt);
|
||||
m_settings.setChannelCount(fmt.channels());
|
||||
m_settings.setCodec(fmt.codec());
|
||||
m_settings.setSampleRate(fmt.sampleRate());
|
||||
|
||||
DP0("S60AudioEncoderControl::S60AudioEncoderControl ---");
|
||||
}
|
||||
|
||||
S60AudioEncoderControl::~S60AudioEncoderControl()
|
||||
{
|
||||
DP0("S60AudioEncoderControl::~S60AudioEncoderControl +++");
|
||||
|
||||
DP0("S60AudioEncoderControl::~S60AudioEncoderControl ---");
|
||||
}
|
||||
|
||||
QStringList S60AudioEncoderControl::supportedAudioCodecs() const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::supportedAudioCodecs");
|
||||
|
||||
return m_session->supportedAudioCodecs();
|
||||
}
|
||||
|
||||
QString S60AudioEncoderControl::codecDescription(const QString &codecName) const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::codecDescription");
|
||||
|
||||
return m_session->codecDescription(codecName);
|
||||
}
|
||||
|
||||
QtMultimediaKit::EncodingQuality S60AudioEncoderControl::quality() const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::quality");
|
||||
|
||||
return m_quality;
|
||||
}
|
||||
|
||||
void S60AudioEncoderControl::setQuality(QtMultimediaKit::EncodingQuality value, QAudioFormat &fmt)
|
||||
{
|
||||
DP0("S60AudioEncoderControl::setQuality +++");
|
||||
|
||||
switch (value) {
|
||||
case QtMultimediaKit::VeryLowQuality:
|
||||
case QtMultimediaKit::LowQuality:
|
||||
// low, 8000Hz mono U8
|
||||
fmt.setSampleType(QAudioFormat::UnSignedInt);
|
||||
fmt.setSampleSize(8);
|
||||
fmt.setFrequency(8000);
|
||||
fmt.setChannels(1);
|
||||
break;
|
||||
case QtMultimediaKit::NormalQuality:
|
||||
// medium, 22050Hz mono S16
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
fmt.setSampleSize(16);
|
||||
fmt.setFrequency(22050);
|
||||
fmt.setChannels(1);
|
||||
break;
|
||||
case QtMultimediaKit::HighQuality:
|
||||
case QtMultimediaKit::VeryHighQuality:
|
||||
// high, 44100Hz mono S16
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
fmt.setSampleSize(16);
|
||||
fmt.setFrequency(44100);
|
||||
fmt.setChannels(2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DP0("S60AudioEncoderControl::setQuality ---");
|
||||
}
|
||||
|
||||
QStringList S60AudioEncoderControl::supportedEncodingOptions(const QString &codec) const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::supportedEncodingOptions");
|
||||
|
||||
Q_UNUSED(codec)
|
||||
QStringList list;
|
||||
if (codec == "PCM")
|
||||
list << "quality" << "channels" << "samplerate";
|
||||
return list;
|
||||
}
|
||||
|
||||
QVariant S60AudioEncoderControl::encodingOption(const QString &codec, const QString &name) const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::encodingOption");
|
||||
|
||||
if (codec == "PCM") {
|
||||
QAudioFormat fmt = m_session->format();
|
||||
|
||||
if(qstrcmp(name.toLocal8Bit().constData(), "quality") == 0) {
|
||||
return QVariant(quality());
|
||||
}
|
||||
else if(qstrcmp(name.toLocal8Bit().constData(), "channels") == 0) {
|
||||
return QVariant(fmt.channels());
|
||||
}
|
||||
else if(qstrcmp(name.toLocal8Bit().constData(), "samplerate") == 0) {
|
||||
return QVariant(fmt.frequency());
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void S60AudioEncoderControl::setEncodingOption(
|
||||
const QString &codec, const QString &name, const QVariant &value)
|
||||
{
|
||||
DP0("S60AudioEncoderControl::setEncodingOption +++");
|
||||
|
||||
if (codec == "PCM") {
|
||||
QAudioFormat fmt = m_session->format();
|
||||
|
||||
if(qstrcmp(name.toLocal8Bit().constData(), "quality") == 0) {
|
||||
setQuality((QtMultimediaKit::EncodingQuality)value.toInt(), fmt);
|
||||
} else if(qstrcmp(name.toLocal8Bit().constData(), "channels") == 0) {
|
||||
fmt.setChannels(value.toInt());
|
||||
} else if(qstrcmp(name.toLocal8Bit().constData(), "samplerate") == 0) {
|
||||
fmt.setFrequency(value.toInt());
|
||||
}
|
||||
m_session->setFormat(fmt);
|
||||
}
|
||||
|
||||
DP0("S60AudioEncoderControl::setEncodingOption ---");
|
||||
}
|
||||
|
||||
QList<int> S60AudioEncoderControl::supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous) const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::supportedSampleRates");
|
||||
|
||||
if (continuous)
|
||||
*continuous = false;
|
||||
|
||||
return m_session->supportedAudioSampleRates(settings);
|
||||
}
|
||||
|
||||
QAudioEncoderSettings S60AudioEncoderControl::audioSettings() const
|
||||
{
|
||||
DP0("S60AudioEncoderControl::audioSettings");
|
||||
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
void S60AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
|
||||
{
|
||||
DP0("S60AudioEncoderControl::setAudioSettings +++");
|
||||
|
||||
QAudioFormat fmt = m_session->format();
|
||||
if (settings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) {
|
||||
fmt.setCodec(settings.codec());
|
||||
setQuality(settings.quality(), fmt);
|
||||
if (settings.sampleRate() > 0) {
|
||||
fmt.setFrequency(settings.sampleRate());
|
||||
}
|
||||
if (settings.channelCount() > 0)
|
||||
fmt.setChannels(settings.channelCount());
|
||||
}else {
|
||||
if (settings.sampleRate() == 8000) {
|
||||
fmt.setSampleType(QAudioFormat::UnSignedInt);
|
||||
fmt.setSampleSize(8);
|
||||
} else {
|
||||
fmt.setSampleType(QAudioFormat::SignedInt);
|
||||
fmt.setSampleSize(16);
|
||||
}
|
||||
fmt.setCodec(settings.codec());
|
||||
fmt.setFrequency(settings.sampleRate());
|
||||
fmt.setChannels(settings.channelCount());
|
||||
}
|
||||
m_session->setFormat(fmt);
|
||||
m_session->setEncoderSettings(settings);
|
||||
m_settings = settings;
|
||||
|
||||
DP0("S60AudioEncoderControl::setAudioSettings ---");
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AUDIOENCODERCONTROL_H
|
||||
#define AUDIOENCODERCONTROL_H
|
||||
|
||||
#include <qaudioencodercontrol.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include "qaudioformat.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60AudioCaptureSession;
|
||||
|
||||
class S60AudioEncoderControl : public QAudioEncoderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
S60AudioEncoderControl(QObject *session, QObject *parent = 0);
|
||||
virtual ~S60AudioEncoderControl();
|
||||
|
||||
QStringList supportedAudioCodecs() const;
|
||||
QString codecDescription(const QString &codecName) const;
|
||||
|
||||
QList<int> supportedSampleRates(const QAudioEncoderSettings &settings, bool *continuous = 0) const;
|
||||
|
||||
QAudioEncoderSettings audioSettings() const;
|
||||
void setAudioSettings(const QAudioEncoderSettings&);
|
||||
|
||||
QStringList supportedEncodingOptions(const QString &codec) const;
|
||||
QVariant encodingOption(const QString &codec, const QString &name) const;
|
||||
void setEncodingOption(const QString &codec, const QString &name, const QVariant &value);
|
||||
|
||||
private:
|
||||
QtMultimediaKit::EncodingQuality quality() const;
|
||||
void setQuality(QtMultimediaKit::EncodingQuality, QAudioFormat &format);
|
||||
|
||||
private:
|
||||
S60AudioCaptureSession* m_session;
|
||||
QAudioEncoderSettings m_settings;
|
||||
QtMultimediaKit::EncodingQuality m_quality;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audiocapturesession.h"
|
||||
#include "s60audioendpointselector.h"
|
||||
|
||||
#include <qaudiodeviceinfo.h>
|
||||
|
||||
S60AudioEndpointSelector::S60AudioEndpointSelector(QObject *session, QObject *parent)
|
||||
:QAudioEndpointSelector(parent)
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::S60AudioEndpointSelector +++");
|
||||
m_session = qobject_cast<S60AudioCaptureSession*>(session);
|
||||
|
||||
connect(m_session, SIGNAL(activeEndpointChanged(const QString &)), this, SIGNAL(activeEndpointChanged(const QString &)));
|
||||
|
||||
DP0("S60AudioEndpointSelector::S60AudioEndpointSelector ---");
|
||||
}
|
||||
|
||||
S60AudioEndpointSelector::~S60AudioEndpointSelector()
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::~S60AudioEndpointSelector +++");
|
||||
|
||||
DP0("S60AudioEndpointSelector::~S60AudioEndpointSelector ---");
|
||||
}
|
||||
|
||||
QList<QString> S60AudioEndpointSelector::availableEndpoints() const
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::availableEndpoints");
|
||||
|
||||
return m_session->availableEndpoints();
|
||||
}
|
||||
|
||||
QString S60AudioEndpointSelector::endpointDescription(const QString& name) const
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::endpointDescription");
|
||||
|
||||
return m_session->endpointDescription(name);
|
||||
}
|
||||
|
||||
QString S60AudioEndpointSelector::defaultEndpoint() const
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::defaultEndpoint");
|
||||
|
||||
return m_session->defaultEndpoint();
|
||||
}
|
||||
|
||||
QString S60AudioEndpointSelector::activeEndpoint() const
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::activeEndpoint");
|
||||
|
||||
return m_session->activeEndpoint();
|
||||
}
|
||||
|
||||
void S60AudioEndpointSelector::setActiveEndpoint(const QString& name)
|
||||
{
|
||||
DP0("S60AudioEndpointSelector::setActiveEndpoint +++");
|
||||
m_session->setActiveEndpoint(name);
|
||||
DP0("S60AudioEndpointSelector::setActiveEndpoint ---");
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOENDPOINTSELECTOR_H
|
||||
#define S60AUDIOENDPOINTSELECTOR_H
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <qaudioendpointselector.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60AudioCaptureSession;
|
||||
|
||||
class S60AudioEndpointSelector : public QAudioEndpointSelector
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
S60AudioEndpointSelector(QObject *session, QObject *parent = 0);
|
||||
~S60AudioEndpointSelector();
|
||||
|
||||
QList<QString> availableEndpoints() const;
|
||||
QString endpointDescription(const QString& name) const;
|
||||
QString defaultEndpoint() const;
|
||||
QString activeEndpoint() const;
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
void setActiveEndpoint(const QString& name);
|
||||
|
||||
private:
|
||||
|
||||
S60AudioCaptureSession* m_session;
|
||||
};
|
||||
|
||||
#endif // S60AUDIOENDPOINTSELECTOR_H
|
||||
@@ -1,180 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audiomediarecordercontrol.h"
|
||||
#include "s60audiocapturesession.h"
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
S60AudioMediaRecorderControl::S60AudioMediaRecorderControl(QObject *session, QObject *parent)
|
||||
:QMediaRecorderControl(parent), m_state(QMediaRecorder::StoppedState)
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::S60AudioMediaRecorderControl +++");
|
||||
|
||||
m_session = qobject_cast<S60AudioCaptureSession*>(session);
|
||||
connect(m_session, SIGNAL(positionChanged(qint64)), this, SIGNAL(durationChanged(qint64)));
|
||||
connect(m_session, SIGNAL(stateChanged(S60AudioCaptureSession::TAudioCaptureState)), this, SLOT(updateState(S60AudioCaptureSession::TAudioCaptureState)));
|
||||
connect(m_session,SIGNAL(error(int,const QString &)),this,SIGNAL(error(int,const QString &)));
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::S60AudioMediaRecorderControl ---");
|
||||
}
|
||||
|
||||
S60AudioMediaRecorderControl::~S60AudioMediaRecorderControl()
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::~S60AudioMediaRecorderControl +++");
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::~S60AudioMediaRecorderControl - - ");
|
||||
}
|
||||
|
||||
QUrl S60AudioMediaRecorderControl::outputLocation() const
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::outputLocation");
|
||||
|
||||
return m_session->outputLocation();
|
||||
}
|
||||
|
||||
bool S60AudioMediaRecorderControl::setOutputLocation(const QUrl& sink)
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::setOutputLocation");
|
||||
|
||||
return m_session->setOutputLocation(sink);
|
||||
}
|
||||
|
||||
QMediaRecorder::State S60AudioMediaRecorderControl::convertState(S60AudioCaptureSession::TAudioCaptureState aState) const
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::convertState +++");
|
||||
|
||||
QMediaRecorder::State state = QMediaRecorder::StoppedState;;
|
||||
switch (aState) {
|
||||
case S60AudioCaptureSession::ERecording:
|
||||
state = QMediaRecorder::RecordingState;
|
||||
break;
|
||||
case S60AudioCaptureSession::EPaused:
|
||||
state = QMediaRecorder::PausedState;
|
||||
break;
|
||||
case S60AudioCaptureSession::ERecordComplete:
|
||||
case S60AudioCaptureSession::ENotInitialized:
|
||||
case S60AudioCaptureSession::EOpenCompelete:
|
||||
case S60AudioCaptureSession::EInitialized:
|
||||
state = QMediaRecorder::StoppedState;
|
||||
break;
|
||||
}
|
||||
|
||||
DP1("S60AudioMediaRecorderControl::convertState:", state);
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::convertState ---");
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void S60AudioMediaRecorderControl::updateState(S60AudioCaptureSession::TAudioCaptureState aState)
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::updateState +++");
|
||||
|
||||
QMediaRecorder::State newState = convertState(aState);
|
||||
if (m_state != newState) {
|
||||
m_state = newState;
|
||||
emit stateChanged(m_state);
|
||||
}
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::updateState ---");
|
||||
}
|
||||
|
||||
QMediaRecorder::State S60AudioMediaRecorderControl::state() const
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::state");
|
||||
|
||||
return m_state;
|
||||
}
|
||||
|
||||
qint64 S60AudioMediaRecorderControl::duration() const
|
||||
{
|
||||
// DP0("S60AudioMediaRecorderControl::duration +++");
|
||||
|
||||
return m_session->position();
|
||||
}
|
||||
|
||||
void S60AudioMediaRecorderControl::record()
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::record +++");
|
||||
|
||||
m_session->record();
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::record ---");
|
||||
}
|
||||
|
||||
void S60AudioMediaRecorderControl::pause()
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::pause +++");
|
||||
|
||||
m_session->pause();
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::pause ---");
|
||||
}
|
||||
|
||||
void S60AudioMediaRecorderControl::stop()
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::stop +++");
|
||||
|
||||
m_session->stop();
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::stop ---");
|
||||
}
|
||||
|
||||
bool S60AudioMediaRecorderControl::isMuted() const
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::isMuted");
|
||||
|
||||
return m_session->muted();
|
||||
}
|
||||
|
||||
void S60AudioMediaRecorderControl::setMuted(bool muted)
|
||||
{
|
||||
DP0("S60AudioMediaRecorderControl::setMuted +++");
|
||||
|
||||
DP1("S60AudioMediaRecorderControl::setMuted:", muted);
|
||||
|
||||
m_session->mute(muted);
|
||||
|
||||
DP0("S60AudioMediaRecorderControl::setMuted +++");
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOMEDIARECORDERCONTROL_H
|
||||
#define S60AUDIOMEDIARECORDERCONTROL_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QUrl>
|
||||
|
||||
#include "qmediarecorder.h"
|
||||
#include "qmediarecordercontrol.h"
|
||||
|
||||
#include "s60audiocapturesession.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
//class S60AudioCaptureSession;
|
||||
|
||||
class S60AudioMediaRecorderControl : public QMediaRecorderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
S60AudioMediaRecorderControl(QObject *session,QObject *parent = 0);
|
||||
~S60AudioMediaRecorderControl();
|
||||
|
||||
QUrl outputLocation() const;
|
||||
bool setOutputLocation(const QUrl &sink);
|
||||
|
||||
QMediaRecorder::State state() const;
|
||||
|
||||
qint64 duration() const;
|
||||
|
||||
bool isMuted() const;
|
||||
|
||||
void applySettings() {}
|
||||
|
||||
private:
|
||||
QMediaRecorder::State convertState(S60AudioCaptureSession::TAudioCaptureState aState) const;
|
||||
|
||||
public slots:
|
||||
void record();
|
||||
void pause();
|
||||
void stop();
|
||||
void setMuted(bool);
|
||||
|
||||
private slots:
|
||||
void updateState(S60AudioCaptureSession::TAudioCaptureState aState);
|
||||
|
||||
private:
|
||||
S60AudioCaptureSession* m_session;
|
||||
QMediaRecorder::State m_state;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,66 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#ifndef __DEBUGMACROS_H__
|
||||
#define __DEBUGMACROS_H__
|
||||
|
||||
// MACROS
|
||||
#ifdef _DEBUG
|
||||
#define DP0(string) qDebug()<<string
|
||||
#define DP1(string,arg1) qDebug()<<string<<arg1
|
||||
#define DP2(string,arg1,arg2) qDebug()<<string<<arg1<<arg2
|
||||
#define DP3(string,arg1,arg2,arg3) qDebug()<<string<<arg1<<arg2<<arg3
|
||||
#define DP4(string,arg1,arg2,arg3,arg4) qDebug()<<string<<arg1<<arg2<<arg3<<arg4
|
||||
#define DP5(string,arg1,arg2,arg3,arg4,arg5) qDebug()<<string<<arg1<<arg2<<arg3<<arg4<<arg5
|
||||
#define DP6(string,arg1,arg2,arg3,arg4,arg5,arg6) qDebug()<<string<<arg1<<arg2<<arg3<<arg4<<arg5<<arg6
|
||||
#else
|
||||
#define DP0(string)
|
||||
#define DP1(string,arg1)
|
||||
#define DP2(string,arg1,arg2)
|
||||
#define DP3(string,arg1,arg2,arg3)
|
||||
#define DP4(string,arg1,arg2,arg3,arg4)
|
||||
#define DP5(string,arg1,arg2,arg3,arg4,arg5)
|
||||
#define DP6(string,arg1,arg2,arg3,arg4,arg5,arg6)
|
||||
#endif
|
||||
|
||||
#endif //__DEBUGMACROS_H__
|
||||
@@ -1,92 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
include (../../videooutput/videooutput.pri)
|
||||
|
||||
LIBS *= -lmediaclientvideo \
|
||||
-lmediaclientaudio \
|
||||
-lws32 \
|
||||
-lfbscli \
|
||||
-lcone \
|
||||
-lmmfcontrollerframework \
|
||||
-lefsrv \
|
||||
-lbitgdi \
|
||||
-lapgrfx \
|
||||
-lapmime \
|
||||
-lcommdb \
|
||||
-lbafl
|
||||
|
||||
# If support to DRM is wanted then comment out the following line
|
||||
#CONFIG += drm_supported
|
||||
|
||||
# We are building Symbian backend with media player support
|
||||
DEFINES += HAS_MEDIA_PLAYER
|
||||
# We are building media player with QVideoRendererControl support
|
||||
#DEFINES += HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER
|
||||
|
||||
drm_supported {
|
||||
LIBS += -ldrmaudioplayutility
|
||||
DEFINES += S60_DRM_SUPPORTED
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/s60mediaplayercontrol.h \
|
||||
$$PWD/s60mediaplayerservice.h \
|
||||
$$PWD/s60mediaplayersession.h \
|
||||
$$PWD/s60mediametadataprovider.h \
|
||||
$$PWD/s60videoplayersession.h \
|
||||
$$PWD/s60videosurface.h \
|
||||
$$PWD/s60mediarecognizer.h \
|
||||
$$PWD/s60audioplayersession.h \
|
||||
$$PWD/ms60mediaplayerresolver.h \
|
||||
$$PWD/s60mediaplayeraudioendpointselector.h \
|
||||
$$PWD/s60mediastreamcontrol.h \
|
||||
$$PWD/s60medianetworkaccesscontrol.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/s60mediaplayercontrol.cpp \
|
||||
$$PWD/s60mediaplayerservice.cpp \
|
||||
$$PWD/s60mediaplayersession.cpp \
|
||||
$$PWD/s60mediametadataprovider.cpp \
|
||||
$$PWD/s60videoplayersession.cpp \
|
||||
$$PWD/s60videosurface.cpp \
|
||||
$$PWD/s60mediarecognizer.cpp \
|
||||
$$PWD/s60audioplayersession.cpp \
|
||||
$$PWD/s60mediaplayeraudioendpointselector.cpp \
|
||||
$$PWD/s60mediastreamcontrol.cpp \
|
||||
$$PWD/s60medianetworkaccesscontrol.cpp
|
||||
|
||||
contains(DEFINES, HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER) {
|
||||
HEADERS += $$PWD/s60videorenderer.h
|
||||
SOURCES += $$PWD/s60videorenderer.cpp
|
||||
}
|
||||
|
||||
contains(S60_VERSION, 3.1) {
|
||||
#3.1 doesn't provide audio routing in videoplayer
|
||||
contains(audiorouting_s60_enabled,yes) {
|
||||
MMP_RULES += "$${LITERAL_HASH}ifndef WINSCW" \
|
||||
"MACRO HAS_AUDIOROUTING" \
|
||||
"LIBRARY audiooutputrouting.lib" \
|
||||
"$${LITERAL_HASH}endif"
|
||||
message("Note: AudioOutput Routing API not supported for 3.1 winscw target and in videoplayer")
|
||||
}
|
||||
|
||||
} else {
|
||||
contains(audiorouting_s60_enabled,yes) {
|
||||
#We use audiooutputrouting.lib for directing audio output to speaker/earspeaker
|
||||
DEFINES += HAS_AUDIOROUTING_IN_VIDEOPLAYER
|
||||
DEFINES += HAS_AUDIOROUTING
|
||||
message("Audiorouting_s60 enabled for post 3.1 sdk")
|
||||
LIBS += -laudiooutputrouting
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
contains(S60_VERSION, 3.1) {
|
||||
DEFINES += PLAY_RATE_NOT_SUPPORTED
|
||||
message("S60 version 3.1 does not support setplaybackrate")
|
||||
}
|
||||
contains(S60_VERSION, 3.2) {
|
||||
DEFINES += PLAY_RATE_NOT_SUPPORTED
|
||||
message("S60 version 3.2 does not support setplaybackrate")
|
||||
}
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
#ifndef MS60MEDIAPLAYERRESOLVER_H
|
||||
#define MS60MEDIAPLAYERRESOLVER_H
|
||||
|
||||
class S60MediaPlayerSession;
|
||||
|
||||
class MS60MediaPlayerResolver
|
||||
{
|
||||
public:
|
||||
virtual S60MediaPlayerSession* PlayerSession() = 0;
|
||||
virtual S60MediaPlayerSession* VideoPlayerSession() = 0;
|
||||
virtual S60MediaPlayerSession* AudioPlayerSession() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,577 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60audioplayersession.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
|
||||
/*!
|
||||
Constructs the CMdaAudioPlayerUtility object with given \a parent QObject.
|
||||
|
||||
And Registers for Audio Loading Notifications.
|
||||
|
||||
*/
|
||||
|
||||
S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent)
|
||||
: S60MediaPlayerSession(parent)
|
||||
, m_player(0)
|
||||
, m_audioEndpoint("Default")
|
||||
{
|
||||
DP0("S60AudioPlayerSession::S60AudioPlayerSession +++");
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
m_audioOutput = 0;
|
||||
#endif //HAS_AUDIOROUTING
|
||||
QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone));
|
||||
m_player->RegisterForAudioLoadingNotification(*this);
|
||||
|
||||
DP0("S60AudioPlayerSession::S60AudioPlayerSession ---");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Destroys the CMdaAudioPlayerUtility object.
|
||||
|
||||
And Unregister the observer.
|
||||
|
||||
*/
|
||||
|
||||
S60AudioPlayerSession::~S60AudioPlayerSession()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::~S60AudioPlayerSession +++");
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
if (m_audioOutput)
|
||||
m_audioOutput->UnregisterObserver(*this);
|
||||
delete m_audioOutput;
|
||||
#endif
|
||||
m_player->Close();
|
||||
delete m_player;
|
||||
|
||||
DP0("S60AudioPlayerSession::~S60AudioPlayerSession ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Opens the a file from \a path.
|
||||
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doLoadL(const TDesC &path)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doLoadL +++");
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
// m_audioOutput needs to be reinitialized after MapcInitComplete
|
||||
if (m_audioOutput)
|
||||
m_audioOutput->UnregisterObserver(*this);
|
||||
delete m_audioOutput;
|
||||
m_audioOutput = NULL;
|
||||
#endif //HAS_AUDIOROUTING
|
||||
m_player->OpenFileL(path);
|
||||
|
||||
DP0("S60AudioPlayerSession::doLoadL ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Returns the duration of the audio sample in microseconds.
|
||||
|
||||
*/
|
||||
|
||||
qint64 S60AudioPlayerSession::doGetDurationL() const
|
||||
{
|
||||
// DP0("S60AudioPlayerSession::doGetDurationL");
|
||||
|
||||
return m_player->Duration().Int64() / qint64(1000);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the current playback position in microseconds from the start of the clip.
|
||||
|
||||
*/
|
||||
|
||||
qint64 S60AudioPlayerSession::doGetPositionL() const
|
||||
{
|
||||
// DP0("S60AudioPlayerSession::doGetPositionL");
|
||||
|
||||
TTimeIntervalMicroSeconds ms = 0;
|
||||
m_player->GetPosition(ms);
|
||||
return ms.Int64() / qint64(1000);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns TRUE if Video available or else FALSE
|
||||
*/
|
||||
|
||||
bool S60AudioPlayerSession::isVideoAvailable()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::isVideoAvailable");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns TRUE if Audio available or else FALSE
|
||||
*/
|
||||
bool S60AudioPlayerSession::isAudioAvailable()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::isAudioAvailable");
|
||||
|
||||
return true; // this is a bit happy scenario, but we do emit error that we can't play
|
||||
}
|
||||
|
||||
/*!
|
||||
Starts loading Media and sets media status to Buffering.
|
||||
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::MaloLoadingStarted()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::MaloLoadingStarted +++");
|
||||
|
||||
buffering();
|
||||
|
||||
DP0("S60AudioPlayerSession::MaloLoadingStarted ---");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Indicates loading Media is completed.
|
||||
|
||||
And sets media status to Buffered.
|
||||
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::MaloLoadingComplete()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::MaloLoadingComplete +++");
|
||||
|
||||
buffered();
|
||||
|
||||
DP0("S60AudioPlayerSession::MaloLoadingComplete ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Start or resume playing the current source.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doPlay()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doPlay +++");
|
||||
|
||||
// For some reason loading progress callback are not called on emulator
|
||||
// Same is the case with hardware. Will be fixed as part of QTMOBILITY-782.
|
||||
|
||||
//#ifdef __WINSCW__
|
||||
buffering();
|
||||
//#endif
|
||||
m_player->Play();
|
||||
//#ifdef __WINSCW__
|
||||
buffered();
|
||||
//#endif
|
||||
|
||||
DP0("S60AudioPlayerSession::doPlay ---");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Pause playing the current source.
|
||||
*/
|
||||
|
||||
|
||||
void S60AudioPlayerSession::doPauseL()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doPauseL +++");
|
||||
|
||||
m_player->Pause();
|
||||
|
||||
DP0("S60AudioPlayerSession::doPauseL ---");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
Stop playing, and reset the play position to the beginning.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doStop()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doStop +++");
|
||||
|
||||
m_player->Stop();
|
||||
|
||||
DP0("S60AudioPlayerSession::doStop ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Closes the current audio clip (allowing another clip to be opened)
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doClose()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doClose +++");
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
if (m_audioOutput) {
|
||||
m_audioOutput->UnregisterObserver(*this);
|
||||
delete m_audioOutput;
|
||||
m_audioOutput = NULL;
|
||||
}
|
||||
#endif
|
||||
m_player->Close();
|
||||
|
||||
DP0("S60AudioPlayerSession::doClose ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Changes the current playback volume to specified \a value.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doSetVolumeL(int volume)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doSetVolumeL +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::doSetVolumeL, Volume:", volume);
|
||||
|
||||
m_player->SetVolume(volume * m_player->MaxVolume() / 100);
|
||||
|
||||
DP0("S60AudioPlayerSession::doSetVolumeL ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the current playback position to \a microSeconds from the start of the clip.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doSetPositionL(qint64 microSeconds)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doSetPositionL +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::doSetPositionL, Microseconds:", microSeconds);
|
||||
|
||||
m_player->SetPosition(TTimeIntervalMicroSeconds(microSeconds));
|
||||
|
||||
DP0("S60AudioPlayerSession::doSetPositionL ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Updates meta data entries in the current audio clip.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::updateMetaDataEntriesL()
|
||||
{
|
||||
DP0("S60AudioPlayerSession::updateMetaDataEntriesL +++");
|
||||
|
||||
metaDataEntries().clear();
|
||||
int numberOfMetaDataEntries = 0;
|
||||
|
||||
//User::LeaveIfError(m_player->GetNumberOfMetaDataEntries(numberOfMetaDataEntries));
|
||||
m_player->GetNumberOfMetaDataEntries(numberOfMetaDataEntries);
|
||||
|
||||
for (int i = 0; i < numberOfMetaDataEntries; i++) {
|
||||
CMMFMetaDataEntry *entry = NULL;
|
||||
entry = m_player->GetMetaDataEntryL(i);
|
||||
metaDataEntries().insert(QString::fromUtf16(entry->Name().Ptr(), entry->Name().Length()), QString::fromUtf16(entry->Value().Ptr(), entry->Value().Length()));
|
||||
delete entry;
|
||||
}
|
||||
emit metaDataChanged();
|
||||
|
||||
DP0("S60AudioPlayerSession::updateMetaDataEntriesL ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the playbackRate with \a rate.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::setPlaybackRate(qreal rate)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::setPlaybackRate +++");
|
||||
DP1("S60AudioPlayerSession::setPlaybackRate, Rate:", rate);
|
||||
/*Since AudioPlayerUtility doesn't support set playback rate hence
|
||||
* setPlaybackRate emits playbackRateChanged signal for 1.0x ie normal playback.
|
||||
* For all other playBackRates it sets and emits error signal.
|
||||
*/
|
||||
if (rate == 1.0) {
|
||||
emit playbackRateChanged(rate);
|
||||
return;
|
||||
} else {
|
||||
int err = KErrNotSupported;
|
||||
setAndEmitError(err);
|
||||
}
|
||||
DP0("S60AudioPlayerSession::setPlaybackRate ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Returns the percentage of the audio clip loaded.
|
||||
*/
|
||||
|
||||
int S60AudioPlayerSession::doGetBufferStatusL() const
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doGetBufferStatusL +++");
|
||||
|
||||
int progress = 0;
|
||||
m_player->GetAudioLoadingProgressL(progress);
|
||||
|
||||
DP0("S60AudioPlayerSession::doGetBufferStatusL ---");
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Defines required client behaviour when an attempt to open and initialise an audio sample has completed,
|
||||
successfully or not.
|
||||
|
||||
\a aError if KErrNone the sample is ready to play or else system wide error.
|
||||
|
||||
\a aDuration The duration of the audio sample.
|
||||
*/
|
||||
|
||||
#ifdef S60_DRM_SUPPORTED
|
||||
void S60AudioPlayerSession::MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)
|
||||
#else
|
||||
void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration)
|
||||
#endif
|
||||
{
|
||||
DP0("S60AudioPlayerSession::MdapcInitComplete +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::MdapcInitComplete - aError", aError);
|
||||
|
||||
Q_UNUSED(aDuration);
|
||||
setError(aError);
|
||||
if (KErrNone != aError)
|
||||
return;
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
TRAPD(err,
|
||||
m_audioOutput = CAudioOutput::NewL(*m_player);
|
||||
m_audioOutput->RegisterObserverL(*this);
|
||||
);
|
||||
setActiveEndpoint(m_audioEndpoint);
|
||||
setError(err);
|
||||
#endif //HAS_AUDIOROUTING
|
||||
if (KErrNone == aError)
|
||||
loaded();
|
||||
|
||||
DP0("S60AudioPlayerSession::MdapcInitComplete ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Defines required client behaviour when an attempt to playback an audio sample has completed,
|
||||
successfully or not.
|
||||
|
||||
\a aError if KErrNone the playback completed or else system wide error.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef S60_DRM_SUPPORTED
|
||||
void S60AudioPlayerSession::MdapcPlayComplete(TInt aError)
|
||||
#else
|
||||
void S60AudioPlayerSession::MapcPlayComplete(TInt aError)
|
||||
#endif
|
||||
{
|
||||
DP0("S60AudioPlayerSession::MdapcPlayComplete +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::MdapcPlayComplete", aError);
|
||||
|
||||
if (KErrNone == aError)
|
||||
endOfMedia();
|
||||
else
|
||||
setError(aError);
|
||||
|
||||
DP0("S60AudioPlayerSession::MdapcPlayComplete ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Defiens which Audio End point to use.
|
||||
|
||||
\a audioEndpoint audioEndpoint name.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::doSetAudioEndpoint +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::doSetAudioEndpoint - ", audioEndpoint);
|
||||
|
||||
m_audioEndpoint = audioEndpoint;
|
||||
|
||||
DP0("S60AudioPlayerSession::doSetAudioEndpoint ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Returns audioEndpoint name.
|
||||
*/
|
||||
|
||||
QString S60AudioPlayerSession::activeEndpoint() const
|
||||
{
|
||||
DP0("S60AudioPlayerSession::activeEndpoint +++");
|
||||
|
||||
QString outputName = QString("Default");
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
if (m_audioOutput) {
|
||||
CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput();
|
||||
outputName = qStringFromTAudioOutputPreference(output);
|
||||
}
|
||||
#endif
|
||||
DP1("S60AudioPlayerSession::activeEndpoint is :", outputName);
|
||||
|
||||
DP0("S60AudioPlayerSession::activeEndpoint ---");
|
||||
return outputName;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns default Audio End point in use.
|
||||
*/
|
||||
|
||||
QString S60AudioPlayerSession::defaultEndpoint() const
|
||||
{
|
||||
DP0("S60AudioPlayerSession::defaultEndpoint +++");
|
||||
|
||||
QString outputName = QString("Default");
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
if (m_audioOutput) {
|
||||
CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput();
|
||||
outputName = qStringFromTAudioOutputPreference(output);
|
||||
}
|
||||
#endif
|
||||
DP1("S60AudioPlayerSession::defaultEndpoint is :", outputName);
|
||||
|
||||
DP0("S60AudioPlayerSession::defaultEndpoint ---");
|
||||
return outputName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets active end \a name as an Audio End point.
|
||||
*/
|
||||
|
||||
void S60AudioPlayerSession::setActiveEndpoint(const QString& name)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::setActiveEndpoint +++");
|
||||
|
||||
DP1("S60AudioPlayerSession::setActiveEndpoint - ", name);
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference;
|
||||
|
||||
if (name == QString("Default"))
|
||||
output = CAudioOutput::ENoPreference;
|
||||
else if (name == QString("All"))
|
||||
output = CAudioOutput::EAll;
|
||||
else if (name == QString("None"))
|
||||
output = CAudioOutput::ENoOutput;
|
||||
else if (name == QString("Earphone"))
|
||||
output = CAudioOutput::EPrivate;
|
||||
else if (name == QString("Speaker"))
|
||||
output = CAudioOutput::EPublic;
|
||||
|
||||
if (m_audioOutput) {
|
||||
TRAPD(err, m_audioOutput->SetAudioOutputL(output));
|
||||
setError(err);
|
||||
}
|
||||
#endif
|
||||
|
||||
DP0("S60AudioPlayerSession::setActiveEndpoint ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
The default audio output has been changed.
|
||||
|
||||
\a aAudioOutput Audio Output object.
|
||||
|
||||
\a aNewDefault is CAudioOutput::TAudioOutputPreference.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput,
|
||||
CAudioOutput::TAudioOutputPreference aNewDefault)
|
||||
{
|
||||
DP0("S60AudioPlayerSession::DefaultAudioOutputChanged +++");
|
||||
|
||||
// Emit already implemented in setActiveEndpoint function
|
||||
Q_UNUSED(aAudioOutput)
|
||||
Q_UNUSED(aNewDefault)
|
||||
|
||||
DP0("S60AudioPlayerSession::DefaultAudioOutputChanged ---");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Converts CAudioOutput::TAudioOutputPreference enum to QString.
|
||||
|
||||
\a output is CAudioOutput::TAudioOutputPreference enum value.
|
||||
|
||||
*/
|
||||
|
||||
QString S60AudioPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const
|
||||
{
|
||||
DP0("S60AudioPlayerSession::qStringFromTAudioOutputPreference");
|
||||
|
||||
if (output == CAudioOutput::ENoPreference)
|
||||
return QString("Default");
|
||||
else if (output == CAudioOutput::EAll)
|
||||
return QString("All");
|
||||
else if (output == CAudioOutput::ENoOutput)
|
||||
return QString("None");
|
||||
else if (output == CAudioOutput::EPrivate)
|
||||
return QString("Earphone");
|
||||
else if (output == CAudioOutput::EPublic)
|
||||
return QString("Speaker");
|
||||
return QString("Default");
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Return True if its Seekable or else False.
|
||||
*/
|
||||
|
||||
bool S60AudioPlayerSession::getIsSeekable() const
|
||||
{
|
||||
DP0("S60AudioPlayerSession::getIsSeekable");
|
||||
|
||||
return ETrue;
|
||||
}
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60AUDIOPLAYERSESSION_H
|
||||
#define S60AUDIOPLAYERSESSION_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include "s60mediaplayersession.h"
|
||||
|
||||
#ifdef S60_DRM_SUPPORTED
|
||||
#include <drmaudiosampleplayer.h>
|
||||
typedef CDrmPlayerUtility CAudioPlayer;
|
||||
typedef MDrmAudioPlayerCallback MAudioPlayerObserver;
|
||||
#else
|
||||
#include <mdaaudiosampleplayer.h>
|
||||
typedef CMdaAudioPlayerUtility CAudioPlayer;
|
||||
typedef MMdaAudioPlayerCallback MAudioPlayerObserver;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
#include <AudioOutput.h>
|
||||
#include <MAudioOutputObserver.h>
|
||||
#endif //HAS_AUDIOROUTING
|
||||
|
||||
class S60AudioPlayerSession : public S60MediaPlayerSession
|
||||
, public MAudioPlayerObserver
|
||||
, public MAudioLoadingObserver
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
, public MAudioOutputObserver
|
||||
#endif
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
S60AudioPlayerSession(QObject *parent);
|
||||
~S60AudioPlayerSession();
|
||||
|
||||
//From S60MediaPlayerSession
|
||||
bool isVideoAvailable();
|
||||
bool isAudioAvailable();
|
||||
|
||||
// From MAudioLoadingObserver
|
||||
void MaloLoadingStarted();
|
||||
void MaloLoadingComplete();
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
// From MAudioOutputObserver
|
||||
void DefaultAudioOutputChanged( CAudioOutput& aAudioOutput,
|
||||
CAudioOutput::TAudioOutputPreference aNewDefault );
|
||||
#endif //HAS_AUDIOROUTING
|
||||
|
||||
public:
|
||||
// From S60MediaPlayerAudioEndpointSelector
|
||||
QString activeEndpoint() const;
|
||||
QString defaultEndpoint() const;
|
||||
void setPlaybackRate(qreal rate);
|
||||
public Q_SLOTS:
|
||||
void setActiveEndpoint(const QString& name);
|
||||
|
||||
protected:
|
||||
//From S60MediaPlayerSession
|
||||
void doLoadL(const TDesC &path);
|
||||
void doLoadUrlL(const TDesC &path){Q_UNUSED(path)/*empty implementation*/}
|
||||
void doPlay();
|
||||
void doStop();
|
||||
void doClose();
|
||||
void doPauseL();
|
||||
void doSetVolumeL(int volume);
|
||||
qint64 doGetPositionL() const;
|
||||
void doSetPositionL(qint64 microSeconds);
|
||||
void updateMetaDataEntriesL();
|
||||
int doGetBufferStatusL() const;
|
||||
qint64 doGetDurationL() const;
|
||||
void doSetAudioEndpoint(const QString& audioEndpoint);
|
||||
bool getIsSeekable() const;
|
||||
private:
|
||||
#ifdef S60_DRM_SUPPORTED
|
||||
// From MMdaAudioPlayerCallback
|
||||
void MdapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
|
||||
void MdapcPlayComplete(TInt aError);
|
||||
#else
|
||||
// From MDrmAudioPlayerCallback
|
||||
void MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration);
|
||||
void MapcPlayComplete(TInt aError);
|
||||
#endif
|
||||
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
QString qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const;
|
||||
#endif //HAS_AUDIOROUTING
|
||||
|
||||
private:
|
||||
CAudioPlayer *m_player;
|
||||
#ifdef HAS_AUDIOROUTING
|
||||
CAudioOutput *m_audioOutput;
|
||||
#endif //HAS_AUDIOROUTING
|
||||
QString m_audioEndpoint;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,146 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60mediametadataprovider.h"
|
||||
#include "s60mediaplayercontrol.h"
|
||||
#include "s60mediaplayersession.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
/*!
|
||||
* Typecasts the \a control object to S60MediaPlayerControl object.
|
||||
*/
|
||||
S60MediaMetaDataProvider::S60MediaMetaDataProvider(QObject *control, QObject *parent)
|
||||
: QMetaDataReaderControl(parent)
|
||||
, m_control(NULL)
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::S60MediaMetaDataProvider +++");
|
||||
|
||||
m_control = qobject_cast<S60MediaPlayerControl*>(control);
|
||||
|
||||
DP0("S60MediaMetaDataProvider::S60MediaMetaDataProvider ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* Destructor
|
||||
*/
|
||||
|
||||
S60MediaMetaDataProvider::~S60MediaMetaDataProvider()
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::~S60MediaMetaDataProvider +++");
|
||||
DP0("S60MediaMetaDataProvider::~S60MediaMetaDataProvider ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns TRUE if MetaData is Available or else FALSE.
|
||||
*/
|
||||
|
||||
bool S60MediaMetaDataProvider::isMetaDataAvailable() const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::isMetaDataAvailable");
|
||||
|
||||
if (m_control->session())
|
||||
return m_control->session()->isMetadataAvailable();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Always returns FLASE.
|
||||
*/
|
||||
bool S60MediaMetaDataProvider::isWritable() const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::isWritable");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns when \a key meta data is found in metaData.
|
||||
*/
|
||||
|
||||
QVariant S60MediaMetaDataProvider::metaData(QtMultimediaKit::MetaData key) const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::metaData");
|
||||
|
||||
if (m_control->session())
|
||||
return m_control->session()->metaData(key);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns available metaData.
|
||||
*/
|
||||
|
||||
QList<QtMultimediaKit::MetaData> S60MediaMetaDataProvider::availableMetaData() const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::availableMetaData");
|
||||
|
||||
if (m_control->session())
|
||||
return m_control->session()->availableMetaData();
|
||||
return QList<QtMultimediaKit::MetaData>();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns when \a key string is found in extended metaData.
|
||||
*/
|
||||
|
||||
QVariant S60MediaMetaDataProvider::extendedMetaData(const QString &key) const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::extendedMetaData");
|
||||
|
||||
if (m_control->session())
|
||||
return m_control->session()->metaData(key);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns available Extended MetaData.
|
||||
*/
|
||||
|
||||
QStringList S60MediaMetaDataProvider::availableExtendedMetaData() const
|
||||
{
|
||||
DP0("S60MediaMetaDataProvider::availableExtendedMetaData");
|
||||
|
||||
if (m_control->session())
|
||||
return m_control->session()->availableExtendedMetaData();
|
||||
return QStringList();
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIAMETADATAPROVIDER_H
|
||||
#define S60MEDIAMETADATAPROVIDER_H
|
||||
|
||||
#include <qmetadatareadercontrol.h>
|
||||
#include "s60mediaplayercontrol.h"
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60MediaPlayerControl;
|
||||
|
||||
class S60MediaMetaDataProvider : public QMetaDataReaderControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
S60MediaMetaDataProvider(QObject *control, QObject *parent = 0);
|
||||
~S60MediaMetaDataProvider();
|
||||
|
||||
bool isMetaDataAvailable() const;
|
||||
bool isWritable() const;
|
||||
|
||||
QVariant metaData(QtMultimediaKit::MetaData key) const;
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const;
|
||||
QVariant extendedMetaData(const QString &key) const ;
|
||||
QStringList availableExtendedMetaData() const;
|
||||
|
||||
private:
|
||||
S60MediaPlayerControl *m_control;
|
||||
};
|
||||
|
||||
#endif // S60VIDEOMETADATAPROVIDER_H
|
||||
@@ -1,144 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "s60medianetworkaccesscontrol.h"
|
||||
|
||||
#define KBuffersize 512
|
||||
|
||||
S60MediaNetworkAccessControl::S60MediaNetworkAccessControl(QObject *parent)
|
||||
: QMediaNetworkAccessControl(parent)
|
||||
, m_iapId(KUseDefaultIap)
|
||||
, m_currentIndex(0)
|
||||
{
|
||||
}
|
||||
|
||||
void S60MediaNetworkAccessControl::accessPointChanged(int id)
|
||||
{
|
||||
if (!m_IapIdList.isEmpty())
|
||||
m_NetworkObject = m_NetworkObjectList.at(m_IapIdList.indexOf(id));
|
||||
emit configurationChanged(m_NetworkObject);
|
||||
}
|
||||
|
||||
S60MediaNetworkAccessControl::~S60MediaNetworkAccessControl()
|
||||
{
|
||||
m_NetworkObjectList.clear();
|
||||
m_IapIdList.clear();
|
||||
}
|
||||
|
||||
void S60MediaNetworkAccessControl::resetIndex()
|
||||
{
|
||||
m_currentIndex = 0;
|
||||
}
|
||||
|
||||
void S60MediaNetworkAccessControl::setConfigurations(const QList<QNetworkConfiguration> &configurations)
|
||||
{
|
||||
if (!configurations.isEmpty()) {
|
||||
m_currentIndex =0;
|
||||
TRAPD(error, retriveAccesspointIDL(configurations));
|
||||
if (error != KErrNone) {
|
||||
m_NetworkObjectList.clear();
|
||||
m_IapIdList.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TBool S60MediaNetworkAccessControl::isLastAccessPoint()
|
||||
{
|
||||
if (m_currentIndex == m_NetworkObjectList.size())
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int S60MediaNetworkAccessControl::accessPointId()
|
||||
{
|
||||
if (m_IapIdList.isEmpty())
|
||||
return m_iapId;
|
||||
|
||||
m_iapId = m_IapIdList.at(m_currentIndex);
|
||||
|
||||
if (isLastAccessPoint())
|
||||
m_currentIndex = 0;
|
||||
else
|
||||
m_currentIndex ++;
|
||||
|
||||
return m_iapId;
|
||||
}
|
||||
|
||||
QNetworkConfiguration S60MediaNetworkAccessControl::currentConfiguration() const
|
||||
{
|
||||
return m_NetworkObject;
|
||||
}
|
||||
|
||||
void S60MediaNetworkAccessControl::retriveAccesspointIDL(const QList<QNetworkConfiguration> &configurationList)
|
||||
{
|
||||
m_NetworkObjectList.clear();
|
||||
m_IapIdList.clear();
|
||||
TBuf<KBuffersize> iapName;
|
||||
TUint32 iapId;
|
||||
TInt err;
|
||||
|
||||
// open the IAP communications database
|
||||
CCommsDatabase* commDB = CCommsDatabase::NewL();
|
||||
CleanupStack::PushL(commDB);
|
||||
|
||||
// Open the IAP table
|
||||
CCommsDbTableView* view = commDB->OpenTableLC(TPtrC(IAP));
|
||||
|
||||
for (int i=0;i<=configurationList.size()- 1;i++) {
|
||||
QString accesspointname = configurationList.at(i).name();
|
||||
TBuf<KBuffersize> accesspointbuffer(accesspointname.utf16());
|
||||
// Point to the first entry
|
||||
if (view->GotoFirstRecord() == KErrNone) {
|
||||
do {
|
||||
view->ReadTextL(TPtrC(COMMDB_NAME), iapName);
|
||||
view->ReadUintL(TPtrC(COMMDB_ID), iapId);
|
||||
if (accesspointbuffer == iapName) {
|
||||
m_NetworkObjectList<<configurationList.at(i);
|
||||
m_IapIdList<<iapId;
|
||||
}
|
||||
// Store name and ID to where you want to
|
||||
} while (err = view->GotoNextRecord(), err == KErrNone);
|
||||
}
|
||||
}
|
||||
CleanupStack::PopAndDestroy(); // view
|
||||
CleanupStack::PopAndDestroy(); // commDB
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIANETWORKACCESSCONTROL_H_
|
||||
#define S60MEDIANETWORKACCESSCONTROL_H_
|
||||
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <qmetaobject.h>
|
||||
#include <QtNetwork/qnetworkconfiguration.h>
|
||||
#include <commdbconnpref.h>
|
||||
#include <commdb.h>
|
||||
#include <mmf/common/mmfcontrollerframeworkbase.h>
|
||||
#include <qmedianetworkaccesscontrol.h>
|
||||
#include "s60mediaplayercontrol.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaPlayerControl;
|
||||
class QMediaNetworkAccessControl;
|
||||
class QNetworkConfiguration;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class S60MediaNetworkAccessControl : public QMediaNetworkAccessControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
S60MediaNetworkAccessControl(QObject *parent = 0);
|
||||
~S60MediaNetworkAccessControl();
|
||||
|
||||
virtual void setConfigurations(const QList<QNetworkConfiguration> &configurations);
|
||||
virtual QNetworkConfiguration currentConfiguration() const;
|
||||
int accessPointId();
|
||||
TBool isLastAccessPoint();
|
||||
void resetIndex();
|
||||
|
||||
public Q_SLOTS:
|
||||
void accessPointChanged(int);
|
||||
|
||||
private:
|
||||
void retriveAccesspointIDL(const QList<QNetworkConfiguration> &);
|
||||
QList<int> m_IapIdList;
|
||||
QList<QNetworkConfiguration> m_NetworkObjectList;
|
||||
QNetworkConfiguration m_NetworkObject;
|
||||
int m_iapId;
|
||||
int m_currentIndex;
|
||||
};
|
||||
#endif /* S60MEDIANETWORKACCESSCONTROL_H_ */
|
||||
@@ -1,182 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60mediaplayercontrol.h"
|
||||
#include "s60mediaplayersession.h"
|
||||
#include "s60mediaplayeraudioendpointselector.h"
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
/*!
|
||||
Constructs a new audio endpoint selector with the given \a parent.
|
||||
*/
|
||||
|
||||
S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent)
|
||||
:QAudioEndpointSelector(parent)
|
||||
, m_control(0)
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector +++");
|
||||
|
||||
m_control = qobject_cast<S60MediaPlayerControl*>(control);
|
||||
m_audioEndpointNames.append("Default");
|
||||
m_audioEndpointNames.append("All");
|
||||
m_audioEndpointNames.append("None");
|
||||
m_audioEndpointNames.append("Earphone");
|
||||
m_audioEndpointNames.append("Speaker");
|
||||
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::S60MediaPlayerAudioEndpointSelector ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys an audio endpoint selector.
|
||||
*/
|
||||
|
||||
S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector()
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector +++");
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::~S60MediaPlayerAudioEndpointSelector ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
\return a list of available audio endpoints.
|
||||
*/
|
||||
|
||||
QList<QString> S60MediaPlayerAudioEndpointSelector::availableEndpoints() const
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::availableEndpoints");
|
||||
|
||||
return m_audioEndpointNames;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the description of the endpoint name.
|
||||
*/
|
||||
|
||||
QString S60MediaPlayerAudioEndpointSelector::endpointDescription(const QString& name) const
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::endpointDescription");
|
||||
|
||||
if (name == QString("Default")) //ENoPreference
|
||||
return QString("Used to indicate that the playing audio can be routed to"
|
||||
"any speaker. This is the default value for audio.");
|
||||
else if (name == QString("All")) //EAll
|
||||
return QString("Used to indicate that the playing audio should be routed to all speakers.");
|
||||
else if (name == QString("None")) //ENoOutput
|
||||
return QString("Used to indicate that the playing audio should not be routed to any output.");
|
||||
else if (name == QString("Earphone")) //EPrivate
|
||||
return QString("Used to indicate that the playing audio should be routed to"
|
||||
"the default private speaker. A private speaker is one that can only"
|
||||
"be heard by one person.");
|
||||
else if (name == QString("Speaker")) //EPublic
|
||||
return QString("Used to indicate that the playing audio should be routed to"
|
||||
"the default public speaker. A public speaker is one that can "
|
||||
"be heard by multiple people.");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the name of the currently selected audio endpoint.
|
||||
*/
|
||||
|
||||
QString S60MediaPlayerAudioEndpointSelector::activeEndpoint() const
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::activeEndpoint");
|
||||
|
||||
if (m_control->session()) {
|
||||
DP1("S60MediaPlayerAudioEndpointSelector::activeEndpoint - ",
|
||||
m_control->session()->activeEndpoint());
|
||||
return m_control->session()->activeEndpoint();
|
||||
}
|
||||
else {
|
||||
DP1("S60MediaPlayerAudioEndpointSelector::activeEndpoint - ",
|
||||
m_control->mediaControlSettings().audioEndpoint());
|
||||
return m_control->mediaControlSettings().audioEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the name of the default audio endpoint.
|
||||
*/
|
||||
|
||||
QString S60MediaPlayerAudioEndpointSelector::defaultEndpoint() const
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::defaultEndpoint");
|
||||
|
||||
if (m_control->session()) {
|
||||
DP1("S60MediaPlayerAudioEndpointSelector::defaultEndpoint - ",
|
||||
m_control->session()->defaultEndpoint());
|
||||
return m_control->session()->defaultEndpoint();
|
||||
}
|
||||
else {
|
||||
DP1("S60MediaPlayerAudioEndpointSelector::defaultEndpoint - ",
|
||||
m_control->mediaControlSettings().audioEndpoint());
|
||||
return m_control->mediaControlSettings().audioEndpoint();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the audio endpoint to \a name.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerAudioEndpointSelector::setActiveEndpoint(const QString& name)
|
||||
{
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::setActiveEndpoin +++");
|
||||
|
||||
DP1("S60MediaPlayerAudioEndpointSelector::setActiveEndpoint - ", name);
|
||||
|
||||
QString oldEndpoint = m_control->mediaControlSettings().audioEndpoint();
|
||||
|
||||
if (name != oldEndpoint && (name == QString("Default") || name == QString("All") ||
|
||||
name == QString("None") || name == QString("Earphone") || name == QString("Speaker"))) {
|
||||
|
||||
if (m_control->session()) {
|
||||
m_control->session()->setActiveEndpoint(name);
|
||||
emit activeEndpointChanged(name);
|
||||
}
|
||||
m_control->setAudioEndpoint(name);
|
||||
}
|
||||
|
||||
DP0("S60MediaPlayerAudioEndpointSelector::setActiveEndpoin ---");
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H
|
||||
#define S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
#include <qaudioendpointselector.h>
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60MediaPlayerControl;
|
||||
class S60MediaPlayerSession;
|
||||
|
||||
class S60MediaPlayerAudioEndpointSelector : public QAudioEndpointSelector
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
S60MediaPlayerAudioEndpointSelector(QObject *control, QObject *parent = 0);
|
||||
~S60MediaPlayerAudioEndpointSelector();
|
||||
|
||||
QList<QString> availableEndpoints() const ;
|
||||
QString endpointDescription(const QString& name) const;
|
||||
QString defaultEndpoint() const;
|
||||
QString activeEndpoint() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setActiveEndpoint(const QString& name);
|
||||
|
||||
private:
|
||||
S60MediaPlayerControl* m_control;
|
||||
QString m_audioInput;
|
||||
QList<QString> m_audioEndpointNames;
|
||||
};
|
||||
|
||||
#endif // S60MEDIAPLAYERAUDIOENDPOINTSELECTOR_H
|
||||
@@ -1,518 +0,0 @@
|
||||
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60mediaplayercontrol.h"
|
||||
#include "s60mediaplayersession.h"
|
||||
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
/*!
|
||||
Constructs a new media player control with the given \a parent.
|
||||
*/
|
||||
|
||||
S60MediaPlayerControl::S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent)
|
||||
: QMediaPlayerControl(parent),
|
||||
m_mediaPlayerResolver(mediaPlayerResolver),
|
||||
m_session(NULL),
|
||||
m_stream(NULL)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::S60MediaPlayerControl +++");
|
||||
|
||||
DP0("S60MediaPlayerControl::S60MediaPlayerControl ---");
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media player control.
|
||||
*/
|
||||
|
||||
S60MediaPlayerControl::~S60MediaPlayerControl()
|
||||
{
|
||||
DP0("S60MediaPlayerControl::~S60MediaPlayerControl +++");
|
||||
DP0("S60MediaPlayerControl::~S60MediaPlayerControl ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the current playback position in milliseconds.
|
||||
*/
|
||||
|
||||
qint64 S60MediaPlayerControl::position() const
|
||||
{
|
||||
// DP0("S60MediaPlayerControl::position");
|
||||
|
||||
if (m_session)
|
||||
return m_session->position();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the duration of the current media in milliseconds.
|
||||
*/
|
||||
|
||||
qint64 S60MediaPlayerControl::duration() const
|
||||
{
|
||||
// DP0("S60MediaPlayerControl::duration");
|
||||
|
||||
if (m_session)
|
||||
return m_session->duration();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the state of a player control.
|
||||
*/
|
||||
|
||||
QMediaPlayer::State S60MediaPlayerControl::state() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::state");
|
||||
|
||||
if (m_session)
|
||||
return m_session->state();
|
||||
return QMediaPlayer::StoppedState;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the status of the current media.
|
||||
*/
|
||||
|
||||
QMediaPlayer::MediaStatus S60MediaPlayerControl::mediaStatus() const
|
||||
{
|
||||
DP0("QMediaPlayer::mediaStatus");
|
||||
|
||||
if (m_session)
|
||||
return m_session->mediaStatus();
|
||||
return m_mediaSettings.mediaStatus();
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the buffering progress of the current media. Progress is measured in the percentage
|
||||
of the buffer filled.
|
||||
*/
|
||||
|
||||
int S60MediaPlayerControl::bufferStatus() const
|
||||
{
|
||||
// DP0("S60MediaPlayerControl::bufferStatus");
|
||||
|
||||
if (m_session)
|
||||
return m_session->bufferStatus();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the audio volume of a player control.
|
||||
*/
|
||||
|
||||
int S60MediaPlayerControl::volume() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::volume");
|
||||
|
||||
if (m_session)
|
||||
return m_session->volume();
|
||||
return m_mediaSettings.volume();
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the mute state of a player control.
|
||||
*/
|
||||
|
||||
bool S60MediaPlayerControl::isMuted() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::isMuted");
|
||||
|
||||
if (m_session)
|
||||
return m_session->isMuted();
|
||||
return m_mediaSettings.isMuted();
|
||||
}
|
||||
|
||||
/*!
|
||||
Identifies if the current media is seekable.
|
||||
|
||||
\return true if it possible to seek within the current media, and false otherwise.
|
||||
*/
|
||||
|
||||
bool S60MediaPlayerControl::isSeekable() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::isSeekable");
|
||||
|
||||
if (m_session)
|
||||
return m_session->isSeekable();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return a range of times in milliseconds that can be played back.
|
||||
|
||||
Usually for local files this is a continuous interval equal to [0..duration()]
|
||||
or an empty time range if seeking is not supported, but for network sources
|
||||
it refers to the buffered parts of the media.
|
||||
*/
|
||||
|
||||
QMediaTimeRange S60MediaPlayerControl::availablePlaybackRanges() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::availablePlaybackRanges");
|
||||
|
||||
QMediaTimeRange ranges;
|
||||
|
||||
if(m_session && m_session->isSeekable())
|
||||
ranges.addInterval(0, m_session->duration());
|
||||
|
||||
return ranges;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the rate of playback.
|
||||
*/
|
||||
|
||||
qreal S60MediaPlayerControl::playbackRate() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::playbackRate");
|
||||
|
||||
return m_mediaSettings.playbackRate();
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a rate of playback.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setPlaybackRate(qreal rate)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setPlaybackRate +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setPlaybackRate - ", rate);
|
||||
|
||||
//getting the current playbackrate
|
||||
qreal currentPBrate = m_mediaSettings.playbackRate();
|
||||
//checking if we need to change the Playback rate
|
||||
if (!qFuzzyCompare(currentPBrate,rate))
|
||||
{
|
||||
if(m_session)
|
||||
m_session->setPlaybackRate(rate);
|
||||
|
||||
m_mediaSettings.setPlaybackRate(rate);
|
||||
}
|
||||
|
||||
DP0("S60MediaPlayerControl::setPlaybackRate ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the playback \a pos of the current media. This will initiate a seek and it may take
|
||||
some time for playback to reach the position set.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setPosition(qint64 pos)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setPosition +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setPosition, Position:", pos);
|
||||
|
||||
if (m_session)
|
||||
m_session->setPosition(pos);
|
||||
|
||||
DP0("S60MediaPlayerControl::setPosition ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Starts playback of the current media.
|
||||
|
||||
If successful the player control will immediately enter the \l {QMediaPlayer::PlayingState}
|
||||
{playing} state.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::play()
|
||||
{
|
||||
DP0("S60MediaPlayerControl::play +++");
|
||||
|
||||
if (m_session)
|
||||
m_session->play();
|
||||
|
||||
DP0("S60MediaPlayerControl::play ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Pauses playback of the current media.
|
||||
|
||||
If sucessful the player control will immediately enter the \l {QMediaPlayer::PausedState}
|
||||
{paused} state.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::pause()
|
||||
{
|
||||
DP0("S60MediaPlayerControl::pause +++");
|
||||
|
||||
if (m_session)
|
||||
m_session->pause();
|
||||
|
||||
DP0("S60MediaPlayerControl::pause ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Stops playback of the current media.
|
||||
|
||||
If successful the player control will immediately enter the \l {QMediaPlayer::StoppedState}
|
||||
{stopped} state.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::stop()
|
||||
{
|
||||
DP0("S60MediaPlayerControl::stop +++");
|
||||
|
||||
if (m_session)
|
||||
m_session->stop();
|
||||
|
||||
DP0("S60MediaPlayerControl::stop ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the audio \a volume of a player control.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setVolume(int volume)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setVolume +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setVolume", volume);
|
||||
|
||||
int boundVolume = qBound(0, volume, 100);
|
||||
if (boundVolume == m_mediaSettings.volume())
|
||||
return;
|
||||
|
||||
m_mediaSettings.setVolume(boundVolume);
|
||||
|
||||
if (m_session)
|
||||
m_session->setVolume(boundVolume);
|
||||
|
||||
DP0("S60MediaPlayerControl::setVolume ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the \a muted state of a player control.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setMuted(bool muted)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setMuted +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setMuted - ", muted);
|
||||
|
||||
if (m_mediaSettings.isMuted() == muted)
|
||||
return;
|
||||
|
||||
m_mediaSettings.setMuted(muted);
|
||||
|
||||
if (m_session)
|
||||
m_session->setMuted(muted);
|
||||
|
||||
DP0("S60MediaPlayerControl::setMuted ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return the current media source.
|
||||
*/
|
||||
|
||||
QMediaContent S60MediaPlayerControl::media() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::media");
|
||||
|
||||
return m_currentResource;
|
||||
}
|
||||
|
||||
/*!
|
||||
\return the current media stream. This is only a valid if a stream was passed to setMedia().
|
||||
|
||||
\sa setMedia()
|
||||
*/
|
||||
|
||||
const QIODevice *S60MediaPlayerControl::mediaStream() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::mediaStream");
|
||||
|
||||
return m_stream;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the current \a source media source. If a \a stream is supplied; data will be read from that
|
||||
instead of attempting to resolve the media source. The media source may still be used to
|
||||
supply media information such as mime type.
|
||||
|
||||
Setting the media to a null QMediaContent will cause the control to discard all
|
||||
information relating to the current media source and to cease all I/O operations related
|
||||
to that media.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setMedia(const QMediaContent &source, QIODevice *stream)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setMedia +++");
|
||||
|
||||
Q_UNUSED(stream)
|
||||
|
||||
if ((m_session && m_currentResource == source) && m_session->isStreaming())
|
||||
{
|
||||
m_session->load(source);
|
||||
return;
|
||||
}
|
||||
|
||||
// we don't want to set & load media again when it is already loaded
|
||||
if (m_session && m_currentResource == source)
|
||||
return;
|
||||
|
||||
// store to variable as session is created based on the content type.
|
||||
m_currentResource = source;
|
||||
S60MediaPlayerSession *newSession = m_mediaPlayerResolver.PlayerSession();
|
||||
m_mediaSettings.setMediaStatus(QMediaPlayer::UnknownMediaStatus);
|
||||
|
||||
if (m_session)
|
||||
m_session->reset();
|
||||
else {
|
||||
emit mediaStatusChanged(QMediaPlayer::UnknownMediaStatus);
|
||||
emit error(QMediaPlayer::NoError, QString());
|
||||
}
|
||||
|
||||
m_session = newSession;
|
||||
|
||||
if (m_session)
|
||||
m_session->load(source);
|
||||
else {
|
||||
QMediaPlayer::MediaStatus status = (source.isNull()) ? QMediaPlayer::NoMedia : QMediaPlayer::InvalidMedia;
|
||||
m_mediaSettings.setMediaStatus(status);
|
||||
emit stateChanged(QMediaPlayer::StoppedState);
|
||||
emit error((source.isNull()) ? QMediaPlayer::NoError : QMediaPlayer::ResourceError,
|
||||
(source.isNull()) ? "" : tr("Media couldn't be resolved"));
|
||||
emit mediaStatusChanged(status);
|
||||
}
|
||||
emit mediaChanged(m_currentResource);
|
||||
|
||||
DP0("S60MediaPlayerControl::setMedia ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media player session.
|
||||
*/
|
||||
S60MediaPlayerSession* S60MediaPlayerControl::session()
|
||||
{
|
||||
DP0("S60MediaPlayerControl::session");
|
||||
|
||||
return m_session;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Sets \a output as a VideoOutput.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setVideoOutput(QObject *output)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setVideoOutput +++");
|
||||
|
||||
m_mediaPlayerResolver.VideoPlayerSession()->setVideoRenderer(output);
|
||||
|
||||
DP0("S60MediaPlayerControl::setVideoOutput ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return TRUE if Audio available or else FALSE.
|
||||
*/
|
||||
|
||||
bool S60MediaPlayerControl::isAudioAvailable() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::isAudioAvailable");
|
||||
|
||||
if (m_session)
|
||||
return m_session->isAudioAvailable();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return TRUE if Video available or else FALSE.
|
||||
*/
|
||||
|
||||
bool S60MediaPlayerControl::isVideoAvailable() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::isVideoAvailable");
|
||||
|
||||
if (m_session)
|
||||
return m_session->isVideoAvailable();
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media settings.
|
||||
*
|
||||
* Media Settings include volume, muted, playbackRate, mediaStatus, audioEndpoint.
|
||||
*/
|
||||
const S60MediaSettings& S60MediaPlayerControl::mediaControlSettings() const
|
||||
{
|
||||
DP0("S60MediaPlayerControl::mediaControlSettings");
|
||||
return m_mediaSettings;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Set the audio endpoint to \a name.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setAudioEndpoint(const QString& name)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setAudioEndpoint +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setAudioEndpoint - ", name);
|
||||
|
||||
m_mediaSettings.setAudioEndpoint(name);
|
||||
|
||||
DP0("S60MediaPlayerControl::setAudioEndpoint ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* Sets media type \a type as Unknown, Video, Audio, Data.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerControl::setMediaType(S60MediaSettings::TMediaType type)
|
||||
{
|
||||
DP0("S60MediaPlayerControl::setMediaType +++");
|
||||
|
||||
DP1("S60MediaPlayerControl::setMediaType - ", type);
|
||||
|
||||
m_mediaSettings.setMediaType(type);
|
||||
|
||||
DP0("S60MediaPlayerControl::setMediaType ---");
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIAPLAYERCONTROL_H
|
||||
#define S60MEDIAPLAYERCONTROL_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#include <qmediaplayercontrol.h>
|
||||
|
||||
#include "ms60mediaplayerresolver.h"
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaPlayer;
|
||||
class QMediaTimeRange;
|
||||
class QMediaContent;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60MediaPlayerSession;
|
||||
class S60MediaPlayerService;
|
||||
|
||||
class S60MediaSettings
|
||||
{
|
||||
|
||||
public:
|
||||
S60MediaSettings()
|
||||
: m_volume(30)
|
||||
, m_muted(false)
|
||||
, m_playbackRate(0)
|
||||
, m_mediaStatus(QMediaPlayer::NoMedia)
|
||||
, m_audioEndpoint(QString("Default"))
|
||||
{
|
||||
}
|
||||
|
||||
enum TMediaType {Unknown, Video, Audio, Data};
|
||||
|
||||
void setVolume(int volume) { m_volume = volume; }
|
||||
void setMuted(bool muted) { m_muted = muted; }
|
||||
void setPlaybackRate(qreal rate) { m_playbackRate = rate; }
|
||||
void setMediaStatus(QMediaPlayer::MediaStatus status) {m_mediaStatus=status;}
|
||||
void setAudioEndpoint(const QString& audioEndpoint) { m_audioEndpoint = audioEndpoint; }
|
||||
void setMediaType(S60MediaSettings::TMediaType type) { m_mediaType = type; }
|
||||
|
||||
int volume() const { return m_volume; }
|
||||
bool isMuted() const { return m_muted; }
|
||||
qreal playbackRate() const { return m_playbackRate; }
|
||||
QMediaPlayer::MediaStatus mediaStatus() const {return m_mediaStatus;}
|
||||
QString audioEndpoint() const { return m_audioEndpoint; }
|
||||
S60MediaSettings::TMediaType mediaType() const { return m_mediaType; }
|
||||
|
||||
private:
|
||||
int m_volume;
|
||||
bool m_muted;
|
||||
qreal m_playbackRate;
|
||||
QMediaPlayer::MediaStatus m_mediaStatus;
|
||||
QString m_audioEndpoint;
|
||||
S60MediaSettings::TMediaType m_mediaType;
|
||||
};
|
||||
|
||||
class S60MediaPlayerControl : public QMediaPlayerControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
S60MediaPlayerControl(MS60MediaPlayerResolver& mediaPlayerResolver, QObject *parent = 0);
|
||||
~S60MediaPlayerControl();
|
||||
|
||||
// from QMediaPlayerControl
|
||||
virtual QMediaPlayer::State state() const;
|
||||
virtual QMediaPlayer::MediaStatus mediaStatus() const;
|
||||
virtual qint64 duration() const;
|
||||
virtual qint64 position() const;
|
||||
virtual void setPosition(qint64 pos);
|
||||
virtual int volume() const;
|
||||
virtual void setVolume(int volume);
|
||||
virtual bool isMuted() const;
|
||||
virtual void setMuted(bool muted);
|
||||
virtual int bufferStatus() const;
|
||||
virtual bool isAudioAvailable() const;
|
||||
virtual bool isVideoAvailable() const;
|
||||
virtual bool isSeekable() const;
|
||||
virtual QMediaTimeRange availablePlaybackRanges() const;
|
||||
virtual qreal playbackRate() const;
|
||||
virtual void setPlaybackRate(qreal rate);
|
||||
virtual QMediaContent media() const;
|
||||
virtual const QIODevice *mediaStream() const;
|
||||
virtual void setMedia(const QMediaContent&, QIODevice *);
|
||||
virtual void play();
|
||||
virtual void pause();
|
||||
virtual void stop();
|
||||
|
||||
// Own methods
|
||||
S60MediaPlayerSession* session();
|
||||
void setVideoOutput(QObject *output);
|
||||
const S60MediaSettings& mediaControlSettings() const;
|
||||
void setAudioEndpoint(const QString& name);
|
||||
void setMediaType(S60MediaSettings::TMediaType type);
|
||||
|
||||
private:
|
||||
MS60MediaPlayerResolver &m_mediaPlayerResolver;
|
||||
S60MediaPlayerSession *m_session;
|
||||
QMediaContent m_currentResource;
|
||||
QIODevice *m_stream;
|
||||
S60MediaSettings m_mediaSettings;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,326 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtGui/qwidget.h>
|
||||
|
||||
#include "s60mediaplayerservice.h"
|
||||
#include "s60mediaplayercontrol.h"
|
||||
#include "s60videoplayersession.h"
|
||||
#include "s60audioplayersession.h"
|
||||
#include "s60mediametadataprovider.h"
|
||||
#include "s60mediarecognizer.h"
|
||||
#include "s60videowidgetcontrol.h"
|
||||
#include "s60videowindowcontrol.h"
|
||||
#ifdef HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER
|
||||
#include "s60videorenderer.h"
|
||||
#endif
|
||||
#include "s60mediaplayeraudioendpointselector.h"
|
||||
#include "s60medianetworkaccesscontrol.h"
|
||||
#include "s60mediastreamcontrol.h"
|
||||
|
||||
#include <qmediaplaylistnavigator.h>
|
||||
#include <qmediaplaylist.h>
|
||||
|
||||
/*!
|
||||
Construct a media service with the given \a parent.
|
||||
*/
|
||||
|
||||
S60MediaPlayerService::S60MediaPlayerService(QObject *parent)
|
||||
: QMediaService(parent)
|
||||
, m_control(NULL)
|
||||
, m_videoPlayerSession(NULL)
|
||||
, m_audioPlayerSession(NULL)
|
||||
, m_metaData(NULL)
|
||||
, m_audioEndpointSelector(NULL)
|
||||
, m_streamControl(NULL)
|
||||
, m_networkAccessControl(NULL)
|
||||
, m_videoOutput(NULL)
|
||||
{
|
||||
DP0("S60MediaPlayerService::S60MediaPlayerService +++");
|
||||
|
||||
m_control = new S60MediaPlayerControl(*this, this);
|
||||
m_metaData = new S60MediaMetaDataProvider(m_control, this);
|
||||
m_audioEndpointSelector = new S60MediaPlayerAudioEndpointSelector(m_control, this);
|
||||
m_streamControl = new S60MediaStreamControl(m_control, this);
|
||||
m_networkAccessControl = new S60MediaNetworkAccessControl(this);
|
||||
|
||||
DP0("S60MediaPlayerService::S60MediaPlayerService ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media service.
|
||||
*/
|
||||
|
||||
S60MediaPlayerService::~S60MediaPlayerService()
|
||||
{
|
||||
DP0("S60MediaPlayerService::~S60MediaPlayerService +++");
|
||||
DP0("S60MediaPlayerService::~S60MediaPlayerService ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
\return a pointer to the media control, which matches the controller \a name.
|
||||
|
||||
If the service does not implement the control, or if it is unavailable a
|
||||
null pointer is returned instead.
|
||||
|
||||
Controls must be returned to the service when no longer needed using the
|
||||
releaseControl() function.
|
||||
*/
|
||||
|
||||
QMediaControl *S60MediaPlayerService::requestControl(const char *name)
|
||||
{
|
||||
DP0("S60MediaPlayerService::requestControl");
|
||||
|
||||
if (qstrcmp(name, QMediaPlayerControl_iid) == 0)
|
||||
return m_control;
|
||||
|
||||
if (qstrcmp(name, QMediaNetworkAccessControl_iid) == 0)
|
||||
return m_networkAccessControl;
|
||||
|
||||
if (qstrcmp(name, QMetaDataReaderControl_iid) == 0)
|
||||
return m_metaData;
|
||||
|
||||
if (qstrcmp(name, QAudioEndpointSelector_iid) == 0)
|
||||
return m_audioEndpointSelector;
|
||||
|
||||
if (qstrcmp(name, QMediaStreamsControl_iid) == 0)
|
||||
return m_streamControl;
|
||||
|
||||
if (!m_videoOutput) {
|
||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0) {
|
||||
m_videoOutput = new S60VideoWidgetControl(this);
|
||||
}
|
||||
#ifdef HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER
|
||||
else if (qstrcmp(name, QVideoRendererControl_iid) == 0) {
|
||||
m_videoOutput = new S60VideoRenderer(this);
|
||||
}
|
||||
#endif /* HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER */
|
||||
else if (qstrcmp(name, QVideoWindowControl_iid) == 0) {
|
||||
m_videoOutput = new S60VideoWindowControl(this);
|
||||
}
|
||||
|
||||
if (m_videoOutput) {
|
||||
m_control->setVideoOutput(m_videoOutput);
|
||||
return m_videoOutput;
|
||||
}
|
||||
}else {
|
||||
if (qstrcmp(name, QVideoWidgetControl_iid) == 0 ||
|
||||
#ifdef HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER
|
||||
qstrcmp(name, QVideoRendererControl_iid) == 0 ||
|
||||
#endif /* HAS_VIDEORENDERERCONTROL_IN_VIDEOPLAYER */
|
||||
qstrcmp(name, QVideoWindowControl_iid) == 0){
|
||||
return m_videoOutput;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Releases a \a control back to the service.
|
||||
*/
|
||||
|
||||
void S60MediaPlayerService::releaseControl(QMediaControl *control)
|
||||
{
|
||||
DP0("S60MediaPlayerService::releaseControl ++");
|
||||
|
||||
if (control == m_videoOutput) {
|
||||
m_videoOutput = 0;
|
||||
m_control->setVideoOutput(m_videoOutput);
|
||||
}
|
||||
|
||||
DP0("S60MediaPlayerService::releaseControl --");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media player session(audio playersesion/video playersession)
|
||||
* by recognizing whether media is audio or video and sets it on media type.
|
||||
*/
|
||||
S60MediaPlayerSession* S60MediaPlayerService::PlayerSession()
|
||||
{
|
||||
DP0("S60MediaPlayerService::PlayerSession");
|
||||
|
||||
QUrl url = m_control->media().canonicalUrl();
|
||||
|
||||
if (url.isEmpty() == true) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
QScopedPointer<S60MediaRecognizer> mediaRecognizer(new S60MediaRecognizer);
|
||||
S60MediaRecognizer::MediaType mediaType = mediaRecognizer->mediaType(url);
|
||||
mediaRecognizer.reset();
|
||||
|
||||
switch (mediaType) {
|
||||
case S60MediaRecognizer::Video:
|
||||
case S60MediaRecognizer::Url: {
|
||||
m_control->setMediaType(S60MediaSettings::Video);
|
||||
return VideoPlayerSession();
|
||||
}
|
||||
case S60MediaRecognizer::Audio: {
|
||||
m_control->setMediaType(S60MediaSettings::Audio);
|
||||
return AudioPlayerSession();
|
||||
}
|
||||
default:
|
||||
m_control->setMediaType(S60MediaSettings::Unknown);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media playersession (videoplayersession).
|
||||
* constructs the videoplayersession object and connects all the respective signals and slots.
|
||||
* and initialises all the media settings.
|
||||
*/
|
||||
|
||||
S60MediaPlayerSession* S60MediaPlayerService::VideoPlayerSession()
|
||||
{
|
||||
DP0("S60MediaPlayerService::VideoPlayerSession +++");
|
||||
|
||||
if (!m_videoPlayerSession) {
|
||||
m_videoPlayerSession = new S60VideoPlayerSession(this, m_networkAccessControl);
|
||||
|
||||
connect(m_videoPlayerSession, SIGNAL(positionChanged(qint64)),
|
||||
m_control, SIGNAL(positionChanged(qint64)));
|
||||
connect(m_videoPlayerSession, SIGNAL(playbackRateChanged(qreal)),
|
||||
m_control, SIGNAL(playbackRateChanged(qreal)));
|
||||
connect(m_videoPlayerSession, SIGNAL(volumeChanged(int)),
|
||||
m_control, SIGNAL(volumeChanged(int)));
|
||||
connect(m_videoPlayerSession, SIGNAL(mutedChanged(bool)),
|
||||
m_control, SIGNAL(mutedChanged(bool)));
|
||||
connect(m_videoPlayerSession, SIGNAL(durationChanged(qint64)),
|
||||
m_control, SIGNAL(durationChanged(qint64)));
|
||||
connect(m_videoPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)),
|
||||
m_control, SIGNAL(stateChanged(QMediaPlayer::State)));
|
||||
connect(m_videoPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
|
||||
m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
|
||||
connect(m_videoPlayerSession,SIGNAL(bufferStatusChanged(int)),
|
||||
m_control, SIGNAL(bufferStatusChanged(int)));
|
||||
connect(m_videoPlayerSession, SIGNAL(videoAvailableChanged(bool)),
|
||||
m_control, SIGNAL(videoAvailableChanged(bool)));
|
||||
connect(m_videoPlayerSession, SIGNAL(audioAvailableChanged(bool)),
|
||||
m_control, SIGNAL(audioAvailableChanged(bool)));
|
||||
connect(m_videoPlayerSession, SIGNAL(seekableChanged(bool)),
|
||||
m_control, SIGNAL(seekableChanged(bool)));
|
||||
connect(m_videoPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)),
|
||||
m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)));
|
||||
connect(m_videoPlayerSession, SIGNAL(error(int, const QString &)),
|
||||
m_control, SIGNAL(error(int, const QString &)));
|
||||
connect(m_videoPlayerSession, SIGNAL(metaDataChanged()),
|
||||
m_metaData, SIGNAL(metaDataChanged()));
|
||||
connect(m_videoPlayerSession, SIGNAL(activeEndpointChanged(const QString&)),
|
||||
m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)));
|
||||
connect(m_videoPlayerSession, SIGNAL(mediaChanged()),
|
||||
m_streamControl, SLOT(handleStreamsChanged()));
|
||||
connect(m_videoPlayerSession, SIGNAL(accessPointChanged(int)),
|
||||
m_networkAccessControl, SLOT(accessPointChanged(int)));
|
||||
|
||||
}
|
||||
|
||||
m_videoPlayerSession->setVolume(m_control->mediaControlSettings().volume());
|
||||
m_videoPlayerSession->setMuted(m_control->mediaControlSettings().isMuted());
|
||||
m_videoPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint());
|
||||
|
||||
DP0("S60MediaPlayerService::VideoPlayerSession ---");
|
||||
|
||||
return m_videoPlayerSession;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media playersession (audioplayersession).
|
||||
* constructs the audioplayersession object and connects all the respective signals and slots.
|
||||
* and initialises all the media settings.
|
||||
*/
|
||||
|
||||
S60MediaPlayerSession* S60MediaPlayerService::AudioPlayerSession()
|
||||
{
|
||||
DP0("S60MediaPlayerService::AudioPlayerSession +++");
|
||||
|
||||
if (!m_audioPlayerSession) {
|
||||
m_audioPlayerSession = new S60AudioPlayerSession(this);
|
||||
|
||||
connect(m_audioPlayerSession, SIGNAL(positionChanged(qint64)),
|
||||
m_control, SIGNAL(positionChanged(qint64)));
|
||||
connect(m_audioPlayerSession, SIGNAL(playbackRateChanged(qreal)),
|
||||
m_control, SIGNAL(playbackRateChanged(qreal)));
|
||||
connect(m_audioPlayerSession, SIGNAL(volumeChanged(int)),
|
||||
m_control, SIGNAL(volumeChanged(int)));
|
||||
connect(m_audioPlayerSession, SIGNAL(mutedChanged(bool)),
|
||||
m_control, SIGNAL(mutedChanged(bool)));
|
||||
connect(m_audioPlayerSession, SIGNAL(durationChanged(qint64)),
|
||||
m_control, SIGNAL(durationChanged(qint64)));
|
||||
connect(m_audioPlayerSession, SIGNAL(stateChanged(QMediaPlayer::State)),
|
||||
m_control, SIGNAL(stateChanged(QMediaPlayer::State)));
|
||||
connect(m_audioPlayerSession, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
|
||||
m_control, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)));
|
||||
connect(m_audioPlayerSession,SIGNAL(bufferStatusChanged(int)),
|
||||
m_control, SIGNAL(bufferStatusChanged(int)));
|
||||
connect(m_audioPlayerSession, SIGNAL(videoAvailableChanged(bool)),
|
||||
m_control, SIGNAL(videoAvailableChanged(bool)));
|
||||
connect(m_audioPlayerSession, SIGNAL(audioAvailableChanged(bool)),
|
||||
m_control, SIGNAL(audioAvailableChanged(bool)));
|
||||
connect(m_audioPlayerSession, SIGNAL(seekableChanged(bool)),
|
||||
m_control, SIGNAL(seekableChanged(bool)));
|
||||
connect(m_audioPlayerSession, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)),
|
||||
m_control, SIGNAL(availablePlaybackRangesChanged(const QMediaTimeRange&)));
|
||||
connect(m_audioPlayerSession, SIGNAL(error(int, const QString &)),
|
||||
m_control, SIGNAL(error(int, const QString &)));
|
||||
connect(m_audioPlayerSession, SIGNAL(metaDataChanged()),
|
||||
m_metaData, SIGNAL(metaDataChanged()));
|
||||
connect(m_audioPlayerSession, SIGNAL(activeEndpointChanged(const QString&)),
|
||||
m_audioEndpointSelector, SIGNAL(activeEndpointChanged(const QString&)));
|
||||
connect(m_audioPlayerSession, SIGNAL(mediaChanged()),
|
||||
m_streamControl, SLOT(handleStreamsChanged()));
|
||||
|
||||
}
|
||||
|
||||
m_audioPlayerSession->setVolume(m_control->mediaControlSettings().volume());
|
||||
m_audioPlayerSession->setMuted(m_control->mediaControlSettings().isMuted());
|
||||
m_audioPlayerSession->setAudioEndpoint(m_control->mediaControlSettings().audioEndpoint());
|
||||
|
||||
DP0("S60MediaPlayerService::AudioPlayerSession ---");
|
||||
|
||||
return m_audioPlayerSession;
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60VIDEOPLAYERSERVICE_H
|
||||
#define S60VIDEOPLAYERSERVICE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <qmediaservice.h>
|
||||
|
||||
#include "ms60mediaplayerresolver.h"
|
||||
#include "s60mediaplayeraudioendpointselector.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaMetaData;
|
||||
class QMediaPlayerControl;
|
||||
class QMediaPlaylist;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
class S60VideoPlayerSession;
|
||||
class S60AudioPlayerSession;
|
||||
class S60MediaPlayerControl;
|
||||
class S60MediaMetaDataProvider;
|
||||
class S60MediaStreamControl;
|
||||
class S60MediaRecognizer;
|
||||
|
||||
class QMediaPlaylistNavigator;
|
||||
class S60MediaNetworkAccessControl;
|
||||
|
||||
class S60MediaPlayerService : public QMediaService, public MS60MediaPlayerResolver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
S60MediaPlayerService(QObject *parent = 0);
|
||||
~S60MediaPlayerService();
|
||||
|
||||
QMediaControl *requestControl(const char *name);
|
||||
void releaseControl(QMediaControl *control);
|
||||
|
||||
protected: // From MS60MediaPlayerResolver
|
||||
S60MediaPlayerSession* PlayerSession();
|
||||
S60MediaPlayerSession* VideoPlayerSession();
|
||||
S60MediaPlayerSession* AudioPlayerSession();
|
||||
|
||||
private:
|
||||
S60MediaPlayerControl *m_control;
|
||||
S60VideoPlayerSession *m_videoPlayerSession;
|
||||
S60AudioPlayerSession *m_audioPlayerSession;
|
||||
S60MediaMetaDataProvider *m_metaData;
|
||||
S60MediaPlayerAudioEndpointSelector *m_audioEndpointSelector;
|
||||
S60MediaStreamControl *m_streamControl;
|
||||
S60MediaNetworkAccessControl *m_networkAccessControl;
|
||||
QMediaControl *m_videoOutput;
|
||||
};
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,187 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIAPLAYERSESSION_H
|
||||
#define S60MEDIAPLAYERSESSION_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qpair.h>
|
||||
#include <qmediaplayer.h>
|
||||
#include <e32cmn.h> // for TDesC
|
||||
#include <QRect>
|
||||
#include "s60mediaplayerservice.h"
|
||||
|
||||
|
||||
_LIT( KSeekable, "Seekable" );
|
||||
_LIT( KFalse, "0");
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMediaTimeRange;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
class QTimer;
|
||||
|
||||
class S60MediaPlayerSession : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
S60MediaPlayerSession(QObject *parent);
|
||||
virtual ~S60MediaPlayerSession();
|
||||
|
||||
// for player control interface to use
|
||||
QMediaPlayer::State state() const;
|
||||
QMediaPlayer::MediaStatus mediaStatus() const;
|
||||
qint64 duration() const;
|
||||
qint64 position() const;
|
||||
void setPosition(qint64 pos);
|
||||
int volume() const;
|
||||
void setVolume(int volume);
|
||||
bool isMuted() const;
|
||||
void setMuted(bool muted);
|
||||
virtual bool isVideoAvailable() = 0;
|
||||
virtual bool isAudioAvailable() = 0;
|
||||
bool isSeekable() const;
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
void reset();
|
||||
bool isMetadataAvailable() const;
|
||||
QVariant metaData(const QString &key) const;
|
||||
QVariant metaData(QtMultimediaKit::MetaData key) const;
|
||||
QList<QtMultimediaKit::MetaData> availableMetaData() const;
|
||||
QStringList availableExtendedMetaData() const;
|
||||
QString metaDataKeyAsString(QtMultimediaKit::MetaData key) const;
|
||||
void load(const QMediaContent source);
|
||||
int bufferStatus();
|
||||
virtual void setVideoRenderer(QObject *renderer);
|
||||
void setMediaStatus(QMediaPlayer::MediaStatus);
|
||||
void setState(QMediaPlayer::State state);
|
||||
void setAudioEndpoint(const QString& audioEndpoint);
|
||||
virtual void setPlaybackRate(qreal rate) = 0;
|
||||
virtual bool getIsSeekable() const { return ETrue; }
|
||||
TBool isStreaming();
|
||||
|
||||
protected:
|
||||
virtual void doLoadL(const TDesC &path) = 0;
|
||||
virtual void doLoadUrlL(const TDesC &path) = 0;
|
||||
virtual void doPlay() = 0;
|
||||
virtual void doStop() = 0;
|
||||
virtual void doClose() = 0;
|
||||
virtual void doPauseL() = 0;
|
||||
virtual void doSetVolumeL(int volume) = 0;
|
||||
virtual void doSetPositionL(qint64 microSeconds) = 0;
|
||||
virtual qint64 doGetPositionL() const = 0;
|
||||
virtual void updateMetaDataEntriesL() = 0;
|
||||
virtual int doGetBufferStatusL() const = 0;
|
||||
virtual qint64 doGetDurationL() const = 0;
|
||||
virtual void doSetAudioEndpoint(const QString& audioEndpoint) = 0;
|
||||
|
||||
public:
|
||||
// From S60MediaPlayerAudioEndpointSelector
|
||||
virtual QString activeEndpoint() const = 0;
|
||||
virtual QString defaultEndpoint() const = 0;
|
||||
public Q_SLOTS:
|
||||
virtual void setActiveEndpoint(const QString& name) = 0;
|
||||
|
||||
protected:
|
||||
int error() const;
|
||||
void setError(int error, const QString &errorString = QString(), bool forceReset = false);
|
||||
void setAndEmitError(int error);
|
||||
void loaded();
|
||||
void buffering();
|
||||
void buffered();
|
||||
void endOfMedia();
|
||||
QMap<QString, QVariant>& metaDataEntries();
|
||||
QMediaPlayer::Error fromSymbianErrorToMultimediaError(int error);
|
||||
void startProgressTimer();
|
||||
void stopProgressTimer();
|
||||
void startStalledTimer();
|
||||
void stopStalledTimer();
|
||||
QString TDesC2QString(const TDesC& aDescriptor);
|
||||
TPtrC QString2TPtrC( const QString& string );
|
||||
QRect TRect2QRect(const TRect& tr);
|
||||
TRect QRect2TRect(const QRect& qr);
|
||||
|
||||
protected slots:
|
||||
void tick();
|
||||
void stalled();
|
||||
|
||||
signals:
|
||||
void durationChanged(qint64 duration);
|
||||
void positionChanged(qint64 position);
|
||||
void stateChanged(QMediaPlayer::State state);
|
||||
void mediaStatusChanged(QMediaPlayer::MediaStatus mediaStatus);
|
||||
void videoAvailableChanged(bool videoAvailable);
|
||||
void audioAvailableChanged(bool audioAvailable);
|
||||
void bufferStatusChanged(int percentFilled);
|
||||
void seekableChanged(bool);
|
||||
void availablePlaybackRangesChanged(const QMediaTimeRange&);
|
||||
void metaDataChanged();
|
||||
void error(int error, const QString &errorString);
|
||||
void activeEndpointChanged(const QString &name);
|
||||
void mediaChanged();
|
||||
void playbackRateChanged(qreal rate);
|
||||
void volumeChanged(int volume);
|
||||
void mutedChanged(bool muted);
|
||||
|
||||
protected:
|
||||
QUrl m_UrlPath;
|
||||
bool m_stream;
|
||||
QMediaContent m_source;
|
||||
|
||||
private:
|
||||
qreal m_playbackRate;
|
||||
QMap<QString, QVariant> m_metaDataMap;
|
||||
bool m_muted;
|
||||
int m_volume;
|
||||
QMediaPlayer::State m_state;
|
||||
QMediaPlayer::MediaStatus m_mediaStatus;
|
||||
QTimer *m_progressTimer;
|
||||
QTimer *m_stalledTimer;
|
||||
int m_error;
|
||||
bool m_play_requested;
|
||||
bool m_seekable;
|
||||
qint64 m_duration;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,167 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "DebugMacros.h"
|
||||
|
||||
#include "s60mediarecognizer.h"
|
||||
#include <e32def.h>
|
||||
#include <e32cmn.h>
|
||||
#include <QtCore/qurl.h>
|
||||
#include <QtCore/qdir.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include <apgcli.h>
|
||||
|
||||
static const TInt KMimeTypePrefixLength = 6; // "audio/" or "video/"
|
||||
|
||||
_LIT(KMimeTypePrefixAudio, "audio/");
|
||||
_LIT(KMimeTypePrefixVideo, "video/");
|
||||
_LIT(KMimeTypeRingingTone, "application/vnd.nokia.ringing-tone");
|
||||
|
||||
/*!
|
||||
Construct a media Recognizer with the given \a parent.
|
||||
*/
|
||||
|
||||
S60MediaRecognizer::S60MediaRecognizer(QObject *parent) : QObject(parent)
|
||||
{
|
||||
DP0("S60MediaRecognizer::S60MediaRecognizer +++");
|
||||
DP0("S60MediaRecognizer::S60MediaRecognizer ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys a media Recognizer.
|
||||
*/
|
||||
|
||||
S60MediaRecognizer::~S60MediaRecognizer()
|
||||
{
|
||||
DP0("S60MediaRecognizer::~S60MediaRecognizer +++");
|
||||
|
||||
m_file.Close();
|
||||
m_fileServer.Close();
|
||||
m_recognizer.Close();
|
||||
|
||||
DP0("S60MediaRecognizer::~S60MediaRecognizer ---");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return media type of \a url.
|
||||
* \a url may be a streaming link or a local file.
|
||||
* If \a url is local file then identifies the media type and returns it.
|
||||
*/
|
||||
|
||||
S60MediaRecognizer::MediaType S60MediaRecognizer::mediaType(const QUrl &url)
|
||||
{
|
||||
DP0("S60MediaRecognizer::mediaType");
|
||||
|
||||
bool isStream = (url.scheme() == "file")?false:true;
|
||||
|
||||
if (isStream)
|
||||
return Url;
|
||||
else
|
||||
return identifyMediaType(QDir::cleanPath(url.toLocalFile()));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return Media type of \a file name by recognizing its mimetype whether its audio or video.
|
||||
*/
|
||||
|
||||
S60MediaRecognizer::MediaType S60MediaRecognizer::identifyMediaType(const QString& fileName)
|
||||
{
|
||||
DP0("S60MediaRecognizer::identifyMediaType +++");
|
||||
|
||||
DP1("S60MediaRecognizer::identifyMediaType - ", fileName);
|
||||
|
||||
S60MediaRecognizer::MediaType result = Video; // default to videoplayer
|
||||
bool recognizerOpened = false;
|
||||
|
||||
TInt err = m_recognizer.Connect();
|
||||
if (err == KErrNone) {
|
||||
recognizerOpened = true;
|
||||
}
|
||||
|
||||
err = m_fileServer.Connect();
|
||||
if (err == KErrNone) {
|
||||
recognizerOpened = true;
|
||||
}
|
||||
|
||||
// This is needed for sharing file handles for the recognizer
|
||||
err = m_fileServer.ShareProtected();
|
||||
if (err == KErrNone) {
|
||||
recognizerOpened = true;
|
||||
}
|
||||
|
||||
if (recognizerOpened) {
|
||||
m_file.Close();
|
||||
err = m_file.Open(m_fileServer, QString2TPtrC(QDir::toNativeSeparators(fileName)), EFileRead |
|
||||
EFileShareReadersOnly);
|
||||
|
||||
if (err == KErrNone) {
|
||||
TDataRecognitionResult recognizerResult;
|
||||
err = m_recognizer.RecognizeData(m_file, recognizerResult);
|
||||
if (err == KErrNone) {
|
||||
const TPtrC mimeType = recognizerResult.iDataType.Des();
|
||||
|
||||
if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixAudio) == 0 ||
|
||||
mimeType.Compare(KMimeTypeRingingTone) == 0) {
|
||||
result = Audio;
|
||||
} else if (mimeType.Left(KMimeTypePrefixLength).Compare(KMimeTypePrefixVideo) == 0) {
|
||||
result = Video;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DP0("S60MediaRecognizer::identifyMediaType ---");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \return Symbian modifiable pointer descriptor from a QString \a string.
|
||||
*/
|
||||
|
||||
TPtrC S60MediaRecognizer::QString2TPtrC( const QString& string )
|
||||
{
|
||||
DP1("S60MediaRecognizer::QString2TPtrC - ", string);
|
||||
|
||||
// Returned TPtrC is valid as long as the given parameter is valid and unmodified
|
||||
return TPtrC16(static_cast<const TUint16*>(string.utf16()), string.length());
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the Qt Mobility Components.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU Lesser
|
||||
** General Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License version 3.0 as published by the Free Software Foundation
|
||||
** and appearing in the file LICENSE.GPL included in the packaging of this
|
||||
** file. Please review the following information to ensure the GNU General
|
||||
** Public License version 3.0 requirements will be met:
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef S60MEDIARECOGNIZER_H_
|
||||
#define S60MEDIARECOGNIZER_H_
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
|
||||
#include <apgcli.h>
|
||||
#include <f32file.h>
|
||||
|
||||
class QUrl;
|
||||
|
||||
class S60MediaRecognizer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum MediaType {
|
||||
Audio,
|
||||
Video,
|
||||
Url,
|
||||
NotSupported = -1
|
||||
};
|
||||
|
||||
S60MediaRecognizer(QObject *parent = 0);
|
||||
~S60MediaRecognizer();
|
||||
|
||||
S60MediaRecognizer::MediaType mediaType(const QUrl &url);
|
||||
S60MediaRecognizer::MediaType identifyMediaType(const QString& fileName);
|
||||
|
||||
protected:
|
||||
TPtrC QString2TPtrC( const QString& string );
|
||||
|
||||
private:
|
||||
RApaLsSession m_recognizer;
|
||||
RFile m_file;
|
||||
RFs m_fileServer;
|
||||
};
|
||||
|
||||
#endif /* S60MEDIARECOGNIZER_H_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user