Hi Mohammed
I have been trying to implement your suggestion, but am still having
problems ...
The Nokia code quoted in my original post did not have an explicit
sink (and on the N9 worked without one). But following the tutorial in
the link below I have added one to the my code.
http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+2%3A+GStreamer+concepts
The code compiles and runs, but the LED does not respond. On startup I
get errors like:
"
(GSTTorch:14916): GLib-GObject-CRITICAL **: Object class
GstDroidCamSrc doesn't implement property 'scene-mode' from interface
'GstPhotography'
(GSTTorch:14916): GLib-GObject-CRITICAL **: Object class
GstDroidCamSrc doesn't implement property 'noise-reduction' from
interface 'GstPhotography'
...more of the same ...
"
I confess that I have not yet fully understood the Gstreamer
architecture, so my code is very much "best guess" attempt.
thanks for your help,
Chris
//start gsttorch.h
#ifndef GSTTORCH_H
#define GSTTORCH_H
#include <QObject>
#include <gst/gstelement.h>
class GstTorch : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(bool status READ status WRITE setStatus NOTIFY statusChanged)
explicit GstTorch(QObject *parent = 0);
void start();
void stop();
Q_INVOKABLE void toggle();
bool status();
void setStatus(bool on);
signals:
void statusChanged(bool on);
private:
GstElement *pipeline;
GstElement *src;
GstElement *sink;
bool mStatus; // true = on
};
#endif // GSTTORCH_H
//end gsttorch.h
//start gsttorch.cpp
//thanks to:
//http://developer.nokia.com/Community/Wiki/How_to_turn_your_camera_flash_into_a_torch_on_Harmattan_using_GStreamer
//
http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+2%3A+GStreamer+concepts
#include "gsttorch.h"
#include <gst/gst.h>
#include <QDebug>
GstTorch::GstTorch(QObject *parent) :
QObject(parent), pipeline(0), src(0), sink(0), mStatus(false)
{
//gst-launch-0.10 droidcamsrc video-torch=1 viewfinder-mode=1 ! fakesink
gst_init(NULL, NULL);
src = gst_element_factory_make("droidcamsrc", "src");
sink = gst_element_factory_make("droideglsink", "sink");
pipeline = gst_pipeline_new ("test-pipeline");
if (!src || !sink || !pipeline) {
return;
}
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
if (gst_element_link (src, sink) != TRUE) {
qDebug() << "Elements could not be linked!";
gst_object_unref (pipeline);
return;
}
g_object_set(G_OBJECT(src), "video-torch", 1, NULL);
g_object_set(G_OBJECT(src), "mode", 1, NULL);
gst_element_set_state(pipeline, GST_STATE_NULL);
}
void GstTorch::start(){
qDebug() << "START";
gst_element_set_state(pipeline, GST_STATE_PLAYING);
}
void GstTorch::stop(){
qDebug() << "STOP";
gst_element_set_state(pipeline, GST_STATE_NULL);
}
void GstTorch::toggle(){
qDebug() << "TOGGLE";
setStatus(!mStatus);
}
bool GstTorch::status(){
qDebug() << "STATUS";
return mStatus;
}
void GstTorch::setStatus(bool on){
qDebug() << "SET STATUS" << on;
if (on){
emit statusChanged(true);
start();
} else {
emit statusChanged(false);
stop();
}
mStatus = on;
}
//end gsttorch.cpp
Zitat von "Mohammed Hassan" <mohammed.has...@jollamobile.com>:
On Wed, Jan 22, 2014 at 08:29:19PM +0100, christopher.l...@thurweb.ch wrote:
[...]
Solution 3)
Via a Gstreamer QML Plugin.
I dug out some old code that worked on Harmattan, basically the code
from this link to create a qml plugin
http://developer.nokia.com/Community/Wiki/How_to_turn_your_camera_flash_into_a_torch_on_Harmattan_using_GStreamer
On Sailfish this compiles, but gives the following error when I
start the torch.
(GSTTorch:708): GStreamer-CRITICAL **: gst_element_set_state:
assertion `GST_IS_ELEMENT (element)' failed
This is not the recommended way but it's the only way to get flash
light to work but I have to
warn you that it wil prevent your app from entering harbour. You
will also have to make use
of resource policy engine to arbitrate access to camera. Failing to
do so will lead to breaking
jolla camera app.
Simply replace subdevsrc with droidcamsrc and use droideglsink as
the sink and
it should work fine.
Cheers,
_______________________________________________
SailfishOS.org Devel mailing list
_______________________________________________
SailfishOS.org Devel mailing list