1 #include "qtcamvideomode.h"
2 #include "qtcammode_p.h"
4 #include "qtcamdevice_p.h"
5 #include "qtcamdevice.h"
6 #include "qtcamvideosettings.h"
8 class QtCamVideoModePrivate : public QtCamModePrivate {
10 QtCamVideoModePrivate(QtCamDevicePrivate *dev) :
11 QtCamModePrivate(dev),
12 settings(dev->conf->defaultVideoSettings()) {
16 ~QtCamVideoModePrivate() {}
18 QtCamVideoSettings settings;
21 QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *d, QObject *parent) :
22 QtCamMode(new QtCamVideoModePrivate(d), "mode-video", "video-done", parent) {
24 d_ptr = (QtCamVideoModePrivate *)QtCamMode::d_ptr;
26 QString name = d_ptr->dev->conf->videoEncodingProfileName();
27 QString path = d_ptr->dev->conf->videoEncodingProfilePath();
29 if (!name.isEmpty() && !path.isEmpty()) {
30 GstEncodingProfile *profile = d_ptr->loadProfile(path, name);
37 QtCamVideoMode::~QtCamVideoMode() {
41 bool QtCamVideoMode::canCapture() {
42 return d_ptr->dev->q_ptr->isIdle();
45 void QtCamVideoMode::applySettings() {
46 setCaps("viewfinder-caps", d_ptr->settings.captureResolution(),
47 d_ptr->settings.frameRate());
49 setCaps("video-capture-caps", d_ptr->settings.captureResolution(),
50 d_ptr->settings.frameRate());
52 setPreviewSize(d_ptr->settings.previewResolution());
55 void QtCamVideoMode::start() {
59 void QtCamVideoMode::stop() {
65 bool QtCamVideoMode::isRecording() {
66 return !d_ptr->dev->q_ptr->isIdle();
69 bool QtCamVideoMode::startRecording(const QString& fileName) {
70 if (!canCapture() || isRecording()) {
74 setFileName(fileName);
76 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
77 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
82 bool QtCamVideoMode::stopRecording() {
84 g_signal_emit_by_name(d_ptr->dev->cameraBin, "stop-capture", NULL);
90 bool QtCamVideoMode::setSettings(const QtCamVideoSettings& settings) {
91 d_ptr->settings = settings;
103 void QtCamVideoMode::setProfile(GstEncodingProfile *profile) {
104 if (!d_ptr->dev->cameraBin) {
105 gst_encoding_profile_unref(profile);
109 g_object_set(d_ptr->dev->cameraBin, "video-profile", profile, NULL);