Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 522112 | Differences between
and this patch

Collapse All | Expand All

(-)a/Makefile.am (-1 / +1 lines)
Lines 47-53 minidlnad_LDADD = \ Link Here
47
	@LIBEXIF_LIBS@ \
47
	@LIBEXIF_LIBS@ \
48
	@LIBINTL@ \
48
	@LIBINTL@ \
49
	@LIBICONV@ \
49
	@LIBICONV@ \
50
	-lFLAC  $(flacoggflag) $(vorbisflag)
50
	-lFLAC  $(flacoggflag) $(vorbisflag) @LIBFFMPEGTHUMBNAILER_LIBS@
51
51
52
minidlnad_LDFLAGS = @STATIC_LDFLAGS@
52
minidlnad_LDFLAGS = @STATIC_LDFLAGS@
53
53
(-)a/albumart.c (-2 / +60 lines)
Lines 32-37 Link Here
32
32
33
#include <jpeglib.h>
33
#include <jpeglib.h>
34
34
35
#ifdef THUMBNAIL_CREATION
36
#include <libffmpegthumbnailer/videothumbnailerc.h>
37
#endif
38
35
#include "upnpglobalvars.h"
39
#include "upnpglobalvars.h"
36
#include "albumart.h"
40
#include "albumart.h"
37
#include "sql.h"
41
#include "sql.h"
Lines 345-358 found_file: Link Here
345
	return NULL;
349
	return NULL;
346
}
350
}
347
351
352
#ifdef THUMBNAIL_CREATION
353
char *
354
generate_thumbnail(const char * path)
355
{
356
	char *tfile = NULL;
357
	video_thumbnailer *vt = NULL;
358
	char cache_dir[MAXPATHLEN];
359
360
	if( art_cache_exists(path, &tfile) )
361
		return tfile;
362
363
	if ( is_video(path) )
364
	{
365
366
		vt = video_thumbnailer_create();
367
		if ( !vt )
368
		{
369
			free(tfile);
370
			return 0;
371
		}
372
		vt->thumbnail_image_type = Jpeg;
373
		vt->thumbnail_image_quality = runtime_vars.thumb_quality;
374
		vt->thumbnail_size = runtime_vars.thumb_width;
375
		vt->seek_percentage = 20;
376
		vt->overlay_film_strip = (GETFLAG(THUMB_FILMSTRIP))?1:0;
377
378
		DPRINTF(E_DEBUG, L_METADATA, "generating thumbnail: %s\n", path);
379
380
		strncpyt(cache_dir, tfile, sizeof(cache_dir));
381
		if ( !make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) &&
382
			!video_thumbnailer_generate_thumbnail_to_file(vt, path, tfile) )
383
		{
384
			video_thumbnailer_destroy(vt);
385
			return tfile;
386
		}
387
388
		video_thumbnailer_destroy(vt);
389
	}
390
	free(tfile);
391
392
	return 0;
393
}
394
#endif
395
348
int64_t
396
int64_t
349
find_album_art(const char *path, uint8_t *image_data, int image_size)
397
find_album_art(const char *path, uint8_t *image_data, int image_size)
350
{
398
{
351
	char *album_art = NULL;
399
	char *album_art = NULL;
352
	int64_t ret = 0;
400
	int64_t ret = 0;
353
401
354
	if( (image_size && (album_art = check_embedded_art(path, image_data, image_size))) ||
402
	if(image_size)
355
	    (album_art = check_for_album_file(path)) )
403
		album_art = check_embedded_art(path, image_data, image_size);
404
405
	if(!album_art)
406
		album_art = check_for_album_file(path);
407
408
#ifdef THUMBNAIL_CREATION
409
	if(!album_art && GETFLAG(THUMB_MASK))
410
		album_art = generate_thumbnail(path);
411
#endif
412
413
	if(album_art)
356
	{
414
	{
357
		ret = sql_get_int_field(db, "SELECT ID from ALBUM_ART where PATH = '%q'", album_art);
415
		ret = sql_get_int_field(db, "SELECT ID from ALBUM_ART where PATH = '%q'", album_art);
358
		if( !ret )
416
		if( !ret )
(-)a/configure.ac (+15 lines)
Lines 607-612 AC_ARG_ENABLE(static, Link Here
607
        ]
607
        ]
608
)
608
)
609
609
610
AC_ARG_ENABLE(thumbnail,
611
	[  --enable-thumbnail       enable video thumbnail generation using libffmpegthumbnailer],[
612
	if test "$enableval" = "yes"; then
613
		AC_DEFINE([THUMBNAIL_CREATION],[1],[Define to 1 if you want to enable video thumbnail generation])
614
		PKG_CHECK_MODULES([LIBFFMPEGTHUMBNAILER], libffmpegthumbnailer, ,
615
			AC_MSG_ERROR([Unable to find libffmpegthumbnailer]))
616
		AC_SUBST([LIBFFMPEGTHUMBNAILER_CFLAGS])
617
		AC_SUBST([LIBFFMPEGTHUMBNAILER_LIBS])
618
        else
619
                AC_MSG_RESULT([no])
620
        fi
621
        ],[
622
                AC_MSG_RESULT([no])
623
        ]
624
)
610
625
611
case "$target_os" in
626
case "$target_os" in
612
	darwin*)
627
	darwin*)
(-)a/inotify.c (-1 / +36 lines)
Lines 600-605 inotify_remove_file(const char * path) Link Here
600
		sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID);
600
		sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID);
601
	}
601
	}
602
	snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path);
602
	snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path);
603
604
#ifdef THUMBNAIL_CREATION
605
	/* Remove video thumbnails */
606
	if ( is_video(path) )
607
	{
608
		char *vthumb = art_cache;
609
		strcpy(strchr(vthumb, '\0')-4, ".jpg");
610
	}
611
#endif
612
603
	remove(art_cache);
613
	remove(art_cache);
604
614
605
	return 0;
615
	return 0;
Lines 649-655 start_inotify() Link Here
649
	int length, i = 0;
659
	int length, i = 0;
650
	char * esc_name = NULL;
660
	char * esc_name = NULL;
651
	struct stat st;
661
	struct stat st;
652
        
662
#ifdef THUMBNAIL_CREATION
663
	char renpath_buf[PATH_MAX];
664
	int cookie = 0;
665
#endif
666
653
	pollfds[0].fd = inotify_init();
667
	pollfds[0].fd = inotify_init();
654
	pollfds[0].events = POLLIN;
668
	pollfds[0].events = POLLIN;
655
669
Lines 710-715 start_inotify() Link Here
710
				{
724
				{
711
					DPRINTF(E_DEBUG, L_INOTIFY,  "The directory %s was %s.\n",
725
					DPRINTF(E_DEBUG, L_INOTIFY,  "The directory %s was %s.\n",
712
						path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created"));
726
						path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created"));
727
#ifdef THUMBNAIL_CREATION
728
					/* We do not want to regenerate the thumbnails if e rename a directory.
729
					   We should keep at least four cookies/olddir since IN_MOVED_FROM/IN_MOVED_TO may
730
					   not arrive in sequence, but one should cover most cases */
731
					if (event->cookie == cookie && event->mask & IN_MOVED_TO)
732
					{
733
						DPRINTF(E_DEBUG, L_INOTIFY, "Directory rename: %s -> %s \n", renpath_buf, path_buf);
734
						rename_artcache_dir(renpath_buf, path_buf);
735
					}
736
#endif
713
					inotify_insert_directory(pollfds[0].fd, esc_name, path_buf);
737
					inotify_insert_directory(pollfds[0].fd, esc_name, path_buf);
714
				}
738
				}
715
				else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) &&
739
				else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) &&
Lines 741-747 start_inotify() Link Here
741
						(event->mask & IN_ISDIR ? "directory" : "file"),
765
						(event->mask & IN_ISDIR ? "directory" : "file"),
742
						path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted"));
766
						path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted"));
743
					if ( event->mask & IN_ISDIR )
767
					if ( event->mask & IN_ISDIR )
768
#ifdef THUMBNAIL_CREATION
769
					{
770
						if ( event->mask & IN_MOVED_FROM )
771
						{
772
							strncpy(renpath_buf, path_buf, sizeof(renpath_buf));
773
							cookie = event->cookie;
774
						}
775
#endif
744
						inotify_remove_directory(pollfds[0].fd, path_buf);
776
						inotify_remove_directory(pollfds[0].fd, path_buf);
777
#ifdef THUMBNAIL_CREATION
778
					}
779
#endif
745
					else
780
					else
746
						inotify_remove_file(path_buf);
781
						inotify_remove_file(path_buf);
747
				}
782
				}
(-)a/minidlna.c (+29 lines)
Lines 532-537 init(int argc, char **argv) Link Here
532
	runtime_vars.root_container = NULL;
532
	runtime_vars.root_container = NULL;
533
	runtime_vars.ifaces[0] = NULL;
533
	runtime_vars.ifaces[0] = NULL;
534
534
535
#ifdef THUMBNAIL_CREATION
536
	runtime_vars.thumb_width = 160;
537
	runtime_vars.thumb_quality = 8;
538
#endif
539
535
	/* read options file first since
540
	/* read options file first since
536
	 * command line arguments have final say */
541
	 * command line arguments have final say */
537
	if (readoptionsfile(optionsfile) < 0)
542
	if (readoptionsfile(optionsfile) < 0)
Lines 734-739 init(int argc, char **argv) Link Here
734
			if (strtobool(ary_options[i].value))
739
			if (strtobool(ary_options[i].value))
735
				SETFLAG(MERGE_MEDIA_DIRS_MASK);
740
				SETFLAG(MERGE_MEDIA_DIRS_MASK);
736
			break;
741
			break;
742
#ifdef THUMBNAIL_CREATION
743
		case ENABLE_THUMB:
744
			if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) )
745
				SETFLAG(THUMB_MASK);
746
		break;
747
		case THUMB_WIDTH:
748
			runtime_vars.thumb_width = atoi(ary_options[i].value);
749
			if (runtime_vars.thumb_width < 120)
750
				runtime_vars.thumb_width = 120;
751
			if (runtime_vars.thumb_width > 480)
752
				runtime_vars.thumb_width = 480;
753
			break;
754
		case THUMB_QUALITY:
755
			runtime_vars.thumb_quality = atoi(ary_options[i].value);
756
			if (runtime_vars.thumb_quality < 5)
757
				runtime_vars.thumb_quality = 5;
758
			if (runtime_vars.thumb_quality > 30)
759
				runtime_vars.thumb_quality = 30;
760
		break;
761
		case ENABLE_THUMB_FILMSTRIP:
762
			if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) )
763
				SETFLAG(THUMB_FILMSTRIP);
764
		break;
765
#endif
737
		default:
766
		default:
738
			DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n",
767
			DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n",
739
				optionsfile);
768
				optionsfile);
(-)a/minidlna.conf (+12 lines)
Lines 81-83 model_number=1 Link Here
81
# maximum number of simultaneous connections
81
# maximum number of simultaneous connections
82
# note: many clients open several simultaneous connections while streaming
82
# note: many clients open several simultaneous connections while streaming
83
#max_connections=50
83
#max_connections=50
84
85
# Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time.
86
#enable_thumbnail=no
87
88
# The width of the thumbnail image. Large images takes more time to generate.  To use this option, thumbnail generation must be enable at compile time.
89
#thumbnail_width=160
90
91
# Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time.
92
#thumbnail_quality=8
93
94
# Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time.
95
#enable_thumbnail_filmstrip=no
(-)a/minidlnatypes.h (+4 lines)
Lines 51-56 struct runtime_vars_s { Link Here
51
	int max_connections;	/* max number of simultaneous conenctions */
51
	int max_connections;	/* max number of simultaneous conenctions */
52
	const char *root_container;	/* root ObjectID (instead of "0") */
52
	const char *root_container;	/* root ObjectID (instead of "0") */
53
	const char *ifaces[MAX_LAN_ADDR];	/* list of configured network interfaces */
53
	const char *ifaces[MAX_LAN_ADDR];	/* list of configured network interfaces */
54
#ifdef THUMBNAIL_CREATION
55
	int thumb_width;
56
	int thumb_quality;
57
#endif
54
};
58
};
55
59
56
struct string_s {
60
struct string_s {
(-)a/options.c (+8 lines)
Lines 64-70 static const struct { Link Here
64
	{ USER_ACCOUNT, "user" },
64
	{ USER_ACCOUNT, "user" },
65
	{ FORCE_SORT_CRITERIA, "force_sort_criteria" },
65
	{ FORCE_SORT_CRITERIA, "force_sort_criteria" },
66
	{ MAX_CONNECTIONS, "max_connections" },
66
	{ MAX_CONNECTIONS, "max_connections" },
67
#ifndef THUMBNAIL_CREATION
67
	{ MERGE_MEDIA_DIRS, "merge_media_dirs" }
68
	{ MERGE_MEDIA_DIRS, "merge_media_dirs" }
69
#else
70
	{ MERGE_MEDIA_DIRS, "merge_media_dirs" },
71
	{ ENABLE_THUMB, "enable_thumbnail" },
72
	{ THUMB_WIDTH, "thumbnail_width" },
73
	{ THUMB_QUALITY, "thumbnail_quality" },
74
	{ ENABLE_THUMB_FILMSTRIP, "enable_thumbnail_filmstrip" }
75
#endif
68
};
76
};
69
77
70
int
78
int
(-)a/options.h (+8 lines)
Lines 57-63 enum upnpconfigoptions { Link Here
57
	USER_ACCOUNT,			/* user account to run as */
57
	USER_ACCOUNT,			/* user account to run as */
58
	FORCE_SORT_CRITERIA,		/* force sorting by a given sort criteria */
58
	FORCE_SORT_CRITERIA,		/* force sorting by a given sort criteria */
59
	MAX_CONNECTIONS,		/* maximum number of simultaneous connections */
59
	MAX_CONNECTIONS,		/* maximum number of simultaneous connections */
60
#ifndef THUMBNAIL_CREATION
60
	MERGE_MEDIA_DIRS		/* don't add an extra directory level when there are multiple media dirs */
61
	MERGE_MEDIA_DIRS		/* don't add an extra directory level when there are multiple media dirs */
62
#else
63
	MERGE_MEDIA_DIRS,		/* don't add an extra directory level when there are multiple media dirs */
64
	ENABLE_THUMB,                   /* enable thumbnail generation */
65
	THUMB_WIDTH,                    /* thunbnail image with */
66
	THUMB_QUALITY,                  /* thumnail image quality */
67
	ENABLE_THUMB_FILMSTRIP          /* film strip overlay */
68
#endif
61
};
69
};
62
70
63
/* readoptionsfile()
71
/* readoptionsfile()
(-)a/upnpglobalvars.h (+4 lines)
Lines 191-196 extern uint32_t runtime_flags; Link Here
191
#define NO_PLAYLIST_MASK      0x0008
191
#define NO_PLAYLIST_MASK      0x0008
192
#define SYSTEMD_MASK          0x0010
192
#define SYSTEMD_MASK          0x0010
193
#define MERGE_MEDIA_DIRS_MASK 0x0020
193
#define MERGE_MEDIA_DIRS_MASK 0x0020
194
#ifdef THUMBNAIL_CREATION
195
#define THUMB_MASK            0x0040
196
#define THUMB_FILMSTRIP       0x0080
197
#endif
194
198
195
#define SETFLAG(mask)	runtime_flags |= mask
199
#define SETFLAG(mask)	runtime_flags |= mask
196
#define GETFLAG(mask)	(runtime_flags & mask)
200
#define GETFLAG(mask)	(runtime_flags & mask)
(-)a/utils.c (+13 lines)
Lines 501-503 resolve_unknown_type(const char * path, media_types dir_type) Link Here
501
	return type;
501
	return type;
502
}
502
}
503
503
504
#ifdef THUMBNAIL_CREATION
505
int
506
rename_artcache_dir(const char * oldpath, const char * newpath)
507
{
508
	char old_artcache[PATH_MAX];
509
	char new_artcache[PATH_MAX];
510
511
	snprintf(old_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, oldpath);
512
	snprintf(new_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, newpath);
513
514
	return rename(old_artcache, new_artcache);
515
}
516
#endif
(-)a/utils.h (+3 lines)
Lines 95-99 const char *mime_to_ext(const char * mime); Link Here
95
/* Others */
95
/* Others */
96
int make_dir(char * path, mode_t mode);
96
int make_dir(char * path, mode_t mode);
97
unsigned int DJBHash(uint8_t *data, int len);
97
unsigned int DJBHash(uint8_t *data, int len);
98
#ifdef THUMBNAIL_CREATION
99
int rename_artcache_dir(const char * oldpath, const char * newpath);
100
#endif
98
101
99
#endif
102
#endif

Return to bug 522112