* Fallback code for duplicate audio/video extensions (.mp4).
* Fix a couple potential very small memory leaks in the scanner.
This commit is contained in:
parent
e6aa386f77
commit
9eb6f81a64
22
metadata.c
22
metadata.c
@ -169,7 +169,8 @@ GetAudioMetadata(const char * path, char * name)
|
|||||||
|
|
||||||
if( readtags((char *)path, &song, &file, NULL, type) != 0 )
|
if( readtags((char *)path, &song, &file, NULL, type) != 0 )
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_GENERAL, "Cannot extract tags from %s\n", path);
|
DPRINTF(E_WARN, L_GENERAL, "Cannot extract tags from %s!\n", path);
|
||||||
|
freetags(&song);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,7 +464,7 @@ GetVideoMetadata(const char * path, char * name)
|
|||||||
memset(&m, '\0', sizeof(m));
|
memset(&m, '\0', sizeof(m));
|
||||||
date[0] = '\0';
|
date[0] = '\0';
|
||||||
|
|
||||||
DPRINTF(E_DEBUG, L_METADATA, "Parsing %s...\n", path);
|
DPRINTF(E_DEBUG, L_METADATA, "Parsing video %s...\n", path);
|
||||||
if ( stat(path, &file) == 0 )
|
if ( stat(path, &file) == 0 )
|
||||||
{
|
{
|
||||||
modtime = localtime(&file.st_mtime);
|
modtime = localtime(&file.st_mtime);
|
||||||
@ -474,8 +475,11 @@ GetVideoMetadata(const char * path, char * name)
|
|||||||
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %d\n", size);
|
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %d\n", size);
|
||||||
|
|
||||||
av_register_all();
|
av_register_all();
|
||||||
if( av_open_input_file(&ctx, path, NULL, 0, NULL) == 0 )
|
if( av_open_input_file(&ctx, path, NULL, 0, NULL) != 0 )
|
||||||
{
|
{
|
||||||
|
DPRINTF(E_WARN, L_METADATA, "Opening %s failed!\n", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
av_find_stream_info(ctx);
|
av_find_stream_info(ctx);
|
||||||
//dump_format(ctx, 0, NULL, 0);
|
//dump_format(ctx, 0, NULL, 0);
|
||||||
for( i=0; i<ctx->nb_streams; i++)
|
for( i=0; i<ctx->nb_streams; i++)
|
||||||
@ -493,6 +497,13 @@ GetVideoMetadata(const char * path, char * name)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* This must not be a video file. */
|
||||||
|
if( video_stream == -1 )
|
||||||
|
{
|
||||||
|
av_close_input_file(ctx);
|
||||||
|
DPRINTF(E_WARN, L_METADATA, "File %s does not contain a video stream!\n", path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if( audio_stream >= 0 )
|
if( audio_stream >= 0 )
|
||||||
{
|
{
|
||||||
switch( ctx->streams[audio_stream]->codec->codec_id )
|
switch( ctx->streams[audio_stream]->codec->codec_id )
|
||||||
@ -829,11 +840,6 @@ GetVideoMetadata(const char * path, char * name)
|
|||||||
asprintf(&m.mime, "video/mp4");
|
asprintf(&m.mime, "video/mp4");
|
||||||
}
|
}
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DPRINTF(E_WARN, L_METADATA, "Opening %s failed!\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
sql = sqlite3_mprintf( "INSERT into DETAILS"
|
sql = sqlite3_mprintf( "INSERT into DETAILS"
|
||||||
" (PATH, SIZE, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION,"
|
" (PATH, SIZE, DURATION, DATE, CHANNELS, BITRATE, SAMPLERATE, RESOLUTION,"
|
||||||
|
20
scanner.c
20
scanner.c
@ -432,6 +432,7 @@ insert_file(char * name, const char * path, const char * parentID, int object)
|
|||||||
char * typedir_parentID;
|
char * typedir_parentID;
|
||||||
int typedir_objectID;
|
int typedir_objectID;
|
||||||
char * baseid;
|
char * baseid;
|
||||||
|
char * orig_name = NULL;
|
||||||
|
|
||||||
if( is_image(name) )
|
if( is_image(name) )
|
||||||
{
|
{
|
||||||
@ -439,18 +440,23 @@ insert_file(char * name, const char * path, const char * parentID, int object)
|
|||||||
strcpy(class, "item.imageItem.photo");
|
strcpy(class, "item.imageItem.photo");
|
||||||
detailID = GetImageMetadata(path, name);
|
detailID = GetImageMetadata(path, name);
|
||||||
}
|
}
|
||||||
else if( is_audio(name) )
|
else if( is_video(name) )
|
||||||
|
{
|
||||||
|
orig_name = strdup(name);
|
||||||
|
strcpy(base, VIDEO_DIR_ID);
|
||||||
|
strcpy(class, "item.videoItem");
|
||||||
|
detailID = GetVideoMetadata(path, name);
|
||||||
|
if( !detailID )
|
||||||
|
strcpy(name, orig_name);
|
||||||
|
}
|
||||||
|
if( !detailID && is_audio(name) )
|
||||||
{
|
{
|
||||||
strcpy(base, MUSIC_DIR_ID);
|
strcpy(base, MUSIC_DIR_ID);
|
||||||
strcpy(class, "item.audioItem.musicTrack");
|
strcpy(class, "item.audioItem.musicTrack");
|
||||||
detailID = GetAudioMetadata(path, name);
|
detailID = GetAudioMetadata(path, name);
|
||||||
}
|
}
|
||||||
if( !detailID && is_video(name) )
|
if( orig_name )
|
||||||
{
|
free(orig_name);
|
||||||
strcpy(base, VIDEO_DIR_ID);
|
|
||||||
strcpy(class, "item.videoItem");
|
|
||||||
detailID = GetVideoMetadata(path, name);
|
|
||||||
}
|
|
||||||
if( !detailID )
|
if( !detailID )
|
||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_SCANNER, "Unsuccessful getting details for %s!\n", path);
|
DPRINTF(E_WARN, L_SCANNER, "Unsuccessful getting details for %s!\n", path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user