gmediaserver-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gmediaserver-devel] gmediaserver with libmagic


From: Han
Subject: [gmediaserver-devel] gmediaserver with libmagic
Date: Tue, 5 Jan 2010 22:22:24 -0800

Hi,

I have upgraded my linux box from Ubuntu 9.04 to 9.10, and found
gmediaserver does not recognize MP3 files anymore.

with some debugging, it seems that now the libmagic returns a
different mime string from the ones hardcoded in gmediaserver
(metadata.c):

(gdb) p magic
$6 = 0x80930a8 "audio/mpeg; charset=binary"  <==== from libmagic
(gdb) n
358             for (c = 0; mime_map[c].mime != NULL; c++) {
(gdb) p mime_map
$7 = {{id = FILE_MP3, mime = 0x8062d1d "audio/mpeg"}, ===> from metadata.c
{id = FILE_WMA,
    mime = 0x8062d28 "audio/x-ms-wma"}, {id = FILE_RIFF_WAVE,
    mime = 0x8062d37 "audio/x-wav"}, {id = FILE_M4A,
    mime = 0x8062d43 "audio/mp4"}, {id = FILE_OGG,
    mime = 0x8062d4d "application/ogg"}, {id = FILE_MPG,
    mime = 0x8062d5d "video/mpeg"}, {id = FILE_MPG,
    mime = 0x8062d68 "video/mpv"}, {id = FILE_MPG,
    mime = 0x8062d72 "video/mp2p"}, {id = FILE_MPG,
    mime = 0x8062d7d "video/mp2t"}, {id = FILE_MP4,
    mime = 0x8062d88 "video/mp4"}, {id = FILE_MP4,
    mime = 0x8062d92 "video/mp4v-es"}, {id = FILE_MP4,
    mime = 0x8062da0 "video/h264"}, {id = FILE_MP4,
    mime = 0x8062dab "video/3gpp"}, {id = FILE_BMP,
    mime = 0x8062db6 "image/bmp"}, {id = FILE_GIF,
    mime = 0x8062dc0 "image/gif"}, {id = FILE_JPG,
    mime = 0x8062dca "image/jpeg"}, {id = FILE_PNG,
    mime = 0x8062dd5 "image/png"}, {id = FILE_TIFF,
    mime = 0x8062ddf "image/tiff"}, {id = FILE_MP3, mime = 0x0}}
(gdb)

gmediaserver compares the two as following:

<snip>
if (strcmp(magic, mime_map[c].mime) == 0)
</snip>

so if the strings don't match 100%,  it will not find the correct file
type. As shown above, libmagic seems have extra info in the string
(i.e. charset), so it failed to match.

I have put a temporary hack to work around this now:

-     if (strcmp(magic, mime_map[c].mime) == 0)
+    if (strstr(magic, mime_map[c].mime))

i.e. as long as mime_map[c].mime is a sub-string of libmagic string,
it is a match. It worked for me now.

I am wondering if this is known issue.  My gmediaserver is v0.13.0 and
libmagic seems to be  libmagic.so.1.0.0.

thanks.
Han




reply via email to

[Prev in Thread] Current Thread [Next in Thread]