Posts Tagged MediaTomb

Ahhhh, the joys of the standards compliance…

After managing to build a functional copy of MediaTomb for my DroboShare, I then found out that it doesn’t support the Xbox 360. Yay… the single device that I wanted to work with it. Oh well, I suppose I should have loaded up the Ubuntu based version first or something beforehand. According to the authors of MediaTomb, it is the fault of Microsoft. That I can believe. I have yet to do a protocol trace but I do know that most other UPnP media servers have a special switch that you have to flip to make it work with the Xbox 360. What a bummer… so much for the UPnP “standard”.

, , ,

3 Comments

Building MediaTomb for the Drobo using Ubunutu

Seeing as it constantly comes up on the Drobo developer forums, I thought i’d take the time to put in some work and compile MediaTomb for the DroboShare. For those of you who don’t know, DroboShare is a NAS device that attaches to the Drobo and allows for the device to be used over the network instead of direct USB connections. The beauty of the DroboShare is that it’s an embedded Linux machine with an ARM processor and shell access. Gotta love that! The default media server on the Drobo forums is FUPPES. No offense to it’s author, but I really can’t stand using it. :( It seems slow and I really dislike the interface. I also don’t like the amount of configuration that it takes to get it to work with my Xbox 360 so I decided to do MediaTomb instead.

The first part of this is going to require a working Ubuntu 8.10 installation. I use Kubuntu 8.10 as my desktop OS so I already had this part covered. ;) You can also use a VMware image if you don’t have a Ubuntu Linux machine around. Everything is done in a chroot environment and can be easily deleted after the software is compiled and uploaded to the DroboShare.

First, let’s create the jailed environment.

sudo mkdir -p /var/chroot/drobo

Install schroot (you can also use chroot if you’d like) and debootstrap

sudo apt-get install schroot debootstrap

Create the file /etc/schroot/chroot.d/drobo with the following contents
——– /etc/schroot/chroot.d/drobo ——–

[drobo]
description=Ubunutu Intrepid for DroboApps
location=/var/chroot/drobo
priority=3
users=<Your Username>
groups=sbuild
root-groups=root

——– /etc/schroot/chroot.d/drobo ——–

Create a minimal system in the chroot jail

sudo debootstrap --variant=buildd --arch i386 intrepid /var/chroot/drobo

Create a place to extract the new downloads

sudo mkdir /var/chroot/drobo/root/code

Download the Drobo toolchain to a temporary directory
http://www.codesourcery.com/gnu_toolchains/arm/releases/2006q1-6
(Select ARM GNU/Linux, then IA32 GNU/Linux, then click Download)

Extract the Drobo toolchain

cd /var/chroot/drobo/usr/local
sudo tar xfj <DownloadDir>/arm-2006q1-6-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

Download MediaTomb
Grab a copy from here : http://mediatomb.cc/pages/download#source_code
Extract the files into the chroot

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/mediatomb-0.11.0.tar.gz

Because i’m building MediaTomb, i’ll need SQLite, ZLib, expat, and a few other things … Let’s start with SQLite
Grab a copy from here : http://www.sqlite.org/download.html
I used ‘sqlite-amalgamation-3.6.7.tar.gz’
Extract to the code directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/sqlite-amalgamation-3.6.7.tar.gz

ZLib – http://www.zlib.net/
I used ‘zlib-1.2.3.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/zlib-1.2.3.tar.gz

Expat – http://sourceforge.net/projects/expat/
I used ‘expat-2.0.1.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/expat-2.0.1.tar.gz

File – http://www.darwinsys.com/file/
Note : The site admin removed the 4.24 version of file so I had to get mine from here
ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/file-4.24.tar.gz
I used ‘file-4.24.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/file-4.24.tar.gz

TagLib – http://developer.kde.org/~wheeler/taglib.html
I used ‘taglib-1.5.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/taglib-1.5.tar.gz

libexif – http://libexif.sourceforge.net
I used ‘libexif-0.6.17.tar.gz’
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfz <DownloadDir>/libexif0.6.17.tar.gz

ffmpeg – http://ffmpeg.org
FFmpeg doesn’t really do releases so I used a snapshot from a Gentoo mirror. The filename was ‘ffmpeg-0.4.9-p20081219.tar.bz2′ and I got it from http://gentoo-distfiles.mirrors.tds.net/distfiles/ffmpeg-0.4.9-p20081219.tar.bz2
Extract to the directory

cd /var/chroot/drobo/root/code
sudo tar xfj <DownloadDir>/ffmpeg-0.4.9-p20081219.tar.bz2

Create a directory for the resulting binaries.

sudo mkdir -p /var/chroot/drobo/usr/arm

Now it’s time to enter the chroot jail and start compiling!

Mount the required filesystems

sudo mount -o bind /proc /var/chroot/drobo/proc
sudo cp /etc/resolv.conf /var/chroot/drobo/etc/resolv.conf

Activate the chroot

sudo schroot -c drobo -d /root

Load some extra packages

apt-get install vim

(Feel free to use whatever editor you like in place of vim)

apt-get install automake autoconf libtool autotools-dev m4

Setup some environment variables. The trick to cross-compiling is to use the system’s binaries for running autotools but tell the compiler to link against the ARM headers, libraries, and binaries. These environment variables ease the pain when building in a non-standard directory. If they’re not set, a few of the below builds will fail miserably. :(

Seeing as we know the CPU/Architecture of the Drobo and the version of GCC, a quick check of the docs gives us some additional command line switches to further tweak things for our processor. The Drobo is no speed demon so everything helps.

export CFLAGS="-I/usr/arm/include -march=armv5te"
export CPPFLAGS=${CFLAGS}
export LDFLAGS="-L/usr/arm/lib"
export CC=arm-none-linux-gnueabi-gcc

With that out of that way, let’s build some software! ZLib is up first

cd /root/code/zlib-1.2.3
./configure --prefix=/usr/arm --shared
make
make install

Now Expat

cd /root/code/expat-2.0.1
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

SQLite

cd /root/code/sqlite-3.6.7
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

File proved to be a bit more tricky, but nothing too horid…

cd /root/code/file-4.24

Edit magic/Makefile.am

vi magic/Makefile.am

Change line 224 from

${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE)

to

${MAGIC}: $(EXTRA_DIST)

Now run the following to rebuild the build system …

aclocal
autoheader
autoconf
libtoolize
automake
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Libexif

cd /root/code/libexif-0.6.17
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Taglib time!

cd /root/code/taglib-1.5
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm
make
make install

Hold on to your cookies … it’s time for ffmpeg. This is a seriously daunting command line but I have a feeling that this version is broken when cross compiling. Who knows what the problem is … this build works, just no Matroska. :(

cd /root/code/ffmpeg
./configure --cross-prefix=arm-none-linux-gnueabi- --prefix=/usr/arm --arch=arm --enable-armv5te --enable-nonfree --disable-network --disable-ipv6 --enable-pthreads --disable-zlib --disable-bzlib --disable-ffserver --disable-ffplay --disable-devices --disable-encoders --disable-muxers --enable-shared --disable-static --disable-vhook --enable-avfilter --enable-cross-compile --disable-decoder=matroska
make
make install

MediaTomb leaves a lot to be desired when it comes to properly detecting items in a cross-compiled environment. It also looks like some of the distributions move header files around… which of course breaks it further. :( The following hack fixes it up for us to use again.

mkdir -p /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavcodec/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavutil/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavformat/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libavdevice/* /usr/arm/include/ffmpeg
cp -v /usr/arm/include/libswscale/* /usr/arm/include/ffmpeg

Last but not least … MediaTomb! Time for some build system hacking again.
Enter the code directory

cd /root/code/mediatomb-0.11.0

Hack up the configure script a little. :)

vi configure.ac

Change the following line numbers.
2378, 2395, 2402, 2418
On each of those lines, you’re going to see the following section

"-lavformat -lavutil"

With this version of FFmpeg, a

"-lavcodec"

is needed. Here’s how mine turned out.
Line 2378

FFMPEG_LIBS="-L$FFMPEG_SEARCH_LIBS -lavcodec -lavformat -lavutil -lz"

Line 2395

FFMPEG_LIBS="-lavcodec -lavformat -lavutil"

Line 2402

FFMPEG_LIBS="-L$SEARCH_DIR_LIBS -lavcodec -lavformat -lavutil -lz"

Line 2418

FFMPEG_LIBS="-L$SEARCH_DIR_LIBS -lavcodec -lavformat -lavutil -lz"

Now it’s autotools time again.

aclocal
autoheader
autoconf
libtoolize
automake
./configure --host=arm-none-linux-gnueabi --prefix=/usr/arm --disable-external-transcoding --enable-ffmpeg --with-taglib-cfg=/usr/arm/bin/taglib-config --disable-libjs --disable-rpl-malloc --with-ffmpeg-lbs=/usr/arm/lib --disable-inotify --disable-mysql
make
make install

If all went well, you should see the following output

CONFIGURATION SUMMARY ----
sqlite3               : yes
mysql                 : disabled
libjs                 : disabled
libmagic              : yes
inotify               : disabled
libexif               : yes
expat                 : yes
id3lib                : disabled
taglib                : yes
ffmpeg                : yes
external transcoding  : disabled
libextractor          : disabled

Okay, now to create the required scripts, tar it up and send it to the Drobo! I’ve attached them here as text files and also as a ZIP file all of the necessary files.

The following two files go in the

/usr/arm

directory
mediatomb-stop.sh
mediatomb-start.sh

The following file goes into the

/usr/arm/config

directory. This directory does not exist in the default MediaTomb setup, just create it and put the file in there. This is the default configuration that MediaTomb creates on first startup except that the paths have been modified to work on the DroboShare. This file will definitely need some more tweaking.
config.xml

This ZIP file contains all of the original files in their original form. Just unzip this file to /usr/arm and move the configuration file to /usr/arm/config
configs_for_mediatomb.zip

Almost home … just create the Tarball

cd /usr/arm
tar cvfz ../mediatomb.tgz *

Now exit the chroot jail and upload

/var/chroot/drobo/usr/mediatomb.tgz

to the Drobo. For more information on how to add applications to the DroboShare, check out the DroboSpace site.

, , , , , , , ,

17 Comments