3 #ifndef QT_CAM_MODE_P_H
4 #define QT_CAM_MODE_P_H
7 #include "qtcamdevice_p.h"
8 #include <gst/pbutils/encoding-profile.h>
9 #include <gst/pbutils/encoding-target.h>
11 #ifndef GST_USE_UNSTABLE_API
12 #define GST_USE_UNSTABLE_API
13 #endif /* GST_USE_UNSTABLE_API */
14 #include <gst/interfaces/photography.h>
16 class QtCamDevicePrivate;
17 class PreviewImageHandler;
20 class QtCamModePrivate {
22 QtCamModePrivate(QtCamDevicePrivate *d) : id(-1), dev(d) {}
23 virtual ~QtCamModePrivate() {}
25 int modeId(const char *mode) {
26 if (!dev->cameraBin) {
30 GParamSpec *pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(dev->cameraBin),
36 if (!G_IS_PARAM_SPEC_ENUM(pspec)) {
40 GParamSpecEnum *e = (GParamSpecEnum *)pspec;
41 GEnumClass *klass = e->enum_class;
43 for (unsigned x = 0; x < klass->n_values; x++) {
44 if (QLatin1String(mode) == QLatin1String(klass->values[x].value_nick)) {
45 return klass->values[x].value;
52 GstEncodingProfile *loadProfile(const QString& path, const QString& name) {
55 GstEncodingTarget *target = gst_encoding_target_load_from_file(path.toUtf8().data(), &error);
57 qCritical() << "Failed to load encoding target from" << path << error->message;
62 GstEncodingProfile *profile = gst_encoding_target_get_profile(target, name.toUtf8().data());
64 qCritical() << "Failed to load encoding profile from" << path;
65 gst_encoding_target_unref(target);
69 gst_encoding_target_unref(target);
74 void resetCaps(const char *property) {
75 if (!dev->cameraBin) {
79 g_object_set(dev->cameraBin, property, NULL, NULL);
83 if (!dev->cameraBin) {
89 g_object_get(dev->videoSource, "scene-mode", &val, NULL);
91 return val == GST_PHOTOGRAPHY_SCENE_MODE_NIGHT;
94 void setCaps(const char *property, const QSize& resolution, int fps) {
95 if (!dev->cameraBin) {
99 if (resolution.width() <= 0 || resolution.height() <= 0) {
106 caps = gst_caps_new_simple("video/x-raw-yuv",
107 "width", G_TYPE_INT, resolution.width(),
108 "height", G_TYPE_INT, resolution.height(),
112 caps = gst_caps_new_simple("video/x-raw-yuv",
113 "width", G_TYPE_INT, resolution.width(),
114 "height", G_TYPE_INT, resolution.height(),
116 GST_TYPE_FRACTION_RANGE, fps - 1, 1, fps + 1, 1,
122 g_object_get(dev->cameraBin, property, &old, NULL);
124 if (gst_caps_is_equal(caps, old)) {
126 gst_caps_unref(caps);
131 qDebug() << "Setting caps" << property << gst_caps_to_string(caps);
133 g_object_set(dev->cameraBin, property, caps, NULL);
141 QtCamDevicePrivate *dev;
142 PreviewImageHandler *previewImageHandler;
143 DoneHandler *doneHandler;
146 #endif /* QT_CAM_MODE_P_H */