From ff046503bd65e7d53c6eb502693dbf2ab86a54ea Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 1 May 2009 01:39:55 +0000 Subject: [PATCH] * Update client cache if the client type changes on a given IP. * Default .avi files to MIME type video/x-msvideo for better backward compatibility. --- metadata.c | 18 ++++++++++-------- minidlna.c | 13 +++++++++++++ upnphttp.c | 4 ++-- upnpsoap.c | 23 +++++++++++++++-------- 4 files changed, 40 insertions(+), 18 deletions(-) diff --git a/metadata.c b/metadata.c index 3910333..3214fde 100644 --- a/metadata.c +++ b/metadata.c @@ -754,17 +754,17 @@ GetVideoMetadata(const char * path, char * name) if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("XVID") ) { DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s XViD\n", video_stream, path, m.resolution); - asprintf(&m.mime, "video/divx"); + asprintf(&m.artist, "DiVX"); } else if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("DX50") ) { DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s DiVX5\n", video_stream, path, m.resolution); - asprintf(&m.mime, "video/divx"); + asprintf(&m.artist, "DiVX"); } else if( ctx->streams[video_stream]->codec->codec_tag == get_fourcc("DIVX") ) { DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is DiVX\n", video_stream, path); - asprintf(&m.mime, "video/divx"); + asprintf(&m.artist, "DiVX"); } else { @@ -832,7 +832,7 @@ GetVideoMetadata(const char * path, char * name) } break; case CODEC_ID_MSMPEG4V3: - asprintf(&m.mime, "video/avi"); + asprintf(&m.mime, "video/x-msvideo"); default: DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n", video_stream, path, m.resolution, ctx->streams[video_stream]->codec->codec_id); break; @@ -841,7 +841,7 @@ GetVideoMetadata(const char * path, char * name) if( !m.mime ) { if( strcmp(ctx->iformat->name, "avi") == 0 ) - asprintf(&m.mime, "video/avi"); + asprintf(&m.mime, "video/x-msvideo"); else if( strcmp(ctx->iformat->name, "mpegts") == 0 ) asprintf(&m.mime, "video/mpeg"); else if( strcmp(ctx->iformat->name, "mpeg") == 0 ) @@ -867,13 +867,13 @@ GetVideoMetadata(const char * path, char * name) #endif sql = sqlite3_mprintf( "INSERT into DETAILS" " (PATH, SIZE, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION," - " TITLE, DLNA_PN, MIME) " + " CREATOR, TITLE, DLNA_PN, MIME) " "VALUES" - " (%Q, %lld, %Q, %Q, %Q, %Q, %Q, %Q, '%q', %Q, '%q');", + " (%Q, %lld, %Q, %Q, %Q, %Q, %Q, %Q, %Q, '%q', %Q, '%q');", path, size, m.duration, strlen(date) ? date : NULL, m.channels, m.bitrate, m.frequency, m.resolution, - name, m.dlna_pn, m.mime); + m.artist, name, m.dlna_pn, m.mime); //DEBUG DPRINTF(E_DEBUG, L_METADATA, "SQL: %s\n", sql); if( sql_exec(db, sql) != SQLITE_OK ) { @@ -901,6 +901,8 @@ GetVideoMetadata(const char * path, char * name) free(m.bps); if( m.channels ) free(m.channels); + if( m.artist ) + free(m.artist); return ret; } diff --git a/minidlna.c b/minidlna.c index a119c99..72eb3ae 100644 --- a/minidlna.c +++ b/minidlna.c @@ -926,6 +926,19 @@ shutdown: free(sql); sqlite3_close(db); + struct media_dir_s * media_path = media_dirs; + while( media_path ) + { + free(media_path->path); + media_path = media_path->next; + } + struct album_art_name_s * art_names = album_art_names; + while( art_names ) + { + free(art_names->name); + art_names = art_names->next; + } + if(unlink(pidfilename) < 0) { DPRINTF(E_ERROR, L_GENERAL, "Failed to remove pidfile %s: %s\n", pidfilename, strerror(errno)); diff --git a/upnphttp.c b/upnphttp.c index fa1d953..eeb56f4 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -305,12 +305,12 @@ intervening space) by either an integer or the keyword "infinite". */ if( clients[n].addr.s_addr ) continue; clients[n].addr = h->clientaddr; - clients[n].type = h->req_client; DPRINTF(E_DEBUG, L_HTTP, "Added client [%d/%X] to cache slot %d.\n", - clients[n].type, clients[n].addr.s_addr, n); + h->req_client, clients[n].addr.s_addr, n); break; } } + clients[n].type = h->req_client; clients[n].age = time(NULL); } else if( n >= 0 ) diff --git a/upnpsoap.c b/upnpsoap.c index c6b4af9..7038da5 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -446,15 +446,22 @@ callback(void *args, int argc, char **argv, char **azColName) if( strncmp(class, "item", 4) == 0 ) { - if( passed_args->client == EXbox ) + switch( passed_args->client ) { - if( strcmp(mime, "video/divx") == 0 ) - { - mime[6] = 'a'; - mime[7] = 'v'; - mime[8] = 'i'; - mime[9] = '\0'; - } + case EPS3: + if( creator && (strcmp(mime, "video/x-msvideo") == 0) ) + { + strcpy(mime+6, "divx"); + break; + } + case EXbox: + if( strcmp(mime, "video/x-msvideo") == 0 ) + { + strcpy(mime+6, "avi"); + } + break; + default: + break; } ret = sprintf(str_buf, "<item id=\"%s\" parentID=\"%s\" restricted=\"1\"", id, parent); memcpy(passed_args->resp+passed_args->size, &str_buf, ret+1);