Sunday 13 December 2015

ushare in MIPS platform

If looking for a light-weight DLNA Media Server (DMS) to run in embedded device then ushare is one of the good option.


http://ushare.geexbox.org/

 The development for ushare is stopped now but still the version is good to bring up a DMS quickly. Ushare depends on libupnp and libdlna modules.


http://pupnp.sourceforge.net/
http://libdlna.geexbox.org/

The objective of this post is to mention how to cross compile ushare successfully with its dependency for MIPS architecture.


(1) Dependency Matrix


Very first thing is the dependency matrix which I could not see anywhere and spent more time to identify that


ushare - ushare-1.1a
libpupnp - libupnp-1.6.19
libdlna - libdlna-0.2.4
ffmpeg - ffmpeg-1.0.10

(2) Cross compile libpupnp


(3) Cross compile ffmpeg


Export the toolchain location in PATH environment variable.

#export PATH=/user/venkateshm/work/ushare-cc/toolchain/mips4k_gcc_x86_linux_22/bin/:$PATH

#./configure --prefix=/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg --enable-cross-compile --cross-prefix=mipsel-linux- --arch=mipsel --target-os=linux --disable-static --enable-shared --enable-pic --extra-cflags=-O2 --enable-memalign-hack --disable-devices --disable-muxers --disable-encoders --disable-filters --disable-hwaccels --enable-muxer=adts --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-yasm --disable-demuxer=matroska --disable-stripping

Since we need only the libraries, we can disable the generation of executors like ffmpeg, ffplay.

In runtime, I was facing 'Illegal instruction' when av_log() API is invoked. Not sure about the root cause; for quick resolution, I commented the implementation of av_log API in libavutil/log.c file.


#vi libavutil/log.c


Comment out the implementation of av_log API

#make
#make install

(4) Cross compile libdlna


In the configure file the ffmpeg dependency was not not properly listed and that was causing 'Symbol not found' error. After that edited the configure file to resolve the problem

#export CFLAGS="-I/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg/include/"


#export LDFLAGS="-L/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg/lib"

#vi configure

Add -lavutil -lavcodec and -lswresample in line number 646

645 echolog "Checking for libavformat ..."
646 check_lib libavformat/avformat.h av_register_all -lavformat -lavutil -lavcodec -lswresample || die "Error, can't find libavformat !"
647 echolog "Checking for libavcodec ..."

648 check_lib libavcodec/avcodec.h avcodec_register_all -lavcodec || die "Error, can't find libavcodec !"

#./configure --prefix=/user/venkateshm/work/ushare-cc/OUTPUT/libdlna --cross-compile --with-ffmpeg-dir=/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg --cross-prefix=mipsel-linux- --disable-static --enable-shared --enable-debug

#make

#make install

(5) Cross compile ushare


#export CFLAGS="-I/user/venkateshm/work/ushare-cc/ushare/ushare-1.1a -I/user/venkateshm/work/ushare-cc/OUTPUT/libupnp/include/ -I/user/venkateshm/work/ushare-cc/OUTPUT/libdlna/include/"


#export LDFLAGS="-L/user/venkateshm/work/ushare-cc/OUTPUT/libupnp/lib/ -L/user/venkateshm/work/ushare-cc/OUTPUT/libdlna/lib/ -L/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg/lib/"

#export CC=/user/venkateshm/work/ushare-cc/toolchain/mips4k_gcc_x86_linux_22/bin/mipsel-linux-gcc


#./configure --prefix=/user/venkateshm/work/ushare-cc/OUTPUT/ushare --with-libupnp-dir=/user/venkateshm/work/ushare-cc/OUTPUT/libupnp/  --with-libdlna-dir=/user/venkateshm/work/ushare-cc/OUTPUT/libdlna/ --cross-compile --disable-nls --disable-strip --enable-debug --enable-dlna

There is a bug in ushare source code, before make fix the code in ushare.c:line number 191 file

# vi src/ushare.c

ip = ((struct in_addr*)&request->CtrlPtIPAddr)->s_addr;

#make

#make install


At run time, export LD_LIBRARY_PATH environment variable before executing ushare binary

# export LD_LIBRARY_PATH=/user/venkateshm/work/ushare-cc/OUTPUT/libupnp/lib/:/user/venkateshm/work/ushare-cc/OUTPUT/libdlna/lib/:/user/venkateshm/work/ushare-cc/OUTPUT/ffmpeg/lib

No comments:

Post a Comment