Cheese 2.91.91 using Camerabin

In January I started changing Cheese to use Camerabin as its pipeline base. I blogged about it twice, but, in case you missed it or forgot everything about it, let me repeat myself: Camerabin is the high level GStreamer element that basically does what a camera does, that is, take pictures, record video and show preview. Since Cheese does all that and more, it makes sense to use this element instead of re-implementing it all. The news part is that this work is now in Cheese’s master branch and also in release 2.91.91.

There are some other things I haven’t posted about yet:

Event handling: There was a warning in Cheese after the change to Camerabin which said “Internal GStreamer error: clock problem“. Investigating that I discovered that it was a problem in the input-selector that Camerabin uses internally.

Right now Camerabin has a copy of input-selector, because it uses the “select-all” property that was removed from current input-selector. The problem was that the input-selector didn’t handle upstream events (from the sink to the source direction) when the input-selector had the “select-all” property set. Well, input-selector can have many inputs and choose among them, as you can guess from the name. So, when select-all is set you need to send the event to all of those inputs. Other than the warning, this actually has no effect in Cheese’s case, because the event that is not forwarded (a latency event) wouldn’t actually be handled by the elements that don’t get it. Even so, I submitted a patch which was committed to master branch of gst-plugins-bad.

Taking photo without saving: Cheese Camera has a method that takes a photo and then provides the picture as a GDK pixbuf without saving it. The api may not be the best and there were some nice comments on how to improve it, but at least in Cheese without Camerabin this worked and it was used inside of cheese-avatar-chooser. Well, I didn’t realize that before my last blog post about Camerabin, but this was totally broken in my Camerabin branch, in fact, I hadn’t implement it at all.

Camerabin can send a preview message after taking a photo if you set the preview-caps with the desired format for the preview. I thought using the preview message was the best way to implement cheese_camera_take_photo_pixbuf(). The problem is that Camerabin only took photos to save them too, meaning the file name of the photo to be saved had to be set. Right now Cheese works around that by setting the file name to /dev/null, but I also sent a patch to Camerabin to allow taking a picture without saving if preview-caps is set, meaning it won’t encode the image just to save it to /dev/null. I’m keeping the workaround for now, since the change wasn’t released yet, but we will be able to remove it in the future.

Many thanks to Thiago Santos, who held my hand when I met those and other problems in Camerabin and who always encourages me to fix stuff and send patches.

I’m very excited about this change in Cheese. I’m sure there will be bugs, but I think using Camerabin will make some improvements in Cheese easier and we will grow with Camerabin (and maybe Camerabin2 in the future) and also push it to be better.

Posted in Cheese, english | Tagged , | 7 Comments

My GTK3 porting story

It is now possible to run Cheese using GTK+ 3 getting it from Cheese’s branch gtk3.

Cheese has a gtk3 branch for a while, but until very recently it only had one patch changing mostly versions in configure.ac. Then Bastien Nocera made 3 more patches changing code of CheeseWidget, CheeseFlash and um-crop-area. I wanted to use the changes, and silly me, I thought the branch was going to compile when I first tried to run it. It turns out that I spent days on it until it finally compiled and then a little more time before I was able to run it.

Most of the changes were on build system and Cheese’s vala code. I have never programmed in vala before, so this was a learning opportunity with some challenges in the way.

Funny story

Cheese was still using libunique-1.0, but in order to work with gtk3 I would have to switch to libunique-3.0. There was no vala binding for libunique 3, but I also hadn’t found one for clutter-gtk-1.0 and I was using the GObject Instrospection one instead and it seemed to work at the time.

Using gir files didn’t work so well with libunique. Vala was loading the right gir file, but it said the namespace “Unique” did not exist. So, I asked for help on the #vala channel. The first piece of advice was to switch to GApplication instead of using libunique, but I didn’t know how hard that would be and I wanted to understand why I was unable to use libunique-3.0 first. With some more help from someone else in the #vala channel I found out that the Unique-3.0.gir file had the wrong package name on it. As I didn’t know how to fix that and I didn’t even know if it was a problem in libunique or a GObject Introspection parsing problem I asked for help in #introspection.

In the #introspection channel, Emmanuele Bassi (ebassi) was the one that helped me, libunique’s maintainer. Isn’t it nice when that happens? I mean, you’re just asking for anyone less clueless than you to help, but you can actually talk with people that work on what you’re using. Anyway, continuing with the long story, ebassi told me the problem was in libunique, that he wouldn’t work on it soon, but he encouraged me to file a bug for it and I did. It turned out that the bug was easy to fix (for him at least) and something like 15 mins later he had fixed it and pushed it to master already. That was a nice surprise!

But my problems didn’t end there. After I fixed some GObject Introspection annotation in libunique for my code to work, valac started to crash with a segfault. I reported it, but I still don’t know what the exact problem was. The only way I found to fix it was to switch to GtkApplication and stop using libunique. If only I had listened to that first advice! Using clutter-gtk with GObject Introspection did not work in the end either, but turns out I was just missing the recently released vala binding for it.

I learned many things on this quest. I had never looked at gir files or vapi files before and I learned a little trying to debug and fix problems. The non-technical lessons were: it’s really painful to use stuff that is new and not widely used (yet?), you will find problems. But it’s also very nice to be able to fix the problems and work with helpful people.

By the way, to share my love for GNOME I’m organizing a GNOME 3.0 Release party in my town – Belo Horizonte, Brazil. So, if you’re in the area, save April 9th and get in touch if you want to help with organization.

Update: Patricia Santana Cruz had already made a patch to port Cheese to Gtk.Application (which is also way better than mine), so if I was any smarter I wouldn’t have half of the work I did. And now I know she is also one of the responsibles for we having the clutter-gtk-1.0 binding for vala too and she is working on some more bugs in vala and going after the warnings that affects Cheese. In short, she is awesome!

Posted in Cheese, english, free software | 10 Comments

Presenting the new Libcheese

Yesterday Daniel made a new Cheese release. It contains a library called simply LibCheese that contains basically a way to take photos, record video and see preview with your webcam plus some detecting stuff. It also allows you to add an effect to that.

LibCheese without GTK

Libcheese concept exists for a long time now, but it was not in a good shape. There used to be two libraries in cheese, one called libcheesecommon, that was only used internally, and one called libcheese-gtk that was installed. The problem is that Cheese is still using GTK+ 2, which is a deal breaker for potential users such as The Board. Also, libcheese-gtk has some things that are a bit old and are not very useful right now.

What I did was to change libcheesecommon to contain only non-gtk stuff and then export it calling it libcheese, which was Lucas‘ idea. So, even though Cheese is still using GTK+ 2, applications using GTK+ 3 can use libcheese if they want to. This involved changing cheese-flash to libcheese-gtk instead of libchesecommon, but also removing some old GTK code stuff that was not being used anymore.

Taking advantage of the moment, Daniel also removed cheese-countdown.c, which draws the countdown on the GtkWindow, since Cheese now uses cheese-countdown.vala that draws countdown on top of the video preview using clutter.

GObject Introspection

I also started annotating CheeseCamera, which is the main part of LibCheese, to allow applications written in different languages to use it. While doing that I made small changes to the api to help GObject Introspection annotation such as adding const to strings when appropriate. You can find my not yet tested GObject Introspection annotation in libcheese branch, and the other changes are all already in master and in the new release.

Next step will be to test and improve GObject Introspection annotation. If jhbuild is nice to me I might try to use LibCheese in The Board.

Quick LibCheese example

I also added a new test to Cheese that tests CheeseCamera, which is also a good example of how to use LibCheese. Here are the important bits:

CheeseCamera *camera;

camera = cheese_camera_new (CLUTTER_TEXTURE (texture), NULL, width, height);

cheese_camera_setup (camera, NULL, &error);

cheese_camera_play (camera);

The texture is the ClutterTexture where you want the video to be drawn. You can also set the device name instead of using NULL to create CheeseCamera.

To take a picture after that:

cheese_camera_take_photo (camera, filename);

To record video:

cheese_camera_start_video_recording (camera, filename);

cheese_camera_stop_video_recording (camera);
Special thanks to kov for helping me with autotools and other build issues in the worst hours possible.
Posted in Cheese, english, free software | 8 Comments

Cheese with Camerabin

So, last week I posted I started changing Cheese to use Camerabin, the high level GStreamer element that can capture video, photos and show preview. I can now say that Cheese is now working using Camerabin as its base, at least for me and two other people.

I’m a little embarrassed to say that the black preview problem I was having all along was actually because of lack of dconf installed in jhbuild. Because of that, my contrast and saturation were always set to zero when I started Cheese and I thought that was a problem with the preview, specially because I did have a problem with clutter-gst before. Thanks to Laura I discovered that.

Other problems were much easier to solve after I stopped debugging this nonexistent problem. The main problem was that Camerabin sets a lot of stuff by default, such as resolution and filtered video format. This caused a lot of negotiation problems depending on which camera was used or which size of photo or video was requested. After working around the defaults, it seems to be working ok now.

Another improvement was to use Camerabin’s signal “set-video-resolution-fps” to set resolution for photo and video, instead of using a capsfilter for that. In the future, we might be able to switch between photo-capture and video-capture modes in Cheese without turning off the camera. But, for now, I’ll leave it like it used to be, specially because it seems Camerabin doesn’t set image-capture size separate from video-capture size as it should.

I just posted a bug with the patch to add camerabin to master in Cheese. I really hope it’s working perfectly, but it would be really nice to have more people testing it. So, if you feel like it, check camerabin branch and tell me the results.

Next week I plan to work on other improvements in libcheese. Maybe I’ll try to make some improvements in the API before the API freeze for 3.0.

Posted in Cheese, english | 4 Comments

Cheese slowly moving to camerabin

This week I started working on libcheese to see if it is in a better shape for GNOME 3.0.

Last week I talked briefly about Cheese Widget not working right. I continued to look into that and discovered that the reason cheese-test-widget was not working was gconfaudiosrc, the source Cheese uses to capture audio. It makes sense that this doesn’t work, since Cheese is now using GSettings, but I really couldn’t understand why Cheese works with it (without using Cheese Widget) and cheese-test-widget doesn’t (and with the same code for pipeline). The fact is that replacing gconfaudiosrc solved the problem for cheese-test-widget.

Instead of changing only the audio source, I decided to start changing Cheese to use Camerabin. This is one of my goals for GNOME Outreach Program. Camerabin takes care of taking pictures, recording video and preview, so it fits Cheese perfectly, and Cheese won’t have to do this all again.

First part of using Camerabin in Cheese worked great, with some help of my mentor Thiago, camerabin specialist. I even made a small patch for camerabin. I can take pictures and record video using Cheese with Camerabin, and it even solved a bug that I had using Cheese master branch.

The tricky part about using Camerabin in Cheese is that, besides recording video and taking pictures, Cheese has effects, and it does a live preview of this effects. You can set a “video-source-filter” property in Camerabin which takes a GStreamer element as argument and sets a filter between capture and all the other components (video-capture, image-capture, view finder).

I tried to add Cheese complexity inside this video-source-filter, with a big Gstreamer Bin that splits camera into the branch that is going to image capture, video capture and preview and the other branch that will be used for live preview of the effects. When I added that, I started experiencing again the black preview bug. Since I’m the only one that I know having this bug and can’t find a way to fix it, I can’t actually tell if other people would actually see the preview when using Cheese with Camerabin. I have been trying to persuade some people to test it for me and tell me. Maybe you could do it too? Check camerabin branch in Cheese repository in git.gnome.org.

One thing that is definitely broken is to apply effects. Yes, I know Cheese is no fun without it. I am working on getting it fixed. If you have worked with GStreamer for a while, you probably had negotiation problems that were hard to fix too.

While working on that I ended up making a patch to be applied to master to handle GStreamer warning and error messages. And another one just removing an extra colorspace.

Posted in Cheese, english, free software | 3 Comments

GNOME Outreach Program update

When I think we are getting closer to define a format for configurable properties in GNOME Video Effects, someone thinks of something else to change. This is actually good, I think every little change that was done is for the best, but it’s a very slow process and it’s not very good to work on a library of a changing format.

It was great to start the library to learn more about how it would be parsed, but there are some small differences in the format that might change the library a lot. One of those is detecting the type of a property automatically from the GStreamer element, since right now we have properties in GNOME Video Effects that always map to one unique property in one GStreamer element. To do that I will probably create a GstBin from the description of the effect, get the element, its class and the property type. At least it seems the most simple way of doing it for me. Always creating the GstBin will also help me get the default of every property.

I also made improvements not related to changing the format in the library, most of them thanks to Younness‘ comments.

I also decided to work on Cheese a little. I rebuilt everything again to see if some upgrades would fix a bug that I have. I can’t see the preview in Cheese, it is a black screen or a red screen if I apply some specific effects. I can see the effects preview, though. I tried somethings, including using a workaround I had done for a similar problem, but it doesn’t work anymore. This is probably not a bug in Cheese itself and no one else seems to have it. Maybe I’ll just try to use it this way for now. I also started debugging Cheese Widget since the test stopped working for me. This one I will continue to work on, since I want Cheese to use Cheese Widget again.

Posted in Cheese, english | Leave a comment

GNOME Video Effect Library update

First of all, this is a very late report of the work I did last week.

I continue to work on a library to parse GNOME Video Effects. Some of the highlights of what I did last week are:

  • Added the library to be compiled by autotools.
  • Added a small test.
  • Started handling more types of properties (boolean and string).
  • Started checking property values when they are set.
  • Change of license: When I started the library, I used GPL version 2 as the license following GNOME Video Effect license. Last week I decided to change it to LGPL. The library is very simple and my goal is for it to be used by most applications using GNOME Video Effects. I doubt that any application would change its license just to avoid implementing a simple parser, so I think LGPL will allow us having the most users without losing anything.

Other than that, mostly fixing stuff that was wrong and minor improvements.

The discussion about the format for properties in GNOME Video Effect is also not finished yet, but almost. This week I’m replacing the Min and Max keys for double and int properties to a range Range key and I will change how the default value is defined also. In the library I’m parsing a Default key, but the default value will be set inside the pipeline description, so, if an application is not interested in configurable properties, it will have the default value set only by using the pipeline description. This was actually right when I posted the format the first time but I changed it when implementing the library. The example is almost the same as before:

[Effect]
Encoding=UTF-8
Name=Hulk
Name[pt_BR]=Hulk
Comment=Transform yourself into the amazing Hulk
Comment[pt_BR]=Transforme-se no incrível Hulk
PipelineDescription=videobalance saturation=1.5 hue=-0.5 name=balance1

[Property::angriness]
Name=Angriness
Name[pt_BR]=Raiva
Comment=Change the angriness of Hulk by making yourself more or less green.
Comment[pt_BR]=Mude a raiva do Hulk ficando mais verde ou menos verde.
Type=double
Range=1.2;1.6;
Element=balance1
Property=saturation
Posted in Cheese, english, free software | Tagged | 2 Comments

GNOME Video Effects library

I blogged about adding properties to GNOME Video Effects before. The discussion about the format is still going on, but meanwhile I started working on a library to parse the new format (I will adapt it when the format is defined).

Until now, GNOME Video Effects didn’t have a parser, because the format was very simple and small and every application could parse it itself. Now that we are adding properties to it, I think it will make sense to have a parsing library inside of GNOME Video Effects that applications can use. You can check what I have developed until now in http://gitorious.org/libgve/libgve/commits/parser.

In its current state, the library basically parses the .effect file and stores its properties as pspecs in a hash table. It creates the actual effect (a GStreamer Element to be used in the application pipeline) only when requested and after that you can set its properties as you wish. Besides improving and fixing what is done, I still need to add a way to get the information that was parsed which can be used, for instance, to show it in a UI.

I also added a bug about adding the library to GNOME Video Effects.

Posted in Cheese, english | Tagged | 2 Comments

Adding configurable properties to GNOME Video Effects

GNOME Video Effects is a collection of GStreamer effects that can be used in GNOME applications. It is currently used by Cheese, meaning it has all those nice effects that are used in Cheese.

Effects are described in a very simple format, so it’s very easy to add a new effect if you know a little about GStreamer. The famous hulk effect is as simple as:

[Effect]
Encoding=UTF-8
Name=Hulk
Name[pt_BR]=Hulk
Comment=Transform yourself into the amazing Hulk
Comment[pt_BR]=Transforme-se no incrível Hulk
PipelineDescription=videobalance saturation=1.5 hue=-0.5

It couldn’t be simpler, but it doesn’t allow us to change anything. In many effects, it would be nice to have configurable properties, such as making hulk more or less green or choosing delaying time in timedelay for 2 or for 20 seconds. This would allow other applications to use GNOME Video Effects as well.

The new format to specify configurable properties is being discussed in bug number 626533. We are heading to something like this, with some details to be decided:

[Effect]
Encoding=UTF-8
Name=Hulk
Name[pt_BR]=Hulk
Comment=Transform yourself into the amazing Hulk
Comment[pt_BR]=Transforme-se no incrível Hulk
PipelineDescription=videobalance saturation=1.5 hue=-0.5 name=balance1

[Property::angriness]
Name=Angriness
Name[pt_BR]=Raiva
Comment=Change the angriness of Hulk by making yourself more or less green.
Comment[pt_BR]=Mude a raiva do Hulk ficando mais verde ou menos verde.
Type=double
Min=1.2
Max=1.6
Element=balance1
Property=saturation

Currently, GNOME Video Effects only provides a collection of effects, but parsing should be done by the application using it. As this format will be a little more complicated, I’m also thinking about writing a library that could be used by the applications and, off course, use it in Cheese.

Posted in Cheese, english | 5 Comments

GNOME Outreach Program for Women plans

This is my first post after I was added to Planet GNOME (although some of my very old posts have already been displayed on the planet), so, hello planet readers!

I will be part of GNOME Outreach Program for Women working on Cheese and I will have Thiago Souza Santos as a mentor. I’m really happy about this opportunity. I would like to thank GNOME Foundation, Google and Collabora for sponsoring this, Marina for organizing it and Daniel Siegel for helping me through application and giving me the great ideas to work on.

One of my goals for the project is to improve Libcheese making it good to be used by other software. I plan to use camerabin in Libcheese and use gobject-instrospection to allow applications written in other languages to use it.

Another goal is to add configurable properties to GNOME Video Effects. For instance, think about the hulk effect in Cheese, while you want to keep the hue property in videobalance fixed so you can get the green skin tone, you can configure saturation to have lighter or stronger greens. The goal is to fix this bug: https://bugzilla.gnome.org/show_bug.cgi?id=626533 and hopefully have more people using GNOME Video Effects after that.

If you have any ideas on those topics, please send me an e-mail, contact me on IRC or just add it to bugzilla. And, keep in mind that I can only start working for real on that on December 15th, when the program starts. Less than a month away! Counting down!

Posted in Cheese, english, free software | Leave a comment