Re: [Banshee-List] Banshee and radio FM player

Salvatore Benedetto wrote:

would it be possible, and useful, to develop a plugin that allows to use banshee
as a radio FM player by using the video4linux API?

As far as I know there are no many radio FM player around.

A couple of weeks ago I wrote C# bindings for v4l2 and ALSA to make use of the FM radio chip in the Nokia 800. (The bindings cover everything you need to tune a radio, and might be able to do more but they aren't yet complete for general use.) The interface is standard so the code will work with any Linux-supported tuner device.

Both are split into a low level API and high level .NET-style API. There are examples in the git repositories and it's all pretty easy to use:

Radio radio = new Radio ("/dev/radio0");
radio.IsMuted = false;
radio.Frequency = 95.8f; //Capital FM

The API was stream-of-thought, so I might rename this class to Tuner, or make Radio a subclass of Tuner based on the result of a TunerType query (which can be Radio, AnalogTv or DigitalTv) etc. I'm figuring out as I go how to provide a fun and powerful API so your thoughts would be welcome.

For integration into Banshee, it probably makes sense to enumerate tuner devices with hal-sharp (which is already included in the code base). Once you discover the device node, pass the path to the Radio constructor.

Tuners are often patched or looped back into Line-in, and this is where alsa-sharp comes in. You need access to ALSA to un-mute and set the volume of line in, and if you want to record the stream you need to use the enumerated value type in that API to set the recording source.

HCtl ctl = new HCtl ("default");
foreach (HCtlElem elem in ctl.Elements)
	//do stuff

alsa-sharp currently lacks GLib main loop integration, so if another application changes the volume, a Gtk# volume widget will not move to reflect the new value (unless it polls or uses a thread, neither of which are valid approaches). This is easy to implement -- will push the changes soon.

I'm designing these APIs so they can be used as standalone libraries or pipelined in the style of GStreamer. If there are bad interactions with Banshee's media framework and alsa-sharp being in the same process for example, the libraries can be turned into D-Bus services with some five lines of code each so tuners and controls can be manipulated out-of-process, over the network etc.

This means that whatever code you write to support radio tuners in Banshee will be trivially modified to remote control some other tuner on the network. This is only interesting because I assume there are now more N800s out there than actual FM radio tuner cards.

The code is at

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]