qtubuntu-camera-0.3.3+14.04.20140304/ 0000755 0000152 0177776 00000000000 12305354713 017227 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/ 0000755 0000152 0177776 00000000000 12305354713 021271 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/ 0000755 0000152 0177776 00000000000 12305354713 027273 5 ustar pbuser nogroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000161 00000000000 011213 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/tst_aalviewfindersettingscontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/tst_aalviewfindersetting0000644 0000152 0177776 00000007276 12305354476 034350 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include "aalcameraservice.h"
#define private public
#include "aalviewfindersettingscontrol.h"
class tst_AalViewfinderSettingsControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void setSize();
void resetAllSettings();
void chooseOptimalSize16by9();
void chooseOptimalSize4by3();
void chooseOptimalSizeEmpty();
void chooseOptimalSize0AspectRatio();
void chooseOptimalSize0AspectRatioEmpty();
private:
AalViewfinderSettingsControl *m_vfControl;
AalCameraService *m_service;
friend class AalViewfinderSettingsControl;
};
void tst_AalViewfinderSettingsControl::initTestCase()
{
m_service = new AalCameraService();
m_vfControl = new AalViewfinderSettingsControl(m_service);
}
void tst_AalViewfinderSettingsControl::cleanupTestCase()
{
delete m_vfControl;
delete m_service;
}
void tst_AalViewfinderSettingsControl::setSize()
{
m_vfControl->m_currentSize = QSize(123, 234);
QSize size(640, 480);
m_vfControl->setViewfinderParameter(QCameraViewfinderSettingsControl::Resolution, size);
QSize result = m_vfControl->viewfinderParameter(QCameraViewfinderSettingsControl::Resolution).toSize();
QCOMPARE(result, size);
QCOMPARE(result, m_vfControl->currentSize());
}
void tst_AalViewfinderSettingsControl::resetAllSettings()
{
m_vfControl->m_currentSize = QSize(123, 234);
m_vfControl->resetAllSettings();
QCOMPARE(m_vfControl->currentSize(), QSize());
}
void tst_AalViewfinderSettingsControl::chooseOptimalSize16by9()
{
m_vfControl->m_aspectRatio = (float)16 / (float)9;
QList resolutions;
resolutions.append(QSize(1920, 1080));
resolutions.append(QSize(1280, 720));
resolutions.append(QSize(960, 720));
QCOMPARE(m_vfControl->chooseOptimalSize(resolutions), QSize(1920, 1080));
}
void tst_AalViewfinderSettingsControl::chooseOptimalSize4by3()
{
m_vfControl->m_aspectRatio = (float)4 / (float)3;
QList resolutions;
resolutions.append(QSize(1920, 1080));
resolutions.append(QSize(1280, 720));
resolutions.append(QSize(960, 720));
QCOMPARE(m_vfControl->chooseOptimalSize(resolutions), QSize(960, 720));
}
void tst_AalViewfinderSettingsControl::chooseOptimalSizeEmpty()
{
m_vfControl->m_aspectRatio = (float)4 / (float)3;
QList resolutions;
QCOMPARE(m_vfControl->chooseOptimalSize(resolutions), QSize());
}
void tst_AalViewfinderSettingsControl::chooseOptimalSize0AspectRatio()
{
m_vfControl->m_aspectRatio = 0;
QList resolutions;
resolutions.append(QSize(1920, 1080));
resolutions.append(QSize(1280, 720));
resolutions.append(QSize(960, 720));
QCOMPARE(m_vfControl->chooseOptimalSize(resolutions), QSize(1280, 720));
}
void tst_AalViewfinderSettingsControl::chooseOptimalSize0AspectRatioEmpty()
{
m_vfControl->m_aspectRatio = 0;
QList resolutions;
QCOMPARE(m_vfControl->chooseOptimalSize(resolutions), QSize());
}
QTEST_MAIN(tst_AalViewfinderSettingsControl)
#include "tst_aalviewfindersettingscontrol.moc"
././@LongLink 0000000 0000000 0000000 00000000155 00000000000 011216 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/aalviewfindersettingscontrol.pro qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/aalviewfindersettingscon0000644 0000152 0177776 00000001063 12305354476 034325 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalviewfindersettingscontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalviewfindersettingscontrol.h \
../../src/aalcameraservice.h \
../../src/aalvideorenderercontrol.h
SOURCES += tst_aalviewfindersettingscontrol.cpp \
../../src/aalviewfindersettingscontrol.cpp \
aalcameraservice.cpp \
aalvideorenderercontrol.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011211 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/aalvideorenderercontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/aalvideorenderercontrol.0000644 0000152 0177776 00000003407 12305354476 034222 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideorenderercontrol.h"
#include "aalcameraservice.h"
AalVideoRendererControl::AalVideoRendererControl(AalCameraService *service, QObject *parent)
: QVideoRendererControl(parent)
, m_surface(0),
m_service(service),
m_viewFinderRunning(false),
m_textureId(0)
{
}
AalVideoRendererControl::~AalVideoRendererControl()
{
}
QAbstractVideoSurface *AalVideoRendererControl::surface() const
{
return m_surface;
}
void AalVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
{
Q_UNUSED(surface);
}
void AalVideoRendererControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
}
void AalVideoRendererControl::startPreview()
{
}
void AalVideoRendererControl::stopPreview()
{
}
bool AalVideoRendererControl::isViewfinderRunning() const
{
return m_viewFinderRunning;
}
void AalVideoRendererControl::updateViewfinderFrame()
{
}
void AalVideoRendererControl::onTextureCreated(unsigned int textureID)
{
Q_UNUSED(textureID);
}
void AalVideoRendererControl::onSnapshotTaken(QImage snapshotImage)
{
Q_UNUSED(snapshotImage);
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalviewfindersettingscontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000003146 12305354476 033300 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
}
AalCameraService::~AalCameraService()
{
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isCameraActive() const
{
return true;
}
bool AalCameraService::isBackCameraUsed() const
{
return true;
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerazoomcontrol/ 0000755 0000152 0177776 00000000000 12305354713 025505 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerazoomcontrol/tst_aalcamerazoomcontrol.cpp 0000644 0000152 0177776 00000004032 12305354476 033324 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalcamerazoomcontrol.h"
class tst_AalCameraZoomControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void zoomTo();
private:
AalCameraZoomControl *m_zoomControl;
AalCameraService *m_service;
};
void tst_AalCameraZoomControl::initTestCase()
{
m_service = new AalCameraService();
m_zoomControl = m_service->zoomControl();
}
void tst_AalCameraZoomControl::cleanupTestCase()
{
delete m_service;
}
void tst_AalCameraZoomControl::zoomTo()
{
QSignalSpy spy(m_zoomControl, SIGNAL(currentDigitalZoomChanged(qreal)));
int zoom = 3.0;
m_zoomControl->zoomTo(1.0, zoom);
QCOMPARE(m_zoomControl->currentDigitalZoom(), 1.0);
QCOMPARE(spy.count(), 0);
m_service->connectCamera();
zoom = 3.0;
m_zoomControl->zoomTo(1.0, zoom);
QCOMPARE(m_zoomControl->currentDigitalZoom(), 3.0);
QCOMPARE(spy.count(), 1);
// video mode resets to 1
m_zoomControl->enableVideoMode();
QCOMPARE(m_zoomControl->currentDigitalZoom(), 1.0);
QCOMPARE(spy.count(), 2);
// video does not support zoom
m_zoomControl->zoomTo(2.0, zoom);
QCOMPARE(m_zoomControl->currentDigitalZoom(), 1.0);
QCOMPARE(spy.count(), 2);
}
QTEST_MAIN(tst_AalCameraZoomControl)
#include "tst_aalcamerazoomcontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerazoomcontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000004004 12305354476 031504 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
#include "aalcameracontrol.h"
#include
#include
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
m_cameraControl = new AalCameraControl(this);
m_zoomControl = new AalCameraZoomControl(this);
}
AalCameraService::~AalCameraService()
{
delete m_cameraControl;
delete m_zoomControl;
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
m_androidListener = new CameraControlListener;
m_androidControl = android_camera_connect_to(BACK_FACING_CAMERA_TYPE, m_androidListener);
initControls(m_androidControl, m_androidListener);
return true;
}
void AalCameraService::disconnectCamera()
{
delete m_androidListener;
android_camera_disconnect(m_androidControl);
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
m_zoomControl->init(camControl, listener);
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerazoomcontrol/aalcamerazoomcontrol.pro 0000644 0000152 0177776 00000001023 12305354476 032445 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalcamerazoomcontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalcamerazoomcontrol.h \
../../src/aalcameracontrol.h \
../../src/aalcameraservice.h
SOURCES += tst_aalcamerazoomcontrol.cpp \
../../src/aalcamerazoomcontrol.cpp \
../stubs/aalcameracontrol_stub.cpp \
aalcameraservice.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/ 0000755 0000152 0177776 00000000000 12305354713 026016 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/storagemanager.cpp 0000644 0000152 0177776 00000002725 12305354476 031535 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "storagemanager.h"
StorageManager::StorageManager()
{
}
QString StorageManager::nextPhotoFileName(const QString &directory)
{
Q_UNUSED(directory);
return QString();
}
QString StorageManager::nextVideoFileName(const QString &directory)
{
Q_UNUSED(directory);
return QString();
}
bool StorageManager::checkDirectory(const QString &path) const
{
Q_UNUSED(path);
return true;
}
QString StorageManager::nextMediaFileName(const QString &base, const QString &extension)
{
Q_UNUSED(base);
Q_UNUSED(extension);
return QString();
}
QString StorageManager::fileNameGenerator(int idx, const QString &base,
const QString& extension)
{
Q_UNUSED(idx);
Q_UNUSED(base);
Q_UNUSED(extension);
return QString();
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/aalimageencodercontrol.cpp 0000644 0000152 0177776 00000004171 12305354476 033234 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#include
#include "aalimageencodercontrol.h"
AalImageEncoderControl::AalImageEncoderControl(AalCameraService *service, QObject *parent)
: QImageEncoderControl(parent),
m_service(service),
m_currentSize()
{
}
AalImageEncoderControl::~AalImageEncoderControl()
{
}
QString AalImageEncoderControl::imageCodecDescription(const QString &codec) const
{
Q_UNUSED(codec);
return QString();
}
QImageEncoderSettings AalImageEncoderControl::imageSettings() const
{
return QImageEncoderSettings();
}
void AalImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
{
Q_UNUSED(settings);
}
QStringList AalImageEncoderControl::supportedImageCodecs() const
{
return QStringList();
}
QList AalImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
return QList();
}
void AalImageEncoderControl::init(CameraControl *control)
{
Q_UNUSED(control);
}
void AalImageEncoderControl::setSize(const QSize &size)
{
Q_UNUSED(size);
}
void AalImageEncoderControl::resetAllSettings()
{
}
void AalImageEncoderControl::setPictureSizeCb(void *ctx, int width, int height)
{
Q_UNUSED(ctx);
Q_UNUSED(width);
Q_UNUSED(height);
}
void AalImageEncoderControl::setPictureSize(int width, int height)
{
Q_UNUSED(width);
Q_UNUSED(height);
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/aalvideorenderercontrol.cpp 0000644 0000152 0177776 00000003614 12305354476 033450 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideorenderercontrol.h"
#include "aalcameraservice.h"
AalVideoRendererControl::AalVideoRendererControl(AalCameraService *service, QObject *parent)
: QVideoRendererControl(parent)
, m_surface(0),
m_service(service),
m_viewFinderRunning(false),
m_textureId(0)
{
}
AalVideoRendererControl::~AalVideoRendererControl()
{
}
QAbstractVideoSurface *AalVideoRendererControl::surface() const
{
return m_surface;
}
void AalVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
{
Q_UNUSED(surface);
}
void AalVideoRendererControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
}
void AalVideoRendererControl::startPreview()
{
}
void AalVideoRendererControl::stopPreview()
{
}
bool AalVideoRendererControl::isViewfinderRunning() const
{
return m_viewFinderRunning;
}
void AalVideoRendererControl::updateViewfinderFrame()
{
}
void AalVideoRendererControl::onTextureCreated(unsigned int textureID)
{
Q_UNUSED(textureID);
}
void AalVideoRendererControl::onSnapshotTaken(QImage snapshotImage)
{
Q_UNUSED(snapshotImage);
}
const QImage &AalVideoRendererControl::preview() const
{
return m_preview;
}
void AalVideoRendererControl::createPreview()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/aalimagecapturecontrol.pro 0000644 0000152 0177776 00000001373 12305354476 033277 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalimagecapturecontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalimagecapturecontrol.h \
../../src/aalcameraservice.h \
../../src/aalimageencodercontrol.h \
../../src/aalmetadatawritercontrol.h \
../../src/aalvideorenderercontrol.h \
../../src/storagemanager.h
SOURCES += tst_aalimagecapturecontrol.cpp \
../../src/aalimagecapturecontrol.cpp \
aalcameraservice.cpp \
aalimageencodercontrol.cpp \
../stubs/aalmetadatawritercontrol_stub.cpp \
aalvideorenderercontrol.cpp \
storagemanager.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/tst_aalimagecapturecontrol.cpp0000644 0000152 0177776 00000005376 12305354476 034162 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalimagecapturecontrol.h"
class tst_AalImageCaptureControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void chooseOptimalSize16by9();
void chooseOptimalSizeEmpty();
void priorityAspectRatio();
private:
AalImageCaptureControl *m_icControl;
AalCameraService *m_service;
friend class AalImageCaptureControl;
};
void tst_AalImageCaptureControl::initTestCase()
{
m_service = new AalCameraService();
m_icControl = new AalImageCaptureControl(m_service);
}
void tst_AalImageCaptureControl::cleanupTestCase()
{
delete m_icControl;
delete m_service;
}
void tst_AalImageCaptureControl::chooseOptimalSize16by9()
{
Q_ASSERT(m_service->isBackCameraUsed());
m_icControl->m_aspectRatio = 16.0f / 9.0f;
QList resolutions;
resolutions.append(QSize(1920, 1080));
resolutions.append(QSize(1280, 720));
resolutions.append(QSize(960, 720));
QCOMPARE(m_icControl->chooseOptimalSize(resolutions), QSize(1920, 1080));
}
void tst_AalImageCaptureControl::chooseOptimalSizeEmpty()
{
m_icControl->m_aspectRatio = 4.0f / 3.0f;
QList resolutions;
QCOMPARE(m_icControl->chooseOptimalSize(resolutions), QSize());
}
void tst_AalImageCaptureControl::priorityAspectRatio()
{
Q_ASSERT(m_service->isBackCameraUsed());
QList backAspectRatios;
backAspectRatios.append(16.0f / 9.0f);
backAspectRatios.append(15.0f / 10.0f);
backAspectRatios.append(4.0f / 3.0f);
backAspectRatios.append(5.0f / 4.0f);
m_icControl->getPriorityAspectRatios();
for (uint8_t i=0; i<4; ++i) {
const float EPSILON = 10e-2;
qDebug() << "m_icControl->m_prioritizedAspectRatios[i]: " << m_icControl->m_prioritizedAspectRatios[i] << endl;
qDebug() << "backAspectRatios[i]: " << backAspectRatios[i] << endl;
Q_ASSERT(fabs(m_icControl->m_prioritizedAspectRatios[i] - backAspectRatios[i]) < EPSILON);
}
}
QTEST_MAIN(tst_AalImageCaptureControl)
#include "tst_aalimagecapturecontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalimagecapturecontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000003146 12305354476 032023 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
}
AalCameraService::~AalCameraService()
{
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isCameraActive() const
{
return true;
}
bool AalCameraService::isBackCameraUsed() const
{
return true;
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameracontrol/ 0000755 0000152 0177776 00000000000 12305354713 024600 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameracontrol/aalcameracontrol.pro 0000644 0000152 0177776 00000000667 12305354476 030650 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalcameracontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalcameracontrol.h \
../../src/aalcameraservice.h
SOURCES += tst_aalcameracontrol.cpp \
../../src/aalcameracontrol.cpp \
aalcameraservice.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameracontrol/tst_aalcameracontrol.cpp 0000644 0000152 0177776 00000003645 12305354476 031523 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalcameracontrol.h"
class tst_AalCameraControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void setState();
void captureMode();
private:
AalCameraControl *m_cameraControl;
AalCameraService *m_service;
};
void tst_AalCameraControl::initTestCase()
{
m_service = new AalCameraService();
m_cameraControl = new AalCameraControl(m_service);
}
void tst_AalCameraControl::cleanupTestCase()
{
delete m_cameraControl;
delete m_service;
}
void tst_AalCameraControl::setState()
{
QSignalSpy spy(m_cameraControl, SIGNAL(stateChanged(QCamera::State)));
QCamera::State state = QCamera::ActiveState;
m_cameraControl->setState(state);
QCOMPARE(m_cameraControl->state(), state);
QCOMPARE(spy.count(), 1);
}
void tst_AalCameraControl::captureMode()
{
QSignalSpy spy(m_cameraControl, SIGNAL(captureModeChanged(QCamera::CaptureModes)));
QCamera::CaptureModes mode = QCamera::CaptureVideo;
m_cameraControl->setCaptureMode(mode);
QCOMPARE(m_cameraControl->captureMode(), mode);
QCOMPARE(spy.count(), 1);
}
QTEST_MAIN(tst_AalCameraControl)
#include "tst_aalcameracontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameracontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000003276 12305354476 030611 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
}
AalCameraService::~AalCameraService()
{
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
bool AalCameraService::isCameraActive() const
{
return true;
}
void AalCameraService::enablePhotoMode()
{
}
void AalCameraService::enableVideoMode()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isRecording() const
{
return false;
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameraflashcontrol/ 0000755 0000152 0177776 00000000000 12305354713 025616 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameraflashcontrol/tst_aalcameraflashcontrol.cpp 0000644 0000152 0177776 00000003160 12305354476 033547 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include "aalcameraservice.h"
#define private public
#include "aalcameraflashcontrol.h"
class tst_AalCameraFlashControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void flashMode();
private:
AalCameraFlashControl *m_flashControl;
AalCameraService *m_service;
};
void tst_AalCameraFlashControl::initTestCase()
{
m_service = new AalCameraService();
m_flashControl = new AalCameraFlashControl(m_service);
}
void tst_AalCameraFlashControl::cleanupTestCase()
{
delete m_flashControl;
delete m_service;
}
void tst_AalCameraFlashControl::flashMode()
{
m_flashControl->m_supportedModes << QCameraExposure::FlashOff << QCameraExposure::FlashOn;
QCameraExposure::FlashModes mode = QCameraExposure::FlashOn;
m_flashControl->setFlashMode(mode);
QCOMPARE(m_flashControl->flashMode(), mode);
}
QTEST_MAIN(tst_AalCameraFlashControl)
#include "tst_aalcameraflashcontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameraflashcontrol/aalcameraflashcontrol.pro 0000644 0000152 0177776 00000001027 12305354476 032673 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalcameraflashcontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalcameraflashcontrol.h \
../../src/aalcameracontrol.h \
../../src/aalcameraservice.h
SOURCES += tst_aalcameraflashcontrol.cpp \
../../src/aalcameraflashcontrol.cpp \
../stubs/aalcameracontrol_stub.cpp \
aalcameraservice.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcameraflashcontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000003322 12305354476 031617 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
#include "aalcameracontrol.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
m_cameraControl = new AalCameraControl(this);
}
AalCameraService::~AalCameraService()
{
delete m_cameraControl;
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isCameraActive() const
{
return true;
}
bool AalCameraService::isBackCameraUsed() const
{
return true;
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerafocuscontrol/ 0000755 0000152 0177776 00000000000 12305354713 025640 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerafocuscontrol/aalimagecapturecontrol.cpp 0000644 0000152 0177776 00000003110 12305354476 033072 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalimagecapturecontrol.h"
#include
#include
StorageManager::StorageManager()
{
}
AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent)
: QCameraImageCaptureControl(parent)
{
Q_UNUSED(service);
}
AalImageCaptureControl::~AalImageCaptureControl()
{
}
int AalImageCaptureControl::capture(const QString &fileName)
{
Q_UNUSED(fileName);
return 0;
}
void AalImageCaptureControl::cancelCapture()
{
}
bool AalImageCaptureControl::isReadyForCapture() const
{
return true;
}
void AalImageCaptureControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
}
void AalImageCaptureControl::onPreviewReady()
{
}
void AalImageCaptureControl::setReady(bool ready)
{
Q_UNUSED(ready);
}
void AalImageCaptureControl::shutter()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerafocuscontrol/tst_aalcamerafocuscontrol.cpp 0000644 0000152 0177776 00000006612 12305354476 033620 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalcamerafocuscontrol.h"
class tst_AalCameraFocusControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void customPoint();
void focusMode();
void focusPointMode();
void point2Region_data();
void point2Region();
private:
AalCameraFocusControl *m_focusControl;
AalCameraService *m_service;
};
void tst_AalCameraFocusControl::initTestCase()
{
m_service = new AalCameraService();
m_focusControl = new AalCameraFocusControl(m_service);
}
void tst_AalCameraFocusControl::cleanupTestCase()
{
delete m_focusControl;
delete m_service;
}
void tst_AalCameraFocusControl::customPoint()
{
QSignalSpy spy(m_focusControl, SIGNAL(customFocusPointChanged(const QPointF &)));
QPointF point(0.2, 0.3);
m_focusControl->setCustomFocusPoint(point);
QCOMPARE(m_focusControl->customFocusPoint(), point);
QCOMPARE(spy.count(), 1);
}
void tst_AalCameraFocusControl::focusMode()
{
QSignalSpy spy(m_focusControl, SIGNAL(focusModeChanged(QCameraFocus::FocusModes)));
QCameraFocus::FocusModes mode = QCameraFocus::InfinityFocus;
m_focusControl->setFocusMode(mode);
QCOMPARE(m_focusControl->focusMode(), mode);
QCOMPARE(spy.count(), 1);
}
void tst_AalCameraFocusControl::focusPointMode()
{
QSignalSpy spy(m_focusControl, SIGNAL(focusPointModeChanged(QCameraFocus::FocusPointMode)));
QCameraFocus::FocusPointMode mode = QCameraFocus::FocusPointCenter;
m_focusControl->setFocusPointMode(mode);
QCOMPARE(m_focusControl->focusPointMode(), mode);
QCOMPARE(spy.count(), 1);
}
void tst_AalCameraFocusControl::point2Region_data()
{
QTest::addColumn("x");
QTest::addColumn("y");
QTest::addColumn("left");
QTest::addColumn("right");
QTest::addColumn("top");
QTest::addColumn("bottom");
QTest::newRow("center") << (qreal)0.5 << (qreal)0.5 << -100 << 100 << -100 << 100;
QTest::newRow("topLeft") << (qreal)0.0 << (qreal)1.0 << -1000 << -800 << -1000 << -800;
QTest::newRow("bottomRight") << (qreal)1.0 << (qreal)0.0 << 800 << 1000 << 800 << 1000;
}
void tst_AalCameraFocusControl::point2Region()
{
QFETCH(qreal, x);
QFETCH(qreal, y);
QFETCH(int, left);
QFETCH(int, right);
QFETCH(int, top);
QFETCH(int, bottom);
AalCameraFocusControl focusControl(0);
QPointF point(x, y);
FocusRegion region;
region = m_focusControl->point2Region(point);
QCOMPARE(region.left, left);
QCOMPARE(region.right, right);
QCOMPARE(region.top, top);
QCOMPARE(region.bottom, bottom);
}
QTEST_MAIN(tst_AalCameraFocusControl)
#include "tst_aalcamerafocuscontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerafocuscontrol/aalcamerafocuscontrol.pro 0000644 0000152 0177776 00000001025 12305354476 032735 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalcamerafocuscontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalcamerafocuscontrol.h \
../../src/aalcameraservice.h \
../../src/aalimagecapturecontrol.h
SOURCES += tst_aalcamerafocuscontrol.cpp \
../../src/aalcamerafocuscontrol.cpp \
aalcameraservice.cpp \
aalimagecapturecontrol.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalcamerafocuscontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000002734 12305354476 031647 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
}
AalCameraService::~AalCameraService()
{
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/ 0000755 0000152 0177776 00000000000 12305354713 027377 5 ustar pbuser nogroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011211 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalimageencodercontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalimageencodercontrol.0000644 0000152 0177776 00000004047 12305354476 034114 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalimageencodercontrol.h"
#include "aalcameraservice.h"
AalImageEncoderControl::AalImageEncoderControl(AalCameraService *service, QObject *parent)
: QImageEncoderControl(parent),
m_service(service),
m_currentSize()
{
}
AalImageEncoderControl::~AalImageEncoderControl()
{
}
QString AalImageEncoderControl::imageCodecDescription(const QString &codec) const
{
Q_UNUSED(codec);
return QString();
}
QImageEncoderSettings AalImageEncoderControl::imageSettings() const
{
return QImageEncoderSettings();
}
void AalImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
{
Q_UNUSED(settings);
}
QStringList AalImageEncoderControl::supportedImageCodecs() const
{
return QStringList();
}
QList AalImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
return QList();
}
void AalImageEncoderControl::init(CameraControl *control)
{
Q_UNUSED(control);
}
void AalImageEncoderControl::setSize(const QSize &size)
{
Q_UNUSED(size);
}
void AalImageEncoderControl::resetAllSettings()
{
}
void AalImageEncoderControl::setPictureSizeCb(void *ctx, int width, int height)
{
Q_UNUSED(ctx);
Q_UNUSED(width);
Q_UNUSED(height);
}
void AalImageEncoderControl::setPictureSize(int width, int height)
{
Q_UNUSED(width);
Q_UNUSED(height);
}
././@LongLink 0000000 0000000 0000000 00000000163 00000000000 011215 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselectorcontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/tst_aalvideodeviceselec0000644 0000152 0177776 00000003421 12305354476 034202 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalvideodeviceselectorcontrol.h"
class tst_AalVideoDeviceSelectorControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void selectDevice();
private:
AalVideoDeviceSelectorControl *m_selectControl;
AalCameraService *m_service;
};
void tst_AalVideoDeviceSelectorControl::initTestCase()
{
m_service = new AalCameraService();
m_selectControl = new AalVideoDeviceSelectorControl(m_service);
}
void tst_AalVideoDeviceSelectorControl::cleanupTestCase()
{
delete m_selectControl;
delete m_service;
}
void tst_AalVideoDeviceSelectorControl::selectDevice()
{
QSignalSpy spy(m_selectControl, SIGNAL(selectedDeviceChanged(int)));
QSignalSpy spy2(m_selectControl, SIGNAL(selectedDeviceChanged(QString)));
m_selectControl->setSelectedDevice(1);
QCOMPARE(m_selectControl->selectedDevice(), 1);
QCOMPARE(spy.count(), 1);
QCOMPARE(spy2.count(), 1);
}
QTEST_MAIN(tst_AalVideoDeviceSelectorControl)
#include "tst_aalvideodeviceselectorcontrol.moc"
././@LongLink 0000000 0000000 0000000 00000000157 00000000000 011220 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorcontrol.pro qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalvideodeviceselectorc0000644 0000152 0177776 00000001233 12305354476 034177 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalvideodeviceselectorcontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalvideodeviceselectorcontrol.h \
../../src/aalcameraservice.h \
../../src/aalvideoencodersettingscontrol.h
SOURCES += tst_aalvideodeviceselectorcontrol.cpp \
../../src/aalvideodeviceselectorcontrol.cpp \
aalcameraservice.cpp \
aalimageencodercontrol.cpp \
aalviewfindersettingscontrol.cpp \
../stubs/aalvideoencodersettingscontrol_stub.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
././@LongLink 0000000 0000000 0000000 00000000156 00000000000 011217 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalviewfindersettingscontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalviewfindersettingsco0000644 0000152 0177776 00000003054 12305354476 034255 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalviewfindersettingscontrol.h"
#include "aalcameraservice.h"
AalViewfinderSettingsControl::AalViewfinderSettingsControl(AalCameraService *service, QObject *parent)
:QCameraViewfinderSettingsControl(parent),
m_service(service),
m_currentSize(),
m_currentFPS(30),
m_minFPS(10),
m_maxFPS(30)
{
}
AalViewfinderSettingsControl::~AalViewfinderSettingsControl()
{
}
bool AalViewfinderSettingsControl::isViewfinderParameterSupported(ViewfinderParameter parameter) const
{
Q_UNUSED(parameter);
return false;
}
void AalViewfinderSettingsControl::setViewfinderParameter(ViewfinderParameter parameter, const QVariant &value)
{
Q_UNUSED(parameter);
Q_UNUSED(value);
}
QVariant AalViewfinderSettingsControl::viewfinderParameter(ViewfinderParameter parameter) const
{
Q_UNUSED(parameter);
return QVariant();
}
void AalViewfinderSettingsControl::resetAllSettings()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalvideodeviceselectorcontrol/aalcameraservice.cpp 0000644 0000152 0177776 00000003237 12305354476 033405 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_androidControl(0),
m_androidListener(0)
{
}
AalCameraService::~AalCameraService()
{
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
return true;
}
void AalCameraService::disconnectCamera()
{
}
bool AalCameraService::isCameraActive() const
{
return true;
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isReady() const
{
return true;
}
bool AalCameraService::isRecording() const
{
return false;
}
void AalCameraService::updateCaptureReady()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/ 0000755 0000152 0177776 00000000000 12305354713 022431 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/storagemanager_stub.cpp 0000644 0000152 0177776 00000002725 12305354476 027205 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include "storagemanager.h"
StorageManager::StorageManager()
{
}
QString StorageManager::nextPhotoFileName(const QString &directory)
{
Q_UNUSED(directory);
return QString();
}
QString StorageManager::nextVideoFileName(const QString &directory)
{
Q_UNUSED(directory);
return QString();
}
bool StorageManager::checkDirectory(const QString &path) const
{
Q_UNUSED(path);
return true;
}
QString StorageManager::nextMediaFileName(const QString &base, const QString &extension)
{
Q_UNUSED(base);
Q_UNUSED(extension);
return QString();
}
QString StorageManager::fileNameGenerator(int idx, const QString &base,
const QString& extension)
{
Q_UNUSED(idx);
Q_UNUSED(base);
Q_UNUSED(extension);
return QString();
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/aalcameraservice_stub.cpp 0000644 0000152 0177776 00000004147 12305354476 027475 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
#include "aalvideoencodersettingscontrol.h"
#include "storagemanager.h"
#include "camera_control.h"
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent) :
QMediaService(parent),
m_metadataWriter(0),
m_androidControl(0),
m_androidListener(0)
{
m_storageManager = new StorageManager;
m_videoEncoderControl = new AalVideoEncoderSettingsControl(this);
}
AalCameraService::~AalCameraService()
{
delete m_storageManager;
delete m_androidControl;
delete m_videoEncoderControl;
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
Q_UNUSED(name);
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
bool AalCameraService::connectCamera()
{
m_androidControl = new CameraControl;
return true;
}
void AalCameraService::disconnectCamera()
{
}
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
delete m_androidControl;
m_androidControl = 0;
Q_UNUSED(camControl);
Q_UNUSED(listener);
}
bool AalCameraService::isCameraActive() const
{
return true;
}
bool AalCameraService::isBackCameraUsed() const
{
return true;
}
void AalCameraService::updateCaptureReady()
{
}
StorageManager *AalCameraService::storageManager()
{
return m_storageManager;
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/aalvideoencodersettingscontrol_stub.cpp 0000644 0000152 0177776 00000004127 12305354476 032512 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideoencodersettingscontrol.h"
#include "aalcameraservice.h"
const QSize AalVideoEncoderSettingsControl::DEFAULT_SIZE = QSize(1280,720);
const int AalVideoEncoderSettingsControl::DEFAULT_FPS = 30;
AalVideoEncoderSettingsControl::AalVideoEncoderSettingsControl(AalCameraService *service, QObject *parent)
: QVideoEncoderSettingsControl(parent),
m_service(service)
{
}
void AalVideoEncoderSettingsControl::setVideoSettings(const QVideoEncoderSettings &settings)
{
Q_UNUSED(settings);
}
QList AalVideoEncoderSettingsControl::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
QList fps;
fps << 30;
return fps;
}
QList AalVideoEncoderSettingsControl::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
return m_availableSizes;
}
QStringList AalVideoEncoderSettingsControl::supportedVideoCodecs() const
{
QStringList codecs;
codecs << QString("H.264");
return codecs;
}
QString AalVideoEncoderSettingsControl::videoCodecDescription(const QString &codec) const
{
return codec;
}
QVideoEncoderSettings AalVideoEncoderSettingsControl::videoSettings() const
{
return m_settings;
}
float AalVideoEncoderSettingsControl::getAspectRatio() const
{
return 16.0 / 9.0;
}
void AalVideoEncoderSettingsControl::resetAllSettings()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/aalmetadatawritercontrol_stub.cpp 0000644 0000152 0177776 00000003105 12305354476 031273 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalmetadatawritercontrol.h"
#include "aalcameraservice.h"
AalMetaDataWriterControl::AalMetaDataWriterControl(AalCameraService *service, QObject *parent) :
QMetaDataWriterControl(parent),
m_service(service)
{
}
QStringList AalMetaDataWriterControl::availableMetaData() const
{
QStringList keys;
return keys;
}
bool AalMetaDataWriterControl::isMetaDataAvailable() const
{
return true;
}
bool AalMetaDataWriterControl::isWritable() const
{
return true;
}
QVariant AalMetaDataWriterControl::metaData(const QString &key) const
{
Q_UNUSED(key);
return QVariant();
}
void AalMetaDataWriterControl::setMetaData(const QString &key, const QVariant &value)
{
m_metaData[key] = value;
}
int AalMetaDataWriterControl::orientation() const
{
return m_orientation;
}
int AalMetaDataWriterControl::correctedOrientation() const
{
return m_orientation;
}
void AalMetaDataWriterControl::clearAllMetaData()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/aalcameracontrol_stub.cpp 0000644 0000152 0177776 00000004107 12305354476 027511 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameracontrol.h"
#include "aalcameraservice.h"
#include
AalCameraControl::AalCameraControl(AalCameraService *service, QObject *parent)
: QCameraControl(parent),
m_service(service),
m_state(QCamera::UnloadedState),
m_status(QCamera::UnloadedStatus),
m_captureMode(QCamera::CaptureStillImage)
{
}
AalCameraControl::~AalCameraControl()
{
}
QCamera::State AalCameraControl::state() const
{
return m_state;
}
void AalCameraControl::setState(QCamera::State state)
{
m_state = state;
Q_EMIT stateChanged(m_state);
}
QCamera::Status AalCameraControl::status() const
{
return m_status;
}
QCamera::CaptureModes AalCameraControl::captureMode() const
{
return m_captureMode;
}
void AalCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
m_captureMode = mode;
Q_EMIT captureModeChanged(mode);
}
bool AalCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const
{
Q_UNUSED(mode);
return true;
}
bool AalCameraControl::canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const
{
Q_UNUSED(changeType);
Q_UNUSED(status);
return true;
}
void AalCameraControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
}
void AalCameraControl::handleError()
{
}
void AalCameraControl::errorCB(void *context)
{
Q_UNUSED(context);
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/stubs/aalmediarecordercontrol_stub.cpp 0000644 0000152 0177776 00000004722 12305354476 031071 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
#include "aalmediarecordercontrol.h"
AalMediaRecorderControl::AalMediaRecorderControl(AalCameraService *service, QObject *parent)
: QMediaRecorderControl(parent),
m_service(service),
m_mediaRecorder(0),
m_duration(0),
m_currentState(QMediaRecorder::StoppedState),
m_currentStatus(QMediaRecorder::UnloadedStatus),
m_recordingTimer(0)
{
}
AalMediaRecorderControl::~AalMediaRecorderControl()
{
}
void AalMediaRecorderControl::applySettings()
{
qDebug() << Q_FUNC_INFO << " is not used";
}
qint64 AalMediaRecorderControl::duration() const
{
return m_duration;
}
bool AalMediaRecorderControl::isMuted() const
{
return false;
}
QUrl AalMediaRecorderControl::outputLocation() const
{
return m_outputLocation;
}
bool AalMediaRecorderControl::setOutputLocation(const QUrl &location)
{
Q_UNUSED(location);
return true;
}
QMediaRecorder::State AalMediaRecorderControl::state() const
{
return m_currentState;
}
QMediaRecorder::Status AalMediaRecorderControl::status() const
{
return m_currentStatus;
}
qreal AalMediaRecorderControl::volume() const
{
return 1.0;
}
void AalMediaRecorderControl::init()
{
}
void AalMediaRecorderControl::deleteRecorder()
{
}
void AalMediaRecorderControl::setMuted(bool muted)
{
Q_UNUSED(muted);
}
void AalMediaRecorderControl::setState(QMediaRecorder::State state)
{
Q_UNUSED(state);
}
void AalMediaRecorderControl::setVolume(qreal gain)
{
Q_UNUSED(gain);
}
void AalMediaRecorderControl::updateDuration()
{
}
void AalMediaRecorderControl::handleError()
{
Q_EMIT error(-1, "Error on recording video");
}
void AalMediaRecorderControl::setStatus(QMediaRecorder::Status status)
{
Q_UNUSED(status);
}
int AalMediaRecorderControl::startRecording()
{
return 0;
}
void AalMediaRecorderControl::stopRecording()
{
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/unittests.pro 0000644 0000152 0177776 00000000504 12305354476 024062 0 ustar pbuser nogroup 0000000 0000000 include(../coverage.pri)
TEMPLATE = subdirs
SUBDIRS += \
mocks \
aalcameracontrol \
aalcameraflashcontrol \
aalcamerafocuscontrol \
aalcamerazoomcontrol \
aalimagecapturecontrol \
aalmediarecordercontrol \
aalvideodeviceselectorcontrol \
aalviewfindersettingscontrol \
storagemanager
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalmediarecordercontrol/ 0000755 0000152 0177776 00000000000 12305354713 026155 5 ustar pbuser nogroup 0000000 0000000 ././@LongLink 0000000 0000000 0000000 00000000147 00000000000 011217 L ustar 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalmediarecordercontrol/tst_aalmediarecordercontrol.cpp qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalmediarecordercontrol/tst_aalmediarecordercontrol.c0000644 0000152 0177776 00000004546 12305354476 034116 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include "aalcameraservice.h"
#define private public
#include "aalmediarecordercontrol.h"
class tst_AalMediaRecorderControl : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void setState();
private:
AalMediaRecorderControl *m_recorderControl;
AalCameraService *m_service;
};
void tst_AalMediaRecorderControl::initTestCase()
{
m_service = new AalCameraService();
m_recorderControl = new AalMediaRecorderControl(m_service);
m_service->connectCamera();
}
void tst_AalMediaRecorderControl::cleanupTestCase()
{
delete m_recorderControl;
delete m_service;
}
void tst_AalMediaRecorderControl::setState()
{
QString fileName("/tmp/videotest.avi");
QFile::remove(fileName);
m_recorderControl->setOutputLocation(QUrl(fileName));
QCOMPARE(m_recorderControl->state(), QMediaRecorder::StoppedState);
QCOMPARE(m_recorderControl->status(), QMediaRecorder::UnloadedStatus);
m_recorderControl->setState(QMediaRecorder::RecordingState);
QCOMPARE(m_recorderControl->state(), QMediaRecorder::RecordingState);
QCOMPARE(m_recorderControl->status(), QMediaRecorder::RecordingStatus);
m_recorderControl->setState(QMediaRecorder::PausedState);
QCOMPARE(m_recorderControl->state(), QMediaRecorder::RecordingState);
QCOMPARE(m_recorderControl->status(), QMediaRecorder::RecordingStatus);
m_recorderControl->setState(QMediaRecorder::StoppedState);
QCOMPARE(m_recorderControl->state(), QMediaRecorder::StoppedState);
QCOMPARE(m_recorderControl->status(), QMediaRecorder::UnloadedStatus);
}
QTEST_MAIN(tst_AalMediaRecorderControl)
#include "tst_aalmediarecordercontrol.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/aalmediarecordercontrol/aalmediarecordercontrol.pro 0000644 0000152 0177776 00000001356 12305354476 033576 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_aalmediarecordercontrol
QT += testlib multimedia opengl
LIBS += -L../mocks/aal -laal
INCLUDEPATH += ../../src
INCLUDEPATH += ../mocks/aal
HEADERS += ../../src/aalmediarecordercontrol.h \
../../src/aalcameraservice.h \
../../src/aalvideoencodersettingscontrol.h \
../../src/aalmetadatawritercontrol.h \
../../src/storagemanager.h
SOURCES += tst_aalmediarecordercontrol.cpp \
../../src/aalmediarecordercontrol.cpp \
../stubs/aalcameraservice_stub.cpp \
../stubs/aalvideoencodersettingscontrol_stub.cpp \
../stubs/aalmetadatawritercontrol_stub.cpp \
../stubs/storagemanager_stub.cpp
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/storagemanager/ 0000755 0000152 0177776 00000000000 12305354713 024270 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/storagemanager/tst_storagemanager.cpp 0000644 0000152 0177776 00000007310 12305354476 030674 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#include
#define private public
#include "storagemanager.h"
const QLatin1String testPath("/tmp/aalCameraStorageManagerUnitTestDirectory0192837465/");
class tst_StorageManager : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void nextFileName();
void checkDirectory();
void fileNameGenerator_data();
void fileNameGenerator();
private:
void removeTestDirectory();
};
void tst_StorageManager::initTestCase()
{
removeTestDirectory();
}
void tst_StorageManager::cleanupTestCase()
{
removeTestDirectory();
}
void tst_StorageManager::nextFileName()
{
StorageManager storage;
const QLatin1String photoBase("image");
const QLatin1String videoBase("video");
QString fileName = storage.nextPhotoFileName(testPath);
QString compareFileName = storage.fileNameGenerator(1, photoBase,"jpg");
QCOMPARE(fileName, compareFileName);
QDir dir;
dir.mkpath(testPath);
QFile file(compareFileName);
file.open(QIODevice::ReadWrite);
file.close();
fileName = storage.nextPhotoFileName(testPath);
compareFileName = storage.fileNameGenerator(2, photoBase, "jpg");
QCOMPARE(fileName, compareFileName);
fileName = storage.nextVideoFileName(testPath);
compareFileName = storage.fileNameGenerator(1, videoBase, "mp4");
QCOMPARE(fileName, compareFileName);
removeTestDirectory();
}
void tst_StorageManager::checkDirectory()
{
StorageManager storage;
QString path = testPath;
bool ok = storage.checkDirectory(path);
QCOMPARE(ok, true);
QDir dir(path);
ok = dir.exists();
QCOMPARE(ok, true);
dir.rmdir(path);
QString file = "image007.jpg";
ok = storage.checkDirectory(path+file);
QCOMPARE(ok, true);
dir.setPath(path);
ok = dir.exists();
QCOMPARE(ok, true);
dir.rmdir(path);
}
void tst_StorageManager::fileNameGenerator_data()
{
QTest::addColumn("index");
QTest::addColumn("idxString");
QTest::addColumn("extension");
QTest::newRow("1") << 1 << "0001" << "jpg";
QTest::newRow("12") << 12 << "0012" << "mp4";
QTest::newRow("9999") << 9999 << "9999" << "jpg";
}
void tst_StorageManager::fileNameGenerator()
{
QFETCH(int, index);
QFETCH(QString, idxString);
QFETCH(QString, extension);
StorageManager storage;
storage.m_directory = "/tmp";
const QLatin1String photoBase("image");
QString date = QDate::currentDate().toString("yyyyMMdd");
QString expected = QString("/tmp/image%1_%2.%3").arg(date).arg(idxString).arg(extension);
QString generated = storage.fileNameGenerator(index, photoBase, extension);
QCOMPARE(generated, expected);
}
void tst_StorageManager::removeTestDirectory()
{
QDir dir(testPath);
QStringList fileNames = dir.entryList(QDir::Files);
foreach (QString fileName, fileNames) {
QFile::remove(testPath+fileName);
}
if (dir.exists())
dir.rmdir(testPath);
}
QTEST_MAIN(tst_StorageManager);
#include "tst_storagemanager.moc"
qtubuntu-camera-0.3.3+14.04.20140304/unittests/storagemanager/storagemanager.pro 0000644 0000152 0177776 00000000377 12305354476 030026 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TARGET = tst_storagemanager
QT += testlib
SOURCES += tst_storagemanager.cpp \
../../src/storagemanager.cpp
INCLUDEPATH += ../../src
check.depends = $${TARGET}
check.commands = ./$${TARGET}
QMAKE_EXTRA_TARGETS += check
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/ 0000755 0000152 0177776 00000000000 12305354713 022405 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/mocks.pro 0000644 0000152 0177776 00000000104 12305354476 024244 0 ustar pbuser nogroup 0000000 0000000 include(../../coverage.pri)
TEMPLATE = subdirs
SUBDIRS += \
aal
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/ 0000755 0000152 0177776 00000000000 12305354713 023142 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/camera_control.h 0000644 0000152 0177776 00000001572 12305354476 026316 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CAMERA_CONTROL_H_
#define CAMERA_CONTROL_H_
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
struct CameraControlListener;
struct CameraControl
{
CameraControlListener* listener;
};
#ifdef __cplusplus
}
#endif
#endif // CAMERA_CONTROL_H_
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/ubuntu_application_api.cpp 0000644 0000152 0177776 00000002166 12305354476 030417 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#include
#define UNUSED __attribute__((unused))
UAUiDisplay* ua_ui_display_new_with_index(UNUSED size_t index)
{
UAUiDisplay* display = 0;
return display;
}
void ua_ui_display_destroy(UNUSED UAUiDisplay* display)
{
}
uint32_t ua_ui_display_query_horizontal_res(UNUSED UAUiDisplay* display)
{
return 1920;
}
uint32_t ua_ui_display_query_vertical_res(UNUSED UAUiDisplay* display)
{
return 1080;
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/camera_compatibility_layer.h 0000644 0000152 0177776 00000013562 12305354476 030705 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Authored by: Thomas Voss
*/
#ifndef CAMERA_COMPATIBILITY_LAYER_H_
#define CAMERA_COMPATIBILITY_LAYER_H_
//#include "camera_compatibility_layer_capabilities.h"
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
// Forward declarations
struct SfSurface;
typedef enum
{
// This camera has higher quality and features like high resolution and flash
BACK_FACING_CAMERA_TYPE,
// The camera that is on the same side as the touch display. Usually used for video calls
FRONT_FACING_CAMERA_TYPE
} CameraType;
struct CameraControl;
struct CameraControlListener
{
typedef void (*on_msg_error)(void* context);
typedef void (*on_msg_shutter)(void* context);
typedef void (*on_msg_focus)(void* context);
typedef void (*on_msg_zoom)(void* context, int32_t new_zoom_level);
typedef void (*on_data_raw_image)(void* data, uint32_t data_size, void* context);
typedef void (*on_data_compressed_image)(void* data, uint32_t data_size, void* context);
typedef void (*on_preview_texture_needs_update)(void* context);
// Called whenever an error occurs while the camera HAL executes a command
on_msg_error on_msg_error_cb;
// Called while taking a picture when the shutter has been triggered
on_msg_shutter on_msg_shutter_cb;
// Called while focusing
on_msg_focus on_msg_focus_cb;
// Called while zooming
on_msg_zoom on_msg_zoom_cb;
// Raw image data (Bayer pattern) is reported over this callback
on_data_raw_image on_data_raw_image_cb;
// JPEG-compressed image is reported over this callback
on_data_compressed_image on_data_compressed_image_cb;
// If a texture has been set as a destination for preview frames,
// this callback is invoked whenever a new buffer from the camera is available
// and needs to be uploaded to the texture by means of calling
// android_camera_update_preview_texture. Please note that this callback can
// be invoked on any thread, and android_camera_update_preview_texture must only
// be called on the thread that setup the EGL/GL context.
on_preview_texture_needs_update on_preview_texture_needs_update_cb;
void* context;
};
// Initializes a connection to the camera, returns NULL on error.
CameraControl* android_camera_connect_to(CameraType camera_type, CameraControlListener* listener);
// Disconnects the camera and deletes the pointer
void android_camera_disconnect(CameraControl* control);
int android_camera_lock(CameraControl* control);
int android_camera_unlock(CameraControl* control);
// Deletes the CameraControl
void android_camera_delete(CameraControl* control);
// Passes the rotation r of the display in [°] relative to the camera to the camera HAL. r \in [0, 359].
void android_camera_set_display_orientation(CameraControl* control, int32_t clockwise_rotation_degree);
// Prepares the camera HAL to display preview images to the
// supplied surface/texture in a H/W-acclerated way. New frames
// are reported via the
// 'on_preview_texture_needs_update'-callback, and clients of this
// API should invoke android_camera_update_preview_texture
// subsequently. Please note that the texture is bound automatically by the underlying
// implementation.
void android_camera_set_preview_texture(CameraControl* control, int texture_id);
// Reads out the transformation matrix that needs to be applied when displaying the texture
void android_camera_get_preview_texture_transformation(CameraControl* control, float m[16]);
// Updates the texture to the last received frame and binds the texture
void android_camera_update_preview_texture(CameraControl* control);
// Prepares the camera HAL to display preview images to the supplied surface/texture in a H/W-acclerated way.
void android_camera_set_preview_surface(CameraControl* control, SfSurface* surface);
// Starts the camera preview
void android_camera_start_preview(CameraControl* control);
// Stops the camera preview
void android_camera_stop_preview(CameraControl* control);
// Starts an autofocus operation of the camera, results are reported via callback.
void android_camera_start_autofocus(CameraControl* control);
// Stops an ongoing autofocus operation.
void android_camera_stop_autofocus(CameraControl* control);
// Starts a zooming operation, zoom values are absolute, valid values [1, \infty].
void android_camera_start_zoom(CameraControl* control, int32_t zoom);
// Stops an ongoing zoom operation.
void android_camera_stop_zoom(CameraControl* control);
// Adjust the zoom level immediately as opposed to smoothly zoomin gin.
void android_camera_set_zoom(CameraControl* control, int32_t zoom);
// Takes a picture and reports back image data via
// callback. Please note that this stops the preview and thus, the
// preview needs to be restarted after the picture operation has
// completed. Ideally, this is done from the raw data callback.
void android_camera_take_snapshot(CameraControl* control);
#ifdef __cplusplus
}
#endif
#endif // CAMERA_COMPATIBILITY_LAYER_H_
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/recorder_compatibility_layer.cpp 0000644 0000152 0177776 00000006273 12305354476 031616 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include
#include "camera_control.h"
#include
class MediaRecorderListenerWrapper
{
public:
MediaRecorderListenerWrapper()
{
}
};
struct MediaRecorderWrapper
{
public:
MediaRecorderWrapper()
{
}
};
void android_recorder_set_error_cb(MediaRecorderWrapper *mr, on_recorder_msg_error cb,
void *context)
{
Q_UNUSED(mr);
Q_UNUSED(cb);
Q_UNUSED(context);
}
MediaRecorderWrapper *android_media_new_recorder()
{
MediaRecorderWrapper *mr = new MediaRecorderWrapper;
return mr;
}
int android_recorder_initCheck(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_setCamera(MediaRecorderWrapper *mr, CameraControl* control)
{
Q_UNUSED(mr);
Q_UNUSED(control);
return 0;
}
int android_recorder_setVideoSource(MediaRecorderWrapper *mr, VideoSource vs)
{
Q_UNUSED(mr);
Q_UNUSED(vs);
return 0;
}
int android_recorder_setAudioSource(MediaRecorderWrapper *mr, AudioSource as)
{
Q_UNUSED(mr);
Q_UNUSED(as);
return 0;
}
int android_recorder_setOutputFormat(MediaRecorderWrapper *mr, OutputFormat of)
{
Q_UNUSED(mr);
Q_UNUSED(of);
return 0;
}
int android_recorder_setVideoEncoder(MediaRecorderWrapper *mr, VideoEncoder ve)
{
Q_UNUSED(mr);
Q_UNUSED(ve);
return 0;
}
int android_recorder_setAudioEncoder(MediaRecorderWrapper *mr, AudioEncoder ae)
{
Q_UNUSED(mr);
Q_UNUSED(ae);
return 0;
}
int android_recorder_setOutputFile(MediaRecorderWrapper *mr, int fd)
{
Q_UNUSED(mr);
Q_UNUSED(fd);
return 0;
}
int android_recorder_setVideoSize(MediaRecorderWrapper *mr, int width, int height)
{
Q_UNUSED(mr);
Q_UNUSED(width);
Q_UNUSED(height);
return 0;
}
int android_recorder_setVideoFrameRate(MediaRecorderWrapper *mr, int frames_per_second)
{
Q_UNUSED(mr);
Q_UNUSED(frames_per_second);
return 0;
}
int android_recorder_setParameters(MediaRecorderWrapper *mr, const char* parameters)
{
Q_UNUSED(mr);
Q_UNUSED(parameters);
return 0;
}
int android_recorder_start(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_stop(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_prepare(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_reset(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_close(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
int android_recorder_release(MediaRecorderWrapper *mr)
{
Q_UNUSED(mr);
return 0;
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/camera_compatibility_layer.cpp 0000644 0000152 0177776 00000014234 12305354476 031235 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voss
*/
#include
#include
#include "camera_control.h"
#include
#include
void crashTest(CameraControl* control)
{
if (control->listener == 0)
qDebug() << "Something is wrong, but at least it did not crash";
}
int android_camera_get_number_of_devices()
{
return 2;
}
CameraControl* android_camera_connect_to(CameraType camera_type, CameraControlListener* listener)
{
Q_UNUSED(camera_type);
CameraControl* cc = new CameraControl();
cc->listener = listener;
return cc;
}
void android_camera_disconnect(CameraControl* control)
{
crashTest(control);
}
int android_camera_lock(CameraControl* control)
{
Q_UNUSED(control);
return 0;
}
int android_camera_unlock(CameraControl* control)
{
Q_UNUSED(control);
return 0;
}
void android_camera_delete(CameraControl* control)
{
delete control;
}
void android_camera_dump_parameters(CameraControl* control)
{
crashTest(control);
}
void android_camera_set_flash_mode(CameraControl* control, FlashMode mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_flash_mode(CameraControl* control, FlashMode* mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_set_white_balance_mode(CameraControl* control, WhiteBalanceMode mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_white_balance_mode(CameraControl* control, WhiteBalanceMode* mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_set_scene_mode(CameraControl* control, SceneMode mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_set_auto_focus_mode(CameraControl* control, AutoFocusMode mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_set_effect_mode(CameraControl* control, EffectMode mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_effect_mode(CameraControl* control, EffectMode* mode)
{
Q_UNUSED(mode);
crashTest(control);
}
void android_camera_get_preview_fps_range(CameraControl* control, int* min, int* max)
{
Q_UNUSED(min);
Q_UNUSED(max);
crashTest(control);
}
void android_camera_set_preview_fps(CameraControl* control, int fps)
{
Q_UNUSED(fps);
crashTest(control);
}
void android_camera_get_preview_fps(CameraControl* control, int* fps)
{
Q_UNUSED(fps);
crashTest(control);
}
void android_camera_enumerate_supported_preview_sizes(CameraControl* control, size_callback cb, void* ctx)
{
Q_UNUSED(cb);
Q_UNUSED(ctx);
crashTest(control);
}
void android_camera_enumerate_supported_picture_sizes(CameraControl* control, size_callback cb, void* ctx)
{
Q_UNUSED(cb);
Q_UNUSED(ctx);
crashTest(control);
}
void android_camera_get_preview_size(CameraControl* control, int* width, int* height)
{
Q_UNUSED(width);
Q_UNUSED(height);
crashTest(control);
}
void android_camera_set_preview_size(CameraControl* control, int width, int height)
{
Q_UNUSED(width);
Q_UNUSED(height);
crashTest(control);
}
void android_camera_get_picture_size(CameraControl* control, int* width, int* height)
{
Q_UNUSED(width);
Q_UNUSED(height);
crashTest(control);
}
void android_camera_set_picture_size(CameraControl* control, int width, int height)
{
Q_UNUSED(width);
Q_UNUSED(height);
crashTest(control);
}
void android_camera_get_current_zoom(CameraControl* control, int* zoom)
{
Q_UNUSED(zoom);
crashTest(control);
}
void android_camera_get_max_zoom(CameraControl* control, int* zoom)
{
crashTest(control);
*zoom = 4;
}
void android_camera_set_display_orientation(CameraControl* control, int32_t clockwise_rotation_degree)
{
Q_UNUSED(clockwise_rotation_degree);
crashTest(control);
}
void android_camera_get_preview_texture_transformation(CameraControl* control, float m[16])
{
Q_UNUSED(m);
crashTest(control);
}
void android_camera_update_preview_texture(CameraControl* control)
{
crashTest(control);
}
void android_camera_set_preview_texture(CameraControl* control, int texture_id)
{
Q_UNUSED(texture_id);
crashTest(control);
}
void android_camera_start_preview(CameraControl* control)
{
crashTest(control);
}
void android_camera_stop_preview(CameraControl* control)
{
crashTest(control);
}
void android_camera_start_autofocus(CameraControl* control)
{
crashTest(control);
}
void android_camera_stop_autofocus(CameraControl* control)
{
crashTest(control);
}
void android_camera_start_zoom(CameraControl* control, int32_t zoom)
{
Q_UNUSED(zoom);
crashTest(control);
}
void android_camera_set_zoom(CameraControl* control, int32_t zoom)
{
Q_UNUSED(zoom);
crashTest(control);
}
void android_camera_stop_zoom(CameraControl* control)
{
crashTest(control);
}
void android_camera_take_snapshot(CameraControl* control)
{
crashTest(control);
}
void android_camera_set_focus_region(CameraControl* control, FocusRegion* region)
{
Q_UNUSED(region);
crashTest(control);
}
void android_camera_reset_focus_region(CameraControl* control)
{
crashTest(control);
}
void android_camera_set_rotation(CameraControl* control, int rotation)
{
Q_UNUSED(rotation);
crashTest(control);
}
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/recorder_compatibility_layer.h 0000644 0000152 0177776 00000011413 12305354476 031253 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef RECORDER_COMPATIBILITY_LAYER_H_
#define RECORDER_COMPATIBILITY_LAYER_H_
#include
#include
#ifdef __cplusplus
extern "C" {
#endif
struct MediaRecorderWrapper;
struct CameraControl;
// values are from andoid /frameworks/av/include/media/mediarecorder.h
typedef enum
{
ANDROID_VIDEO_SOURCE_DEFAULT = 0,
ANDROID_VIDEO_SOURCE_CAMERA = 1,
ANDROID_VIDEO_SOURCE_GRALLOC_BUFFER = 2
} VideoSource;
// values are from andoid /system/core/include/system/audio.h
typedef enum
{
ANDROID_AUDIO_SOURCE_DEFAULT = 0,
ANDROID_AUDIO_SOURCE_MIC = 1,
ANDROID_AUDIO_SOURCE_VOICE_UPLINK = 2,
ANDROID_AUDIO_SOURCE_VOICE_DOWNLINK = 3,
ANDROID_AUDIO_SOURCE_VOICE_CALL = 4,
ANDROID_AUDIO_SOURCE_CAMCORDER = 5,
ANDROID_AUDIO_SOURCE_VOICE_RECOGNITION = 6,
ANDROID_AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
ANDROID_AUDIO_SOURCE_REMOTE_SUBMIX = 8,
ANDROID_AUDIO_SOURCE_CNT,
ANDROID_AUDIO_SOURCE_MAX = ANDROID_AUDIO_SOURCE_CNT - 1
} AudioSource;
// values are from andoid /frameworks/av/include/media/mediarecorder.h
typedef enum
{
ANDROID_OUTPUT_FORMAT_DEFAULT = 0,
ANDROID_OUTPUT_FORMAT_THREE_GPP = 1,
ANDROID_OUTPUT_FORMAT_MPEG_4 = 2,
ANDROID_OUTPUT_FORMAT_AUDIO_ONLY_START = 3,
/* These are audio only file formats */
ANDROID_OUTPUT_FORMAT_RAW_AMR = 3, //to be backward compatible
ANDROID_OUTPUT_FORMAT_AMR_NB = 3,
ANDROID_OUTPUT_FORMAT_AMR_WB = 4,
ANDROID_OUTPUT_FORMAT_AAC_ADIF = 5,
ANDROID_OUTPUT_FORMAT_AAC_ADTS = 6,
/* Stream over a socket, limited to a single stream */
ANDROID_OUTPUT_FORMAT_RTP_AVP = 7,
/* H.264/AAC data encapsulated in MPEG2/TS */
ANDROID_OUTPUT_FORMAT_MPEG2TS = 8
} OutputFormat;
// values are from andoid /frameworks/av/include/media/mediarecorder.h
typedef enum
{
ANDROID_VIDEO_ENCODER_DEFAULT = 0,
ANDROID_VIDEO_ENCODER_H263 = 1,
ANDROID_VIDEO_ENCODER_H264 = 2,
ANDROID_VIDEO_ENCODER_MPEG_4_SP = 3
} VideoEncoder;
// values are from andoid /frameworks/av/include/media/mediarecorder.h
typedef enum
{
ANDROID_AUDIO_ENCODER_DEFAULT = 0,
ANDROID_AUDIO_ENCODER_AMR_NB = 1,
ANDROID_AUDIO_ENCODER_AMR_WB = 2,
ANDROID_AUDIO_ENCODER_AAC = 3,
ANDROID_AUDIO_ENCODER_HE_AAC = 4,
ANDROID_AUDIO_ENCODER_AAC_ELD = 5
} AudioEncoder;
// Callback types
typedef void (*on_recorder_msg_error)(void *context);
// Callback setters
void android_recorder_set_error_cb(MediaRecorderWrapper *mr, on_recorder_msg_error cb,
void *context);
// Main recorder control API
MediaRecorderWrapper *android_media_new_recorder();
int android_recorder_initCheck(MediaRecorderWrapper *mr);
int android_recorder_setCamera(MediaRecorderWrapper *mr, CameraControl* control);
int android_recorder_setVideoSource(MediaRecorderWrapper *mr, VideoSource vs);
int android_recorder_setAudioSource(MediaRecorderWrapper *mr, AudioSource as);
int android_recorder_setOutputFormat(MediaRecorderWrapper *mr, OutputFormat of);
int android_recorder_setVideoEncoder(MediaRecorderWrapper *mr, VideoEncoder ve);
int android_recorder_setAudioEncoder(MediaRecorderWrapper *mr, AudioEncoder ae);
int android_recorder_setOutputFile(MediaRecorderWrapper *mr, int fd);
int android_recorder_setVideoSize(MediaRecorderWrapper *mr, int width, int height);
int android_recorder_setVideoFrameRate(MediaRecorderWrapper *mr, int frames_per_second);
int android_recorder_setParameters(MediaRecorderWrapper *mr, const char* parameters);
int android_recorder_start(MediaRecorderWrapper *mr);
int android_recorder_stop(MediaRecorderWrapper *mr);
int android_recorder_prepare(MediaRecorderWrapper *mr);
int android_recorder_reset(MediaRecorderWrapper *mr);
int android_recorder_close(MediaRecorderWrapper *mr);
int android_recorder_release(MediaRecorderWrapper *mr);
#ifdef __cplusplus
}
#endif
#endif
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/aal.pro 0000644 0000152 0177776 00000000572 12305354476 024433 0 ustar pbuser nogroup 0000000 0000000 include(../../../coverage.pri)
TEMPLATE = lib
TARGET = aal
CONFIG += staticlib
HEADERS = camera_compatibility_layer.h \
camera_compatibility_layer_capabilities.h \
camera_control.h \
recorder_compatibility_layer.h
SOURCES += camera_compatibility_layer.cpp \
recorder_compatibility_layer.cpp \
ubuntu_application_api.cpp
qtubuntu-camera-0.3.3+14.04.20140304/unittests/mocks/aal/camera_compatibility_layer_capabilities.h 0000644 0000152 0177776 00000011167 12305354476 033415 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical Ltd
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voss
*/
#ifndef CAMERA_COMPATIBILITY_LAYER_CONFIGURATION_H_
#define CAMERA_COMPATIBILITY_LAYER_CONFIGURATION_H_
#ifdef __cplusplus
extern "C" {
#endif
struct CameraControl;
typedef enum
{
FLASH_MODE_OFF,
FLASH_MODE_AUTO,
FLASH_MODE_ON,
FLASH_MODE_TORCH
} FlashMode;
typedef enum
{
WHITE_BALANCE_MODE_AUTO,
WHITE_BALANCE_MODE_DAYLIGHT,
WHITE_BALANCE_MODE_CLOUDY_DAYLIGHT,
WHITE_BALANCE_MODE_FLUORESCENT,
WHITE_BALANCE_MODE_INCANDESCENT
} WhiteBalanceMode;
typedef enum
{
SCENE_MODE_AUTO,
SCENE_MODE_ACTION,
SCENE_MODE_NIGHT,
SCENE_MODE_PARTY,
SCENE_MODE_SUNSET
} SceneMode;
typedef enum
{
AUTO_FOCUS_MODE_OFF,
AUTO_FOCUS_MODE_CONTINUOUS_VIDEO,
AUTO_FOCUS_MODE_AUTO,
AUTO_FOCUS_MODE_MACRO,
AUTO_FOCUS_MODE_CONTINUOUS_PICTURE,
AUTO_FOCUS_MODE_INFINITY
} AutoFocusMode;
typedef enum
{
EFFECT_MODE_NONE,
EFFECT_MODE_MONO,
EFFECT_MODE_NEGATIVE,
EFFECT_MODE_SOLARIZE,
EFFECT_MODE_SEPIA,
EFFECT_MODE_POSTERIZE,
EFFECT_MODE_WHITEBOARD,
EFFECT_MODE_BLACKBOARD,
EFFECT_MODE_AQUA
} EffectMode;
typedef enum
{
CAMERA_PIXEL_FORMAT_YUV422SP,
CAMERA_PIXEL_FORMAT_YUV420SP,
CAMERA_PIXEL_FORMAT_YUV422I,
CAMERA_PIXEL_FORMAT_YUV420P,
CAMERA_PIXEL_FORMAT_RGB565,
CAMERA_PIXEL_FORMAT_RGBA8888,
CAMERA_PIXEL_FORMAT_BAYER_RGGB
} CameraPixelFormat;
typedef struct
{
int top;
int left;
int bottom;
int right;
int weight;
} FocusRegion;
typedef void (*size_callback)(void* ctx, int width, int height);
// Dumps the camera parameters to stdout.
void android_camera_dump_parameters(CameraControl* control);
// Query camera parameters
int android_camera_get_number_of_devices();
void android_camera_enumerate_supported_preview_sizes(CameraControl* control, size_callback cb, void* ctx);
void android_camera_get_preview_fps_range(CameraControl* control, int* min, int* max);
void android_camera_get_preview_fps(CameraControl* control, int* fps);
void android_camera_enumerate_supported_picture_sizes(CameraControl* control, size_callback cb, void* ctx);
void android_camera_get_preview_size(CameraControl* control, int* width, int* height);
void android_camera_get_picture_size(CameraControl* control, int* width, int* height);
void android_camera_get_current_zoom(CameraControl* control, int* zoom);
void android_camera_get_max_zoom(CameraControl* control, int* max_zoom);
void android_camera_get_effect_mode(CameraControl* control, EffectMode* mode);
void android_camera_get_flash_mode(CameraControl* control, FlashMode* mode);
void android_camera_get_white_balance_mode(CameraControl* control, WhiteBalanceMode* mode);
void android_camera_get_scene_mode(CameraControl* control, SceneMode* mode);
void android_camera_get_auto_focus_mode(CameraControl* control, AutoFocusMode* mode);
void android_camera_get_preview_format(CameraControl* control, CameraPixelFormat* format);
// Adjusts camera parameters
void android_camera_set_preview_size(CameraControl* control, int width, int height);
void android_camera_set_preview_fps(CameraControl* control, int fps);
void android_camera_set_picture_size(CameraControl* control, int width, int height);
void android_camera_set_effect_mode(CameraControl* control, EffectMode mode);
void android_camera_set_flash_mode(CameraControl* control, FlashMode mode);
void android_camera_set_white_balance_mode(CameraControl* control, WhiteBalanceMode mode);
void android_camera_set_scene_mode(CameraControl* control, SceneMode mode);
void android_camera_set_auto_focus_mode(CameraControl* control, AutoFocusMode mode);
void android_camera_set_preview_format(CameraControl* control, CameraPixelFormat format);
void android_camera_set_focus_region(CameraControl* control, FocusRegion* region);
void android_camera_reset_focus_region(CameraControl* control);
// Set photo metadata
void android_camera_set_rotation(CameraControl* control, int rotation);
#ifdef __cplusplus
}
#endif
#endif // CAMERA_COMPATIBILITY_LAYER_CONFIGURATION_H_
qtubuntu-camera-0.3.3+14.04.20140304/aalCamera.pro 0000644 0000152 0177776 00000000120 12305354476 021616 0 ustar pbuser nogroup 0000000 0000000 include(coverage.pri)
TEMPLATE = subdirs
SUBDIRS += \
src \
unittests
qtubuntu-camera-0.3.3+14.04.20140304/coverage.pri 0000644 0000152 0177776 00000003561 12305354476 021551 0 ustar pbuser nogroup 0000000 0000000 # Coverage
CONFIG(coverage) {
OBJECTS_DIR =
MOC_DIR =
TOP_SRC_DIR = $$PWD
LIBS += -lgcov
QMAKE_CXXFLAGS += --coverage
QMAKE_LDFLAGS += --coverage
QMAKE_EXTRA_TARGETS += coverage cov
QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \
generate-coverage-html clean-coverage-html coverage-gcovr \
generate-gcovr generate-coverage-gcovr clean-coverage-gcovr
clean-gcno.commands = \
"@echo Removing old coverage instrumentation"; \
"find -name '*.gcno' -print | xargs -r rm"
clean-gcda.commands = \
"@echo Removing old coverage results"; \
"find -name '*.gcda' -print | xargs -r rm"
coverage-html.depends = clean-gcda check generate-coverage-html
generate-coverage-html.commands = \
"@echo Collecting coverage data"; \
"lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \
"lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \
"lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \
"LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info"
clean-coverage-html.depends = clean-gcda
clean-coverage-html.commands = \
"lcov --directory $${TOP_SRC_DIR} -z"; \
"rm -rf coverage.info coverage-html"
coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr
generate-coverage-gcovr.commands = \
"@echo Generating coverage GCOVR report"; \
"gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"unittests/.*\" -e \".*\\.h\""
clean-coverage-gcovr.depends = clean-gcda
clean-coverage-gcovr.commands = \
"rm -rf $${TOP_SRC_DIR}/coverage.xml"
QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml
}
qtubuntu-camera-0.3.3+14.04.20140304/src/ 0000755 0000152 0177776 00000000000 12305354713 020016 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-camera-0.3.3+14.04.20140304/src/storagemanager.cpp 0000644 0000152 0177776 00000005417 12305354476 023536 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "storagemanager.h"
#include
#include
#include
#include
#include
#include
const QLatin1String photoBase = QLatin1String("image");
const QLatin1String videoBase = QLatin1String("video");
const QLatin1String photoExtension = QLatin1String("jpg");
const QLatin1String videoExtension = QLatin1String("mp4");
const QLatin1String dateFormat = QLatin1String("yyyyMMdd");
StorageManager::StorageManager()
{
}
QString StorageManager::nextPhotoFileName(const QString &directoy)
{
m_directory = directoy;
if (m_directory.isEmpty())
m_directory = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
return nextMediaFileName(photoBase, photoExtension);
}
QString StorageManager::nextVideoFileName(const QString &directoy)
{
m_directory = directoy;
if (m_directory.isEmpty())
m_directory = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
return nextMediaFileName(videoBase, videoExtension);
}
bool StorageManager::checkDirectory(const QString &path) const
{
QFileInfo fi(path);
QDir dir;
if (fi.isDir())
dir.setPath(path);
else
dir.setPath(fi.absoluteDir().absolutePath());
if (!dir.exists()) {
bool ok = dir.mkpath(dir.absolutePath());
if (!ok)
return false;
}
fi.setFile(dir.absolutePath());
if (!fi.isWritable())
return false;
return true;
}
QString StorageManager::nextMediaFileName(const QString &base, const QString &extension)
{
int idx = 1;
QString fileName = fileNameGenerator(idx, base, extension);
while (QFile::exists(fileName)) {
++idx;
fileName = fileNameGenerator(idx, base, extension);
}
return fileName;
}
QString StorageManager::fileNameGenerator(int idx, const QString &base,
const QString& extension)
{
QString date = QDate::currentDate().toString(dateFormat);
return QString("%1/%2%3_%4.%5")
.arg(m_directory)
.arg(base)
.arg(date)
.arg(idx,4,10,QLatin1Char('0'))
.arg(extension);
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalimageencodercontrol.h 0000644 0000152 0177776 00000003303 12305354476 024675 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALIMAGEENCODERCONTROL_H
#define AALIMAGEENCODERCONTROL_H
#include
#include
#include
#include
class AalCameraService;
class CameraControl;
class AalImageEncoderControl : public QImageEncoderControl
{
public:
AalImageEncoderControl(AalCameraService *service, QObject *parent = 0);
~AalImageEncoderControl();
QString imageCodecDescription(const QString &codec) const;
QImageEncoderSettings imageSettings() const;
void setImageSettings(const QImageEncoderSettings &settings);
QStringList supportedImageCodecs() const;
QList supportedResolutions(const QImageEncoderSettings &settings, bool *continuous = 0) const;
void init(CameraControl *control);
void setSize(const QSize &size);
void resetAllSettings();
void enablePhotoMode();
static void setPictureSizeCb(void *ctx, int width, int height);
private:
AalCameraService *m_service;
QList m_availableSizes;
QSize m_currentSize;
void setPictureSize(int width, int height);
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalviewfindersettingscontrol.h 0000644 0000152 0177776 00000003637 12305354476 026210 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALVIEWFINDERSETTINGSCONTROL_H
#define AALVIEWFINDERSETTINGSCONTROL_H
#include
#include
#include
class AalCameraService;
struct CameraControl;
struct CameraControlListener;
class AalViewfinderSettingsControl : public QCameraViewfinderSettingsControl
{
public:
AalViewfinderSettingsControl(AalCameraService *service, QObject *parent = 0);
~AalViewfinderSettingsControl();
bool isViewfinderParameterSupported(ViewfinderParameter parameter) const ;
void setViewfinderParameter(ViewfinderParameter parameter, const QVariant & value);
QVariant viewfinderParameter(ViewfinderParameter parameter) const;
void setSize(const QSize &size);
QSize currentSize() const;
const QList &supportedSizes() const;
void setAspectRatio(float ratio);
void init(CameraControl *control, CameraControlListener *listener);
void resetAllSettings();
static void sizeCB(void* ctx, int width, int height);
private:
QSize chooseOptimalSize(const QList &sizes) const;
AalCameraService *m_service;
QSize m_currentSize;
float m_aspectRatio;
int m_currentFPS;
mutable QList m_availableSizes;
int m_minFPS;
int m_maxFPS;
};
#endif // AALVIEWFINDERSETTINGSCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideodeviceselectorcontrol.h 0000644 0000152 0177776 00000002507 12305354476 026307 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALVIDEODEVICESELECTORCONTROL_H
#define AALVIDEODEVICESELECTORCONTROL_H
#include
class AalCameraService;
class AalVideoDeviceSelectorControl : public QVideoDeviceSelectorControl
{
public:
AalVideoDeviceSelectorControl(AalCameraService *service, QObject *parent = 0);
int defaultDevice() const;
int deviceCount() const;
QString deviceDescription(int index) const;
QString deviceName(int index) const;
int selectedDevice() const;
public Q_SLOTS:
void setSelectedDevice(int index);
private:
AalCameraService *m_service;
int m_currentDevice;
mutable int m_numberOfCameras;
};
#endif // AALVIDEODEVICESELECTORCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcamerazoomcontrol.cpp 0000644 0000152 0177776 00000007340 12305354476 024750 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcamerazoomcontrol.h"
#include "aalcameracontrol.h"
#include "aalcameraservice.h"
#include
#include
#include
AalCameraZoomControl::AalCameraZoomControl(AalCameraService *service, QObject *parent)
: QCameraZoomControl(parent),
m_service(service),
m_currentDigialZoom(1),
m_maximalDigitalZoom(1),
m_pendingZoom(-1)
{
}
qreal AalCameraZoomControl::currentDigitalZoom() const
{
return (qreal)m_currentDigialZoom;
}
qreal AalCameraZoomControl::currentOpticalZoom() const
{
return 1.0;
}
qreal AalCameraZoomControl::maximumDigitalZoom() const
{
return (qreal)m_maximalDigitalZoom;
}
qreal AalCameraZoomControl::maximumOpticalZoom() const
{
return 1.0;
}
qreal AalCameraZoomControl::requestedDigitalZoom() const
{
return (qreal)m_pendingZoom;
}
qreal AalCameraZoomControl::requestedOpticalZoom() const
{
return 1.0;
}
void AalCameraZoomControl::zoomTo(qreal optical, qreal digital)
{
Q_UNUSED(optical);
if (!m_service->androidControl())
return;
if (digital < 1.0 || digital > m_maximalDigitalZoom) {
qWarning() << "Invalid zoom value:" << digital;
return;
}
m_pendingZoom = static_cast(digital);
if (m_pendingZoom == m_currentDigialZoom)
return;
android_camera_set_zoom(m_service->androidControl(), m_pendingZoom);
m_currentDigialZoom = m_pendingZoom;
Q_EMIT currentDigitalZoomChanged(m_currentDigialZoom);
}
/*!
* \brief AalCameraZoomControl::enablePhotoMode
*/
void AalCameraZoomControl::enablePhotoMode()
{
Q_ASSERT(m_service->androidControl());
resetCurrentZoom();
int maxZoom = 1;
android_camera_get_max_zoom(m_service->androidControl(), &maxZoom);
setMaxZoom(maxZoom);
}
/*!
* \brief AalCameraZoomControl::enableVideoMode disabled zooming, as some HW has
* issues zooming when focus mode is continuous focus
* https://bugs.launchpad.net/camera-app/+bug/1191088
*/
void AalCameraZoomControl::enableVideoMode()
{
resetCurrentZoom();
setMaxZoom(1);
}
void AalCameraZoomControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
if (m_service->cameraControl()->captureMode() == QCamera::CaptureStillImage)
enablePhotoMode();
else
enableVideoMode();
}
/*!
* \brief AalCameraZoomControl::resetCurrentZoom sets the current zoom value to 1
*/
void AalCameraZoomControl::resetCurrentZoom()
{
if (m_currentDigialZoom != 1) {
m_currentDigialZoom = 1;
Q_EMIT currentDigitalZoomChanged(m_currentDigialZoom);
}
if (m_service->androidControl())
android_camera_set_zoom(m_service->androidControl(), m_currentDigialZoom);
}
/*!
* \brief AalCameraZoomControl::setMaxZoom
* \param maxValue
*/
void AalCameraZoomControl::setMaxZoom(int maxValue)
{
if (maxValue < 1)
return;
if (maxValue != m_maximalDigitalZoom) {
m_maximalDigitalZoom = maxValue;
Q_EMIT maximumDigitalZoomChanged(m_maximalDigitalZoom);
}
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcamerafocuscontrol.cpp 0000644 0000152 0177776 00000015523 12305354476 025105 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcamerafocuscontrol.h"
#include "aalcameracontrol.h"
#include "aalcameraservice.h"
#include
#include
#include
/// The size of the full sensor is +/- of this one in x and y
const int focusFullSize = 1000;
/// The size of the focus area is +/- of this one in x and y
const int focusRegionSize = 100;
AalCameraFocusControl::AalCameraFocusControl(AalCameraService *service, QObject *parent)
: QCameraFocusControl(parent),
m_service(service),
m_focusMode(QCameraFocus::AutoFocus),
m_focusPointMode(QCameraFocus::FocusPointAuto),
m_focusPoint(0.0, 0.0),
setOnInit(false),
m_focusRunning(false)
{
m_focusRegion.left = 0.0;
m_focusRegion.right = 0.0;
m_focusRegion.top = 0.0;
m_focusRegion.bottom = 0.0;
m_focusRegion.weight = -9.9;
}
QPointF AalCameraFocusControl::customFocusPoint() const
{
return m_focusPoint;
}
QCameraFocus::FocusModes AalCameraFocusControl::focusMode() const
{
return m_focusMode;
}
QCameraFocus::FocusPointMode AalCameraFocusControl::focusPointMode() const
{
return m_focusPointMode;
}
QCameraFocusZoneList AalCameraFocusControl::focusZones() const
{
return QCameraFocusZoneList();
}
bool AalCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusModes mode) const
{
if (mode == QCameraFocus::HyperfocalFocus)
return false;
return true;
}
bool AalCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
{
if (mode == QCameraFocus::FocusPointFaceDetection)
return false;
return true;
}
void AalCameraFocusControl::setCustomFocusPoint(const QPointF &point)
{
if (m_focusPoint == point)
return;
m_focusPoint = point;
m_focusRegion = point2Region(m_focusPoint);
Q_EMIT customFocusPointChanged(m_focusPoint);
if (m_service->androidControl()) {
android_camera_set_focus_region(m_service->androidControl(), &m_focusRegion);
startFocus();
}
}
void AalCameraFocusControl::setFocusMode(QCameraFocus::FocusModes mode)
{
if (m_focusMode == mode || !isFocusModeSupported(mode))
return;
m_focusRunning = false;
AutoFocusMode focusMode = qt2Android(mode);
m_focusMode = mode;
if (m_service->androidControl()) {
android_camera_set_auto_focus_mode(m_service->androidControl(), focusMode);
} else {
setOnInit = true;
}
Q_EMIT focusModeChanged(m_focusMode);
}
void AalCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode)
{
if (m_focusPointMode == mode || !isFocusPointModeSupported(mode))
return;
m_focusPointMode = mode;
Q_EMIT focusPointModeChanged(m_focusPointMode);
}
void AalCameraFocusControl::focusCB(void *context)
{
Q_UNUSED(context);
AalCameraService::instance()->focusControl()->m_focusRunning = false;
QMetaObject::invokeMethod(AalCameraService::instance(),
"updateCaptureReady", Qt::QueuedConnection);
}
bool AalCameraFocusControl::isFocusBusy() const
{
return m_focusRunning;
}
/*!
* \brief AalCameraFocusControl::enablePhotoMode resets the last focus mode for photos
*/
void AalCameraFocusControl::enablePhotoMode()
{
setFocusMode(QCameraFocus::AutoFocus);
}
/*!
* \brief AalCameraFocusControl::enableVideoMode sets the focus mode to continuous for video
*/
void AalCameraFocusControl::enableVideoMode()
{
setFocusMode(QCameraFocus::ContinuousFocus);
}
void AalCameraFocusControl::init(CameraControl *control, CameraControlListener *listener)
{
listener->on_msg_focus_cb = &AalCameraFocusControl::focusCB;
if (setOnInit) {
AutoFocusMode mode = qt2Android(m_focusMode);
android_camera_set_auto_focus_mode(control, mode);
if (m_focusRegion.weight > 0.0) {
android_camera_set_focus_region(control, &m_focusRegion);
QTimer::singleShot(1, this, SLOT(startFocus()));
}
setOnInit = false;
} else {
AutoFocusMode mode;
android_camera_get_auto_focus_mode(control, &mode);
m_focusMode = android2Qt(mode);
}
m_focusRunning = false;
}
void AalCameraFocusControl::startFocus()
{
if (!m_service->androidControl())
return;
m_focusRunning = true;
m_service->updateCaptureReady();
android_camera_start_autofocus(m_service->androidControl());
}
AutoFocusMode AalCameraFocusControl::qt2Android(QCameraFocus::FocusModes mode)
{
switch(mode) {
case QCameraFocus::ManualFocus:
return AUTO_FOCUS_MODE_OFF;
case QCameraFocus::InfinityFocus:
return AUTO_FOCUS_MODE_INFINITY;
case QCameraFocus::ContinuousFocus:
if (m_service->cameraControl()->captureMode() == QCamera::CaptureStillImage)
return AUTO_FOCUS_MODE_CONTINUOUS_PICTURE;
else
return AUTO_FOCUS_MODE_CONTINUOUS_VIDEO;
case QCameraFocus::MacroFocus:
return AUTO_FOCUS_MODE_MACRO;
case QCameraFocus::AutoFocus:
case QCameraFocus::HyperfocalFocus:
default:
return AUTO_FOCUS_MODE_AUTO;
}
}
QCameraFocus::FocusModes AalCameraFocusControl::android2Qt(AutoFocusMode mode)
{
switch(mode) {
case AUTO_FOCUS_MODE_OFF:
return QCameraFocus::ManualFocus;
case AUTO_FOCUS_MODE_INFINITY:
return QCameraFocus::InfinityFocus;
case AUTO_FOCUS_MODE_CONTINUOUS_PICTURE:
case AUTO_FOCUS_MODE_CONTINUOUS_VIDEO:
return QCameraFocus::ContinuousFocus;
case AUTO_FOCUS_MODE_MACRO:
return QCameraFocus::MacroFocus;
case AUTO_FOCUS_MODE_AUTO:
default:
return QCameraFocus::AutoFocus;
}
}
FocusRegion AalCameraFocusControl::point2Region(const QPointF &point) const
{
int centerX = (point.x() * (2* focusFullSize)) - focusFullSize;
int maxCenterPosition = focusFullSize - focusRegionSize;
centerX = std::max(std::min(centerX, maxCenterPosition), -maxCenterPosition);
int centerY = -1 * ((point.y() * (2 * focusFullSize)) - focusFullSize);
centerY = std::max(std::min(centerY, maxCenterPosition), -maxCenterPosition);
FocusRegion region;
region.left = centerX - focusRegionSize;
region.right = centerX + focusRegionSize;
region.top = centerY - focusRegionSize;
region.bottom = centerY + focusRegionSize;
region.weight = 5;
return region;
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraserviceplugin.h 0000644 0000152 0177776 00000002467 12305354476 024714 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALSERVICEPLUGIN_H
#define AALSERVICEPLUGIN_H
#include
class AalServicePlugin : public QMediaServiceProviderPlugin,
public QMediaServiceSupportedDevicesInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "aalcamera.json")
public:
AalServicePlugin();
QMediaService* create(QString const& key);
void release(QMediaService *service);
QList devices(const QByteArray &service) const;
QString deviceDescription(const QByteArray &service, const QByteArray &device);
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameracontrol.cpp 0000644 0000152 0177776 00000006103 12305354476 024037 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameracontrol.h"
#include "aalcameraservice.h"
#include
AalCameraControl::AalCameraControl(AalCameraService *service, QObject *parent)
: QCameraControl(parent),
m_service(service),
m_state(QCamera::UnloadedState),
m_status(QCamera::UnloadedStatus),
m_captureMode(QCamera::CaptureStillImage)
{
}
AalCameraControl::~AalCameraControl()
{
}
QCamera::State AalCameraControl::state() const
{
return m_state;
}
void AalCameraControl::setState(QCamera::State state)
{
if (m_state == state)
return;
if (m_state == QCamera::ActiveState) {
m_service->disconnectCamera();
} else {
bool ok = m_service->connectCamera();
if (!ok) {
Q_EMIT error(QCamera::CameraError, QLatin1String("Unable to connect to camera"));
return;
}
}
m_state = state;
Q_EMIT stateChanged(m_state);
m_service->updateCaptureReady();
}
QCamera::Status AalCameraControl::status() const
{
return m_status;
}
QCamera::CaptureModes AalCameraControl::captureMode() const
{
return m_captureMode;
}
void AalCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
if (m_captureMode == mode)
return;
if (m_service->isRecording())
return;
m_captureMode = mode;
if (m_service->isCameraActive() && mode == QCamera::CaptureStillImage) {
m_service->enablePhotoMode();
} else {
m_service->enableVideoMode();
}
Q_EMIT captureModeChanged(mode);
}
bool AalCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const
{
return (QCamera::CaptureStillImage==mode) | (QCamera::CaptureVideo==mode);
}
bool AalCameraControl::canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const
{
Q_UNUSED(changeType);
Q_UNUSED(status);
return true;
}
void AalCameraControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
listener->on_msg_error_cb = &AalCameraControl::errorCB;
}
void AalCameraControl::handleError()
{
setState(QCamera::LoadedState);
Q_EMIT error(QCamera::CameraError, QLatin1String("Unknown error in camera"));
setState(QCamera::ActiveState);
}
void AalCameraControl::errorCB(void *context)
{
Q_UNUSED(context);
QMetaObject::invokeMethod(AalCameraService::instance()->cameraControl(),
"handleError", Qt::QueuedConnection);
}
qtubuntu-camera-0.3.3+14.04.20140304/src/storagemanager.h 0000644 0000152 0177776 00000002256 12305354476 023201 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef STORAGEMANAGER_H
#define STORAGEMANAGER_H
#include
class StorageManager
{
public:
StorageManager();
QString nextPhotoFileName(const QString &directoy = QString());
QString nextVideoFileName(const QString &directoy = QString());
bool checkDirectory(const QString &path) const;
private:
QString nextMediaFileName(const QString &base, const QString &extension);
QString fileNameGenerator(int idx, const QString &base, const QString &extension);
QString m_directory;
};
#endif // STORAGEMANAGER_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideoencodersettingscontrol.cpp 0000644 0000152 0177776 00000012604 12305354476 027041 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideoencodersettingscontrol.h"
#include "aalcameraservice.h"
#include "aalviewfindersettingscontrol.h"
#include
const QSize AalVideoEncoderSettingsControl::DEFAULT_SIZE = QSize(1280,720);
const int AalVideoEncoderSettingsControl::DEFAULT_FPS = 30;
const QString AalVideoEncoderSettingsControl::DEFAULT_CODEC = QString("H.264");
/*!
* \brief AalVideoEncoderSettingsControl::AalVideoEncoderSettingsControl
* \param service
* \param parent
*/
AalVideoEncoderSettingsControl::AalVideoEncoderSettingsControl(AalCameraService *service, QObject *parent)
: QVideoEncoderSettingsControl(parent),
m_service(service)
{
}
/*!
* \reimp
*/
void AalVideoEncoderSettingsControl::setVideoSettings(const QVideoEncoderSettings &settings)
{
bool continuous;
if (supportedVideoCodecs().contains(settings.codec()))
m_settings.setCodec(settings.codec());
m_settings.setBitRate(settings.bitRate());
if (supportedFrameRates(settings, &continuous).contains(settings.frameRate()))
m_settings.setFrameRate(settings.frameRate());
if (supportedResolutions(settings, &continuous).contains(settings.resolution()))
m_settings.setResolution(settings.resolution());
// FIXME support more options
}
/*!
* \reimp
*/
QList AalVideoEncoderSettingsControl::supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
// FIXME get data from android
QList fps;
fps << 15 << 30;
return fps;
}
/*!
* \reimp
*/
QList AalVideoEncoderSettingsControl::supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(settings);
Q_UNUSED(continuous);
if (m_availableSizes.isEmpty())
querySupportedResolution();
return m_availableSizes;
}
/*!
* \reimp
*/
QStringList AalVideoEncoderSettingsControl::supportedVideoCodecs() const
{
// FIXME get data from android
QStringList codecs;
codecs << DEFAULT_CODEC;
return codecs;
}
/*!
* \reimp
*/
QString AalVideoEncoderSettingsControl::videoCodecDescription(const QString &codec) const
{
return codec;
}
/*!
* \reimp
*/
QVideoEncoderSettings AalVideoEncoderSettingsControl::videoSettings() const
{
return m_settings;
}
/*!
* \brief AalMediaRecorderControl::getAspectRatio returns the curent used aspect ratio
* \return
*/
float AalVideoEncoderSettingsControl::getAspectRatio() const
{
QSize resolution = m_settings.resolution();
return (float)resolution.width() / (float)resolution.height();
}
/*!
* \brief AalVideoEncoderSettingsControl::init
* \param control
* \param listener
*/
void AalVideoEncoderSettingsControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
Q_UNUSED(listener);
resetAllSettings();
if (m_availableSizes.isEmpty())
querySupportedResolution();
if (!m_availableSizes.contains(m_settings.resolution()) && !m_availableSizes.empty()) {
m_settings.setResolution(m_availableSizes[0]);
}
}
/*!
* \brief AalVideoEncoderSettingsControl::resetAllSettings
*/
void AalVideoEncoderSettingsControl::resetAllSettings()
{
m_availableSizes.clear();
int videoBitRate = 7 * DEFAULT_SIZE.width() * DEFAULT_SIZE.height();
m_settings.setBitRate(videoBitRate);
m_settings.setCodec(DEFAULT_CODEC);
m_settings.setFrameRate(DEFAULT_FPS);
m_settings.setResolution(DEFAULT_SIZE.width(), DEFAULT_SIZE.height());
}
/*!
* \brief AalVideoEncoderSettingsControl::querySupportedResolution gets the
* supported resolutions from android, and saves the to the m_availableSizes member
*/
void AalVideoEncoderSettingsControl::querySupportedResolution() const
{
CameraControl *cc = m_service->androidControl();
if (!cc)
return;
AalVideoEncoderSettingsControl *vSettings = const_cast(this);
android_camera_enumerate_supported_video_sizes(cc, &AalVideoEncoderSettingsControl::sizeCB,
vSettings);
if (m_availableSizes.isEmpty()) {
// android devices where video and viewfinder are "linked", no sizes are returned
// so use the viewfinder sizes
m_availableSizes = m_service->viewfinderControl()->supportedSizes();
}
}
/*!
* \brief AalVideoEncoderSettingsControl::sizeCB calback function to get the supported sizes
* \param ctx pointer to the AalVideoEncoderSettingsControl object that requests the sizes
* \param width
* \param height
*/
void AalVideoEncoderSettingsControl::sizeCB(void *ctx, int width, int height)
{
AalVideoEncoderSettingsControl *self = (AalVideoEncoderSettingsControl*)ctx;
self->m_availableSizes.append(QSize(width, height));
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalimageencodercontrol.cpp 0000644 0000152 0177776 00000006473 12305354476 025243 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalimageencodercontrol.h"
#include "aalcameraservice.h"
#include
#include
#include
AalImageEncoderControl::AalImageEncoderControl(AalCameraService *service, QObject *parent)
: QImageEncoderControl(parent),
m_service(service),
m_currentSize()
{
}
AalImageEncoderControl::~AalImageEncoderControl()
{
}
QString AalImageEncoderControl::imageCodecDescription(const QString &codec) const
{
Q_UNUSED(codec);
return QString();
}
QImageEncoderSettings AalImageEncoderControl::imageSettings() const
{
return QImageEncoderSettings();
}
void AalImageEncoderControl::setImageSettings(const QImageEncoderSettings &settings)
{
Q_UNUSED(settings);
}
QStringList AalImageEncoderControl::supportedImageCodecs() const
{
return QStringList();
}
QList AalImageEncoderControl::supportedResolutions(const QImageEncoderSettings &settings, bool *continuous) const
{
Q_UNUSED(continuous);
Q_UNUSED(settings);
return m_availableSizes;
}
void AalImageEncoderControl::init(CameraControl *control)
{
Q_ASSERT(control != NULL);
if (m_availableSizes.isEmpty()) {
android_camera_enumerate_supported_picture_sizes(control, &AalImageEncoderControl::setPictureSizeCb, this);
}
}
void AalImageEncoderControl::setSize(const QSize &size)
{
CameraControl *cc = m_service->androidControl();
if (!cc) {
m_currentSize = size;
return;
}
if (!m_availableSizes.contains(size)) {
qWarning() << "Size " << size << "is not supported by the camera";
qWarning() << "Supported sizes are: " << m_availableSizes;
return;
}
m_currentSize = size;
android_camera_set_picture_size(cc, size.width(), size.height());
}
void AalImageEncoderControl::resetAllSettings()
{
m_availableSizes.clear();
m_currentSize = QSize();
}
/*!
* \brief AalImageEncoderControl::enablePhotoMode prepares the camera to take photos
*/
void AalImageEncoderControl::enablePhotoMode()
{
CameraControl *cc = m_service->androidControl();
if (!cc || !m_currentSize.isValid()) {
return;
}
android_camera_set_picture_size(cc, m_currentSize.width(), m_currentSize.height());
}
void AalImageEncoderControl::setPictureSizeCb(void *ctx, int width, int height)
{
if (ctx != NULL)
{
AalImageEncoderControl *self = static_cast(ctx);
self->setPictureSize(width, height);
}
else
qWarning() << "ctx is NULL, cannot set supported camera resolutions." << endl;
}
void AalImageEncoderControl::setPictureSize(int width, int height)
{
m_availableSizes.append(QSize(width, height));
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraflashcontrol.h 0000644 0000152 0177776 00000003233 12305354476 024523 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALCAMERAFLASHCONTROL_H
#define AALCAMERAFLASHCONTROL_H
#include
#include
#include
#include
class AalCameraService;
struct CameraControl;
class AalCameraFlashControl : public QCameraFlashControl
{
Q_OBJECT
public:
AalCameraFlashControl(AalCameraService *service, QObject *parent = 0);
QCameraExposure::FlashModes flashMode() const;
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const;
bool isFlashReady() const;
void setFlashMode(QCameraExposure::FlashModes mode);
public Q_SLOTS:
void init(CameraControl *control);
private:
FlashMode qt2Android(QCameraExposure::FlashModes mode);
QCameraExposure::FlashModes android2Qt(FlashMode mode);
void querySupportedFlashModes();
AalCameraService *m_service;
QCameraExposure::FlashModes m_currentMode;
bool setOnInit;
QSet m_supportedModes;
};
#endif // AALCAMERAFLASHCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameracontrol.h 0000644 0000152 0177776 00000003177 12305354476 023514 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALCAMERACONTROL_H
#define AALCAMERACONTROL_H
#include
class AalCameraService;
struct CameraControl;
struct CameraControlListener;
class AalCameraControl : public QCameraControl
{
Q_OBJECT
public:
AalCameraControl(AalCameraService *service, QObject *parent = 0);
~AalCameraControl();
QCamera::State state() const;
void setState(QCamera::State state);
QCamera::Status status() const;
QCamera::CaptureModes captureMode() const;
void setCaptureMode(QCamera::CaptureModes);
bool isCaptureModeSupported(QCamera::CaptureModes mode) const;
bool canChangeProperty(PropertyChangeType changeType, QCamera::Status status) const;
static void errorCB(void* context);
public Q_SLOTS:
void init(CameraControl *control, CameraControlListener *listener);
private Q_SLOTS:
void handleError();
private:
AalCameraService *m_service;
QCamera::State m_state;
QCamera::Status m_status;
QCamera::CaptureModes m_captureMode;
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalmetadatawritercontrol.cpp 0000644 0000152 0177776 00000006121 12305354476 025624 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalmetadatawritercontrol.h"
#include "aalcameraservice.h"
/*!
* \brief AalMetaDataWriterControl::AalMetaDataWriterControl
* \param service
* \param parent
*/
AalMetaDataWriterControl::AalMetaDataWriterControl(AalCameraService *service, QObject *parent) :
QMetaDataWriterControl(parent),
m_service(service),
m_orientation(0)
{
Q_ASSERT(service);
}
/*!
* \brief AalMetaDataWriterControl::availableMetaData \reimp
* \return
*/
QStringList AalMetaDataWriterControl::availableMetaData() const
{
QStringList keys;
keys.reserve(m_metaData.size());
QMap::const_iterator i = m_metaData.constBegin();
while (i != m_metaData.constEnd()) {
keys.append(i.key());
++i;
}
return keys;
}
/*!
* \brief AalMetaDataWriterControl::isMetaDataAvailable \reimp
* \return
*/
bool AalMetaDataWriterControl::isMetaDataAvailable() const
{
return !m_metaData.isEmpty();
}
/*!
* \brief AalMetaDataWriterControl::isWritable \reimp
* \return
*/
bool AalMetaDataWriterControl::isWritable() const
{
return true;
}
/*!
* \brief AalMetaDataWriterControl::metaData \reimp
* \param key
* \return
*/
QVariant AalMetaDataWriterControl::metaData(const QString &key) const
{
if (m_metaData.contains(key))
return m_metaData[key];
return QVariant();
}
/*!
* \brief AalMetaDataWriterControl::setMetaData \reimp
* \param key
* \param value
*/
void AalMetaDataWriterControl::setMetaData(const QString &key, const QVariant &value)
{
m_metaData[key] = value;
if (key == QLatin1String("Orientation"))
m_orientation = value.toInt();
}
/*!
* \brief AalMetaDataWriterControl::orientation returns the orientation of the device, as set by the
* app in degrees.
* \return orientation, set by the app. Defaults is 0
*/
int AalMetaDataWriterControl::orientation() const
{
return m_orientation;
}
/*!
* \brief AalMetaDataWriterControl::correctedOrientation retusn the orientation
* depending on which camera is active, the value is adapted
* \return
*/
int AalMetaDataWriterControl::correctedOrientation() const
{
int rotation = m_orientation % 360;
// the front camera rotates the other way round
if (!m_service->isBackCameraUsed())
rotation = (360 - rotation) % 360;
return rotation;
}
/*!
* \brief AalMetaDataWriterControl::clearMetaData removes all metadata
*/
void AalMetaDataWriterControl::clearAllMetaData()
{
m_orientation = 0;
m_metaData.clear();
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideorenderercontrol.cpp 0000644 0000152 0177776 00000015050 12305354476 025445 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2012 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideorenderercontrol.h"
#include "aalcameraservice.h"
#include "aalviewfindersettingscontrol.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
const int MIN_FRAME_COUNT = 8; // minimal number of frames to be ready for capture
class AalGLTextureBuffer : public QAbstractVideoBuffer
{
public:
AalGLTextureBuffer(GLuint textureId) :
QAbstractVideoBuffer(QAbstractVideoBuffer::GLTextureHandle),
m_textureId(textureId)
{
}
MapMode mapMode() const { return NotMapped; }
uchar *map(MapMode mode, int *numBytes, int *bytesPerLine)
{
qDebug() << Q_FUNC_INFO;
Q_UNUSED(mode);
Q_UNUSED(numBytes);
Q_UNUSED(bytesPerLine);
return (uchar*)0;
}
void unmap()
{
qDebug() << Q_FUNC_INFO;
}
QVariant handle() const
{
return QVariant::fromValue(m_textureId);
}
GLuint textureId() { return m_textureId; }
private:
GLuint m_textureId;
};
AalVideoRendererControl::AalVideoRendererControl(AalCameraService *service, QObject *parent)
: QVideoRendererControl(parent)
, m_surface(0),
m_service(service),
m_viewFinderRunning(false),
m_textureId(0),
m_frameCount(0)
{
// Get notified when qtvideo-node creates a GL texture
connect(SharedSignal::instance(), SIGNAL(textureCreated(unsigned int)), this, SLOT(onTextureCreated(unsigned int)));
connect(SharedSignal::instance(), SIGNAL(snapshotTaken(QImage)), this, SLOT(onSnapshotTaken(QImage)));
}
AalVideoRendererControl::~AalVideoRendererControl()
{
}
QAbstractVideoSurface *AalVideoRendererControl::surface() const
{
return m_surface;
}
void AalVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
{
if (m_surface != surface) {
m_surface = surface;
Q_EMIT surfaceChanged(surface);
}
}
void AalVideoRendererControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
listener->on_preview_texture_needs_update_cb = &AalVideoRendererControl::updateViewfinderFrameCB;
m_textureId = 0;
m_frameCount = 0;
}
void AalVideoRendererControl::startPreview()
{
if (m_frameCount > 0)
return;
if (m_viewFinderRunning)
return;
if (m_textureId) {
CameraControl *cc = m_service->androidControl();
if (cc) {
android_camera_set_preview_texture(cc, m_textureId);
android_camera_start_preview(cc);
m_viewFinderRunning = true;
}
} else {
// requests a new texture
updateViewfinderFrame();
}
m_service->updateCaptureReady();
}
void AalVideoRendererControl::stopPreview()
{
if (!m_viewFinderRunning || !m_surface)
return;
m_viewFinderRunning = false;
CameraControl *cc = m_service->androidControl();
if (cc) {
android_camera_stop_preview(cc);
}
if (m_surface->isActive())
m_surface->stop();
m_frameCount = 0;
m_service->updateCaptureReady();
}
void AalVideoRendererControl::updateViewfinderFrame()
{
if (!m_surface) {
qWarning() << "Can't draw video frame without surface";
return;
}
if (!m_service->androidControl()) {
qWarning() << "Can't draw video frame without camera";
return;
}
// if framecount is 0, then m_textureId can be 0, as this will request the
// texture from the render thread. (see code in qtvideo-node).
if (!m_textureId && m_frameCount > 0) {
qWarning() << "Can't draw video frame without texture" << m_frameCount;
return;
}
QSize vfSize = m_service->viewfinderControl()->currentSize();
QVideoFrame frame(new AalGLTextureBuffer(m_textureId), vfSize, QVideoFrame::Format_RGB32);
if (!frame.isValid())
return;
CameraControl *cc = m_service->androidControl();
frame.setMetaData("CamControl", QVariant::fromValue((void*)cc));
if (!m_surface->isActive()) {
QVideoSurfaceFormat format(frame.size(), frame.pixelFormat(), frame.handleType());
if (!m_surface->start(format)) {
qWarning() << "Failed to start viewfinder with format:" << format;
}
}
if (m_surface->isActive()) {
m_surface->present(frame);
}
++m_frameCount;
if (m_frameCount == MIN_FRAME_COUNT) {
m_service->updateCaptureReady();
}
}
void AalVideoRendererControl::onTextureCreated(GLuint textureID)
{
m_textureId = textureID;
if (m_textureId) {
// as we got a new textureID
CameraControl *cc = m_service->androidControl();
if (cc) {
android_camera_set_preview_texture(cc, m_textureId);
android_camera_start_preview(cc);
m_viewFinderRunning = true;
}
}
m_service->updateCaptureReady();
}
void AalVideoRendererControl::onSnapshotTaken(QImage snapshotImage)
{
m_preview = snapshotImage;
Q_EMIT previewReady();
}
void AalVideoRendererControl::updateViewfinderFrameCB(void* context)
{
Q_UNUSED(context);
AalVideoRendererControl *self = AalCameraService::instance()->videoOutputControl();
if (self->m_viewFinderRunning)
QMetaObject::invokeMethod(self, "updateViewfinderFrame", Qt::QueuedConnection);
}
const QImage &AalVideoRendererControl::preview() const
{
return m_preview;
}
void AalVideoRendererControl::createPreview()
{
if (!m_textureId || !m_service->androidControl())
return;
QSize vfSize = m_service->viewfinderControl()->currentSize();
SharedSignal::instance()->setSnapshotSize(vfSize);
SharedSignal::instance()->takeSnapshot(m_service->androidControl());
}
bool AalVideoRendererControl::isViewfinderRunning() const
{
return m_viewFinderRunning && m_frameCount >= MIN_FRAME_COUNT;
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcamerafocuscontrol.h 0000644 0000152 0177776 00000004315 12305354476 024547 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALCAMERAFOCUSCONTROL_H
#define AALCAMERAFOCUSCONTROL_H
#include
#include
#include
class AalCameraService;
class AalCameraFocusControl : public QCameraFocusControl
{
Q_OBJECT
public:
AalCameraFocusControl(AalCameraService *service, QObject *parent = 0);
QPointF customFocusPoint() const;
QCameraFocus::FocusModes focusMode() const;
QCameraFocus::FocusPointMode focusPointMode() const;
QCameraFocusZoneList focusZones() const;
bool isFocusModeSupported(QCameraFocus::FocusModes mode) const;
bool isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const;
void setCustomFocusPoint(const QPointF & point);
void setFocusMode(QCameraFocus::FocusModes mode);
void setFocusPointMode(QCameraFocus::FocusPointMode mode);
static void focusCB(void* context);
bool isFocusBusy() const;
void enablePhotoMode();
void enableVideoMode();
public Q_SLOTS:
void init(CameraControl *control, CameraControlListener *listener);
void startFocus();
private:
AutoFocusMode qt2Android(QCameraFocus::FocusModes mode);
QCameraFocus::FocusModes android2Qt(AutoFocusMode mode);
FocusRegion point2Region(const QPointF &point) const;
AalCameraService *m_service;
QCameraFocus::FocusModes m_focusMode;
QCameraFocus::FocusPointMode m_focusPointMode;
QPointF m_focusPoint;
FocusRegion m_focusRegion;
bool setOnInit;
bool m_focusRunning;
};
#endif // AALCAMERAFOCUSCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalmediarecordercontrol.cpp 0000644 0000152 0177776 00000031570 12305354476 025422 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalmediarecordercontrol.h"
#include "aalcameraservice.h"
#include "aalmetadatawritercontrol.h"
#include "aalvideoencodersettingscontrol.h"
#include "aalviewfindersettingscontrol.h"
#include "storagemanager.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
const int AalMediaRecorderControl::RECORDER_GENERAL_ERROR;
const int AalMediaRecorderControl::RECORDER_NOT_AVAILABLE_ERROR;
const int AalMediaRecorderControl::RECORDER_INITIALIZATION_ERROR;
const int AalMediaRecorderControl::DURATION_UPDATE_INTERVALL;
const QLatin1String AalMediaRecorderControl::PARAM_AUDIO_BITRATE = QLatin1String("audio-param-encoding-bitrate");
const QLatin1String AalMediaRecorderControl::PARAM_AUDIO_CHANNELS = QLatin1String("audio-param-number-of-channels");
const QLatin1String AalMediaRecorderControl::PARAM_AUTIO_SAMPLING = QLatin1String("audio-param-sampling-rate");
const QLatin1String AalMediaRecorderControl::PARAM_LATITUDE = QLatin1String("param-geotag-latitude");
const QLatin1String AalMediaRecorderControl::PARAM_LONGITUDE = QLatin1String("param-geotag-longitude");
const QLatin1String AalMediaRecorderControl::PARAM_ORIENTATION = QLatin1String("video-param-rotation-angle-degrees");
const QLatin1String AalMediaRecorderControl::PARAM_VIDEO_BITRATE = QLatin1String("video-param-encoding-bitrate");
/*!
* \brief AalMediaRecorderControl::AalMediaRecorderControl
* \param service
* \param parent
*/
AalMediaRecorderControl::AalMediaRecorderControl(AalCameraService *service, QObject *parent)
: QMediaRecorderControl(parent),
m_service(service),
m_mediaRecorder(0),
m_duration(0),
m_currentState(QMediaRecorder::StoppedState),
m_currentStatus(QMediaRecorder::UnloadedStatus),
m_recordingTimer(0)
{
}
/*!
* \brief AalMediaRecorderControl::~AalMediaRecorderControl
*/
AalMediaRecorderControl::~AalMediaRecorderControl()
{
delete m_recordingTimer;
deleteRecorder();
}
/*!
* \reimp
*/
void AalMediaRecorderControl::applySettings()
{
qDebug() << Q_FUNC_INFO << " is not used";
}
/*!
* \reimp
*/
qint64 AalMediaRecorderControl::duration() const
{
return m_duration;
}
/*!
* \reimp
*/
bool AalMediaRecorderControl::isMuted() const
{
qDebug() << Q_FUNC_INFO << " is not used";
return false;
}
/*!
* \reimp
*/
QUrl AalMediaRecorderControl::outputLocation() const
{
return m_outputLocation;
}
/*!
* \reimp
*/
bool AalMediaRecorderControl::setOutputLocation(const QUrl &location)
{
if ( m_outputLocation == location)
return true;
m_outputLocation = location;
Q_EMIT actualLocationChanged(m_outputLocation);
return true;
}
/*!
* \reimp
*/
QMediaRecorder::State AalMediaRecorderControl::state() const
{
return m_currentState;
}
/*!
* \reimp
*/
QMediaRecorder::Status AalMediaRecorderControl::status() const
{
return m_currentStatus;
}
/*!
* \reimp
*/
qreal AalMediaRecorderControl::volume() const
{
qDebug() << Q_FUNC_INFO << " is not used";
return 1.0;
}
/*!
* \brief AalMediaRecorderControl::init makes sure the mediarecorder is
* initialized
*/
void AalMediaRecorderControl::initRecorder()
{
if (m_mediaRecorder == 0) {
m_mediaRecorder = android_media_new_recorder();
if (m_mediaRecorder == 0) {
qWarning() << "Unable to create new media recorder";
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "Unable to create new media recorder");
} else {
setStatus(QMediaRecorder::LoadedStatus);
android_recorder_set_error_cb(m_mediaRecorder, &AalMediaRecorderControl::errorCB, this);
android_camera_unlock(m_service->androidControl());
}
}
if (m_recordingTimer == 0) {
m_recordingTimer = new QTimer(this);
m_recordingTimer->setInterval(DURATION_UPDATE_INTERVALL);
m_recordingTimer->setSingleShot(false);
QObject::connect(m_recordingTimer, SIGNAL(timeout()),
this, SLOT(updateDuration()));
}
}
/*!
* \brief AalMediaRecorderControl::deleteRecorder releases all resources and
* deletes the MediaRecorder
*/
void AalMediaRecorderControl::deleteRecorder()
{
if (m_mediaRecorder == 0)
return;
android_recorder_release(m_mediaRecorder);
m_mediaRecorder = 0;
android_camera_lock(m_service->androidControl());
setStatus(QMediaRecorder::UnloadedStatus);
}
/*!
* \brief AalMediaRecorderControl::errorCB handles errors from the android layer
* \param context
*/
void AalMediaRecorderControl::errorCB(void *context)
{
Q_UNUSED(context);
QMetaObject::invokeMethod(AalCameraService::instance()->mediaRecorderControl(),
"handleError", Qt::QueuedConnection);
}
/*!
* \reimp
*/
void AalMediaRecorderControl::setMuted(bool muted)
{
Q_UNUSED(muted);
qDebug() << Q_FUNC_INFO << " is not used";
}
/*!
* \reimp
*/
void AalMediaRecorderControl::setState(QMediaRecorder::State state)
{
if (m_currentState == state)
return;
switch (state) {
case QMediaRecorder::RecordingState: {
int ret = startRecording();
if (ret == -1) {
setStatus(QMediaRecorder::LoadedStatus);
}
break;
}
case QMediaRecorder::StoppedState: {
stopRecording();
break;
}
case QMediaRecorder::PausedState: {
qDebug() << Q_FUNC_INFO << " pause not used for video recording.";
break;
}
}
}
/*!
* \reimp
*/
void AalMediaRecorderControl::setVolume(qreal gain)
{
Q_UNUSED(gain);
qDebug() << Q_FUNC_INFO << " is not used";
}
void AalMediaRecorderControl::updateDuration()
{
m_duration += DURATION_UPDATE_INTERVALL;
Q_EMIT durationChanged(m_duration);
}
/*!
* \brief AalMediaRecorderControl::handleError emits errors from android layer
*/
void AalMediaRecorderControl::handleError()
{
Q_EMIT error(RECORDER_GENERAL_ERROR, "Error on recording video");
}
/*!
* \brief AalMediaRecorderControl::setStatus
* \param status
*/
void AalMediaRecorderControl::setStatus(QMediaRecorder::Status status)
{
if (m_currentStatus == status)
return;
m_currentStatus = status;
Q_EMIT statusChanged(m_currentStatus);
}
/*!
* \brief AalMediaRecorderControl::startRecording starts a video record.
* FIXME add support for recording audio only
*/
int AalMediaRecorderControl::startRecording()
{
if (m_service->androidControl() == 0) {
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "No camera connection");
return RECORDER_INITIALIZATION_ERROR;
}
m_duration = 0;
Q_EMIT durationChanged(m_duration);
initRecorder();
if (m_mediaRecorder == 0) {
deleteRecorder();
return RECORDER_NOT_AVAILABLE_ERROR;
}
setStatus(QMediaRecorder::StartingStatus);
QVideoEncoderSettings videoSettings = m_service->videoEncoderControl()->videoSettings();
int ret;
ret = android_recorder_setCamera(m_mediaRecorder, m_service->androidControl());
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setCamera() failed\n");
return RECORDER_INITIALIZATION_ERROR;
}
//state initial / idle
ret = android_recorder_setAudioSource(m_mediaRecorder, ANDROID_AUDIO_SOURCE_CAMCORDER);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setAudioSource() failed");
return RECORDER_INITIALIZATION_ERROR;
}
ret = android_recorder_setVideoSource(m_mediaRecorder, ANDROID_VIDEO_SOURCE_CAMERA);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setVideoSource() failed");
return RECORDER_INITIALIZATION_ERROR;
}
//state initialized
ret = android_recorder_setOutputFormat(m_mediaRecorder, ANDROID_OUTPUT_FORMAT_MPEG_4);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setOutputFormat() failed");
return RECORDER_INITIALIZATION_ERROR;
}
//state DataSourceConfigured
ret = android_recorder_setAudioEncoder(m_mediaRecorder, ANDROID_AUDIO_ENCODER_AAC);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setAudioEncoder() failed");
return RECORDER_INITIALIZATION_ERROR;
}
// FIXME set codec from settings
ret = android_recorder_setVideoEncoder(m_mediaRecorder, ANDROID_VIDEO_ENCODER_H264);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setVideoEncoder() failed");
return RECORDER_INITIALIZATION_ERROR;
}
QString fileName = m_outputLocation.path();
if (fileName.isEmpty() || QFile::exists(fileName)) {
fileName = m_service->storageManager()->nextVideoFileName();
}
int fd;
fd = open(fileName.toLocal8Bit().data(), O_WRONLY | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "Could not open file for video recording");
return RECORDER_INITIALIZATION_ERROR;
}
ret = android_recorder_setOutputFile(m_mediaRecorder, fd);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setOutputFile() failed");
return RECORDER_INITIALIZATION_ERROR;
}
QSize resolution = videoSettings.resolution();
ret = android_recorder_setVideoSize(m_mediaRecorder, resolution.width(), resolution.height());
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setVideoSize() failed");
return RECORDER_INITIALIZATION_ERROR;
}
ret = android_recorder_setVideoFrameRate(m_mediaRecorder, videoSettings.frameRate());
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_setVideoFrameRate() failed");
return RECORDER_INITIALIZATION_ERROR;
}
setParameter(PARAM_VIDEO_BITRATE, videoSettings.bitRate());
// FIXME get data from a new AalAudioEncoderSettingsControl
setParameter(PARAM_AUDIO_BITRATE, 48000);
setParameter(PARAM_AUDIO_CHANNELS, 2);
setParameter(PARAM_AUTIO_SAMPLING, 96000);
if (m_service->metadataWriterControl()) {
int rotation = m_service->metadataWriterControl()->correctedOrientation();
setParameter(PARAM_ORIENTATION, rotation);
m_service->metadataWriterControl()->clearAllMetaData();
}
ret = android_recorder_prepare(m_mediaRecorder);
if (ret < 0) {
deleteRecorder();
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_prepare() failed");
return RECORDER_INITIALIZATION_ERROR;
}
//state prepared
ret = android_recorder_start(m_mediaRecorder);
if (ret < 0) {
Q_EMIT error(RECORDER_INITIALIZATION_ERROR, "android_recorder_start() failed");
return RECORDER_INITIALIZATION_ERROR;
}
m_currentState = QMediaRecorder::RecordingState;
Q_EMIT stateChanged(m_currentState);
setStatus(QMediaRecorder::RecordingStatus);
m_recordingTimer->start();
return 0;
}
/*!
* \brief AalMediaRecorderControl::stopRecording
*/
void AalMediaRecorderControl::stopRecording()
{
if (m_mediaRecorder == 0) {
return;
}
setStatus(QMediaRecorder::FinalizingStatus);
m_recordingTimer->stop();
int result = android_recorder_stop(m_mediaRecorder);
if (result < 0) {
Q_EMIT error(RECORDER_GENERAL_ERROR, "Cannot stop video recording");
return;
}
android_recorder_reset(m_mediaRecorder);
m_currentState = QMediaRecorder::StoppedState;
Q_EMIT stateChanged(m_currentState);
deleteRecorder();
}
/*!
* \brief AalMediaRecorderControl::setParameter convenient function to set parameters
* \param parameter Name of the parameter
* \param value value to set
*/
void AalMediaRecorderControl::setParameter(const QString ¶meter, int value)
{
Q_ASSERT(m_mediaRecorder);
QString param = parameter + QChar('=') + QString::number(value);
android_recorder_setParameters(m_mediaRecorder, param.toLocal8Bit().data());
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalmetadatawritercontrol.h 0000644 0000152 0177776 00000003400 12305354476 025266 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALMETADATAWRITERCONTROL_H
#define AALMETADATAWRITERCONTROL_H
#include
#include
#include
class AalCameraService;
/*!
* \brief The AalMetaDataWriterControl class handles the writable metadata
* Implementation for QMetaDataWriterControl
* http://qt-project.org/doc/qt-5.0/qtmultimedia/qmetadatawritercontrol.html
* A list of already defined tags is listed here
* http://qt-project.org/doc/qt-5.0/qtmultimedia/qmediametadata.html
*/
class AalMetaDataWriterControl : public QMetaDataWriterControl
{
Q_OBJECT
public:
explicit AalMetaDataWriterControl(AalCameraService *service, QObject *parent = 0);
QStringList availableMetaData() const;
bool isMetaDataAvailable() const;
bool isWritable() const;
QVariant metaData(const QString & key) const;
void setMetaData(const QString & key, const QVariant & value);
int orientation() const;
int correctedOrientation() const;
void clearAllMetaData();
private:
AalCameraService *m_service;
QMap m_metaData;
int m_orientation;
};
#endif // AALMETADATAWRITERCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideodeviceselectorcontrol.cpp 0000644 0000152 0177776 00000005371 12305354476 026644 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalvideodeviceselectorcontrol.h"
#include "aalcameraservice.h"
#include "aalimageencodercontrol.h"
#include "aalvideoencodersettingscontrol.h"
#include "aalviewfindersettingscontrol.h"
#include
#include
AalVideoDeviceSelectorControl::AalVideoDeviceSelectorControl(AalCameraService *service, QObject *parent)
:QVideoDeviceSelectorControl(parent),
m_service(service),
m_currentDevice(0),
m_numberOfCameras(-1)
{
}
int AalVideoDeviceSelectorControl::defaultDevice() const
{
return m_currentDevice;
}
int AalVideoDeviceSelectorControl::deviceCount() const
{
if (m_numberOfCameras < 0)
m_numberOfCameras = android_camera_get_number_of_devices();
return m_numberOfCameras;
}
QString AalVideoDeviceSelectorControl::deviceDescription(int index) const
{
switch (index) {
case 0: return QLatin1String("Back camera");
case 1: return QLatin1String("Front camera");
default: return QLatin1String("");
}
}
QString AalVideoDeviceSelectorControl::deviceName(int index) const
{
switch (index) {
case 0: return QLatin1String("Back");
case 1: return QLatin1String("Front");
default: return QLatin1String("");
}
}
int AalVideoDeviceSelectorControl::selectedDevice() const
{
return m_currentDevice;
}
void AalVideoDeviceSelectorControl::setSelectedDevice(int index)
{
if (index == m_currentDevice)
return;
if (index < 0 || index >= deviceCount()) {
qWarning() << "no valid device selected: " << index;
return;
}
if (m_service->isRecording())
return;
if (m_service->isCameraActive() && !m_service->isReady())
return;
m_service->disconnectCamera();
m_service->viewfinderControl()->resetAllSettings();
m_service->imageEncoderControl()->resetAllSettings();
m_service->videoEncoderControl()->resetAllSettings();
m_currentDevice = index;
if (m_service->isCameraActive())
m_service->connectCamera();
Q_EMIT selectedDeviceChanged(m_currentDevice);
Q_EMIT selectedDeviceChanged(deviceName(m_currentDevice));
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalimagecapturecontrol.cpp 0000644 0000152 0177776 00000022330 12305354476 025255 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraservice.h"
#include "aalimagecapturecontrol.h"
#include "aalimageencodercontrol.h"
#include "aalmetadatawritercontrol.h"
#include "aalvideorenderercontrol.h"
#include "storagemanager.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
AalImageCaptureControl::AalImageCaptureControl(AalCameraService *service, QObject *parent)
: QCameraImageCaptureControl(parent),
m_service(service),
m_cameraControl(service->cameraControl()),
m_lastRequestId(0),
m_ready(false),
m_pendingCaptureFile(),
m_photoWidth(320),
m_photoHeight(240),
m_aspectRatio(0.0),
m_screenAspectRatio(0.0),
m_audioPlayer(new QMediaPlayer(this))
{
m_galleryPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
m_audioPlayer->setMedia(QUrl::fromLocalFile("/system/media/audio/ui/camera_click.ogg"));
}
AalImageCaptureControl::~AalImageCaptureControl()
{
delete(m_audioPlayer);
}
bool AalImageCaptureControl::isReadyForCapture() const
{
return m_ready;
}
int AalImageCaptureControl::capture(const QString &fileName)
{
m_lastRequestId++;
if (!m_ready || !m_service->androidControl()) {
emit error(m_lastRequestId, QCameraImageCapture::NotReadyError,
QLatin1String("Camera not ready to capture"));
return m_lastRequestId;
}
QFileInfo fi(fileName);
if (fileName.isEmpty() || fi.isDir()) {
m_pendingCaptureFile = m_storageManager.nextPhotoFileName(fileName);
} else {
m_pendingCaptureFile = fileName;
}
bool diskOk = m_storageManager.checkDirectory(m_pendingCaptureFile);
if (!diskOk) {
emit error(m_lastRequestId, QCameraImageCapture::ResourceError,
QString("Won't be able to save file %1 to disk").arg(m_pendingCaptureFile));
return m_lastRequestId;
}
int rotation = m_service->metadataWriterControl()->correctedOrientation();
android_camera_set_rotation(m_service->androidControl(), rotation);
android_camera_take_snapshot(m_service->androidControl());
m_service->updateCaptureReady();
m_service->videoOutputControl()->createPreview();
m_service->metadataWriterControl()->clearAllMetaData();
return m_lastRequestId;
}
void AalImageCaptureControl::cancelCapture()
{
}
void AalImageCaptureControl::shutterCB(void *context)
{
Q_UNUSED(context);
QMetaObject::invokeMethod(AalCameraService::instance()->imageCaptureControl(),
"shutter", Qt::QueuedConnection);
}
void AalImageCaptureControl::saveJpegCB(void *data, uint32_t data_size, void *context)
{
Q_UNUSED(context);
AalCameraService::instance()->imageCaptureControl()->saveJpeg(data, data_size);
}
void AalImageCaptureControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(control);
// Set the optimal image resolution that will be used by the camera
QImageEncoderSettings settings;
AalImageEncoderControl *imageEncoderControl = AalCameraService::instance()->imageEncoderControl();
if (!imageEncoderControl->supportedResolutions(settings).empty()) {
imageEncoderControl->setSize(
chooseOptimalSize(imageEncoderControl->supportedResolutions(settings)));
}
else
qWarning() << "No supported resolutions detected for currently selected camera device." << endl;
listener->on_msg_shutter_cb = &AalImageCaptureControl::shutterCB;
listener->on_data_compressed_image_cb = &AalImageCaptureControl::saveJpegCB;
connect(m_service->videoOutputControl(), SIGNAL(previewReady()), this, SLOT(onPreviewReady()));
}
void AalImageCaptureControl::onPreviewReady()
{
// The preview image was fully captured, notify the UI layer
Q_EMIT imageCaptured(m_lastRequestId, m_service->videoOutputControl()->preview());
}
void AalImageCaptureControl::setReady(bool ready)
{
if (m_ready != ready) {
m_ready = ready;
Q_EMIT readyForCaptureChanged(m_ready);
}
}
bool AalImageCaptureControl::isCaptureRunning() const
{
return !m_pendingCaptureFile.isNull();
}
float AalImageCaptureControl::getAspectRatio() const
{
return m_aspectRatio;
}
void AalImageCaptureControl::shutter()
{
m_audioPlayer->play();
Q_EMIT imageExposed(m_lastRequestId);
}
QSize AalImageCaptureControl::chooseOptimalSize(const QList &sizes)
{
QSize optimalSize;
if (!sizes.empty()) {
getPriorityAspectRatios();
m_aspectRatio = m_prioritizedAspectRatios.front();
// Loop over all reported camera resolutions until we find the highest
// one that matches the current prioritized aspect ratio. If it doesn't
// find one on the current aspect ration, it selects the next ratio and
// tries again.
QList::const_iterator ratioIt = m_prioritizedAspectRatios.begin();
while (ratioIt != m_prioritizedAspectRatios.end() && optimalSize.isEmpty()) {
m_aspectRatio = (*ratioIt);
QList::const_iterator it = sizes.begin();
while (it != sizes.end()) {
const float ratio = (float)(*it).width() / (float)(*it).height();
const float EPSILON = 10e-3;
if (fabs(ratio - m_aspectRatio) < EPSILON) {
optimalSize = *it;
break;
}
++it;
}
++ratioIt;
}
}
return optimalSize;
}
float AalImageCaptureControl::getScreenAspectRatio()
{
// Only get the screen aspect ratio once, otherwise use the cached copy
if (m_screenAspectRatio == 0.0) {
// Get screen resolution.
UAUiDisplay* display = ua_ui_display_new_with_index(0);
const int kScreenWidth = ua_ui_display_query_horizontal_res(display);
const int kScreenHeight = ua_ui_display_query_vertical_res(display);
Q_ASSERT(kScreenWidth > 0 && kScreenHeight > 0);
ua_ui_display_destroy(display);
m_screenAspectRatio = (kScreenWidth > kScreenHeight) ?
((float)kScreenWidth / (float)kScreenHeight) : ((float)kScreenHeight / (float)kScreenWidth);
}
return m_screenAspectRatio;
}
void AalImageCaptureControl::getPriorityAspectRatios()
{
m_prioritizedAspectRatios.clear();
if (m_service->isBackCameraUsed()) {
if (m_screenAspectRatio > 0.0f) {
m_prioritizedAspectRatios.append(getScreenAspectRatio());
}
// Prioritized list of aspect ratios for the back camera
const float backAspectRatios[4] = { 16.0f/9.0f, 3.0f/2.0f, 4.0f/3.0f, 5.0f/4.0f };
for (uint8_t i=0; i<4; ++i) {
if (!m_prioritizedAspectRatios.contains(backAspectRatios[i])) {
m_prioritizedAspectRatios.append(backAspectRatios[i]);
}
}
} else {
// Prioritized list of aspect ratios for the front camera
const float frontAspectRatios[4] = { 4.0f/3.0f, 5.0f/4.0f, 16.0f/9.0f, 3.0f/2.0f };
for (uint8_t i=0; i<4; ++i) {
m_prioritizedAspectRatios.append(frontAspectRatios[i]);
}
}
}
void AalImageCaptureControl::saveJpeg(void *data, uint32_t dataSize)
{
if (m_pendingCaptureFile.isNull() || !m_service->androidControl())
return;
QTemporaryFile file;
if (!file.open()) {
emit error(m_lastRequestId, QCameraImageCapture::ResourceError,
QString("Could not open temprary file %1").arg(file.fileName()));
m_pendingCaptureFile.clear();
m_service->updateCaptureReady();
return;
}
qint64 writtenSize = file.write((const char*)data, dataSize);
file.close();
if (writtenSize != dataSize) {
emit error(m_lastRequestId, QCameraImageCapture::ResourceError,
QString("Could not write file %1").arg(file.fileName()));
m_pendingCaptureFile.clear();
m_service->updateCaptureReady();
return;
}
QFile finalFile(file.fileName());
bool ok = finalFile.rename(m_pendingCaptureFile);
if (!ok) {
emit error(m_lastRequestId, QCameraImageCapture::ResourceError,
QString("Could not save image to %1").arg(m_pendingCaptureFile));
m_pendingCaptureFile.clear();
m_service->updateCaptureReady();
return;
}
Q_EMIT imageSaved(m_lastRequestId, m_pendingCaptureFile);
m_pendingCaptureFile.clear();
android_camera_start_preview(m_service->androidControl());
m_service->updateCaptureReady();
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalimagecapturecontrol.h 0000644 0000152 0177776 00000005053 12305354476 024725 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALIMAGECAPTURECONTROL_H
#define AALIMAGECAPTURECONTROL_H
#include
#include
#include
#include
class AalCameraService;
class AalCameraControl;
class CameraControl;
class CameraControlListener;
class QMediaPlayer;
class AalImageCaptureControl : public QCameraImageCaptureControl
{
Q_OBJECT
public:
AalImageCaptureControl(AalCameraService *service, QObject *parent = 0);
~AalImageCaptureControl();
int capture(const QString &fileName);
void cancelCapture();
bool isReadyForCapture() const;
QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; }
void setDriveMode(QCameraImageCapture::DriveMode ) {}
static void shutterCB(void* context);
static void saveJpegCB(void* data, uint32_t data_size, void* context);
void setReady(bool ready);
bool isCaptureRunning() const;
/// Find the highest optimal aspect ratio resolution, which depends
/// on the type of camera currently selected:
float getAspectRatio() const;
public Q_SLOTS:
void init(CameraControl *control, CameraControlListener *listener);
void onPreviewReady();
private Q_SLOTS:
void shutter();
private:
QSize chooseOptimalSize(const QList &sizes);
float getScreenAspectRatio();
void getPriorityAspectRatios();
void saveJpeg(void* data, uint32_t dataSize);
AalCameraService *m_service;
AalCameraControl *m_cameraControl;
int m_lastRequestId;
StorageManager m_storageManager;
bool m_ready;
QString m_pendingCaptureFile;
int m_photoWidth;
int m_photoHeight;
float m_aspectRatio;
float m_screenAspectRatio;
/// Maintains a list of highest priority aspect ratio to lowest, for the
/// currently selected camera
QList m_prioritizedAspectRatios;
QString m_galleryPath;
QMediaPlayer *m_audioPlayer;
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraserviceplugin.cpp 0000644 0000152 0177776 00000002631 12305354476 025240 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraserviceplugin.h"
#include "aalcameraservice.h"
#include
#include
#include
AalServicePlugin::AalServicePlugin()
{
}
QMediaService* AalServicePlugin::create(QString const& key)
{
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
return new AalCameraService;
else
qWarning() << "Key not supported:" << key;
return 0;
}
void AalServicePlugin::release(QMediaService *service)
{
delete service;
}
QList AalServicePlugin::devices(const QByteArray &service) const
{
Q_UNUSED(service);
return QList();
}
QString AalServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
{
Q_UNUSED(service);
Q_UNUSED(device);
return QString();
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraservice.h 0000644 0000152 0177776 00000007311 12305354476 023466 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALCAMERASERVICE_H
#define AALCAMERASERVICE_H
#include
class AalCameraControl;
class AalCameraFlashControl;
class AalCameraFocusControl;
class AalCameraZoomControl;
class AalImageCaptureControl;
class AalImageEncoderControl;
class AalMediaRecorderControl;
class AalMetaDataWriterControl;
class AalVideoDeviceSelectorControl;
class AalVideoEncoderSettingsControl;
class AalVideoRendererControl;
class AalViewfinderSettingsControl;
class QCameraControl;
struct CameraControl;
struct CameraControlListener;
class StorageManager;
class AalCameraService : public QMediaService
{
Q_OBJECT
public:
AalCameraService(QObject *parent = 0);
~AalCameraService();
QMediaControl* requestControl(const char *name);
void releaseControl(QMediaControl *control);
AalCameraControl *cameraControl() const { return m_cameraControl; }
AalCameraFlashControl *flashControl() const { return m_flashControl; }
AalCameraFocusControl *focusControl() const { return m_focusControl; }
AalCameraZoomControl *zoomControl() const { return m_zoomControl; }
AalImageCaptureControl *imageCaptureControl() const { return m_imageCaptureControl; }
AalImageEncoderControl *imageEncoderControl() const { return m_imageEncoderControl; }
AalMediaRecorderControl *mediaRecorderControl() const { return m_mediaRecorderControl; }
AalMetaDataWriterControl *metadataWriterControl() const { return m_metadataWriter; }
AalVideoDeviceSelectorControl *deviceSelector() const { return m_deviceSelectControl; }
AalVideoEncoderSettingsControl *videoEncoderControl() const { return m_videoEncoderControl; }
AalVideoRendererControl *videoOutputControl() const { return m_videoOutput; }
AalViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; }
CameraControl *androidControl();
StorageManager *storageManager();
bool connectCamera();
void disconnectCamera();
bool isCameraActive() const;
bool isBackCameraUsed() const;
void enablePhotoMode();
void enableVideoMode();
bool isReady() const;
bool isRecording() const;
static AalCameraService *instance() { return m_service; }
public Q_SLOTS:
void updateCaptureReady();
private:
void initControls(CameraControl *camControl, CameraControlListener *listener);
static AalCameraService *m_service;
AalCameraControl *m_cameraControl;
AalCameraFlashControl *m_flashControl;
AalCameraFocusControl *m_focusControl;
AalCameraZoomControl *m_zoomControl;
AalImageCaptureControl *m_imageCaptureControl;
AalImageEncoderControl *m_imageEncoderControl;
AalMediaRecorderControl *m_mediaRecorderControl;
AalMetaDataWriterControl *m_metadataWriter;
AalVideoDeviceSelectorControl *m_deviceSelectControl;
AalVideoEncoderSettingsControl *m_videoEncoderControl;
AalVideoRendererControl *m_videoOutput;
AalViewfinderSettingsControl *m_viewfinderControl;
CameraControl *m_androidControl;
CameraControlListener *m_androidListener;
CameraControl *m_oldAndroidControl;
StorageManager *m_storageManager;
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalmediarecordercontrol.h 0000644 0000152 0177776 00000005530 12305354476 025064 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALMEDIARECORDERCONTROL_H
#define AALMEDIARECORDERCONTROL_H
#include
#include
#include
#include
#include
class AalCameraService;
struct CameraControl;
struct CameraControlListener;
struct MediaRecorderWrapper;
class QTimer;
class AalMediaRecorderControl : public QMediaRecorderControl
{
Q_OBJECT
public:
AalMediaRecorderControl(AalCameraService *service, QObject *parent = 0);
~AalMediaRecorderControl();
virtual void applySettings();
virtual qint64 duration() const;
virtual bool isMuted() const;
virtual QUrl outputLocation() const;
virtual bool setOutputLocation(const QUrl & location);
virtual QMediaRecorder::State state() const;
virtual QMediaRecorder::Status status() const;
virtual qreal volume() const;
static void errorCB(void* context);
void init(CameraControl *control, CameraControlListener *listener);
public Q_SLOTS:
virtual void setMuted(bool muted);
virtual void setState(QMediaRecorder::State state);
virtual void setVolume(qreal gain);
private Q_SLOTS:
virtual void updateDuration();
void handleError();
private:
void initRecorder();
void deleteRecorder();
void setStatus(QMediaRecorder::Status status);
int startRecording();
void stopRecording();
void setParameter(const QString ¶meter, int value);
AalCameraService *m_service;
MediaRecorderWrapper *m_mediaRecorder;
QUrl m_outputLocation;
qint64 m_duration;
QMediaRecorder::State m_currentState;
QMediaRecorder::Status m_currentStatus;
QTimer *m_recordingTimer;
static const int RECORDER_GENERAL_ERROR = -1;
static const int RECORDER_NOT_AVAILABLE_ERROR = -2;
static const int RECORDER_INITIALIZATION_ERROR = -3;
static const int DURATION_UPDATE_INTERVALL = 1000; // update every second
static const QLatin1String PARAM_AUDIO_BITRATE;
static const QLatin1String PARAM_AUDIO_CHANNELS;
static const QLatin1String PARAM_AUTIO_SAMPLING;
static const QLatin1String PARAM_LATITUDE;
static const QLatin1String PARAM_LONGITUDE;
static const QLatin1String PARAM_ORIENTATION;
static const QLatin1String PARAM_VIDEO_BITRATE;
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideoencodersettingscontrol.h 0000644 0000152 0177776 00000004007 12305354476 026504 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALVIDEOENCODERSETTINGSCONTROL_H
#define AALVIDEOENCODERSETTINGSCONTROL_H
#include
class AalCameraService;
struct CameraControl;
struct CameraControlListener;
class AalVideoEncoderSettingsControl : public QVideoEncoderSettingsControl
{
Q_OBJECT
public:
explicit AalVideoEncoderSettingsControl(AalCameraService *service, QObject *parent = 0);
virtual void setVideoSettings(const QVideoEncoderSettings &settings);
virtual QList supportedFrameRates(const QVideoEncoderSettings &settings, bool *continuous = 0) const;
virtual QList supportedResolutions(const QVideoEncoderSettings &settings, bool *continuous = 0) const;
virtual QStringList supportedVideoCodecs() const;
virtual QString videoCodecDescription(const QString &codec) const;
virtual QVideoEncoderSettings videoSettings() const;
float getAspectRatio() const;
void init(CameraControl *control, CameraControlListener *listener);
void resetAllSettings();
static void sizeCB(void *ctx, int width, int height);
private:
void querySupportedResolution() const;
AalCameraService *m_service;
QVideoEncoderSettings m_settings;
mutable QList m_availableSizes;
static const QSize DEFAULT_SIZE;
static const int DEFAULT_FPS;
static const QString DEFAULT_CODEC;
};
#endif // AALVIDEOENCODERSETTINGSCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/aalviewfindersettingscontrol.cpp 0000644 0000152 0177776 00000015361 12305354476 026540 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalviewfindersettingscontrol.h"
#include "aalcameraservice.h"
#include "aalvideorenderercontrol.h"
#include
#include
#include
AalViewfinderSettingsControl::AalViewfinderSettingsControl(AalCameraService *service, QObject *parent)
:QCameraViewfinderSettingsControl(parent),
m_service(service),
m_currentSize(),
m_aspectRatio(0.0),
m_currentFPS(30),
m_minFPS(10),
m_maxFPS(30)
{
}
AalViewfinderSettingsControl::~AalViewfinderSettingsControl()
{
}
bool AalViewfinderSettingsControl::isViewfinderParameterSupported(ViewfinderParameter parameter) const
{
if (parameter == QCameraViewfinderSettingsControl::Resolution ||
parameter == QCameraViewfinderSettingsControl::MinimumFrameRate ||
parameter == QCameraViewfinderSettingsControl::MaximumFrameRate ) {
return true;
}
return false;
}
void AalViewfinderSettingsControl::setViewfinderParameter(ViewfinderParameter parameter, const QVariant &value)
{
if (!isViewfinderParameterSupported(parameter)) {
qWarning() << "Viewfinder dos not support parameter " << parameter;
return;
}
switch (parameter) {
case QCameraViewfinderSettingsControl::Resolution:
setSize(value.toSize());
break;
case QCameraViewfinderSettingsControl::MinimumFrameRate:
case QCameraViewfinderSettingsControl::MaximumFrameRate:
qWarning() << "Camera framerate boundaries are set by the backend";
break;
default:
break;
}
}
QVariant AalViewfinderSettingsControl::viewfinderParameter(ViewfinderParameter parameter) const
{
if (!isViewfinderParameterSupported(parameter)) {
qWarning() << "Viewfinder dos not support parameter " << parameter;
return QVariant();
}
switch (parameter) {
case QCameraViewfinderSettingsControl::Resolution:
return m_currentSize;
case QCameraViewfinderSettingsControl::MinimumFrameRate:
return m_minFPS;
case QCameraViewfinderSettingsControl::MaximumFrameRate:
return m_maxFPS;
default:
break;
}
return QVariant();
}
void AalViewfinderSettingsControl::setSize(const QSize &size)
{
if (size == m_currentSize)
return;
CameraControl *cc = m_service->androidControl();
if (!cc) {
m_currentSize = size; // will be used on next call of init
return;
}
if (!m_availableSizes.contains(size)) {
qWarning() << "Size " << size << "is not supported by the camera";
qWarning() << "Supported sizes are: " << m_availableSizes;
return;
}
m_currentSize = size;
AalVideoRendererControl *videoRenderer = m_service->videoOutputControl();
bool vfRunning = videoRenderer->isViewfinderRunning();
if (vfRunning)
videoRenderer->stopPreview();
android_camera_set_preview_size(cc, m_currentSize.width(), m_currentSize.height());
if (vfRunning)
videoRenderer->startPreview();
}
QSize AalViewfinderSettingsControl::currentSize() const
{
return m_currentSize;
}
/*!
* \brief AalViewfinderSettingsControl::supportedSizes returns the supported viewfinder
* sizes
* \return
*/
const QList &AalViewfinderSettingsControl::supportedSizes() const
{
if (m_availableSizes.isEmpty()) {
CameraControl *cc = m_service->androidControl();
if (cc) {
AalViewfinderSettingsControl *vfControl = const_cast(this);
android_camera_enumerate_supported_preview_sizes(cc,
&AalViewfinderSettingsControl::sizeCB,
vfControl);
}
}
return m_availableSizes;
}
/*!
* \brief AalViewfinderSettingsControl::setAspectRatio sets the viewfinder's aspect ratio
* \param ratio the aspect ratio that should be used
*/
void AalViewfinderSettingsControl::setAspectRatio(float ratio)
{
if (ratio == m_aspectRatio)
return;
m_aspectRatio = ratio;
// Choose optimal resolution based on the current camera's aspect ratio
QSize size = chooseOptimalSize(m_availableSizes);
setSize(size);
}
void AalViewfinderSettingsControl::init(CameraControl *control, CameraControlListener *listener)
{
Q_UNUSED(listener);
if (m_availableSizes.isEmpty()) {
android_camera_enumerate_supported_preview_sizes(control, &AalViewfinderSettingsControl::sizeCB, this);
}
// Choose optimal resolution based on the current camera's aspect ratio
m_currentSize = chooseOptimalSize(m_availableSizes);
android_camera_set_preview_size(control, m_currentSize.width(), m_currentSize.height());
android_camera_get_preview_fps_range(control, &m_minFPS, &m_maxFPS);
m_minFPS /= 1000;
m_maxFPS /= 1000;
m_currentFPS = m_maxFPS;
android_camera_set_preview_fps(control, m_currentFPS);
}
/*! Resets all data, so a new init starts with a fresh start
This is used when switching the cameras
Only works when there is no camera active/connected
*/
void AalViewfinderSettingsControl::resetAllSettings()
{
if (m_service->androidControl())
return;
m_currentSize = QSize();
m_availableSizes.clear();
m_currentFPS = 0;
m_minFPS = 0;
m_maxFPS = 0;
}
void AalViewfinderSettingsControl::sizeCB(void *ctx, int width, int height)
{
AalViewfinderSettingsControl *self = (AalViewfinderSettingsControl*)ctx;
self->m_availableSizes.append(QSize(width, height));
}
QSize AalViewfinderSettingsControl::chooseOptimalSize(const QList &sizes) const
{
if (!sizes.empty()) {
if (m_aspectRatio == 0) {
// There are resolutions supported, choose one non-optimal one):
return sizes[1];
}
QList::const_iterator it = sizes.begin();
while (it != sizes.end()) {
const float ratio = (float)(*it).width() / (float)(*it).height();
const float EPSILON = 10e-3;
if (fabs(ratio - m_aspectRatio) < EPSILON) {
return *it;
}
++it;
}
}
return QSize();
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalvideorenderercontrol.h 0000644 0000152 0177776 00000003543 12305354476 025116 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALVIDEORENDERERCONTROL_H
#define AALVIDEORENDERERCONTROL_H
#include
#include
#include
class AalCameraService;
struct CameraControl;
struct CameraControlListener;
class AalVideoRendererControl : public QVideoRendererControl
{
Q_OBJECT
public:
AalVideoRendererControl(AalCameraService *service, QObject *parent = 0);
~AalVideoRendererControl();
QAbstractVideoSurface *surface() const;
void setSurface(QAbstractVideoSurface *surface);
static void updateViewfinderFrameCB(void *context);
const QImage &preview() const;
void createPreview();
bool isViewfinderRunning() const;
public Q_SLOTS:
void init(CameraControl *control, CameraControlListener *listener);
void startPreview();
void stopPreview();
Q_SIGNALS:
void surfaceChanged(QAbstractVideoSurface *surface);
void previewReady();
private Q_SLOTS:
void updateViewfinderFrame();
void onTextureCreated(unsigned int textureID);
void onSnapshotTaken(QImage snapshotImage);
private:
QAbstractVideoSurface *m_surface;
AalCameraService *m_service;
bool m_viewFinderRunning;
GLuint m_textureId;
QImage m_preview;
int m_frameCount;
};
#endif
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraflashcontrol.cpp 0000644 0000152 0177776 00000006730 12305354476 025063 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameraflashcontrol.h"
#include "aalcameracontrol.h"
#include "aalcameraservice.h"
#include
#include
#include
AalCameraFlashControl::AalCameraFlashControl(AalCameraService *service, QObject *parent)
: QCameraFlashControl(parent),
m_service(service),
m_currentMode(QCameraExposure::FlashManual),
setOnInit(false)
{
}
QCameraExposure::FlashModes AalCameraFlashControl::flashMode() const
{
return m_currentMode;
}
bool AalCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const
{
return m_supportedModes.contains(mode);
}
bool AalCameraFlashControl::isFlashReady() const
{
return true;
}
void AalCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode)
{
if (mode == m_currentMode || !isFlashModeSupported(mode))
return;
FlashMode fmode = qt2Android(mode);
m_currentMode = mode;
if (m_service->androidControl()) {
android_camera_set_flash_mode(m_service->androidControl(), fmode);
}
else {
setOnInit = true;
}
}
void AalCameraFlashControl::init(CameraControl *control)
{
querySupportedFlashModes();
if (setOnInit) {
FlashMode mode = qt2Android(m_currentMode);
android_camera_set_flash_mode(control, mode);
setOnInit = false;
}
Q_EMIT flashReady(true);
}
FlashMode AalCameraFlashControl::qt2Android(QCameraExposure::FlashModes mode)
{
switch(mode) {
case QCameraExposure::FlashOff:
return FLASH_MODE_OFF;
case QCameraExposure::FlashOn:
return FLASH_MODE_ON;
case QCameraExposure::FlashVideoLight:
case QCameraExposure::FlashTorch:
return FLASH_MODE_TORCH;
case QCameraExposure::FlashAuto:
default:
return FLASH_MODE_AUTO;
}
}
QCameraExposure::FlashModes AalCameraFlashControl::android2Qt(FlashMode mode)
{
switch(mode) {
case FLASH_MODE_OFF:
return QCameraExposure::FlashOff;
case FLASH_MODE_ON:
return QCameraExposure::FlashOn;
case FLASH_MODE_TORCH:
return QCameraExposure::FlashTorch;
case FLASH_MODE_AUTO:
default:
return QCameraExposure::FlashAuto;
}
}
/*!
* \brief AalCameraFlashControl::querySupportedFlashModes gets the supported
* flash modes for the current camera
* FIXME get the supported modes from libhybris
*/
void AalCameraFlashControl::querySupportedFlashModes()
{
m_supportedModes.clear();
if (m_service->isBackCameraUsed()) {
m_supportedModes << QCameraExposure::FlashOff << QCameraExposure::FlashOn
<< QCameraExposure::FlashAuto << QCameraExposure::FlashVideoLight
<< QCameraExposure::FlashTorch;
} else {
m_supportedModes << QCameraExposure::FlashOff;
}
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcamerazoomcontrol.h 0000644 0000152 0177776 00000003133 12305354476 024411 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef AALCAMERAZOOMCONTROL_H
#define AALCAMERAZOOMCONTROL_H
#include
class AalCameraService;
class CameraControl;
class CameraControlListener;
class AalCameraZoomControl : public QCameraZoomControl
{
Q_OBJECT
public:
AalCameraZoomControl(AalCameraService *service, QObject *parent = 0);
qreal currentDigitalZoom() const;
qreal currentOpticalZoom() const;
qreal maximumDigitalZoom() const;
qreal maximumOpticalZoom() const;
qreal requestedDigitalZoom() const;
qreal requestedOpticalZoom() const;
void zoomTo(qreal optical, qreal digital);
void enablePhotoMode();
void enableVideoMode();
public Q_SLOTS:
void init(CameraControl *control, CameraControlListener *listener);
private:
void resetCurrentZoom();
void setMaxZoom(int maxValue);
AalCameraService *m_service;
int m_currentDigialZoom;
int m_maximalDigitalZoom;
int m_pendingZoom;
};
#endif // AALCAMERAZOOMCONTROL_H
qtubuntu-camera-0.3.3+14.04.20140304/src/src.pro 0000644 0000152 0177776 00000002534 12305354476 021341 0 ustar pbuser nogroup 0000000 0000000 include(../coverage.pri)
TARGET = aalcamera
TEMPLATE = lib
CONFIG += plugin
QT += multimedia opengl
PLUGIN_TYPE = mediaservice
target.path += $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS = target
INCLUDEPATH += /usr/include/libqtubuntu-media-signals
LIBS += \
-lcamera \
-lmedia \
-lubuntu_application_api \
-lqtubuntu-media-signals
OTHER_FILES += aalcamera.json
HEADERS += \
aalcameracontrol.h \
aalcameraflashcontrol.h \
aalcamerafocuscontrol.h \
aalcameraservice.h \
aalcameraserviceplugin.h \
aalcamerazoomcontrol.h \
aalimagecapturecontrol.h \
aalimageencodercontrol.h \
aalmediarecordercontrol.h \
aalmetadatawritercontrol.h \
aalvideodeviceselectorcontrol.h \
aalvideoencodersettingscontrol.h \
aalvideorenderercontrol.h \
aalviewfindersettingscontrol.h \
storagemanager.h
SOURCES += \
aalcameracontrol.cpp \
aalcameraflashcontrol.cpp \
aalcamerafocuscontrol.cpp \
aalcameraservice.cpp \
aalcameraserviceplugin.cpp \
aalcamerazoomcontrol.cpp \
aalimagecapturecontrol.cpp \
aalimageencodercontrol.cpp \
aalmediarecordercontrol.cpp \
aalmetadatawritercontrol.cpp \
aalvideodeviceselectorcontrol.cpp \
aalvideoencodersettingscontrol.cpp \
aalvideorenderercontrol.cpp \
aalviewfindersettingscontrol.cpp \
storagemanager.cpp
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcameraservice.cpp 0000644 0000152 0177776 00000021216 12305354476 024021 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "aalcameracontrol.h"
#include "aalcameraflashcontrol.h"
#include "aalcamerafocuscontrol.h"
#include "aalcameraservice.h"
#include "aalcamerazoomcontrol.h"
#include "aalimagecapturecontrol.h"
#include "aalimageencodercontrol.h"
#include "aalmediarecordercontrol.h"
#include "aalmetadatawritercontrol.h"
#include "aalvideodeviceselectorcontrol.h"
#include "aalvideoencodersettingscontrol.h"
#include "aalvideorenderercontrol.h"
#include "aalviewfindersettingscontrol.h"
#include
#include
#include
AalCameraService *AalCameraService::m_service = 0;
AalCameraService::AalCameraService(QObject *parent):
QMediaService(parent),
m_androidControl(0),
m_androidListener(0),
m_oldAndroidControl(0)
{
m_service = this;
m_storageManager = new StorageManager;
m_cameraControl = new AalCameraControl(this);
m_flashControl = new AalCameraFlashControl(this);
m_focusControl = new AalCameraFocusControl(this);
m_zoomControl = new AalCameraZoomControl(this);
m_imageCaptureControl = new AalImageCaptureControl(this);
m_imageEncoderControl = new AalImageEncoderControl(this);
m_mediaRecorderControl = new AalMediaRecorderControl(this);
m_metadataWriter = new AalMetaDataWriterControl(this);
m_deviceSelectControl = new AalVideoDeviceSelectorControl(this);
m_videoEncoderControl = new AalVideoEncoderSettingsControl(this);
m_videoOutput = new AalVideoRendererControl(this);
m_viewfinderControl = new AalViewfinderSettingsControl(this);
}
AalCameraService::~AalCameraService()
{
disconnectCamera();
m_cameraControl->setState(QCamera::UnloadedState);
delete m_cameraControl;
delete m_flashControl;
delete m_focusControl;
delete m_zoomControl;
delete m_imageEncoderControl;
delete m_imageCaptureControl;
delete m_mediaRecorderControl;
delete m_metadataWriter;
delete m_deviceSelectControl;
delete m_videoEncoderControl;
delete m_videoOutput;
delete m_viewfinderControl;
if (m_oldAndroidControl)
android_camera_delete(m_oldAndroidControl);
if (m_androidControl)
android_camera_delete(m_androidControl);
delete m_storageManager;
}
QMediaControl *AalCameraService::requestControl(const char *name)
{
if (qstrcmp(name, QCameraControl_iid) == 0)
return m_cameraControl;
if (qstrcmp(name, QCameraFlashControl_iid) == 0)
return m_flashControl;
if (qstrcmp(name, QCameraFocusControl_iid) == 0)
return m_focusControl;
if (qstrcmp(name, QCameraImageCaptureControl_iid) == 0)
return m_imageCaptureControl;
if (qstrcmp(name, QImageEncoderControl_iid) == 0)
return m_imageEncoderControl;
if (qstrcmp(name, QMediaRecorderControl_iid) == 0)
return m_mediaRecorderControl;
if (qstrcmp(name, QMetaDataWriterControl_iid) == 0)
return m_metadataWriter;
if (qstrcmp(name, QCameraZoomControl_iid) == 0)
return m_zoomControl;
if (qstrcmp(name, QVideoDeviceSelectorControl_iid) == 0)
return m_deviceSelectControl;
if (qstrcmp(name, QVideoEncoderSettingsControl_iid) == 0)
return m_videoEncoderControl;
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
return m_videoOutput;
if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0)
return m_viewfinderControl;
return 0;
}
void AalCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
CameraControl *AalCameraService::androidControl()
{
return m_androidControl;
}
StorageManager *AalCameraService::storageManager()
{
return m_storageManager;
}
bool AalCameraService::connectCamera()
{
if (m_androidControl)
return true;
if (m_oldAndroidControl){
/// FIXME
/// becasue android_camera_disconnect() is asynchronous, it's not deleted directly when calling disconnect
/// properly implemented, whe should be notified when it can be deleted
/// in case 2 switches happend very fast, this delete might happen too eraly
android_camera_delete(m_oldAndroidControl);
}
m_oldAndroidControl = m_androidControl;
CameraType device = BACK_FACING_CAMERA_TYPE;
if (!isBackCameraUsed())
device = FRONT_FACING_CAMERA_TYPE;
m_androidListener = new CameraControlListener;
memset(m_androidListener, 0, sizeof(*m_androidListener));
m_androidControl = android_camera_connect_to(device, m_androidListener);
// fallback if there is only one camera
if (!m_androidControl && m_deviceSelectControl->deviceCount() == 1) {
if (device == BACK_FACING_CAMERA_TYPE)
device = FRONT_FACING_CAMERA_TYPE;
else
device = BACK_FACING_CAMERA_TYPE;
m_androidControl = android_camera_connect_to(device, m_androidListener);
}
if (!m_androidControl) {
delete m_androidListener;
m_androidListener = 0;
return false;
}
m_androidListener->context = m_androidControl;
initControls(m_androidControl, m_androidListener);
m_videoOutput->startPreview();
return true;
}
void AalCameraService::disconnectCamera()
{
if (m_service->videoOutputControl()->isViewfinderRunning())
m_service->videoOutputControl()->stopPreview();
if (m_androidControl) {
android_camera_disconnect(m_androidControl);
m_androidControl = 0;
}
if (m_androidListener) {
delete m_androidListener;
m_androidListener = 0;
}
}
bool AalCameraService::isCameraActive() const
{
return m_cameraControl->state() == QCamera::ActiveState;
}
bool AalCameraService::isBackCameraUsed() const
{
return m_deviceSelectControl->selectedDevice() == 0;
}
/*!
* \brief AalCameraService::enablePhotoMode sets all controls into photo mode
*/
void AalCameraService::enablePhotoMode()
{
m_imageEncoderControl->enablePhotoMode();
m_focusControl->enablePhotoMode();
m_zoomControl->enablePhotoMode();
m_viewfinderControl->setAspectRatio(m_imageCaptureControl->getAspectRatio());
}
/*!
* \brief AalCameraService::enableVideoMode sets all controls into video mode
*/
void AalCameraService::enableVideoMode()
{
m_focusControl->enableVideoMode();
m_zoomControl->enableVideoMode();
m_viewfinderControl->setAspectRatio(m_videoEncoderControl->getAspectRatio());
}
/*!
* \brief AalCameraService::isReady return if the camera is ready for capturing
* \return
*/
bool AalCameraService::isReady() const
{
return m_imageCaptureControl->isReadyForCapture();
}
/*!
* \brief AalCameraService::isRecording returns true is a video recording is
* currently ongoing
* \return
*/
bool AalCameraService::isRecording() const
{
return m_mediaRecorderControl->state() != QMediaRecorder::StoppedState;
}
void AalCameraService::updateCaptureReady()
{
bool ready = true;
if (!(m_cameraControl->state() == QCamera::ActiveState))
ready = false;
if (m_imageCaptureControl->isCaptureRunning())
ready = false;
if (m_focusControl->isFocusBusy())
ready = false;
if (!m_videoOutput->isViewfinderRunning())
ready = false;
m_imageCaptureControl->setReady(ready);
}
/*!
* \brief AalCameraService::initControls initialize all the controls for a newly
* connected camera
* \param camControl
* \param listener
*/
void AalCameraService::initControls(CameraControl *camControl, CameraControlListener *listener)
{
m_cameraControl->init(camControl, listener);
m_imageEncoderControl->init(camControl);
m_imageCaptureControl->init(camControl, listener);
m_flashControl->init(camControl);
m_focusControl->init(camControl, listener);
m_zoomControl->init(camControl, listener);
m_videoEncoderControl->init(camControl, listener);
if (m_cameraControl->captureMode() == QCamera::CaptureStillImage)
m_viewfinderControl->setAspectRatio(m_imageCaptureControl->getAspectRatio());
else
m_viewfinderControl->setAspectRatio(m_videoEncoderControl->getAspectRatio());
m_viewfinderControl->init(camControl, listener);
m_videoOutput->init(camControl, listener);
}
qtubuntu-camera-0.3.3+14.04.20140304/src/aalcamera.json 0000644 0000152 0177776 00000000055 12305354476 022625 0 ustar pbuser nogroup 0000000 0000000 {
"Keys": ["org.qt-project.qt.camera"]
}
qtubuntu-camera-0.3.3+14.04.20140304/COPYING 0000644 0000152 0177776 00000016743 12305354476 020303 0 ustar pbuser nogroup 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.