Skip to content

Commit

Permalink
Merge pull request #5 from m4st3r-bl4ckb1rd/master
Browse files Browse the repository at this point in the history
merged from original minidlna 1.1.6 incl. fix for sql statement line …1926 and 1929

Awesome!  Thanks for getting the code base up to v1.1.6
  • Loading branch information
NathanaelA authored Jun 27, 2016
2 parents 65c172c + 4e1da37 commit 6aa3afc
Show file tree
Hide file tree
Showing 39 changed files with 486 additions and 127 deletions.
27 changes: 27 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
1.1.6 - Released 16-June-2016
--------------------------------
- Add AllShare and Windows client detection.
- Update support for LG2012 TV.
- Fix Samsung bookmarking on magic containers.
- Fix SQL error when moving captions.
- Add wide_links config option.
- Fix external subtitles on Samsung Series J.
- Add string localization support for magic containers.
- Rework NLS init to work with non-en_US locales.

1.1.5 - Released 10-Sep-2015
--------------------------------
- Re-enable Samsung DCM10, which adds video bookmarks and "BasicView" support.
- Allow SSDP M-SEARCH from other subnets.
- Fix some nfo file character escaping.
- Fix crash with >3 network interfaces.
- Support rotation of monochrome JPEGs.
- Handle cover art streams that come after the video stream.
- Recognize new hard links with inotify.
- Work around LG TV ordering bug.
- Implement TiVo image PixelShape support.
- Support thumbnail rotation.
- Use "Album Artist" tag from AAC files.
- Add Korean translations.
- Fix handling of bad FLAC files.

1.1.4 - Released 26-Aug-2014
--------------------------------
- Add magic container infrastructure.
Expand Down
30 changes: 28 additions & 2 deletions clients.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ struct client_type_s client_types[] =
EXAVClientInfo
},

/* User-Agent: DLNADOC/1.50 SEC_HHP_[PC]LPC001/1.0 MS-DeviceCaps/1024 */
/* This is AllShare running on a PC. We don't want to respond with Samsung
* capabilities, or Windows (and AllShare) might get grumpy. */
{ 0,
FLAG_DLNA,
"AllShare",
"SEC_HHP_[PC]",
EUserAgent
},

/* Samsung Series [CDE] BDPs and TVs must be separated, or some of our
* advertised extra features trigger a folder browsing bug on BDPs. */
/* User-Agent: DLNADOC/1.50 SEC_HHP_BD-D5100/1.0 */
Expand All @@ -65,9 +75,10 @@ struct client_type_s client_types[] =

/* User-Agent: DLNADOC/1.50 SEC_HHP_[TV]UE40D7000/1.0 */
/* User-Agent: DLNADOC/1.50 SEC_HHP_ Family TV/1.0 */
/* USER-AGENT: DLNADOC/1.50 SEC_HHP_[TV] UE65JU7000/1.0 UPnP/1.0 */
{ ESamsungSeriesCDE,
FLAG_SAMSUNG | FLAG_DLNA | FLAG_NO_RESIZE | FLAG_SAMSUNG_DCM10,
"Samsung Series [CDEF]",
FLAG_SAMSUNG | FLAG_DLNA | FLAG_NO_RESIZE | FLAG_SAMSUNG_DCM10 | FLAG_CAPTION_RES,
"Samsung Series [CDEFJ]",
"SEC_HHP_",
EUserAgent
},
Expand Down Expand Up @@ -134,6 +145,14 @@ struct client_type_s client_types[] =
EXAVClientInfo
},

/* USER-AGENT: Linux/2.6.35 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.6.0 */
{ ELGNetCastDevice,
FLAG_DLNA | FLAG_CAPTION_RES,
"LG",
"LGE_DLNA_SDK/1.6.0",
EUserAgent
},

/* User-Agent: Linux/2.6.31-1.0 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.5.0 */
{ ELGDevice,
FLAG_DLNA | FLAG_CAPTION_RES,
Expand Down Expand Up @@ -221,6 +240,13 @@ struct client_type_s client_types[] =
EUserAgent
},

{ 0,
FLAG_DLNA | FLAG_MIME_AVI_AVI,
"Windows",
"FDSSDP",
EUserAgent
},

{ EStandardDLNA150,
FLAG_DLNA | FLAG_MIME_AVI_AVI,
"Generic DLNA 1.5",
Expand Down
2 changes: 2 additions & 0 deletions clients.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#define FLAG_CAPTION_RES 0x00001000
/* Response-related flags */
#define FLAG_HAS_CAPTIONS 0x80000000
#define RESPONSE_FLAGS 0xF0000000

enum match_types {
EMatchNone,
Expand All @@ -56,6 +57,7 @@ enum client_types {
EDirecTV,
EFreeBox,
ELGDevice,
ELGNetCastDevice,
ELifeTab,
EMarantzDMP,
EMediaRoom,
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ AC_ARG_ENABLE(readynas,
AC_DEFINE([NETGEAR],[1],[Define to 1 if you want to enable generic NETGEAR device support])
AC_DEFINE([READYNAS],[1],[Define to 1 if you want to enable NETGEAR ReadyNAS support])
AC_DEFINE([TIVO_SUPPORT], 1, [Define to 1 if you want to enable TiVo support])
AC_DEFINE([PNPX],[5],[Define to 5 if you want to enable NETGEAR ReadyNAS PnP-X support])
AC_DEFINE_UNQUOTED([OS_URL],"http://www.readynas.com/")
AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURERURL],"http://www.netgear.com/")
AC_DEFINE_UNQUOTED([ROOTDEV_MANUFACTURER],"NETGEAR")
Expand Down
2 changes: 1 addition & 1 deletion getifaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ reload_ifaces(int force_notify)
do {
getifaddr(runtime_vars.ifaces[i]);
i++;
} while (runtime_vars.ifaces[i]);
} while (i < MAX_LAN_ADDR && runtime_vars.ifaces[i]);

for (i = 0; i < n_lan_addr; i++)
{
Expand Down
10 changes: 9 additions & 1 deletion image_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ image_new_from_jpeg(const char *path, int is_file, const uint8_t *buf, int size,
}
else if(cinfo.output_components == 1)
{
int rx, ry;
ofs = 0;
for(i = 0; i < cinfo.rec_outbuf_height; i++)
{
Expand All @@ -543,12 +544,19 @@ image_new_from_jpeg(const char *path, int is_file, const uint8_t *buf, int size,
}
for(y = 0; y < h; y += cinfo.rec_outbuf_height)
{
ry = (rotate & (ROTATE_90|ROTATE_180)) ? (y - h + 1) * -1 : y;
jpeg_read_scanlines(&cinfo, line, cinfo.rec_outbuf_height);
for(i = 0; i < cinfo.rec_outbuf_height; i++)
{
for(x = 0; x < w; x++)
{
vimage->buf[ofs++] = COL(line[i][x], line[i][x], line[i][x]);
rx = (rotate & (ROTATE_180|ROTATE_270)) ?
(x - w + 1) * -1 : x;
ofs = (rotate & (ROTATE_90|ROTATE_270)) ?
ry + (rx * h) : rx + (ry * w);
if( ofs < maxbuf )
vimage->buf[ofs] =
COL(line[i][x], line[i][x], line[i][x]);
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions inotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <dirent.h>
#include <libgen.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -329,6 +330,7 @@ inotify_insert_file(char * name, const char * path)
if( !is_audio(path) &&
!is_video(path) &&
!is_playlist(path) )
return -1;
break;
case TYPE_AUDIO|TYPE_IMAGES:
if( !is_image(path) &&
Expand All @@ -349,9 +351,8 @@ inotify_insert_file(char * name, const char * path)
if( !is_image(path) )
return -1;
break;
default:
default:
return -1;
break;
}

/* If it's already in the database and hasn't been modified, skip it. */
Expand Down Expand Up @@ -642,7 +643,7 @@ inotify_remove_directory(int fd, const char * path)
}

void *
start_inotify()
start_inotify(void)
{
struct pollfd pollfds[1];
int timeout = 1000;
Expand All @@ -651,6 +652,10 @@ start_inotify()
int length, i = 0;
char * esc_name = NULL;
struct stat st;
sigset_t set;

sigfillset(&set);
pthread_sigmask(SIG_BLOCK, &set, NULL);

pollfds[0].fd = inotify_init();
pollfds[0].events = POLLIN;
Expand Down Expand Up @@ -717,9 +722,10 @@ start_inotify()
else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) &&
(lstat(path_buf, &st) == 0) )
{
if( S_ISLNK(st.st_mode) )
if( (event->mask & (IN_MOVED_TO|IN_CREATE)) && (S_ISLNK(st.st_mode) || st.st_nlink > 1) )
{
DPRINTF(E_DEBUG, L_INOTIFY, "The symbolic link %s was %s.\n",
DPRINTF(E_DEBUG, L_INOTIFY, "The %s link %s was %s.\n",
(S_ISLNK(st.st_mode) ? "symbolic" : "hard"),
path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created"));
if( stat(path_buf, &st) == 0 && S_ISDIR(st.st_mode) )
inotify_insert_directory(pollfds[0].fd, esc_name, path_buf);
Expand Down
10 changes: 5 additions & 5 deletions metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ check_for_captions(const char *path, int64_t detailID)

if (ret == 0)
{
sql_exec(db, "INSERT into CAPTIONS"
sql_exec(db, "INSERT OR REPLACE into CAPTIONS"
" (ID, PATH) "
"VALUES"
" (%lld, %Q)", detailID, file);
Expand Down Expand Up @@ -694,16 +694,16 @@ GetVideoMetadata(const char *path, char *name)
//dump_format(ctx, 0, NULL, 0);
for( i=0; i<ctx->nb_streams; i++)
{
if( audio_stream == -1 &&
ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO )
if( ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO &&
audio_stream == -1 )
{
audio_stream = i;
ac = ctx->streams[audio_stream]->codec;
continue;
}
else if( video_stream == -1 &&
else if( ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO &&
!lav_is_thumbnail_stream(ctx->streams[i], &m.thumb_data, &m.thumb_size) &&
ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO )
video_stream == -1 )
{
video_stream = i;
vc = ctx->streams[video_stream]->codec;
Expand Down
65 changes: 32 additions & 33 deletions minidlna.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,30 +238,6 @@ getfriendlyname(char *buf, int len)
}
}
fclose(info);
#if PNPX
memcpy(pnpx_hwid+4, "01F2", 4);
if (strcmp(modelnumber, "NVX") == 0)
memcpy(pnpx_hwid+17, "0101", 4);
else if (strcmp(modelnumber, "Pro") == 0 ||
strcmp(modelnumber, "Pro 6") == 0 ||
strncmp(modelnumber, "Ultra 6", 7) == 0)
memcpy(pnpx_hwid+17, "0102", 4);
else if (strcmp(modelnumber, "Pro 2") == 0 ||
strncmp(modelnumber, "Ultra 2", 7) == 0)
memcpy(pnpx_hwid+17, "0103", 4);
else if (strcmp(modelnumber, "Pro 4") == 0 ||
strncmp(modelnumber, "Ultra 4", 7) == 0)
memcpy(pnpx_hwid+17, "0104", 4);
else if (strcmp(modelnumber+1, "100") == 0)
memcpy(pnpx_hwid+17, "0105", 4);
else if (strcmp(modelnumber+1, "200") == 0)
memcpy(pnpx_hwid+17, "0106", 4);
/* 0107 = Stora */
else if (strcmp(modelnumber, "Duo v2") == 0)
memcpy(pnpx_hwid+17, "0108", 4);
else if (strcmp(modelnumber, "NV+ v2") == 0)
memcpy(pnpx_hwid+17, "0109", 4);
#endif
#else
char * logname;
logname = getenv("LOGNAME");
Expand Down Expand Up @@ -380,6 +356,7 @@ check_db(sqlite3 *db, int new_db, pid_t *scanner_pid)
sqlite3_close(db);
log_close();
freeoptions();
free(children);
exit(EXIT_SUCCESS);
}
else if (*scanner_pid < 0)
Expand Down Expand Up @@ -467,9 +444,21 @@ static int strtobool(const char *str)
static void init_nls(void)
{
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "en_US.utf8");
DPRINTF(E_DEBUG, L_GENERAL, "Using locale dir %s\n", bindtextdomain("minidlna", getenv("TEXTDOMAINDIR")));
const char *messages, *ctype, *locale_dir;

ctype = setlocale(LC_CTYPE, "");
if (!ctype || !strcmp(ctype, "C"))
ctype = setlocale(LC_CTYPE, "en_US.utf8");
if (!ctype)
DPRINTF(E_WARN, L_GENERAL, "Unset locale\n");
else if (!strstr(ctype, "utf8") && !strstr(ctype, "UTF8") &&
!strstr(ctype, "utf-8") && !strstr(ctype, "UTF-8"))
DPRINTF(E_WARN, L_GENERAL, "Using unsupported non-utf8 locale '%s'\n", ctype);
messages = setlocale(LC_MESSAGES, "");
if (!messages)
messages = "unset";
locale_dir = bindtextdomain("minidlna", getenv("TEXTDOMAINDIR"));
DPRINTF(E_DEBUG, L_GENERAL, "Using locale dir '%s' and locale langauge %s/%s\n", locale_dir, messages, ctype);
textdomain("minidlna");
#endif
}
Expand Down Expand Up @@ -555,6 +544,8 @@ init(int argc, char **argv)
MAX_LAN_ADDR, word);
break;
}
while (isspace(*word))
word++;
runtime_vars.ifaces[ifaces++] = word;
}
break;
Expand Down Expand Up @@ -726,7 +717,8 @@ init(int argc, char **argv)
/* Symbolic username given, not UID. */
struct passwd *entry = getpwnam(ary_options[i].value);
if (!entry)
DPRINTF(E_FATAL, L_GENERAL, "Bad user '%s'.\n", argv[i]);
DPRINTF(E_FATAL, L_GENERAL, "Bad user '%s'.\n",
ary_options[i].value);
uid = entry->pw_uid;
}
break;
Expand All @@ -740,6 +732,10 @@ init(int argc, char **argv)
if (strtobool(ary_options[i].value))
SETFLAG(MERGE_MEDIA_DIRS_MASK);
break;
case WIDE_LINKS:
if (strtobool(ary_options[i].value))
SETFLAG(WIDE_LINKS_MASK);
break;
default:
DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n",
optionsfile);
Expand Down Expand Up @@ -1023,11 +1019,11 @@ main(int argc, char **argv)

for (i = 0; i < L_MAX; i++)
log_level[i] = E_WARN;
init_nls();

ret = init(argc, argv);
if (ret != 0)
return 1;
init_nls();

DPRINTF(E_WARN, L_GENERAL, "Starting " SERVER_NAME " version " MINIDLNA_VERSION ".\n");
if (sqlite3_libversion_number() < 3005001)
Expand Down Expand Up @@ -1061,6 +1057,7 @@ main(int argc, char **argv)
if (sssdp < 0)
{
DPRINTF(E_INFO, L_GENERAL, "Failed to open socket for receiving SSDP. Trying to use MiniSSDPd\n");
reload_ifaces(0); /* populate lan_addr[0].str */
if (SubmitServicesToMiniSSDPD(lan_addr[0].str, runtime_vars.port) < 0)
DPRINTF(E_FATAL, L_GENERAL, "Failed to connect to MiniSSDPd. EXITING");
}
Expand Down Expand Up @@ -1300,10 +1297,6 @@ main(int argc, char **argv)
if (scanning && scanner_pid)
kill(scanner_pid, SIGKILL);

/* kill other child processes */
process_reap_children();
free(children);

/* close out open sockets */
while (upnphttphead.lh_first != NULL)
{
Expand All @@ -1319,6 +1312,8 @@ main(int argc, char **argv)
if (sbeacon >= 0)
close(sbeacon);
#endif
if (smonitor >= 0)
close(smonitor);

for (i = 0; i < n_lan_addr; i++)
{
Expand All @@ -1329,6 +1324,10 @@ main(int argc, char **argv)
if (inotify_thread)
pthread_join(inotify_thread, NULL);

/* kill other child processes */
process_reap_children();
free(children);

sql_exec(db, "UPDATE SETTINGS set VALUE = '%u' where KEY = 'UPDATE_ID'", updateID);
sqlite3_close(db);

Expand Down
4 changes: 4 additions & 0 deletions minidlna.conf
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ model_number=1
# maximum number of simultaneous connections
# note: many clients open several simultaneous connections while streaming
#max_connections=50

# set this to yes to allow symlinks that point outside user-defined media_dirs.
#wide_links=no

Loading

0 comments on commit 6aa3afc

Please sign in to comment.