minidlna: backport fixes from 1.1.6 and 1.2.0 releases

This fixes one or two issues and adds support for few new devices
including Kodi.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
This commit is contained in:
Rafał Miłecki 2017-06-15 07:55:23 +02:00
parent ec928e8a9f
commit 7292844261
13 changed files with 576 additions and 1 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=minidlna
PKG_VERSION:=1.1.5
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/minidlna
@ -19,6 +19,8 @@ PKG_LICENSE_FILES:=COPYING LICENCE.miniupnpd
PKG_MAINTAINER:=Knyazkov Dmitry <medavedik@gmail.com>
PKG_FIXUP:=autoreconf
PKG_BUILD_PARALLEL:=0
PKG_BUILD_DEPENDS:=util-linux

View File

@ -0,0 +1,31 @@
From d097d3c02da148c73c46ea5e6402a01b78cc1b5a Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Mon, 16 Nov 2015 09:57:07 -0800
Subject: [PATCH] nls: Move init_nls() after log_init().
Otherwise the DPRINTF in minidlna.c:init_nls() will always fail to log.
Pointed out by Shrimpkin.
---
minidlna.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/minidlna.c b/minidlna.c
index 7933f54..8977a17 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -1021,11 +1021,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)
--
2.11.0

View File

@ -0,0 +1,53 @@
From 4ec6cd005358f3474ce9caec4f0954b4756570ed Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Thu, 7 Jan 2016 00:31:56 -0800
Subject: [PATCH] upnpsoap: Fix external subtitles on Samsung Series J.
Add FLAG_CAPTION_RES to the modern Samsung profile. Older Samsung
devices used a custom method for describing subtitles, but apparently
Series J no longer supports it. The good thing is, they now support
the more standard method (and probably have been for a while, since it
works on my old Series D BDP).
So let's just expose both methods to the client, since everything should
be able to handle it.
Fixes: SF bug #113 (Subtitles support for new 2015 Samsung J series TV)
---
clients.c | 5 +++--
upnpsoap.c | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/clients.c b/clients.c
index a8609d2..39ca362 100644
--- a/clients.c
+++ b/clients.c
@@ -65,9 +65,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
},
diff --git a/upnpsoap.c b/upnpsoap.c
index 8066318..96ad2d5 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -1064,7 +1064,7 @@ callback(void *args, int argc, char **argv, char **azColName)
"http://%s:%d/Captions/%s.srt"
"&lt;/res&gt;",
lan_addr[passed_args->iface].str, runtime_vars.port, detailID);
- else if( passed_args->filter & FILTER_SEC_CAPTION_INFO_EX )
+ if( passed_args->filter & FILTER_SEC_CAPTION_INFO_EX )
ret = strcatf(str, "&lt;sec:CaptionInfoEx sec:type=\"srt\"&gt;"
"http://%s:%d/Captions/%s.srt"
"&lt;/sec:CaptionInfoEx&gt;",
--
2.11.0

View File

@ -0,0 +1,24 @@
From 910b84bcd6b64a8a72368aaa66d1bd4731c67cc8 Mon Sep 17 00:00:00 2001
From: Darkvater <tamas.farago@credit-suisse.com>
Date: Wed, 27 Jan 2016 19:42:36 +0800
Subject: [PATCH] inotify: missing include file
---
inotify.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/inotify.c b/inotify.c
index d5043bb..c5c4343 100644
--- a/inotify.c
+++ b/inotify.c
@@ -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>
--
2.11.0

View File

@ -0,0 +1,59 @@
From abc1972600d03d93e35fe30661f84a6ea52a058a Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Thu, 17 Mar 2016 13:37:09 -0700
Subject: [PATCH] inotify: fix SQL error when moving captions
Change INSERT to INSERT OR REPLACE when recording caption file moves,
to avoid UNIQUE constraint failures.
---
inotify.c | 3 +--
metadata.c | 2 +-
po/ru.po | 4 ++++
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/inotify.c b/inotify.c
index c5c4343..88ca83a 100644
--- a/inotify.c
+++ b/inotify.c
@@ -350,9 +350,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. */
diff --git a/metadata.c b/metadata.c
index c08ca3f..2bfa8b9 100644
--- a/metadata.c
+++ b/metadata.c
@@ -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);
diff --git a/po/ru.po b/po/ru.po
index fda545d..e07502b 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -85,6 +85,10 @@ msgstr "Папки"
msgid "Playlists"
msgstr "Списки Воспроизведения"
+#: scanner.c:598
+msgid "Recently Added"
+msgstr ""
+
#: scanner.c:536
msgid "Video"
msgstr "Видео"
--
2.11.0

View File

@ -0,0 +1,33 @@
From cae3e880d26ba7671b59ac4fe44c499b6a0a9d4e Mon Sep 17 00:00:00 2001
From: Eduardo Rocha <folhabranca@gmail.com>
Date: Sun, 14 Sep 2014 13:45:11 -0300
Subject: [PATCH] Samsung bookmarking: fix for magic containers
---
upnpsoap.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/upnpsoap.c b/upnpsoap.c
index 96ad2d5..4f6f22e 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -1927,11 +1927,14 @@ SamsungSetBookmark(struct upnphttp * h, const char * action)
if( ObjectID && PosSecond )
{
int ret;
+ const char *rid = ObjectID;
+
+ in_magic_container(ObjectID, 0, &rid);
ret = sql_exec(db, "INSERT OR REPLACE into BOOKMARKS"
" VALUES "
- "((select DETAIL_ID from OBJECTS where OBJECT_ID = '%q'), %q)", ObjectID, PosSecond);
+ "((select DETAIL_ID from OBJECTS where OBJECT_ID = '%q'), %q)", rid, PosSecond);
if( ret != SQLITE_OK )
- DPRINTF(E_WARN, L_METADATA, "Error setting bookmark %s on ObjectID='%s'\n", PosSecond, ObjectID);
+ DPRINTF(E_WARN, L_METADATA, "Error setting bookmark %s on ObjectID='%s'\n", PosSecond, rid);
BuildSendAndCloseSoapResp(h, resp, sizeof(resp)-1);
}
else
--
2.11.0

View File

@ -0,0 +1,28 @@
From 126f0f5cb8cd93eef448e2e5bf7a2c0d8d5183fb Mon Sep 17 00:00:00 2001
From: Eduardo Rocha <folhabranca@gmail.com>
Date: Sun, 14 Sep 2014 14:11:51 -0300
Subject: [PATCH] Samsung bookmark - go back to the beginning of the movie if
less than 30 seconds was played.
---
upnpsoap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/upnpsoap.c b/upnpsoap.c
index 4f6f22e..0f19035 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -1924,6 +1924,10 @@ SamsungSetBookmark(struct upnphttp * h, const char * action)
ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, 0);
ObjectID = GetValueFromNameValueList(&data, "ObjectID");
PosSecond = GetValueFromNameValueList(&data, "PosSecond");
+
+ if ( atoi(PosSecond) < 30 )
+ PosSecond = "0";
+
if( ObjectID && PosSecond )
{
int ret;
--
2.11.0

View File

@ -0,0 +1,59 @@
From 533907539357df45d1923638d11192b98f7bf280 Mon Sep 17 00:00:00 2001
From: Darkvater <tamas.farago@credit-suisse.com>
Date: Sun, 4 May 2014 13:51:29 +0800
Subject: [PATCH] Update support for LG2012 TV
LG 2012 series does not need '.' in title anymore to be able to show
captions
---
clients.c | 8 ++++++++
clients.h | 1 +
upnpsoap.c | 1 +
3 files changed, 10 insertions(+)
diff --git a/clients.c b/clients.c
index 39ca362..cd1d06a 100644
--- a/clients.c
+++ b/clients.c
@@ -135,6 +135,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,
diff --git a/clients.h b/clients.h
index 190d569..35d819a 100644
--- a/clients.h
+++ b/clients.h
@@ -57,6 +57,7 @@ enum client_types {
EDirecTV,
EFreeBox,
ELGDevice,
+ ELGNetCastDevice,
ELifeTab,
EMarantzDMP,
EMediaRoom,
diff --git a/upnpsoap.c b/upnpsoap.c
index 0f19035..0c2b9af 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -1055,6 +1055,7 @@ callback(void *args, int argc, char **argv, char **azColName)
break;
case ESamsungSeriesCDE:
case ELGDevice:
+ case ELGNetCastDevice:
case EAsusOPlay:
default:
if( passed_args->flags & FLAG_HAS_CAPTIONS )
--
2.11.0

View File

@ -0,0 +1,50 @@
From 02b6085380e3dfb422037c8b08a492e48789dd59 Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Thu, 21 Apr 2016 14:31:53 -0700
Subject: [PATCH] clients: Add AllShare and Windows detection
Reporting Samsung features to Windows and AllShare somehow makes them
ignore us, so detect these client types specifically and don't expose
Samsung capabilities to them.
---
clients.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/clients.c b/clients.c
index cd1d06a..5b9ba5d 100644
--- a/clients.c
+++ b/clients.c
@@ -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 */
@@ -230,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",
--
2.11.0

View File

@ -0,0 +1,32 @@
From 8a996b4b624ef45538a5de10730b8e94c55e7768 Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Wed, 28 Sep 2016 18:44:58 -0700
Subject: [PATCH] upnphttp: Kill strange HTTP request parsing
Avoid reading uninitialized memory on malicious HTTP requests.
Fixes: Bug #293 - upnphttp.c ProcessHttpQuery_upnphttp() Function HTTP Request Handling Remote DoS
---
upnphttp.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/upnphttp.c b/upnphttp.c
index 4184bb2..1902159 100644
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -827,12 +827,6 @@ ProcessHttpQuery_upnphttp(struct upnphttp * h)
HttpCommand[i] = '\0';
while(*p==' ')
p++;
- if(strncmp(p, "http://", 7) == 0)
- {
- p = p+7;
- while(*p!='/')
- p++;
- }
for(i = 0; i<511 && *p && *p != ' ' && *p != '\r'; i++)
HttpUrl[i] = *(p++);
HttpUrl[i] = '\0';
--
2.11.0

View File

@ -0,0 +1,93 @@
From d894885bc1f6d9d43d5421663cdff7b993d0304e Mon Sep 17 00:00:00 2001
From: Justin Maggard <jmaggard@netgear.com>
Date: Mon, 1 May 2017 17:49:16 -0700
Subject: [PATCH] clients: Improve Samsung BD-J5500 support
From SF user Andrea Odetti:
The Samsung BD J5500 player does not accept some of the DLNA_PN values
used by minidlna for *.mp4 files.
For instance AVC_MP4_MP_HD_720p_AAC and AVC_MP4_BL_L31_HD_AAC are
problematic as the player would simply ignore the files and not show
them.
AVC_MP4_HP_HD_AAC works.
All the files play normally from a USB key.
I've noticed as well that NULL works always, and this is the approach I
have followed.
So I changed minidlna and added a flag to disable DLNA_PN, and this
flag is only used for a Samsung BD J5500 in order not to break other
players, which can handle DLNA_PN properly.
So when a J5500 is connected we simply set DLNA_PN to NULL and
everything works well.
---
clients.c | 8 +++++++-
clients.h | 2 ++
upnpsoap.c | 3 +++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/clients.c b/clients.c
index 5b9ba5d..e045ad8 100644
--- a/clients.c
+++ b/clients.c
@@ -63,6 +63,13 @@ struct client_type_s client_types[] =
EUserAgent
},
+ { ESamsungBDJ5500,
+ FLAG_SAMSUNG | FLAG_DLNA | FLAG_NO_RESIZE | FLAG_CAPTION_RES | FLAG_SKIP_DLNA_PN,
+ "Samsung BD J5500",
+ "[BD]J5500",
+ 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 */
@@ -324,4 +331,3 @@ AddClientCache(struct in_addr addr, int type)
return NULL;
}
-
diff --git a/clients.h b/clients.h
index 35d819a..f9818f5 100644
--- a/clients.h
+++ b/clients.h
@@ -37,6 +37,7 @@
#define FLAG_AUDIO_ONLY 0x00000400
#define FLAG_FORCE_SORT 0x00000800
#define FLAG_CAPTION_RES 0x00001000
+#define FLAG_SKIP_DLNA_PN 0x00002000 /* during browsing */
/* Response-related flags */
#define FLAG_HAS_CAPTIONS 0x80000000
#define RESPONSE_FLAGS 0xF0000000
@@ -69,6 +70,7 @@ enum client_types {
ESamsungSeriesB,
ESamsungSeriesCDEBDP,
ESamsungSeriesCDE,
+ ESamsungBDJ5500,
ESonyBDP,
ESonyBravia,
ESonyInternetTV,
diff --git a/upnpsoap.c b/upnpsoap.c
index 0c2b9af..9ee0b90 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -905,6 +905,9 @@ callback(void *args, int argc, char **argv, char **azColName)
else
dlna_flags |= DLNA_FLAG_TM_I;
+ if( passed_args->flags & FLAG_SKIP_DLNA_PN )
+ dlna_pn = NULL;
+
if( dlna_pn )
snprintf(dlna_buf, sizeof(dlna_buf), "DLNA.ORG_PN=%s;"
"DLNA.ORG_OP=01;"
--
2.11.0

View File

@ -0,0 +1,71 @@
From 5450ac486e9956f5139c5d5074ce09c49f4b6a9a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= <makovick@gmail.com>
Date: Tue, 2 May 2017 20:08:30 +0200
Subject: [PATCH] clients: Add media extension to titles for Hyundai TVs
On Hyundai HLN 24TS382 Smart TV, the DLNA client refuses to display
media files whose title does not end with a media file extension.
Because minidlna strips the extensions, all folders thus appear empty.
This patch adds a quirk for Hyundai TVs that appends the original file
extension to the titles, which fixes the issue.
---
clients.c | 7 +++++++
clients.h | 1 +
upnpsoap.c | 10 ++++++++++
3 files changed, 18 insertions(+)
diff --git a/clients.c b/clients.c
index e045ad8..c3bd96d 100644
--- a/clients.c
+++ b/clients.c
@@ -205,6 +205,13 @@ struct client_type_s client_types[] =
EUserAgent
},
+ { EHyundaiTV,
+ FLAG_DLNA,
+ "Hyundai TV",
+ "HYUNDAITV",
+ EFriendlyName
+ },
+
{ ERokuSoundBridge,
FLAG_MS_PFS | FLAG_AUDIO_ONLY | FLAG_MIME_WAV_WAV | FLAG_FORCE_SORT,
"Roku SoundBridge",
diff --git a/clients.h b/clients.h
index f9818f5..fa39656 100644
--- a/clients.h
+++ b/clients.h
@@ -75,6 +75,7 @@ enum client_types {
ESonyBravia,
ESonyInternetTV,
EToshibaTV,
+ EHyundaiTV,
EAsusOPlay,
EBubbleUPnP,
ENetFrontLivingConnect,
diff --git a/upnpsoap.c b/upnpsoap.c
index 9ee0b90..23473b7 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -883,6 +883,16 @@ callback(void *args, int argc, char **argv, char **azColName)
if( strlen(title) > 23 )
title[23] = '\0';
}
+ /* Hyundai hack: Only titles with a media extension get recognized. */
+ else if( passed_args->client == EHyundaiTV )
+ {
+ ext = mime_to_ext(mime);
+ ret = asprintf(&alt_title, "%s.%s", title, ext);
+ if( ret > 0 )
+ title = alt_title;
+ else
+ alt_title = NULL;
+ }
}
else if( *mime == 'a' )
{
--
2.11.0

View File

@ -0,0 +1,40 @@
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
Subject: [PATCH] clients: add support for Kodi and captions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This change has been extracted out of the upstream commit 4f926639b24f8
("upnpsoap: Add additonal bookmark support").
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
--- a/clients.c
+++ b/clients.c
@@ -254,6 +254,13 @@ struct client_type_s client_types[] =
EUserAgent
},
+ { EKodi,
+ FLAG_DLNA | FLAG_MIME_AVI_AVI | FLAG_CAPTION_RES,
+ "Kodi",
+ "Kodi",
+ EUserAgent
+ },
+
{ 0,
FLAG_DLNA | FLAG_MIME_AVI_AVI,
"Windows",
diff --git a/clients.h b/clients.h
index fa39656..a7f038d 100644
--- a/clients.h
+++ b/clients.h
@@ -79,6 +79,7 @@ enum client_types {
EAsusOPlay,
EBubbleUPnP,
ENetFrontLivingConnect,
+ EKodi,
EStandardDLNA150,
EStandardUPnP
};