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.
This commit is contained in:
Justin Maggard 2014-03-12 11:40:49 -07:00
parent 7c0739ad3f
commit cce9a012b3
6 changed files with 14 additions and 3 deletions

View File

@ -717,6 +717,10 @@ init(int argc, char **argv)
case MAX_CONNECTIONS: case MAX_CONNECTIONS:
runtime_vars.max_connections = atoi(ary_options[i].value); runtime_vars.max_connections = atoi(ary_options[i].value);
break; break;
case MERGE_MEDIA_DIRS:
if (strtobool(ary_options[i].value))
SETFLAG(MERGE_MEDIA_DIRS_MASK);
break;
default: default:
DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n", DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n",
optionsfile); optionsfile);

View File

@ -17,6 +17,10 @@ port=8200
# + "PV" for pictures and video (eg. media_dir=AV,/home/jmaggard/digital_camera) # + "PV" for pictures and video (eg. media_dir=AV,/home/jmaggard/digital_camera)
media_dir=/opt 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 # set this if you want to customize the name that shows up on your clients
#friendly_name=My DLNA Server #friendly_name=My DLNA Server

View File

@ -63,7 +63,8 @@ static const struct {
{ ROOT_CONTAINER, "root_container" }, { ROOT_CONTAINER, "root_container" },
{ USER_ACCOUNT, "user" }, { USER_ACCOUNT, "user" },
{ FORCE_SORT_CRITERIA, "force_sort_criteria" }, { FORCE_SORT_CRITERIA, "force_sort_criteria" },
{ MAX_CONNECTIONS, "max_connections" } { MAX_CONNECTIONS, "max_connections" },
{ MERGE_MEDIA_DIRS, "merge_media_dirs" }
}; };
int int

View File

@ -57,7 +57,8 @@ enum upnpconfigoptions {
ROOT_CONTAINER, /* root ObjectID (instead of "0") */ ROOT_CONTAINER, /* root ObjectID (instead of "0") */
USER_ACCOUNT, /* user account to run as */ USER_ACCOUNT, /* user account to run as */
FORCE_SORT_CRITERIA, /* force sorting by a given sort criteria */ 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() /* readoptionsfile()

View File

@ -832,7 +832,7 @@ start_scanner()
strncpyt(path, media_path->path, sizeof(path)); strncpyt(path, media_path->path, sizeof(path));
bname = basename(path); bname = basename(path);
/* If there are multiple media locations, add a level to the ContentDirectory */ /* 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); int startID = get_next_available_id("OBJECTS", BROWSEDIR_ID);
id = insert_directory(bname, path, BROWSEDIR_ID, "", startID); id = insert_directory(bname, path, BROWSEDIR_ID, "", startID);

View File

@ -189,6 +189,7 @@ extern uint32_t runtime_flags;
#define DLNA_STRICT_MASK 0x0004 #define DLNA_STRICT_MASK 0x0004
#define NO_PLAYLIST_MASK 0x0008 #define NO_PLAYLIST_MASK 0x0008
#define SYSTEMD_MASK 0x0010 #define SYSTEMD_MASK 0x0010
#define MERGE_MEDIA_DIRS_MASK 0x0020
#define SETFLAG(mask) runtime_flags |= mask #define SETFLAG(mask) runtime_flags |= mask
#define GETFLAG(mask) (runtime_flags & mask) #define GETFLAG(mask) (runtime_flags & mask)