Re: [SailfishDevel] LED Flash functionality on a real Jolla
Cool to see that happening, guys! Will help me to move Flashlight app to proper gstreamer too if it is ever allowed in harbour or if I (or anybody else) manages to bundle it with the app. Should be possible. Cheers, Artem. On Sat, Jan 25, 2014 at 6:50 PM, wrote: > Mohammed et al > > I have just posted the code of my demo Flashlight app to Github > > https://github.com/sailfishapps/ThrowawayDemos/ > tree/master/Working/GSTTorch2 > > This uses Gstreamer, and in its current form is far from Harbour > compliancy. > > It exposes a torch to QML using the Jolla LED flash that can be turned on > and off, and changed from Beam mode to Flash mode. > > So far the main focus is on the "back-end" c++ part, as I require this > functionality as part of my main app. > > As and when time permits I will enrich this demo including: > > > * use of resource policy engine to arbitrate access to camera > * expose flash rate to QML as property so it can be changed from GUI (e.g. > with a slider control). > > Have fun > > Chris > > > > Zitat von "Mohammed Hassan" : > > I am glad it worked for you :-) >> >> Perhaps I should start working on an open flash light app. >> Would anyone like to contribute to such app? I have already 2 apps to >> maintain >> and I can't easily fit a 3rd. >> >> Cheers, >> >> On Fri, Jan 24, 2014 at 09:43:54PM +0100, christopher.lamb@thurweb.chwrote: >> >>> Hi Mohammed >>> >>> That's it! >>> >>> It's strange how things go. Yesterday was one of those days: At work >>> I spent hours fighting with a recalcitrant Confluence installation >>> that refused to start properly, and the evening I could not get the >>> GST code working properly. >>> >>> Today was very different. I discovered that that the mysql database >>> under the Confluence was corrupt. Once i found that, it more or less >>> fixed itself. Then this evening I see from your mail that my GST >>> code only needs one character changed to work! >>> >>> Zitat von "Mohammed Hassan" : >>> > >>> >g_object_set (G_OBJECT(src), "mode", 2, NULL); >>> > >>> >That should do it for you. Works fine here after changing mode to 2 >>> >instead of 1 >>> >>> It really does work, both in developer mode from Qt Creator, and >>> once installed from the Jolla itself. Thank you! I will integrate >>> this functionality into my core app this weekend. >>> >>> >>> Zitat von "Mohammed Hassan" : >>> > >>> >Those errors are harmless. Just ignore them. They decrease with each >>> >update as we implement more camera features ;) >>> > >>> >>> Looking forward to the update(s)! 8) >>> >>> chris >>> >>> >>> >> > > > ___ > SailfishOS.org Devel mailing list > -- Artem Marchenko http://agilesoftwaredevelopment.com http://twitter.com/AgileArtem ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla: using policy engine
Hi Mohmammed following your suggestion earlier in this thread: "You will also have to make use of resource policy engine to arbitrate access to camera." I have updated this demo: https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/GSTTorch2 to do so using nemo-qml-plugin-policy. As far as I can tell from testing with my torch app and the camera app, it works. I chose this approach because it seemed the easiest and best-documented (basically the readme at https://github.com/nemomobile/nemo-qml-plugin-policy was enough). I considered writing C++ code to directly access libresourceqt, but baulked at the code I would have to write just to get permission for the LED. My question is: is using nemo-qml-plugin-policy to get resource permissions a valid method for Sailfish apps? Or is there an even better way? I have found no documentation on the topic of Sailfish and resource policy engine, other than source code ... Thanks Chris ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
Mohammed et al I have just posted the code of my demo Flashlight app to Github https://github.com/sailfishapps/ThrowawayDemos/tree/master/Working/GSTTorch2 This uses Gstreamer, and in its current form is far from Harbour compliancy. It exposes a torch to QML using the Jolla LED flash that can be turned on and off, and changed from Beam mode to Flash mode. So far the main focus is on the "back-end" c++ part, as I require this functionality as part of my main app. As and when time permits I will enrich this demo including: * use of resource policy engine to arbitrate access to camera * expose flash rate to QML as property so it can be changed from GUI (e.g. with a slider control). Have fun Chris Zitat von "Mohammed Hassan" : I am glad it worked for you :-) Perhaps I should start working on an open flash light app. Would anyone like to contribute to such app? I have already 2 apps to maintain and I can't easily fit a 3rd. Cheers, On Fri, Jan 24, 2014 at 09:43:54PM +0100, christopher.l...@thurweb.ch wrote: Hi Mohammed That's it! It's strange how things go. Yesterday was one of those days: At work I spent hours fighting with a recalcitrant Confluence installation that refused to start properly, and the evening I could not get the GST code working properly. Today was very different. I discovered that that the mysql database under the Confluence was corrupt. Once i found that, it more or less fixed itself. Then this evening I see from your mail that my GST code only needs one character changed to work! Zitat von "Mohammed Hassan" : > >g_object_set (G_OBJECT(src), "mode", 2, NULL); > >That should do it for you. Works fine here after changing mode to 2 >instead of 1 It really does work, both in developer mode from Qt Creator, and once installed from the Jolla itself. Thank you! I will integrate this functionality into my core app this weekend. Zitat von "Mohammed Hassan" : > >Those errors are harmless. Just ignore them. They decrease with each >update as we implement more camera features ;) > Looking forward to the update(s)! 8) chris ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
I am glad it worked for you :-) Perhaps I should start working on an open flash light app. Would anyone like to contribute to such app? I have already 2 apps to maintain and I can't easily fit a 3rd. Cheers, On Fri, Jan 24, 2014 at 09:43:54PM +0100, christopher.l...@thurweb.ch wrote: > Hi Mohammed > > That's it! > > It's strange how things go. Yesterday was one of those days: At work > I spent hours fighting with a recalcitrant Confluence installation > that refused to start properly, and the evening I could not get the > GST code working properly. > > Today was very different. I discovered that that the mysql database > under the Confluence was corrupt. Once i found that, it more or less > fixed itself. Then this evening I see from your mail that my GST > code only needs one character changed to work! > > Zitat von "Mohammed Hassan" : > > > >g_object_set (G_OBJECT(src), "mode", 2, NULL); > > > >That should do it for you. Works fine here after changing mode to 2 > >instead of 1 > > It really does work, both in developer mode from Qt Creator, and > once installed from the Jolla itself. Thank you! I will integrate > this functionality into my core app this weekend. > > > Zitat von "Mohammed Hassan" : > > > >Those errors are harmless. Just ignore them. They decrease with each > >update as we implement more camera features ;) > > > > Looking forward to the update(s)! 8) > > chris > > ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
Hi Mohammed That's it! It's strange how things go. Yesterday was one of those days: At work I spent hours fighting with a recalcitrant Confluence installation that refused to start properly, and the evening I could not get the GST code working properly. Today was very different. I discovered that that the mysql database under the Confluence was corrupt. Once i found that, it more or less fixed itself. Then this evening I see from your mail that my GST code only needs one character changed to work! Zitat von "Mohammed Hassan" : g_object_set (G_OBJECT(src), "mode", 2, NULL); That should do it for you. Works fine here after changing mode to 2 instead of 1 It really does work, both in developer mode from Qt Creator, and once installed from the Jolla itself. Thank you! I will integrate this functionality into my core app this weekend. Zitat von "Mohammed Hassan" : Those errors are harmless. Just ignore them. They decrease with each update as we implement more camera features ;) Looking forward to the update(s)! 8) chris ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
On Thu, 23 Jan 2014 22:10:19 +0100 wrote: > 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. I tried to use fakesink instead of droideglsink and it worked so you can use that too. > 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 ... Those errors are harmless. Just ignore them. They decrease with each update as we implement more camera features ;) [...] > 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); ^^^ g_object_set (G_OBJECT(src), "mode", 2, NULL); That should do it for you. Works fine here after changing mode to 2 instead of 1 1 is image mode and you can't have the torch on with that 2 is for videos and thus torch will light happily. Cheers, ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
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 #include 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 #include 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" : 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
Re: [SailfishDevel] LED Flash functionality on a real Jolla
Cool to see that ported, Chris! Are you into porting a tracker such as Gaggle? I am flying a paraglider myself, so would be interested to help. As for LED. I did a flashlight that is currently in the app store. Here is the state of art: 1. Qt Multimedia's torch mode is promised to come, but does not work yet 2. GStreamer way should work and that's what flashlight uses 3. GStreamer library, however, is not allowed to link to in harbour rules, so you will have to provide your own copy of GStreamer 4. Resource policy is needed, but for now I go around it by just stopping LED whenever app is not maximized. That's not exactly correct, but will do for now 5. Note also that you can start LED in a shell by running gst-launch and.. that is actually a workaround flashlight is using while I am figuring out the resource policy and how to provide gstreamer lib with the app. I hope it helps. Best regards, Artem. On Thu, Jan 23, 2014 at 10:16 AM, wrote: > Hi Mohammed > > thanks. I will try that later (am at work at the moment). I will also need > to look into the resource policy engine, as that is new to me. > > Harbour entry is becoming less and less of a concern for me. My app does > too many things that are not considered kosher under the current Harbour > rules (sending SMS direct, use of QtContacts, LED access, other Qt > Libraries etc.) > > As an aside, on Harmattan while I got the the Gstreamer route working in > developer mode, I never got it working when launching the app direct from > the device (and thus chose the QCamera approach). This was probably down to > AEGIS, but that should not be a concern on the Jolla. > > Chris > > > Zitat von "Mohammed Hassan" : > > > On Wed, Jan 22, 2014 at 08:29:19PM +0100, christopher.lamb@thurweb.chwrote: >> [...] >> >>> 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 > -- Artem Marchenko http://agilesoftwaredevelopment.com http://twitter.com/AgileArtem ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] LED Flash functionality on a real Jolla
Hi Mohammed thanks. I will try that later (am at work at the moment). I will also need to look into the resource policy engine, as that is new to me. Harbour entry is becoming less and less of a concern for me. My app does too many things that are not considered kosher under the current Harbour rules (sending SMS direct, use of QtContacts, LED access, other Qt Libraries etc.) As an aside, on Harmattan while I got the the Gstreamer route working in developer mode, I never got it working when launching the app direct from the device (and thus chose the QCamera approach). This was probably down to AEGIS, but that should not be a concern on the Jolla. Chris Zitat von "Mohammed Hassan" : 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
Re: [SailfishDevel] LED Flash functionality on a real Jolla
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
[SailfishDevel] LED Flash functionality on a real Jolla
Hi All As many will know from previous threads, I am well on the way to porting an app for paraglider pilots. A subsidiary yet still important feature {1} that I added to the Harmattan version is an emergency flash, using the phone's LED. Now that I have got the app's main functionality ported and up and running on a real Jolla device, I am now trying to get this feature working too. Unfortunately everything I try fails. But as there is a working flashlight app in the Harbour, it must be possible by hook or crock. So far i have tried 3 solutions: Solution 1) A C++ plugin exposing QtMultimedia QCamera to QML This is the solution that works in the Harmattan version of the app, and was therefore the first solution I tried to port to the Sailfish version. When I start the flash I get the following error: QCameraPrivate::_q_error:171 - Camera error: "The camera service is missing" Solution 2) QtMultimedia 5.0 Torch QML element As QtMultimedia offers a Torch Element this seemed an easier and cleaner approach. import QtMultimedia 5.0 Page { id: page Torch { id: torch power: 75 // 75% of full power enabled: false // off onEnabledChanged: console.log("onEnabledChanged: " + enabled) } However this gives the following errors on app start up. (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'scene-mode' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'noise-reduction' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'image-preview-supported-caps' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'image-capture-supported-caps' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'flicker-mode' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'exposure' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'ev-compensation' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'colour-tone-mode' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'capabilities' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'autofocus' from interface 'GstPhotography' (QMLTorch:2300): GLib-GObject-CRITICAL **: Object class GstDroidCamSrc doesn't implement property 'aperture' from interface 'GstPhotography' QObject::connect: No such signal CameraBinExposure::valueChanged(int) 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 Thanks Chris {1} at about this time last year I discovered that a GPS position is enough to get a helicopter close to you, but on a dark and snowy night you need a bright light to get it exactly over you. ___ SailfishOS.org Devel mailing list