GNOME Bugzilla – Bug 338308
Install needed plugins when metadata load fails.
Last modified: 2007-11-21 21:57:32 UTC
It would be good to automagically install the necessary gstreamer plugins when we can't decode a file. Exactly how to do this will be distro-specific, so we really just need to provide the necessary hooks to allow it.
Created attachment 63360 [details] [review] patch to add hooks. This adds an "import-error" signal which can be used to absorb import errors, and install plugins. How it would get used: a) write a plugin that connects to the db's "import-error" signal b) in the signal handler, lookup the mimetype in the plugins mimetype->gst_plugin map c) if it isn't in the map, or the plugin is installed, return false to continue normal import error processing d) store the data somewhere, and return true to stop normal import error processing e) install the gstreamer plugin f) ask gstreamer to check for new plugins g) use the info stored in (d) to call rhythmdb_add_uri (uri, entry_type) again (e) is the only bit that is really distro-specific, and I'm not sure how (or if) we can do (f).
Created attachment 63691 [details] gst-plugin-install-apt.py Python plugin to use these to automagically install needed plugins with apt. I don't know if there is a way to get GStreamer to re-scan for new plugins, so you have to restart RB and import again once it has done installing. If there is a way to do that, it should automatically re-try the import once the install has been completed.
Created attachment 64133 [details] [review] patch This patch adds the requires hooks and a plugin that works for me on Ubuntu Dapper. It currently doesn't work with the metadata helper turned on, because that doesn't send the mime-type with the load error. Adding support for other distros or install methods is simply a matter of adding a new subclass. I'm not sure how it is best to set up, probably with a configure flag to choose which one to use.
Created attachment 66242 [details] [review] update to cvs. Updated to cvs. As before it doesn't work with the metadata-helper becuase I haven't figured out how best to send the mimetype with the error.
Marking as enhancement
http://devel.linux.duke.edu/cgi-bin/viewcvs.cgi/yum-utils/yumdownloader.py?revision=1.10&view=markup is probably useful, for anyone who wanted to write a yum backend.
This should be using GStreamer's missing plugins support instead. Totem already implements this.
It's a lot easier to do in Totem though than it is for Rhythmbox, because Totem doesn't have a decoupled importer. I started implementing this at same point based on the code above, but gave up when it became clear it wouldn't be finished in time for the release/feature freeze. I'll have a look to see how much of my half-finished patch still applies though.
I've started working on this a bit, using the Totem code as a base. It shouldn't be too hard to get it working for import and playback situations, but tag writing and (especially) encoding will be more difficult.
Created attachment 94933 [details] [review] it works.. This only works if you're importing a single file. It needs to block further imports until the plugin installation finishes. It seems to break ignoring of non-audio files a bit too.
Created attachment 97846 [details] [review] add playback and podcast download hooks The playback side of things is pretty simple, in the end.
It looks okay to me, although shouldn't there be an i++ somewhere in the loop in emit_missing_plugins()? The dialog provided by Ubuntu's codec-buddy can be a bit confusing some times, but there isn't much we can do about it. It told me "you need to install a codec to play this file" while I was already listening to some music, because the library watching noticed a new file.
(In reply to comment #12) > The dialog provided by Ubuntu's codec-buddy can be a bit confusing some times, > but there isn't much we can do about it. It told me "you need to install a > codec to play this file" while I was already listening to some music, because > the library watching noticed a new file. File a bug? :)
This manages to deadlock itself if you hit two files in a row that have missing plugins. The locking used to block importing while processing missing plugins is too racy. And yes, there should have been an i++ in the loop in emit_missing_plugins().
Created attachment 98514 [details] [review] better Now with well-behaved locking. I think the changes in rb-metadata-gst.c have some slightly bad side effects relating to plain text or nearly-plain text files.
Created attachment 98905 [details] [review] slightly better again I think this fixes ignorable file types a bit better. Stops us requesting 'application/xml decoder' plugins, at least. It doesn't seem to retry importing files after installing plugins correctly. Has anyone tried this on a fedora system, or indeed anything other than debian/ubuntu?
(In reply to comment #16) > Has anyone tried this on a fedora system, or indeed anything other than > debian/ubuntu? Just tried this on Fedora 7, if I double-click a file with a missing plugin, I see the following on the console, but nothing else (e.g. any kind of GUI selector) appears: Rhythmbox-Message: Missing plugin: gstreamer|0.10|rhythmbox|MPEG-1 Layer 3 (MP3) decoder|decoder-audio/mpeg, mpegversion=(int)1, layer=(int)3, parsed=(boolean)true Rhythmbox-Message: Automatic missing codec installation not supported (helper script missing) What is supposed to happen? Is the codec-buddy an Ubuntu/Debian-specific thing?
On Fedora, a (possible) equivalent to the codec-buddy on Ubuntu is this: http://fedoraproject.org/wiki/Multimedia/Codeina
With codeina installed, installing Fluendo plugins for (say) MP3, works if you try to playback an MP3 file without gstreamer-plugins-ugly (say). The playback seemed to be a bit odd with the fluendo plugin, but that's not rhythmbox's fault.
I've committed this to svn. Thanks for testing.
*** Bug 498840 has been marked as a duplicate of this bug. ***