Revision 11754,
12.3 KB
checked in by iwaim, 6 years ago
(diff) |
self-build-minidlna: add files
|
-
old
|
new
|
|
53 | 53 | @LIBEXIF_LIBS@ \ |
54 | 54 | @LIBINTL@ \ |
55 | 55 | @LIBICONV@ \ |
56 | | -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) |
| 56 | -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) @LIBFFMPEGTHUMBNAILER_LIBS@ |
57 | 57 | |
58 | 58 | minidlnad_LDFLAGS = @STATIC_LDFLAGS@ |
59 | 59 | |
-
old
|
new
|
|
32 | 32 | |
33 | 33 | #include <jpeglib.h> |
34 | 34 | |
| 35 | #ifdef THUMBNAIL_CREATION |
| 36 | #include <libffmpegthumbnailer/videothumbnailerc.h> |
| 37 | #endif |
| 38 | |
35 | 39 | #include "upnpglobalvars.h" |
36 | 40 | #include "albumart.h" |
37 | 41 | #include "sql.h" |
… |
… |
|
348 | 352 | return NULL; |
349 | 353 | } |
350 | 354 | |
| 355 | #ifdef THUMBNAIL_CREATION |
| 356 | char * |
| 357 | generate_thumbnail(const char * path) |
| 358 | { |
| 359 | char *tfile = NULL; |
| 360 | video_thumbnailer *vt = NULL; |
| 361 | char cache_dir[MAXPATHLEN]; |
| 362 | |
| 363 | if( art_cache_exists(path, &tfile) ) |
| 364 | return tfile; |
| 365 | |
| 366 | if ( is_video(path) ) |
| 367 | { |
| 368 | |
| 369 | vt = video_thumbnailer_create(); |
| 370 | if ( !vt ) |
| 371 | { |
| 372 | free(tfile); |
| 373 | return 0; |
| 374 | } |
| 375 | vt->thumbnail_image_type = Jpeg; |
| 376 | vt->thumbnail_image_quality = runtime_vars.thumb_quality; |
| 377 | vt->thumbnail_size = runtime_vars.thumb_width; |
| 378 | vt->seek_percentage = 20; |
| 379 | vt->overlay_film_strip = (GETFLAG(THUMB_FILMSTRIP))?1:0; |
| 380 | |
| 381 | DPRINTF(E_DEBUG, L_METADATA, "generating thumbnail: %s\n", path); |
| 382 | |
| 383 | strncpyt(cache_dir, tfile, sizeof(cache_dir)); |
| 384 | if ( !make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) && |
| 385 | !video_thumbnailer_generate_thumbnail_to_file(vt, path, tfile) ) |
| 386 | { |
| 387 | video_thumbnailer_destroy(vt); |
| 388 | return tfile; |
| 389 | } |
| 390 | |
| 391 | video_thumbnailer_destroy(vt); |
| 392 | } |
| 393 | free(tfile); |
| 394 | |
| 395 | return 0; |
| 396 | } |
| 397 | #endif |
| 398 | |
351 | 399 | int64_t |
352 | 400 | find_album_art(const char *path, uint8_t *image_data, int image_size) |
353 | 401 | { |
354 | 402 | char *album_art = NULL; |
355 | 403 | int64_t ret = 0; |
356 | 404 | |
357 | | if( (image_size && (album_art = check_embedded_art(path, image_data, image_size))) || |
358 | | (album_art = check_for_album_file(path)) ) |
| 405 | if(image_size) |
| 406 | album_art = check_embedded_art(path, image_data, image_size); |
| 407 | |
| 408 | if(!album_art) |
| 409 | album_art = check_for_album_file(path); |
| 410 | |
| 411 | #ifdef THUMBNAIL_CREATION |
| 412 | if(!album_art && GETFLAG(THUMB_MASK)) |
| 413 | album_art = generate_thumbnail(path); |
| 414 | #endif |
| 415 | |
| 416 | if(album_art) |
359 | 417 | { |
360 | 418 | ret = sql_get_int_field(db, "SELECT ID from ALBUM_ART where PATH = '%q'", album_art); |
361 | 419 | if( !ret ) |
-
old
|
new
|
|
617 | 617 | ] |
618 | 618 | ) |
619 | 619 | |
| 620 | AC_ARG_ENABLE(thumbnail, |
| 621 | [ --enable-thumbnail enable video thumbnail generation using libffmpegthumbnailer],[ |
| 622 | if test "$enableval" = "yes"; then |
| 623 | AC_DEFINE([THUMBNAIL_CREATION],[1],[Define to 1 if you want to enable video thumbnail generation]) |
| 624 | PKG_CHECK_MODULES([LIBFFMPEGTHUMBNAILER], libffmpegthumbnailer, , |
| 625 | AC_MSG_ERROR([Unable to find libffmpegthumbnailer])) |
| 626 | AC_SUBST([LIBFFMPEGTHUMBNAILER_CFLAGS]) |
| 627 | AC_SUBST([LIBFFMPEGTHUMBNAILER_LIBS]) |
| 628 | else |
| 629 | AC_MSG_RESULT([no]) |
| 630 | fi |
| 631 | ],[ |
| 632 | AC_MSG_RESULT([no]) |
| 633 | ] |
| 634 | ) |
620 | 635 | |
621 | 636 | case "$target_os" in |
622 | 637 | darwin*) |
-
old
|
new
|
|
539 | 539 | runtime_vars.root_container = NULL; |
540 | 540 | runtime_vars.ifaces[0] = NULL; |
541 | 541 | |
| 542 | #ifdef THUMBNAIL_CREATION |
| 543 | runtime_vars.thumb_width = 160; |
| 544 | runtime_vars.thumb_quality = 8; |
| 545 | #endif |
| 546 | |
542 | 547 | /* read options file first since |
543 | 548 | * command line arguments have final say */ |
544 | 549 | if (readoptionsfile(optionsfile) < 0) |
… |
… |
|
752 | 757 | if (strcasecmp(ary_options[i].value, "beacon") == 0) |
753 | 758 | CLEARFLAG(TIVO_BONJOUR_MASK); |
754 | 759 | break; |
| 760 | #ifdef THUMBNAIL_CREATION |
| 761 | case ENABLE_THUMB: |
| 762 | if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) |
| 763 | SETFLAG(THUMB_MASK); |
| 764 | break; |
| 765 | case THUMB_WIDTH: |
| 766 | runtime_vars.thumb_width = atoi(ary_options[i].value); |
| 767 | if (runtime_vars.thumb_width < 120) |
| 768 | runtime_vars.thumb_width = 120; |
| 769 | if (runtime_vars.thumb_width > 480) |
| 770 | runtime_vars.thumb_width = 480; |
| 771 | break; |
| 772 | case THUMB_QUALITY: |
| 773 | runtime_vars.thumb_quality = atoi(ary_options[i].value); |
| 774 | if (runtime_vars.thumb_quality < 5) |
| 775 | runtime_vars.thumb_quality = 5; |
| 776 | if (runtime_vars.thumb_quality > 30) |
| 777 | runtime_vars.thumb_quality = 30; |
| 778 | break; |
| 779 | case ENABLE_THUMB_FILMSTRIP: |
| 780 | if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) |
| 781 | SETFLAG(THUMB_FILMSTRIP); |
| 782 | break; |
| 783 | #endif |
755 | 784 | default: |
756 | 785 | DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n", |
757 | 786 | optionsfile); |
-
old
|
new
|
|
88 | 88 | |
89 | 89 | # set this to yes to allow symlinks that point outside user-defined media_dirs. |
90 | 90 | #wide_links=no |
| 91 | |
| 92 | # Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time. |
| 93 | #enable_thumbnail=no |
| 94 | |
| 95 | # 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. |
| 96 | #thumbnail_width=160 |
| 97 | |
| 98 | # Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time. |
| 99 | #thumbnail_quality=8 |
| 100 | |
| 101 | # Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time. |
| 102 | #enable_thumbnail_filmstrip=no |
-
old
|
new
|
|
64 | 64 | { USER_ACCOUNT, "user" }, |
65 | 65 | { FORCE_SORT_CRITERIA, "force_sort_criteria" }, |
66 | 66 | { MAX_CONNECTIONS, "max_connections" }, |
| 67 | #ifndef THUMBNAIL_CREATION |
67 | 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 | { WIDE_LINKS, "wide_links" }, |
69 | 77 | { TIVO_DISCOVERY, "tivo_discovery" }, |
70 | 78 | }; |
-
old
|
new
|
|
57 | 57 | USER_ACCOUNT, /* user account to run as */ |
58 | 58 | FORCE_SORT_CRITERIA, /* force sorting by a given sort criteria */ |
59 | 59 | MAX_CONNECTIONS, /* maximum number of simultaneous connections */ |
| 60 | #ifndef THUMBNAIL_CREATION |
60 | 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 | WIDE_LINKS, /* allow following symlinks outside the defined media_dirs */ |
62 | 70 | TIVO_DISCOVERY, /* TiVo discovery protocol: bonjour or beacon. Defaults to bonjour if supported */ |
63 | 71 | }; |
-
old
|
new
|
|
196 | 196 | #define SCANNING_MASK 0x0100 |
197 | 197 | #define RESCAN_MASK 0x0200 |
198 | 198 | |
| 199 | #ifdef THUMBNAIL_CREATION |
| 200 | #define THUMB_MASK 0x0100 |
| 201 | #define THUMB_FILMSTRIP 0x0200 |
| 202 | #endif |
| 203 | |
199 | 204 | #define SETFLAG(mask) runtime_flags |= mask |
200 | 205 | #define GETFLAG(mask) (runtime_flags & mask) |
201 | 206 | #define CLEARFLAG(mask) runtime_flags &= ~mask |
-
old
|
new
|
|
101 | 101 | int make_dir(char * path, mode_t mode); |
102 | 102 | unsigned int DJBHash(uint8_t *data, int len); |
103 | 103 | |
| 104 | #ifdef THUMBNAIL_CREATION |
| 105 | int rename_artcache_dir(const char * oldpath, const char * newpath); |
| 106 | #endif |
| 107 | |
104 | 108 | #endif |
-
old
|
new
|
|
51 | 51 | int max_connections; /* max number of simultaneous conenctions */ |
52 | 52 | const char *root_container; /* root ObjectID (instead of "0") */ |
53 | 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 | 60 | struct string_s { |
-
old
|
new
|
|
322 | 322 | sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID); |
323 | 323 | } |
324 | 324 | snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path); |
| 325 | |
| 326 | #ifdef THUMBNAIL_CREATION |
| 327 | /* Remove video thumbnails */ |
| 328 | if ( is_video(path) ) |
| 329 | { |
| 330 | char *vthumb = art_cache; |
| 331 | strcpy(strchr(vthumb, '\0')-4, ".jpg"); |
| 332 | } |
| 333 | #endif |
| 334 | |
325 | 335 | remove(art_cache); |
326 | 336 | |
327 | 337 | return 0; |
… |
… |
|
616 | 626 | sigdelset(&set, SIGCHLD); |
617 | 627 | pthread_sigmask(SIG_BLOCK, &set, NULL); |
618 | 628 | |
| 629 | #ifdef THUMBNAIL_CREATION |
| 630 | char renpath_buf[PATH_MAX]; |
| 631 | int cookie = 0; |
| 632 | #endif |
| 633 | |
619 | 634 | pollfds[0].fd = inotify_init(); |
620 | 635 | pollfds[0].events = POLLIN; |
621 | 636 | |
… |
… |
|
685 | 700 | { |
686 | 701 | DPRINTF(E_DEBUG, L_INOTIFY, "The directory %s was %s.\n", |
687 | 702 | path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created")); |
| 703 | |
| 704 | #ifdef THUMBNAIL_CREATION |
| 705 | /* We do not want to regenerate the thumbnails if e rename a directory. |
| 706 | We should keep at least four cookies/olddir since IN_MOVED_FROM/IN_MOVED_TO may |
| 707 | not arrive in sequence, but one should cover most cases */ |
| 708 | if (event->cookie == cookie && event->mask & IN_MOVED_TO) |
| 709 | { |
| 710 | DPRINTF(E_DEBUG, L_INOTIFY, "Directory rename: %s -> %s \n", renpath_buf, path_buf); |
| 711 | rename_artcache_dir(renpath_buf, path_buf); |
| 712 | } |
| 713 | #endif |
| 714 | |
688 | 715 | monitor_insert_directory(pollfds[0].fd, esc_name, path_buf); |
689 | 716 | } |
690 | 717 | else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) && |
… |
… |
|
717 | 744 | (event->mask & IN_ISDIR ? "directory" : "file"), |
718 | 745 | path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted")); |
719 | 746 | if ( event->mask & IN_ISDIR ) |
| 747 | |
| 748 | #ifdef THUMBNAIL_CREATION |
| 749 | { |
| 750 | if ( event->mask & IN_MOVED_FROM ) |
| 751 | { |
| 752 | strncpy(renpath_buf, path_buf, sizeof(renpath_buf)); |
| 753 | cookie = event->cookie; |
| 754 | } |
| 755 | #endif |
| 756 | |
720 | 757 | monitor_remove_directory(pollfds[0].fd, path_buf); |
| 758 | |
| 759 | #ifdef THUMBNAIL_CREATION |
| 760 | } |
| 761 | #endif |
| 762 | |
721 | 763 | else |
722 | 764 | monitor_remove_file(path_buf); |
723 | 765 | } |
-
old
|
new
|
|
531 | 531 | |
532 | 532 | return ALL_MEDIA; |
533 | 533 | } |
| 534 | |
| 535 | #ifdef THUMBNAIL_CREATION |
| 536 | int |
| 537 | rename_artcache_dir(const char * oldpath, const char * newpath) |
| 538 | { |
| 539 | char old_artcache[PATH_MAX]; |
| 540 | char new_artcache[PATH_MAX]; |
| 541 | |
| 542 | snprintf(old_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, oldpath); |
| 543 | snprintf(new_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, newpath); |
| 544 | |
| 545 | return rename(old_artcache, new_artcache); |
| 546 | } |
| 547 | #endif |
Note: See
TracBrowser
for help on using the repository browser.