OpenWrt Forum Archive

Topic: iTunes server (forked-daapd)

The content of this topic has been archived between 28 Feb 2018 and 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi ejurgensen and others,

I have put the sources of my (command line) player on GitHub. You can find it here: https://github.com/ErikOnBike/light-play

The player can only play ALAC files to Airport Express devices right now. I might add AirPlay support in the future (ie stream AAC audio-files to more modern AirPort express devices or AppleTV devices).

The player is very low on resource usage. It does not perform any music transcoding (streams directly from the m4a-file) and no encryption (ignores all optional Airport Express authentication stuff). Passwords on the Airport Express Music streaming is supported.

The player is developed and will compile on a Mac (with Xcode command line tools or MacPorts). It compiles on OpenWrt and uses around 1% CPU on my WNDR3700.

The coming time I will try to turn the player into a little server with a web frontend. Afterwards I might try and add AirPlay support. Since I do not have an AppleTV, this is less priority. It requires some rewrite of the network code (since AirPlay is UDP based and requires more timing stuff to be handled). Difficult to test without a real device ;-).

Cheers,
Erik

In one word - Awesome!

If you guys wanna look at a Java implementation (for curiosity or protocol inspection, that is), take a look at https://github.com/jkiddo/jolivia

(Last edited by jkiddo on 23 Nov 2013, 16:48)

@onlinespending: Didn't see your post till know, for some reason the forum stopped sending me email notifications. Yes, as you found out newer versions of ffmpeg will detect the embedded artwork, and the file's media type will be labeled video - even though it's an mp3. I'll look into fixing that, I don't think that should be too hard. The CPU issue on the other hand... I'm at a loss about what causes it, and I don't know how to debug it.

@ErikOnBike: Nice work, thank you for sharing!

(Last edited by ejurgensen on 4 Dec 2013, 21:57)

Hi jurgen,

Do you have the sources for the 20.0 version?
I tried compiling the 0.19 version for ixp4xx and experienced a lot of strange problems.

I found the github sources but don't know how to incorporate it into the build root.
any help is greatly appreciated!

Thank you!

Yes, you can get the Makefiles here: http://www.gyfgafguf.dk/openwrt/src/source.tar.gz (I've just updated them to 20.0 - they had unfortunately fallen behind). When you build with these Makefiles the source will automatically be downloaded from github - a very nifty OpenWrt thing.

You'll need to put the four folders (without the src part) in the package directory. If you're crosscompiling in Debian/Ubuntu then you've then got to do the following (these are from my notes from the last time I set it up - I hope it's complete):

cd ~/YourOpenWrtBaseDir
sudo apt-get install subversion
sudo apt-get install g++
sudo apt-get install zlib1g-dev
sudo apt-get install gawk
sudo apt-get install git
sudo apt-get install libncurses5-dev
sudo apt-get install antlr3
sudo apt-get install libxml-parser-perl
scripts/feeds update
scripts/feeds install confuse
scripts/feeds install libdaemon
scripts/feeds install mxml
scripts/feeds install avahi-daemon
scripts/feeds install libavahi-client
scripts/feeds install sqlite3-cli
scripts/feeds install libexpat
scripts/feeds install libgpg-error
scripts/feeds install libgcrypt
scripts/feeds install alsa-lib
scripts/feeds install libffmpeg-full
scripts/feeds install libevent
scripts/feeds install glib2
scripts/feeds install libintl
make menuconfig (<- select forked-daapd and your architechture)
make tools/install
make toolchain/install
make package/forked-daapd/compile V=s
make package/index

If it is not working, and you're running Attitude Adjustment, I should be able to make you a package easily, since I already have the setup. Just let me know.

(Last edited by ejurgensen on 15 Mar 2014, 23:17)

ejurgensen,

Thank you for responding so quickly!

Bear with me while I pick up on the nuances of the buildroot system.
It's been a while since I worked on C code with such a high level of complexity.
Looking at how you did the sources for 20.0 version is teaching me new stuff!

I followed your instructions and during the compile of forked-daapd and the toolchain spat out this error message.

------------------------------

checking LIBGCRYPT API version... okay
checking for gpg-error-config... /home/ubuntu/openwrt/openwrt/staging_dir/target-armeb_v5te_uClibc-0.9.33.2/host/bin/gpg-error-config
checking for GPG Error - version >= 1.6... yes (1.9)
checking for LIBPLIST... no
configure: error: Package requirements ( libplist >= 0.16 ) were not met:

No package 'libplist' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBPLIST_CFLAGS
and LIBPLIST_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
make[2]: *** [/home/ubuntu/openwrt/openwrt/build_dir/target-armeb_v5te_uClibc-0.9.33.2/forked-daapd-20.0/.configured_] Error 1
make[2]: Leaving directory `/home/ubuntu/openwrt/openwrt/package/forked-daapd'
make[1]: *** [package/forked-daapd/compile] Error 2
make[1]: Leaving directory `/home/ubuntu/openwrt/openwrt'
make: *** [package/forked-daapd/compile] Error 2

----------------------------------------------

I did a

sudo apt-get install libplist++

and confirm that I have libplist++1, libplist and libplist-dev

I think this is a configure.in thing doing a build dependency check and I have absolutely zero working knowledge in this area.
Although it would be easy to ask you to help me compile the ixp4xx version, that would be lazy and not helpful in the long term.
With your help, I would like to make the source usable for as many people as possible.
Your time is valuable so thank you for your help and instruction.

By the way, your package of the ar7xx version is working great for me.
I just have a couple of NSLU2 that I am hoping to make use of.

You're welcome! Remember, that what you are doing is crosscompiling, so installing stuff with apt-get is not going to do any good unless it is some tool used only during the compilation (like git, antlr3 and so on). If you want libplist you must install it as a feed, so use "scripts/feeds install libplist". You may also need to select the package during make menuconfig.

Libplist is actually only necessary because --enable-itunes is selected. If you remove that you can also remove the libplist depedency.

(Last edited by ejurgensen on 16 Mar 2014, 12:21)

ejurgensen,

That did the trick!
Thank you!

In my mind, I thought that libplist was a toolchain dependency, which was why I did the apt-get.
Now that you point that out to me, it seems so obvious.
I read the description for libplist but the dots didn't connect.

I am testing the package now and it's working great.
Remote pairing works flawlessly, as is playing to a Shairport4w and Shairport.

I am hearing some crackle and pops but it could be due to the hardware as I didn't experience this with the ar7xx version.
I do recalled hearing them on the NSLU2 while using madplay.

Thank you for the fantasic job and guidance.

Hello, I'm trying to install forked-daapd on my tplink router but I'm having many difficulties.

I'm on  ATTITUDE ADJUSTMENT (Attitude Adjustment, r33883)

and I installed it from here:

src/gz forked-daapd http://www.gyfgafguf.dk/openwrt/attitud … x/packages

When I try to run it I get no errors whatsoever I set the log to spam and all I get is this:

[2014-04-16 11:56:45]     main: Forked Media Server Version 20.0 taking off
[2014-04-16 11:56:45]     main: Initialized with gcrypt 1.5.0
[2014-04-16 11:56:45]     main: PID: 2217
[2014-04-16 11:56:45]     main: mDNS init
[2014-04-16 11:56:45]     mdns: Initializing Avahi mDNS

if I start with -f I get:

root@OpenWrt:~# forked-daapd -f
    main: Forked Media Server Version 20.0 taking off
    main: Initialized with gcrypt 1.5.0
    main: mDNS init
    mdns: Initializing Avahi mDNS
Segmentation fault

Can anyone please help me or point me in the right direction, I don't know how to compile and I just wanted to share my music with my 2 computers without having one of them on all the time (it's an economy thing!).

Thanks

(Last edited by luisfmoreira on 16 Apr 2014, 15:33)

I don't have a good idea about what might be going wrong for you, unfortunately. I can see program execution is failing very early in the start up sequence, and as you can see it is happening while it is registering with Avahi. There is only one function being executed in this step, avahi_client_new(). Apparently this function is segfaulting for you.

So one thing to check is your version of libavahi, libavahi-client and libavahi-dbus-support. What version are they? They should be 0.6.31-5 (you can check with opkg list-installed | grep libavahi). Maybe also try reinstalling the libavahi libs?

If that is alright you might need to use a debugger. I have never had much luck with gdb, but Valgrind is sometimes helpful (but will be very slow on your tplink).

(Last edited by ejurgensen on 16 Apr 2014, 22:20)

Hi, thanks for replying! I got this from grep:

root@OpenWrt:~# opkg list-installed | grep libavahi
libavahi - 0.6.31-5
libavahi-client - 0.6.31-5
libavahi-dbus-support - 0.6.31-5

I have removed the 3 packages and re-installed them but I get the same result, I dont know valgrind is it har to use?

Thanks

I also found this on avahi:

found user 'nobody' (UID 65534) and group 'nogroup' (GID 65534).
Successfully dropped root privileges.
avahi-daemon 0.6.31 starting up.
WARNING: No NSS support for mDNS detected, consider installing nss-mdns!
dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
WARNING: Failed to contact D-Bus daemon.
avahi-daemon 0.6.31 exiting.

Could this be the issue?

(Last edited by luisfmoreira on 16 Apr 2014, 22:22)

You install it with opkg, and then run:
valgrind --track-origins=yes --trace-children=yes /usr/sbin/forked-daapd

When it crashes it should give you some info about what happened - you can post it here. It will probably also give a lot non-relevant error messages, just disregard them. The important part is the stuff right before the crash - probably no more than 10-15 lines.

(Last edited by ejurgensen on 16 Apr 2014, 22:18)

I got this from valgrind:

==2843==     Valgrind's memory management: out of memory:
==2843==        memcheck:allocating ocacheL1's request for 92274688 bytes failed.
==2843==        17686528 bytes have already been allocated.
==2843==     Valgrind cannot continue.  Sorry.

Don't think it's useful ...

Yeah, not very useful. The avahi error messages on the other hand might be something. It seems Avahi is not running, which it should. Do you have dbus and libdbus 1.4.14-2?

It doesn't quite explain why you get a segfault. When I start forked-daapd without Avahi running the log says: "Failed to create service browser: Bad state"

Found it right now ! Dbus was not running big_smile !!! I enabled dbus and avahi on boot and it goes smooth big_smile indexing all my songs ! Thanks a lot

ejurgensen wrote:

@onlinespending: Didn't see your post till know, for some reason the forum stopped sending me email notifications. Yes, as you found out newer versions of ffmpeg will detect the embedded artwork, and the file's media type will be labeled video - even though it's an mp3. I'll look into fixing that, I don't think that should be too hard. The CPU issue on the other hand... I'm at a loss about what causes it, and I don't know how to debug it.

@ErikOnBike: Nice work, thank you for sharing!

Out of curiosity, were you able to get the embedded artwork issue mentioned above sorted out? I suppose no breakthroughs getting AAC to stream without the CPU getting hammered?

On an unrelated note, if I recall correctly your source packages were once only for Barrier Breaker. I see on the wiki you've now added support for Attitude Adjustment. Any advantage using one over the other? I was going to back down to AA for something else and may prefer going with that.

Yes, I fixed the embedded artwork issue a while ago. I forgot to put a notice up about it. The only progress on the AAC problem is that I've found out that ffmpeg's transcoding is causing it. Maybe a newer version of ffmpeg has some optimizations, or maybe there is some ffmpeg compile option which will fix it. Other solutions would be to use another library for decoding, or to not transcode when not required (like discussed above).

About AA vs BB, I think it comes down to ffmpeg as well. BB has ffmpeg 0.11.5, while AA has ffmpeg 0.8. Both should work, but ffmpeg 0.11.5 is required for forked-daapd to be able to extract embedded artwork.

that's great news about the embedded artwork. Looks like I'll stick with BB for now then. And thanks for contributions you've made to forked-daapd

ejurgensen wrote:

About AA vs BB, I think it comes down to ffmpeg as well. BB has ffmpeg 0.11.5, while AA has ffmpeg 0.8. Both should work, but ffmpeg 0.11.5 is required for forked-daapd to be able to extract embedded artwork.

Since I've decided to stick with BB, what do you recommend is the easiest and least error prone method of updating forked-daapd and its dependent packages? Ideally I wouldn't have to start the process from scratch and would be able to keep my existing settings if that's possible. Thanks.

If your device is ar71xx the easiest would be to install the package for r36713 which is mentioned here: http://wiki.openwrt.org/inbox/howto/forked-daapd

Otherwise, you've got to do the compiling yourself. I gave some info above about the packages needed for that here: https://forum.openwrt.org/viewtopic.php … 80#p227680

Your settings should be preserved when you upgrade with opkg, but for safety it is probably also a good idea to make a backup of the config file and database file before upgrading.

(Last edited by ejurgensen on 28 Jul 2014, 10:07)

ejurgensen wrote:

If your device is ar71xx the easiest would be to install the package for r36713 which is mentioned here: http://wiki.openwrt.org/inbox/howto/forked-daapd

I see they released RC1 of BB. I imagine you'll create an install package for the golden release of BB? May just hold off until then since it's likely around the corner. Or do you suppose your current build would work with RC1 (based off of trunk r41580)?

(Last edited by onlinespending on 31 Jul 2014, 19:22)

I don’t know if the current build will work with RC1, but when BB comes out I’ll make sure to upload a binary for ar71xx and brcm47xx. Looks like they are already at RC2 now, so maybe it will be soon.

@ejurgensen - I noticed your interest in ffmpeg versions. Please take a look at my post at:

https://forum.openwrt.org/viewtopic.php?id=51994

and let us know if you have any objections to upgrading to 2.x versions.

/ted

I have no objections, I can only applaud the work you are doing!

There seems to be a bug in version ffmpeg 2.1.1 (see https://github.com/ejurgensen/forked-daapd/issues/45), which can cause segfaults, so I suggest a newer version than that.

Apart from that, forked-daapd should work with all versions of both libav and ffmpeg.

Oh, one thing I'd like to ask: Please configure with --enable-avresample. They moved the resampling stuff from avcodec to avresample, but for some reason they did not set libavresample to be built by default.

The discussion might have continued from here.