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 bool night = d_ptr->inNightMode();
48 int fps = night ? d->settings.nightFrameRate() : d->settings.frameRate();
50 d_ptr->setCaps("viewfinder-caps", d->settings.viewfinderResolution(), fps);
53 // Ideally, we should query the image-capture-supported-caps and get a proper framerate
54 // as it seems that subdevsrc2 can only capture 15 FPS for at least the highest resolution
55 // we use. For now we will not set any FPS.
56 d_ptr->setCaps("image-capture-caps", d->settings.captureResolution(), -1);
58 setPreviewSize(d->settings.previewResolution());
61 // d_ptr->resetCaps("video-capture-caps");
64 void QtCamImageMode::start() {
68 void QtCamImageMode::stop() {
72 bool QtCamImageMode::capture(const QString& fileName) {
77 if (fileName.isEmpty()) {
81 setFileName(fileName);
83 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
84 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
89 bool QtCamImageMode::setSettings(const QtCamImageSettings& settings) {
90 d->settings = settings;
92 if (!d_ptr->dev->q_ptr->isRunning() || !d_ptr->dev->q_ptr->isIdle()) {
101 void QtCamImageMode::setProfile(GstEncodingProfile *profile) {
102 if (!d_ptr->dev->cameraBin) {
103 gst_encoding_profile_unref(profile);
107 g_object_set(d_ptr->dev->cameraBin, "image-profile", profile, NULL);