Showing posts with label Cheese. Show all posts
Showing posts with label Cheese. Show all posts

12 March, 2012

Tic tac tic tac in Cheese

Look at this image for a second, don't you notice something different?


Right!! Soon and after some polishing, when you record a video in Cheese, you will be able to see how much time you have already recorded!!

Enjoy!

** Update ** : You can see the changes now in the Cheese repository.

02 March, 2012

Very hot in Cheese!

It has been some time since I wrote my last post. It seems to be that this year's cold in Spain has been one of the worse ones in the last years, and I was one of its victims twice, yayyy!

Apart from surviving this cold, I have been lately working on improving hotplug connection of camera devices in Cheese.

Some history:
Hotplug is a feature that has been recently introduced in Cheese. First, I worked on the common case, removing or adding a camera whenever they were not the first or last device. These two left cases, needed a bit further investigation.

I have been now working on "adding the first device" case. I thought that this would be a simple and straight forward task, but it hasn't been. It hasn't been, due to the nature of Cheese, since it was developed without considering hotplug connections and the code was structured in a way that made it difficult to do "non-very intrusive / for working in all the cases" changes.

What did I learn from this?
  1. It would be nice to work on refactoring Cheese.
  2. Do not get so frustrated if something takes you longer than expected and finish it. Somebody told me once: "If you think something is going to take you one week, double that time, and you will get what you will really need". So true...
  3. Using 'export CLUTTER_DEBUG=script' before executing a program that uses Clutter and *.json files for its UI, can be very useful. Thanks to Emmanuele Bassi for this hint!
The changes are still in a working branch of the Cheese repository.

By the way, I just realized that there are just two weeks left for the end of the GOPW! Where is all the time gone??

01 February, 2012

PackageKit in Cheese

As I already mentioned in one of my last posts, the sharing functionality in Cheese uses nautilus-sendto, which is a runtime dependency, and we wanted to do it our best to let the user/developer/maintainer know about it:


  2. By writing a comment in the README file.

  3. By using PackageKit to install the package at runtime. If the package is not installed, and the user tries to use the sharing functionality, PackageKit will be used to install it at runtime. 

The adventure
The PackageKit bit has been quite challenging for me, and I have to admit that it took me much longer than expected :(! I have learned a lot of new things though!

The first problem I had, was that I spent a few days working on dbus-glib, which I later discovered through Dave, that was deprecated. The source of the problem and biggest issue for me was, that both of the examples I followed in the PackageKit FAQ and the Vala tutorial, were obsolete and using dbus-glib. I have already talked with Richard Hughes about the first example and marked the second one as obsolete in the Vala tutorial wiki.

After this discovery, I started using the C API and the org.freedesktop.PackageKit.Transaction interface, which offers the InstallPackages method. I realised of course, that all the examples I looked at, used the org.freedesktop.PackageKit.Modify interface instead, but from my last experience, and since I did not see this interface documented anywhere in the API, I just went on working using the 'Transaction' interface. It also took me a long time to get it 'almost' working, but it never did completely. Another failure!

While I was in the middle of this frustrating process, Dave found out, that the 'Modify' interface was actually not obsolete, and pointed me to a very interesting link that took him some time to find and explained us why all the examples we saw, were using the 'Modify' interface. We both wondered why this was not documented and so hidden, and agreed that this should be somewhere more visible.

After making all the changes in the code again to use D-Bus and the 'Modify' interface instead, I talked to Richard Hughes regarding all these issues. He was really nice, and informed me that the reason why this was not documented in the API, was because the API is just documenting the 'system interface', since the 'session interface' isn't really part of the core PackageKit project but a reference implementation that both KDE and GNOME provide. He also pointed me to another very useful link and agreed on the need of a better entry in the PackageKit FAQ, to provide the users with all these information and documentation, something I will be helping with.

Gained knowledge
I could resume what I have learned about PackageKit in a few paragraphs, that I hope will be useful for you in the future.

There are two different levels of API in PackageKit:

  - The system API: It is the 'Transaction' interface, which is more low level, but allows the developer to control everything, including things like GPG keys and EULAs. Everything is explained in the PackageKit reference manual.

  - The session API: It is the 'Modify' and 'Query' interface, which allows the developer to install a package without taking care of the low level part. This is the one used in Cheese. The documentation in this case, is not so visible as I already mentioned before, but you can find what you need in the git.gnome.org repositories under the /src and /docs directories of gnome-packagekit.

Dave wrote a nice generic synchronous example of PackageKit usage in Vala, using the 'Modify' interface:

[DBus (name = "org.freedesktop.PackageKit.Modify")]
interface Packagekit : Object {
    public abstract void install_package_names (uint xid, string[] packages,
                                                                            string interaction) throws IOError;}


int main () { 
    Packagekit pk;
    try {
        pk = Bus.get_proxy_sync (BusType.SESSION, "org.freedesktop.PackageKit",
                                                   "/org/freedesktop/PackageKit");

        string[] packages = {"nautilus-sendto" };
        var interaction = "hide-confirm-search,hide-finished,hide-warning";
        pk.install_package_names (0, packages, interaction);
    } catch (IOError error) {
        critical ("D-Bus error: %s", error.message);
        return 1;
    }
    return 0;

}

This is basically what you need to know if you want to install any package at runtime in your application using PackageKit, and do not want to bother with the details. I have used the asynchronous version of it for Cheese.

PackageKit in Cheese.

This has been a long post, but as you can see, it was quite an adventure to get here! I will write soon with more news!

17 January, 2012

Add 'Share' functionality to Cheese - check!

Great news! The sharing functionality I have been lately working on, have been merged into Cheese master! Now, users will be able to share pictures and videos within different technologies! This needs some improvement though.

First of all, nautilus-sendto needs a good check in the configure.ac file. We are talking here about a runtime dependency, and it would be really nice to have a hint for the user in the form of a message at configure time if nautilus-sendto is not installed on their system or they have the wrong version of it. I already tried something, but it is not completely working, and therefore had to be dropped from the patch for the merge:

# Check for nautilus-sendto runtime dependency.
NAUTILUS_SENDTO_DEP_MSG="This is a runtime dependency just needed for using the sharing functionality in Cheese."
NAUTILUS_SENDTO_REQUIRED=2.91.0
AC_PATH_PROGS([NAUTILUS_SENDTO], [nautilus-sendto], [notfound])
AS_IF([test "x$NAUTILUS_SENDTO" = "xnotfound"],
   [AC_MSG_WARN([Unable to find nautilus-sendto >= $NAUTILUS_SENDTO_REQUIRED in the path. $NAUTILUS_SENDTO_DEP_MSG])],
   [NAUTILUS_SENDTO_SYSTEM=`nautilus-sendto --version | $SED 's/nautilus-sendto //g'`
    AS_VERSION_COMPARE([$NAUTILUS_SENDTO_SYSTEM], [$NAUTILUS_SENDTO_REQUIRED],
         [NS_VERSION_COMPARE=0],
         [NS_VERSION_COMPARE=1],
         [NS_VERSION_COMPARE=1])
    AS_IF([test $NS_VERSION_COMPARE = 0],
       [AC_MSG_WARN([Unable to check the version of nautilus-sendto, it is probably too old. At least $NAUTILUS_SENDTO_REQUIRED is required. $NAUTILUS_SENDTO_DEP_MSG])])]
)

The problem with this solution, is that it will only work for those versions of nautilus-sendto that include support for the --version argument, currently just nautilus-sendto master, since this is a feature I also worked on during the nautilus-sendto integration, and was merged about a week ago. This means, that old versions of nautilus-sendto will not recognize this argument, and therefore return an error message ("Could not parse command-line options: Unknown option --version"), that AS_VERSION_COMPARE will use, comparing a version number with a string, instead of a version number with another version number, which will of course make the check useless. In the meantime, while I work on finding an improved solution, the user will be informed in two ways in case they hit this problem: through the UI by an insensitive 'Share' action and through the README file.

There are other bits that also need some improvement. As I already explained a few blog posts ago, for accomplishing this task,  I used nautilus-sendto, that internally uses libsocialweb, which needs to have some libsocialweb accounts first set up for working. Right now, the only way for setting those accounts up is using Bisho, that is also giving some problems. The idea now and next challenge, is to use GOA (GNOME Online Accounts) in libsocialweb instead, at least, and just for the moment, for the Google services, so my next tasks will be to focus on porting the current libsocialweb YouTube service to use GOA, and to fix all of those underlying bits that are not working correctly, to make the sharing functionality work really well!

As you can see, I do not get bored. I will be back soon with more news!

03 January, 2012

Avoid using busy-waiting or spinning technique

Busy-waiting, or in other words, spinning, happens when a process repeatedly executes a loop of code to see if a condition is true, while waiting for an event to occur. This means, that the processor will be waiting for the task to be finished in order to go on executing other tasks, which means, that in general this technique should be avoided, since it consumes time of the processor that could be used, wasting it on useless activity. The solution would be to use an asynchronous approach.

Thinking in asynchronous terms is hard though, synchronous API is simpler in many ways, so most of us tend to use it. It is also usually a quicker hack, but not because of this reason it is the best option.

In order to let Cheese users launch several nautilus-sendto dialogs, to send several pictures each time, and change the form of the cursor from when Cheese was busy with nautilus-sendto to when it was not and all of these without blocking the UI, I needed to take an asynchronous approach. I do not have experience with it, so I of course did it the "easy way", spinning the loop (spin_event_loop()) and this was the result (please, take into account that I removed all the code that was not necessary for this explanation):
public void files_share() {
    try {
       main_window.set_busy_cursor();
       Pid child_pid;
       Process.spawn_async("/", argv, null SpawnFlags.SEARCH_PATH, null, out child_pid);
       main_window.set_normal_cursor();
    }
public void set_busy_cursor() {
   get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.WATCH));
   spin_event_loop();
}
public void set_normal_cursor() {
   get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR));
   spin_event_loop();
}
public bool spin_event_loop() { 

   while (Gtk.events_pending()) // Busy-waiting
     {...}
} 
After submitting my first patch with this code, Dave was the one who made the review, and he suggested me to not use the spinning technique. Now it is obvious after reading the above mentioned reasons why :P. At first I was a little bit "afraid" of using asynchronous API. It looked completely akward to me, but then I also discovered through him, that GIO and GLib have some nice API to make asynchronous operations simpler. GIO offers GSimpleAsyncResult, which I personally did not find specially pretty, but still very useful. Sushi uses it and has some nice examples in its code. On the other hand, GLib has g_child_watch_add() (ChildWatch.add()), which sets a function to be called (child_finished()) when a child exits, and was the best approach for my case and the one I decided to replace the spinning technique with:
public void files_share () {
   try {
      Pid child_pid;
      if (Process.spawn_async("/", argv, null,
                                             SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
                                             null, out child_pid))
      {
         ChildWatch.add (child_pid, child_finished);
         if (num_children == 1)
            window.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.WATCH));
      }
   }
}
void child_finished (Pid pid, int status) {
   Process.close_pid(pid);
   if (num_children == 0)
      window.get_window().set_cursor(new Gdk.Cursor(Gdk.CursorType.LEFT_PTR));
}
All of these has been totally new for me and I am very happy I learned some bits of it. It definitely improved the code a lot!

Hopefully, all these changes will be merged to master very soon. I will keep you informed!

24 December, 2011

Integrating nautilus-sendto in Cheese

Among other things, last week I have been very focused and working on the integration of nautilus-sendto in Cheese.

First, I spent some time playing around with nautilus-sendto, and during this process, I filed some bugs and made patches for them too. I first could not compile master during maintainer mode due to some deprecated symbols that I replaced at the end in the form of a patch. After that, I have been having problems with the libsocialweb plugin, which is loaded by nautilus-sendto. At run time, the nautilus-sendto dialog did not show any of the libsocialweb offered technolgies. After talking to Bastien about this issue, he informed me, that in order to show the above mentioned accounts in nautilus-sendto, it is necessary to create your own libsocialweb accounts with Bisho (MeeGo configuration tool for libsocialweb social network aggregator) first. Once the accounts have been created, nautilus-sendto should show those accounts in its dialog. I also filed a bug and submitted a patch updating the README file of nautilus-sendto with this information, which was not available anywhere and updated the diagram I used in my last post with the following one:

Sharing videos and images with Cheese.

The truth is, that even using Bisho now, nautilus-sendto is not showing the libsocialweb accounts for me, which is something I have to go on investigating.

Bisho is also not very stable. It is currently showing just 3 different account types: Facebook, Twitter and Flickr, and just Flickr is working. After what has happened with Meego and the integration of GNOME Online Accounts (GOA) in GNOME, it might be nice and wise to migrate from Bisho, to GOA, another thing I filed a bug about.

Bisho.

After getting familiar with nautilus-sendto, I started working on the integration itself and made a small wrapper in Cheese. Now we can say, that Cheese has the capacity to share images and videos through different technologies. Look that I just said the capacity, which does not mean that is completely working yet! For my changes, I have created a new "shareable-media" branch in Cheese that you are very welcome to test!

This is how it is currently looking in the UI:

Share images and videos Cheese option.

 Integration of nautilus-sendto in Cheese.

I have also realised, that multiple selection of images and videos is not completely working on Cheese. A user is able to select several images and videos that are together one next to the other, but not different separate ones, which is something we will also try to fix.

This, improving the current code and fixing the different issues within nautilus-sendto and Bisho are the next points in my TODOs list. Lots of fun!! :))

I will write back soon with more updates! Thanks for reading!

14 December, 2011

GNOME Outreach Program for Women 2011: The goals

As I already announced a few weeks ago, I had the honour to be selected as an intern for the GNOME Outreach Program for Women 2011 (GOPW)! I will be working on the Cheese project and mentored by David King.

My main goal, and proposed one, from the outset, was to provide Cheese with support for uploading recorded videos to YouTube. Analysing the problem, I decided that I would like to solve it in a way from the beginning, that would permit to extend this feature with other social sharing technologies for sharing images and videos in Cheese in the future. After talking about all of these ideas with Dave, he pointed me to libsocialweb. Later on, and talking to Bastien Nocera about what the plan was, he pointed me to nautilus-sendto, a convenience application to send files via email, bluetooth or instant messenger, which internally uses libsocialweb already and is what I am finally going to use for my purpose, extending my main goal a bit from sharing in Youtube, to sharing in general.

The following diagram should give you an overview of the whole general idea:


I am very excited to see all of this working already! I will try to keep you up to date with the whole process.

Thanks for reading!

18 November, 2011

Cheese Architecture

During the process of trying to understand the internals of Cheese and together with Dave, we created a diagram that I rewrote in dot language and which I think will be very useful for all of those who want to start contributing to the project or are simply curious about it. It took us some time to put the pieces together, but here is the result!

Created using Graphviz.

Did I mention before that I love Graphviz? It is so, but on this occasion it took me a while to get the layout and the legend the way that I wanted. In order to reorder the subgraphs (each of the external boxes: UI, libcheese, libcheese_gtk, System and Legend), I needed to create some transparent nodes and connections to lie to the rank system that dot uses. You can check out the code on my GitHub repository for more details.

The diagram will be available as part of the Cheese documentation for the next 3.3.2 release, coming out next Monday the 21st of November. 

Enjoy!

30 March, 2011

Muktware.com interview.

As I already wrote in my last post and as part of my trainee program, I have spent the last few weeks porting Cheese to GTK+3. In creating the new Cheese version, I collaborated, among others, with two other women developers: Luciana, who was responsible for the camerabin port and gobject introspection support, and Laura, who provided Cheese with SVG overlays support. It is already known that there are not many women involved in the development world yet, so seeing one of them might be considered kind of remarkable. Can you imagine the surprise when you find out that three of them are working in the same project? I think those were the thoughts that came across Swapnil Bhartiya mind when he decided to make us an interview for Muktware.com.