* 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.
This commit is contained in:
Justin Maggard 2009-05-01 01:39:55 +00:00
parent f35e0831d1
commit ff046503bd
4 changed files with 40 additions and 18 deletions

View File

@ -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;
}

View File

@ -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));

View File

@ -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 )

View File

@ -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, "&lt;item id=\"%s\" parentID=\"%s\" restricted=\"1\"", id, parent);
memcpy(passed_args->resp+passed_args->size, &str_buf, ret+1);