Command line sharing plugin for n900

Thomas Perl made a proposal for creating a command line sharing plugin for the n900. I had already planned to implement something like that so I joined the project.

I pushed the first “proof-of-concept” quality implementation to the GIT a month ago. I’ve been using it with the Irssi script (in the scripts directory) to get http URLs with meta information to IRC. The Irssi script needs to be modified to match the directories and IRC servers in use and both the script and the sharing plugin are still missing most of the error checking and extra functionality. Nevertheless, they’ve worked for me for the past weeks.

For the sharing plugin I’ve given something like the following command line:


scp %s kulve@foo.bar.fi:~/photos_incoming/%s

There’s two times the %s as the local temporary file name doesn’t match the actual file name to be copied. And that assumes the SSH keys have been exchanged so that no passwords will be asked.

The Irssi script polls the incoming directory for new images. For each new file, it moves the file to public WWW tree, gets the meta information with exiftool and prints something like this to the specified IRC channel:


Title: Description [tags] (GPS coordinates) http://foo.bar.fi/~kulve/imagename.jpg

I modified the Irssi script a bit before pushing it to the GIT, so no guarantees it works. And that’s my first Irssi script ever, so it may do something odd ;)

There’s no debian packages yet as neither the script nor the plugin have been tested properly. Comments, testing and patches are welcome.

n900 Battery Duration: Ogg vs. MP3

There have always been complaints about Ogg being more of a battery hog on the Nokia tablets compared to Nokia optimized MP3. I decided to measure the difference.

All tests were run on a preproduction n900 device that Nokia distributed at the Maemo Summit. The software is the Maemo5 41-10 release which was already installed in the device. I installed Ogg Support, gst-av, ffmpeg and OpenSSH. Otherwise the device is the default 41-10 release. WLAN connection was configured but not activated during the tests. A SIM card was in place only in the SIM idle test.

Before every test I charged the device, disconnected the charger once I noticed the green led, and rebooted the device. After the boot I started a simple script in the xterm. The script logged current time to a file, run “sync” command and slept 60 seconds after which it started the loop again.

Idle tests

I run two idle tests between the libvorbis and ffvorbis tests but I’ll introduce the idle results first.

First idle test was a generally idle device. I.e. it did have the default processes running but I didn’t start anything, except my logging script. During the test I did check a couple of times if the device was still on. The battery lasted for 93.8 hours.

According to Igor Stoppa, there’s a cellmo sw bug that makes current higher without a SIM card. Therefore I rerun the idle test with a SIM card inserted. During the test I received two phone calls which I hung up, I received two SMS messages and wrote one. At one point the notification led was blinking for 45 mins. The battery laster for 93.6 hours.

There’s probably a few hour error margin on those tests, so basically the battery lasted roughly a bit over 90 hours in both tests.

Powertop shows that after 60 seconds of showing the xterm with display blanked, the CPU is mostly in the highest C4 sleep state:

C# Ratio Avg/dura Frequency Ratio
C0 0.3% 600 MHz 0.0%
C1 0.0% 550 MHz 0.0%
C2 0.1% 1.1ms 500 MHz 0.0%
C3 0.2% 15.2ms 250 MHz 100.0%
C4 99.5% 2297.0ms    

Ogg vs. MP3

Now that we know how long the device will last when idle we can move to the actual results.

I run two sets of tests. First one was with the Ogg Support 1.0.5 from Extras and the second one with Felipe’s gst-av (2009-09-25) which is using vorbis decoder from FFmpeg (2009-09-07). I repeated both tests three times, running every other test with MP3 and every other with Ogg.

After restarting the device with a fully charged battery I started the logging script in the xterm, started the File Manager and clicked on the MP3 or Ogg file which then started playing that single file in a loop in the Media Player. Both files were encoded with variable bitrate 192kbps settings. Volume of the device was set to minimum and no headphones were connected.

This is what powertop shows while playing MP3 in Media Player compared to libvorbis:

MP3 libvorbis
C# Ratio Avg/dura Frequency Ratio
C0 37.9% 600 MHz 3.1%
C1 0.0% 0.2ms 550 MHz 1.1%
C2 7.0% 3.0ms 500 MHz 17.5%
C3 55.1% 8.0ms 250 MHz 78.3%
C4 0.0%    
C# Ratio Avg/dura Frequency Ratio
C0 70.1% 600 MHz 18.2%
C1 0.0% 0.1ms 550 MHz 0.0%
C2 4.7% 2.7ms 500 MHz 28.8%
C3 25.1% 7.8ms 250 MHz 52.9%
C4 0.0%    

Clearly while using libvorbis the CPU spents more time in lower sleep state and running with higher frequency. The following graph shows how this affects the battery. The battery lasts around 18 hours while playing MP3 but only around 11 hours while playing Ogg.

Battery duration: MP3 vs. libvorbis

Next numbers are with ffvorbis instead of libvorbis. Powertop shows that while using ffvorbis the time spent in different sleep states matches quite closely to the ones of MP3 usage:

MP3 ffvorbis
C# Ratio Avg/dura Frequency Ratio
C0 37.9% 600 MHz 3.1%
C1 0.0% 0.2ms 550 MHz 1.1%
C2 7.0% 3.0ms 500 MHz 17.5%
C3 55.1% 8.0ms 250 MHz 78.3%
C4 0.0%    
C# Ratio Avg/dura Frequency Ratio
C0 38.4% 600 MHz 2.1%
C1 0.0% 0.1ms 550 MHz 0.0%
C2 5.7% 3.1ms 500 MHz 13.2%
C3 55.9% 8.3ms 250 MHz 84.6%
C4 0.0%    

The similarity of the powertop numbers can be seen in the battery duration as well:

Battery duration: MP3 vs. ffvorbis

The average battery duration while using ffvorbis was slightly better than while using MP3 but probably well within the error margins. So basically they are equal when battery duration is concerned.

It’s interesting to see how the situation changes in a year, will Nokia make better optimizations to their MP3 decoder than the community to the FFmpeg. These tests were run in a preproduction device with a pre-sales software. I’m sure the overall power management of the device will get (even?) better in the future software releases.

Addition (2009-11-17):

When using the speakers the n900 runs some “speaker protection algorithms” that take extra power. I repeated the ffvorbis test case with Nokia’s headset and here are the results:

Battery duration: ffvorbis with headphones

On the average the battery duration improved a bit over three hours.

Addition (2009-11-25):

I run the same tests (Ogg Support 1.0.5, no headset) for Flac:

Battery duration: libflac

n900 with a pre-sales w41-10 software can run Flac roughly 1.5 hours longer than MP3.

Ogg Support: Next Steps

Purpose of the 1.0.5 release was to get a decent feature set to Extras repository before the Maemo Summit. There are still some bigger issues to be fixed in the future releases.

Bugs

There’s a product for Ogg Support at the Maemo Extras Bugzilla. I’ve added the major issues there but do report any other issues you find.

Tags

Media Player and File Manager depend heavily on the open source Tracker for the meta data. Tracker has different meta data extractors for different mime types. GStreamer extractor is used by default for all audio/* and video/* mime types. The gstreamer extractor uses tagreadbin for getting the meta data from the media files.

For better efficiency tagreadbin uses only parsers for getting the meta data. Decoders may need e.g. separate DSP hardware, so using decoders for getting the meta data could be a very slow and heavy process.

Unfortunately Vorbis and Flac tags are not in the container and need a decoder for parsing them. Tracker provides a separate extractor for Vorbis that’s now packaged separately for Maemo by Ivan Frade. That’s not “product quality” and shouldn’t be used, so a proper solution will replace that one. The work for getting a tag parser for Vorbis and Flac to be used with tagreadbin has already been started. Hopefully the patch will be attached to the Gnome bugzilla at some point.

Gstreamer’s playbin(2) element reports tags while playing the media file and this already works with Vorbis and Flac. MP and FM need to know the meta data before they start to play the file but e.g. the Media Widget on the Desktop seems to get the tags from the playbin2 as it shows the tags for Flac as well.

Performance

The Vorbis decoder from xiph.org isn’t as fast as the FFmpeg’s Vorbis decoder on the n900.

There weren’t any GStreamer plugins for the FFmpeg’s Vorbis decoder until Felipe implemented one. The gst-av is still missing some features that need to be implemented before it can be taken into use, mainly tags and streaming.

If you are interested in the topic, I’m sure Felipe would be more than happy to apply patches :)

I’ll report numbers about performance comparisons between MP3 and Ogg later.

Ogg Support in Fremantle Extras

In my last post I asked for a wish list of features for the Ogg Support. I started the integration work based on those comments and now the 1.0.5 version for n900 has been promoted to Fremantle Extras repository.

The support for Vorbis audio is good: tags work, File Manager shows them too and knows how to launch Vorbis files in Media Player, etc. Flacs are missing tags but no magic is needed for that, just a new GStreamer element. Theora support is also included. I haven’t tested it much but at least the basic features seem to work.

I’ll tell more about the details at the Maemo Summit.

Wishlist for N900 ogg-support

Time to switch to a Linux phone and time to start preparing ogg-support for N900/Fremantle.

Hopefully everything will be easier to get working with the N900 since at least the closed source Metalayer Crawler is replaced with open source Tracker.

I would like to hear if there’s anything special people would like to get with ogg-support. Support for oggs in the built-in media player with tags is of course the first goal but is there something else that is a must? Theora? Flac?

Thanks.

Learning OpenGL ES 2.0

I got (again) interested on OpenGL ES 2.0 and bought OpenGL® ES 2.0 Programming Guide.

The examples on the book can be downloaded from http://www.opengles-book.com/. Those are meant to be compiled with Microsoft Visual Studio.

I made a small patch that adds initial support for Linux/X11. It doesn’t support texture loading (because I misplaced my png loader somewhere), the WinCreate() is copypaste code I don’t fully understand and the WinLoop() is missing some functionality. But at least the Chapter 1 Hello Triangle compiles and runs in Fremantle on Beagle board :)

Compile and install the libes in a normal autotools manner. Then you can compile the examples by exporting the PKG_CONFIG_PATH and running gcc:


gcc `pkg-config libes --cflags --libs` Hello_Triangle.c -o Hello_Triangle

As usual, patches are welcome :)

ALIP on n8x0

ARM and Movial announced a second stable release of ARM Linux Internet Platform (ALIP) generic repository. ALIP got other updates as well, see a blog post about them in Movial’s Sandbox or the actual release notes.

The Kaze project for n8x0 devices was updated to use the generic-2 branch as well. There are no built images provided, but ALIP is relatively easy to compile if one is already familiar with Scratchbox. The ALIP rootfs works with the Maemo kernel and initfs and it can be booted nicely from an MMC/SD card, so no need to destroy the Maemo from the device just to test ALIP.


Kaze on n8x0

ALIP requires newer SB components (and specific toolchains) but the newer SB components should work just fine with Maemo targets and Maemo toolchains. Or the newer SB can be installed in a different directory from tarballs and used concurrently with the Maemo SB.

Follow the From scratch instructions but replace alip-project with kaze-project and don’t pass the -cbeagleboard. You should pass -c multimedia to include 3rd party provided (by me actually) gst-ffmpeg to the build.

If you want to include WebKit engine and Midori UI to it, add “midori” to the components file.

Unfortunately the X driver for OMAPs (xf86-video-omapfb) in the stable branch in omap-repository has a bug concerning n8x0 devices and you should use master branch of it if you want to test video playback. The easiest way to switch using master branch for this component is to clone the n8x0 configuration repository and switch the branch before running the matrix install.


git clone git://linux.onarm.com/git/n8x0/config/n8x0.git
vi n8x0/suite/n8x0-recommended
# Add the branch: Component("xf86-video-omapfb", branch="master")
matrix install -c multimedia

After the install you should include the binary DSP tasks from the device (they are proprietary and cannot be distributed). Use the helper script (get_nokia_binaries.sh) in src/platform-n8x0 that fetches them from the device over ssh and reinstall the component before creating the rootfs image:


matrix install-only -c multimedia platform-n8x0

Lots of things are still broken:

  • Power button tries to suspend, which fails and does nothing.
  • WLAN encryption keys are not stored succesfully.
  • WPA doesn’t work (WEP and unencrypted do work).
  • Midori should be started after networking.
  • There’s no ssh client (but dbclient as it’s dropbear).
  • Power management.
  • Default XFCE theme doesn’t look cool.
  • Etc.

But I believe that with some work Kaze on n8x0 will become decent enough for everyday use and will provide up to date components long after Nokia has dropped the n8x0 support.

If you have any questions, visit #alip @ freenode.

PS. If you want an open source media engine with D-Bus API checkout the Octopus. It’s a work in progress but handles basic audio and video playback on n8x0 just fine :)

Ogg-support: in Extras

I promoted the ogg-support 0.9 to Extras repository. Feedback is welcome.

I’ve also managed to get the tags (except for the album) to show up in Metalayer Crawler. But that code isn’t even in SVN yet.

Kilikali shows all the tags properly and based on the GStreamer debug prints the MLC also gets the album tag but for some reason doesn’t write it to ~/.meta_storage SQL db.

Too bad the MLC is closed source so I can’t debug further why it rejects the album tag.

Ogg-support 0.9: Builder

I added the Theora support back to ogg-support and uploaded the source packages to extras-devel builder.

I didn’t change the mimetypes though, so all *.ogg files are seen as audio files even though they may contain video streams as well. I quickly transcoded the Big Buck Bunny video to lower resolution ogg containing Theora video and vorbis audio. The Media Player was able to show it although I should have used even lower resolution (and lower audio bitrate).

Comments are welcome.

New UI for Kilikali

Thanks to Movial Kilikali got a modern UI and looks quite nice now:

Kilikali UI

Kilikali development has moved to a GIT tree (branch generic-2) hosted by linux.onarm.com.

Although the UI got improved and the playback on n8x0 got fixes there are still some bigger task to be done. E.g. adding single files, adding directories recursively and skipping unknown media types. Integration with Light Media Scanner has also been discussed.