Commit Graph

1735 Commits

Author SHA1 Message Date
wm4 3cd394995f cache: assume file size from EOF position
If we're caching a stream with unknown size, and we reach EOF, then
consider the EOF position the file size. Typically makes sense when
reading from a pipe or a http connection that did not send a size.
2015-03-04 17:28:42 +01:00
wm4 9746e71efc stream_cdda: add option to enable cdtext, and disable it by default
Fixes #1615.
2015-03-03 15:29:07 +01:00
wm4 1ba24d2585 stream_cdda: fix parameter passing
All cdda options (except --cdrom-drive) were ignored, because the priv
struct (with the options set) was just replaced. Oops.
2015-03-03 15:28:26 +01:00
wm4 a4b6bf8c41 player: refine rar:// playlist-safety handling
It was possible to make the player play local files by putting rar://
links into remote playlists, and some other potentially unsafe things.

Redo the handling of it. Now the rar-redirector (the thing in
demux_playlist.c) sets disable_safety, which makes the player open any
playlist entries returned. This is fine, because it redirects to the
same file anyway (just with different selection/interpretation of the
contents). On the other hand, rar:// itself is now considered fully
unsafe, which means that it is ignored if found in normal playlists.
2015-03-02 19:09:36 +01:00
Oliver Freyermuth 40c9e79068 stream_dvb: Always define NO_STREAM_ID_FILTER if missing.
It is also used for initialization in channel-list setup.
Should fix compilation on FreeBSD, and is more correct
since it is used unconditionally.
Reverts 6445648 .
2015-02-28 18:27:21 +01:00
wm4 fbf76da913 stream: remove stream filter concept
Unused since the previous commit. (Apparently it was a stupid idea.)
2015-02-27 19:51:14 +01:00
wm4 5824eb7107 stream_rar: treat rar files as playlists
Refactors an older hack, which for some reason used a more complicated
way. This generates the playlist representing the contents of the rar
file in demux_playlist.c. The pseudo-demuxer could easily be separate
from the the playlist parsers (and in fact there's almost no shared
code), but I don't think this obscure feature deserves a separate file.

Sample files created with:

    rar a -v20000k -m0 files.rar file1.mkv file1.mkv
2015-02-27 19:44:39 +01:00
wm4 e85bcc1223 cache: use MPCLAMP() macro 2015-02-25 22:23:31 +01:00
wm4 899f0cd51e cache: limit to file size
Saves some memory. Should be especially helpful if many small files are
loaded, like when mass-loading subtitle files and the cache is enabled.
2015-02-25 22:23:25 +01:00
wm4 3c9344a1a9 stream_file: open pipes non-blocking
Now the player can actually be quit if a pipe was opened, but nobody is
writing to it.
2015-02-20 20:01:01 +01:00
wm4 3f5b5b758d cache: silence "EOF reached" message
This message will be printed relatively often once EOF is reached. In
some cases this is rather annoying, for example when playing HLS. (With
HLS, the stream is just a playlist file, while libavformat opens actual
media files without mpv's knowledge, so the cache is completely useless
and hits EOF instantly.)

That it retries reading is apparently a good thing: at least local files
can grow, and even after the player got the EOF, playback _could_ be
resumed by basically polling and detecting that there is more data. So
I'm not changing this behavior yet.
2015-02-18 21:13:11 +01:00
wm4 cf881396b5 dvb_tune: fix invalid syntax
Oops.
2015-02-11 11:36:14 +01:00
wm4 5de29b860b stream: get rid of remaining uses of the end_pos field
Most things stopped using this field for better support of growing
files. Go through the trouble to repalce the remaining uses, so it can
be removed.

Also move the "streaming" field; saves 4 bytes (wow!).
2015-02-06 21:43:52 +01:00
wm4 347cf97231 stream: minor cleanups
Fix return types and return values to make them more consistent. Some
reformatting and making code more concise.

In stream_reconnect(), avoid the additional mp_cancel_test() call by
moving the "connection lost" message below the mp_cancel_wait() call,
which effectively leads to the same behavior when the stream was already
canceled. (The goal is not to show the message in this case.)

Merge stream_seek_long() into stream_seek(). It was the only caller.

Always clear the eof flag on seeks.

Reduce access to stream internals in cache.c and stream_lavf.c.
2015-02-06 21:43:52 +01:00
wm4 45e214d7ae stream: slightly improve reconnect behavior
Wait for a longer time between reconnects. Introdeuce and use
mp_cancel_wait(), so that quitting is still immediate.
2015-02-06 19:19:15 +01:00
wm4 e14d09c8a6 stream_lavf: fix build with Libav
The API function used is FFmpeg-only.

Sigh...
2015-02-06 18:02:37 +01:00
wm4 f3ae845fd2 options: add --network-timeout
Not quite sure if this actually works as intended.

Fixes #1566.
2015-02-06 17:01:35 +01:00
wm4 5bce4664be stream_cdda: fix bugs in chapter time retrieval
Looks like a bunch of off-by-one errors.

The track number was mistakenly offset by 1 - this shifted all chapters
by one, and make the first chapter start on the second track (so the
"chapter" property returned -1 in the first track since it was before
the first chapter).

Also, the calculation of the sector destination was messed up. This
comes from commit 32d818f0, where I apparently attempted to calculate
the position to one byte before the section, but unfortunately math
doesn't work this way and it was nonsense. Just drop this idea; while it
may help with seeking (probably...), it also returns slightly different
times. The user shall use hr-seeks if accurate seeking is required.

Hopefully fixes #1560.
2015-02-04 15:17:49 +01:00
wm4 9d8b00f1d6 command: add dummy get implementation for tv-channel property
A small cosmetic change with the effect that pressing 'k' shows
"unavailable" instead of "error" (even if no  TV code is active).
2015-02-02 18:07:37 +01:00
wm4 303924c343 stream: reject overly long URLs 2015-01-21 12:11:37 +01:00
wm4 d558accaa6 stream_lavf: escape disallowed characters in http URLs
In my opinion, libavformat should be doing this. But a patch handling a
very safe case rejected, so I suppose we have to do it manually. (This
patch was only escaping spaces, which can never work because they break
the basic syntax of the HTTP protocol.)

This commit attempts to do 2 things:
- Try to guess whether libavformat will use the URL for http. This is
  not always trivial, because some protocols will recursively pass part
  of the user URL to http in some way.
- Try to fix invalid URLs. We fix only the simplest case: only
  characters that are never valid are escaped. This excludes invalid
  escape codes, which happen with freestanding '%' characters.

Fixes #1495.
2015-01-21 12:10:49 +01:00
wm4 7a7d8d50e2 dvd: try to improve seeking
libdvdnav is garbage. Seeking by time is incredibly inexact, which is in
part due to the fact that it does not use the DVD seek tables. Instead,
it assumes CBR for certain ranges within the DVD, which makes especially
small seeks unreliable.

I have no good fix for this, other than hacking libdvdnav (I'd rather
prefer to remove mpv DVD support completely than doing this). So here's
a shitty hack that tries to workaround these problems. A basic
observation is that seeking in VLC seems to work quite well; however it
seems to be based on seeking by blocks (unless there is a subtle "trick"
I didn't see in the source code). mpv usually seeks by timestamps, so
this is not an option for us. However, we can pretend we are doing this
in the DVD layer.

The previous commit added a way to pass through relative seeks. This
commit uses the relative seek. STREAM_CTRL_SEEK_TO_TIME is backwards
compatible (there's still dvdread and bluray), so most code is about
extracing the relative seek information and turning it into a block
seek.

(Another way would have been using SEEK_FACTOR stuff, but that would
probably make for a less reliable way to handle this situation.)

Additionally, if a hr-seek is done, add an offset by 10 seconds. As long
as the error done by libdvdnav is not worse, this should help with hr-
seeks - although it makes them much slower.
2015-01-19 21:30:05 +01:00
wm4 616cfb90c1 stream_dvb: silence bogus compiler warning
This complains within dvb_strtok_r() that savePtr is uninitialized.
There doesn't seem to be any code path where this can happen though, so
it's probably a false positive. Silence it anyway.
2015-01-19 17:58:37 +01:00
Oliver Freyermuth 794804725d cache: cache-position needs to be int64_t
Both max_filepos and offset are int64_t,
so pos can overflow, e.g. causing endless loops
in stream implementation.
2015-01-13 02:39:16 +01:00
Oliver Freyermuth 3d1b9ba4bd stream_dvb: Add MP_ERR if polling worked, but read fails.
Read can still fail, e.g. if the buffer is invalid.
2015-01-13 02:37:12 +01:00
wm4 12910da66a stream_pvr: uncrustify
Mostly automatic, with some manual changes.
2015-01-06 20:27:36 +01:00
wm4 c915b0b0ec dvb: uncrustify
Mostly automatic, some manual changes.
2015-01-06 20:19:49 +01:00
Oliver Freyermuth ec92ab294e stream_dvb: Enable streaming mode, activates cache.
This causes more constant reading from the DVB device,
and seems not to hurt the stream-controls.
As the device cache seems to fill up when not
reading from it for several seconds, reading
into the cache fixes desync-issues after
the initial analyzeduration of the demuxer.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 672b5df411 stream_dvb: Do not add special PIDs if we anyways record the full TP.
This just exchanges two blocks of code: If we record
the full transponder, no need to explicitly add some PIDs to the
filter list.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth ca32a15a22 stream_dvb: Add possibility to dump a full transponder.
Was already possible before by injecting the magic PID
8192 into channels.conf, the flag makes this much more
useable and we also have it documented.
Useful not only for debugging, but also for incomplete
channels.conf (mplayer format...), multi-channel
recording, or channels which do dynamic PID switchng.

full-transponder is also useful for channels which switch PIDs on-the-fly.
ffmpeg can handle this, but it needs the full stream with all PIDs.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 7f84da4902 stream_dvb: Record PIDs with human-readable content, bump max demuxer count.
There is the STD which contains service-names
(ffmpeg can understand it),
and the EIT which contains the EPG
(ffmpeg does not parse it, but e.g. VLC does).

As we now have more PIDs in general, increase the maximum
number of demuxers we can open. ffmpeg has an internal
limit of 64 PIDs, we are still far from that.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth f309ecebe5 stream_dvb: Also demux PMT if possible, reactivate TPID parsing.
If VDR-channel-config is used, we know the service_id.
Using that, PMT can be extracted from PAT (code for that
inspired by szap-s2 again).
For this, we need to demux PAT with a special filter-setup,
and once PMT was found it can be added to the PID-list.
PMT is only resolved the first time one tunes to a channel,
then stored in the channel-list in memory.

With PMT available, ffmpeg can safely decode the teletext-pids.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth ef463aa103 stream_dvb: Extend token-list for pid-parsing, magically allows to parse VDR-style PID-lists.
I also added a comment explaining the potentially occuring structures for future reference.

For tokenization, a custom strtok_r implementation is used,
inspired by strtok_r as implemented in musl and ffmpeg,
hopefully slightly more readable (av_strtok_r is not available in libav,
and strtok_r is not available everywhere).
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 02e6cf7a0a stream_dvb: Move out PID-parsing, disable TPID parsing.
Move PID-string parsing into a separate function, reduces code-duplication.
Drop TPID-parsing again since teletext-stream seems not really correctly identified (ffmpeg guessed mp3 in my test...).
Parsing now done using strtok + sscanf instead of sscanfs with fixed numbers of expected fields -
gives more correct checking of PID-overflow, will allow VDR-style PID-field parsing.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 2c6ce12b3c stream_dvb: Add TPID (teletext-pid) parsing from VDR-style channel-lists.
The PID-parsing is not really nicely done and also does not yet handle the special VDR-style syntax.
A later commit will move the parsing to a separate function handling that which also checks that the maximum PID-count is not exceeded.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 641cba9e3d stream_dvb: Handle VDR-config location-field as DISEQc-field.
In mplayer-style channels-config, we had a LNB-field used for that.
In old VDR times, the location-field was also containing DISEQc information,
now it does that only indirectly (location => LNB => vdr knows from lnb-config).
We only accept it as this if the field is fully numeric.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 7fe5d8c78e dvb: Extend understanding of VDR channel config: stream_id, inversion.
Now also "stream ID" (for DVB-S2) and "inversion" are understood.
The parameter-string can also provide information on FEC, rolloff etc. For DVB-S, "auto" which mpv uses by default should be fine, I can also confirm it works. For non-DVB-S cards, it might be useful to also parse this information in case of a vdr-channel list.
As I have no such hardware and thus would have to do it blindly, I added a FIXME.
Mostly complete vdr-channels.conf format documentation is at http://www.vdr-wiki.de/wiki/index.php/Channels.conf (german only).
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 0c42484d8e stream_dvb: Very basic vdr-type channels.conf support.
Still incomplete. Initialize is_dvb_s2 boolean in channel-struct.
We first check whether the channels.conf-line at hand is sscanf'able with a vdr-style pattern. If yes, we assume it is a vdr-channel-config (we check whether sscanf consumed the full line).
The vdr-style config also contains a parameter-string which contains information about polarization + delivery type (e.g. DVB-S2).
With this change, S2-tuning works with a VDR-channel list.
Missing (later commits):
- vdr-parameter-string also contains other information, e.g. invert-flag, needs to be parsed.
- Diseqc-lnb-number is not present in VDR-config (I believe it is handled via the location-parameter + lnb-config there). For backwards compatibility, the location-parameter can be the lnb-number - we should test whether it is an int and assume this in this case.
- VID, AID and TID-lists are extremely ugly in their syntax for VDR. At the moment, only the first number is parsed (and TID fully ignored), needs to be fixed.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth bef1893cd5 dvb: Extend dvb_channel struct, needs to know whether channel is S2.
It contains now also a boolean which tells whether this is an DVB-S2 channel (not initialized yet - tbd in next commit).
We could also pass through the type of the delivery system (would be more flexible), but the delivery-system-enum is only available with S2API, so this is more backwards-compatible.
If someone has DVB-T2 / DVB-C2 hardware and extends the code to deal with it, this should be changed.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth 3abf26f019 dvb_tune: (DVB-S) Initial S2API support.
Also allows demuxers to buffer, and we explicitly discard stale QPSK events.
Inspiration taken from the szap-s2 implementation.
S2API is only used if available and for DVB-S cards - it might also be useful to have that for DVB-T2 / DVB-C2 tuning later, but I do not have the HW / no DVB-T2 broadcasting station nearby to test functionality.
This should do no functional changes, only usage of the different API. The S2API is more extensible and a requirement for all the HD-deliveries (e.g. DVB-S2) and since 2.6.28 is the successor of the old API.
Tuning to DVB-S2 channels actually already "works" like this if the delivery is hardcoded in - for a fully working implementation, the channels.conf.sat would need an additional field indicating the delivery type (VDR-type channels.conf have that).
This commit also:
- Cleans up some debug output.
- Moves an unneeded usleep(100000) (only needed for diseqc switching for SAT) into the DVB-S-only part of the implementation.
2015-01-06 19:52:27 +01:00
Oliver Freyermuth ae81cb4343 dvbin: Prepare S2API-implementation, support different DVB-API versions.
Define a new macro "DVB_USE_S2API" to be used to switch to S2API if available,
also document what is the main difference in the new S2API.

StreamID-handling is only supported since API 5.2, and some macros
were renamed or only added later with 5.8 (somewhere around kernel 3.6),
so some define-fixups are needed to support these intermediate
kernel header versions.
2015-01-06 19:52:27 +01:00
wm4 1a6dc9ae44 stream_pvr: sort channel list by --tv-channels order
Apparently this is what users would expect.

Going the way of least resistance (in terms of messing with this old,
rarely used code), sorting them by some kind of addition timestamp
(called priority in the patch) is the easiest.

Fixes #1390.
2014-12-28 20:04:25 +01:00
wm4 ed253beef0 stream: always make stream dumping/capturing append to output file
Partially fixes #1393 (but not really).
2014-12-27 21:20:57 +01:00
wm4 b164e8c2fe stream_pvr: remove redundant log prefixes 2014-12-26 14:25:41 +01:00
wm4 98ba7b44d9 stream_pvr: increase timeout, slightly better error reporting
An attempt to find out what's wrong with issue #1382.

I don't even know why a timeout would be needed; for robustness with
broken devices maybe?
2014-12-26 14:18:48 +01:00
wm4 2b3b88b6ee stream: always disable cache for pseudo-streams
Streams which don't have a full_buffer function never return any actual
data. Slight improvement over commit 5640c195.
2014-12-24 14:33:34 +01:00
wm4 5640c195a9 stream_edl: disable caching
stream_edl merely makes demux_edl act "special", which checks for the
stream type explicitly and then does something with its URL. If a cache
is added before the stream, it'll try to use the cache's URL (i.e. an
empty string), and will then obviously fail to parse the URL. While this
is slightly stupid, just disabling the entirely useless cache is the
most effective solution.

Fixes #1378.
2014-12-23 14:57:50 +01:00
wm4 50e39ebb0a dvd: add the last chapter
As suggested in issue #1251. I think the main point is that it acts as
a hack to return to the DVD menu when jumping past the last chapter,
because it will reach title-EOF, instead of explicitly jumping to the
next file (which usually exits the player).

This basically reverts commit 8b7418d, except it doesn't include an
off-by-1 error (apparently).

Closes #1251.
2014-12-16 19:28:08 +01:00
wm4 5b618ef629 command, dvd: add property which returns list of DVD titles
This was requested.

It seems libdvdread can't get the duration for titlesets other than the
currently opened title. The data structures contain dangling pointers
for these, and MPlayer works this around by opening every title
separately for the purpose of dumping the title list.
2014-12-13 20:25:56 +01:00
wm4 c3275f7e53 stream_cdda: don't return number of tracks as number of titles
Apparently, we treat different tracks as titles, so returning the number
of titles (which is user-visible as "disc-titles" property) is
completely misguided.
2014-12-13 20:25:56 +01:00