[DEV] corect matrovska mine type

This commit is contained in:
Edouard DUPIN 2015-11-10 14:23:03 +01:00
parent f0a67e540c
commit 10c25b8015
2 changed files with 28 additions and 32 deletions

View File

@ -58,23 +58,19 @@ getExtension (const char *filename)
return str; return str;
} }
static struct mime_type_t * static struct mime_type_t * getMimeType (const char *extension) {
getMimeType (const char *extension)
{
extern struct mime_type_t MIME_Type_List[]; extern struct mime_type_t MIME_Type_List[];
struct mime_type_t *list; struct mime_type_t *list;
if (!extension) {
if (!extension)
return NULL; return NULL;
}
list = MIME_Type_List; list = MIME_Type_List;
while (list->extension) while (list->extension) {
{ if (!strcasecmp (list->extension, extension)) {
if (!strcasecmp (list->extension, extension))
return list; return list;
}
list++; list++;
} }
return NULL; return NULL;
} }
@ -163,17 +159,21 @@ convert_xml (const char *title)
static struct mime_type_t Container_MIME_Type = static struct mime_type_t Container_MIME_Type =
{ NULL, "object.container.storageFolder", NULL}; { NULL, "object.container.storageFolder", NULL};
static struct upnp_entry_t * static struct upnp_entry_t * upnp_entry_new(struct ushare_t *ut,
upnp_entry_new (struct ushare_t *ut, const char *name, const char *fullpath, const char *name,
struct upnp_entry_t *parent, off_t size, int dir) const char *fullpath,
struct upnp_entry_t *parent,
off_t size,
int dir)
{ {
struct upnp_entry_t *entry = NULL; struct upnp_entry_t *entry = NULL;
char *title = NULL, *x = NULL; char *title = NULL, *x = NULL;
char url_tmp[MAX_URL_SIZE] = { '\0' }; char url_tmp[MAX_URL_SIZE] = { '\0' };
char *title_or_name = NULL; char *title_or_name = NULL;
if (!name) if (!name) {
return NULL; return NULL;
}
entry = (struct upnp_entry_t *) malloc (sizeof (struct upnp_entry_t)); entry = (struct upnp_entry_t *) malloc (sizeof (struct upnp_entry_t));
@ -192,36 +192,32 @@ upnp_entry_new (struct ushare_t *ut, const char *name, const char *fullpath,
} }
#endif /* HAVE_DLNA */ #endif /* HAVE_DLNA */
if (ut->xbox360) if (ut->xbox360) {
{ if (ut->root_entry) {
if (ut->root_entry)
entry->id = ut->starting_id + ut->nr_entries++; entry->id = ut->starting_id + ut->nr_entries++;
else } else {
entry->id = 0; /* Creating the root node so don't use the usual IDs */ entry->id = 0; /* Creating the root node so don't use the usual IDs */
} }
else } else {
entry->id = ut->starting_id + ut->nr_entries++; entry->id = ut->starting_id + ut->nr_entries++;
}
entry->fullpath = fullpath ? strdup (fullpath) : NULL; entry->fullpath = fullpath ? strdup (fullpath) : NULL;
entry->parent = parent; entry->parent = parent;
entry->child_count = dir ? 0 : -1; entry->child_count = dir ? 0 : -1;
entry->title = NULL; entry->title = NULL;
entry->childs = (struct upnp_entry_t **) entry->childs = (struct upnp_entry_t **)
malloc (sizeof (struct upnp_entry_t *)); malloc (sizeof (struct upnp_entry_t *));
*(entry->childs) = NULL; *(entry->childs) = NULL;
if (!dir) /* item */ if (!dir) /* item */ {
{
#ifdef HAVE_DLNA #ifdef HAVE_DLNA
if (ut->dlna_enabled) if (ut->dlna_enabled) {
entry->mime_type = NULL; entry->mime_type = NULL;
else } else {
{
#endif /* HAVE_DLNA */ #endif /* HAVE_DLNA */
struct mime_type_t *mime = getMimeType (getExtension (name)); struct mime_type_t *mime = getMimeType(getExtension (name));
if (!mime) if (!mime) {
{
--ut->nr_entries; --ut->nr_entries;
upnp_entry_free (ut, entry); upnp_entry_free (ut, entry);
log_error ("Invalid Mime type for %s, entry ignored", name); log_error ("Invalid Mime type for %s, entry ignored", name);

View File

@ -56,7 +56,7 @@ const struct mime_type_t MIME_Type_List[] = {
{ "mp4ps", UPNP_VIDEO, "http-get:*:video/x-nerodigital-ps:"}, { "mp4ps", UPNP_VIDEO, "http-get:*:video/x-nerodigital-ps:"},
{ "ts", UPNP_VIDEO, "http-get:*:video/mpeg2:"}, { "ts", UPNP_VIDEO, "http-get:*:video/mpeg2:"},
{ "ogm", UPNP_VIDEO, "http-get:*:video/mpeg:"}, { "ogm", UPNP_VIDEO, "http-get:*:video/mpeg:"},
{ "mkv", UPNP_VIDEO, "http-get:*:video/mpeg:"}, { "mkv", UPNP_VIDEO, "http-get:*:video/x-matroska:"},
{ "rmvb", UPNP_VIDEO, "http-get:*:video/mpeg:"}, { "rmvb", UPNP_VIDEO, "http-get:*:video/mpeg:"},
{ "mov", UPNP_VIDEO, "http-get:*:video/quicktime:"}, { "mov", UPNP_VIDEO, "http-get:*:video/quicktime:"},
{ "hdmov", UPNP_VIDEO, "http-get:*:video/quicktime:"}, { "hdmov", UPNP_VIDEO, "http-get:*:video/quicktime:"},
@ -87,7 +87,7 @@ const struct mime_type_t MIME_Type_List[] = {
{ "lpcm", UPNP_AUDIO, "http-get:*:audio/l16:"}, { "lpcm", UPNP_AUDIO, "http-get:*:audio/l16:"},
{ "l16", UPNP_AUDIO, "http-get:*:audio/l16:"}, { "l16", UPNP_AUDIO, "http-get:*:audio/l16:"},
{ "wma", UPNP_AUDIO, "http-get:*:audio/x-ms-wma:"}, { "wma", UPNP_AUDIO, "http-get:*:audio/x-ms-wma:"},
{ "mka", UPNP_AUDIO, "http-get:*:audio/mpeg:"}, { "mka", UPNP_AUDIO, "http-get:*:audio/x-matroska:"},
{ "ra", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"}, { "ra", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"},
{ "rm", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"}, { "rm", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"},
{ "ram", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"}, { "ram", UPNP_AUDIO, "http-get:*:audio/x-pn-realaudio:"},