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 *d, QObject *parent) :
22 QtCamMode(new QtCamImageModePrivate(d), "mode-image", "image-done", parent) {
24 d_ptr = (QtCamImageModePrivate *)QtCamMode::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 setCaps("image-capture-caps", d_ptr->settings.captureResolution(),
47 d_ptr->settings.frameRate());
48 setCaps("viewfinder-caps", d_ptr->settings.viewfinderResolution(),
49 d_ptr->settings.frameRate());
50 setPreviewSize(d_ptr->settings.previewResolution());
53 void QtCamImageMode::start() {
57 void QtCamImageMode::stop() {
61 bool QtCamImageMode::capture(const QString& fileName) {
66 setFileName(fileName);
68 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
69 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
74 bool QtCamImageMode::setSettings(const QtCamImageSettings& settings) {
75 d_ptr->settings = settings;
77 if (!d_ptr->dev->q_ptr->isIdle()) {
86 void QtCamImageMode::setProfile(GstEncodingProfile *profile) {
87 if (!d_ptr->dev->cameraBin) {
88 gst_encoding_profile_unref(profile);
92 g_object_set(d_ptr->dev->cameraBin, "image-profile", profile, NULL);