From cce9a012b32a3c9da23e7925de1118ec728a31e5 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 12 Mar 2014 11:40:49 -0700 Subject: [PATCH] config: add merge_media_dirs option By default, if there are multiple media directories specified, there will be entries for each one in the root directory container. If there is only one media directory specified, then just its contents will be in the root container, to save one level of browsing. Setting this option changes the default behavior so that multiple media dirs will behave like a single media dir. --- minidlna.c | 4 ++++ minidlna.conf | 4 ++++ options.c | 3 ++- options.h | 3 ++- scanner.c | 2 +- upnpglobalvars.h | 1 + 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/minidlna.c b/minidlna.c index 25dbf2d..5c2d5dc 100644 --- a/minidlna.c +++ b/minidlna.c @@ -717,6 +717,10 @@ init(int argc, char **argv) case MAX_CONNECTIONS: runtime_vars.max_connections = atoi(ary_options[i].value); break; + case MERGE_MEDIA_DIRS: + if (strtobool(ary_options[i].value)) + SETFLAG(MERGE_MEDIA_DIRS_MASK); + break; default: DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n", optionsfile); diff --git a/minidlna.conf b/minidlna.conf index a56330e..009d750 100644 --- a/minidlna.conf +++ b/minidlna.conf @@ -17,6 +17,10 @@ port=8200 # + "PV" for pictures and video (eg. media_dir=AV,/home/jmaggard/digital_camera) media_dir=/opt +# set this to merge all media_dir base contents into the root container +# note: the default is no +#merge_media_dirs=no + # set this if you want to customize the name that shows up on your clients #friendly_name=My DLNA Server diff --git a/options.c b/options.c index e211b33..2fa8c06 100644 --- a/options.c +++ b/options.c @@ -63,7 +63,8 @@ static const struct { { ROOT_CONTAINER, "root_container" }, { USER_ACCOUNT, "user" }, { FORCE_SORT_CRITERIA, "force_sort_criteria" }, - { MAX_CONNECTIONS, "max_connections" } + { MAX_CONNECTIONS, "max_connections" }, + { MERGE_MEDIA_DIRS, "merge_media_dirs" } }; int diff --git a/options.h b/options.h index 42686fc..157338a 100644 --- a/options.h +++ b/options.h @@ -57,7 +57,8 @@ enum upnpconfigoptions { ROOT_CONTAINER, /* root ObjectID (instead of "0") */ USER_ACCOUNT, /* user account to run as */ FORCE_SORT_CRITERIA, /* force sorting by a given sort criteria */ - MAX_CONNECTIONS /* maximum number of simultaneous connections */ + MAX_CONNECTIONS, /* maximum number of simultaneous connections */ + MERGE_MEDIA_DIRS /* don't add an extra directory level when there are multiple media dirs */ }; /* readoptionsfile() diff --git a/scanner.c b/scanner.c index f086d7a..2e5bcc9 100644 --- a/scanner.c +++ b/scanner.c @@ -832,7 +832,7 @@ start_scanner() strncpyt(path, media_path->path, sizeof(path)); bname = basename(path); /* If there are multiple media locations, add a level to the ContentDirectory */ - if( media_dirs && media_dirs->next ) + if( !GETFLAG(MERGE_MEDIA_DIRS_MASK) && media_dirs->next ) { int startID = get_next_available_id("OBJECTS", BROWSEDIR_ID); id = insert_directory(bname, path, BROWSEDIR_ID, "", startID); diff --git a/upnpglobalvars.h b/upnpglobalvars.h index 650a3d4..d21f347 100644 --- a/upnpglobalvars.h +++ b/upnpglobalvars.h @@ -189,6 +189,7 @@ extern uint32_t runtime_flags; #define DLNA_STRICT_MASK 0x0004 #define NO_PLAYLIST_MASK 0x0008 #define SYSTEMD_MASK 0x0010 +#define MERGE_MEDIA_DIRS_MASK 0x0020 #define SETFLAG(mask) runtime_flags |= mask #define GETFLAG(mask) (runtime_flags & mask)