#include "qtcamvideomode.h"
#include "qtcamnotifications.h"
-// TODO: we want the ability to change the image and video gep from the app.
-
QtCamDevice::QtCamDevice(QtCamConfig *config, const QString& name,
const QVariant& id, QObject *parent) :
QObject(parent), d_ptr(new QtCamDevicePrivate) {
// TODO: audio bitrate
// TODO: video bitrate
// TODO: filters
- // TODO: capabilities
// TODO: custom properties for jifmux, mp4mux, audio encoder, video encoder, sink & video source
d_ptr->listener = new QtCamGStreamerMessageListener(gst_element_get_bus(d_ptr->cameraBin),
d_ptr, this);
}
QtCamDevice::~QtCamDevice() {
- stop();
+ stop(true);
d_ptr->image->deactivate();
d_ptr->video->deactivate();
return true;
}
+QtCamViewfinder *QtCamDevice::viewfinder() const {
+ return d_ptr->viewfinder;
+}
+
bool QtCamDevice::start() {
if (d_ptr->error) {
qWarning() << "Pipeline must be stopped first because of an error.";
return true;
}
-bool QtCamDevice::stop() {
+bool QtCamDevice::stop(bool force) {
if (!d_ptr->cameraBin) {
return true;
}
if (d_ptr->error) {
gst_element_set_state(d_ptr->cameraBin, GST_STATE_NULL);
d_ptr->error = false;
+
+ d_ptr->viewfinder->stop();
+
return true;
}
}
if (!isIdle()) {
- return false;
+ if (!force) {
+ return false;
+ }
}
- d_ptr->viewfinder->stop();
-
// First we go to ready:
GstStateChangeReturn st = gst_element_set_state(d_ptr->cameraBin, GST_STATE_READY);
if (st != GST_STATE_CHANGE_FAILURE) {
// Now to NULL
gst_element_set_state(d_ptr->cameraBin, GST_STATE_NULL);
+ d_ptr->viewfinder->stop();
+
return true;
}