"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "metadata.c" between
minidlna-1.2.0.tar.gz and minidlna-1.2.1.tar.gz

About: ReadyMedia (formerly known as MiniDLNA) is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

metadata.c  (minidlna-1.2.0):metadata.c  (minidlna-1.2.1)
skipping to change at line 99 skipping to change at line 99
close(fd); close(fd);
if( i < 0 ) if( i < 0 )
return 0; return 0;
for( i = 0; i < MPEG_TS_PACKET_LENGTH_DLNA; i++ ) for( i = 0; i < MPEG_TS_PACKET_LENGTH_DLNA; i++ )
{ {
if( buffer[i] == MPEG_TS_SYNC_CODE ) if( buffer[i] == MPEG_TS_SYNC_CODE )
{ {
if (buffer[i + MPEG_TS_PACKET_LENGTH_DLNA] == MPEG_TS_SYN C_CODE && if (buffer[i + MPEG_TS_PACKET_LENGTH_DLNA] == MPEG_TS_SYN C_CODE &&
buffer[i + MPEG_TS_PACKET_LENGTH_DLNA*2] == MPEG_TS_S YNC_CODE) buffer[i + MPEG_TS_PACKET_LENGTH_DLNA*2] == MPEG_TS_S YNC_CODE)
{ {
*raw_packet_size = MPEG_TS_PACKET_LENGTH_DLNA; *raw_packet_size = MPEG_TS_PACKET_LENGTH_DLNA;
if (buffer[i+MPEG_TS_PACKET_LENGTH] == 0x00 && if (buffer[i+MPEG_TS_PACKET_LENGTH] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+1] == 0x00 && buffer[i+MPEG_TS_PACKET_LENGTH+1] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+2] == 0x00 && buffer[i+MPEG_TS_PACKET_LENGTH+2] == 0x00 &&
buffer[i+MPEG_TS_PACKET_LENGTH+3] == 0x00) buffer[i+MPEG_TS_PACKET_LENGTH+3] == 0x00)
return 0; return 0;
else else
return 1; return 1;
} else if (buffer[i + MPEG_TS_PACKET_LENGTH] == MPEG_TS_S YNC_CODE && } else if (buffer[i + MPEG_TS_PACKET_LENGTH] == MPEG_TS_S YNC_CODE &&
buffer[i + MPEG_TS_PACKET_LENGTH*2] == MPEG_TS _SYNC_CODE) { buffer[i + MPEG_TS_PACKET_LENGTH*2] == MPEG_TS _SYNC_CODE) {
*raw_packet_size = MPEG_TS_PACKET_LENGTH; *raw_packet_size = MPEG_TS_PACKET_LENGTH;
return 0; return 0;
} }
} }
} }
*raw_packet_size = 0; *raw_packet_size = 0;
return 0; return 0;
} }
void void
check_for_captions(const char *path, int64_t detailID) check_for_captions(const char *path, int64_t detailID)
{ {
char file[MAXPATHLEN]; char file[MAXPATHLEN];
char *p; char *p;
int ret; int ret;
strncpyt(file, path, sizeof(file)); strncpyt(file, path, sizeof(file));
p = strip_ext(file); p = strip_ext(file);
if (!p) if (!p)
p = strrchr(file, '\0'); return;
/* If we weren't given a detail ID, look for one. */ /* If we weren't given a detail ID, look for one. */
if (!detailID) if (!detailID)
{ {
detailID = sql_get_int64_field(db, "SELECT ID from DETAILS where (PATH > '%q.' and PATH <= '%q.z')" detailID = sql_get_int64_field(db, "SELECT ID from DETAILS where (PATH > '%q.' and PATH <= '%q.z')"
" and MIME glob 'video/*' limit 1", f ile, file); " and MIME glob 'video/*' limi t 1", file, file);
if (detailID <= 0) if (detailID <= 0)
{ {
//DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for capt ion %s.\n", path); //DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for capt ion %s.\n", path);
return; return;
} }
} }
strcpy(p, ".srt"); strcpy(p, ".srt");
ret = access(file, R_OK); ret = access(file, R_OK);
if (ret != 0) if (ret != 0)
skipping to change at line 177 skipping to change at line 177
char *val, *val2; char *val, *val2;
if (stat(path, &file) != 0 || if (stat(path, &file) != 0 ||
file.st_size > 65535) file.st_size > 65535)
{ {
DPRINTF(E_INFO, L_METADATA, "Not parsing very large .nfo file %s\ n", path); DPRINTF(E_INFO, L_METADATA, "Not parsing very large .nfo file %s\ n", path);
return; return;
} }
DPRINTF(E_DEBUG, L_METADATA, "Parsing .nfo file: %s\n", path); DPRINTF(E_DEBUG, L_METADATA, "Parsing .nfo file: %s\n", path);
buf = calloc(1, file.st_size + 1); buf = calloc(1, file.st_size + 1);
if (buf) if (!buf)
return; return;
nfo = fopen(path, "r"); nfo = fopen(path, "r");
if (!nfo) if (!nfo)
{ {
free(buf); free(buf);
return; return;
} }
nread = fread(&buf, 1, sizeof(buf), nfo); nread = fread(buf, 1, file.st_size, nfo);
fclose(nfo); fclose(nfo);
ParseNameValue(buf, nread, &xml, 0); ParseNameValue(buf, nread, &xml, 0);
//printf("\ttype: %s\n", GetValueFromNameValueList(&xml, "rootElement")); //printf("\ttype: %s\n", GetValueFromNameValueList(&xml, "rootElement"));
val = GetValueFromNameValueList(&xml, "title"); val = GetValueFromNameValueList(&xml, "title");
if (val) if (val)
{ {
char *esc_tag, *title; char *esc_tag, *title;
val2 = GetValueFromNameValueList(&xml, "episodetitle"); val2 = GetValueFromNameValueList(&xml, "episodetitle");
skipping to change at line 290 skipping to change at line 290
name, path, artist, artist, genre, album_art); name, path, artist, artist, genre, album_art);
if( ret != SQLITE_OK ) if( ret != SQLITE_OK )
ret = 0; ret = 0;
else else
ret = sqlite3_last_insert_rowid(db); ret = sqlite3_last_insert_rowid(db);
return ret; return ret;
} }
int64_t int64_t
GetAudioMetadata(const char *path, char *name) GetAudioMetadata(const char *path, const char *name)
{ {
char type[4]; char type[4];
static char lang[6] = { '\0' }; static char lang[6] = { '\0' };
struct stat file; struct stat file;
int64_t ret; int64_t ret;
char *esc_tag; char *esc_tag;
int i; int i;
int64_t album_art = 0; int64_t album_art = 0;
struct song_metadata song; struct song_metadata song;
metadata_t m; metadata_t m;
uint32_t free_flags = FLAG_MIME|FLAG_DURATION|FLAG_DLNA_PN|FLAG_DATE; uint32_t free_flags = FLAG_MIME|FLAG_DURATION|FLAG_DLNA_PN|FLAG_DATE;
memset(&m, '\0', sizeof(metadata_t)); memset(&m, '\0', sizeof(metadata_t));
if ( stat(path, &file) != 0 ) if ( stat(path, &file) != 0 )
return 0; return 0;
strip_ext(name);
if( ends_with(path, ".mp3") ) if( ends_with(path, ".mp3") )
{ {
strcpy(type, "mp3"); strcpy(type, "mp3");
m.mime = strdup("audio/mpeg"); m.mime = strdup("audio/mpeg");
} }
else if( ends_with(path, ".m4a") || ends_with(path, ".mp4") || else if( ends_with(path, ".m4a") || ends_with(path, ".mp4") ||
ends_with(path, ".aac") || ends_with(path, ".m4p") ) ends_with(path, ".aac") || ends_with(path, ".m4p") )
{ {
strcpy(type, "aac"); strcpy(type, "aac");
skipping to change at line 387 skipping to change at line 386
{ {
m.title = trim(song.title); m.title = trim(song.title);
if( (esc_tag = escape_tag(m.title, 0)) ) if( (esc_tag = escape_tag(m.title, 0)) )
{ {
free_flags |= FLAG_TITLE; free_flags |= FLAG_TITLE;
m.title = esc_tag; m.title = esc_tag;
} }
} }
else else
{ {
m.title = name; free_flags |= FLAG_TITLE;
m.title = strdup(name);
strip_ext(m.title);
} }
for( i = ROLE_START; i < N_ROLE; i++ ) for( i = ROLE_START; i < N_ROLE; i++ )
{ {
if( song.contributor[i] && *song.contributor[i] ) if( song.contributor[i] && *song.contributor[i] )
{ {
m.creator = trim(song.contributor[i]); m.creator = trim(song.contributor[i]);
if( strlen(m.creator) > 48 ) if( strlen(m.creator) > 48 )
{ {
m.creator = strdup("Various Artists"); m.creator = strdup("Various Artists");
free_flags |= FLAG_CREATOR; free_flags |= FLAG_CREATOR;
skipping to change at line 496 skipping to change at line 497
jmp_buf setjmp_buffer; jmp_buf setjmp_buffer;
static void static void
libjpeg_error_handler(j_common_ptr cinfo) libjpeg_error_handler(j_common_ptr cinfo)
{ {
cinfo->err->output_message (cinfo); cinfo->err->output_message (cinfo);
longjmp(setjmp_buffer, 1); longjmp(setjmp_buffer, 1);
return; return;
} }
int64_t int64_t
GetImageMetadata(const char *path, char *name) GetImageMetadata(const char *path, const char *name)
{ {
ExifData *ed; ExifData *ed;
ExifEntry *e = NULL; ExifEntry *e = NULL;
ExifLoader *l; ExifLoader *l;
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr; struct jpeg_error_mgr jerr;
FILE *infile; FILE *infile;
int width=0, height=0, thumb=0; int width=0, height=0, thumb=0;
char make[32], model[64] = {'\0'}; char make[32], model[64] = {'\0'};
char b[1024]; char b[1024];
struct stat file; struct stat file;
int64_t ret; int64_t ret;
image_s *imsrc; image_s *imsrc;
metadata_t m; metadata_t m;
uint32_t free_flags = 0xFFFFFFFF; uint32_t free_flags = 0xFFFFFFFF;
memset(&m, '\0', sizeof(metadata_t)); memset(&m, '\0', sizeof(metadata_t));
//DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing %s...\n", path); //DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing %s...\n", path);
if ( stat(path, &file) != 0 ) if ( stat(path, &file) != 0 )
return 0; return 0;
strip_ext(name);
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size); //DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size);
/* MIME hard-coded to JPEG for now, until we add PNG support */ /* MIME hard-coded to JPEG for now, until we add PNG support */
m.mime = strdup("image/jpeg"); m.mime = strdup("image/jpeg");
l = exif_loader_new(); l = exif_loader_new();
exif_loader_write_file(l, path); exif_loader_write_file(l, path);
ed = exif_loader_get_data(l); ed = exif_loader_get_data(l);
exif_loader_unref(l); exif_loader_unref(l);
if( !ed ) if( !ed )
skipping to change at line 642 skipping to change at line 642
free_metadata(&m, free_flags); free_metadata(&m, free_flags);
return 0; return 0;
} }
if( width <= 640 && height <= 480 ) if( width <= 640 && height <= 480 )
m.dlna_pn = strdup("JPEG_SM"); m.dlna_pn = strdup("JPEG_SM");
else if( width <= 1024 && height <= 768 ) else if( width <= 1024 && height <= 768 )
m.dlna_pn = strdup("JPEG_MED"); m.dlna_pn = strdup("JPEG_MED");
else if( (width <= 4096 && height <= 4096) || !GETFLAG(DLNA_STRICT_MASK) ) else if( (width <= 4096 && height <= 4096) || !GETFLAG(DLNA_STRICT_MASK) )
m.dlna_pn = strdup("JPEG_LRG"); m.dlna_pn = strdup("JPEG_LRG");
xasprintf(&m.resolution, "%dx%d", width, height); xasprintf(&m.resolution, "%dx%d", width, height);
m.title = strdup(name);
strip_ext(m.title);
ret = sql_exec(db, "INSERT into DETAILS" ret = sql_exec(db, "INSERT into DETAILS"
" (PATH, TITLE, SIZE, TIMESTAMP, DATE, RESOLUTION," " (PATH, TITLE, SIZE, TIMESTAMP, DATE, RESOLUTION,"
" ROTATION, THUMBNAIL, CREATOR, DLNA_PN, MIME) " " ROTATION, THUMBNAIL, CREATOR, DLNA_PN, MIME) "
"VALUES" "VALUES"
" (%Q, '%q', %lld, %lld, %Q, %Q, %u, %d, %Q, %Q, %Q);" , " (%Q, '%q', %lld, %lld, %Q, %Q, %u, %d, %Q, %Q, %Q);" ,
path, name, (long long)file.st_size, (long long)file.s t_mtime, m.date, path, m.title, (long long)file.st_size, (long long)fil e.st_mtime, m.date,
m.resolution, m.rotation, thumb, m.creator, m.dlna_pn, m.mime); m.resolution, m.rotation, thumb, m.creator, m.dlna_pn, m.mime);
if( ret != SQLITE_OK ) if( ret != SQLITE_OK )
{ {
DPRINTF(E_ERROR, L_METADATA, "Error inserting details for '%s'!\n ", path); DPRINTF(E_ERROR, L_METADATA, "Error inserting details for '%s'!\n ", path);
ret = 0; ret = 0;
} }
else else
{ {
ret = sqlite3_last_insert_rowid(db); ret = sqlite3_last_insert_rowid(db);
} }
free_metadata(&m, free_flags); free_metadata(&m, free_flags);
return ret; return ret;
} }
int64_t int64_t
GetVideoMetadata(const char *path, char *name) GetVideoMetadata(const char *path, const char *name)
{ {
struct stat file; struct stat file;
int ret, i; int ret, i;
struct tm *modtime; struct tm *modtime;
AVFormatContext *ctx = NULL; AVFormatContext *ctx = NULL;
AVStream *astream = NULL, *vstream = NULL; AVStream *astream = NULL, *vstream = NULL;
int audio_stream = -1, video_stream = -1; int audio_stream = -1, video_stream = -1;
enum audio_profiles audio_profile = PROFILE_AUDIO_UNKNOWN; enum audio_profiles audio_profile = PROFILE_AUDIO_UNKNOWN;
char fourcc[4]; char fourcc[4];
int64_t album_art = 0; int64_t album_art = 0;
skipping to change at line 688 skipping to change at line 690
metadata_t m; metadata_t m;
uint32_t free_flags = 0xFFFFFFFF; uint32_t free_flags = 0xFFFFFFFF;
char *path_cpy, *basepath; char *path_cpy, *basepath;
memset(&m, '\0', sizeof(m)); memset(&m, '\0', sizeof(m));
memset(&video, '\0', sizeof(video)); memset(&video, '\0', sizeof(video));
//DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing video %s...\n", name); //DEBUG DPRINTF(E_DEBUG, L_METADATA, "Parsing video %s...\n", name);
if ( stat(path, &file) != 0 ) if ( stat(path, &file) != 0 )
return 0; return 0;
strip_ext(name);
//DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size); //DEBUG DPRINTF(E_DEBUG, L_METADATA, " * size: %jd\n", file.st_size);
ret = lav_open(&ctx, path); ret = lav_open(&ctx, path);
if( ret != 0 ) if( ret != 0 )
{ {
char err[128]; char err[128];
av_strerror(ret, err, sizeof(err)); av_strerror(ret, err, sizeof(err));
DPRINTF(E_WARN, L_METADATA, "Opening %s failed! [%s]\n", path, er r); DPRINTF(E_WARN, L_METADATA, "Opening %s failed! [%s]\n", path, er r);
return 0; return 0;
} }
skipping to change at line 1536 skipping to change at line 1537
} }
if( !m.date ) if( !m.date )
{ {
m.date = malloc(20); m.date = malloc(20);
modtime = localtime(&file.st_mtime); modtime = localtime(&file.st_mtime);
strftime(m.date, 20, "%FT%T", modtime); strftime(m.date, 20, "%FT%T", modtime);
} }
if( !m.title ) if( !m.title )
{
m.title = strdup(name); m.title = strdup(name);
strip_ext(m.title);
}
album_art = find_album_art(path, m.thumb_data, m.thumb_size); album_art = find_album_art(path, m.thumb_data, m.thumb_size);
freetags(&video); freetags(&video);
lav_close(ctx); lav_close(ctx);
ret = sql_exec(db, "INSERT into DETAILS" ret = sql_exec(db, "INSERT into DETAILS"
" (PATH, SIZE, TIMESTAMP, DURATION, DATE, CHANNELS, BI TRATE, SAMPLERATE, RESOLUTION," " (PATH, SIZE, TIMESTAMP, DURATION, DATE, CHANNELS, BI TRATE, SAMPLERATE, RESOLUTION,"
" TITLE, CREATOR, ARTIST, GENRE, COMMENT, DLNA_PN, MI ME, ALBUM_ART) " " TITLE, CREATOR, ARTIST, GENRE, COMMENT, DLNA_PN, MI ME, ALBUM_ART) "
"VALUES" "VALUES"
" (%Q, %lld, %lld, %Q, %Q, %u, %u, %u, %Q, '%q', %Q, % Q, %Q, %Q, %Q, '%q', %lld);", " (%Q, %lld, %lld, %Q, %Q, %u, %u, %u, %Q, '%q', %Q, % Q, %Q, %Q, %Q, '%q', %lld);",
 End of changes. 17 change blocks. 
15 lines changed or deleted 19 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)