qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/ 0000755 0000152 0177776 00000000000 12305355706 021431 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/fakeCamera.pro 0000644 0000152 0177776 00000000104 12305355477 024172 0 ustar pbuser nogroup 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += \
data \
src \
unittests
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/unittests/ 0000755 0000152 0177776 00000000000 12305355706 023473 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/unittests/unittests.pro 0000644 0000152 0177776 00000000055 12305355477 026264 0 ustar pbuser nogroup 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += storagemanager
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/unittests/storagemanager/ 0000755 0000152 0177776 00000000000 12305355706 026472 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/unittests/storagemanager/tst_storagemanager.cpp 0000644 0000152 0177776 00000003303 12305355477 033073 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
#define private public
#include "storagemanager.h"
class tst_StorageManager : public QObject
{
Q_OBJECT
private slots:
void fileNameGenerator_data();
void fileNameGenerator();
};
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" << "mpg";
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";
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, extension);
QCOMPARE(generated, expected);
}
QTEST_MAIN(tst_StorageManager)
#include "tst_storagemanager.moc"
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/unittests/storagemanager/storagemanager.pro 0000644 0000152 0177776 00000000507 12305355477 032222 0 ustar pbuser nogroup 0000000 0000000 CONFIG += testcase
TARGET = tst_storagemanager
QT += testlib
SOURCES += tst_storagemanager.cpp \
../../src/storagemanager.cpp
INCLUDEPATH += ../../src
# The testcase config forces an INSTALLS of the tests, so we have to
# explicitly inform it that we do not want the tests installed
target.CONFIG += no_default_install
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/ 0000755 0000152 0177776 00000000000 12305355706 022220 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecamerazoomcontrol.cpp 0000644 0000152 0177776 00000004164 12305355477 027323 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 "fakecamerazoomcontrol.h"
#include "fakecameraservice.h"
#include "fakevideodeviceselectorcontrol.h"
#include
FakeCameraZoomControl::FakeCameraZoomControl(FakeCameraService *service, QObject *parent)
: QCameraZoomControl(parent),
m_service(service),
m_zoom(1.0),
m_maxZoom(6.0)
{
m_service->fakeSensor().setZoomFactor(m_zoom);
}
qreal FakeCameraZoomControl::currentDigitalZoom() const
{
return m_zoom;
}
qreal FakeCameraZoomControl::currentOpticalZoom() const
{
return 1.0;
}
qreal FakeCameraZoomControl::maximumDigitalZoom() const
{
return m_maxZoom;
}
qreal FakeCameraZoomControl::maximumOpticalZoom() const
{
return 1.0;
}
qreal FakeCameraZoomControl::requestedDigitalZoom() const
{
return m_zoom;
}
qreal FakeCameraZoomControl::requestedOpticalZoom() const
{
return 1.0;
}
void FakeCameraZoomControl::zoomTo(qreal optical, qreal digital)
{
Q_UNUSED(optical);
if (!(digital < 1.0 || digital > maximumDigitalZoom())) {
m_zoom = digital;
m_service->fakeSensor().setZoomFactor(m_zoom);
Q_EMIT currentDigitalZoomChanged(m_zoom);
}
}
void FakeCameraZoomControl::resetZoom()
{
if (m_service->deviceSelector()->selectedDevice() == 0) {
m_zoom = 1.0;
m_maxZoom = 6.0;
} else {
m_zoom = 1.0;
m_maxZoom = 3.0;
}
m_service->fakeSensor().setZoomFactor(m_zoom);
Q_EMIT currentDigitalZoomChanged(m_zoom);
Q_EMIT maximumDigitalZoomChanged(m_maxZoom);
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/storagemanager.cpp 0000644 0000152 0177776 00000004700 12305355477 025731 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 photoExtension = QLatin1String("jpg");
const QLatin1String videoExtension = QLatin1String("mpg");
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(photoExtension);
}
QString StorageManager::nextVideoFileName(const QString &directoy)
{
m_directory = directoy;
if (m_directory.isEmpty())
m_directory = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
return nextMediaFileName(videoExtension);
}
void 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())
dir.mkpath(dir.absolutePath());
}
QString StorageManager::nextMediaFileName(const QString &extension)
{
int idx = 1;
QString fileName = fileNameGenerator(idx, extension);
while (QFile::exists(fileName)) {
++idx;
fileName = fileNameGenerator(idx, extension);
}
return fileName;
}
QString StorageManager::fileNameGenerator(int idx, const QString& extension)
{
QString date = QDate::currentDate().toString(dateFormat);
return QString("%1/%2%3_%4.%5")
.arg(m_directory)
.arg(photoBase)
.arg(date)
.arg(idx,4,10,QLatin1Char('0'))
.arg(extension);
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakedata.h 0000644 0000152 0177776 00000002774 12305355477 024150 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 FAKEDATA_H
#define FAKEDATA_H
#include
#include
#include
#include
#include
class FakeData: public QObject
{
Q_OBJECT
public:
FakeData();
QImage viewfinderFrame() const;
QImage previewFrame() const;
QImage capturedImage() const;
void setViewfinderSize(const QSize &size);
const QSize& viewfinderSize() const;
void setZoomFactor(double zoom);
void startMove();
void stopMove();
void setSelectedCamera(int idx);
Q_SIGNALS:
void newViewfinderFrame();
private Q_SLOTS:
void updatePosition();
private:
QImage rawFrame() const;
QImage m_rawData;
int m_frameWidth;
int m_frameHeight;
QPoint m_offset;
QTimer m_cameraShake;
double m_movecounter;
QSize m_viewfinderSize;
QSize m_imageSize;
double m_zoomFactor;
};
#endif // FAKEDATA_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakedata.cpp 0000644 0000152 0177776 00000007544 12305355477 024503 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 "fakedata.h"
#include
#include
#include
const QLatin1String fakeImageBack = QLatin1String("/usr/share/fakeCamera/image_back.jpg");
const QLatin1String fakeImageFront = QLatin1String("/usr/share/fakeCamera/image_front.jpg");
const int backFrameWidth = 1250;
const int backFrameHeight = 2000;
const int frontFrameWidth = 960;
const int frontFrameHeight = 1280;
const int backImageWidth = 1458;
const int backImageHeight = 2592;
const int frontImageWidth = 960;
const int frontImageHeight = 1280;
const int widthShake = 30;
const int heightShake = 20;
const int backVfWidth = 720;
const int backVfHeight = 1280;
const int frontVfWidth = 720;
const int frontVfHeight = 960;
FakeData::FakeData()
: m_frameWidth(backFrameWidth),
m_frameHeight(backFrameHeight),
m_offset(widthShake,heightShake),
m_movecounter(0),
m_viewfinderSize(backVfWidth,backVfHeight),
m_imageSize(backImageWidth,backImageHeight),
m_zoomFactor(1.0)
{
m_rawData.load(fakeImageBack);
m_cameraShake.setInterval(67);
QObject::connect(&m_cameraShake, SIGNAL(timeout()), this, SLOT(updatePosition()));
startMove();
}
QImage FakeData::viewfinderFrame() const
{
QImage frame = rawFrame().scaled(m_viewfinderSize);
QTransform rot;
rot = rot.rotate(-90);
return frame.transformed(rot);
}
QImage FakeData::previewFrame() const
{
return viewfinderFrame();
}
QImage FakeData::capturedImage() const
{
QImage frame = rawFrame().scaled(m_imageSize);
QTransform rot;
rot = rot.rotate(-90);
return frame.transformed(rot);
}
void FakeData::setViewfinderSize(const QSize& size)
{
m_viewfinderSize = size;
}
const QSize &FakeData::viewfinderSize() const
{
return m_viewfinderSize;
}
void FakeData::setZoomFactor(double zoom)
{
if (zoom < 1.0)
return;
m_zoomFactor = zoom;
}
void FakeData::updatePosition()
{
m_offset.setX(widthShake + widthShake*sin(m_movecounter));
m_offset.setY(heightShake + heightShake*cos(m_movecounter));
m_movecounter += 0.05;
Q_EMIT newViewfinderFrame();
}
void FakeData::startMove()
{
m_cameraShake.start();
}
void FakeData::stopMove()
{
m_cameraShake.stop();
}
void FakeData::setSelectedCamera(int idx)
{
if (idx==1) {
m_rawData.load(fakeImageFront);
m_frameWidth = frontFrameWidth;
m_frameHeight = frontFrameHeight;
m_viewfinderSize.setWidth(frontVfWidth);
m_viewfinderSize.setHeight(frontVfHeight);
m_imageSize.setWidth(frontImageWidth);
m_imageSize.setHeight(frontImageHeight);
} else {
m_rawData.load(fakeImageBack);
m_frameWidth = backFrameWidth;
m_frameHeight = backFrameHeight;
m_viewfinderSize.setWidth(backVfWidth);
m_viewfinderSize.setHeight(backVfHeight);
m_imageSize.setWidth(backImageWidth);
m_imageSize.setHeight(backImageHeight);
}
}
QImage FakeData::rawFrame() const
{
QPoint center(500+m_offset.x()+m_frameWidth/2, m_offset.y()+m_frameHeight/2);
int width = (double)m_frameWidth / m_zoomFactor;
int height = (double)m_frameHeight / m_zoomFactor;
int x = center.x() - width/2;
int y = center.y() - height/2;
return m_rawData.copy(x, y, width, height);
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/storagemanager.h 0000644 0000152 0177776 00000002204 12305355477 025373 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());
void checkDirectory(const QString &path) const;
private:
QString nextMediaFileName(const QString &extension);
QString fileNameGenerator(int idx, const QString &extension);
QString m_directory;
};
#endif // STORAGEMANAGER_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraserviceplugin.cpp 0000644 0000152 0177776 00000002623 12305355477 027613 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 "fakecameraserviceplugin.h"
#include "fakecameraservice.h"
#include
FakeServicePlugin::FakeServicePlugin()
{
}
QMediaService* FakeServicePlugin::create(QString const& key)
{
if (key == QLatin1String(Q_MEDIASERVICE_CAMERA))
return new FakeCameraService;
else
qWarning() << "Key not supported:" << key;
return 0;
}
void FakeServicePlugin::release(QMediaService *service)
{
Q_UNUSED(service);
delete service;
}
QList FakeServicePlugin::devices(const QByteArray &service) const
{
Q_UNUSED(service);
return QList();
}
QString FakeServicePlugin::deviceDescription(const QByteArray &service, const QByteArray &device)
{
Q_UNUSED(service);
Q_UNUSED(device);
return QString();
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakeimagecapturecontrol.h 0000644 0000152 0177776 00000003516 12305355477 027301 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 FAKEIMAGECAPTURECONTROL_H
#define FAKEIMAGECAPTURECONTROL_H
#include
#include
class FakeCameraService;
class FakeCameraControl;
class QThread;
class SaveJpegWorker: public QObject
{
Q_OBJECT
public Q_SLOTS:
void saveJpeg(QImage image, const QString &fileName);
Q_SIGNALS:
void saveDone();
};
class FakeImageCaptureControl : public QCameraImageCaptureControl
{
Q_OBJECT
public:
FakeImageCaptureControl(FakeCameraService *service, QObject *parent = 0);
~FakeImageCaptureControl();
int capture(const QString &fileName);
void cancelCapture();
bool isReadyForCapture() const;
QCameraImageCapture::DriveMode driveMode() const { return QCameraImageCapture::SingleImageCapture; }
void setDriveMode(QCameraImageCapture::DriveMode ) {}
private Q_SLOTS:
void updateReady();
void performPreview();
void performCapture();
void saveDone();
private:
FakeCameraService *m_service;
FakeCameraControl *m_cameraControl;
int m_lastRequestId;
QString m_pendingCaptureFile;
StorageManager m_storageManager;
bool m_ready;
QThread *m_saveThread;
SaveJpegWorker *m_saveWorker;
};
#endif
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameracontrol.h 0000644 0000152 0177776 00000002650 12305355477 026061 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 FAKECAMERACONTROL_H
#define FAKECAMERACONTROL_H
#include
class FakeCameraService;
class FakeCameraControl : public QCameraControl
{
Q_OBJECT
public:
FakeCameraControl(FakeCameraService *service, QObject *parent = 0);
~FakeCameraControl();
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;
private:
FakeCameraService *m_service;
QCamera::State m_state;
QCamera::Status m_status;
QCamera::CaptureModes m_captureMode;
};
#endif
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakevideorenderercontrol.cpp 0000644 0000152 0177776 00000004232 12305355477 030017 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 "fakevideorenderercontrol.h"
#include "fakecameraservice.h"
#include
#include
#include
#include
//const QLatin1String viewfinderImage = QLatin1String("/usr/share/fakeCamera/viewfinder_landscape.jpg");
FakeVideoRendererControl::FakeVideoRendererControl(FakeCameraService *service, QObject *parent)
: QVideoRendererControl(parent)
, m_surface(0),
m_service(service)
{
QObject::connect(&(m_service->fakeSensor()), SIGNAL(newViewfinderFrame()),
this, SLOT(updateViewfinderFrame()));
}
FakeVideoRendererControl::~FakeVideoRendererControl()
{
}
QAbstractVideoSurface *FakeVideoRendererControl::surface() const
{
return m_surface;
}
void FakeVideoRendererControl::setSurface(QAbstractVideoSurface *surface)
{
if (m_surface != surface) {
m_surface = surface;
Q_EMIT surfaceChanged(surface);
}
}
void FakeVideoRendererControl::stopViewfinder()
{
if (m_surface)
m_surface->stop();
}
void FakeVideoRendererControl::updateViewfinderFrame()
{
if (!m_surface)
return;
QVideoFrame frame(m_service->fakeSensor().viewfinderFrame());
if (!frame.isValid())
return;
if (!m_surface->isActive()) {
QVideoSurfaceFormat format(frame.size(), frame.pixelFormat());
if (!m_surface->start(format)) {
qWarning() << "Failed to start viewfinder with format:" << format;
}
}
if (m_surface->isActive()) {
m_surface->present(frame);
}
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakemediarecordercontrol.cpp 0000644 0000152 0177776 00000004553 12305355477 027775 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 "fakemediarecordercontrol.h"
#include "fakecameraservice.h"
#include
#include
FakeMediaRecorderControl::FakeMediaRecorderControl(FakeCameraService *service, QObject *parent)
: QMediaRecorderControl(parent),
m_service(service),
m_state(QMediaRecorder::StoppedState),
m_duration(0.0)
{
m_durationTimer.setInterval(1000);
QObject::connect(&m_durationTimer, SIGNAL(timeout()), this, SLOT(durationIncrease()));
}
void FakeMediaRecorderControl::applySettings()
{
}
qint64 FakeMediaRecorderControl::duration() const
{
return m_duration;
}
bool FakeMediaRecorderControl::isMuted() const
{
return false;
}
QUrl FakeMediaRecorderControl::outputLocation() const
{
return QUrl("/tmp/movie0001.mpg");
}
bool FakeMediaRecorderControl::setOutputLocation(const QUrl &location)
{
Q_UNUSED(location);
return true;
}
QMediaRecorder::State FakeMediaRecorderControl::state() const
{
return m_state;
}
QMediaRecorder::Status FakeMediaRecorderControl::status() const
{
return QMediaRecorder::LoadedStatus;
}
qreal FakeMediaRecorderControl::volume() const
{
return 1.0;
}
void FakeMediaRecorderControl::setMuted(bool muted)
{
Q_UNUSED(muted);
}
void FakeMediaRecorderControl::setState(QMediaRecorder::State state)
{
if (m_state == state)
return;
m_state = state;
Q_EMIT stateChanged(m_state);
if (m_state == QMediaRecorder::StoppedState) {
m_durationTimer.stop();
m_duration = 0.0;
Q_EMIT durationChanged(m_duration);
} else {
m_durationTimer.start();
}
}
void FakeMediaRecorderControl::setVolume(qreal gain)
{
Q_UNUSED(gain);
}
void FakeMediaRecorderControl::durationIncrease()
{
m_duration += 1000;
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecamerafocuscontrol.cpp 0000644 0000152 0177776 00000004327 12305355477 027457 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 "fakecamerafocuscontrol.h"
#include "fakecameraservice.h"
FakeCameraFocusControl::FakeCameraFocusControl(FakeCameraService *service, QObject *parent)
: QCameraFocusControl(parent),
m_service(service),
m_focusMode(QCameraFocus::AutoFocus),
m_pointMode(QCameraFocus::FocusPointCenter),
m_focusPoint(200,300)
{
}
QPointF FakeCameraFocusControl::customFocusPoint() const
{
return m_focusPoint;
}
QCameraFocus::FocusModes FakeCameraFocusControl::focusMode() const
{
return m_focusMode;
}
QCameraFocus::FocusPointMode FakeCameraFocusControl::focusPointMode() const
{
return m_pointMode;
}
QCameraFocusZoneList FakeCameraFocusControl::focusZones() const
{
return QCameraFocusZoneList();
}
bool FakeCameraFocusControl::isFocusModeSupported(QCameraFocus::FocusModes mode) const
{
Q_UNUSED(mode);
return true;
}
bool FakeCameraFocusControl::isFocusPointModeSupported(QCameraFocus::FocusPointMode mode) const
{
Q_UNUSED(mode);
return true;
}
void FakeCameraFocusControl::setCustomFocusPoint(const QPointF &point)
{
if (point == m_focusPoint)
return;
m_focusPoint = m_focusPoint;
Q_EMIT(customFocusPointChanged(m_focusPoint));
}
void FakeCameraFocusControl::setFocusMode(QCameraFocus::FocusModes mode)
{
if (mode == m_focusMode)
return;
m_focusMode = mode;
Q_EMIT(focusModeChanged(m_focusMode));
}
void FakeCameraFocusControl::setFocusPointMode(QCameraFocus::FocusPointMode mode)
{
if (mode == m_pointMode)
return;
m_pointMode = mode;
Q_EMIT(focusPointModeChanged(m_pointMode));
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakevideodeviceselectorcontrol.cpp 0000644 0000152 0177776 00000004545 12305355477 031220 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 "fakevideodeviceselectorcontrol.h"
#include "fakecameraflashcontrol.h"
#include "fakecameraservice.h"
#include "fakecamerazoomcontrol.h"
#include "fakevideorenderercontrol.h"
#include
FakeVideoDeviceSelectorControl::FakeVideoDeviceSelectorControl(FakeCameraService *service, QObject *parent)
: QVideoDeviceSelectorControl(parent),
m_service(service),
m_currentCamera(0)
{
}
int FakeVideoDeviceSelectorControl::defaultDevice() const
{
return 0;
}
int FakeVideoDeviceSelectorControl::deviceCount() const
{
return 2;
}
QString FakeVideoDeviceSelectorControl::deviceDescription(int index) const
{
switch (index) {
case 0: return QString("Back camera");
case 1: return QString("Front camera");
default: return QString();
}
}
QString FakeVideoDeviceSelectorControl::deviceName(int index) const
{
switch (index) {
case 0: return QString("Back");
case 1: return QString("Front");
default: return QString();
}
}
int FakeVideoDeviceSelectorControl::selectedDevice() const
{
return m_currentCamera;
}
void FakeVideoDeviceSelectorControl::setSelectedDevice(int index)
{
if (index >= 0 && index < deviceCount() && index != m_currentCamera) {
m_currentCamera = index;
Q_EMIT devicesChanged();
Q_EMIT selectedDeviceChanged(m_currentCamera);
Q_EMIT selectedDeviceChanged(deviceName(m_currentCamera));
m_service->fakeSensor().stopMove();
m_service->fakeSensor().setSelectedCamera(index);
m_service->zoomControl()->resetZoom();
m_service->flashControl()->setFlashMode(QCameraExposure::FlashOff);
m_service->videoOutputControl()->stopViewfinder();
m_service->fakeSensor().startMove();
}
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakeimagecapturecontrol.cpp 0000644 0000152 0177776 00000007025 12305355477 027633 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 "fakeimagecapturecontrol.h"
#include "fakecameracontrol.h"
#include "fakecameraservice.h"
#include "storagemanager.h"
#include
#include
#include
#include
#include
#include
#include
#include
void SaveJpegWorker::saveJpeg(QImage image, const QString &fileName)
{
QTemporaryFile tempFile;
tempFile.open();
image.save(&tempFile, "JPEG");
QFile file(tempFile.fileName());
tempFile.close();
file.rename(fileName);
Q_EMIT saveDone();
}
FakeImageCaptureControl::FakeImageCaptureControl(FakeCameraService *service, QObject *parent)
: QCameraImageCaptureControl(parent),
m_service(service),
m_cameraControl(service->cameraControl()),
m_lastRequestId(0),
m_pendingCaptureFile(),
m_ready(false)
{
QObject::connect(m_cameraControl, SIGNAL(stateChanged(QCamera::State)),
this, SLOT(updateReady()));
m_saveThread = new QThread(this);
m_saveWorker = new SaveJpegWorker;
m_saveWorker->moveToThread(m_saveThread);
m_saveThread->start();
QObject::connect(m_saveWorker, SIGNAL(saveDone()), this, SLOT(saveDone()));
}
FakeImageCaptureControl::~FakeImageCaptureControl()
{
m_saveThread->exit();
m_saveThread->wait();
}
bool FakeImageCaptureControl::isReadyForCapture() const
{
return m_ready;
}
int FakeImageCaptureControl::capture(const QString &fileName)
{
m_lastRequestId++;
QFileInfo fi(fileName);
if (fileName.isEmpty() || fi.isDir()) {
m_pendingCaptureFile = m_storageManager.nextPhotoFileName(fileName);
} else {
m_pendingCaptureFile = fileName;
}
m_storageManager.checkDirectory(m_pendingCaptureFile);
m_service->fakeSensor().stopMove();
QTimer::singleShot(100, this, SLOT(performPreview()));
QTimer::singleShot(500, this, SLOT(performCapture()));
Q_EMIT imageExposed(m_lastRequestId);
updateReady();
return m_lastRequestId;
}
void FakeImageCaptureControl::cancelCapture()
{
}
void FakeImageCaptureControl::updateReady()
{
bool ready = m_cameraControl->state() == QCamera::ActiveState && m_pendingCaptureFile.isEmpty();
if (m_ready != ready) {
m_ready = ready;
Q_EMIT readyForCaptureChanged(m_ready);
}
}
void FakeImageCaptureControl::performPreview()
{
QImage preview = m_service->fakeSensor().previewFrame();
m_service->fakeSensor().startMove();
Q_EMIT imageCaptured(m_lastRequestId, preview);
}
void FakeImageCaptureControl::performCapture()
{
QMetaObject::invokeMethod(m_saveWorker, "saveJpeg", Qt::QueuedConnection,
Q_ARG(QImage, m_service->fakeSensor().capturedImage()),
Q_ARG(QString, m_pendingCaptureFile));
}
void FakeImageCaptureControl::saveDone()
{
Q_EMIT imageSaved(m_lastRequestId, m_pendingCaptureFile);
m_pendingCaptureFile.clear();
updateReady();
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraservice.cpp 0000644 0000152 0177776 00000005727 12305355477 026404 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 "fakecameracontrol.h"
#include "fakecameraflashcontrol.h"
#include "fakecamerafocuscontrol.h"
#include "fakecameraservice.h"
#include "fakecamerazoomcontrol.h"
#include "fakeimagecapturecontrol.h"
#include "fakemediarecordercontrol.h"
#include "fakevideodeviceselectorcontrol.h"
#include "fakevideorenderercontrol.h"
#include "fakeviewfindersettingscontrol.h"
#include
FakeCameraService::FakeCameraService(QObject *parent):
QMediaService(parent),
m_videoOutput(0)
{
m_cameraControl = new FakeCameraControl(this);
m_flashControl = new FakeCameraFlashControl(this);
m_focusControl = new FakeCameraFocusControl(this);
m_zoomControl = new FakeCameraZoomControl(this);
m_imageCaptureControl = new FakeImageCaptureControl(this);
m_recorderControl = new FakeMediaRecorderControl(this);
m_deviceSelectControl = new FakeVideoDeviceSelectorControl(this);
m_videoOutput = new FakeVideoRendererControl(this);
m_viewfinderControl = new FakeViewfinderSettingsControl(this);
}
FakeCameraService::~FakeCameraService()
{
m_cameraControl->setState(QCamera::UnloadedState);
delete m_cameraControl;
delete m_flashControl;
delete m_focusControl;
delete m_zoomControl;
delete m_imageCaptureControl;
delete m_recorderControl;
delete m_deviceSelectControl;
delete m_videoOutput;
delete m_viewfinderControl;
}
QMediaControl *FakeCameraService::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, QCameraZoomControl_iid) == 0)
return m_zoomControl;
if (qstrcmp(name, QMediaRecorderControl_iid) == 0)
return m_recorderControl;
if (qstrcmp(name, QVideoDeviceSelectorControl_iid) == 0)
return m_deviceSelectControl;
if (qstrcmp(name, QVideoRendererControl_iid) == 0)
return m_videoOutput;
if (qstrcmp(name, QCameraViewfinderSettingsControl_iid) == 0)
return m_viewfinderControl;
return 0;
}
void FakeCameraService::releaseControl(QMediaControl *control)
{
Q_UNUSED(control);
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameracontrol.cpp 0000644 0000152 0177776 00000003713 12305355477 026415 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 "fakecameracontrol.h"
#include "fakecameraservice.h"
#include "fakevideorenderercontrol.h"
FakeCameraControl::FakeCameraControl(FakeCameraService *service, QObject *parent)
: QCameraControl(parent)
, m_service(service)
, m_state(QCamera::UnloadedState)
, m_status(QCamera::ActiveStatus)
, m_captureMode(QCamera::CaptureStillImage)
{
}
FakeCameraControl::~FakeCameraControl()
{
}
QCamera::State FakeCameraControl::state() const
{
return m_state;
}
void FakeCameraControl::setState(QCamera::State state)
{
if (m_state == state)
return;
m_state = state;
Q_EMIT stateChanged(m_state);
}
QCamera::Status FakeCameraControl::status() const
{
return m_status;
}
QCamera::CaptureModes FakeCameraControl::captureMode() const
{
return m_captureMode;
}
void FakeCameraControl::setCaptureMode(QCamera::CaptureModes mode)
{
if (m_captureMode == mode)
return;
m_captureMode = mode;
Q_EMIT captureModeChanged(mode);
}
bool FakeCameraControl::isCaptureModeSupported(QCamera::CaptureModes mode) const
{
return (QCamera::CaptureStillImage==mode) || (QCamera::CaptureVideo==mode);
}
bool FakeCameraControl::canChangeProperty(QCameraControl::PropertyChangeType changeType, QCamera::Status status) const
{
Q_UNUSED(changeType);
Q_UNUSED(status);
return true;
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakeviewfindersettingscontrol.cpp 0000644 0000152 0177776 00000005550 12305355477 031111 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 "fakeviewfindersettingscontrol.h"
#include "fakecameraservice.h"
#include "fakevideorenderercontrol.h"
#include
FakeViewfinderSettingsControl::FakeViewfinderSettingsControl(FakeCameraService *service, QObject *parent)
:QCameraViewfinderSettingsControl(parent),
m_service(service)
{
}
FakeViewfinderSettingsControl::~FakeViewfinderSettingsControl()
{
}
bool FakeViewfinderSettingsControl::isViewfinderParameterSupported(ViewfinderParameter parameter) const
{
if (parameter == QCameraViewfinderSettingsControl::Resolution ||
parameter == QCameraViewfinderSettingsControl::MinimumFrameRate ||
parameter == QCameraViewfinderSettingsControl::MaximumFrameRate ) {
return true;
}
return false;
}
void FakeViewfinderSettingsControl::setViewfinderParameter(ViewfinderParameter parameter, const QVariant &value)
{
if (!isViewfinderParameterSupported(parameter)) {
qWarning() << "Viewfinder dos not support parameter " << parameter;
return;
}
switch (parameter) {
case QCameraViewfinderSettingsControl::Resolution: {
QSize size = value.toSize();
QSize dataSize(size.height(), size.width());
m_service->fakeSensor().setViewfinderSize(dataSize);
break;
}
case QCameraViewfinderSettingsControl::MinimumFrameRate:
case QCameraViewfinderSettingsControl::MaximumFrameRate:
qWarning() << "Camera framerate boundaries are set by the backend";
break;
default:
break;
}
}
QVariant FakeViewfinderSettingsControl::viewfinderParameter(ViewfinderParameter parameter) const
{
if (!isViewfinderParameterSupported(parameter)) {
qWarning() << "Viewfinder dos not support parameter " << parameter;
return QVariant();
}
switch (parameter) {
case QCameraViewfinderSettingsControl::Resolution: {
QSize dataSize = m_service->fakeSensor().viewfinderSize();
QSize size(dataSize.height(), dataSize.width());
return QVariant(size);
}
case QCameraViewfinderSettingsControl::MinimumFrameRate:
return 15;
case QCameraViewfinderSettingsControl::MaximumFrameRate:
return 30;
default:
break;
}
return QVariant();
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraservice.h 0000644 0000152 0177776 00000005011 12305355477 026033 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 FAKECAMERASERVICE_H
#define FAKECAMERASERVICE_H
#include "fakedata.h"
#include
class QCameraControl;
class FakeCameraControl;
class FakeCameraFlashControl;
class FakeCameraFocusControl;
class FakeCameraZoomControl;
class FakeImageCaptureControl;
class FakeMediaRecorderControl;
class FakeVideoDeviceSelectorControl;
class FakeVideoRendererControl;
class FakeViewfinderSettingsControl;
class FakeCameraService : public QMediaService
{
Q_OBJECT
public:
FakeCameraService(QObject *parent = 0);
~FakeCameraService();
QMediaControl* requestControl(const char *name);
void releaseControl(QMediaControl *control);
FakeCameraControl *cameraControl() const { return m_cameraControl; }
FakeCameraFlashControl *flashControl() const { return m_flashControl; }
FakeCameraFocusControl *focusControl() const { return m_focusControl; }
FakeCameraZoomControl *zoomControl() const { return m_zoomControl; }
FakeImageCaptureControl *imageCaptureControl() const { return m_imageCaptureControl; }
FakeMediaRecorderControl *recorderControl() const { return m_recorderControl; }
FakeVideoDeviceSelectorControl *deviceSelector() const { return m_deviceSelectControl; }
FakeVideoRendererControl *videoOutputControl() const { return m_videoOutput; }
FakeViewfinderSettingsControl *viewfinderControl() const { return m_viewfinderControl; }
FakeData& fakeSensor() { return m_sensor; }
private:
FakeCameraControl *m_cameraControl;
FakeCameraFlashControl *m_flashControl;
FakeCameraFocusControl *m_focusControl;
FakeCameraZoomControl *m_zoomControl;
FakeImageCaptureControl *m_imageCaptureControl;
FakeMediaRecorderControl *m_recorderControl;
FakeVideoDeviceSelectorControl *m_deviceSelectControl;
FakeVideoRendererControl *m_videoOutput;
FakeViewfinderSettingsControl *m_viewfinderControl;
FakeData m_sensor;
};
#endif
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecamera.json 0000644 0000152 0177776 00000000055 12305355477 025177 0 ustar pbuser nogroup 0000000 0000000 {
"Keys": ["org.qt-project.qt.camera"]
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakemediarecordercontrol.h 0000644 0000152 0177776 00000003076 12305355477 027441 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 FAKEMEDIARECORDERCONTROL_H
#define FAKEMEDIARECORDERCONTROL_H
#include
#include
class FakeCameraService;
class QUrl;
class FakeMediaRecorderControl : public QMediaRecorderControl
{
Q_OBJECT
public:
FakeMediaRecorderControl(FakeCameraService *service, QObject *parent = 0);
void applySettings();
qint64 duration() const;
bool isMuted() const;
QUrl outputLocation() const;
bool setOutputLocation(const QUrl & location);
QMediaRecorder::State state() const;
QMediaRecorder::Status status() const;
qreal volume() const;
public Q_SLOTS:
void setMuted(bool muted);
void setState(QMediaRecorder::State state);
void setVolume(qreal gain);
private Q_SLOTS:
void durationIncrease();
private:
FakeCameraService *m_service;
QMediaRecorder::State m_state;
qreal m_duration;
QTimer m_durationTimer;
};
#endif // FAKEMEDIARECORDERCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecamerazoomcontrol.h 0000644 0000152 0177776 00000002474 12305355477 026772 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 FAKECAMERAZOOMCONTROL_H
#define FAKECAMERAZOOMCONTROL_H
#include
class FakeCameraService;
class FakeCameraZoomControl : public QCameraZoomControl
{
public:
FakeCameraZoomControl(FakeCameraService *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 resetZoom();
private:
FakeCameraService *m_service;
qreal m_zoom;
qreal m_maxZoom;
};
#endif // FAKECAMERAZOOMCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakevideorenderercontrol.h 0000644 0000152 0177776 00000002444 12305355477 027467 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 FAKEVIDEORENDERERCONTROL_H
#define FAKEVIDEORENDERERCONTROL_H
#include
class FakeCameraService;
class FakeVideoRendererControl : public QVideoRendererControl
{
Q_OBJECT
public:
FakeVideoRendererControl(FakeCameraService *service, QObject *parent = 0);
~FakeVideoRendererControl();
QAbstractVideoSurface *surface() const;
void setSurface(QAbstractVideoSurface *surface);
void stopViewfinder();
Q_SIGNALS:
void surfaceChanged(QAbstractVideoSurface *surface);
private Q_SLOTS:
void updateViewfinderFrame();
private:
QAbstractVideoSurface *m_surface;
FakeCameraService *m_service;
};
#endif
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakevideodeviceselectorcontrol.h 0000644 0000152 0177776 00000002454 12305355477 030662 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 FAKEVIDEODEVICESELECTORCONTROL_H
#define FAKEVIDEODEVICESELECTORCONTROL_H
#include
class FakeCameraService;
class FakeVideoDeviceSelectorControl : public QVideoDeviceSelectorControl
{
public:
FakeVideoDeviceSelectorControl(FakeCameraService *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:
FakeCameraService *m_service;
int m_currentCamera;
};
#endif // FAKEVIDEODEVICESELECTORCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/src.pro 0000644 0000152 0177776 00000002012 12305355477 023531 0 ustar pbuser nogroup 0000000 0000000 TARGET = fakecamera
TEMPLATE = lib
CONFIG += plugin
QT += multimedia
PLUGIN_TYPE = mediaservice
target.path = $$[QT_INSTALL_PLUGINS]/$${PLUGIN_TYPE}
INSTALLS += target
OTHER_FILES += fakecamera.json
HEADERS += \
fakecameracontrol.h \
fakecameraflashcontrol.h \
fakecamerafocuscontrol.h \
fakecameraservice.h \
fakecameraserviceplugin.h \
fakecamerazoomcontrol.h \
fakedata.h \
fakeimagecapturecontrol.h \
fakemediarecordercontrol.h \
fakevideodeviceselectorcontrol.h \
fakevideorenderercontrol.h \
fakeviewfindersettingscontrol.h \
storagemanager.h
SOURCES += \
fakecameracontrol.cpp \
fakecameraflashcontrol.cpp \
fakecamerafocuscontrol.cpp \
fakecameraservice.cpp \
fakecameraserviceplugin.cpp \
fakecamerazoomcontrol.cpp \
fakedata.cpp \
fakeimagecapturecontrol.cpp \
fakemediarecordercontrol.cpp \
fakevideodeviceselectorcontrol.cpp \
fakevideorenderercontrol.cpp \
fakeviewfindersettingscontrol.cpp \
storagemanager.cpp
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecamerafocuscontrol.h 0000644 0000152 0177776 00000003127 12305355477 027121 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 FAKECAMERAFOCUSCONTROL_H
#define FAKECAMERAFOCUSCONTROL_H
#include
class FakeCameraService;
class FakeCameraFocusControl : public QCameraFocusControl
{
public:
FakeCameraFocusControl(FakeCameraService *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);
private:
FakeCameraService *m_service;
QCameraFocus::FocusModes m_focusMode;
QCameraFocus::FocusPointMode m_pointMode;
QPointF m_focusPoint;
};
#endif // FAKECAMERAFOCUSCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakeviewfindersettingscontrol.h 0000644 0000152 0177776 00000002476 12305355477 030562 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 FAKEVIEWFINDERSETTINGSCONTROL_H
#define FAKEVIEWFINDERSETTINGSCONTROL_H
#include
class FakeCameraService;
class FakeViewfinderSettingsControl : public QCameraViewfinderSettingsControl
{
public:
FakeViewfinderSettingsControl(FakeCameraService *service, QObject *parent = 0);
~FakeViewfinderSettingsControl();
bool isViewfinderParameterSupported(ViewfinderParameter parameter) const ;
void setViewfinderParameter(ViewfinderParameter parameter, const QVariant & value);
QVariant viewfinderParameter(ViewfinderParameter parameter) const;
private:
FakeCameraService *m_service;
};
#endif // AALVIEWFINDERSETTINGSCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraflashcontrol.h 0000644 0000152 0177776 00000002350 12305355477 027074 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 FAKECAMERAFLASHCONTROL_H
#define FAKECAMERAFLASHCONTROL_H
#include
class FakeCameraService;
class FakeCameraFlashControl : public QCameraFlashControl
{
public:
FakeCameraFlashControl(FakeCameraService *service, QObject *parent = 0);
QCameraExposure::FlashModes flashMode() const;
bool isFlashModeSupported(QCameraExposure::FlashModes mode) const;
bool isFlashReady() const;
void setFlashMode(QCameraExposure::FlashModes mode);
private:
FakeCameraService *m_service;
QCameraExposure::FlashModes m_mode;
};
#endif // FAKECAMERAFLASHCONTROL_H
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraflashcontrol.cpp 0000644 0000152 0177776 00000003427 12305355477 027435 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 "fakecameraflashcontrol.h"
#include "fakecameraservice.h"
#include "fakevideodeviceselectorcontrol.h"
FakeCameraFlashControl::FakeCameraFlashControl(FakeCameraService *service, QObject *parent)
: QCameraFlashControl(parent),
m_service(service),
m_mode(QCameraExposure::FlashAuto)
{
}
QCameraExposure::FlashModes FakeCameraFlashControl::flashMode() const
{
return m_mode;
}
bool FakeCameraFlashControl::isFlashModeSupported(QCameraExposure::FlashModes mode) const
{
if (m_service->deviceSelector()->selectedDevice() == 0) {
return (mode == QCameraExposure::FlashAuto ||
mode == QCameraExposure::FlashOff ||
mode == QCameraExposure::FlashOn ||
mode == QCameraExposure::FlashVideoLight);
} else {
return mode == QCameraExposure::FlashOff;
}
}
bool FakeCameraFlashControl::isFlashReady() const
{
if (m_service->deviceSelector()->selectedDevice() == 0)
return true;
else
return false;
}
void FakeCameraFlashControl::setFlashMode(QCameraExposure::FlashModes mode)
{
if (isFlashModeSupported(mode)) {
m_mode = mode;
}
}
qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/src/fakecameraserviceplugin.h 0000644 0000152 0177776 00000002474 12305355477 027264 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 FAKESERVICEPLUGIN_H
#define FAKESERVICEPLUGIN_H
#include
class FakeServicePlugin : public QMediaServiceProviderPlugin,
public QMediaServiceSupportedDevicesInterface
{
Q_OBJECT
Q_INTERFACES(QMediaServiceSupportedDevicesInterface)
Q_PLUGIN_METADATA(IID "org.qt-project.qt.mediaserviceproviderfactory/5.0" FILE "fakecamera.json")
public:
FakeServicePlugin();
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-cameraplugin-fake-0.1.10+14.04.20140304/data/ 0000755 0000152 0177776 00000000000 12305355706 022342 5 ustar pbuser nogroup 0000000 0000000 qtubuntu-cameraplugin-fake-0.1.10+14.04.20140304/data/image_front.jpg 0000644 0000152 0177776 00000501667 12305355477 025362 0 ustar pbuser nogroup 0000000 0000000 JFIF H H C
' .)10.)-,3:J>36F7,-@WAFLNRSR2>ZaZP`JQRO C&&O5-5OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO