streaming dlna from fedora to a Samsung TV (mediatomb)

By thomas, 14 February, 2013

I was trying to get my Samsung TV to play files from my Beefy miracle box and although it was able to connect, it would not show any files. It took a bit of hunting around but I found the following patch needed to be applied to get the files to display.

diff -ruN mediatomb.orig/tombupnp/upnp/src/genlib/net/uri/uri.c mediatomb/tombupnp/upnp/src/genlib/net/uri/uri.c
--- mediatomb.orig/tombupnp/upnp/src/genlib/net/uri/uri.c 2012-06-06 23:01:22.000000000 +0200
+++ mediatomb/tombupnp/upnp/src/genlib/net/uri/uri.c 2012-06-07 08:22:01.000000000 +0200
@@ -1042,7 +1042,8 @@
out->path_type = REL_PATH;
}

- if( ( ( begin_hostport + 1 ) < max ) && ( in[begin_hostport] == '/' )
+ //parse hostport only if scheme was found
+ if( ( begin_hostport > 0 ) && ( ( begin_hostport + 1 ) < max ) && ( in[begin_hostport] == '/' )
&& ( in[begin_hostport + 1] == '/' ) ) {
begin_hostport += 2;

@@ -1059,6 +1060,12 @@
out->hostport.text.size = 0;
out->hostport.text.buff = 0;
begin_path = begin_hostport;
+
+ //remove excessive leading slashes (fix for Samsung Smart TV 2012)
+ while( ( ( begin_path + 1 ) < max ) && ( in[begin_path] == '/' ) && ( in[begin_path + 1] == '/') ) {
+ begin_path++;
+ }
+
}

begin_fragment =

Next I needed to recompile mediatomb on fedora, to get that to work I had to modify the rpm and add another patch.

=== modified file 'src/metadata/ffmpeg_handler.cc'
--- old/src/metadata/ffmpeg_handler.cc 2010-08-25 17:07:03 +0000
+++ new/src/metadata/ffmpeg_handler.cc 2011-05-18 06:56:48 +0000
@@ -89,6 +89,35 @@

Ref sc = StringConverter::m2i();

+ /* Tabs are 4 characters here */
+ typedef struct {const char *avname; metadata_fields_t field;} mapping_t;
+ static const mapping_t mapping[] =
+ {
+ {"title", M_TITLE},
+ {"artist", M_ARTIST},
+ {"album", M_ALBUM},
+ {"date", M_DATE},
+ {"genre", M_GENRE},
+ {"comment", M_DESCRIPTION},
+ {"track", M_TRACKNUMBER},
+ {NULL, M_MAX},
+ };
+
+ if (!pFormatCtx->metadata)
+ return;
+ for (const mapping_t *m = mapping; m->avname != NULL; m++)
+ {
+ AVMetadataTag *tag = NULL;
+ tag = av_metadata_get(pFormatCtx->metadata, m->avname, NULL,
+ AV_METADATA_DONT_STRDUP_KEY | AV_METADATA_DONT_STRDUP_VAL);
+ if (tag && tag->value && tag->value[0])
+ {
+ log_debug("Added metadata %s: %s\n", m->avname, tag->value);
+ item->setMetadata(MT_KEYS[m->field].upnp,
+ sc->convert(tag->value));
+ }
+ }
+ /* Old algorithm (doesn't work with libav >= 0.7)
if (strlen(pFormatCtx->title) > 0)
{
log_debug("Added metadata title: %s\n", pFormatCtx->title);
@@ -131,6 +160,7 @@
item->setMetadata(MT_KEYS[M_TRACKNUMBER].upnp,
sc->convert(String::from(pFormatCtx->track)));
}
+ */
}

// ffmpeg library calls
@@ -178,7 +208,7 @@
for(i=0; inb_streams; i++)
{
AVStream *st = pFormatCtx->streams[i];
- if((st != NULL) && (videoset == false) && (st->codec->codec_type == CODEC_TYPE_VIDEO))
+ if((st != NULL) && (videoset == false) && (st->codec->codec_type == AVMEDIA_TYPE_VIDEO))
{
if (st->codec->codec_tag > 0)
{
@@ -209,7 +239,7 @@
*y = st->codec->height;
}
}
- if(st->codec->codec_type == CODEC_TYPE_AUDIO)
+ if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
{
// Increase number of audiochannels
audioch++;

After applying that patch the package will build. You then need to change the config.xml and set some headers so that the Samsung will see the server.

After that, my samsung was able to see the fedora box and successfully stream files, even SBS 3d files work properly.

Here is my compiled rpm for f17 and the src rpm.

mediatomb-0.12.1-22.fc17.x86_64.rpm mediatomb-0.12.1-22.fc17.src.rpm

Here is the complete config.xml

<?xml version="1.0" encoding="UTF-8"?>

MediaTomb
uuid:e779c814-8ea1-4f2f-ab97-4bf09b2a24a2
/etc/mediatomb
/usr/share/mediatomb/web

mediatomb.db

localhost
mediatomb
mediatomb

redsonic.com
105
-->

101
-->

*

video

lastfmuser
lastfmpass

/usr/share/mediatomb/js/common.js
/usr/share/mediatomb/js/playlists.js

/usr/share/mediatomb/js/import.js

audio/L16
no
yes
no

video/mpeg
yes
yes
yes