173 Commits

Author SHA1 Message Date
Gleb Smirnoff
f9a78d598e Support for pluggable event modules, stage 1. Take out select() loop and associated code into a separate module select.c. Detailed list of changes down below.
The idea is taken from the nginx web server, but much simplified and
almost no copypaste left. This will allow minidlna to use different
event dispatcher APIs, which would be defined at compile time.

My personal goal is to convert minidlna to kqueue(2) on FreeBSD. This
would later allow for kqueue based directory change notification, which
won't conflict with select(2) like the current patch does.
Other platforms will also benefit from the pluggability of the event
system, Linux can switch to epoll(2) or at least to poll(2).

Detailed list of changes:

* event.h [New]
  Our internal API to unify different event dispatch systems.
* select.c [New]
  Much simplified version of nginx's ngx_select_module.c.
* minidlna.c
  - Split out listen socket event processing into separate function
    ProcessListen(), which matches event_process_t type.
  - Create and initialize struct event for the monitor socket, SSDP
    socket, HTTP socket and beacon socket.
  - Simplify and make more precise timeout calculation using
    helper timeval functions from utils.c. Treat gettimeofday() error
    as a fatal event.
  - Rip out all stuff related to select(2). Just call event_module.process().
* upnpevents.c
  - Embed struct event into upnp_event_notify.
  - Merge upnp_event_create_notify() with upnp_event_notify_connect().
    Start connecting immediately after socket creation. Garbage collect
    now useless ECreated state.
  - Make upnp_event_process_notify() of event_process_t type, and use it
    as process callback for upnp_event_notify event.
  - Looks like we always create upnp_event_notify with existing subscriber,
    and never clear it later. Remove checks for obj->sub and assert that it
    is never NULL. Simplifies things.
  - When switching obj state, add/del it to event dispatcher accrodingly.
  - Garbage collect upnpevents_selectfds().
  - Garbage collect select(2) related stuff from upnpevents_processfds().
    Rename function to upnpevents_gc(), since the remaining functionality
    is garbage collecting, not file descriptor processing.
    Actually, this can be simplified even more. We can safely close sockets
    and free objects immediately, eliminating need for upnpevents_gc(). But
    this change would be beyond scope of this commit.
* upnphttp.c, upnphttp.h
  Embed struct event into struct upnphttp. Adjust Process_upnphttp() to match
  event_process_t type. Add/del to event dispatcher once creating/closing a
  socket.
* minissdp.c, minissdp.h
  Make ProcessSSDPRequest() of event_process_t type.
* getifaddr.c, getifaddr.h
  Make ProcessMonitorEvent() of event_process_t type.
2018-01-16 16:53:08 -08:00
Justin Maggard
3e9ca13fa3 upnpsoap: Add forced alphasort capability
Add the ability to force title modification for clients that do their own
alphanumeric sorting.  Adding a '!' to the beginning of the
force_sort_criteria value will enable this behavior.

It is implemented by prepending all titles with a zero-padded number, and
possibly season and episode (or disc and track) numbers if they aren't
already in the title.
2018-01-11 11:12:22 -08:00
Justin Maggard
c0e66e9997 metadata: Add episode season and number support
Add upnp:episodeSeason and upnp:episodeNumber support for video items.
The DISC and TRACK columns are multiplexed to store the data.
2018-01-11 11:12:22 -08:00
Justin Maggard
8bdba2f40d options: Add enable_subtitles config option
Enable generic subtitle support by default for unknown clients.  Set the
new enable_subtitles option to false to revert to the old behavior.
2018-01-11 11:11:42 -08:00
Justin Maggard
0d224a4607 upnpsoap: Add SEC namespace
Declare Samsung namespace where appropriate.
2018-01-03 23:01:46 -08:00
Justin Maggard
c8665bcf40 containers: Add Samsung DCM10 magic containers
Some Samsung clients (at least UE40ES8000) apparently cannot handle our
standard container IDs when we turn on the DCM10 feature. So they end up
requesting an empty ObjectID, which is invalid. If we blindly return our
root container, they still have problems browsing because they only use
one object from our returned results, so they don't get a full list of
browseable categories.

It has been confirmed that we can work around this by using the same
ObjectIDs that Samsung uses for our root containers in our
X_GetFeatureList response (A, V, and I). And fortunately it's trivial to
handle these renamed ObjectIDs using our magic container system.

Fixes: SF Bug #311 (Samsung TV built-in DLNA client broken since v1.1.5)
2017-08-22 12:28:42 -07:00
Justin Maggard
14d0110fb4 upnpsoap: Add extra thumnail res for Samsung video thumbnails
It's been reported that modern Samsung TVs (Series F?) won't show video
thumbnails unless they're listed as JPEG_SM. So add an extra entry for
that.
2017-07-28 18:14:52 -07:00
Justin Maggard
4f926639b2 upnpsoap: Add additonal bookmark support
Add support for upnp:playbackCount and upnp:lastPlaybackPosition tags.
These are used by Kodi to keep track of bookmark information as well as
determining whether to show the checkmark to indicate that the video
has been played.

Also add support for the UpdateObject command, which Kodi uses to
update the playbackCount and lastPlaybackPosition information.

This change requires a DB schema update, which should be done
automatically on the first run.

Inspired by SF user Karsten's patch #167.
2017-05-17 12:01:04 -07:00
Jindřich Makovička
5450ac486e 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.
2017-05-02 15:22:40 -07:00
Justin Maggard
d894885bc1 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.
2017-05-01 17:49:16 -07:00
Darkvater
5339075393 Update support for LG2012 TV
LG 2012 series does not need '.' in title anymore to be able to show
captions
2016-03-17 14:48:05 -07:00
Eduardo Rocha
126f0f5cb8 Samsung bookmark - go back to the beginning of the movie if less than 30 seconds was played. 2016-03-17 14:48:05 -07:00
Eduardo Rocha
cae3e880d2 Samsung bookmarking: fix for magic containers 2016-03-17 14:48:05 -07:00
Justin Maggard
4ec6cd0053 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)
2016-01-07 00:39:37 -08:00
Darkvater
f09339d95c Fix an issue in trunk with captions
When a browse command is issued multiple files are returned. As soon as one had a caption, all files were marked as having captions because the flag wasn't cleared.

Signed-off-by: Justin Maggard <jmaggard@netgear.com>
2015-07-30 15:45:53 -07:00
Justin Maggard
b78c25f260 upnpsoap: Use magic container sort order.
Magic containers can have a pre-defined sort order.  Let's use it by default if
it exists.
2015-07-30 15:10:03 -07:00
Justin Maggard
b94f04d6ef upnpsoap: Work around LG TV ordering bug.
From SF Patch #90:

My LG TV (42LE5500) retrieves items from BrowseDirectChildren in a weird way.
The TV can only display up to 20 items per page, but it sets RequestedCount to
54. StartingIndex is correctly set to 0, 20, 40, ... etc. When minidlna responds
with the 54 entries, the TV sorts folders (containers) first, before items, then
displays the entries, limited to 20 per page.

In my setup, I have ~23 folders whose names are similar to the files, so that
when sorting by name, the folders are mixed with the files, thereby resulting in
duplicate folders appearing on all 3 pages and many missing files. The solution
is to make sure minidlna orders items the same way that the TV expects them, so
that when the StartingIndex is 20 or more, we return the "correct" subset of
items.

Thanks SF user Darell Tan for the fix.
2015-07-29 23:58:21 -07:00
Justin Maggard
13d36533b5 cleanup: Declare some unshared functions static. 2015-04-10 15:47:28 -07:00
Justin Maggard
c1bb37a387 clients: Re-enable Samsung DCM10 flag.
The browsing issue that was reported on Samsung Series F was
actually only present when a custom root container was being
specified (http://sourceforge.net/p/minidlna/patches/121/).

So instead of disabling DCM10, fix our X_GetFeatureList
response when a custom root container is set.  If the custom
root is Browse Folders, then drop the user straight to
folder browsing for that media type.  If it's something
other than folder browsing, just set all media type roots to
the custom root container.

For future reference, the DCM10 flag enables (at least)
video bookmark support and Samsung "BasicView" support; so
selecting, for example, Videos from the Samsung UI can send
you straight to the Videos section of the media library.
2015-04-10 15:33:09 -07:00
Justin Maggard
ec11819012 upnpsoap: Don't honor the NO_RESIZE flag for thumbnails
Some images don't include an embedded thumbnail, and others
have the thumbnail in the wrong aspect ratio.  In these
cases we resize ourselves, which we should allow to occur
regardless of the NO_RESIZE flag.
2015-04-09 16:57:08 -07:00
Justin Maggard
f09f441607 upnpsoap: Handle StartingIndex on magic containers
We need to subtract StartingIndex when we limit SQL query
results based on the max number of items in a magic container.
2015-04-08 01:21:21 -07:00
Justin Maggard
3c4c35b49c upnpsoap: Use scaled thumbnails when rotation is needed
Embedded thumbnails may have an undesirable orientation, so
we should do our own scaling with inline rotation if the
thumbnail image needs to be rotated.
2014-12-11 17:03:35 -08:00
Justin Maggard
8029921884 containers: add magic container infrastructure
Add support for dynamic containers, with enough flexibility to also
replace our existing container ID replacement functionality.
2014-07-01 17:08:18 -07:00
Justin Maggard
95bbedb196 upnpsoap: factor out some duplicated code. 2014-06-27 12:59:50 -07:00
Justin Maggard
c226e615ad upnpsoap: factor out ObjecID translation into a separate function. 2014-06-26 18:54:45 -07:00
Justin Maggard
e9a653d6e8 clients: restructure client cache 2014-06-09 18:02:03 -07:00
Justin Maggard
13e3613dd6 Minor code simplification. 2014-04-28 12:00:59 -07:00
Catalin Patulea
3a57744735 Add printf attribute to log_err/DPRINTF and fix a few warnings
Modified to not use %z for portability reasons.
2014-04-10 18:57:30 -07:00
Justin Maggard
d492b43ef8 Fix various potential illegal access and memory leaks in error conditions. 2014-04-07 11:20:19 -07:00
Justin Maggard
6e43ab3c06 Introduce THISORNUL macro. 2014-04-07 10:29:56 -07:00
Justin Maggard
e3792ad8da upnpsoap: fix uninitialized read with emtpy filter 2014-04-07 09:08:30 -07:00
Justin Maggard
0ea24845eb clients: add Asus O!Play support and quirks
Asus O!Play reboots with titles longer than 23 characters with some
file types when there are subtitles present.  So we truncate video
file titles with external subtitles.

It also supports subtitles in LG fashion, so add that too.
2014-03-13 10:48:41 -07:00
Justin Maggard
365d5c3412 upnpsoap: make subtitle support more generic
It sounds like more clients may support subtitles using a res element,
so we should make our support more generic.
2014-03-12 11:59:10 -07:00
Justin Maggard
ce16739213 samsung: fix root_container setting
Pretend that we don't support SamsungGetFeatureList if we have a
custom root container specified, or else the Samsung client will
jump straight to our normal A/V/P sections.
2014-03-07 12:23:58 -08:00
Justin Maggard
65fb740414 upnpsoap: Support searches specifying @parentid = 0. 2014-02-04 12:03:57 -08:00
Justin Maggard
a3252bd2dd minissdp: Use struct ip_mreqn for multicast membership if it's available. 2014-02-03 15:02:30 -08:00
Justin Maggard
16b0963a5b Add fake X_MS_MediaReceiverRegistrar RegisterDevice support. 2014-01-31 16:25:43 -08:00
Spencer Oliver
fc6b47fe6a upnpsoap: fix incorrectly formed Samsung GetFeatureList reply
Bug raised here https://sourceforge.net/p/minidlna/bugs/210/, and also
mentioned in http://sourceforge.net/p/minidlna/discussion/879956/thread/34276163/.
However patch given needs to correctly escaped to work otherwise the
renderer will get stuck in an endless loop.

Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-31 15:35:30 -08:00
Spencer Oliver
7e6b015b05 upnpsoap: fix samsung bookmarks
This makes the bookmark functionality work as expected on Samsung E series.
Adapted from http://sourceforge.net/p/minidlna/discussion/879956/thread/1a711ef6/ and
http://sourceforge.net/p/minidlna/bugs/197/.

Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-31 15:33:51 -08:00
Spencer Oliver
e2c73f163d clients: merge samsung Series C client id
A Samsung TV cannot be reliably detected by checking for "SEC_HHP_TV"
User Agent. Only the first part can be guaranteed, eg. "SEC_HHP_" as the rest
can be changed by the end user.

Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-31 15:33:51 -08:00
Spencer Oliver
b0c1dea56b upnpsoap: fix some clients playing artwork instead of movie
While playback on an Samsung E Series TV is ok, other clients such as VLC
and vplayer (android) attempt to play the artwork rather than the movie.

The issue was traced to minidlna serving the artwork res before the movie res.
Other dlna server's were observed and found to the send the movie first then
the artwork.

Swapping the order seems to keep all tested clients happy.

Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-31 15:33:51 -08:00
Justin Maggard
f119cfe1a6 Support @parentID in SearchCriteria. 2014-01-31 13:18:36 -08:00
Justin Maggard
3f4877cf2f Add a new force_sort_criteria option, to globally override the SortCriteria value sent by the client. 2014-01-07 11:30:15 -08:00
Justin Maggard
0700cf9774 Fix up a few conformance issues with latest testing tools. 2013-10-22 19:05:22 -07:00
Justin Maggard
a4a301d1df Set the conversion indicator on fake resources for Sony BDP's. New models support most of these natively, and don't like fake resources. 2013-06-12 23:25:30 -07:00
Justin Maggard
1c748c1d5a * Consolidate client detection code.
* Add forced sorting support for Panasonic devices.
2013-03-18 05:37:46 +00:00
Justin Maggard
fa37df8b1f * Add support for TiVo MPEG-TS files. 2012-11-03 09:45:45 +00:00
Justin Maggard
b15a5d144d * Move SearchCriteria parsing to its own function. 2012-07-28 01:17:30 +00:00
Justin Maggard
2d0ae24009 * Do some additional SQL escaping. 2012-07-28 01:16:43 +00:00
Justin Maggard
f0c7768533 * Add a flag to tell ParseNameValue() to store empty XML elements. 2012-07-10 21:12:10 +00:00