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 bool wrapperIsReady() {
19 if (!dev->wrapperVideoSource) {
23 gboolean ready = FALSE;
24 g_object_get(dev->wrapperVideoSource, "ready-for-capture", &ready, NULL);
29 QtCamImageSettings settings;
32 QtCamImageMode::QtCamImageMode(QtCamDevicePrivate *d, QObject *parent) :
33 QtCamMode(new QtCamImageModePrivate(d), "mode-image", "image-done", parent) {
35 d_ptr = (QtCamImageModePrivate *)QtCamMode::d_ptr;
37 QString name = d_ptr->dev->conf->imageEncodingProfileName();
38 QString path = d_ptr->dev->conf->imageEncodingProfilePath();
40 if (!name.isEmpty() && !path.isEmpty()) {
41 GstEncodingProfile *profile = d_ptr->loadProfile(path, name);
48 QtCamImageMode::~QtCamImageMode() {
52 bool QtCamImageMode::canCapture() {
53 return QtCamMode::canCapture() && d_ptr->wrapperIsReady();
56 void QtCamImageMode::applySettings() {
57 setCaps("image-capture-caps", d_ptr->settings.captureResolution(),
58 d_ptr->settings.frameRate());
59 setCaps("viewfinder-caps", d_ptr->settings.viewfinderResolution(),
60 d_ptr->settings.frameRate());
61 setPreviewSize(d_ptr->settings.previewResolution());
64 void QtCamImageMode::start() {
68 void QtCamImageMode::stop() {
72 bool QtCamImageMode::capture(const QString& fileName) {
77 setFileName(fileName);
79 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
80 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
85 bool QtCamImageMode::setSettings(const QtCamImageSettings& settings) {
86 d_ptr->settings = settings;
88 if (!d_ptr->dev->q_ptr->isIdle()) {
97 void QtCamImageMode::setProfile(GstEncodingProfile *profile) {
98 if (!d_ptr->dev->cameraBin) {
99 gst_encoding_profile_unref(profile);
103 g_object_set(d_ptr->dev->cameraBin, "image-profile", profile, NULL);