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 void _d_idleStateChanged(bool isIdle) {
19 if (isIdle && dev->active == dev->video) {
20 QMetaObject::invokeMethod(dev->video, "recordingStateChanged");
21 QMetaObject::invokeMethod(dev->video, "canCaptureChanged");
25 QtCamVideoSettings settings;
28 QtCamVideoMode::QtCamVideoMode(QtCamDevicePrivate *dev, QObject *parent) :
29 QtCamMode(new QtCamVideoModePrivate(dev), "mode-video", "video-done", parent) {
31 d = (QtCamVideoModePrivate *)QtCamMode::d_ptr;
33 QString name = d_ptr->dev->conf->videoEncodingProfileName();
34 QString path = d_ptr->dev->conf->videoEncodingProfilePath();
36 if (!name.isEmpty() && !path.isEmpty()) {
37 GstEncodingProfile *profile = d_ptr->loadProfile(path, name);
43 QObject::connect(d_ptr->dev->q_ptr, SIGNAL(idleStateChanged(bool)),
44 this, SLOT(_d_idleStateChanged(bool)));
47 QtCamVideoMode::~QtCamVideoMode() {
51 bool QtCamVideoMode::canCapture() {
52 return d_ptr->dev->q_ptr->isIdle();
55 void QtCamVideoMode::applySettings() {
56 bool night = d_ptr->inNightMode();
58 int fps = night ? d->settings.nightFrameRate() : d->settings.frameRate();
60 d_ptr->setCaps("viewfinder-caps", d->settings.captureResolution(), fps);
62 d_ptr->setCaps("video-capture-caps", d->settings.captureResolution(), fps);
64 setPreviewSize(d->settings.previewResolution());
67 // d_ptr->resetCaps("image-capture-caps");
70 void QtCamVideoMode::start() {
74 void QtCamVideoMode::stop() {
80 bool QtCamVideoMode::isRecording() {
81 return !d_ptr->dev->q_ptr->isIdle();
84 bool QtCamVideoMode::startRecording(const QString& fileName) {
85 if (!canCapture() || isRecording()) {
89 setFileName(fileName);
91 g_object_set(d_ptr->dev->cameraBin, "location", fileName.toUtf8().data(), NULL);
92 g_signal_emit_by_name(d_ptr->dev->cameraBin, "start-capture", NULL);
94 emit recordingStateChanged();
96 emit canCaptureChanged();
101 void QtCamVideoMode::stopRecording() {
103 g_signal_emit_by_name(d_ptr->dev->cameraBin, "stop-capture", NULL);
107 bool QtCamVideoMode::setSettings(const QtCamVideoSettings& settings) {
108 d->settings = settings;
119 void QtCamVideoMode::setProfile(GstEncodingProfile *profile) {
120 if (!d_ptr->dev->cameraBin) {
121 gst_encoding_profile_unref(profile);
125 g_object_set(d_ptr->dev->cameraBin, "video-profile", profile, NULL);
128 #include "moc_qtcamvideomode.cpp"