xbmsd – Xbox Media Streaming Daemon
xbmsd is a file sharing server implementing the Xbox Media Streaming Protocol (XBMSP) supported by the Xbox Media Center (XBMC). URLs in XboxMediaCenter.xml that start with "xbms://" use this protocol. xbmsd also supports the XBMSP Server Discovery Protocol (XBSDP).
The main features of xbmsd besides normal file sharing is mapping files to arbitrary local files or HTTP files/streams, the possibility of generating "synthetic" mplayer configuration files according to file extension and the possibility of specifying file processing filters by file extension. Mapping files to HTTP locations is useful because XBMC does not support HTTP locations natively. Synthetic configuration files mean that files ending in a specified extension will all have a file-specific mplayer configuration file visible through xbmsd. If one does not already exist (real or mapped), it is mapped to the file specified in the specification command. Filters work so that if a file has the specified extension the filename is given as an argument to the specified command and the command output is sent to the XBMSP client as a stream.
Usage Example
Let's assume that we have a HTTP server running on localhost port 3000 that provides access to DVB TV channels via files /ts/channel. These are interlaced MPEG transport streams (TS), so we want to map these to local files and then create synthetic deinterlacing configuration files for them.
First we create a mplayer configuration file (/etc/xbmsd/deinterlace.conf) that turns on linear blend deinterlacing and sets the cache to a lower value so that the buffering does not take so long. The contents of the file is:
vf-pre=pp=lb cache=2048
Then we create the xbmsd configuration file that maps the DVB streams to local files and configures the above file as a synthetic configuration file for files ending in ".ts". We use an empty root directory since we don't want to do anything else at this time:
root /var/empty map ch1.ts http://localhost:3000/ts/1 map ch2.ts http://localhost:3000/ts/2 map ch3.ts http://localhost:3000/ts/3 conf ts /etc/xbmsd/deinterlace.conf
When xbmsd is started with this configuration the root directory of the server contains six files: ch1.ts, ch1.ts.conf, ch2.ts, ch2.ts.conf, ch3.ts, ch3.ts.conf. For more information see the manual page.
Usage example: filters
One of the downsides in using (the original) Xbox as a media player is that it chokes on the very CPU-intesive H.264 video codec. However, if the file server is sufficiently powerful there is a solution: re-encode the H.264 media file on the fly to something the Xbox can handle. To do this with a xbmsd filter the file server must be capable of doing the re-encoding in real-time, preferably a bit faster. Doing the re-encoding on the fly has the advantages that there is no need to wait for the re-encoding to finish and no additional disk space is needed. The disadvantage is that as the re-encoded content is only present as a stream, it cannot be seeked.
First we need the filter program which accepts the file name as the first argument and outputs the re-encoded content to stdout. In this example we use the reencpipe.sh shell script which uses mencoder for the re-encoding. The encoding part uses FFMPEG which is very fast. We assume that AVI, OGM and MKV are the container formats that can have H.264 video track. Not all of them have one, so we specify the filter program as a relative file name and symlink (or copy) the filter program to those directories that need a filter (if the filter program does not exist then the files are served as normal). As mencoder produces output in AVI format the option seek_streams must be off (which is the default) for this to work. This filter is specified with the following line in the configuration file:
filter avi,ogm,mkv reencpipe.sh