diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-11-09 20:42:00 +0100 |
---|---|---|
committer | Michael Goddard <michael.goddard@nokia.com> | 2011-11-10 04:15:38 +0100 |
commit | 1d76e399c5d9277895786c6edc2cec76f99d0531 (patch) | |
tree | f56640988d767202cc8f449ff78ad26ff739d314 /src/plugins/gstreamer/camerabin | |
parent | 1e542df82fbcc4e3a8f75537af204f83827a4587 (diff) |
Change-Id: Id6de29b7c1e96aed16be8251195c744f68a2d46b
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Diffstat (limited to 'src/plugins/gstreamer/camerabin')
37 files changed, 0 insertions, 5911 deletions
diff --git a/src/plugins/gstreamer/camerabin/camerabin.pri b/src/plugins/gstreamer/camerabin/camerabin.pri deleted file mode 100644 index 5c266e7..0000000 --- a/src/plugins/gstreamer/camerabin/camerabin.pri +++ /dev/null @@ -1,50 +0,0 @@ -INCLUDEPATH += $$PWD \ - $${SOURCE_DIR}/src/multimedia - -INCLUDEPATH += camerabin - -DEFINES += QMEDIA_GSTREAMER_CAMERABIN - -LIBS += -lgstphotography-0.10 - -DEFINES += GST_USE_UNSTABLE_API #prevents warnings because of unstable photography API - -HEADERS += \ - $$PWD/camerabinservice.h \ - $$PWD/camerabinsession.h \ - $$PWD/camerabincontrol.h \ - $$PWD/camerabinaudioencoder.h \ - $$PWD/camerabinfocus.h \ - $$PWD/camerabinimageencoder.h \ - $$PWD/camerabinlocks.h \ - $$PWD/camerabinrecorder.h \ - $$PWD/camerabincontainer.h \ - $$PWD/camerabinexposure.h \ - $$PWD/camerabinflash.h \ - $$PWD/camerabinimagecapture.h \ - $$PWD/camerabinimageprocessing.h \ - $$PWD/camerabinmetadata.h \ - $$PWD/camerabinvideoencoder.h \ - $$PWD/camerabinresourcepolicy.h \ - $$PWD/camerabincapturedestination.h \ - $$PWD/camerabincapturebufferformat.h - -SOURCES += \ - $$PWD/camerabinservice.cpp \ - $$PWD/camerabinsession.cpp \ - $$PWD/camerabincontrol.cpp \ - $$PWD/camerabinaudioencoder.cpp \ - $$PWD/camerabincontainer.cpp \ - $$PWD/camerabinexposure.cpp \ - $$PWD/camerabinflash.cpp \ - $$PWD/camerabinfocus.cpp \ - $$PWD/camerabinimagecapture.cpp \ - $$PWD/camerabinimageencoder.cpp \ - $$PWD/camerabinimageprocessing.cpp \ - $$PWD/camerabinlocks.cpp \ - $$PWD/camerabinmetadata.cpp \ - $$PWD/camerabinrecorder.cpp \ - $$PWD/camerabinvideoencoder.cpp \ - $$PWD/camerabinresourcepolicy.cpp \ - $$PWD/camerabincapturedestination.cpp \ - $$PWD/camerabincapturebufferformat.cpp diff --git a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp b/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp deleted file mode 100644 index c1f2df9..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.cpp +++ /dev/null @@ -1,129 +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 Toolkit. -** -** $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 "camerabinaudioencoder.h" -#include "camerabincontainer.h" -#include "qgstcodecsinfo.h" - -#include <QtCore/qdebug.h> - -CameraBinAudioEncoder::CameraBinAudioEncoder(QObject *parent) - :QAudioEncoderControl(parent), - m_codecs(QGstCodecsInfo::AudioEncoder) -{ -} - -CameraBinAudioEncoder::~CameraBinAudioEncoder() -{ -} - -QStringList CameraBinAudioEncoder::supportedAudioCodecs() const -{ - return m_codecs.supportedCodecs(); -} - -QString CameraBinAudioEncoder::codecDescription(const QString &codecName) const -{ - return m_codecs.codecDescription(codecName); -} - -QStringList CameraBinAudioEncoder::supportedEncodingOptions(const QString &codec) const -{ - return m_codecOptions.value(codec); -} - -QVariant CameraBinAudioEncoder::encodingOption( - const QString &codec, const QString &name) const -{ - return m_options[codec].value(name); -} - -void CameraBinAudioEncoder::setEncodingOption( - const QString &codec, const QString &name, const QVariant &value) -{ - m_options[codec][name] = value; -} - -QList<int> CameraBinAudioEncoder::supportedSampleRates(const QAudioEncoderSettings &, bool *) const -{ - //TODO check element caps to find actual values - - return QList<int>(); -} - -QAudioEncoderSettings CameraBinAudioEncoder::audioSettings() const -{ - return m_audioSettings; -} - -void CameraBinAudioEncoder::setAudioSettings(const QAudioEncoderSettings &settings) -{ - m_userSettings = settings; - m_audioSettings = settings; - emit settingsChanged(); -} - -void CameraBinAudioEncoder::setActualAudioSettings(const QAudioEncoderSettings &settings) -{ - m_audioSettings = settings; -} - -void CameraBinAudioEncoder::resetActualSettings() -{ - m_audioSettings = m_userSettings; -} - -GstEncodingProfile *CameraBinAudioEncoder::createProfile() -{ - QString codec = m_audioSettings.codec(); - GstCaps *caps; - - if (codec.isEmpty()) - caps = gst_caps_new_any(); - else - caps = gst_caps_from_string(codec.toLatin1()); - - return (GstEncodingProfile *)gst_encoding_audio_profile_new( - caps, - NULL, //preset - NULL, //restriction - 0); //presence -} diff --git a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.h b/src/plugins/gstreamer/camerabin/camerabinaudioencoder.h deleted file mode 100644 index 5468fde..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinaudioencoder.h +++ /dev/null @@ -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 Toolkit. -** -** $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 CAMERABINAUDIOENCODE_H -#define CAMERABINAUDIOENCODE_H - -#include <qaudioencodercontrol.h> -class CameraBinSession; - -#include <QtCore/qstringlist.h> -#include <QtCore/qmap.h> -#include <QtCore/qset.h> - -#include <gst/gst.h> -#include <gst/pbutils/pbutils.h> -#include <gst/pbutils/encoding-profile.h> - -#include <qaudioformat.h> -#include "qgstcodecsinfo.h" - -QT_USE_NAMESPACE - -class CameraBinAudioEncoder : public QAudioEncoderControl -{ - Q_OBJECT -public: - CameraBinAudioEncoder(QObject *parent); - virtual ~CameraBinAudioEncoder(); - - QStringList supportedAudioCodecs() const; - QString codecDescription(const QString &codecName) const; - - 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); - - QList<int> supportedSampleRates(const QAudioEncoderSettings &settings = QAudioEncoderSettings(), - bool *isContinuous = 0) const; - QList<int> supportedChannelCounts(const QAudioEncoderSettings &settings = QAudioEncoderSettings()) const; - QList<int> supportedSampleSizes(const QAudioEncoderSettings &settings = QAudioEncoderSettings()) const; - - QAudioEncoderSettings audioSettings() const; - void setAudioSettings(const QAudioEncoderSettings&); - - void setActualAudioSettings(const QAudioEncoderSettings&); - void resetActualSettings(); - - GstEncodingProfile *createProfile(); - -Q_SIGNALS: - void settingsChanged(); - -private: - QGstCodecsInfo m_codecs; - QMap<QString,QStringList> m_codecOptions; - QMap<QString, QMap<QString, QVariant> > m_options; - - QAudioEncoderSettings m_audioSettings; - QAudioEncoderSettings m_userSettings; -}; - -#endif diff --git a/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.cpp b/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.cpp deleted file mode 100644 index 0611d8b..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.cpp +++ /dev/null @@ -1,78 +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 Toolkit. -** -** $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 "camerabincapturebufferformat.h" -#include "camerabinsession.h" - -CameraBinCaptureBufferFormat::CameraBinCaptureBufferFormat(CameraBinSession *session) - :QCameraCaptureBufferFormatControl(session) - , m_session(session) - , m_format(QVideoFrame::Format_Jpeg) -{ -} - -CameraBinCaptureBufferFormat::~CameraBinCaptureBufferFormat() -{ -} - -QList<QVideoFrame::PixelFormat> CameraBinCaptureBufferFormat::supportedBufferFormats() const -{ - //the exact YUV format is unknown with camerabin until the first capture is requested - return QList<QVideoFrame::PixelFormat>() - << QVideoFrame::Format_Jpeg -#ifdef Q_WS_MAEMO_6 - << QVideoFrame::Format_UYVY -#endif - ; -} - -QVideoFrame::PixelFormat CameraBinCaptureBufferFormat::bufferFormat() const -{ - return m_format; -} - -void CameraBinCaptureBufferFormat::setBufferFormat(QVideoFrame::PixelFormat format) -{ - if (m_format != format) { - m_format = format; - emit bufferFormatChanged(format); - } -} diff --git a/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.h b/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.h deleted file mode 100644 index af119e0..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincapturebufferformat.h +++ /dev/null @@ -1,72 +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 Toolkit. -** -** $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 CAMERABINCAPTUREBUFFERFORMAT_H -#define CAMERABINCAPTUREBUFFERFORMAT_H - -#include <qcamera.h> -#include <qcameracapturebufferformatcontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -class CameraBinSession; - -QT_USE_NAMESPACE - -class Q_MULTIMEDIA_EXPORT CameraBinCaptureBufferFormat : public QCameraCaptureBufferFormatControl -{ - Q_OBJECT -public: - CameraBinCaptureBufferFormat(CameraBinSession *session); - virtual ~CameraBinCaptureBufferFormat(); - - QList<QVideoFrame::PixelFormat> supportedBufferFormats() const; - - QVideoFrame::PixelFormat bufferFormat() const; - void setBufferFormat(QVideoFrame::PixelFormat format); - -private: - CameraBinSession *m_session; - QVideoFrame::PixelFormat m_format; -}; - -#endif diff --git a/src/plugins/gstreamer/camerabin/camerabincapturedestination.cpp b/src/plugins/gstreamer/camerabin/camerabincapturedestination.cpp deleted file mode 100644 index 7472d29..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincapturedestination.cpp +++ /dev/null @@ -1,74 +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 Toolkit. -** -** $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 "camerabincapturedestination.h" -#include "camerabinsession.h" - -CameraBinCaptureDestination::CameraBinCaptureDestination(CameraBinSession *session) - :QCameraCaptureDestinationControl(session) - , m_session(session) - , m_destination(QCameraImageCapture::CaptureToFile) -{ -} - -CameraBinCaptureDestination::~CameraBinCaptureDestination() -{ -} - - -bool CameraBinCaptureDestination::isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const -{ - //capture to buffer, file and both are supported. - return destination & (QCameraImageCapture::CaptureToFile | QCameraImageCapture::CaptureToBuffer); -} - -QCameraImageCapture::CaptureDestinations CameraBinCaptureDestination::captureDestination() const -{ - return m_destination; -} - -void CameraBinCaptureDestination::setCaptureDestination(QCameraImageCapture::CaptureDestinations destination) -{ - if (m_destination != destination) { - m_destination = destination; - emit captureDestinationChanged(m_destination); - } -} diff --git a/src/plugins/gstreamer/camerabin/camerabincapturedestination.h b/src/plugins/gstreamer/camerabin/camerabincapturedestination.h deleted file mode 100644 index 387c3ee..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincapturedestination.h +++ /dev/null @@ -1,69 +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 Toolkit. -** -** $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 CAMERABINCAPTUREDESTINATION_H -#define CAMERABINCAPTUREDESTINATION_H - -#include <qcameraimagecapture.h> -#include <qcameracapturedestinationcontrol.h> - - -class CameraBinSession; - -QT_USE_NAMESPACE - -class Q_MULTIMEDIA_EXPORT CameraBinCaptureDestination : public QCameraCaptureDestinationControl -{ - Q_OBJECT -public: - CameraBinCaptureDestination(CameraBinSession *session); - virtual ~CameraBinCaptureDestination(); - - bool isCaptureDestinationSupported(QCameraImageCapture::CaptureDestinations destination) const; - QCameraImageCapture::CaptureDestinations captureDestination() const; - void setCaptureDestination(QCameraImageCapture::CaptureDestinations destination); - -private: - CameraBinSession *m_session; - QCameraImageCapture::CaptureDestinations m_destination; -}; - -#endif // CAMERABINFLASHCONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabincontainer.cpp b/src/plugins/gstreamer/camerabin/camerabincontainer.cpp deleted file mode 100644 index d0d27fb..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincontainer.cpp +++ /dev/null @@ -1,129 +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 Toolkit. -** -** $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 "camerabincontainer.h" -#include <QtCore/qregexp.h> - -#include <QtCore/qdebug.h> - -CameraBinContainer::CameraBinContainer(QObject *parent) - :QMediaContainerControl(parent), - m_supportedContainers(QGstCodecsInfo::Muxer) -{ - //extension for containers hard to guess from mimetype - m_fileExtensions["video/x-matroska"] = "mkv"; - m_fileExtensions["video/quicktime"] = "mov"; - m_fileExtensions["video/x-msvideo"] = "avi"; - m_fileExtensions["video/msvideo"] = "avi"; - m_fileExtensions["audio/mpeg"] = "mp3"; - m_fileExtensions["application/x-shockwave-flash"] = "swf"; - m_fileExtensions["application/x-pn-realmedia"] = "rm"; -} - -QStringList CameraBinContainer::supportedContainers() const -{ - return m_supportedContainers.supportedCodecs(); -} - -QString CameraBinContainer::containerDescription(const QString &formatMimeType) const -{ - return m_supportedContainers.codecDescription(formatMimeType); -} - -QString CameraBinContainer::containerMimeType() const -{ - return m_format; -} - -void CameraBinContainer::setContainerMimeType(const QString &formatMimeType) -{ - m_format = formatMimeType; - - if (m_userFormat != formatMimeType) { - m_userFormat = formatMimeType; - emit settingsChanged(); - } -} - -void CameraBinContainer::setActualContainer(const QString &formatMimeType) -{ - m_format = formatMimeType; -} - -void CameraBinContainer::resetActualContainer() -{ - m_format = m_userFormat; -} - -GstEncodingContainerProfile *CameraBinContainer::createProfile() -{ - GstCaps *caps; - - if (m_format.isEmpty()) - caps = gst_caps_new_any(); - else - caps = gst_caps_from_string(m_format.toLatin1()); - - return (GstEncodingContainerProfile *)gst_encoding_container_profile_new( - "camerabin2_profile", - (gchar *)"custom camera profile", - caps, - NULL); //preset -} - -/*! - Suggest file extension for current container mimetype. - */ -QString CameraBinContainer::suggestedFileExtension() const -{ - QString format = m_format.left(m_format.indexOf(',')); - QString extension = m_fileExtensions.value(format); - - if (!extension.isEmpty() || format.isEmpty()) - return extension; - - QRegExp rx("[-/]([\\w]+)$"); - - if (rx.indexIn(format) != -1) - extension = rx.cap(1); - - return extension; -} diff --git a/src/plugins/gstreamer/camerabin/camerabincontainer.h b/src/plugins/gstreamer/camerabin/camerabincontainer.h deleted file mode 100644 index 5eaa19f..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincontainer.h +++ /dev/null @@ -1,89 +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 Toolkit. -** -** $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 CAMERABINMEDIACONTAINERCONTROL_H -#define CAMERABINMEDIACONTAINERCONTROL_H - -#include <qmediacontainercontrol.h> -#include <QtCore/qstringlist.h> -#include <QtCore/qset.h> - -#include <gst/gst.h> -#include <gst/pbutils/pbutils.h> -#include <gst/pbutils/encoding-profile.h> - -#include "qgstcodecsinfo.h" - -QT_USE_NAMESPACE - -class CameraBinContainer : public QMediaContainerControl -{ -Q_OBJECT -public: - CameraBinContainer(QObject *parent); - virtual ~CameraBinContainer() {} - - virtual QStringList supportedContainers() const; - virtual QString containerDescription(const QString &formatMimeType) const; - - virtual QString containerMimeType() const; - virtual void setContainerMimeType(const QString &formatMimeType); - - void setActualContainer(const QString &formatMimeType); - void resetActualContainer(); - - QString suggestedFileExtension() const; - - GstEncodingContainerProfile *createProfile(); - -Q_SIGNALS: - void settingsChanged(); - -private: - QString m_format; // backend selected format, using m_userFormat - QString m_userFormat; - QMap<QString, QString> m_fileExtensions; - - QGstCodecsInfo m_supportedContainers; -}; - -#endif // CAMERABINMEDIACONTAINERCONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp b/src/plugins/gstreamer/camerabin/camerabincontrol.cpp deleted file mode 100644 index f40133d..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincontrol.cpp +++ /dev/null @@ -1,341 +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 Toolkit. -** -** $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 "camerabincontrol.h" -#include "camerabincontainer.h" -#include "camerabinaudioencoder.h" -#include "camerabinvideoencoder.h" -#include "camerabinimageencoder.h" -#include "camerabinresourcepolicy.h" - -#include <QtCore/qdebug.h> -#include <QtCore/qfile.h> -#include <QtCore/qmetaobject.h> - -#include <linux/types.h> -#include <sys/time.h> -#include <sys/ioctl.h> -#include <sys/poll.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <linux/videodev2.h> - -//#define CAMEABIN_DEBUG 1 -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) - -CameraBinControl::CameraBinControl(CameraBinSession *session) - :QCameraControl(session), - m_session(session), - m_state(QCamera::UnloadedState), - m_status(QCamera::UnloadedStatus), - m_reloadPending(false) -{ - connect(m_session, SIGNAL(stateChanged(QCamera::State)), - this, SLOT(updateStatus())); - - connect(m_session, SIGNAL(viewfinderChanged()), - SLOT(reloadLater())); - connect(m_session, SIGNAL(readyChanged(bool)), - SLOT(reloadLater())); - connect(m_session, SIGNAL(error(int,QString)), - SLOT(handleCameraError(int,QString))); - - m_resourcePolicy = new CamerabinResourcePolicy(this); - connect(m_resourcePolicy, SIGNAL(resourcesGranted()), - SLOT(handleResourcesGranted())); - connect(m_resourcePolicy, SIGNAL(resourcesDenied()), - SLOT(handleResourcesLost())); - connect(m_resourcePolicy, SIGNAL(resourcesLost()), - SLOT(handleResourcesLost())); - - connect(m_session, SIGNAL(busyChanged(bool)), - SLOT(handleBusyChanged(bool))); -} - -CameraBinControl::~CameraBinControl() -{ -} - -QCamera::CaptureMode CameraBinControl::captureMode() const -{ - return m_session->captureMode(); -} - -void CameraBinControl::setCaptureMode(QCamera::CaptureMode mode) -{ - if (m_session->captureMode() != mode) { - m_session->setCaptureMode(mode); - - if (m_state == QCamera::ActiveState) { - m_resourcePolicy->setResourceSet( - captureMode() == QCamera::CaptureStillImage ? - CamerabinResourcePolicy::ImageCaptureResources : - CamerabinResourcePolicy::VideoCaptureResources); - } - emit captureModeChanged(mode); - } -} - -bool CameraBinControl::isCaptureModeSupported(QCamera::CaptureMode mode) const -{ - return mode == QCamera::CaptureStillImage || mode == QCamera::CaptureVideo; -} - -void CameraBinControl::setState(QCamera::State state) -{ -#ifdef CAMEABIN_DEBUG - qDebug() << Q_FUNC_INFO << ENUM_NAME(QCamera, "State", state); -#endif - if (m_state != state) { - m_state = state; - - //special case for stopping the camera while it's busy, - //it should be delayed until the camera is idle - if (state == QCamera::LoadedState && - m_session->state() == QCamera::ActiveState && - m_session->isBusy()) { -#ifdef CAMEABIN_DEBUG - qDebug() << Q_FUNC_INFO << "Camera is busy, QCamera::stop() is delayed"; -#endif - emit stateChanged(m_state); - return; - } - - CamerabinResourcePolicy::ResourceSet resourceSet; - switch (state) { - case QCamera::UnloadedState: - resourceSet = CamerabinResourcePolicy::NoResources; - break; - case QCamera::LoadedState: - resourceSet = CamerabinResourcePolicy::LoadedResources; - break; - case QCamera::ActiveState: - resourceSet = captureMode() == QCamera::CaptureStillImage ? - CamerabinResourcePolicy::ImageCaptureResources : - CamerabinResourcePolicy::VideoCaptureResources; - break; - } - - m_resourcePolicy->setResourceSet(resourceSet); - - if (m_resourcePolicy->isResourcesGranted()) { - //postpone changing to Active if the session is nor ready yet - if (state == QCamera::ActiveState) { - if (m_session->isReady()) { - m_session->setState(state); - } else { -#ifdef CAMEABIN_DEBUG - qDebug() << "Camera session is not ready yet, postpone activating"; -#endif - } - } else - m_session->setState(state); - } - - emit stateChanged(m_state); - } -} - -QCamera::State CameraBinControl::state() const -{ - return m_state; -} - -void CameraBinControl::updateStatus() -{ - QCamera::State sessionState = m_session->state(); - QCamera::Status oldStatus = m_status; - - switch (m_state) { - case QCamera::UnloadedState: - m_status = QCamera::UnloadedStatus; - break; - case QCamera::LoadedState: - switch (sessionState) { - case QCamera::UnloadedState: - m_status = QCamera::LoadingStatus; - break; - case QCamera::LoadedState: - m_status = QCamera::LoadedStatus; - break; - case QCamera::ActiveState: - m_status = QCamera::ActiveStatus; - break; - } - break; - case QCamera::ActiveState: - switch (sessionState) { - case QCamera::UnloadedState: - m_status = QCamera::LoadingStatus; - break; - case QCamera::LoadedState: - m_status = QCamera::StartingStatus; - break; - case QCamera::ActiveState: - m_status = QCamera::ActiveStatus; - break; - } - } - - if (m_status != oldStatus) { -#ifdef CAMEABIN_DEBUG - qDebug() << "Camera status changed" << ENUM_NAME(QCamera, "Status", m_status); -#endif - emit statusChanged(m_status); - } -} - -void CameraBinControl::reloadLater() -{ -#ifdef CAMEABIN_DEBUG - qDebug() << "CameraBinControl: reload pipeline requested" << ENUM_NAME(QCamera, "State", m_state); -#endif - if (!m_reloadPending && m_state == QCamera::ActiveState) { - m_reloadPending = true; - - if (!m_session->isBusy()) { - m_session->setState(QCamera::LoadedState); - QMetaObject::invokeMethod(this, "delayedReload", Qt::QueuedConnection); - } - } -} - -void CameraBinControl::handleResourcesLost() -{ -#ifdef CAMEABIN_DEBUG - qDebug() << Q_FUNC_INFO << ENUM_NAME(QCamera, "State", m_state); -#endif - m_session->setState(QCamera::UnloadedState); -} - -void CameraBinControl::handleResourcesGranted() -{ -#ifdef CAMEABIN_DEBUG - qDebug() << Q_FUNC_INFO << ENUM_NAME(QCamera, "State", m_state); -#endif - - //camera will be started soon by delayedReload() - if (m_reloadPending && m_state == QCamera::ActiveState) - return; - - if (m_state == QCamera::ActiveState && m_session->isReady()) - m_session->setState(QCamera::ActiveState); - else if (m_state == QCamera::LoadedState) - m_session->setState(QCamera::LoadedState); -} - -void CameraBinControl::handleBusyChanged(bool busy) -{ - if (!busy && m_session->state() == QCamera::ActiveState) { - if (m_state == QCamera::LoadedState) { - //handle delayed stop() because of busy camera - m_resourcePolicy->setResourceSet(CamerabinResourcePolicy::LoadedResources); - m_session->setState(QCamera::LoadedState); - } else if (m_state == QCamera::ActiveState && m_reloadPending) { - //handle delayed reload because of busy camera - m_session->setState(QCamera::LoadedState); - QMetaObject::invokeMethod(this, "delayedReload", Qt::QueuedConnection); - } - } -} - -void CameraBinControl::handleCameraError(int errorCode, const QString &errorString) -{ - emit error(errorCode, errorString); - setState(QCamera::UnloadedState); -} - -void CameraBinControl::delayedReload() -{ -#ifdef CAMEABIN_DEBUG - qDebug() << "CameraBinControl: reload pipeline"; -#endif - if (m_reloadPending) { - m_reloadPending = false; - if (m_state == QCamera::ActiveState && - m_session->isReady() && - m_resourcePolicy->isResourcesGranted()) { - m_session->setState(QCamera::ActiveState); - } - } -} - -bool CameraBinControl::canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const -{ - Q_UNUSED(status); - - switch (changeType) { - case QCameraControl::CaptureMode: - case QCameraControl::ImageEncodingSettings: - case QCameraControl::VideoEncodingSettings: - case QCameraControl::Viewfinder: - return true; - default: - return false; - } -} - -#define VIEWFINDER_COLORSPACE_CONVERSION 0x00000004 - -bool CameraBinControl::viewfinderColorSpaceConversion() const -{ - gint flags = 0; - g_object_get(G_OBJECT(m_session->cameraBin()), "flags", &flags, NULL); - - return flags & VIEWFINDER_COLORSPACE_CONVERSION; -} - -void CameraBinControl::setViewfinderColorSpaceConversion(bool enabled) -{ - gint flags = 0; - g_object_get(G_OBJECT(m_session->cameraBin()), "flags", &flags, NULL); - - if (enabled) - flags |= VIEWFINDER_COLORSPACE_CONVERSION; - else - flags &= ~VIEWFINDER_COLORSPACE_CONVERSION; - - g_object_set(G_OBJECT(m_session->cameraBin()), "flags", flags, NULL); -} diff --git a/src/plugins/gstreamer/camerabin/camerabincontrol.h b/src/plugins/gstreamer/camerabin/camerabincontrol.h deleted file mode 100644 index 3f90ca4..0000000 --- a/src/plugins/gstreamer/camerabin/camerabincontrol.h +++ /dev/null @@ -1,101 +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 Toolkit. -** -** $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 CAMERABINCONTROL_H -#define CAMERABINCONTROL_H - -#include <QHash> -#include <qcameracontrol.h> -#include "camerabinsession.h" - -QT_USE_NAMESPACE - -class CamerabinResourcePolicy; - -class CameraBinControl : public QCameraControl -{ - Q_OBJECT - Q_PROPERTY(bool viewfinderColorSpaceConversion READ viewfinderColorSpaceConversion WRITE setViewfinderColorSpaceConversion) -public: - CameraBinControl( CameraBinSession *session ); - virtual ~CameraBinControl(); - - bool isValid() const { return true; } - - QCamera::State state() const; - void setState(QCamera::State state); - - QCamera::Status status() const { return m_status; } - - QCamera::CaptureMode captureMode() const; - void setCaptureMode(QCamera::CaptureMode mode); - - bool isCaptureModeSupported(QCamera::CaptureMode mode) const; - bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const; - bool viewfinderColorSpaceConversion() const; - -public slots: - void reloadLater(); - void setViewfinderColorSpaceConversion(bool enabled); - -private slots: - void updateStatus(); - void delayedReload(); - - void handleResourcesGranted(); - void handleResourcesLost(); - - void handleBusyChanged(bool); - void handleCameraError(int error, const QString &errorString); - -private: - void updateSupportedResolutions(const QString &device); - - CameraBinSession *m_session; - QCamera::State m_state; - QCamera::Status m_status; - CamerabinResourcePolicy *m_resourcePolicy; - - bool m_reloadPending; -}; - -#endif // CAMERABINCONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp b/src/plugins/gstreamer/camerabin/camerabinexposure.cpp deleted file mode 100644 index 4c7b8aa..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.cpp +++ /dev/null @@ -1,232 +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 Toolkit. -** -** $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 "camerabinexposure.h" -#include "camerabinsession.h" -#include <gst/interfaces/photography.h> - -#include <QDebug> - -CameraBinExposure::CameraBinExposure(CameraBinSession *session) - :QCameraExposureControl(session), - m_session(session) -{ -} - -CameraBinExposure::~CameraBinExposure() -{ -} - -QCameraExposure::ExposureMode CameraBinExposure::exposureMode() const -{ - GstSceneMode sceneMode; - gst_photography_get_scene_mode(m_session->photography(), &sceneMode); - - switch (sceneMode) { - case GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT: return QCameraExposure::ExposurePortrait; - case GST_PHOTOGRAPHY_SCENE_MODE_SPORT: return QCameraExposure::ExposureSports; - case GST_PHOTOGRAPHY_SCENE_MODE_NIGHT: return QCameraExposure::ExposureNight; - case GST_PHOTOGRAPHY_SCENE_MODE_MANUAL: return QCameraExposure::ExposureManual; - case GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP: //no direct mapping available so mapping to auto mode - case GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE: //no direct mapping available so mapping to auto mode - case GST_PHOTOGRAPHY_SCENE_MODE_AUTO: - default: - return QCameraExposure::ExposureAuto; - } -} - -void CameraBinExposure::setExposureMode(QCameraExposure::ExposureMode mode) -{ - GstSceneMode sceneMode; - gst_photography_get_scene_mode(m_session->photography(), &sceneMode); - - switch (mode) { - case QCameraExposure::ExposureManual: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_MANUAL; break; - case QCameraExposure::ExposurePortrait: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_PORTRAIT; break; - case QCameraExposure::ExposureSports: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_SPORT; break; - case QCameraExposure::ExposureNight: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_NIGHT; break; - case QCameraExposure::ExposureAuto: sceneMode = GST_PHOTOGRAPHY_SCENE_MODE_AUTO; break; - default: - break; - } - - gst_photography_set_scene_mode(m_session->photography(), sceneMode); -} - -bool CameraBinExposure::isExposureModeSupported(QCameraExposure::ExposureMode mode) const -{ - //Similar mode names can be found in gst as GstSceneMode - return mode == QCameraExposure::ExposureAuto || - mode == QCameraExposure::ExposurePortrait || - mode == QCameraExposure::ExposureSports || - mode == QCameraExposure::ExposureNight; - - //No direct mapping available for GST_PHOTOGRAPHY_SCENE_MODE_CLOSEUP and - //GST_PHOTOGRAPHY_SCENE_MODE_LANDSCAPE -} - -QCameraExposure::MeteringMode CameraBinExposure::meteringMode() const -{ - return QCameraExposure::MeteringMatrix; -} - -void CameraBinExposure::setMeteringMode(QCameraExposure::MeteringMode mode) -{ - Q_UNUSED(mode); -} - -bool CameraBinExposure::isMeteringModeSupported(QCameraExposure::MeteringMode mode) const -{ - return mode == QCameraExposure::MeteringMatrix; -} - -bool CameraBinExposure::isParameterSupported(ExposureParameter parameter) const -{ - switch (parameter) { - case QCameraExposureControl::ExposureCompensation: - case QCameraExposureControl::ISO: - case QCameraExposureControl::Aperture: - case QCameraExposureControl::ShutterSpeed: - return true; - default: - return false; - } -} - -QVariant CameraBinExposure::exposureParameter(ExposureParameter parameter) const -{ - switch (parameter) { - case QCameraExposureControl::ExposureCompensation: - { - gfloat ev; - gst_photography_get_ev_compensation(m_session->photography(), &ev); - return QVariant(ev); - } - case QCameraExposureControl::ISO: - { - guint isoSpeed = 0; - gst_photography_get_iso_speed(m_session->photography(), &isoSpeed); - return QVariant(isoSpeed); - } - case QCameraExposureControl::Aperture: - return QVariant(2.8); - case QCameraExposureControl::ShutterSpeed: - { - guint32 shutterSpeed = 0; - gst_photography_get_exposure(m_session->photography(), &shutterSpeed); - - return QVariant(shutterSpeed/1000000.0); - } - default: - return QVariant(); - } -} - -QCameraExposureControl::ParameterFlags CameraBinExposure::exposureParameterFlags(ExposureParameter parameter) const -{ - QCameraExposureControl::ParameterFlags flags = 0; - - switch (parameter) { - case QCameraExposureControl::ExposureCompensation: - flags |= ContinuousRange; - break; - case QCameraExposureControl::Aperture: - flags |= ReadOnly; - break; - default: - break; - } - - return flags; -} - -QVariantList CameraBinExposure::supportedParameterRange(ExposureParameter parameter) const -{ - QVariantList res; - switch (parameter) { - case QCameraExposureControl::ExposureCompensation: - res << -2.0 << 2.0; - break; - case QCameraExposureControl::ISO: - res << 100 << 200 << 400; - break; - case QCameraExposureControl::Aperture: - res << 2.8; - break; - default: - break; - } - - return res; -} - -bool CameraBinExposure::setExposureParameter(ExposureParameter parameter, const QVariant& value) -{ - QVariant oldValue = exposureParameter(parameter); - - switch (parameter) { - case QCameraExposureControl::ExposureCompensation: - gst_photography_set_ev_compensation(m_session->photography(), value.toReal()); - break; - case QCameraExposureControl::ISO: - gst_photography_set_iso_speed(m_session->photography(), value.toInt()); - break; - case QCameraExposureControl::Aperture: - gst_photography_set_aperture(m_session->photography(), guint(value.toReal()*1000000)); - break; - case QCameraExposureControl::ShutterSpeed: - gst_photography_set_exposure(m_session->photography(), guint(value.toReal()*1000000)); - break; - default: - return false; - } - - QVariant newValue = exposureParameter(parameter); - if (!qFuzzyCompare(oldValue.toReal(), newValue.toReal())) - emit exposureParameterChanged(parameter); - - return true; -} - -QString CameraBinExposure::extendedParameterName(ExposureParameter) -{ - return QString(); -} diff --git a/src/plugins/gstreamer/camerabin/camerabinexposure.h b/src/plugins/gstreamer/camerabin/camerabinexposure.h deleted file mode 100644 index 4be21d3..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinexposure.h +++ /dev/null @@ -1,83 +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 Toolkit. -** -** $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 CAMERABINEXPOSURECONTROL_MAEMO_H -#define CAMERABINEXPOSURECONTROL_MAEMO_H - -#include <qcamera.h> -#include <qcameraexposurecontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -class CameraBinSession; - -QT_USE_NAMESPACE - -class Q_MULTIMEDIA_EXPORT CameraBinExposure : public QCameraExposureControl -{ - Q_OBJECT - -public: - CameraBinExposure(CameraBinSession *session); - virtual ~CameraBinExposure(); - - QCameraExposure::ExposureMode exposureMode() const; - void setExposureMode(QCameraExposure::ExposureMode mode); - bool isExposureModeSupported(QCameraExposure::ExposureMode mode) const; - - QCameraExposure::MeteringMode meteringMode() const; - void setMeteringMode(QCameraExposure::MeteringMode mode); - bool isMeteringModeSupported(QCameraExposure::MeteringMode mode) const; - - bool isParameterSupported(ExposureParameter parameter) const; - QVariant exposureParameter(ExposureParameter parameter) const; - ParameterFlags exposureParameterFlags(ExposureParameter parameter) const; - QVariantList supportedParameterRange(ExposureParameter parameter) const; - bool setExposureParameter(ExposureParameter parameter, const QVariant& value); - - QString extendedParameterName(ExposureParameter parameter); - -private: - CameraBinSession *m_session; -}; - -#endif // CAMERABINEXPOSURECONTROL_MAEMO_H diff --git a/src/plugins/gstreamer/camerabin/camerabinflash.cpp b/src/plugins/gstreamer/camerabin/camerabinflash.cpp deleted file mode 100644 index 0882747..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinflash.cpp +++ /dev/null @@ -1,104 +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 Toolkit. -** -** $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 "camerabinflash.h" -#include "camerabinsession.h" -#include <gst/interfaces/photography.h> - -#include <QDebug> - -CameraBinFlash::CameraBinFlash(CameraBinSession *session) - :QCameraFlashControl(session), - m_session(session) -{ -} - -CameraBinFlash::~CameraBinFlash() -{ -} - -QCameraExposure::FlashModes CameraBinFlash::flashMode() const -{ - GstFlashMode flashMode; - gst_photography_get_flash_mode(m_session->photography(), &flashMode); - - QCameraExposure::FlashModes modes; - switch (flashMode) { - case GST_PHOTOGRAPHY_FLASH_MODE_AUTO: modes |= QCameraExposure::FlashAuto; break; - case GST_PHOTOGRAPHY_FLASH_MODE_OFF: modes |= QCameraExposure::FlashOff; break; - case GST_PHOTOGRAPHY_FLASH_MODE_ON: modes |= QCameraExposure::FlashOn; break; - case GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN: modes |= QCameraExposure::FlashFill; break; - case GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE: modes |= QCameraExposure::FlashRedEyeReduction; break; - default: - modes |= QCameraExposure::FlashAuto; - break; - } - return modes; -} - -void CameraBinFlash::setFlashMode(QCameraExposure::FlashModes mode) -{ - GstFlashMode flashMode; - gst_photography_get_flash_mode(m_session->photography(), &flashMode); - - if (mode.testFlag(QCameraExposure::FlashAuto)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_AUTO; - else if (mode.testFlag(QCameraExposure::FlashOff)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_OFF; - else if (mode.testFlag(QCameraExposure::FlashOn)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_ON; - else if (mode.testFlag(QCameraExposure::FlashFill)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_FILL_IN; - else if (mode.testFlag(QCameraExposure::FlashRedEyeReduction)) flashMode = GST_PHOTOGRAPHY_FLASH_MODE_RED_EYE; - - gst_photography_set_flash_mode(m_session->photography(), flashMode); -} - -bool CameraBinFlash::isFlashModeSupported(QCameraExposure::FlashModes mode) const -{ - return mode == QCameraExposure::FlashOff || - mode == QCameraExposure::FlashOn || - mode == QCameraExposure::FlashAuto || - mode == QCameraExposure::FlashRedEyeReduction || - mode == QCameraExposure::FlashFill; -} - -bool CameraBinFlash::isFlashReady() const -{ - return true; -} - diff --git a/src/plugins/gstreamer/camerabin/camerabinflash.h b/src/plugins/gstreamer/camerabin/camerabinflash.h deleted file mode 100644 index 40b9724..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinflash.h +++ /dev/null @@ -1,73 +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 Toolkit. -** -** $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 CAMERABINFLASHCONTROL_H -#define CAMERABINFLASHCONTROL_H - -#include <qcamera.h> -#include <qcameraflashcontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -class CameraBinSession; - -QT_USE_NAMESPACE - -class Q_MULTIMEDIA_EXPORT CameraBinFlash : public QCameraFlashControl -{ - Q_OBJECT -public: - CameraBinFlash(CameraBinSession *session); - virtual ~CameraBinFlash(); - - QCameraExposure::FlashModes flashMode() const; - void setFlashMode(QCameraExposure::FlashModes mode); - bool isFlashModeSupported(QCameraExposure::FlashModes mode) const; - - bool isFlashReady() const; - -private: - CameraBinSession *m_session; -}; - -#endif // CAMERABINFLASHCONTROL_H - diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp b/src/plugins/gstreamer/camerabin/camerabinfocus.cpp deleted file mode 100644 index b989c50..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.cpp +++ /dev/null @@ -1,225 +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 Toolkit. -** -** $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 "camerabinfocus.h" -#include "camerabinsession.h" - -#include <gst/interfaces/photography.h> - -#include <QDebug> -#include <QtCore/qmetaobject.h> - -//#define CAMERABIN_DEBUG 1 -#define ZOOM_PROPERTY "zoom" -#define MAX_ZOOM_PROPERTY "max-zoom" - -CameraBinFocus::CameraBinFocus(CameraBinSession *session) - :QCameraFocusControl(session), - m_session(session), - m_focusMode(QCameraFocus::AutoFocus), - m_focusStatus(QCamera::Unlocked), - m_focusZoneStatus(QCameraFocusZone::Selected) -{ - connect(m_session, SIGNAL(stateChanged(QCamera::State)), - this, SLOT(_q_handleCameraStateChange(QCamera::State))); -} - -CameraBinFocus::~CameraBinFocus() -{ -} - -QCameraFocus::FocusMode CameraBinFocus::focusMode() const -{ - return m_focusMode; -} - -void CameraBinFocus::setFocusMode(QCameraFocus::FocusMode mode) -{ - if (isFocusModeSupported(mode)) { - m_focusMode = mode; - } -} - -bool CameraBinFocus::isFocusModeSupported(QCameraFocus::FocusMode mode) const -{ - return mode & QCameraFocus::AutoFocus; -} - -qreal CameraBinFocus::maximumOpticalZoom() const -{ - return 1.0; -} - -qreal CameraBinFocus::maximumDigitalZoom() const -{ - gfloat zoomFactor = 1.0; - g_object_get(GST_BIN(m_session->cameraBin()), MAX_ZOOM_PROPERTY, &zoomFactor, NULL); - return zoomFactor; -} - -qreal CameraBinFocus::opticalZoom() const -{ - return 1.0; -} - -qreal CameraBinFocus::digitalZoom() const -{ - gfloat zoomFactor = 1.0; - g_object_get(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, &zoomFactor, NULL); - return zoomFactor; -} - -void CameraBinFocus::zoomTo(qreal optical, qreal digital) -{ - Q_UNUSED(optical); - digital = qBound(qreal(1.0), digital, maximumDigitalZoom()); - g_object_set(GST_BIN(m_session->cameraBin()), ZOOM_PROPERTY, digital, NULL); - emit digitalZoomChanged(digital); -} - -QCameraFocus::FocusPointMode CameraBinFocus::focusPointMode() const -{ - return QCameraFocus::FocusPointAuto; -} - -void CameraBinFocus::setFocusPointMode(QCameraFocus::FocusPointMode mode) -{ - Q_UNUSED(mode); -} - -bool CameraBinFocus::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const -{ - return mode == QCameraFocus::FocusPointAuto; -} - -QPointF CameraBinFocus::customFocusPoint() const -{ - return QPointF(0.5, 0.5); -} - -void CameraBinFocus::setCustomFocusPoint(const QPointF &point) -{ - Q_UNUSED(point); -} - -QCameraFocusZoneList CameraBinFocus::focusZones() const -{ - return QCameraFocusZoneList() << QCameraFocusZone(QRectF(0.35, 0.35, 0.3, 0.3), m_focusZoneStatus); -} - - -void CameraBinFocus::handleFocusMessage(GstMessage *gm) -{ - //it's a sync message, so it's called from non main thread - if (gst_structure_has_name(gm->structure, GST_PHOTOGRAPHY_AUTOFOCUS_DONE)) { - gint status = GST_PHOTOGRAPHY_FOCUS_STATUS_NONE; - gst_structure_get_int (gm->structure, "status", &status); - QCamera::LockStatus focusStatus = m_focusStatus; - QCamera::LockChangeReason reason = QCamera::UserRequest; - - switch (status) { - case GST_PHOTOGRAPHY_FOCUS_STATUS_FAIL: - focusStatus = QCamera::Unlocked; - reason = QCamera::LockFailed; - break; - case GST_PHOTOGRAPHY_FOCUS_STATUS_SUCCESS: - focusStatus = QCamera::Locked; - break; - case GST_PHOTOGRAPHY_FOCUS_STATUS_NONE: - break; - case GST_PHOTOGRAPHY_FOCUS_STATUS_RUNNING: - focusStatus = QCamera::Searching; - break; - default: - break; - } - - static int signalIndex = metaObject()->indexOfSlot( - "_q_setFocusStatus(QCamera::LockStatus,QCamera::LockChangeReason)"); - metaObject()->method(signalIndex).invoke(this, - Qt::QueuedConnection, - Q_ARG(QCamera::LockStatus,focusStatus), - Q_ARG(QCamera::LockChangeReason,reason)); - } -} - -void CameraBinFocus::_q_setFocusStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ -#ifdef CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << "Current:" - << m_focusStatus - << "New:" - << status << reason; -#endif - - if (m_focusStatus != status) { - m_focusStatus = status; - - QCameraFocusZone::FocusZoneStatus zonesStatus = - m_focusStatus == QCamera::Locked ? - QCameraFocusZone::Focused : QCameraFocusZone::Selected; - - if (m_focusZoneStatus != zonesStatus) { - m_focusZoneStatus = zonesStatus; - emit focusZonesChanged(); - } - - emit _q_focusStatusChanged(m_focusStatus, reason); - } -} - -void CameraBinFocus::_q_handleCameraStateChange(QCamera::State state) -{ - if (state != QCamera::ActiveState) - _q_setFocusStatus(QCamera::Unlocked, QCamera::LockLost); -} - -void CameraBinFocus::_q_startFocusing() -{ - _q_setFocusStatus(QCamera::Searching, QCamera::UserRequest); - gst_photography_set_autofocus(m_session->photography(), TRUE); -} - -void CameraBinFocus::_q_stopFocusing() -{ - gst_photography_set_autofocus(m_session->photography(), FALSE); - _q_setFocusStatus(QCamera::Unlocked, QCamera::UserRequest); -} diff --git a/src/plugins/gstreamer/camerabin/camerabinfocus.h b/src/plugins/gstreamer/camerabin/camerabinfocus.h deleted file mode 100644 index df9448a..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinfocus.h +++ /dev/null @@ -1,103 +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 Toolkit. -** -** $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 CAMERABINFOCUSCONTROL_H -#define CAMERABINFOCUSCONTROL_H - -#include <qcamera.h> -#include <qcamerafocuscontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -class CameraBinSession; - -QT_USE_NAMESPACE - -class CameraBinFocus : public QCameraFocusControl -{ - Q_OBJECT - -public: - CameraBinFocus(CameraBinSession *session); - virtual ~CameraBinFocus(); - - QCameraFocus::FocusMode focusMode() const; - void setFocusMode(QCameraFocus::FocusMode mode); - bool isFocusModeSupported(QCameraFocus::FocusMode mode) const; - - qreal maximumOpticalZoom() const; - qreal maximumDigitalZoom() const; - qreal opticalZoom() const; - qreal digitalZoom() const; - - void zoomTo(qreal optical, qreal digital) ; - - QCameraFocus::FocusPointMode focusPointMode() const; - void setFocusPointMode(QCameraFocus::FocusPointMode mode) ; - bool isFocusPointModeSupported(QCameraFocus::FocusPointMode) const; - QPointF customFocusPoint() const; - void setCustomFocusPoint(const QPointF &point); - - QCameraFocusZoneList focusZones() const; - - void handleFocusMessage(GstMessage*); - QCamera::LockStatus focusStatus() const { return m_focusStatus; } - -Q_SIGNALS: - void _q_focusStatusChanged(QCamera::LockStatus status, QCamera::LockChangeReason reason); - -public Q_SLOTS: - void _q_startFocusing(); - void _q_stopFocusing(); - -private Q_SLOTS: - void _q_setFocusStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason); - void _q_handleCameraStateChange(QCamera::State state); - -private: - CameraBinSession *m_session; - QCameraFocus::FocusMode m_focusMode; - QCamera::LockStatus m_focusStatus; - QCameraFocusZone::FocusZoneStatus m_focusZoneStatus; -}; - -#endif // CAMERABINFOCUSCONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp b/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp deleted file mode 100644 index 874361e..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimagecapture.cpp +++ /dev/null @@ -1,339 +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 Toolkit. -** -** $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 "camerabinimagecapture.h" -#include "camerabincapturedestination.h" -#include "camerabincapturebufferformat.h" -#include "camerabinsession.h" -#include <private/qgstvideobuffer_p.h> -#include <private/qvideosurfacegstsink_p.h> -#include <private/qgstutils_p.h> -#include <QtCore/qdebug.h> -#include <QtCore/qbuffer.h> -#include <QtGui/qimagereader.h> - -//#define DEBUG_CAPTURE - -#define IMAGE_DONE_SIGNAL "image-done" - -Q_DECLARE_METATYPE(QVideoFrame) -Q_DECLARE_METATYPE(QtMultimedia::MetaData) - -namespace -{ -class CameraRegisterMetaTypes -{ -public: - CameraRegisterMetaTypes() - { - qRegisterMetaType<QVideoFrame>("QVideoFrame"); - qRegisterMetaType<QtMultimedia::MetaData>("QtMultimedia::MetaData"); - } -} _registerCameraMetaTypes; -} - - -CameraBinImageCapture::CameraBinImageCapture(CameraBinSession *session) - :QCameraImageCaptureControl(session) - , m_session(session) - , m_ready(false) - , m_requestId(0) - , m_jpegEncoderElement(0) - , m_metadataMuxerElement(0) -{ - connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState())); - connect(m_session, SIGNAL(imageExposed(int)), this, SIGNAL(imageExposed(int))); - connect(m_session, SIGNAL(imageCaptured(int,QImage)), this, SIGNAL(imageCaptured(int,QImage))); - - m_session->bus()->installMessageFilter(this); -} - -CameraBinImageCapture::~CameraBinImageCapture() -{ -} - -bool CameraBinImageCapture::isReadyForCapture() const -{ - return m_ready; -} - -int CameraBinImageCapture::capture(const QString &fileName) -{ - m_requestId++; - - if (!m_ready) { - emit error(m_requestId, QCameraImageCapture::NotReadyError, tr("Camera not ready")); - return m_requestId; - } - -#ifdef DEBUG_CAPTURE - qDebug() << Q_FUNC_INFO << m_requestId << fileName; -#endif - m_session->captureImage(m_requestId, fileName); - return m_requestId; -} - -void CameraBinImageCapture::cancelCapture() -{ -} - -void CameraBinImageCapture::updateState() -{ - bool ready = m_session->state() == QCamera::ActiveState; - if (m_ready != ready) { -#ifdef DEBUG_CAPTURE - qDebug() << "readyForCaptureChanged" << ready; -#endif - emit readyForCaptureChanged(m_ready = ready); - } -} - -gboolean CameraBinImageCapture::metadataEventProbe(GstPad *pad, GstEvent *event, CameraBinImageCapture *self) -{ - Q_UNUSED(pad); - - if (GST_EVENT_TYPE(event) == GST_EVENT_TAG) { - GstTagList *gstTags; - gst_event_parse_tag(event, &gstTags); - QMap<QByteArray, QVariant> extendedTags = QGstUtils::gstTagListToMap(gstTags); - -#ifdef DEBUG_CAPTURE - qDebug() << QString(gst_structure_to_string(gst_event_get_structure(event))).right(768); - qDebug() << "Capture event probe" << extendedTags; -#endif - - QMap<QtMultimedia::MetaData, QVariant> tags; - tags[QtMultimedia::ISOSpeedRatings] = extendedTags.value("capturing-iso-speed"); - tags[QtMultimedia::DigitalZoomRatio] = extendedTags.value("capturing-digital-zoom-ratio"); - tags[QtMultimedia::ExposureTime] = extendedTags.value("capturing-shutter-speed"); - tags[QtMultimedia::WhiteBalance] = extendedTags.value("capturing-white-balance"); - tags[QtMultimedia::Flash] = extendedTags.value("capturing-flash-fired"); - tags[QtMultimedia::FocalLengthIn35mmFilm] = extendedTags.value("capturing-focal-length"); - tags[QtMultimedia::MeteringMode] = extendedTags.value("capturing-metering-mode"); - tags[QtMultimedia::ExposureMode] = extendedTags.value("capturing-exposure-mode"); - tags[QtMultimedia::FNumber] = extendedTags.value("capturing-focal-ratio"); - tags[QtMultimedia::ExposureMode] = extendedTags.value("capturing-exposure-mode"); - - QMapIterator<QtMultimedia::MetaData, QVariant> i(tags); - while (i.hasNext()) { - i.next(); - if (i.value().isValid()) { - QMetaObject::invokeMethod(self, "imageMetadataAvailable", - Qt::QueuedConnection, - Q_ARG(int, self->m_requestId), - Q_ARG(QtMultimedia::MetaData, i.key()), - Q_ARG(QVariant, i.value())); - } - } - } - - return true; -} - -gboolean CameraBinImageCapture::uncompressedBufferProbe(GstPad *pad, GstBuffer *buffer, CameraBinImageCapture *self) -{ - Q_UNUSED(pad); - CameraBinSession *session = self->m_session; - -#ifdef DEBUG_CAPTURE - qDebug() << "Uncompressed buffer probe" << gst_caps_to_string(GST_BUFFER_CAPS(buffer)); -#endif - - QCameraImageCapture::CaptureDestinations destination = - session->captureDestinationControl()->captureDestination(); - QVideoFrame::PixelFormat format = session->captureBufferFormatControl()->bufferFormat(); - - if (destination & QCameraImageCapture::CaptureToBuffer) { - if (format != QVideoFrame::Format_Jpeg) { - GstCaps *caps = GST_BUFFER_CAPS(buffer); - int bytesPerLine = -1; - QVideoSurfaceFormat format = QVideoSurfaceGstSink::formatForCaps(caps, &bytesPerLine); -#ifdef DEBUG_CAPTURE - qDebug() << "imageAvailable(uncompressed):" << format; -#endif - QGstVideoBuffer *videoBuffer = new QGstVideoBuffer(buffer, bytesPerLine); - - QVideoFrame frame(videoBuffer, - format.frameSize(), - format.pixelFormat()); - - QMetaObject::invokeMethod(self, "imageAvailable", - Qt::QueuedConnection, - Q_ARG(int, self->m_requestId), - Q_ARG(QVideoFrame, frame)); - } - } - - //keep the buffer if capture to file or jpeg buffer capture was reuqsted - bool keepBuffer = (destination & QCameraImageCapture::CaptureToFile) || - ((destination & QCameraImageCapture::CaptureToBuffer) && - format == QVideoFrame::Format_Jpeg); - - return keepBuffer; -} - -gboolean CameraBinImageCapture::jpegBufferProbe(GstPad *pad, GstBuffer *buffer, CameraBinImageCapture *self) -{ - Q_UNUSED(pad); - CameraBinSession *session = self->m_session; - -#ifdef DEBUG_CAPTURE - qDebug() << "Jpeg buffer probe" << gst_caps_to_string(GST_BUFFER_CAPS(buffer)); -#endif - - QCameraImageCapture::CaptureDestinations destination = - session->captureDestinationControl()->captureDestination(); - - if ((destination & QCameraImageCapture::CaptureToBuffer) && - session->captureBufferFormatControl()->bufferFormat() == QVideoFrame::Format_Jpeg) { - QGstVideoBuffer *videoBuffer = new QGstVideoBuffer(buffer, - -1); //bytesPerLine is not available for jpegs - - QSize resolution = QGstUtils::capsCorrectedResolution(GST_BUFFER_CAPS(buffer)); - //if resolution is not presented in caps, try to find it from encoded jpeg data: - if (resolution.isEmpty()) { - QBuffer data; - data.setData(reinterpret_cast<const char*>(GST_BUFFER_DATA(buffer)), GST_BUFFER_SIZE(buffer)); - QImageReader reader(&data, "JPEG"); - resolution = reader.size(); - } - - QVideoFrame frame(videoBuffer, - resolution, - QVideoFrame::Format_Jpeg); - - QMetaObject::invokeMethod(self, "imageAvailable", - Qt::QueuedConnection, - Q_ARG(int, self->m_requestId), - Q_ARG(QVideoFrame, frame)); - } - - //drop the buffer if capture to file was disabled - return destination & QCameraImageCapture::CaptureToFile; -} - -bool CameraBinImageCapture::processBusMessage(const QGstreamerMessage &message) -{ - //Install metadata event and buffer probes - - //The image capture pipiline is built dynamically, - //it's necessary to wait until jpeg encoder is added to pipeline - - GstMessage *gm = message.rawMessage(); - if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_STATE_CHANGED) { - GstState oldState; - GstState newState; - GstState pending; - gst_message_parse_state_changed(gm, &oldState, &newState, &pending); - - if (newState == GST_STATE_READY) { - GstElement *element = GST_ELEMENT(GST_MESSAGE_SRC(gm)); - if (!element) - return false; - - QString elementName = QString::fromLatin1(gst_element_get_name(element)); - if (elementName.contains("jpegenc") && element != m_jpegEncoderElement) { - m_jpegEncoderElement = element; - GstPad *sinkpad = gst_element_get_static_pad(element, "sink"); - - //metadata event probe is installed before jpeg encoder - //to emit metadata available signal as soon as possible. -#ifdef DEBUG_CAPTURE - qDebug() << "install metadata probe"; -#endif - gst_pad_add_event_probe(sinkpad, - G_CALLBACK(CameraBinImageCapture::metadataEventProbe), - this); - -#ifdef DEBUG_CAPTURE - qDebug() << "install uncompressed buffer probe"; -#endif - gst_pad_add_buffer_probe(sinkpad, - G_CALLBACK(CameraBinImageCapture::uncompressedBufferProbe), - this); - - gst_object_unref(sinkpad); - } else if ((elementName.contains("jifmux") || elementName.startsWith("metadatamux")) - && element != m_metadataMuxerElement) { - //Jpeg encoded buffer probe is added after jifmux/metadatamux - //element to ensure the resulting jpeg buffer contains capture metadata - m_metadataMuxerElement = element; - - GstPad *srcpad = gst_element_get_static_pad(element, "src"); -#ifdef DEBUG_CAPTURE - qDebug() << "install jpeg buffer probe"; -#endif - gst_pad_add_buffer_probe(srcpad, - G_CALLBACK(CameraBinImageCapture::jpegBufferProbe), - this); - gst_object_unref(srcpad); - } - } - } else if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT) { - if (GST_MESSAGE_SRC(gm) == (GstObject *)m_session->cameraBin()) { - const GstStructure *structure = gst_message_get_structure(gm); - - if (gst_structure_has_name (structure, "image-done")) { - const gchar *fileName = gst_structure_get_string (structure, "filename"); -#ifdef DEBUG_CAPTURE - qDebug() << "Image saved" << fileName; -#endif - - if (m_session->captureDestinationControl()->captureDestination() & QCameraImageCapture::CaptureToFile) { - emit imageSaved(m_requestId, QString::fromUtf8(fileName)); - } else { -#ifdef DEBUG_CAPTURE - qDebug() << Q_FUNC_INFO << "Dropped saving file" << fileName; -#endif - //camerabin creates an empty file when captured buffer is dropped, - //let's remove it - QFileInfo info(QString::fromUtf8(fileName)); - if (info.exists() && info.isFile() && info.size() == 0) { - QFile(info.absoluteFilePath()).remove(); - } - } - } - } - } - - return false; -} - diff --git a/src/plugins/gstreamer/camerabin/camerabinimagecapture.h b/src/plugins/gstreamer/camerabin/camerabinimagecapture.h deleted file mode 100644 index 4a902e9..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimagecapture.h +++ /dev/null @@ -1,83 +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 Toolkit. -** -** $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 CAMERABINIMAGECAPTURECONTROL_H -#define CAMERABINIMAGECAPTURECONTROL_H - -#include <qcameraimagecapturecontrol.h> -#include "camerabinsession.h" - -QT_USE_NAMESPACE - -class CameraBinImageCapture : public QCameraImageCaptureControl, public QGstreamerBusMessageFilter -{ - Q_OBJECT - Q_INTERFACES(QGstreamerBusMessageFilter) -public: - CameraBinImageCapture(CameraBinSession *session); - virtual ~CameraBinImageCapture(); - - QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; } - void setDriveMode(QCameraImageCapture::DriveMode) {} - - bool isReadyForCapture() const; - int capture(const QString &fileName); - void cancelCapture(); - - bool processBusMessage(const QGstreamerMessage &message); - -private slots: - void updateState(); - -private: - static gboolean metadataEventProbe(GstPad *pad, GstEvent *event, CameraBinImageCapture *); - static gboolean uncompressedBufferProbe(GstPad *pad, GstBuffer *buffer, CameraBinImageCapture *); - static gboolean jpegBufferProbe(GstPad *pad, GstBuffer *buffer, CameraBinImageCapture *); - - CameraBinSession *m_session; - bool m_ready; - int m_requestId; - GstElement *m_jpegEncoderElement; - GstElement *m_metadataMuxerElement; -}; - -#endif // CAMERABINCAPTURECORNTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinimageencoder.cpp b/src/plugins/gstreamer/camerabin/camerabinimageencoder.cpp deleted file mode 100644 index c020400..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimageencoder.cpp +++ /dev/null @@ -1,87 +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 Toolkit. -** -** $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 "camerabinimageencoder.h" -#include "camerabinsession.h" - -#include <QtCore/qdebug.h> - -CameraBinImageEncoder::CameraBinImageEncoder(CameraBinSession *session) - :QImageEncoderControl(session), m_session(session) -{ -} - -CameraBinImageEncoder::~CameraBinImageEncoder() -{ -} - -QList<QSize> CameraBinImageEncoder::supportedResolutions(const QImageEncoderSettings &, bool *continuous) const -{ - qDebug() << "CameraBinImageEncoder::supportedResolutions()"; - if (continuous) - *continuous = false; - - return m_session->supportedResolutions(qMakePair<int,int>(0,0), continuous, QCamera::CaptureStillImage); -} - -QStringList CameraBinImageEncoder::supportedImageCodecs() const -{ - return QStringList() << "jpeg"; -} - -QString CameraBinImageEncoder::imageCodecDescription(const QString &codecName) const -{ - if (codecName == "jpeg") - return tr("JPEG image"); - - return QString(); -} - -QImageEncoderSettings CameraBinImageEncoder::imageSettings() const -{ - return m_settings; -} - -void CameraBinImageEncoder::setImageSettings(const QImageEncoderSettings &settings) -{ - m_settings = settings; - emit settingsChanged(); -} diff --git a/src/plugins/gstreamer/camerabin/camerabinimageencoder.h b/src/plugins/gstreamer/camerabin/camerabinimageencoder.h deleted file mode 100644 index 6d49b2f..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimageencoder.h +++ /dev/null @@ -1,86 +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 Toolkit. -** -** $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 CAMERABINIMAGEENCODE_H -#define CAMERABINIMAGEENCODE_H - -class CameraBinSession; - -#include <qimageencodercontrol.h> - -#include <QtCore/qstringlist.h> -#include <QtCore/qmap.h> - -#include <gst/gst.h> -QT_USE_NAMESPACE - -class CameraBinImageEncoder : public QImageEncoderControl -{ - Q_OBJECT -public: - CameraBinImageEncoder(CameraBinSession *session); - virtual ~CameraBinImageEncoder(); - - QList<QSize> supportedResolutions(const QImageEncoderSettings &settings = QImageEncoderSettings(), - bool *continuous = 0) const; - - QStringList supportedImageCodecs() const; - QString imageCodecDescription(const QString &formatName) const; - - QImageEncoderSettings imageSettings() const; - void setImageSettings(const QImageEncoderSettings &settings); - -Q_SIGNALS: - void settingsChanged(); - -private: - QImageEncoderSettings m_settings; - - CameraBinSession *m_session; - - // Added - QStringList m_codecs; - QMap<QString,QByteArray> m_elementNames; - QMap<QString,QString> m_codecDescriptions; - QMap<QString,QStringList> m_codecOptions; -}; - -#endif diff --git a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp deleted file mode 100644 index b219146..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.cpp +++ /dev/null @@ -1,171 +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 Toolkit. -** -** $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 "camerabinimageprocessing.h" -#include "camerabinsession.h" - -CameraBinImageProcessing::CameraBinImageProcessing(CameraBinSession *session) - :QCameraImageProcessingControl(session), - m_session(session) -{ - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_AUTO] = QCameraImageProcessing::WhiteBalanceAuto; - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_DAYLIGHT] = QCameraImageProcessing::WhiteBalanceSunlight; - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_CLOUDY] = QCameraImageProcessing::WhiteBalanceCloudy; - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_SUNSET] = QCameraImageProcessing::WhiteBalanceSunset; - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_TUNGSTEN] = QCameraImageProcessing::WhiteBalanceTungsten; - m_mappedWbValues[GST_PHOTOGRAPHY_WB_MODE_FLUORESCENT] = QCameraImageProcessing::WhiteBalanceFluorescent; - - updateColorBalanceValues(); -} - -CameraBinImageProcessing::~CameraBinImageProcessing() -{ -} - -void CameraBinImageProcessing::updateColorBalanceValues() -{ - if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { - // Camerabin doesn't implement gstcolorbalance interface - return; - } - - GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); - const GList *controls = gst_color_balance_list_channels(balance); - - const GList *item; - GstColorBalanceChannel *channel; - gint cur_value; - - for (item = controls; item; item = g_list_next (item)) { - channel = (GstColorBalanceChannel *)item->data; - cur_value = gst_color_balance_get_value (balance, channel); - - if (!g_ascii_strcasecmp (channel->label, "brightness")) { - m_values[QCameraImageProcessingControl::Brightness] = cur_value; - } else if (!g_ascii_strcasecmp (channel->label, "contrast")) { - m_values[QCameraImageProcessingControl::Contrast] = cur_value; - } else if (!g_ascii_strcasecmp (channel->label, "saturation")) { - m_values[QCameraImageProcessingControl::Saturation] = cur_value; - } - } -} - -bool CameraBinImageProcessing::setColorBalanceValue(const QString& channel, int value) -{ - - if (!GST_IS_COLOR_BALANCE(m_session->cameraBin())) { - // Camerabin doesn't implement gstcolorbalance interface - return false; - } - - GstColorBalance *balance = GST_COLOR_BALANCE(m_session->cameraBin()); - const GList *controls = gst_color_balance_list_channels(balance); - - const GList *item; - GstColorBalanceChannel *colorBalanceChannel; - - for (item = controls; item; item = g_list_next (item)) { - colorBalanceChannel = (GstColorBalanceChannel *)item->data; - - if (!g_ascii_strcasecmp (colorBalanceChannel->label, channel.toAscii())) { - gst_color_balance_set_value (balance, colorBalanceChannel, value); - return true; - } - } - - return false; -} - -QCameraImageProcessing::WhiteBalanceMode CameraBinImageProcessing::whiteBalanceMode() const -{ - GstWhiteBalanceMode wbMode; - gst_photography_get_white_balance_mode(m_session->photography(), &wbMode); - return m_mappedWbValues[wbMode]; -} - -void CameraBinImageProcessing::setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode) -{ - if (isWhiteBalanceModeSupported(mode)) - gst_photography_set_white_balance_mode(m_session->photography(), m_mappedWbValues.key(mode)); -} - -bool CameraBinImageProcessing::isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const -{ - return m_mappedWbValues.values().contains(mode); -} - -bool CameraBinImageProcessing::isProcessingParameterSupported(QCameraImageProcessingControl::ProcessingParameter parameter) const -{ - return parameter == QCameraImageProcessingControl::Contrast - || parameter == QCameraImageProcessingControl::Brightness - || parameter == QCameraImageProcessingControl::Saturation; -} - -QVariant CameraBinImageProcessing::processingParameter( - QCameraImageProcessingControl::ProcessingParameter parameter) const -{ - if (m_values.contains(parameter)) - return m_values.value(parameter); - else - return QVariant(); -} - -void CameraBinImageProcessing::setProcessingParameter( - QCameraImageProcessingControl::ProcessingParameter parameter, - QVariant value) -{ - switch (parameter) { - case Contrast: - setColorBalanceValue("contrast", value.toInt()); - break; - case Brightness: - setColorBalanceValue("brightness", value.toInt()); - break; - case Saturation: - setColorBalanceValue("saturation", value.toInt()); - break; - default: - break; - } - - updateColorBalanceValues(); -} - diff --git a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h b/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h deleted file mode 100644 index ffee55b..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinimageprocessing.h +++ /dev/null @@ -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 Toolkit. -** -** $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 CAMERABINIMAGEPROCESSINGCONTROL_H -#define CAMERABINIMAGEPROCESSINGCONTROL_H - -#include <qcamera.h> -#include <qcameraimageprocessingcontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -#include <gst/interfaces/photography.h> -#include <gst/interfaces/colorbalance.h> - -class CameraBinSession; - -QT_USE_NAMESPACE - -class CameraBinImageProcessing : public QCameraImageProcessingControl -{ - Q_OBJECT - -public: - CameraBinImageProcessing(CameraBinSession *session); - virtual ~CameraBinImageProcessing(); - - QCameraImageProcessing::WhiteBalanceMode whiteBalanceMode() const; - void setWhiteBalanceMode(QCameraImageProcessing::WhiteBalanceMode mode); - bool isWhiteBalanceModeSupported(QCameraImageProcessing::WhiteBalanceMode mode) const; - - bool isProcessingParameterSupported(ProcessingParameter) const; - QVariant processingParameter(ProcessingParameter parameter) const; - void setProcessingParameter(ProcessingParameter parameter, QVariant value); - -private: - bool setColorBalanceValue(const QString& channel, int value); - void updateColorBalanceValues(); - -private: - CameraBinSession *m_session; - QMap<QCameraImageProcessingControl::ProcessingParameter, int> m_values; - QMap<GstWhiteBalanceMode, QCameraImageProcessing::WhiteBalanceMode> m_mappedWbValues; -}; - -#endif // CAMERABINIMAGEPROCESSINGCONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinlocks.cpp b/src/plugins/gstreamer/camerabin/camerabinlocks.cpp deleted file mode 100644 index cc0e3eb..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinlocks.cpp +++ /dev/null @@ -1,88 +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 Toolkit. -** -** $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 "camerabinlocks.h" -#include "camerabinsession.h" -#include "camerabinfocus.h" - -#include <gst/interfaces/photography.h> - -#include <QDebug> - -CameraBinLocks::CameraBinLocks(CameraBinSession *session) - :QCameraLocksControl(session), - m_session(session), - m_focus(m_session->cameraFocusControl()) -{ - connect(m_focus, SIGNAL(_q_focusStatusChanged(QCamera::LockStatus, QCamera::LockChangeReason)), - this, SLOT(updateFocusStatus(QCamera::LockStatus, QCamera::LockChangeReason))); -} - -CameraBinLocks::~CameraBinLocks() -{ -} - -QCamera::LockTypes CameraBinLocks::supportedLocks() const -{ - return QCamera::LockFocus; -} - -QCamera::LockStatus CameraBinLocks::lockStatus(QCamera::LockType lock) const -{ - return lock == QCamera::LockFocus ? m_focus->focusStatus() : QCamera::Unlocked; -} - -void CameraBinLocks::searchAndLock(QCamera::LockTypes locks) -{ - if (locks & QCamera::LockFocus) - m_focus->_q_startFocusing(); -} - -void CameraBinLocks::unlock(QCamera::LockTypes locks) -{ - if (locks & QCamera::LockFocus) - m_focus->_q_stopFocusing(); -} - -void CameraBinLocks::updateFocusStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason) -{ - emit lockStatusChanged(QCamera::LockFocus, status, reason); -} diff --git a/src/plugins/gstreamer/camerabin/camerabinlocks.h b/src/plugins/gstreamer/camerabin/camerabinlocks.h deleted file mode 100644 index 07cb9d1..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinlocks.h +++ /dev/null @@ -1,79 +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 Toolkit. -** -** $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 CAMERABINLOCKSCONTROL_H -#define CAMERABINLOCKSCONTROL_H - -#include <qcamera.h> -#include <qcameralockscontrol.h> - -#include <gst/gst.h> -#include <glib.h> - -class CameraBinSession; -class CameraBinFocus; - -QT_USE_NAMESPACE - -class CameraBinLocks : public QCameraLocksControl -{ - Q_OBJECT - -public: - CameraBinLocks(CameraBinSession *session); - virtual ~CameraBinLocks(); - - QCamera::LockTypes supportedLocks() const; - - QCamera::LockStatus lockStatus(QCamera::LockType lock) const; - - void searchAndLock(QCamera::LockTypes locks); - void unlock(QCamera::LockTypes locks); - -private slots: - void updateFocusStatus(QCamera::LockStatus status, QCamera::LockChangeReason reason); - -private: - CameraBinSession *m_session; - CameraBinFocus *m_focus; -}; - -#endif diff --git a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp b/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp deleted file mode 100644 index 235f5b0..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinmetadata.cpp +++ /dev/null @@ -1,198 +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 Toolkit. -** -** $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 "camerabinmetadata.h" - -#include <gst/gst.h> -#include <gst/gstversion.h> - -struct QGstreamerMetaDataKeyLookup -{ - QtMultimedia::MetaData key; - const char *token; -}; - -static const QGstreamerMetaDataKeyLookup qt_gstreamerMetaDataKeys[] = -{ - { QtMultimedia::Title, GST_TAG_TITLE }, - //{ QtMultimedia::SubTitle, 0 }, - //{ QtMultimedia::Author, 0 }, - { QtMultimedia::Comment, GST_TAG_COMMENT }, - { QtMultimedia::Description, GST_TAG_DESCRIPTION }, - //{ QtMultimedia::Category, 0 }, - { QtMultimedia::Genre, GST_TAG_GENRE }, - //{ QtMultimedia::Year, 0 }, - //{ QtMultimedia::UserRating, 0 }, - - { QtMultimedia::Language, GST_TAG_LANGUAGE_CODE }, - - { QtMultimedia::Publisher, GST_TAG_ORGANIZATION }, - { QtMultimedia::Copyright, GST_TAG_COPYRIGHT }, - //{ QtMultimedia::ParentalRating, 0 }, - //{ QtMultimedia::RatingOrganisation, 0 }, - - // Media - //{ QtMultimedia::Size, 0 }, - //{ QtMultimedia::MediaType, 0 }, - { QtMultimedia::Duration, GST_TAG_DURATION }, - - // Audio - { QtMultimedia::AudioBitRate, GST_TAG_BITRATE }, - { QtMultimedia::AudioCodec, GST_TAG_AUDIO_CODEC }, - //{ QtMultimedia::ChannelCount, 0 }, - //{ QtMultimedia::SampleRate, 0 }, - - // Music - { QtMultimedia::AlbumTitle, GST_TAG_ALBUM }, - { QtMultimedia::AlbumArtist, GST_TAG_ARTIST}, - { QtMultimedia::ContributingArtist, GST_TAG_PERFORMER }, -#if (GST_VERSION_MAJOR >= 0) && (GST_VERSION_MINOR >= 10) && (GST_VERSION_MICRO >= 19) - { QtMultimedia::Composer, GST_TAG_COMPOSER }, -#endif - //{ QtMultimedia::Conductor, 0 }, - //{ QtMultimedia::Lyrics, 0 }, - //{ QtMultimedia::Mood, 0 }, - { QtMultimedia::TrackNumber, GST_TAG_TRACK_NUMBER }, - - //{ QtMultimedia::CoverArtUrlSmall, 0 }, - //{ QtMultimedia::CoverArtUrlLarge, 0 }, - - // Image/Video - //{ QtMultimedia::Resolution, 0 }, - //{ QtMultimedia::PixelAspectRatio, 0 }, - - // Video - //{ QtMultimedia::VideoFrameRate, 0 }, - //{ QtMultimedia::VideoBitRate, 0 }, - { QtMultimedia::VideoCodec, GST_TAG_VIDEO_CODEC }, - - //{ QtMultimedia::PosterUrl, 0 }, - - // Movie - //{ QtMultimedia::ChapterNumber, 0 }, - //{ QtMultimedia::Director, 0 }, - { QtMultimedia::LeadPerformer, GST_TAG_PERFORMER }, - //{ QtMultimedia::Writer, 0 }, - - // Photos - //{ QtMultimedia::CameraManufacturer, 0 }, - //{ QtMultimedia::CameraModel, 0 }, - //{ QtMultimedia::Event, 0 }, - //{ QtMultimedia::Subject, 0 } -}; - -CameraBinMetaData::CameraBinMetaData(QObject *parent) - :QMetaDataWriterControl(parent) -{ -} - -QVariant CameraBinMetaData::metaData(QtMultimedia::MetaData key) const -{ - static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); - - for (int i = 0; i < count; ++i) { - if (qt_gstreamerMetaDataKeys[i].key == key) { - const char *name = qt_gstreamerMetaDataKeys[i].token; - - return m_values.value(QByteArray::fromRawData(name, qstrlen(name))); - } - } - return QVariant(); -} - -void CameraBinMetaData::setMetaData(QtMultimedia::MetaData key, const QVariant &value) -{ - static const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); - - for (int i = 0; i < count; ++i) { - if (qt_gstreamerMetaDataKeys[i].key == key) { - const char *name = qt_gstreamerMetaDataKeys[i].token; - - m_values.insert(QByteArray::fromRawData(name, qstrlen(name)), value); - - emit QMetaDataWriterControl::metaDataChanged(); - emit metaDataChanged(m_values); - - return; - } - } -} - -QList<QtMultimedia::MetaData> CameraBinMetaData::availableMetaData() const -{ - static QMap<QByteArray, QtMultimedia::MetaData> keysMap; - if (keysMap.isEmpty()) { - const int count = sizeof(qt_gstreamerMetaDataKeys) / sizeof(QGstreamerMetaDataKeyLookup); - for (int i = 0; i < count; ++i) { - keysMap[QByteArray(qt_gstreamerMetaDataKeys[i].token)] = qt_gstreamerMetaDataKeys[i].key; - } - } - - QList<QtMultimedia::MetaData> res; - foreach (const QByteArray &key, m_values.keys()) { - QtMultimedia::MetaData tag = keysMap.value(key, QtMultimedia::MetaData(-1)); - if (tag != -1) - res.append(tag); - } - - return res; -} - -QVariant CameraBinMetaData::extendedMetaData(QString const &name) const -{ - return m_values.value(name.toLatin1()); -} - -void CameraBinMetaData::setExtendedMetaData(QString const &name, QVariant const &value) -{ - m_values.insert(name.toLatin1(), value); - emit QMetaDataWriterControl::metaDataChanged(); - emit metaDataChanged(m_values); -} - -QStringList CameraBinMetaData::availableExtendedMetaData() const -{ - QStringList res; - foreach (const QByteArray &key, m_values.keys()) - res.append(QString(key)); - - return res; -} diff --git a/src/plugins/gstreamer/camerabin/camerabinmetadata.h b/src/plugins/gstreamer/camerabin/camerabinmetadata.h deleted file mode 100644 index 16a86a6..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinmetadata.h +++ /dev/null @@ -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 Toolkit. -** -** $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 CAMERABINCAPTUREMETADATACONTROL_H -#define CAMERABINCAPTUREMETADATACONTROL_H - -#include <qmetadatawritercontrol.h> - -QT_USE_NAMESPACE - -class CameraBinMetaData : public QMetaDataWriterControl -{ - Q_OBJECT -public: - CameraBinMetaData(QObject *parent); - virtual ~CameraBinMetaData() {} - - - bool isMetaDataAvailable() const { return true; } - bool isWritable() const { return true; } - - QVariant metaData(QtMultimedia::MetaData key) const; - void setMetaData(QtMultimedia::MetaData key, const QVariant &value); - QList<QtMultimedia::MetaData> availableMetaData() const; - - QVariant extendedMetaData(QString const &name) const; - void setExtendedMetaData(QString const &name, QVariant const &value); - QStringList availableExtendedMetaData() const; - -Q_SIGNALS: - void metaDataChanged(const QMap<QByteArray, QVariant>&); - -private: - QMap<QByteArray, QVariant> m_values; -}; - -#endif // CAMERABINCAPTUREMETADATACONTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinrecorder.cpp b/src/plugins/gstreamer/camerabin/camerabinrecorder.cpp deleted file mode 100644 index ff97c3f..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinrecorder.cpp +++ /dev/null @@ -1,139 +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 Toolkit. -** -** $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 "camerabinrecorder.h" -#include "camerabinaudioencoder.h" -#include "camerabinvideoencoder.h" -#include "camerabincontainer.h" -#include <QtCore/QDebug> - -#include <gst/pbutils/encoding-profile.h> - -CameraBinRecorder::CameraBinRecorder(CameraBinSession *session) - :QMediaRecorderControl(session), - m_session(session), - m_state(QMediaRecorder::StoppedState) -{ - connect(m_session, SIGNAL(stateChanged(QCamera::State)), SLOT(updateState())); - connect(m_session, SIGNAL(durationChanged(qint64)), SIGNAL(durationChanged(qint64))); - connect(m_session, SIGNAL(mutedChanged(bool)), this, SIGNAL(mutedChanged(bool))); -} - -CameraBinRecorder::~CameraBinRecorder() -{ -} - -QUrl CameraBinRecorder::outputLocation() const -{ - return m_session->outputLocation(); -} - -bool CameraBinRecorder::setOutputLocation(const QUrl &sink) -{ - m_session->setOutputLocation(sink); - return true; -} - -QMediaRecorder::State CameraBinRecorder::state() const -{ - return m_state; -} - -void CameraBinRecorder::updateState() -{ - if (m_session->state() != QCamera::ActiveState && - m_state != QMediaRecorder::StoppedState) { - m_session->stopVideoRecording(); - emit stateChanged(m_state = QMediaRecorder::StoppedState); - } -} - -qint64 CameraBinRecorder::duration() const -{ - return m_session->duration(); -} - -void CameraBinRecorder::record() -{ - if (m_session->state() == QCamera::ActiveState) { - m_session->recordVideo(); - emit stateChanged(m_state = QMediaRecorder::RecordingState); - } else - emit error(QMediaRecorder::ResourceError, tr("Service has not been started")); -} - -void CameraBinRecorder::pause() -{ - emit error(QMediaRecorder::ResourceError, tr("QMediaRecorder::pause() is not supported by camerabin2.")); -} - -void CameraBinRecorder::stop() -{ - if (m_session->state() == QCamera::ActiveState) { - m_session->stopVideoRecording(); - emit stateChanged(m_state = QMediaRecorder::StoppedState); - } -} - -void CameraBinRecorder::applySettings() -{ - GstEncodingContainerProfile *containerProfile = m_session->mediaContainerControl()->createProfile(); - - if (containerProfile) { - GstEncodingProfile *audioProfile = m_session->audioEncodeControl()->createProfile(); - GstEncodingProfile *videoProfile = m_session->videoEncodeControl()->createProfile(); - - gst_encoding_container_profile_add_profile(containerProfile, audioProfile); - gst_encoding_container_profile_add_profile(containerProfile, videoProfile); - } - - g_object_set (G_OBJECT(m_session->cameraBin()), "video-profile", containerProfile, NULL); -} - -bool CameraBinRecorder::isMuted() const -{ - return m_session->isMuted(); -} - -void CameraBinRecorder::setMuted(bool muted) -{ - m_session->setMuted(muted); -} diff --git a/src/plugins/gstreamer/camerabin/camerabinrecorder.h b/src/plugins/gstreamer/camerabin/camerabinrecorder.h deleted file mode 100644 index f68c4ee..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinrecorder.h +++ /dev/null @@ -1,83 +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 Toolkit. -** -** $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 CAMERABINRECORDERCONTROL_H -#define CAMERABINRECORDERCONTROL_H - -#include <qmediarecordercontrol.h> -#include "camerabinsession.h" -QT_USE_NAMESPACE - -class CameraBinRecorder : public QMediaRecorderControl -{ - Q_OBJECT - -public: - CameraBinRecorder(CameraBinSession *session); - virtual ~CameraBinRecorder(); - - QUrl outputLocation() const; - bool setOutputLocation(const QUrl &sink); - - QMediaRecorder::State state() const; - - qint64 duration() const; - - bool isMuted() const; - - void applySettings(); - -public slots: - void record(); - void pause(); - void stop(); - void setMuted(bool); - -private slots: - void updateState(); - -private: - CameraBinSession *m_session; - QMediaRecorder::State m_state; -}; - -#endif // CAMERABINCAPTURECORNTROL_H diff --git a/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.cpp b/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.cpp deleted file mode 100644 index df5583d..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.cpp +++ /dev/null @@ -1,184 +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 Toolkit. -** -** $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 "camerabinresourcepolicy.h" - -//#define DEBUG_RESOURCE_POLICY -#include <QtCore/qdebug.h> -#include <QtCore/qset.h> - -#ifdef HAVE_RESOURCE_POLICY -#include <policy/resource.h> -#include <policy/resources.h> -#include <policy/resource-set.h> -#endif - -CamerabinResourcePolicy::CamerabinResourcePolicy(QObject *parent) : - QObject(parent), - m_resourceSet(NoResources), - m_releasingResources(false) -{ -#ifdef HAVE_RESOURCE_POLICY - //loaded resource set is also kept requested for image and video capture sets - m_resource = new ResourcePolicy::ResourceSet("camera"); - m_resource->setAlwaysReply(); - m_resource->initAndConnect(); - - connect(m_resource, SIGNAL(resourcesGranted(const QList<ResourcePolicy::ResourceType>)), - SIGNAL(resourcesGranted())); - connect(m_resource, SIGNAL(resourcesDenied()), SIGNAL(resourcesDenied())); - connect(m_resource, SIGNAL(lostResources()), SIGNAL(resourcesLost())); - connect(m_resource, SIGNAL(resourcesReleased()), SLOT(handleResourcesReleased())); -#endif -} - -CamerabinResourcePolicy::~CamerabinResourcePolicy() -{ -#ifdef HAVE_RESOURCE_POLICY - //ensure the resources are released - if (m_resourceSet != NoResources) - setResourceSet(NoResources); - - //don't delete the resource set until resources are released - if (m_releasingResources) { - m_resource->connect(m_resource, SIGNAL(resourcesReleased()), - SLOT(deleteLater())); - } else { - delete m_resource; - m_resource = 0; - } -#endif -} - -CamerabinResourcePolicy::ResourceSet CamerabinResourcePolicy::resourceSet() const -{ - return m_resourceSet; -} - -void CamerabinResourcePolicy::setResourceSet(CamerabinResourcePolicy::ResourceSet set) -{ - CamerabinResourcePolicy::ResourceSet oldSet = m_resourceSet; - m_resourceSet = set; - -#ifdef DEBUG_RESOURCE_POLICY - qDebug() << Q_FUNC_INFO << set; -#endif - -#ifdef HAVE_RESOURCE_POLICY - QSet<ResourcePolicy::ResourceType> requestedTypes; - - switch (set) { - case NoResources: - break; - case LoadedResources: - requestedTypes << ResourcePolicy::LensCoverType //to detect lens cover is opened/closed - << ResourcePolicy::VideoRecorderType //to open camera device - << ResourcePolicy::SnapButtonType; //to detect capture button events - break; - case ImageCaptureResources: - requestedTypes << ResourcePolicy::LensCoverType - << ResourcePolicy::VideoPlaybackType - << ResourcePolicy::VideoRecorderType - << ResourcePolicy::AudioPlaybackType - << ResourcePolicy::ScaleButtonType - << ResourcePolicy::LedsType - << ResourcePolicy::SnapButtonType; - break; - case VideoCaptureResources: - requestedTypes << ResourcePolicy::LensCoverType - << ResourcePolicy::VideoPlaybackType - << ResourcePolicy::VideoRecorderType - << ResourcePolicy::AudioPlaybackType - << ResourcePolicy::AudioRecorderType - << ResourcePolicy::ScaleButtonType - << ResourcePolicy::LedsType - << ResourcePolicy::SnapButtonType; - break; - } - - QSet<ResourcePolicy::ResourceType> currentTypes; - foreach (ResourcePolicy::Resource *resource, m_resource->resources()) - currentTypes << resource->type(); - - foreach (ResourcePolicy::ResourceType resourceType, currentTypes - requestedTypes) - m_resource->deleteResource(resourceType); - - foreach (ResourcePolicy::ResourceType resourceType, requestedTypes - currentTypes) { - if (resourceType == ResourcePolicy::LensCoverType) { - ResourcePolicy::LensCoverResource *lensCoverResource = new ResourcePolicy::LensCoverResource; - lensCoverResource->setOptional(true); - m_resource->addResourceObject(lensCoverResource); - } else { - m_resource->addResource(resourceType); - } - } - - m_resource->update(); - if (set != NoResources) { - m_resource->acquire(); - } else { - if (oldSet != NoResources) { - m_releasingResources = true; - m_resource->release(); - } - } -#endif -} - -bool CamerabinResourcePolicy::isResourcesGranted() const -{ -#ifdef HAVE_RESOURCE_POLICY - foreach (ResourcePolicy::Resource *resource, m_resource->resources()) - if (!resource->isOptional() && !resource->isGranted()) - return false; -#endif - return true; -} - -void CamerabinResourcePolicy::handleResourcesReleased() -{ -#ifdef HAVE_RESOURCE_POLICY -#ifdef DEBUG_RESOURCE_POLICY - qDebug() << Q_FUNC_INFO; -#endif - m_releasingResources = false; -#endif -} diff --git a/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.h b/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.h deleted file mode 100644 index bd483bf..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinresourcepolicy.h +++ /dev/null @@ -1,84 +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 Toolkit. -** -** $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 CAMERARESOURCEPOLICY_H -#define CAMERARESOURCEPOLICY_H - -#include <QtCore/qobject.h> - -namespace ResourcePolicy { -class ResourceSet; -}; - -class CamerabinResourcePolicy : public QObject -{ - Q_OBJECT -public: - enum ResourceSet { - NoResources, - LoadedResources, - ImageCaptureResources, - VideoCaptureResources - }; - - CamerabinResourcePolicy(QObject *parent); - ~CamerabinResourcePolicy(); - - ResourceSet resourceSet() const; - void setResourceSet(ResourceSet set); - - bool isResourcesGranted() const; - -Q_SIGNALS: - void resourcesDenied(); - void resourcesGranted(); - void resourcesLost(); - -private Q_SLOTS: - void handleResourcesReleased(); - -private: - ResourceSet m_resourceSet; - ResourcePolicy::ResourceSet *m_resource; - bool m_releasingResources; -}; - -#endif diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.cpp b/src/plugins/gstreamer/camerabin/camerabinservice.cpp deleted file mode 100644 index f0aaca7..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinservice.cpp +++ /dev/null @@ -1,250 +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 Toolkit. -** -** $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 "camerabinservice.h" -#include "camerabinsession.h" -#include "camerabinrecorder.h" -#include "camerabincontainer.h" -#include "camerabinaudioencoder.h" -#include "camerabinvideoencoder.h" -#include "camerabinimageencoder.h" -#include "camerabincontrol.h" -#include "camerabinlocks.h" -#include "camerabinmetadata.h" -#include "camerabinexposure.h" -#include "camerabinflash.h" -#include "camerabinfocus.h" -#include "camerabinimagecapture.h" -#include "camerabinimageprocessing.h" -#include "camerabincapturebufferformat.h" -#include "camerabincapturedestination.h" -#include <private/qgstreamerbushelper_p.h> - -#include "qgstreameraudioinputendpointselector.h" -#include "qgstreamervideoinputdevicecontrol.h" - -#include "qgstreamervideooverlay.h" -#include "qgstreamervideowindow.h" -#include "qgstreamervideorenderer.h" - -#if defined(Q_WS_MAEMO_6) && defined(__arm__) -#include "qgstreamergltexturerenderer.h" -#endif - -#include "qgstreamervideowidget.h" - -#include <qmediaserviceprovider.h> - -#include <QtCore/qdebug.h> -#include <QtCore/qprocess.h> - -#if defined(Q_WS_MAEMO_6) -#include "camerabuttonlistener_meego.h" -#endif - -CameraBinService::CameraBinService(const QString &service, QObject *parent): - QMediaService(parent) -{ - m_captureSession = 0; - m_cameraControl = 0; - m_metaDataControl = 0; - - m_audioInputEndpointSelector = 0; - m_videoInputDevice = 0; - - m_videoOutput = 0; - m_videoRenderer = 0; - m_videoWindow = 0; - m_videoWidgetControl = 0; - m_imageCaptureControl = 0; - - if (service == Q_MEDIASERVICE_CAMERA) { - m_captureSession = new CameraBinSession(this); - m_cameraControl = new CameraBinControl(m_captureSession); - m_videoInputDevice = new QGstreamerVideoInputDeviceControl(m_captureSession); - m_imageCaptureControl = new CameraBinImageCapture(m_captureSession); - - connect(m_videoInputDevice, SIGNAL(selectedDeviceChanged(QString)), - m_captureSession, SLOT(setDevice(QString))); - - if (m_videoInputDevice->deviceCount()) - m_captureSession->setDevice(m_videoInputDevice->deviceName(m_videoInputDevice->selectedDevice())); - -#if defined(Q_WS_MAEMO_6) && defined(__arm__) - m_videoRenderer = new QGstreamerGLTextureRenderer(this); -#else - m_videoRenderer = new QGstreamerVideoRenderer(this); -#endif - -#if defined(Q_WS_X11) && !defined(QT_NO_XVIDEO) - -#ifdef Q_WS_MAEMO_6 - m_videoWindow = new QGstreamerVideoWindow(this, "omapxvsink"); - //m_videoWindow = new QGstreamerVideoWindow(this); -#else - m_videoWindow = new QGstreamerVideoOverlay(this); -#endif - - m_videoWidgetControl = new QGstreamerVideoWidgetControl(this); - -#endif - - } - - if (!m_captureSession) { - qWarning() << Q_FUNC_INFO << "Service type is not supported:" << service; - return; - } - - m_audioInputEndpointSelector = new QGstreamerAudioInputEndpointSelector(this); - connect(m_audioInputEndpointSelector, SIGNAL(activeEndpointChanged(QString)), m_captureSession, SLOT(setCaptureDevice(QString))); - - if (m_captureSession && m_audioInputEndpointSelector->availableEndpoints().size() > 0) - m_captureSession->setCaptureDevice(m_audioInputEndpointSelector->defaultEndpoint()); - - m_metaDataControl = new CameraBinMetaData(this); - connect(m_metaDataControl, SIGNAL(metaDataChanged(QMap<QByteArray,QVariant>)), - m_captureSession, SLOT(setMetaData(QMap<QByteArray,QVariant>))); - -#if defined(Q_WS_MAEMO_6) - new CameraButtonListener(this); -#endif -} - -CameraBinService::~CameraBinService() -{ -} - -QMediaControl *CameraBinService::requestControl(const char *name) -{ - if (!m_captureSession) - return 0; - - //qDebug() << "Request control" << name; - - if (!m_videoOutput) { - if (qstrcmp(name, QVideoRendererControl_iid) == 0) { - m_videoOutput = m_videoRenderer; - } else if (qstrcmp(name, QVideoWindowControl_iid) == 0) { - m_videoOutput = m_videoWindow; - } else if (qstrcmp(name, QVideoWidgetControl_iid) == 0) { - m_videoOutput = m_videoWidgetControl; - } - - if (m_videoOutput) { - m_captureSession->setViewfinder(m_videoOutput); - return m_videoOutput; - } - } - - if (qstrcmp(name,QAudioEndpointSelector_iid) == 0) - return m_audioInputEndpointSelector; - - if (qstrcmp(name,QVideoDeviceControl_iid) == 0) - return m_videoInputDevice; - - if (qstrcmp(name,QMediaRecorderControl_iid) == 0) - return m_captureSession->recorderControl(); - - if (qstrcmp(name,QAudioEncoderControl_iid) == 0) - return m_captureSession->audioEncodeControl(); - - if (qstrcmp(name,QVideoEncoderControl_iid) == 0) - return m_captureSession->videoEncodeControl(); - - if (qstrcmp(name,QImageEncoderControl_iid) == 0) - return m_captureSession->imageEncodeControl(); - - - if (qstrcmp(name,QMediaContainerControl_iid) == 0) - return m_captureSession->mediaContainerControl(); - - if (qstrcmp(name,QCameraControl_iid) == 0) - return m_cameraControl; - - if (qstrcmp(name,QMetaDataWriterControl_iid) == 0) - return m_metaDataControl; - - if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0) - return m_imageCaptureControl; - - if (qstrcmp(name, QCameraExposureControl_iid) == 0) - return m_captureSession->cameraExposureControl(); - - if (qstrcmp(name, QCameraFlashControl_iid) == 0) - return m_captureSession->cameraFlashControl(); - - if (qstrcmp(name, QCameraFocusControl_iid) == 0) - return m_captureSession->cameraFocusControl(); - - if (qstrcmp(name, QCameraImageProcessingControl_iid) == 0) - return m_captureSession->imageProcessingControl(); - - if (qstrcmp(name, QCameraLocksControl_iid) == 0) - return m_captureSession->cameraLocksControl(); - - if (qstrcmp(name, QCameraCaptureDestinationControl_iid) == 0) - return m_captureSession->captureDestinationControl(); - - if (qstrcmp(name, QCameraCaptureBufferFormatControl_iid) == 0) - return m_captureSession->captureBufferFormatControl(); - - return 0; -} - -void CameraBinService::releaseControl(QMediaControl *control) -{ - if (control && control == m_videoOutput) { - m_videoOutput = 0; - m_captureSession->setViewfinder(0); - } -} - -bool CameraBinService::isCameraBinAvailable() -{ - GstElementFactory *factory = gst_element_factory_find("camerabin2"); - if (factory) { - gst_object_unref(GST_OBJECT(factory)); - return true; - } - - return false; -} diff --git a/src/plugins/gstreamer/camerabin/camerabinservice.h b/src/plugins/gstreamer/camerabin/camerabinservice.h deleted file mode 100644 index 5513dd8..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinservice.h +++ /dev/null @@ -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 Toolkit. -** -** $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 CAMERABINCAPTURESERVICE_H -#define CAMERABINCAPTURESERVICE_H - -#include <qmediaservice.h> - -#include <gst/gst.h> -QT_BEGIN_NAMESPACE -class QAudioEndpointSelector; -class QVideoDeviceControl; -QT_END_NAMESPACE - -class CameraBinSession; -class CameraBinControl; -class QGstreamerMessage; -class QGstreamerBusHelper; -class QGstreamerVideoRenderer; -class QGstreamerVideoOverlay; -class QGstreamerVideoWidgetControl; -class QGstreamerElementFactory; -class CameraBinMetaData; -class CameraBinImageCapture; -class CameraBinMetaData; - -class CameraBinService : public QMediaService -{ - Q_OBJECT - -public: - CameraBinService(const QString &service, QObject *parent = 0); - virtual ~CameraBinService(); - - QMediaControl *requestControl(const char *name); - void releaseControl(QMediaControl *); - - static bool isCameraBinAvailable(); - -private: - void setAudioPreview(GstElement*); - - CameraBinSession *m_captureSession; - CameraBinControl *m_cameraControl; - CameraBinMetaData *m_metaDataControl; - - QAudioEndpointSelector *m_audioInputEndpointSelector; - QVideoDeviceControl *m_videoInputDevice; - - QMediaControl *m_videoOutput; - - QMediaControl *m_videoRenderer; - QMediaControl *m_videoWindow; - QGstreamerVideoWidgetControl *m_videoWidgetControl; - CameraBinImageCapture *m_imageCaptureControl; -}; - -#endif // CAMERABINCAPTURESERVICE_H diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.cpp b/src/plugins/gstreamer/camerabin/camerabinsession.cpp deleted file mode 100644 index 996e149..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinsession.cpp +++ /dev/null @@ -1,1216 +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 Toolkit. -** -** $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 "camerabinsession.h" -#include "camerabinrecorder.h" -#include "camerabincontainer.h" -#include "camerabinaudioencoder.h" -#include "camerabinvideoencoder.h" -#include "camerabinimageencoder.h" -#include "camerabinexposure.h" -#include "camerabinflash.h" -#include "camerabinfocus.h" -#include "camerabinimageprocessing.h" -#include "camerabinlocks.h" -#include "camerabincapturedestination.h" -#include "camerabincapturebufferformat.h" -#include <private/qgstreamerbushelper_p.h> -#include "qgstreamervideorendererinterface.h" -#include <qmediarecorder.h> -#include <gst/interfaces/photography.h> -#include <gst/gsttagsetter.h> -#include <gst/gstversion.h> - -#include <QtCore/qdebug.h> -#include <QCoreApplication> -#include <QtCore/qmetaobject.h> -#include <QtGui/qdesktopservices.h> - -#include <QtGui/qimage.h> - -//#define CAMERABIN_DEBUG 1 -//#define CAMERABIN_DEBUG_DUMP_BIN 1 -#define ENUM_NAME(c,e,v) (c::staticMetaObject.enumerator(c::staticMetaObject.indexOfEnumerator(e)).valueToKey((v))) - -#define FILENAME_PROPERTY "location" -#define MODE_PROPERTY "mode" -#define MUTE_PROPERTY "mute" -#define IMAGE_PP_PROPERTY "image-post-processing" -#define IMAGE_ENCODER_PROPERTY "image-encoder" -#define VIDEO_PP_PROPERTY "video-post-processing" -#define VIEWFINDER_SINK_PROPERTY "viewfinder-sink" -#define CAMERA_SOURCE_PROPERTY "camera-source" -#define AUDIO_SOURCE_PROPERTY "audio-source" -#define SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY "image-capture-supported-caps" -#define SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY "video-capture-supported-caps" -#define FILTER_CAPS_PROPERTY "filter-caps" -#define PREVIEW_CAPS_PROPERTY "preview-caps" - -#define CAPTURE_START "start-capture" -#define CAPTURE_STOP "stop-capture" -#define SET_VIDEO_RESOLUTION_FPS "set-video-resolution-fps" -#define SET_IMAGE_RESOLUTION "set-image-resolution" - -#define CAMERABIN_IMAGE_MODE 1 -#define CAMERABIN_VIDEO_MODE 2 - -#define gstRef(element) { gst_object_ref(GST_OBJECT(element)); gst_object_sink(GST_OBJECT(element)); } -#define gstUnref(element) { if (element) { gst_object_unref(GST_OBJECT(element)); element = 0; } } - -#define PREVIEW_CAPS_4_3 \ - "video/x-raw-rgb, width = (int) 640, height = (int) 480" - -#define VIEWFINDER_RESOLUTION_4x3 QSize(640, 480) -#define VIEWFINDER_RESOLUTION_3x2 QSize(720, 480) -#define VIEWFINDER_RESOLUTION_16x9 QSize(800, 450) - -//using GST_STATE_READY for QCamera::LoadedState -//may not work reliably at least with some webcams. - -//#define USE_READY_STATE_ON_LOADED - - -CameraBinSession::CameraBinSession(QObject *parent) - :QObject(parent), - m_recordingActive(false), - m_state(QCamera::UnloadedState), - m_pendingState(QCamera::UnloadedState), - m_pendingResolutionUpdate(false), - m_muted(false), - m_busy(false), - m_captureMode(QCamera::CaptureStillImage), - m_audioInputFactory(0), - m_videoInputFactory(0), - m_viewfinder(0), - m_viewfinderInterface(0), - m_videoSrc(0), - m_viewfinderElement(0), - m_viewfinderHasChanged(true), - m_videoInputHasChanged(true), - m_audioSrc(0), - m_audioConvert(0), - m_capsFilter(0), - m_fileSink(0), - m_audioEncoder(0), - m_muxer(0) -{ - m_camerabin = gst_element_factory_make("camerabin2", "camerabin2"); - g_signal_connect(G_OBJECT(m_camerabin), "notify::idle", G_CALLBACK(updateBusyStatus), this); - gstRef(m_camerabin); - - m_bus = gst_element_get_bus(m_camerabin); - - m_busHelper = new QGstreamerBusHelper(m_bus, this); - m_busHelper->installMessageFilter(this); - - m_audioEncodeControl = new CameraBinAudioEncoder(this); - m_videoEncodeControl = new CameraBinVideoEncoder(this); - m_imageEncodeControl = new CameraBinImageEncoder(this); - m_recorderControl = new CameraBinRecorder(this); - m_mediaContainerControl = new CameraBinContainer(this); - m_cameraExposureControl = new CameraBinExposure(this); - m_cameraFlashControl = new CameraBinFlash(this); - m_cameraFocusControl = new CameraBinFocus(this); - m_imageProcessingControl = new CameraBinImageProcessing(this); - m_cameraLocksControl = new CameraBinLocks(this); - m_captureDestinationControl = new CameraBinCaptureDestination(this); - m_captureBufferFormatControl = new CameraBinCaptureBufferFormat(this); - - //post image preview in RGB format - GstCaps *previewCaps = gst_caps_from_string("video/x-raw-rgb"); - g_object_set(G_OBJECT(m_camerabin), PREVIEW_CAPS_PROPERTY, previewCaps, NULL); - gst_caps_unref(previewCaps); -} - -CameraBinSession::~CameraBinSession() -{ - if (m_camerabin) { - if (m_viewfinderInterface) - m_viewfinderInterface->stopRenderer(); - - gst_element_set_state(m_camerabin, GST_STATE_NULL); - gst_element_get_state(m_camerabin, NULL, NULL, GST_CLOCK_TIME_NONE); - gstUnref(m_camerabin); - gstUnref(m_viewfinderElement); - } -} - -GstPhotography *CameraBinSession::photography() -{ - if (GST_IS_PHOTOGRAPHY(m_camerabin)) { - return GST_PHOTOGRAPHY(m_camerabin); - } - - if (!m_videoSrc) { - m_videoSrc = buildCameraSource(); - - if (m_videoSrc) - g_object_set(m_camerabin, CAMERA_SOURCE_PROPERTY, m_videoSrc, NULL); - else - g_object_get(m_camerabin, CAMERA_SOURCE_PROPERTY, &m_videoSrc, NULL); - - m_videoInputHasChanged = false; - } - - if (m_videoSrc && GST_IS_PHOTOGRAPHY(m_videoSrc)) - return GST_PHOTOGRAPHY(m_videoSrc); - - return 0; -} - -CameraBinSession::CameraRole CameraBinSession::cameraRole() const -{ - return BackCamera; -} - -/* - Configure camera during Loaded->Active states stansition. -*/ -bool CameraBinSession::setupCameraBin() -{ - if (m_videoInputHasChanged) { - m_videoSrc = buildCameraSource(); - - if (m_videoSrc) - g_object_set(m_camerabin, CAMERA_SOURCE_PROPERTY, m_videoSrc, NULL); - else - g_object_get(m_camerabin, CAMERA_SOURCE_PROPERTY, &m_videoSrc, NULL); - - m_videoInputHasChanged = false; - } - - - if (m_viewfinderHasChanged) { - if (m_viewfinderElement) - gst_object_unref(GST_OBJECT(m_viewfinderElement)); - - m_viewfinderElement = m_viewfinderInterface ? m_viewfinderInterface->videoSink() : 0; -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << "Viewfinder changed, reconfigure."; -#endif - m_viewfinderHasChanged = false; - if (!m_viewfinderElement) { - qWarning() << "Staring camera without viewfinder available"; - m_viewfinderElement = gst_element_factory_make("fakesink", NULL); - } - gst_object_ref(GST_OBJECT(m_viewfinderElement)); - gst_element_set_state(m_camerabin, GST_STATE_NULL); - g_object_set(G_OBJECT(m_camerabin), VIEWFINDER_SINK_PROPERTY, m_viewfinderElement, NULL); - } - - return true; -} - -static GstCaps *resolutionToCaps(const QSize &resolution, - const QPair<int, int> &rate = qMakePair<int,int>(0,0)) -{ - if (resolution.isEmpty()) - return gst_caps_new_any(); - - GstCaps *caps = 0; - if (rate.second > 0) { - caps = gst_caps_new_full(gst_structure_new("video/x-raw-yuv", - "width", G_TYPE_INT, resolution.width(), - "height", G_TYPE_INT, resolution.height(), - "framerate", GST_TYPE_FRACTION, rate.first, rate.second, - NULL), - gst_structure_new("video/x-raw-rgb", - "width", G_TYPE_INT, resolution.width(), - "height", G_TYPE_INT, resolution.height(), - "framerate", GST_TYPE_FRACTION, rate.first, rate.second, - NULL), NULL); - } else { - caps = gst_caps_new_full (gst_structure_new ("video/x-raw-yuv", - "width", G_TYPE_INT, resolution.width(), - "height", G_TYPE_INT, resolution.height(), - NULL), - gst_structure_new ("video/x-raw-rgb", - "width", G_TYPE_INT, resolution.width(), - "height", G_TYPE_INT, resolution.height(), NULL), NULL); - } - return caps; -} - -void CameraBinSession::setupCaptureResolution() -{ - if (m_captureMode == QCamera::CaptureStillImage) { - QSize resolution = m_imageEncodeControl->imageSettings().resolution(); - - //by default select the maximum supported resolution - if (resolution.isEmpty()) { - bool continuous = false; - QList<QSize> resolutions = supportedResolutions(qMakePair<int,int>(0,0), - &continuous, - QCamera::CaptureStillImage); - if (!resolutions.isEmpty()) - resolution = resolutions.last(); - } - - QSize viewfinderResolution = VIEWFINDER_RESOLUTION_4x3; - - if (!resolution.isEmpty()) { - GstCaps *caps = resolutionToCaps(resolution); -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << "set image resolution" << resolution << gst_caps_to_string(caps); -#endif - g_object_set(m_camerabin, "image-capture-caps", caps, NULL); - gst_caps_unref(caps); - - if (!resolution.isEmpty()) { - qreal aspectRatio = qreal(resolution.width()) / resolution.height(); - if (aspectRatio < 1.4) - viewfinderResolution = VIEWFINDER_RESOLUTION_4x3; - else if (aspectRatio > 1.7) - viewfinderResolution = VIEWFINDER_RESOLUTION_16x9; - else - viewfinderResolution = VIEWFINDER_RESOLUTION_3x2; - } - } - - //on low res cameras the viewfinder resolution should not be bigger - //then capture resolution - if (viewfinderResolution.width() > resolution.width() && !resolution.isEmpty()) - viewfinderResolution = resolution; - - GstCaps *viewfinderCaps = resolutionToCaps(viewfinderResolution); -#if CAMERABIN_DEBUG - qDebug() << "Set viewfinder resolution" << viewfinderResolution <<gst_caps_to_string(viewfinderCaps); -#endif - g_object_set(m_camerabin, "viewfinder-caps", viewfinderCaps, NULL); - gst_caps_unref(viewfinderCaps); - } - - if (m_captureMode == QCamera::CaptureVideo) { - QSize resolution = m_videoEncodeControl->videoSettings().resolution(); - //qreal framerate = m_videoEncodeControl->videoSettings().frameRate(); - - if (resolution.isEmpty()) { - //select the hightest supported resolution - bool continuous = false; - QList<QSize> resolutions = supportedResolutions(qMakePair<int,int>(0,0), - &continuous, - QCamera::CaptureVideo); - if (!resolutions.isEmpty()) - resolution = resolutions.last(); - } - - GstCaps *caps = resolutionToCaps(resolution /*, framerate*/); //convert to rational -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << "set video resolution" << resolution << gst_caps_to_string(caps); -#endif - - g_object_set(m_camerabin, "video-capture-caps", caps, NULL); - gst_caps_unref(caps); - } -} - -GstElement *CameraBinSession::buildCameraSource() -{ -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO; -#endif - GstElement *videoSrc = 0; - if (m_videoInputFactory) { - videoSrc = m_videoInputFactory->buildElement(); - } else { - QList<QByteArray> candidates; - candidates << "wrappercamerabinsrc"; - QByteArray sourceElementName; - - foreach(sourceElementName, candidates) { - videoSrc = gst_element_factory_make(sourceElementName.constData(), "camera_source"); - if (videoSrc) - break; - } - - if (videoSrc && !m_inputDevice.isEmpty()) { -#if CAMERABIN_DEBUG - qDebug() << "set camera device" << m_inputDevice; -#endif - if (sourceElementName == "subdevsrc") { - if (m_inputDevice == QLatin1String("secondary")) - g_object_set(G_OBJECT(videoSrc), "camera-device", 1, NULL); - else - g_object_set(G_OBJECT(videoSrc), "camera-device", 0, NULL); - } else { - if (g_object_class_find_property(G_OBJECT_GET_CLASS(videoSrc), "device")) - g_object_set(G_OBJECT(videoSrc), - "device", - m_inputDevice.toLocal8Bit().constData(), - NULL); - } - } - } - - return videoSrc; -} - -void CameraBinSession::captureImage(int requestId, const QString &fileName) -{ - QString actualFileName = fileName; - if (actualFileName.isEmpty()) - actualFileName = generateFileName("img_", defaultDir(QCamera::CaptureStillImage), "jpg"); - - m_requestId = requestId; - -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << m_requestId << fileName << "actual file name:" << actualFileName; -#endif - - g_object_set(G_OBJECT(m_camerabin), FILENAME_PROPERTY, actualFileName.toLocal8Bit().constData(), NULL); - - g_signal_emit_by_name(G_OBJECT(m_camerabin), CAPTURE_START, NULL); - - m_imageFileName = actualFileName; -} - -void CameraBinSession::setCaptureMode(QCamera::CaptureMode mode) -{ - m_captureMode = mode; - - switch (m_captureMode) { - case QCamera::CaptureStillImage: - g_object_set(m_camerabin, MODE_PROPERTY, CAMERABIN_IMAGE_MODE, NULL); - break; - case QCamera::CaptureVideo: - g_object_set(m_camerabin, MODE_PROPERTY, CAMERABIN_VIDEO_MODE, NULL); - break; - } -} - -QUrl CameraBinSession::outputLocation() const -{ - //return the location service wrote data to, not one set by user, it can be empty. - return m_actualSink; -} - -bool CameraBinSession::setOutputLocation(const QUrl& sink) -{ - m_sink = m_actualSink = sink; - return true; -} - -QDir CameraBinSession::defaultDir(QCamera::CaptureMode mode) const -{ - QStringList dirCandidates; - -#if defined(Q_WS_MAEMO_6) - dirCandidates << QLatin1String("/home/user/MyDocs/DCIM"); - dirCandidates << QLatin1String("/home/user/MyDocs/"); -#endif - - if (mode == QCamera::CaptureVideo) { - dirCandidates << QDesktopServices::storageLocation(QDesktopServices::MoviesLocation); - dirCandidates << QDir::home().filePath("Documents/Video"); - dirCandidates << QDir::home().filePath("Documents/Videos"); - } else { - dirCandidates << QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); - dirCandidates << QDir::home().filePath("Documents/Photo"); - dirCandidates << QDir::home().filePath("Documents/Photos"); - dirCandidates << QDir::home().filePath("Documents/photo"); - dirCandidates << QDir::home().filePath("Documents/photos"); - dirCandidates << QDir::home().filePath("Documents/Images"); - } - - dirCandidates << QDir::home().filePath("Documents"); - dirCandidates << QDir::home().filePath("My Documents"); - dirCandidates << QDir::homePath(); - dirCandidates << QDir::currentPath(); - dirCandidates << QDir::tempPath(); - - foreach (const QString &path, dirCandidates) { - if (QFileInfo(path).isWritable()) - return QDir(path); - } - - return QDir(); -} - -QString CameraBinSession::generateFileName(const QString &prefix, const QDir &dir, const QString &ext) const -{ - int lastClip = 0; - foreach(QString fileName, dir.entryList(QStringList() << QString("%1*.%2").arg(prefix).arg(ext))) { - int imgNumber = fileName.mid(prefix.length(), fileName.size()-prefix.length()-ext.length()-1).toInt(); - lastClip = qMax(lastClip, imgNumber); - } - - QString name = QString("%1%2.%3").arg(prefix) - .arg(lastClip+1, - 4, //fieldWidth - 10, - QLatin1Char('0')) - .arg(ext); - - return dir.absoluteFilePath(name); -} - -void CameraBinSession::setDevice(const QString &device) -{ - if (m_inputDevice != device) { - m_inputDevice = device; - m_videoInputHasChanged = true; - } -} - -void CameraBinSession::setAudioInput(QGstreamerElementFactory *audioInput) -{ - m_audioInputFactory = audioInput; -} - -void CameraBinSession::setVideoInput(QGstreamerElementFactory *videoInput) -{ - m_videoInputFactory = videoInput; - m_videoInputHasChanged = true; -} - -bool CameraBinSession::isReady() const -{ - //it's possible to use QCamera without any viewfinder attached - return !m_viewfinderInterface || m_viewfinderInterface->isReady(); -} - -void CameraBinSession::setViewfinder(QObject *viewfinder) -{ - if (m_viewfinderInterface) - m_viewfinderInterface->stopRenderer(); - - m_viewfinderInterface = qobject_cast<QGstreamerVideoRendererInterface*>(viewfinder); - if (!m_viewfinderInterface) - viewfinder = 0; - - if (m_viewfinder != viewfinder) { - bool oldReady = isReady(); - - if (m_viewfinder) { - disconnect(m_viewfinder, SIGNAL(sinkChanged()), - this, SLOT(handleViewfinderChange())); - disconnect(m_viewfinder, SIGNAL(readyChanged(bool)), - this, SIGNAL(readyChanged(bool))); - - m_busHelper->removeMessageFilter(m_viewfinder); - } - - m_viewfinder = viewfinder; - m_viewfinderHasChanged = true; - - if (m_viewfinder) { - connect(m_viewfinder, SIGNAL(sinkChanged()), - this, SLOT(handleViewfinderChange())); - connect(m_viewfinder, SIGNAL(readyChanged(bool)), - this, SIGNAL(readyChanged(bool))); - - m_busHelper->installMessageFilter(m_viewfinder); - } - - emit viewfinderChanged(); - if (oldReady != isReady()) - emit readyChanged(isReady()); - } -} - -void CameraBinSession::handleViewfinderChange() -{ - //the viewfinder will be reloaded - //shortly when the pipeline is started - m_viewfinderHasChanged = true; - emit viewfinderChanged(); -} - -QCamera::State CameraBinSession::state() const -{ - return m_state; -} - -void CameraBinSession::setState(QCamera::State newState) -{ - if (newState == m_pendingState) - return; - - m_pendingState = newState; - -#if CAMERABIN_DEBUG - qDebug() << Q_FUNC_INFO << newState; -#endif - - switch (newState) { - case QCamera::UnloadedState: - if (m_recordingActive) - stopVideoRecording(); - - if (m_viewfinderInterface) - m_viewfinderInterface->stopRenderer(); - - gst_element_set_state(m_camerabin, GST_STATE_NULL); - m_state = newState; - if (m_busy) - emit busyChanged(m_busy = false); - - emit stateChanged(m_state); - break; - case QCamera::LoadedState: - if (m_recordingActive) - stopVideoRecording(); - - if (m_videoInputHasChanged) { - if (m_viewfinderInterface) - m_viewfinderInterface->stopRenderer(); - - gst_element_set_state(m_camerabin, GST_STATE_NULL); - m_videoSrc = buildCameraSource(); - g_object_set(m_camerabin, CAMERA_SOURCE_PROPERTY, m_videoSrc, NULL); - m_videoInputHasChanged = false; - } -#ifdef USE_READY_STATE_ON_LOADED - gst_element_set_state(m_camerabin, GST_STATE_READY); -#else - m_state = QCamera::LoadedState; - if (m_viewfinderInterface) - m_viewfinderInterface->stopRenderer(); - gst_element_set_state(m_camerabin, GST_STATE_NULL); - emit stateChanged(m_state); -#endif - break; - case QCamera::ActiveState: - if (setupCameraBin()) { - GstState binState = GST_STATE_NULL; - GstState pending = GST_STATE_NULL; - gst_element_get_state(m_camerabin, &binState, &pending, 0); - - if (pending == GST_STATE_VOID_PENDING && binState == GST_STATE_READY) { - m_pendingResolutionUpdate = false; - setupCaptureResolution(); - gst_element_set_state(m_camerabin, GST_STATE_PLAYING); - } else { - m_pendingResolutionUpdate = true; - gst_element_set_state(m_camerabin, GST_STATE_READY); - } - } - } -} - -bool CameraBinSession::isBusy() const -{ - return m_busy; -} - -void CameraBinSession::updateBusyStatus(GObject *o, GParamSpec *p, gpointer d) -{ - Q_UNUSED(p); - CameraBinSession *session = reinterpret_cast<CameraBinSession *>(d); - - bool idle = false; - g_object_get(o, "idle", &idle, NULL); - bool busy = !idle; - - if (session->m_busy != busy) { - session->m_busy = busy; - QMetaObject::invokeMethod(session, "busyChanged", - Qt::QueuedConnection, - Q_ARG(bool, busy)); - } -} - -qint64 CameraBinSession::duration() const -{ - GstFormat format = GST_FORMAT_TIME; - gint64 duration = 0; - - if ( m_camerabin && gst_element_query_position(m_camerabin, &format, &duration)) - return duration / 1000000; - else - return 0; -} - -bool CameraBinSession::isMuted() const -{ - return m_muted; -} - -void CameraBinSession::setMuted(bool muted) -{ - if (m_muted != muted) { - m_muted = muted; - - if (m_camerabin) - g_object_set(G_OBJECT(m_camerabin), MUTE_PROPERTY, m_muted, NULL); - emit mutedChanged(m_muted); - } -} - -void CameraBinSession::setCaptureDevice(const QString &deviceName) -{ - m_captureDevice = deviceName; -} - -void CameraBinSession::setMetaData(const QMap<QByteArray, QVariant> &data) -{ - m_metaData = data; - - if (m_camerabin) { - GstIterator *elements = gst_bin_iterate_all_by_interface(GST_BIN(m_camerabin), GST_TYPE_TAG_SETTER); - GstElement *element = 0; - while (gst_iterator_next(elements, (void**)&element) == GST_ITERATOR_OK) { - QMapIterator<QByteArray, QVariant> it(data); - while (it.hasNext()) { - it.next(); - const QString tagName = it.key(); - const QVariant tagValue = it.value(); - - switch(tagValue.type()) { - case QVariant::String: - gst_tag_setter_add_tags(GST_TAG_SETTER(element), - GST_TAG_MERGE_REPLACE_ALL, - tagName.toUtf8().constData(), - tagValue.toString().toUtf8().constData(), - NULL); - break; - case QVariant::Int: - case QVariant::LongLong: - gst_tag_setter_add_tags(GST_TAG_SETTER(element), - GST_TAG_MERGE_REPLACE_ALL, - tagName.toUtf8().constData(), - tagValue.toInt(), - NULL); - break; - case QVariant::Double: - gst_tag_setter_add_tags(GST_TAG_SETTER(element), - GST_TAG_MERGE_REPLACE_ALL, - tagName.toUtf8().constData(), - tagValue.toDouble(), - NULL); - break; - default: - break; - } - } - } - } -} - -bool CameraBinSession::processSyncMessage(const QGstreamerMessage &message) -{ - GstMessage* gm = message.rawMessage(); - const GstStructure *st; - const GValue *image; - GstBuffer *buffer = NULL; - - if (gm && GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ELEMENT) { - if (m_captureMode == QCamera::CaptureStillImage && - gst_structure_has_name(gm->structure, "preview-image")) { - st = gst_message_get_structure(gm); - - if (gst_structure_has_field_typed(st, "buffer", GST_TYPE_BUFFER)) { - image = gst_structure_get_value(st, "buffer"); - if (image) { - buffer = gst_value_get_buffer(image); - - QImage img; - - GstCaps *caps = gst_buffer_get_caps(buffer); - if (caps) { - GstStructure *structure = gst_caps_get_structure(caps, 0); - gint width = 0; - gint height = 0; -#if CAMERABIN_DEBUG - qDebug() << "Preview caps:" << gst_structure_to_string(structure); -#endif - - if (structure && - gst_structure_get_int(structure, "width", &width) && - gst_structure_get_int(structure, "height", &height) && - width > 0 && height > 0) { - if (qstrcmp(gst_structure_get_name(structure), "video/x-raw-rgb") == 0) { - QImage::Format format = QImage::Format_Invalid; - int bpp = 0; - gst_structure_get_int(structure, "bpp", &bpp); - - if (bpp == 24) - format = QImage::Format_RGB888; - else if (bpp == 32) - format = QImage::Format_RGB32; - - if (format != QImage::Format_Invalid) { - img = QImage((const uchar *)buffer->data, width, height, format); - img.bits(); //detach - } - } - } - gst_caps_unref(caps); - - static int exposedSignalIndex = metaObject()->indexOfSignal("imageExposed(int)"); - metaObject()->method(exposedSignalIndex).invoke(this, - Qt::QueuedConnection, - Q_ARG(int,m_requestId)); - - static int signalIndex = metaObject()->indexOfSignal("imageCaptured(int,QImage)"); - metaObject()->method(signalIndex).invoke(this, - Qt::QueuedConnection, - Q_ARG(int,m_requestId), - Q_ARG(QImage,img)); - } - - } - return true; - } - } - - if (gst_structure_has_name(gm->structure, GST_PHOTOGRAPHY_AUTOFOCUS_DONE)) - m_cameraFocusControl->handleFocusMessage(gm); - } - - return false; -} - -bool CameraBinSession::processBusMessage(const QGstreamerMessage &message) -{ - GstMessage* gm = message.rawMessage(); - - if (gm) { - if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_ERROR) { - GError *err; - gchar *debug; - gst_message_parse_error (gm, &err, &debug); - - QString message; - - if (err && err->message) { - message = QString::fromUtf8(err->message); - qWarning() << "CameraBin error:" << message; - } - - //only report error messager from camerabin - if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_camerabin)) { - if (message.isEmpty()) - message = tr("Camera error"); - - emit error(int(QMediaRecorder::ResourceError), message); - } - -#ifdef CAMERABIN_DEBUG_DUMP_BIN - _gst_debug_bin_to_dot_file_with_ts(GST_BIN(m_camerabin), - GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_ALL /* GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES*/), - "camerabin_error"); -#endif - - - if (err) - g_error_free (err); - - if (debug) - g_free (debug); - } - - if (GST_MESSAGE_TYPE(gm) == GST_MESSAGE_WARNING) { - GError *err; - gchar *debug; - gst_message_parse_warning (gm, &err, &debug); - - if (err && err->message) - qWarning() << "CameraBin warning:" << QString::fromUtf8(err->message); - - if (err) - g_error_free (err); - if (debug) - g_free (debug); - } - - if (GST_MESSAGE_SRC(gm) == GST_OBJECT_CAST(m_camerabin)) { - switch (GST_MESSAGE_TYPE(gm)) { - case GST_MESSAGE_DURATION: - break; - - case GST_MESSAGE_STATE_CHANGED: - { - - GstState oldState; - GstState newState; - GstState pending; - - gst_message_parse_state_changed(gm, &oldState, &newState, &pending); - - -#if CAMERABIN_DEBUG - QStringList states; - states << "GST_STATE_VOID_PENDING" << "GST_STATE_NULL" << "GST_STATE_READY" << "GST_STATE_PAUSED" << "GST_STATE_PLAYING"; - - - qDebug() << QString("state changed: old: %1 new: %2 pending: %3") \ - .arg(states[oldState]) \ - .arg(states[newState]) \ - .arg(states[pending]); -#endif - -#ifdef CAMERABIN_DEBUG_DUMP_BIN - _gst_debug_bin_to_dot_file_with_ts(GST_BIN(m_camerabin), - GstDebugGraphDetails(GST_DEBUG_GRAPH_SHOW_ALL /*GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE | GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS | GST_DEBUG_GRAPH_SHOW_STATES*/), - "camerabin"); -#endif - - switch (newState) { - case GST_STATE_VOID_PENDING: - case GST_STATE_NULL: - if (m_state != QCamera::UnloadedState) - emit stateChanged(m_state = QCamera::UnloadedState); - break; - case GST_STATE_READY: - if (m_pendingResolutionUpdate) { - m_pendingResolutionUpdate = false; - setupCaptureResolution(); - gst_element_set_state(m_camerabin, GST_STATE_PLAYING); - } - if (m_state != QCamera::LoadedState) - emit stateChanged(m_state = QCamera::LoadedState); - break; - case GST_STATE_PAUSED: - case GST_STATE_PLAYING: - emit stateChanged(m_state = QCamera::ActiveState); - break; - } - } - break; - default: - break; - } - //qDebug() << "New session state:" << ENUM_NAME(CameraBinSession,"State",m_state); - } - } - - return false; -} - -void CameraBinSession::recordVideo() -{ - m_recordingActive = true; - m_actualSink = m_sink; - if (m_actualSink.isEmpty()) { - QString ext = m_mediaContainerControl->suggestedFileExtension(); - m_actualSink = generateFileName("clip_", defaultDir(QCamera::CaptureVideo), ext); - } - - g_object_set(G_OBJECT(m_camerabin), FILENAME_PROPERTY, m_actualSink.toEncoded().constData(), NULL); - - g_signal_emit_by_name(G_OBJECT(m_camerabin), CAPTURE_START, NULL); -} - -void CameraBinSession::stopVideoRecording() -{ - m_recordingActive = false; - g_signal_emit_by_name(G_OBJECT(m_camerabin), CAPTURE_STOP, NULL); -} - -//internal, only used by CameraBinSession::supportedFrameRates. -//recursively fills the list of framerates res from value data. -static void readValue(const GValue *value, QList< QPair<int,int> > *res, bool *continuous) -{ - if (GST_VALUE_HOLDS_FRACTION(value)) { - int num = gst_value_get_fraction_numerator(value); - int denum = gst_value_get_fraction_denominator(value); - - *res << QPair<int,int>(num, denum); - } else if (GST_VALUE_HOLDS_FRACTION_RANGE(value)) { - const GValue *rateValueMin = gst_value_get_fraction_range_min(value); - const GValue *rateValueMax = gst_value_get_fraction_range_max(value); - - if (continuous) - *continuous = true; - - readValue(rateValueMin, res, continuous); - readValue(rateValueMax, res, continuous); - } else if (GST_VALUE_HOLDS_LIST(value)) { - for (uint i=0; i<gst_value_list_get_size(value); i++) { - readValue(gst_value_list_get_value(value, i), res, continuous); - } - } -} - -static bool rateLessThan(const QPair<int,int> &r1, const QPair<int,int> &r2) -{ - return r1.first*r2.second < r2.first*r1.second; -} - -QList< QPair<int,int> > CameraBinSession::supportedFrameRates(const QSize &frameSize, bool *continuous) const -{ - QList< QPair<int,int> > res; - - GstCaps *supportedCaps = 0; - g_object_get(G_OBJECT(m_camerabin), - SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, - &supportedCaps, NULL); - - if (!supportedCaps) - return res; - - GstCaps *caps = 0; - - if (frameSize.isEmpty()) { - caps = gst_caps_copy(supportedCaps); - } else { - GstCaps *filter = gst_caps_new_full( - gst_structure_new( - "video/x-raw-rgb", - "width" , G_TYPE_INT , frameSize.width(), - "height" , G_TYPE_INT, frameSize.height(), NULL), - gst_structure_new( - "video/x-raw-yuv", - "width" , G_TYPE_INT, frameSize.width(), - "height" , G_TYPE_INT, frameSize.height(), NULL), - gst_structure_new( - "image/jpeg", - "width" , G_TYPE_INT, frameSize.width(), - "height" , G_TYPE_INT, frameSize.height(), NULL), - NULL); - - caps = gst_caps_intersect(supportedCaps, filter); - gst_caps_unref(filter); - } - gst_caps_unref(supportedCaps); - - //simplify to the list of rates only: - caps = gst_caps_make_writable(caps); - for (uint i=0; i<gst_caps_get_size(caps); i++) { - GstStructure *structure = gst_caps_get_structure(caps, i); - gst_structure_set_name(structure, "video/x-raw-yuv"); - const GValue *oldRate = gst_structure_get_value(structure, "framerate"); - GValue rate; - memset(&rate, 0, sizeof(rate)); - g_value_init(&rate, G_VALUE_TYPE(oldRate)); - g_value_copy(oldRate, &rate); - gst_structure_remove_all_fields(structure); - gst_structure_set_value(structure, "framerate", &rate); - } - gst_caps_do_simplify(caps); - - - for (uint i=0; i<gst_caps_get_size(caps); i++) { - GstStructure *structure = gst_caps_get_structure(caps, i); - const GValue *rateValue = gst_structure_get_value(structure, "framerate"); - readValue(rateValue, &res, continuous); - } - - qSort(res.begin(), res.end(), rateLessThan); - -#if CAMERABIN_DEBUG - qDebug() << "Supported rates:" << gst_caps_to_string(caps); - qDebug() << res; -#endif - - gst_caps_unref(caps); - - return res; -} - -//internal, only used by CameraBinSession::supportedResolutions -//recursively find the supported resolutions range. -static QPair<int,int> valueRange(const GValue *value, bool *continuous) -{ - int minValue = 0; - int maxValue = 0; - - if (g_value_type_compatible(G_VALUE_TYPE(value), G_TYPE_INT)) { - minValue = maxValue = g_value_get_int(value); - } else if (GST_VALUE_HOLDS_INT_RANGE(value)) { - minValue = gst_value_get_int_range_min(value); - maxValue = gst_value_get_int_range_max(value); - *continuous = true; - } else if (GST_VALUE_HOLDS_LIST(value)) { - for (uint i=0; i<gst_value_list_get_size(value); i++) { - QPair<int,int> res = valueRange(gst_value_list_get_value(value, i), continuous); - - if (res.first > 0 && minValue > 0) - minValue = qMin(minValue, res.first); - else //select non 0 valid value - minValue = qMax(minValue, res.first); - - maxValue = qMax(maxValue, res.second); - } - } - - return QPair<int,int>(minValue, maxValue); -} - -static bool resolutionLessThan(const QSize &r1, const QSize &r2) -{ - return r1.width()*r1.height() < r2.width()*r2.height(); -} - - -QList<QSize> CameraBinSession::supportedResolutions(QPair<int,int> rate, - bool *continuous, - QCamera::CaptureMode mode) const -{ - QList<QSize> res; - - if (continuous) - *continuous = false; - - GstCaps *supportedCaps = 0; - g_object_get(G_OBJECT(m_camerabin), - (mode == QCamera::CaptureStillImage) ? - SUPPORTED_IMAGE_CAPTURE_CAPS_PROPERTY : SUPPORTED_VIDEO_CAPTURE_CAPS_PROPERTY, - &supportedCaps, NULL); - - if (!supportedCaps) - return res; - -#if CAMERABIN_DEBUG - qDebug() << "Source caps:" << gst_caps_to_string(supportedCaps); -#endif - - GstCaps *caps = 0; - bool isContinuous = false; - - if (rate.first <= 0 || rate.second <= 0) { - caps = gst_caps_copy(supportedCaps); - } else { - GstCaps *filter = gst_caps_new_full( - gst_structure_new( - "video/x-raw-rgb", - "framerate" , GST_TYPE_FRACTION , rate.first, rate.second, NULL), - gst_structure_new( - "video/x-raw-yuv", - "framerate" , GST_TYPE_FRACTION , rate.first, rate.second, NULL), - gst_structure_new( - "image/jpeg", - "framerate" , GST_TYPE_FRACTION , rate.first, rate.second, NULL), - NULL); - - caps = gst_caps_intersect(supportedCaps, filter); - gst_caps_unref(filter); - } - gst_caps_unref(supportedCaps); - - //simplify to the list of resolutions only: - caps = gst_caps_make_writable(caps); - for (uint i=0; i<gst_caps_get_size(caps); i++) { - GstStructure *structure = gst_caps_get_structure(caps, i); - gst_structure_set_name(structure, "video/x-raw-yuv"); - const GValue *oldW = gst_structure_get_value(structure, "width"); - const GValue *oldH = gst_structure_get_value(structure, "height"); - GValue w; - memset(&w, 0, sizeof(GValue)); - GValue h; - memset(&h, 0, sizeof(GValue)); - g_value_init(&w, G_VALUE_TYPE(oldW)); - g_value_init(&h, G_VALUE_TYPE(oldH)); - g_value_copy(oldW, &w); - g_value_copy(oldH, &h); - gst_structure_remove_all_fields(structure); - gst_structure_set_value(structure, "width", &w); - gst_structure_set_value(structure, "height", &h); - } - gst_caps_do_simplify(caps); - - for (uint i=0; i<gst_caps_get_size(caps); i++) { - GstStructure *structure = gst_caps_get_structure(caps, i); - const GValue *wValue = gst_structure_get_value(structure, "width"); - const GValue *hValue = gst_structure_get_value(structure, "height"); - - QPair<int,int> wRange = valueRange(wValue, &isContinuous); - QPair<int,int> hRange = valueRange(hValue, &isContinuous); - - QSize minSize(wRange.first, hRange.first); - QSize maxSize(wRange.second, hRange.second); - - if (!minSize.isEmpty()) - res << minSize; - - if (minSize != maxSize && !maxSize.isEmpty()) - res << maxSize; - } - - - qSort(res.begin(), res.end(), resolutionLessThan); - - //if the range is continuos, populate is with the common rates - if (isContinuous && res.size() >= 2) { - //fill the ragne with common value - static QList<QSize> commonSizes = - QList<QSize>() << QSize(128, 96) - << QSize(160,120) - << QSize(176, 144) - << QSize(320, 240) - << QSize(352, 288) - << QSize(640, 480) - << QSize(848, 480) - << QSize(854, 480) - << QSize(1024, 768) - << QSize(1280, 720) // HD 720 - << QSize(1280, 1024) - << QSize(1600, 1200) - << QSize(1920, 1080) // HD - << QSize(1920, 1200) - << QSize(2048, 1536) - << QSize(2560, 1600) - << QSize(2580, 1936); - QSize minSize = res.first(); - QSize maxSize = res.last(); - res.clear(); - - foreach (const QSize &candidate, commonSizes) { - int w = candidate.width(); - int h = candidate.height(); - - if (w > maxSize.width() && h > maxSize.height()) - break; - - if (w >= minSize.width() && h >= minSize.height() && - w <= maxSize.width() && h <= maxSize.height()) - res << candidate; - } - - if (res.isEmpty() || res.first() != minSize) - res.prepend(minSize); - - if (res.last() != maxSize) - res.append(maxSize); - } - -#if CAMERABIN_DEBUG - qDebug() << "Supported resolutions:" << gst_caps_to_string(caps); - qDebug() << res; -#endif - - gst_caps_unref(caps); - - if (continuous) - *continuous = isContinuous; - - return res; -} diff --git a/src/plugins/gstreamer/camerabin/camerabinsession.h b/src/plugins/gstreamer/camerabin/camerabinsession.h deleted file mode 100644 index fea1ad5..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinsession.h +++ /dev/null @@ -1,232 +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 Toolkit. -** -** $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 CAMERABINCAPTURESESSION_MAEMO_H -#define CAMERABINCAPTURESESSION_MAEMO_H - -#include <qmediarecordercontrol.h> - -#include <QtCore/qurl.h> -#include <QtCore/qdir.h> - -#include <gst/gst.h> -#include <gst/interfaces/photography.h> - -#include "qgstreamerbushelper.h" -#include "qcamera.h" - - -class QGstreamerMessage; -class QGstreamerBusHelper; -class CameraBinAudioEncoder; -class CameraBinVideoEncoder; -class CameraBinImageEncoder; -class CameraBinRecorder; -class CameraBinContainer; -class CameraBinExposure; -class CameraBinFlash; -class CameraBinFocus; -class CameraBinImageProcessing; -class CameraBinLocks; -class CameraBinCaptureDestination; -class CameraBinCaptureBufferFormat; -class QGstreamerVideoRendererInterface; - -class QGstreamerElementFactory -{ -public: - virtual GstElement *buildElement() = 0; -}; - -class CameraBinSession : public QObject, - public QGstreamerBusMessageFilter, - public QGstreamerSyncMessageFilter -{ - Q_OBJECT - Q_PROPERTY(qint64 duration READ duration NOTIFY durationChanged) - Q_INTERFACES(QGstreamerBusMessageFilter QGstreamerSyncMessageFilter) -public: - enum CameraRole { - FrontCamera, // Secondary camera - BackCamera // Main photo camera - }; - - CameraBinSession(QObject *parent); - ~CameraBinSession(); - - GstPhotography *photography(); - GstElement *cameraBin() { return m_camerabin; } - QGstreamerBusHelper *bus() { return m_busHelper; } - - CameraRole cameraRole() const; - - QList< QPair<int,int> > supportedFrameRates(const QSize &frameSize, bool *continuous) const; - QList<QSize> supportedResolutions( QPair<int,int> rate, bool *continuous, QCamera::CaptureMode mode) const; - - QCamera::CaptureMode captureMode() { return m_captureMode; } - void setCaptureMode(QCamera::CaptureMode mode); - - QUrl outputLocation() const; - bool setOutputLocation(const QUrl& sink); - - QDir defaultDir(QCamera::CaptureMode mode) const; - QString generateFileName(const QString &prefix, const QDir &dir, const QString &ext) const; - - CameraBinAudioEncoder *audioEncodeControl() const { return m_audioEncodeControl; } - CameraBinVideoEncoder *videoEncodeControl() const { return m_videoEncodeControl; } - CameraBinImageEncoder *imageEncodeControl() const { return m_imageEncodeControl; } - CameraBinExposure *cameraExposureControl() const { return m_cameraExposureControl; } - CameraBinFlash *cameraFlashControl() const { return m_cameraFlashControl; } - CameraBinFocus *cameraFocusControl() const { return m_cameraFocusControl; } - CameraBinImageProcessing *imageProcessingControl() const { return m_imageProcessingControl; } - CameraBinLocks *cameraLocksControl() const { return m_cameraLocksControl; } - CameraBinCaptureDestination *captureDestinationControl() const { return m_captureDestinationControl; } - CameraBinCaptureBufferFormat *captureBufferFormatControl() const { return m_captureBufferFormatControl; } - - - CameraBinRecorder *recorderControl() const { return m_recorderControl; } - CameraBinContainer *mediaContainerControl() const { return m_mediaContainerControl; } - - QGstreamerElementFactory *audioInput() const { return m_audioInputFactory; } - void setAudioInput(QGstreamerElementFactory *audioInput); - - QGstreamerElementFactory *videoInput() const { return m_videoInputFactory; } - void setVideoInput(QGstreamerElementFactory *videoInput); - bool isReady() const; - - QObject *viewfinder() const { return m_viewfinder; } - void setViewfinder(QObject *viewfinder); - - void captureImage(int requestId, const QString &fileName); - - QCamera::State state() const; - bool isBusy() const; - - qint64 duration() const; - - void recordVideo(); - void stopVideoRecording(); - - bool isMuted() const; - - bool processSyncMessage(const QGstreamerMessage &message); - bool processBusMessage(const QGstreamerMessage &message); - -signals: - void stateChanged(QCamera::State state); - void durationChanged(qint64 duration); - void error(int error, const QString &errorString); - void imageExposed(int requestId); - void imageCaptured(int requestId, const QImage &img); - void mutedChanged(bool); - void viewfinderChanged(); - void readyChanged(bool); - void busyChanged(bool); - -public slots: - void setDevice(const QString &device); - void setState(QCamera::State); - void setCaptureDevice(const QString &deviceName); - void setMetaData(const QMap<QByteArray, QVariant>&); - void setMuted(bool); - -private slots: - void handleViewfinderChange(); - -private: - bool setupCameraBin(); - void setupCaptureResolution(); - GstElement *buildCameraSource(); - static void updateBusyStatus(GObject *o, GParamSpec *p, gpointer d); - - QUrl m_sink; - QUrl m_actualSink; - bool m_recordingActive; - QString m_captureDevice; - QCamera::State m_state; - QCamera::State m_pendingState; - QString m_inputDevice; - bool m_pendingResolutionUpdate; - bool m_muted; - bool m_busy; - - QCamera::CaptureMode m_captureMode; - QMap<QByteArray, QVariant> m_metaData; - - QGstreamerElementFactory *m_audioInputFactory; - QGstreamerElementFactory *m_videoInputFactory; - QObject *m_viewfinder; - QGstreamerVideoRendererInterface *m_viewfinderInterface; - - CameraBinAudioEncoder *m_audioEncodeControl; - CameraBinVideoEncoder *m_videoEncodeControl; - CameraBinImageEncoder *m_imageEncodeControl; - CameraBinRecorder *m_recorderControl; - CameraBinContainer *m_mediaContainerControl; - CameraBinExposure *m_cameraExposureControl; - CameraBinFlash *m_cameraFlashControl; - CameraBinFocus *m_cameraFocusControl; - CameraBinImageProcessing *m_imageProcessingControl; - CameraBinLocks *m_cameraLocksControl; - CameraBinCaptureDestination *m_captureDestinationControl; - CameraBinCaptureBufferFormat *m_captureBufferFormatControl; - - QGstreamerBusHelper *m_busHelper; - GstBus* m_bus; - GstElement *m_camerabin; - GstElement *m_videoSrc; - GstElement *m_viewfinderElement; - bool m_viewfinderHasChanged; - bool m_videoInputHasChanged; - - GstElement *m_audioSrc; - GstElement *m_audioConvert; - GstElement *m_capsFilter; - GstElement *m_fileSink; - GstElement *m_audioEncoder; - GstElement *m_muxer; - -public: - QString m_imageFileName; - int m_requestId; -}; - -#endif // CAMERABINCAPTURESESSION_MAEMO_H diff --git a/src/plugins/gstreamer/camerabin/camerabinvideoencoder.cpp b/src/plugins/gstreamer/camerabin/camerabinvideoencoder.cpp deleted file mode 100644 index 1e49000..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinvideoencoder.cpp +++ /dev/null @@ -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 Toolkit. -** -** $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 "camerabinvideoencoder.h" -#include "camerabinsession.h" -#include "camerabincontainer.h" - -#include <QtCore/qdebug.h> - -CameraBinVideoEncoder::CameraBinVideoEncoder(CameraBinSession *session) - :QVideoEncoderControl(session), - m_session(session), - m_codecs(QGstCodecsInfo::VideoEncoder) -{ -} - -CameraBinVideoEncoder::~CameraBinVideoEncoder() -{ -} - -QList<QSize> CameraBinVideoEncoder::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - QPair<int,int> rate = rateAsRational(settings.frameRate()); - - //select the closest supported rational rate to settings.frameRate() - - return m_session->supportedResolutions(rate, continuous, QCamera::CaptureVideo); -} - -QList< qreal > CameraBinVideoEncoder::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const -{ - if (continuous) - *continuous = false; - - QList< qreal > res; - QPair<int,int> rate; - - foreach(rate, m_session->supportedFrameRates(settings.resolution(), continuous)) { - if (rate.second > 0) - res << qreal(rate.first)/rate.second; - } - - return res; -} - -QStringList CameraBinVideoEncoder::supportedVideoCodecs() const -{ - return m_codecs.supportedCodecs(); -} - -QString CameraBinVideoEncoder::videoCodecDescription(const QString &codecName) const -{ - return m_codecs.codecDescription(codecName); -} - -QStringList CameraBinVideoEncoder::supportedEncodingOptions(const QString &codec) const -{ - return m_codecOptions.value(codec); -} - -QVariant CameraBinVideoEncoder::encodingOption(const QString &codec, const QString &name) const -{ - return m_options[codec].value(name); -} - -void CameraBinVideoEncoder::setEncodingOption( - const QString &codec, const QString &name, const QVariant &value) -{ - m_options[codec][name] = value; -} - -QVideoEncoderSettings CameraBinVideoEncoder::videoSettings() const -{ - return m_videoSettings; -} - -void CameraBinVideoEncoder::setVideoSettings(const QVideoEncoderSettings &settings) -{ - m_videoSettings = settings; - m_userSettings = settings; - emit settingsChanged(); -} - -void CameraBinVideoEncoder::setActualVideoSettings(const QVideoEncoderSettings &settings) -{ - m_videoSettings = settings; -} - -void CameraBinVideoEncoder::resetActualSettings() -{ - m_videoSettings = m_userSettings; -} - - -QPair<int,int> CameraBinVideoEncoder::rateAsRational(qreal frameRate) const -{ - if (frameRate > 0.001) { - //convert to rational number - QList<int> denumCandidates; - denumCandidates << 1 << 2 << 3 << 5 << 10 << 25 << 30 << 50 << 100 << 1001 << 1000; - - qreal error = 1.0; - int num = 1; - int denum = 1; - - foreach (int curDenum, denumCandidates) { - int curNum = qRound(frameRate*curDenum); - qreal curError = qAbs(qreal(curNum)/curDenum - frameRate); - - if (curError < error) { - error = curError; - num = curNum; - denum = curDenum; - } - - if (curError < 1e-8) - break; - } - - return QPair<int,int>(num,denum); - } - - return QPair<int,int>(); -} - -GstEncodingProfile *CameraBinVideoEncoder::createProfile() -{ - QString codec = m_videoSettings.codec(); - GstCaps *caps; - - if (codec.isEmpty()) - caps = gst_caps_new_any(); - else - caps = gst_caps_from_string(codec.toLatin1()); - - return (GstEncodingProfile *)gst_encoding_video_profile_new( - caps, - NULL, //preset - NULL, //restriction - 0); //presence -} diff --git a/src/plugins/gstreamer/camerabin/camerabinvideoencoder.h b/src/plugins/gstreamer/camerabin/camerabinvideoencoder.h deleted file mode 100644 index 29fc595..0000000 --- a/src/plugins/gstreamer/camerabin/camerabinvideoencoder.h +++ /dev/null @@ -1,103 +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 Toolkit. -** -** $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 CAMERABINVIDEOENCODE_H -#define CAMERABINVIDEOENCODE_H - -#include <qvideoencodercontrol.h> -class CameraBinSession; - -#include <QtCore/qstringlist.h> -#include <QtCore/qmap.h> -#include <QtCore/qset.h> - -#include <gst/gst.h> -#include <gst/pbutils/pbutils.h> -#include <gst/pbutils/encoding-profile.h> -#include "qgstcodecsinfo.h" - -QT_USE_NAMESPACE - -class CameraBinVideoEncoder : public QVideoEncoderControl -{ - Q_OBJECT -public: - CameraBinVideoEncoder(CameraBinSession *session); - virtual ~CameraBinVideoEncoder(); - - QList<QSize> supportedResolutions(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const; - - QList< qreal > supportedFrameRates(const QVideoEncoderSettings &settings = QVideoEncoderSettings(), - bool *continuous = 0) const; - - QPair<int,int> rateAsRational(qreal) const; - - QStringList supportedVideoCodecs() const; - QString videoCodecDescription(const QString &codecName) const; - - QVideoEncoderSettings videoSettings() const; - void setVideoSettings(const QVideoEncoderSettings &settings); - - 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); - - void setActualVideoSettings(const QVideoEncoderSettings&); - void resetActualSettings(); - - GstEncodingProfile *createProfile(); - -Q_SIGNALS: - void settingsChanged(); - -private: - CameraBinSession *m_session; - - QGstCodecsInfo m_codecs; - QMap<QString,QStringList> m_codecOptions; - QMap<QString, QMap<QString, QVariant> > m_options; - - QVideoEncoderSettings m_videoSettings; // backend selected settings, using m_userSettings - QVideoEncoderSettings m_userSettings; -}; - -#endif |