X-Git-Url: http://cgit.sxemacs.org/?a=blobdiff_plain;f=lib%2Fqtcamdevice.cpp;h=38da29ba4eb7ab18d3cf7b247b2249dc2d10ef12;hb=bbaadb8139399ca7d6088bf8ff69fa487eae57bd;hp=20c3d787338f26f113d6a5ab3abcca017fc2d5fb;hpb=51950c94179c2a53e131ff1f787001452c19c2df;p=harmattan%2Fcameraplus diff --git a/lib/qtcamdevice.cpp b/lib/qtcamdevice.cpp index 20c3d78..38da29b 100644 --- a/lib/qtcamdevice.cpp +++ b/lib/qtcamdevice.cpp @@ -1,7 +1,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -65,6 +65,8 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name, d_ptr->createAndAddVideoSource(); } + d_ptr->setDevicePoperty(); + int flags = 0x00000001 /* no-audio-conversion - Do not use audio conversion elements */ | 0x00000002 /* no-video-conversion - Do not use video conversion elements */ @@ -83,10 +85,11 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name, if (!d_ptr->viewfinderFilters) { qWarning() << "Failed to create viewfinder filters"; } + else { + g_object_set(d_ptr->cameraBin, "viewfinder-filter", d_ptr->viewfinderFilters->bin(), NULL); + } } - g_object_set(d_ptr->cameraBin, "viewfinder-filter", d_ptr->viewfinderFilters->bin(), NULL); - d_ptr->listener = new QtCamGStreamerMessageListener(gst_element_get_bus(d_ptr->cameraBin), d_ptr, this); @@ -99,8 +102,14 @@ QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name, g_signal_connect(d_ptr->cameraBin, "notify::idle", G_CALLBACK(QtCamDevicePrivate::on_idle_changed), d_ptr); - g_signal_connect(d_ptr->wrapperVideoSource, "notify::ready-for-capture", - G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr); + if (d_ptr->wrapperVideoSource) { + g_signal_connect(d_ptr->wrapperVideoSource, "notify::ready-for-capture", + G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr); + } + else { + g_signal_connect(d_ptr->videoSource, "notify::ready-for-capture", + G_CALLBACK(QtCamDevicePrivate::on_ready_for_capture_changed), d_ptr); + } d_ptr->image = new QtCamImageMode(d_ptr, this); d_ptr->video = new QtCamVideoMode(d_ptr, this); @@ -139,20 +148,18 @@ bool QtCamDevice::setViewfinder(QtCamViewfinder *viewfinder) { } if (!viewfinder) { - qWarning() << "QtCamDevice: viewfinder cannot be unset."; - return false; - } + if (d_ptr->cameraBin) { + g_object_set(d_ptr->cameraBin, "viewfinder-sink", NULL, NULL); + } - if (d_ptr->viewfinder) { - qWarning() << "QtCamDevice: viewfinder cannot be replaced."; - return false; - } + d_ptr->sink = 0; - if (!viewfinder->setDevice(this)) { - return false; + d_ptr->viewfinder = 0; + return true; } d_ptr->viewfinder = viewfinder; + d_ptr->sink = 0; return true; }