Setup DLNA server on NAS
Server
Cross Compile Environment http://www.pages.drexel.edu/~sg64/stuff/cross-compile.htm
$HOME/cross-compile/$TARGET/usr/bin $HOME/cross-compile/$TARGET/install/module-X.Y.Z $HOME/cross-compile/$TARGET/build/module-X.Y.Z $HOME/cross-compile/$TARGET/usr/src/module-X.Y.Z
export TARGET=powerpc-linux export PREFIX=$HOME/cross-compile/$TARGET/install export PATH=$HOME/cross-compile/$TARGET/usr/bin:$PATH export CC=$TARGET-gcc echo "Cross Compile Envirnment for $TARGET"
./configure --target=$TARGET --prefix=$PREFIX/binutils-2.21 \ --enable-shared \ --disable-nls #native language support. This is for i18n \
./configure --target=$TARGET --prefix=$PREFIX/gcc-4.1.2 \ --enable-shared \ --disable-nls \ --with-as=/home/hideo/cross-compile/powerpc-linux/usr/bin/powerpc-linux-as \ --with-ld=/home/hideo/cross-compile/powerpc-linux/usr/bin/powerpc-linux-ld \ --with-headers=$HOME/runtime/include \ --with-libs=$HOME/runtime/lib \ --enable-language=c,c++
./configure --target=$TARGET --prefix=$PREFIX/libexif-0.6.20 \ --host=$TARGET \ --disable-nls
./configure --host=$TARGET --prefix=$PREFIX/jpeg-8b
./configure --prefix=$PREFIX/zlib-1.2.5
./configure --host=$TARGET --prefix=$PREFIX/libid3tag-0.15.1b
./configure --host=$TARGET --prefix=$PREFIX/libogg-1.2.2
./configure --host=$TARGET --prefix=$PREFIX/flac-1.2.1 \ --disable-cpplibs
./configure --host=$TARGET --prefix=$PREFIX/libvorbis
./configure --host=$TARGET --prefix=$PREFIX/sqlite-autoconf-3070400
runtime環境でライブラリのパスを修正していないと、正しいライブラリとリンクしてくれないので注意
./configure --arch=$TARGET --prefix=$PREFIX/ffmpeg-0.6.1 \ --enable-shared \ --enable-nonfree \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --disable-avdevice \ --disable-avcodec \ --disable-swscale \ --disable-altivec
sendfileがNAS-01Gのカーネルに実装されていないので、read writeを用いて自分で実装する必要がある。 http://www.man7.org/tlpi/code/online/dist/sockets/sendfile.c.html
void
send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset)
{
off_t orig;
char buf[MAX_BUFFER_SIZE];
size_t toRead, numRead, numSent, totSent;
if (offset != NULL) {
/* Save current file offset and set offset to value in '*offset' */
orig = lseek(sendfd, 0, SEEK_CUR);
if (orig == -1)
return -1;
if (lseek(sendfd, offset, SEEK_SET) == -1)
return -1;
}
totSent = 0;
while (end_offset > 0) {
toRead = end_offset < MAX_BUFFER_SIZE ? end_offset : MAX_BUFFER_SIZE;
numRead = read(sendfd, buf, toRead);
if (numRead == -1)
return -1;
if (numRead == 0)
break; /* EOF */
numSent = write(h->socket, buf, numRead);
if (numSent == -1)
return -1;
if (numSent == 0) /* Should never happen */
DPRINTF(E_ERROR, L_HTTP, "sendfile: write() transferred 0 bytes");
end_offset -= numSent;
totSent += numSent;
}
if (offset != NULL) {
/* Return updated file offset in '*offset', and reset the file offset
to the value it had when we were called. */
offset = lseek(sendfd, 0, SEEK_CUR);
if (offset == -1)
return -1;
if (lseek(sendfd, orig, SEEK_SET) == -1)
return -1;
}
}