1 #include "qtcamimagemode.h"
2 #include "qtcammode_p.h"
3 #include "qtcamdevice_p.h"
4 #include "qtcamimagesettings.h"
5 #include "qtcamdevice.h"
7 class QtCamImageModePrivate : public QtCamModePrivate {
9 QtCamImageModePrivate(QtCamDevicePrivate *dev) :
10 QtCamModePrivate(dev),
11 settings(dev->conf->defaultImageSettings()) {
15 ~QtCamImageModePrivate() {
18 QtCamImageSettings settings;
21 QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *dev, QObject *parent) :
22 QtCamMode(new QtCamImageModePrivate(dev), "mode-image", "image-done", parent) {
24 d = (QtCamImageModePrivate *)d_ptr;
26 QString name = d_ptr->dev->conf->imageEncodingProfileName();
27 QString path = d_ptr->dev->conf->imageEncodingProfilePath();
29 if (!name.isEmpty() && !path.isEmpty()) {
30 GstEncodingProfile *profile = d_ptr->loadProfile(path, name);
37 QtCamImageMode::~QtCamImageMode() {
41 bool QtCamImageMode::canCapture() {
42 return QtCamMode::canCapture() && d_ptr->dev->isWrapperReady();
45 void QtCamImageMode::applySettings() {
46 QPair<int, int> fps = d_ptr->night ? d->settings.nightFrameRate() : d->settings.frameRate();
48 d_ptr->setCaps("image-capture-caps", d->settings.captureResolution(),
49 d->settings.frameRate());
51 d_ptr->setCaps("viewfinder-caps", d->settings.viewfinderResolution(), fps);
53 setPreviewSize(d->settings.previewResolution());
56 void QtCamImageMode::start() {
60 void QtCamImageMode::stop() {
64 bool QtCamImageMode::capture(const QString& fileName) {
69 setFileName(fileName);
71 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
72 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
77 bool QtCamImageMode::setSettings(const QtCamImageSettings& settings) {
78 d->settings = settings;
80 if (!d_ptr->dev->q_ptr->isIdle()) {
89 void QtCamImageMode::setProfile(GstEncodingProfile *profile) {
90 if (!d_ptr->dev->cameraBin) {
91 gst_encoding_profile_unref(profile);
95 g_object_set(d_ptr->dev->cameraBin, "image-profile", profile, NULL);