Lukas Jirkovsky - 2012-07-21

I'm studying the code, because I want to add transcode support to minidlna (IMO the existing patch is not flexible enough + it doesn't  support image transcoding). During that I found a code that seems a bit strange to me. It is the code around the line 930 in metadata.c:

    /* NOTE: The DLNA spec only provides for ASF (WMV), TS, PS, and MP4 containers.
     * Skip DLNA parsing for everything else. */
    if( strcmp(ctx->iformat->name, "avi") == 0 )
    else if( strcmp(ctx->iformat->name, "mov,mp4,m4a,3gp,3g2,mj2") == 0 &&
        ends_with(path, ".mov") )
        xasprintf(&m.mime, "video/quicktime");
    else if( strncmp(ctx->iformat->name, "matroska", 8) == 0 )
        xasprintf(&m.mime, "video/x-matroska");
    else if( strcmp(ctx->iformat->name, "flv") == 0 )
        xasprintf(&m.mime, "video/x-flv");
    if( m.mime )
        goto video_no_dlna;

If the containers different than ASF/TS/PS/MP4 really needs to be skipped, the current code may not cover all possible containers. In that case doing the check the other way round (check explicitly if it's one of the containers specified by DLNA spec and otherwise use goto video_no_dlna) would probably work better.

I also tried changing the last condition to if(! m.mime ), and it still works with the testing files I use, as my TV supports both mkv and flv. Maybe this check is not needed at all, because some clients supports more containers than the ones listed in the DLNA spec.