100 Commits
Author SHA1 Message Date
Justin Maggard 138d03db19 Reload log file on SIGHUP
There's a report about a nightly "crash" when users download, compile
from source, and replace their distro's mindlnad binary.  This is because
the Debian package includes a patch that uses SIGUSR2 to reopen the log
file and sends SIGUSR2 from logrotate instead of just using the
"copytruncate" logrotate option.  Then logrotate sends SIGUSR2 at 6:25AM,
which causes us to abort due to the unhandled signal.

I don't want to sacrifice SIGUSR2 just for log rotation, especially when
we already do some reload operations on SIGHUP.  So to avoid this
Debian/Ubuntu issue, we'll explicitly ignore SIGUSR2, and add log file
reopening to the SIGHUP handler.  Then hopefully a future Debian package
version will remove the SIGUSR2 patch and use SIGHUP instead (or
copytruncate).

Fixes: SF Bug #313 (log rotation kills minidlna service)
2018-01-23 22:01:10 -08:00
Justin Maggard 7a8ef80af0 Clean up event module on shutdown
Fixes a harmless memory leak reported by Valgrind.
2018-01-23 22:00:02 -08:00
Justin Maggard fa20ca8526 upnpsoap: Work around some bad SearchCriteria
The Control4 app apparently sends us badly-formatted SearchCriteria,
where they don't quote the upnp:class value.  So we'll add it in for them
if we detect that situation.

Fixes: SF Patches #173 (DLNA search query not as minidlna expects)
2018-01-18 17:35:02 -08:00
Justin Maggard f2294ebea8 upnpsoap: Move watch count set code to a new function 2018-01-16 17:43:15 -08:00
Justin Maggard 4c4485d225 upnpsoap: Only return sec:dcmInfo with a bookmark
There's no point in returning bookmark info without a bookmark.  It also
has been reported that certain Samsung models may have issues with
subtitles if we send dcmInfo data.  So we'll only return it if we have a
bookmark set.

[minidlna:support-requests] #52 External srt subtitles for Samsung UA48JU7800
2018-01-16 17:38:37 -08:00
Justin Maggard 9bb6cf5051 minissdp: Re-add SSDP filtering
Add back SSDP filtering.  Relying on the kernel to filter out multicast
traffic from non-member interfaces simply doesn't work the way many
people think it does, so we need to re-introduce manual filtering.  But
this time we will use in_pktinfo's ifindex for comparison rather than a
netmask comparison, so SSDP packets from other subnets should still work.
2018-01-16 17:12:20 -08:00
Justin Maggard 3990f61c57 monitor: Abort inotify directory scanning on quit
Add more interruption point in case we receive a quit signal while we're
scanning a large directory.
2018-01-12 13:57:58 -08:00
Justin Maggard c2a9186c71 Increase MAX_LAN_ADDR to 8 2018-01-11 16:09:15 -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 33fd018828 minissdp: Delay before answering ssdp:all requests
With some device combinations, our responses may be lost if we don't
delay for some time.
2018-01-08 18:04:57 -08:00
Justin Maggard 0d224a4607 upnpsoap: Add SEC namespace
Declare Samsung namespace where appropriate.
2018-01-03 23:01:46 -08:00
Justin Maggard 8b06ea863d minixml: Fix parsing error with extra whitespace
If there is extra whitespace, the iterator would not get moved properly
resulting in incomplete data.
2018-01-02 16:27:10 -08:00
Justin Maggard 2ad098fd69 Remove test code from last commit. 2017-11-29 23:52:57 -08:00
Justin Maggard 782e99873a upnphttp: Don't select an empty interface address
When determining which address to present to the client for a resource
URL, we should never use an empty string.
2017-11-29 23:31:36 -08:00
Justin Maggard ad5d6413a7 If no group is specified, use the user's primary group 2017-10-06 16:05:01 -07:00
Justin Maggard c760a338e0 Wrap up version 1.2.1. 2017-08-24 10:28:25 -07:00
Justin Maggard 50b1a2e289 scanner: Clean up non-destructive rescan
Fix several issues with the non-destructive rescan functionality.
Most of these issues also affected inotify scanning as well.  These
include annoying debug messages, adding album art for files that we
aren't supposed to be scanning anyway, incrementing the UpdateID when no
changes were made to the database, and other smaller issues.
2017-08-23 23:43:42 -07:00
Justin Maggard 9e534c56fd monitor: Support NFO file changes
Detect when a .nfo file changes, and rescan metadata for the associated
video file.
2017-08-22 15:30:10 -07: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 37346fb0a0 events: Limit subscriber count
Protect against DoS by limiting the number of subscribers we allow to a
total of 500, and immediately removing subscribers from our list if we
encounter an error communicating with them.
2017-08-22 12:20:38 -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 ca08f4540f metadata: Fix NFO parsing
The switch to dymanic allocation was botched. Fix it.
2017-07-28 17:28:15 -07:00
Justin Maggard 4df5400cb1 tivo: Fix Bonjour compatibility with Bolt
Bolt (Series6) seems to have a bug where it only reacts to
_tivo-videostream._tcp service types after a TiVo reboot, and ignores
_tivo-vidoes._tcp.  I have no idea what the difference is supposed to be
because it's undocumented, but either type works on both Roamio (Series5)
and Bolt, so hopefully it's safe for Series 3 and 4 also.
2017-07-26 16:00:20 -07:00
Justin Maggard d9f033aa43 clients: add Movian detection and enable subtitles 2017-05-20 00:16:33 -07:00
Justin Maggard c50936c347 Wrap up version 1.2.0. 2017-05-17 13:55:17 -07:00
Justin Maggard 46c692fc59 metadata: Reduce stack usage in nfo parsing
64KB is a bit much for a stack buffer.  Use dynamic allocation instead.
2017-05-17 13:55:13 -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
Justin Maggard 2b3bdb8373 utils: Move duration formatting to shared function
We'll be using this a few different places.
2017-05-17 11:56:44 -07:00
Justin Maggard 49aa42d893 scanner: Add non-destructive update rescan
New functionality, based on Shrimpkin's patch #145 on SF.
2017-05-04 23:29:59 -07:00
Justin Maggard 46d806ce2d Document the new tivo_discovery config parameter 2017-05-01 18:42:24 -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
Justin Maggard f816911f0c metadata: Fix potential crash on 3GP scanning
If we encounter a 3GP video file with no audio stream, we could end up
accessing out-of-bounds memory.
2017-05-01 17:40:20 -07:00
Justin Maggard da7d868c4b build: Fix up some conditional code
Avahi and Ogg/Vorbis library conditional enablement wasn't working as
intended.
2017-05-01 15:04:44 -07:00
Justin Maggard cee5cfc04e avahi: Clean up code formatting 2017-05-01 15:04:25 -07:00
Justin Maggard 0575299a87 tivo: Add Avahi support
TiVo Bolt doesn't support the old TiVo Beacon discovery mechanism, so
we need to support Bonjour discovery now.  Use Avahi if it's available.
2017-04-28 01:18:53 -07:00
Justin Maggard 58a5f61d46 inotify: Don't export unused function
We don't need to export inotify_remove_file(), since it isn't used
anywhere else.
2017-04-28 01:17:18 -07:00
Justin Maggard f76f060f72 libav: Fix codecpar version check
FFmpeg 3.0, as used on Ubuntu Yakkety, did not include the codecpar
changes, although it uses the same library major version. So refine the
libavformat version check to sort that out.
2017-03-16 12:09:59 -07:00
Justin Maggard 10ae45f53f upnpdescgen: Remove unused variables 2017-03-16 12:09:59 -07:00
Justin Maggard 2301120dd0 inotify: Dynamically increase inotify max watches
If we run out of inotify watches, try dynamically increasing the limit.
2017-02-14 23:54:33 -08:00
Justin Maggard 44f06f4557 inotify: Declare private functions static 2017-02-14 23:24:16 -08:00
Justin Maggard 8a996b4b62 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
2016-09-28 18:44:58 -07:00
Justin Maggard da91cb8de2 metadata: add libavformat > 57 compatibility
AVStream will no longer have a AVCodecContext reference after
libavformat major version 57.
2016-09-28 15:02:18 -07:00
Justin Maggard d1cd7c7a4a Wrap up version 1.1.6. 2016-06-16 14:29:22 -07:00
Justin Maggard 1f46b53030 Remove obsolete PNPX support.
AFAICT this has been abandoned by Microsoft.
2016-04-21 14:38:45 -07:00
Justin Maggard 02b6085380 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.
2016-04-21 14:31:53 -07:00
Justin Maggard abc1972600 inotify: fix SQL error when moving captions
Change INSERT to INSERT OR REPLACE when recording caption file moves,
to avoid UNIQUE constraint failures.
2016-03-17 14:48:05 -07:00
Justin Maggard c4166b3e77 options: Add wide_links config option.
In some environments, it makes sense to validate that symlink destinations
remain inside user-defined media_dirs.  Make this behavior configurable.
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
Justin Maggard 1c5e9ae61c containers: Add gettext support for magic containers.
Run the magic contain names through gettext, so they can get localized.
2015-12-21 11:49:07 -08:00
Justin Maggard 520de165fb nls: Rework NLS init to work with non-en_US locales.
We shouldn't blindly set the LC_CTYPE to en_US.utf8, because the user may
not have it installed.  So if the user already has a utf8 locale defined,
just use it for LC_CTYPE.

Fixed: SF Bug #87 (Problem of accentuation)
2015-12-21 11:45:10 -08:00
Justin Maggard c985eee9c7 inotify: Block signals in the inotify thread.
Otherwise, we may get invalid reads due to double-handling of signals.
2015-12-21 11:43:38 -08:00
Justin Maggard d097d3c02d nls: Move init_nls() after log_init().
Otherwise the DPRINTF in minidlna.c:init_nls() will always fail to log.
Pointed out by Shrimpkin.
2015-11-16 09:57:07 -08:00
Justin Maggard e008ab04bb Wrap up version 1.1.5. 2015-09-10 12:24:09 -07:00
Justin Maggard 0da13b33f0 flac: Fix fd leak on bad FLAC files.
Some types of bad FLAC files error out early in the metadata parsing phase,
and we weren't properly deleting the iterator if it errored out at that
point.
2015-09-10 11:58:16 -07:00
Justin Maggard e4dab2455b scanner: Add more vebose scan error message.
Print the errno in addition to the generic error message.
2015-09-10 11:57:31 -07:00
Justin Maggard c160a8c8fd Fix a couple missed frees on exit.
There were harmless, but we should fix them for correctness.
2015-09-10 11:55:54 -07:00
Justin Maggard 1b75093a43 ssdp: Allow SSDP M-SEARCH from other subnets
Based on a patch from SF user pasdVn <pasdVn3@gmx.de>.

Rely on the kernel to filter out multicasts from non-member interfaces.
Also get the address of the interface we received the multicast on using
sockopt IP_PKTINFO.

Closes: SF Patch ticket #77.
2015-09-08 15:49:22 -07:00
Justin Maggard 916546d45f tagutils: Fix divide-by-zero on bad FLAC files 2015-09-08 14:46:24 -07:00
Justin Maggard cfab9bd056 locale: Add Korean translations.
Thanks SF user manggong.
2015-08-05 10:28:47 -07:00
Justin Maggard 8f7e760747 utils: Unescape "&apos;" in .nfo files.
Kodi escapes apostrophes when exporting its database to .nfo files.

Fixes: Bug #271 (Handle &apos in .nfo files)
2015-08-03 00:20:45 -07:00
Justin Maggard f85f5afe65 upnphttp: Fix inadvertently removed line from 8e201fe. 2015-08-02 23:51:07 -07:00
Justin Maggard 98fbb5b98b Fix error message for bad user.
SF Patch #126 (Thanks Maxim).
2015-07-30 16:40:59 -07:00
Justin Maggard e7ec55a2ad getifaddrs: Fix buffer overrun with >3 interfaces. 2015-07-30 16:25:48 -07:00
Justin Maggard c29a9cf52b image: Support rotation of monochrome JPEGs.
Extends the existing 90°-increment rotation support
(i.e. /Resized/ID?rotation=DEG) to monochrome JPEGs.

SF Patch #135 (Thanks R.L. Horn).
2015-07-30 15:53:15 -07:00
Justin Maggard acac5fb3bc metadata: Handle cover art streams that come after the video stream.
SF patch #140 (`check_embedded_art` not called when Cover Art at end of file)

Using MP4Box, the Cover Art is added after the video stream.

Thanks Mathieu Malaterre.
2015-07-30 15:35:38 -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 5a309fc48f inotify: Recognize new hard links.
Based on SF patch #139 (Thanks Alenky Klaus).
2015-07-30 14:54:39 -07:00
Justin Maggard 8e201fec7b upnphttp: Check for invalid Content-Length header. 2015-07-30 13:44:42 -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 edbdd9acb4 ssdp: Fix service submit to MiniSSDPd.
SubmitServicesToMiniSSDPD(lan_addr[0].str, runtime_vars.port)
is called before lan_addr[0].str get a proper value.
Patch add call to reload_ifaces() in order to fix that
see miniupnp forum post http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=1801

Thanks Thomas Bernard for this fix.
2015-07-29 23:44:45 -07:00
Justin Maggard 30562d0b66 upnpttp: Implement PixelShape support.
TiVo uses this to get the aspect ratio correct on images.
2015-07-29 23:23:55 -07:00
Justin Maggard a294f624e0 inotify: Fix new video file detection for TYPE_AUDIO|TYPE_VIDEO media_dirs.
We were missing a return in one of the cases for the switch.

Patch #150 from user Shrimpkin.
Fixes: Support Request #40 (Inotify don't work when add *.mts video)
2015-06-26 00:03:31 -07:00
Justin Maggard 1e4cf74436 * Enable all network interfaces by default if none were specified. 2013-04-30 21:09:30 +00:00
Justin Maggard bcc69d0dd3 * Wrap up v1.1.0. 2013-04-04 23:39:12 +00:00
Justin Maggard cd20aa0b24 - SQL escape user input in TiVo command processing. 2013-04-03 00:26:54 +00:00
Justin Maggard ba75f275e1 - Check for output truncation in strcatf(). 2013-04-02 23:29:21 +00: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 bc33a34331 * Applying various OpenBSD-related changes. (Thanks SF user sthen23934) 2013-03-13 07:44:54 +00:00
Justin Maggard 42bd49276f * Fix compile issue with old ffmpeg versions. 2013-03-09 00:03:03 +00:00
Justin Maggard 11998204e2 * Code reformatting. 2013-02-04 20:23:49 +00:00
Justin Maggard 77c30bdfba * Check for NULL pointers before reading them. 2013-02-01 20:26:52 +00:00
Justin Maggard db1b9dff32 * Check for hidden album art files. 2013-01-19 01:16:19 +00:00
Justin Maggard f06a93c17a * Store the media type in the TIMESTAMP column, so we can force a rescan if the user changes the media type configuration. 2013-01-02 21:00:52 +00:00
Justin Maggard efbe1e876f * Minor man page updates. 2012-11-16 20:10:10 +00:00
Justin Maggard bcaf6f3024 Add man pages contributed by Noel Butler <noelb@ausics.net>. 2012-11-16 19:03:58 +00:00
Justin Maggard 2521b3f238 * Force a rescan if a media_dir has been removed from the configuration. 2012-11-16 08:06:24 +00:00
Justin Maggard 1320eb4ea6 * Update coding style. 2012-11-16 08:01:05 +00:00
Justin Maggard aee83a3ee6 * Improve how we clean up after ourselves during exit. 2012-11-16 07:40:40 +00:00
Justin Maggard 035fd35ffd * Fix up bad accesses found by valgrind. 2012-11-06 08:24:37 +00:00
Justin Maggard fa37df8b1f * Add support for TiVo MPEG-TS files. 2012-11-03 09:45:45 +00:00
Justin Maggard ec2beb799d * Enable quiet building. 2012-11-03 09:17:28 +00:00
Justin Maggard d5ebaa13f0 * Fix a potential divide-by-zero error. 2012-10-09 20:07:15 +00:00
Justin Maggard 2e120e83a0 * Add some logging and forking tweaks to work better with systemd. 2012-10-04 21:04:36 +00:00
Justin Maggard de15926f76 * Rename minidlna to minidlnad, and install it in /usr/sbin like a proper system daemon. 2012-10-04 21:03:41 +00:00
Justin Maggard 584258c1f8 * Add support for limiting a media dir to multiple media types. 2012-10-03 07:26:00 +00:00
Justin Maggard fdcdd9ded8 * Fix inotify parsing of new video symlinks. (SF bug #3552473) 2012-08-20 21:30:16 +00:00
Justin Maggard 89c70bab24 * Fix ffmpeg API version checks. (SF bug #3549925) 2012-07-30 19:56:30 +00:00
Justin Maggard b15a5d144d * Move SearchCriteria parsing to its own function. 2012-07-28 01:17:30 +00:00