[11754] | 1 | --- Makefile.am.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 2 | +++ Makefile.am 2017-05-26 13:51:55.519612115 +0900 |
---|
| 3 | @@ -53,7 +53,7 @@ |
---|
| 4 | @LIBEXIF_LIBS@ \ |
---|
| 5 | @LIBINTL@ \ |
---|
| 6 | @LIBICONV@ \ |
---|
| 7 | - -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) |
---|
| 8 | + -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) @LIBFFMPEGTHUMBNAILER_LIBS@ |
---|
| 9 | |
---|
| 10 | minidlnad_LDFLAGS = @STATIC_LDFLAGS@ |
---|
| 11 | |
---|
| 12 | --- albumart.c.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 13 | +++ albumart.c 2017-05-26 14:03:52.661089877 +0900 |
---|
| 14 | @@ -32,6 +32,10 @@ |
---|
| 15 | |
---|
| 16 | #include <jpeglib.h> |
---|
| 17 | |
---|
| 18 | +#ifdef THUMBNAIL_CREATION |
---|
| 19 | +#include <libffmpegthumbnailer/videothumbnailerc.h> |
---|
| 20 | +#endif |
---|
| 21 | + |
---|
| 22 | #include "upnpglobalvars.h" |
---|
| 23 | #include "albumart.h" |
---|
| 24 | #include "sql.h" |
---|
| 25 | @@ -348,14 +352,68 @@ |
---|
| 26 | return NULL; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | +#ifdef THUMBNAIL_CREATION |
---|
| 30 | +char * |
---|
| 31 | +generate_thumbnail(const char * path) |
---|
| 32 | +{ |
---|
| 33 | + char *tfile = NULL; |
---|
| 34 | + video_thumbnailer *vt = NULL; |
---|
| 35 | + char cache_dir[MAXPATHLEN]; |
---|
| 36 | + |
---|
| 37 | + if( art_cache_exists(path, &tfile) ) |
---|
| 38 | + return tfile; |
---|
| 39 | + |
---|
| 40 | + if ( is_video(path) ) |
---|
| 41 | + { |
---|
| 42 | + |
---|
| 43 | + vt = video_thumbnailer_create(); |
---|
| 44 | + if ( !vt ) |
---|
| 45 | + { |
---|
| 46 | + free(tfile); |
---|
| 47 | + return 0; |
---|
| 48 | + } |
---|
| 49 | + vt->thumbnail_image_type = Jpeg; |
---|
| 50 | + vt->thumbnail_image_quality = runtime_vars.thumb_quality; |
---|
| 51 | + vt->thumbnail_size = runtime_vars.thumb_width; |
---|
| 52 | + vt->seek_percentage = 20; |
---|
| 53 | + vt->overlay_film_strip = (GETFLAG(THUMB_FILMSTRIP))?1:0; |
---|
| 54 | + |
---|
| 55 | + DPRINTF(E_DEBUG, L_METADATA, "generating thumbnail: %s\n", path); |
---|
| 56 | + |
---|
| 57 | + strncpyt(cache_dir, tfile, sizeof(cache_dir)); |
---|
| 58 | + if ( !make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) && |
---|
| 59 | + !video_thumbnailer_generate_thumbnail_to_file(vt, path, tfile) ) |
---|
| 60 | + { |
---|
| 61 | + video_thumbnailer_destroy(vt); |
---|
| 62 | + return tfile; |
---|
| 63 | + } |
---|
| 64 | + |
---|
| 65 | + video_thumbnailer_destroy(vt); |
---|
| 66 | + } |
---|
| 67 | + free(tfile); |
---|
| 68 | + |
---|
| 69 | + return 0; |
---|
| 70 | +} |
---|
| 71 | +#endif |
---|
| 72 | + |
---|
| 73 | int64_t |
---|
| 74 | find_album_art(const char *path, uint8_t *image_data, int image_size) |
---|
| 75 | { |
---|
| 76 | char *album_art = NULL; |
---|
| 77 | int64_t ret = 0; |
---|
| 78 | |
---|
| 79 | - if( (image_size && (album_art = check_embedded_art(path, image_data, image_size))) || |
---|
| 80 | - (album_art = check_for_album_file(path)) ) |
---|
| 81 | + if(image_size) |
---|
| 82 | + album_art = check_embedded_art(path, image_data, image_size); |
---|
| 83 | + |
---|
| 84 | + if(!album_art) |
---|
| 85 | + album_art = check_for_album_file(path); |
---|
| 86 | + |
---|
| 87 | +#ifdef THUMBNAIL_CREATION |
---|
| 88 | + if(!album_art && GETFLAG(THUMB_MASK)) |
---|
| 89 | + album_art = generate_thumbnail(path); |
---|
| 90 | +#endif |
---|
| 91 | + |
---|
| 92 | + if(album_art) |
---|
| 93 | { |
---|
| 94 | ret = sql_get_int_field(db, "SELECT ID from ALBUM_ART where PATH = '%q'", album_art); |
---|
| 95 | if( !ret ) |
---|
| 96 | --- configure.ac.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 97 | +++ configure.ac 2017-05-26 14:08:49.528778727 +0900 |
---|
| 98 | @@ -617,6 +617,21 @@ |
---|
| 99 | ] |
---|
| 100 | ) |
---|
| 101 | |
---|
| 102 | +AC_ARG_ENABLE(thumbnail, |
---|
| 103 | + [ --enable-thumbnail enable video thumbnail generation using libffmpegthumbnailer],[ |
---|
| 104 | + if test "$enableval" = "yes"; then |
---|
| 105 | + AC_DEFINE([THUMBNAIL_CREATION],[1],[Define to 1 if you want to enable video thumbnail generation]) |
---|
| 106 | + PKG_CHECK_MODULES([LIBFFMPEGTHUMBNAILER], libffmpegthumbnailer, , |
---|
| 107 | + AC_MSG_ERROR([Unable to find libffmpegthumbnailer])) |
---|
| 108 | + AC_SUBST([LIBFFMPEGTHUMBNAILER_CFLAGS]) |
---|
| 109 | + AC_SUBST([LIBFFMPEGTHUMBNAILER_LIBS]) |
---|
| 110 | + else |
---|
| 111 | + AC_MSG_RESULT([no]) |
---|
| 112 | + fi |
---|
| 113 | + ],[ |
---|
| 114 | + AC_MSG_RESULT([no]) |
---|
| 115 | + ] |
---|
| 116 | +) |
---|
| 117 | |
---|
| 118 | case "$target_os" in |
---|
| 119 | darwin*) |
---|
| 120 | --- minidlna.c.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 121 | +++ minidlna.c 2017-05-26 14:48:58.925667651 +0900 |
---|
| 122 | @@ -539,6 +539,11 @@ |
---|
| 123 | runtime_vars.root_container = NULL; |
---|
| 124 | runtime_vars.ifaces[0] = NULL; |
---|
| 125 | |
---|
| 126 | +#ifdef THUMBNAIL_CREATION |
---|
| 127 | + runtime_vars.thumb_width = 160; |
---|
| 128 | + runtime_vars.thumb_quality = 8; |
---|
| 129 | +#endif |
---|
| 130 | + |
---|
| 131 | /* read options file first since |
---|
| 132 | * command line arguments have final say */ |
---|
| 133 | if (readoptionsfile(optionsfile) < 0) |
---|
| 134 | @@ -752,6 +757,30 @@ |
---|
| 135 | if (strcasecmp(ary_options[i].value, "beacon") == 0) |
---|
| 136 | CLEARFLAG(TIVO_BONJOUR_MASK); |
---|
| 137 | break; |
---|
| 138 | +#ifdef THUMBNAIL_CREATION |
---|
| 139 | + case ENABLE_THUMB: |
---|
| 140 | + if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) |
---|
| 141 | + SETFLAG(THUMB_MASK); |
---|
| 142 | + break; |
---|
| 143 | + case THUMB_WIDTH: |
---|
| 144 | + runtime_vars.thumb_width = atoi(ary_options[i].value); |
---|
| 145 | + if (runtime_vars.thumb_width < 120) |
---|
| 146 | + runtime_vars.thumb_width = 120; |
---|
| 147 | + if (runtime_vars.thumb_width > 480) |
---|
| 148 | + runtime_vars.thumb_width = 480; |
---|
| 149 | + break; |
---|
| 150 | + case THUMB_QUALITY: |
---|
| 151 | + runtime_vars.thumb_quality = atoi(ary_options[i].value); |
---|
| 152 | + if (runtime_vars.thumb_quality < 5) |
---|
| 153 | + runtime_vars.thumb_quality = 5; |
---|
| 154 | + if (runtime_vars.thumb_quality > 30) |
---|
| 155 | + runtime_vars.thumb_quality = 30; |
---|
| 156 | + break; |
---|
| 157 | + case ENABLE_THUMB_FILMSTRIP: |
---|
| 158 | + if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) |
---|
| 159 | + SETFLAG(THUMB_FILMSTRIP); |
---|
| 160 | + break; |
---|
| 161 | +#endif |
---|
| 162 | default: |
---|
| 163 | DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n", |
---|
| 164 | optionsfile); |
---|
| 165 | --- minidlna.conf.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 166 | +++ minidlna.conf 2017-05-26 14:52:57.185771270 +0900 |
---|
| 167 | @@ -88,3 +88,15 @@ |
---|
| 168 | |
---|
| 169 | # set this to yes to allow symlinks that point outside user-defined media_dirs. |
---|
| 170 | #wide_links=no |
---|
| 171 | + |
---|
| 172 | +# Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time. |
---|
| 173 | +#enable_thumbnail=no |
---|
| 174 | + |
---|
| 175 | +# 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. |
---|
| 176 | +#thumbnail_width=160 |
---|
| 177 | + |
---|
| 178 | +# Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time. |
---|
| 179 | +#thumbnail_quality=8 |
---|
| 180 | + |
---|
| 181 | +# Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time. |
---|
| 182 | +#enable_thumbnail_filmstrip=no |
---|
| 183 | --- options.c.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 184 | +++ options.c 2017-05-26 14:56:38.408012333 +0900 |
---|
| 185 | @@ -64,7 +64,15 @@ |
---|
| 186 | { USER_ACCOUNT, "user" }, |
---|
| 187 | { FORCE_SORT_CRITERIA, "force_sort_criteria" }, |
---|
| 188 | { MAX_CONNECTIONS, "max_connections" }, |
---|
| 189 | +#ifndef THUMBNAIL_CREATION |
---|
| 190 | { MERGE_MEDIA_DIRS, "merge_media_dirs" }, |
---|
| 191 | +#else |
---|
| 192 | + { MERGE_MEDIA_DIRS, "merge_media_dirs" }, |
---|
| 193 | + { ENABLE_THUMB, "enable_thumbnail" }, |
---|
| 194 | + { THUMB_WIDTH, "thumbnail_width" }, |
---|
| 195 | + { THUMB_QUALITY, "thumbnail_quality" }, |
---|
| 196 | + { ENABLE_THUMB_FILMSTRIP, "enable_thumbnail_filmstrip" }, |
---|
| 197 | +#endif |
---|
| 198 | { WIDE_LINKS, "wide_links" }, |
---|
| 199 | { TIVO_DISCOVERY, "tivo_discovery" }, |
---|
| 200 | }; |
---|
| 201 | --- options.h.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 202 | +++ options.h 2017-05-26 15:07:15.637791194 +0900 |
---|
| 203 | @@ -57,7 +57,15 @@ |
---|
| 204 | USER_ACCOUNT, /* user account to run as */ |
---|
| 205 | FORCE_SORT_CRITERIA, /* force sorting by a given sort criteria */ |
---|
| 206 | MAX_CONNECTIONS, /* maximum number of simultaneous connections */ |
---|
| 207 | +#ifndef THUMBNAIL_CREATION |
---|
| 208 | MERGE_MEDIA_DIRS, /* don't add an extra directory level when there are multiple media dirs */ |
---|
| 209 | +#else |
---|
| 210 | + MERGE_MEDIA_DIRS, /* don't add an extra directory level when there are multiple media dirs */ |
---|
| 211 | + ENABLE_THUMB, /* enable thumbnail generation */ |
---|
| 212 | + THUMB_WIDTH, /* thunbnail image with */ |
---|
| 213 | + THUMB_QUALITY, /* thumnail image quality */ |
---|
| 214 | + ENABLE_THUMB_FILMSTRIP, /* film strip overlay */ |
---|
| 215 | +#endif |
---|
| 216 | WIDE_LINKS, /* allow following symlinks outside the defined media_dirs */ |
---|
| 217 | TIVO_DISCOVERY, /* TiVo discovery protocol: bonjour or beacon. Defaults to bonjour if supported */ |
---|
| 218 | }; |
---|
| 219 | --- upnpglobalvars.h.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 220 | +++ upnpglobalvars.h 2017-05-26 15:12:44.457010482 +0900 |
---|
| 221 | @@ -196,6 +196,11 @@ |
---|
| 222 | #define SCANNING_MASK 0x0100 |
---|
| 223 | #define RESCAN_MASK 0x0200 |
---|
| 224 | |
---|
| 225 | +#ifdef THUMBNAIL_CREATION |
---|
| 226 | +#define THUMB_MASK 0x0100 |
---|
| 227 | +#define THUMB_FILMSTRIP 0x0200 |
---|
| 228 | +#endif |
---|
| 229 | + |
---|
| 230 | #define SETFLAG(mask) runtime_flags |= mask |
---|
| 231 | #define GETFLAG(mask) (runtime_flags & mask) |
---|
| 232 | #define CLEARFLAG(mask) runtime_flags &= ~mask |
---|
| 233 | --- utils.h.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 234 | +++ utils.h 2017-05-26 15:18:47.939957870 +0900 |
---|
| 235 | @@ -101,4 +101,8 @@ |
---|
| 236 | int make_dir(char * path, mode_t mode); |
---|
| 237 | unsigned int DJBHash(uint8_t *data, int len); |
---|
| 238 | |
---|
| 239 | +#ifdef THUMBNAIL_CREATION |
---|
| 240 | +int rename_artcache_dir(const char * oldpath, const char * newpath); |
---|
| 241 | +#endif |
---|
| 242 | + |
---|
| 243 | #endif |
---|
| 244 | --- minidlnatypes.h.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 245 | +++ minidlnatypes.h 2017-05-26 15:25:08.389784656 +0900 |
---|
| 246 | @@ -51,6 +51,10 @@ |
---|
| 247 | int max_connections; /* max number of simultaneous conenctions */ |
---|
| 248 | const char *root_container; /* root ObjectID (instead of "0") */ |
---|
| 249 | const char *ifaces[MAX_LAN_ADDR]; /* list of configured network interfaces */ |
---|
| 250 | +#ifdef THUMBNAIL_CREATION |
---|
| 251 | + int thumb_width; |
---|
| 252 | + int thumb_quality; |
---|
| 253 | +#endif |
---|
| 254 | }; |
---|
| 255 | |
---|
| 256 | struct string_s { |
---|
| 257 | --- monitor.c.orig 2017-05-18 05:55:17.000000000 +0900 |
---|
| 258 | +++ monitor.c 2017-05-26 16:28:48.306100398 +0900 |
---|
| 259 | @@ -322,6 +322,16 @@ |
---|
| 260 | sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID); |
---|
| 261 | } |
---|
| 262 | snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path); |
---|
| 263 | + |
---|
| 264 | +#ifdef THUMBNAIL_CREATION |
---|
| 265 | + /* Remove video thumbnails */ |
---|
| 266 | + if ( is_video(path) ) |
---|
| 267 | + { |
---|
| 268 | + char *vthumb = art_cache; |
---|
| 269 | + strcpy(strchr(vthumb, '\0')-4, ".jpg"); |
---|
| 270 | + } |
---|
| 271 | +#endif |
---|
| 272 | + |
---|
| 273 | remove(art_cache); |
---|
| 274 | |
---|
| 275 | return 0; |
---|
| 276 | @@ -616,6 +626,11 @@ |
---|
| 277 | sigdelset(&set, SIGCHLD); |
---|
| 278 | pthread_sigmask(SIG_BLOCK, &set, NULL); |
---|
| 279 | |
---|
| 280 | +#ifdef THUMBNAIL_CREATION |
---|
| 281 | + char renpath_buf[PATH_MAX]; |
---|
| 282 | + int cookie = 0; |
---|
| 283 | +#endif |
---|
| 284 | + |
---|
| 285 | pollfds[0].fd = inotify_init(); |
---|
| 286 | pollfds[0].events = POLLIN; |
---|
| 287 | |
---|
| 288 | @@ -685,6 +700,18 @@ |
---|
| 289 | { |
---|
| 290 | DPRINTF(E_DEBUG, L_INOTIFY, "The directory %s was %s.\n", |
---|
| 291 | path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created")); |
---|
| 292 | + |
---|
| 293 | +#ifdef THUMBNAIL_CREATION |
---|
| 294 | + /* We do not want to regenerate the thumbnails if e rename a directory. |
---|
| 295 | + We should keep at least four cookies/olddir since IN_MOVED_FROM/IN_MOVED_TO may |
---|
| 296 | + not arrive in sequence, but one should cover most cases */ |
---|
| 297 | + if (event->cookie == cookie && event->mask & IN_MOVED_TO) |
---|
| 298 | + { |
---|
| 299 | + DPRINTF(E_DEBUG, L_INOTIFY, "Directory rename: %s -> %s \n", renpath_buf, path_buf); |
---|
| 300 | + rename_artcache_dir(renpath_buf, path_buf); |
---|
| 301 | + } |
---|
| 302 | +#endif |
---|
| 303 | + |
---|
| 304 | monitor_insert_directory(pollfds[0].fd, esc_name, path_buf); |
---|
| 305 | } |
---|
| 306 | else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) && |
---|
| 307 | @@ -717,7 +744,22 @@ |
---|
| 308 | (event->mask & IN_ISDIR ? "directory" : "file"), |
---|
| 309 | path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted")); |
---|
| 310 | if ( event->mask & IN_ISDIR ) |
---|
| 311 | + |
---|
| 312 | +#ifdef THUMBNAIL_CREATION |
---|
| 313 | + { |
---|
| 314 | + if ( event->mask & IN_MOVED_FROM ) |
---|
| 315 | + { |
---|
| 316 | + strncpy(renpath_buf, path_buf, sizeof(renpath_buf)); |
---|
| 317 | + cookie = event->cookie; |
---|
| 318 | + } |
---|
| 319 | +#endif |
---|
| 320 | + |
---|
| 321 | monitor_remove_directory(pollfds[0].fd, path_buf); |
---|
| 322 | + |
---|
| 323 | +#ifdef THUMBNAIL_CREATION |
---|
| 324 | + } |
---|
| 325 | +#endif |
---|
| 326 | + |
---|
| 327 | else |
---|
| 328 | monitor_remove_file(path_buf); |
---|
| 329 | } |
---|
| 330 | --- utils.c.orig 2017-08-25 02:28:25.000000000 +0900 |
---|
| 331 | +++ utils.c 2017-09-15 04:00:57.174194577 +0900 |
---|
| 332 | @@ -531,3 +531,17 @@ |
---|
| 333 | |
---|
| 334 | return ALL_MEDIA; |
---|
| 335 | } |
---|
| 336 | + |
---|
| 337 | +#ifdef THUMBNAIL_CREATION |
---|
| 338 | +int |
---|
| 339 | +rename_artcache_dir(const char * oldpath, const char * newpath) |
---|
| 340 | +{ |
---|
| 341 | + char old_artcache[PATH_MAX]; |
---|
| 342 | + char new_artcache[PATH_MAX]; |
---|
| 343 | + |
---|
| 344 | + snprintf(old_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, oldpath); |
---|
| 345 | + snprintf(new_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, newpath); |
---|
| 346 | + |
---|
| 347 | + return rename(old_artcache, new_artcache); |
---|
| 348 | +} |
---|
| 349 | +#endif |
---|