Sunday, January 06, 2008

Banshee now has support for MTP devices in trunk. It's a long and torturous story, but here's the short of it:

Way back when, the work on implementing MTP support was started by a guy called Patrick. At the time, there were two options:
1) libgphoto
2) libmtp

libmtp was still in it's early stages of development and wasn't mature enough to be a viable option, so libgphoto was chosen althought it wasn't that much better. At this time, libgphoto didn't have metadata reading/writing implemented, didn't show any stats on the different filesystems in the device. Note: libmtp was no better at the time. So, a C# binding to libgphoto was started and basic support for syncing was eventually pushed into banshee.

Fast forward about 18 months. libgphoto has matured significantly in its support for mp3 players. Track metadata has full read/write support, you can get stats on the filesystems, patches and optimisations have been pushed in so that all the basic operations are fast. However, there's still issues with long filename support - there are hardcoded limits in libghoto itself which means if it encounters a path or filename longer than the limit, it just bails out. For mp3 players, this was a serious issue as these limits were quite frequently reached. For instance, if you were a fan of Sufjan Stephens, you were out of look. His incredibly long track titles like 'Out of Egypt, Into the Great Laugh of Mankind, and I Shake the Dirt From My Sandals as I Run' really throw a spanner in the works

Around this time, i stepped in to complete the binding and complete banshee MTP support. I pestered poor Marcus for quite a while until i got various fixes/updates into libgphoto such as the change to allow unlimited filename length and path length, and also to remove 'long' types from the public API (as a 'long' type can be 32bit or 64bit depending on architecture and leads to nasty complications binding it in C#). I also completed the initial revision of the libgphoto-sharp API restructuring. The entire endevour probably took about 2 months from start to finish.

However, the problem now was that in order to have MTP support in banshee, you needed SVN head of libgphoto, svn head of libgphoto2-sharp and a pot of luck that you could get it installed without screwing up your packaged version. A new release of libgphoto was several months away and probably still a further few months until it managed to trickle down into the various distros.

It was then that i was reminded by Aaron that libmtp still existed and was quite mature. I took a quick look at the API showed that it was tailored specifically for the kind of tasks that banshee was trying to do. Better yet, it had a faster release cycle, it didn't require svn head of anything in order to get all the features that were required and it was already available in nearly every distro.

I spent about 4 days writing a brand new C# wrapper for libmtp and then replaced the libgphoto-sharp code in banshee with the new libmtp-sharp code. While there are things in libmtp that are missing as compared to libgphoto, the simplicity of the new API makes it trivial to implement features which previously would have been quite complicated. For example, Playlist support under libmtp is trivial to implement, yet under libgphoto i'm not 100% sure how i'd go about it!

What i regret most of all out of this is that i put Marcus through so much hassle for minimal benefits as Banshee is no longer using libgphoto. While i do feel bad about putting so much effort into the libgphoto-sharp binding to never use it myself, it was still the best decision from banshee's point of view.

So, if anyone out there has an MTP device and wants to make sure that their device works with banshee before the release (so i can fix any bugs should there be any), check out the guide here. Post any bug reports on http://bugzilla.gnome.org under the DAAP component in Banshee.

17 comments:

Igor said...

Good to see that you're the type of developer that change his mind for something better.

I do remember that I helped you to debug the 32/64 bits issue, and by that time you were not willing to check libmtp even though Rhythmbox read my device.

But remember that F-Spot still uses GPhoto2 so the binding is still used.

Alan said...

Well, the reason what i didn't check out libmtp was because i was assured that libgphoto was the right choice ;) I believed what i was told.

If i had taken a serious look at libmtp, i would have jumped ship earlier, i just never bothered because to my knowledge, there was no point. Patrick had researched the topic, had made his decision, and at the time it was right. Unfortunately by the time i got around to it, the decision was no longer right.

Either way, a lesson was learned.

Patrick said...

Long as it works, that's what matters most :) Hacking around a lot of the libgphoto2 things was tough, and I'm sure libmtp makes that oh-so-much easier. Back when I first started hacking mtp support in Banshee, libmtp was something like v0.0.1 and was very troublesome. I went down the libgphoto2 road because I figured it'd be easier in the short term and with discussions w/ the gphoto developers, we thought libgphoto2 would work better in the long run. However libmtp has matured quite a bit, so I don't doubt that it's much easier to use :)

Good work! Sorry I haven't been around to help, but it probably made it easier for you to do your thing.

Good news is that f-spot will always need the libgphoto2-sharp bindings, so no effort lost there!

wow gold said...

Weekends to peopleig2tmean that they can have a two-day wowgold4europe good rest. For example, people gameusdcan go out to enjoy themselves or get meinwowgoldtogether with relatives and friends to talk with each storeingameother or watch interesting video tapes with the speebiewhole family.
Everyone spends agamegoldweekends in his ownmmoflyway. Within two days,some people can relax themselves by listening to music, reading novels,or watchingogeworld films. Others perhaps are more active by playing basketball,wimming ormmorpgvipdancing. Different people have different gamesavorrelaxations.
I often spend weekends withoggsalemy family or my friends. Sometimes my parents take me on a visit to their old friends. Sometimesgamersell I go to the library to study or borrow some books tommovirtexgain much knowledge. I also go to see various exhibition to broadenrpg tradermy vision. An excursion to seashore or mountain resorts is my favorite way of spending weekends. Weekends are always enjoyable for me.
igxe swagvaultoforu wowgold-usaignmax wowgoldlivebrogame thsaleGoldRockU

dr martens boots said...

Hello. Great job. I did not expect this on a Wednesday. This is a great story. Thanks!

jackanderson said...

You are a Great while writing in the blogs it is awesome I liked it too much.........

kamagra online

zygor guides said...

wow great i have read many articles about this topic and everytime i learn something new i dont think it will ever stop always new info , Thanks for all of your hard work!
zygor guides review

Buy generic viagra online said...

Ahh…finally, after so much of scavenging…here it is...I have been desperately looking for this info from past few months…I am sure this would help me a lot…..I never thought the solution for my nagging question is so simple…Or probably you are damn intelligent to explain such a complicated thing in a simple way..Thank you again!!


buy kamagra oral jelly 100mg

Apcalis said...

Look… here I am I have tried out things in the same manner as you described and guess what!!! I have been successful in taking up the challenge and fulfilling the endeavor finally!!! There cannot be anything better than this.

Caverta | Penegra

online generic viagra said...

Hey,
This is really found me very interesting.... Thank you very much for sharing this great information. I'm looking forward for some more information from your blog.

Thanks!

cheap viagra said...

Thanks a lot for this nice post.


Smith Alan

Vinny said...

Brilliant work ! Your site has supplied me all the content I needed .
Locksmith Hampton VA

amoxicillin amoxil said...

this post really very good and effective for me thanks for sharing this nice post

Online Generic Viagra said...

A very good article post.I must appreciate you knowledge about the subject.Thanks for sharing..

sports handicapping services said...

Thank you for the efforts you been putting on making your site such an interesting and informative place to browse through.

Kamagra Oral Jelly said...

This is something informative for me and useful also.I love the way you write.I will share this information to all my friends to visit this site.Thanks for the share!!!!!
Generic Viagra | kamagra

George said...

Very interesting article! Someone can be useful!

Hit Counter