Commit Graph

2102 Commits

Author SHA1 Message Date
wm4 a9d83eac40 Remove optical disc fancification layers
This removes anything related to DVD/BD/CD that negatively affected the
core code. It includes trying to rewrite timestamps (since DVDs and
Blurays do not set packet stream timestamps to playback time, and can
even have resets mid-stream), export of chapters, stream languages,
export of title/track lists, and all that.

Only basic seeking is supported. It is very much possible that seeking
completely fails on some discs (on some parts of the timeline), because
timestamp rewriting was removed.

Note that I don't give a shit about optical media. If you want to watch
them, rip them. Keeping some bare support for DVD/BD is the most I'm
going to do to appease the type of lazy, obnoxious users who will care.
There are other players which are better at optical discs.
2019-09-13 17:31:59 +02:00
wm4 cf36e3d15b stream_dvdnav: merge stream_dvd_common
Isolate icky DVD garbage into a single file.
2019-09-13 15:35:23 +02:00
wm4 6229404985 Remove libdvdread support in favor of libdvdnav
stream_dvd.c contained large amounts of ancient, unmaintained code,
which has been historically moved to libdvdnav. Basically, it's full of
low level parsing of DVD on-disc structures.

Kill it for good. Users can use the remaining dvdnav support (which
basically operates in non-menu mode). Users have reported that
libdvdread  sometimes works better, but this is just libdvdnav's problem
and not ours.
2019-09-13 15:29:27 +02:00
Aman Gupta 877ae46125 stream_file: avoid redundant free
s->priv->cancel will be freed when s is freed, so
freeing it explicitly is not required.

Signed-off-by: Aman Gupta <aman@tmm1.net>
2019-09-11 13:10:03 -07:00
Oliver Freyermuth c8424a3bee stream_dvb: Increase timeout of streaming read.
It seems some DVB-T2 cards take longer to push out data.
2019-09-02 01:19:33 +03:00
Oliver Freyermuth 66128dec82 stream_dvb: Adapt to VDR channel config format.
While they accept the frequency field with MHz for DVB-S,
for DVB-C and DVB-T, it may be in Hz, kHz or MHz.
The official rule is to multiply whatever is in the channels.conf
by 1000 until a value > 1000000 is reached to get correct units for tuning.
2019-09-02 01:19:33 +03:00
dudemanguy 037cbacb8c libarchive: add fallback for systems without C.UTF-8 2019-05-04 14:17:40 +02:00
Jan Ekström 199aabddcc Merge branch 'master' into pr6360
Manual changes done:
  * Merged the interface-changes under the already master'd changes.
  * Moved the hwdec-related option changes to video/decode/vd_lavc.c.
2019-03-11 01:00:27 +02:00
Oliver Freyermuth d6d6da4711 stream_dvb: Correct range for dvbin-card option.
Adapt documentation accordingly and
also, fix an off-by-one check in the code.
closes #6371
2018-12-12 01:50:43 +02:00
wm4 19a38c4b1f stream: silence failed seek message on termination
Seems to happen often with ytdl pseudo-DASH streams, so whatever. I
couldn't reproduce it and check what triggers it, I just remember seeing
the error message and found it annoying.
2018-12-06 10:33:28 +01:00
wm4 9b10869a61 stream: something 2018-12-06 10:33:14 +01:00
wm4 4dfaa37384 demux, stream: readd cache-speed in some other form
it's more like an input speed rather than a cache speed, but who cares.
2018-12-06 10:30:41 +01:00
Anton Kindestam 8b83c89966 Merge commit '559a400ac36e75a8d73ba263fd7fa6736df1c2da' into wm4-commits--merge-edition
This bumps libmpv version to 1.103
2018-12-05 19:19:24 +01:00
pavelxdd bdec4421e6 stream_smb: make sure the string is NULL-terminated after strncpy
strncpy does not guarantee that the string will be NULL-terminated.
2018-10-25 13:49:49 +02:00
wm4 7e85dc2167 stream_libarchive: fix hangs when demuxer does out of bound seeks
This happened with a .flac file inside an archive. It tried to seek
beyond the end of the archive entry in a format where seeking isn't
supported. stream_libarchive handles these situations by skipping data.
But when the end of the archive is reached, archive_read_data() returns
0. While libarchive didn't bother to fucking document this, they do say
it's supposed to work like read(), so I guess a return value of 0 really
means EOF. So change the "< 0" to "<= 0". Also add some error logging.

The same file actually worked without out of bounds reads when
extracted, so there still might be something very wrong.
2018-10-01 10:41:01 +02:00
wm4 559a400ac3 demux, stream: rip out the classic stream cache
The demuxer cache is the only cache now. Might need another change to
combat seeking failures in mp4 etc. The only bad thing is the loss of
cache-speed, which was sort of nice to have.
2018-08-31 12:55:22 +02:00
Yclept Nemo 5532a3da1e stream_smb/stream_file: fix `write_buffer`
Functions `write` and `smbc_write` are given a diminishing buffer of
incorrect constant size. After partial writes, the code would do another
write of the full original length, failing to subtract the amount
already written.
2018-07-29 12:54:56 +03:00
Yclept Nemo 112b3fa922 stream_smb: locking to bypass libsmbclient issues
Thread-unsafe libsmbclient is likely to crash when used simultaneously
across threads. For example, by:

    mpv "smb://...mkv" --sub-file "smb://...srt"

Work around this by locking all calls to this library under a single
global mutex. This is a temporary solution. When the libsmbclient bug
[1] is fixed, switch to the code from branch [2] which uses a new api to
create per-thread smb contexts. Fixes [3].

[1] https://bugzilla.samba.org/show_bug.cgi?id=11413
[2] https://github.com/orbisvicis/mpv/tree/smbclient_threaded_api
[3] https://github.com/mpv-player/mpv/issues/5936
2018-07-29 12:54:56 +03:00
gall0ws bca59516cc stream_file: enable cache for FUSE filesystems on OpenBSD and FreeBSD 2018-06-05 01:28:35 +03:00
wm4 ca97239cb6 options: add --http-proxy
Often requested, trivial.
2018-05-31 01:24:51 +03:00
wm4 5a4a69cb58 stream_file: properly detect stdin as pipe
There is some code that checks a FD for whether it is a regular file or
not. If it's not a regular file, it e.g. enables use of poll() to avoid
blocking forever.

But this was done only for FDs that were open()ed by us, not from stdin
special handling or fd://. Consequently, " | mpv -" could block the
player. Fix this by moving the code and running for it on all FDs.

Also, set p->regular_file even on mingw.
2018-05-25 10:47:46 +02:00
wm4 b2e24f42d5 options: add --http-proxy
Often requested, trivial.
2018-05-24 19:56:35 +02:00
wm4 29a51900c6 player: some further cleanup of the mp_cancel crap
Alway give each demuxer its own mp_cancel instance. This makes
management of the mp_cancel things much easier. Also, instead of having
add/remove functions for mp_cancel slaves, replace them with a simpler
to use set_parent function. Remove cancel_and_free_demuxer(), which had
mpctx as parameter only to check an assumption. With this commit,
demuxers have their own mp_cancel, so add demux_cancel_and_free() which
makes use of it.
2018-05-24 19:56:35 +02:00
wm4 d7ca95c3ea command: whitelist some blocking accesses for certain demuxers/streams
The properties/commands touched in this commit are all for obscure
special inputs (BD/DVD/DVB/TV), and they all block on the demuxer/stream
layer. For network streams, this blocking is very unwelcome. They will
affect playback and probably introduce pauses and frame drops. The
player can even freeze fully, and the logic that tries to make playback
abortable even if frozen complicates the player.

Since the mentioned accesses are not needed for network streams, but
they will block on network streams even though they're going to fail,
add a flag that coarsely enables/disables these accesses. Essentially it
establishes a whitelist of demuxers/streams which support them.

In theory you could to access BD/DVD images over network (or add such
support, I don't think it's a thing in mpv). In these cases these
controls still can block and could even "freeze" the player completely.

Writing to the "program" and "cache-size" properties still can block
even for network streams. Just don't use them if you don't want freezes.
2018-05-24 19:56:35 +02:00
wm4 a0cce7f775 stream_file: use a separate mp_cancel thing
The intention is to avoid that the parent mp_cancel retains the
internally allocated wakeup pipe. File FDs are a relatively scarce
resource, so try to avoid having too many. This might matter for
subtitle files, for which it is relatively likely that they are loaded
in large quantities.

demux_lavf.c will close the underlying stream for most subtitle files,
and now it will free the wakeup pipe too. Actually, there are currently
only 1 or 2 mp_cancel objects per mpv core, but this could change if
every external subtitle track gets its own mp_cancel in later commits.
2018-05-24 19:56:35 +02:00
wm4 31b78ad7fa misc: move mp_cancel from stream.c to thread_tools.c
It seems a bit inappropriate to have dumped this into stream.c, even if
it's roughly speaking its main user. At least it made its way somewhat
unfortunately to other components not related to the stream or demuxer
layer at all.

I'm too greedy to give this weird helper its own file, so dump it into
thread_tools.c.

Probably a somewhat pointless change.
2018-05-24 19:56:35 +02:00
wm4 34259f11dc stream_file: properly detect stdin as pipe
There is some code that checks a FD for whether it is a regular file or
not. If it's not a regular file, it e.g. enables use of poll() to avoid
blocking forever.

But this was done only for FDs that were open()ed by us, not from stdin
special handling or fd://. Consequently, " | mpv -" could block the
player. Fix this by moving the code and running for it on all FDs.

Also, set p->regular_file even on mingw.
2018-05-24 19:56:34 +02:00
wm4 987eecdb5a stream_libarchive: mark as needing cache
Seeking back can be excessively slow with most formats, so it'll benefit
from this.
2018-04-15 21:07:13 +03:00
wm4 7d10728aaa demux, stream: ignore packets and errors on forced exit
When this happens, network calls are forcibly aborted (more or less),
but demuxers might keep going, as most of them do not check for forced
exits properly. This can possibly lead to broken packets being added.
Also do not attempt to read more packets in this situation.

Also do not print a stream open failed message if opening was aborted
anyway.
2018-03-26 19:47:07 +02:00
Philip Sequeira bd0a636d8b stream_file: enable cache for FUSE filesystems on OS X
Requested in #634. Better late than never?
2018-03-15 03:35:13 -07:00
Philip Sequeira b99da1c0a5 stream_file: add more network file systems (Linux)
Fixes #5643.
2018-03-15 03:35:13 -07:00
Philip Langdale f0223e1b83 tv: Recognise v4l2 'JPEG' fourcc
Naturally, there's more than one fourcc that indicates an mjpeg
stream.

I have a particular ancient webcam here (Logitech QuickCam Messanger)
that only supports the single 'JPEG' format, but there are other
devices out there which support both 'JPEG' and 'MJPG' with no visible
differences, and others where the streams are slightly different.

Regardless of those details, it remains correct to treat 'JPEG'
the same as 'MJPG' from a stream consumption perspective.
2018-03-04 16:28:24 -08:00
wm4 fc76d41194 stream_file: add mode for reading appended files
Do this because retrying reading on higher levels (like the demuxer)
usually causes tons of problems. A hack like this is simpler and could
allow to remove some of the higher level retry behavior.

This works by trying to detect whether the file is appended. If we reach
EOF, check if the file size changed compared to the initial value. If it
did, it means the file was appended at least once, and we set the
p->appending flag. If that flag is set, we simply retry reading more
data every time we encounter EOF. The only way to do this is polling,
and we poll for at most 10 times, after waiting for 200ms every time.
2018-02-21 22:57:39 -08:00
wm4 e7febd6184 stream_lavf: remove deprecated hls protocol from whitelist
The use of the FFmpeg hls protocol (as opposed to demuxer) is
"discouraged", and probably only causes additional potential security
problems at best, so drop it.
2018-01-25 20:18:32 -08:00
Ricardo Constantino 50bf59b652
stream_bluray: always show list of available titles 2018-01-23 11:13:37 +00:00
Ricardo Constantino 123e0239a0
stream_bluray: silence libbluray's debug messages unless we want them
libbluray's way too verbose on default loglevel with non-breaking issues.
2018-01-23 11:13:29 +00:00
wm4 da662ef182 Fix undefined preprocessor behavior
This commit eliminates the following clang warning:

  warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]

Going by the clang commit message, this seems to be explicitly specified
as UB by the standard, and they added this warning because MSVC
apparently results in different behavior. Whatever, we can just avoid
the warning with some small changes.
2018-01-18 00:25:00 -08:00
Ricardo Constantino e3bee23fe4
stream_bluray: support detecting UHD BD directories
Close #5325
2018-01-11 02:34:02 +00:00
wm4 6632d6e287 cache: fix --cache-initial status message
For quite some time, msg.c hasn't output partial log messages anymore,
and instead buffered them in memory. This means the MP_INFO() statement
here just kept appending the message to memory, instead of outputting
it.

Easy enough to fix by abusing the status line (which means the frontend
and this code will "fight" for the status line, but this code seems to
win usually, as the frontend doesn't update it so often).

Users should probably really switch to --cache-pause-initial.

Fixes #5360.
2018-01-07 05:03:15 -08:00
wm4 185e63a3e2 stream: use native libavformat reconnection feature
Remove our own hacky reconnection code, and use libavformat's feature for
that. It's disabled by default, and until recently it did not work too
well. This has been fixed in recent ffmpeg git master[1], so there's no reason
to keep our own code.

[1] FFmpeg/FFmpeg@8a108bdea0

We set "reconnect_delay_max" to 7, which limits the maximum time it
waits. Since libavformat doubles the wait time on each reconnect attempt
(starting with 1), and stops trying to reconnect once the wait time is
over the reconnect_delay_max value, this allows for 4 reconnection
attempts which should add to 11 seconds maximum wait time. The default
is 120, which seems too high for normal playback use.

(The user can still override these parameters with --stream-lavf-o.)
2018-01-04 18:33:18 -08:00
wm4 722f9b63c2 stream_lavf: minor fixes to HTTP reconnection support
Don't drop the stream buffers, because the read call (that must have
been failing) might try to extend an existing read buffer in the first
place. Just move the messy seek logic to stream_lavf.c. (In theory,
stream_lavf should probably make libavformat connect at the correct
offset instead of using a seek to reconnect it again. This patch doesn't
fix it, but at least it's a good argument to have the messing with the
position not in the generic code.)

Also update the comment about avio not supporting reconnecting. It has
that feature now. Maybe we should use it, but only after it gets fixed.
2018-01-02 14:59:27 -08:00
wm4 bf111f9c3c stream_libarchive: fix seeking fallback
In commit 1199c1e3, we added checks to every libarchive API call to make
sure the archive was closed on ARCHIVE_FATAL - otherwise, libarchive
could endow us with free CVEs (such as it apparently happens when you
continue reading a rar archive that uses features not yet supported by
libarchive).

This broke the fallback for seeking in unseekable archive formats. Of
course libarchive won't tell us directly whether a format implementation
has seek support or not - and OF COURSE it returns ARCHIVE_FATAL if it
has no seek support. (The error string, which you can retrieve via API,
is actually more detailed, and also claims it's an "internal error". I
don't think so, libarchive.) Returning ARCHIVE_FATAL means we have to
assume free CVEs are ahead, and we have to close the archive. Which
breaks the fallback in a dumb way (we have no way of telling which of
those cases happened anyway).

Fix this by assuming that all seek errors are potentially due to lack of
seek support. If the seek call fails, reopen the archive, and set a flag
so the seek API is never tried again. (This means we can still skip
ahead for forward seeks, which is more efficient than skipping from the
start of the archive entry.)

Also fix an old typo in an error message.
2017-12-24 21:33:16 +01:00
wm4 2a43060560 cache: propagate underlying stream seek errors in some cases
This just put the cache into an endless loop. This can happen simply if
any seek call of the underlying stream returns an error.
2017-12-24 21:33:16 +01:00
wm4 a23a98f648 cache: lower default size to 2*10MB
Reduce it from 75MB in both directions (forward/backwards) to 10MB each.

The stream cache is kind of becoming useless in favor of the demuxer
cache. Using both doesn't make much sense, because they will contain
duplicated data for no reason.

Still leave it at 10MB, which may help with mp4 a bit. libavformat's mp4
demuxer tends to seek too much, so we try to avoid triggering network
level seeks by having some caching in the stream layer.
2017-12-23 00:32:59 +01:00
rim 04d04033e6 dvb: Add multiple frontends support: MAX_FRONTENDS now 8. 2017-12-16 23:24:55 -08:00
Niklas Haas ba1943ac00 msg: reinterpret a bunch of message levels
I've decided that MP_TRACE means “noisy spam per frame”, whereas
MP_DBG just means “more verbose debugging messages than MSGL_V”.
Basically, MSGL_DBG shouldn't create spam per frame like it currently
does, and MSGL_V should make sense to the end-user and provide mostly
additional informational output.

MP_DBG is basically what I want to make the new default for --log-file,
so the cut-off point for MP_DBG is if we probably want to know if for
debugging purposes but the user most likely doesn't care about on the
terminal.

Also, the debug callbacks for libass and ffmpeg got bumped in their
verbosity levels slightly, because being external components they're a
bit less relevant to mpv debugging, and a bit too over-eager in what
they consider to be relevant information.

I exclusively used the "try it on my machine and remove messages from
MSGL_* until it does what I want it to" approach of refactoring, so
YMMV.
2017-12-15 22:28:47 -08:00
sfan5 3ac8a7f694 stream_libarchive: Fix locale includes on macOS
Fixes #5108
2017-12-03 21:54:12 +01:00
wm4 41cefe3e1f stream_libarchive, osdep: use stubs for POSIX 2008 locale on MinGW 2017-11-12 16:43:34 +01:00
wm4 1e70e82baa stream_libarchive: workaround various types of locale braindeath
Fix that libarchive fails to return filenames for UTF-8/UTF-16 entries.
The reason is that it uses locales and all that garbage, and mpv does
not set a locale.

Both C locales and wchar_t are shitfucked retarded legacy braindeath. If
the C/POSIX standard committee had actually competent members, these
would have been deprecated or removed long ago. (I mean, they managed to
remove gets().) To justify this emotional outbreak potentially insulting
to unknown persons, I will write a lot of text. Those not comfortable
with toxic language should pretend this is a religious text.

C locales are supposed to be a way to support certain languages and
cultures easier. One example are character codepages. Back when UTF-8
was not invented yet, there were only 255 possible characters, which is
not enough for anything but English and some european languages. So they
decided to make the meaning of a character dependent on the current
codepage. The locale (LC_CTYPE specifically) determines what character
encoding is currently used.

Of course nowadays, this is legacy nonsense. Everything uses UTF-8 for
"char", and what doesn't is broken and terrible anyway. But the old ways
stayed with us, and the stupidity of it as well.

C locales were utterly moronic even when they were invented. The locale
(via setlocale()) is global state, and global state is not a reasonable
way to do anything. It will break libraries, or well modularized code.
(The latter would be forced to strictly guard all entrypoints set
set/restore locales, assuming a single threaded world.)

On top of that, setting a locale randomly changes the semantics of a
bunch of standard functions. If a function respects locale, you suddenly
can't rely on it to behave the same on all systems. Some behavior can
come as a surprise, and of course it will be dependent on the region of
the user (it doesn't help that most software is US-centric, and the US
locale is almost like the C locale, i.e. almost what you expect).

Idiotically, locales were not just used to define the current character
encoding, but the concept was used for a whole lot of things, like e. g.
whether numbers should use "," or "." as decimal separaror. The latter
issue is actually much worse, because it breaks basic string conversion
or parsing of numbers for the purpose of interacting with file formats
and such.

Much can be said about how retarded locales are, even beyond what I just
wrote, or will wrote below. They are so hilariously misdesigned and
insufficient, I can't even fathom how this shit was _standardized_. (In
any case, that meant everyone was forced to implement it.) Many C
functions can't even do it correctly. For example, the character set
encoding can be a multibyte encoding (not just UTF-8, but awful garbage
like Shift JIS (sometimes called SHIT JIZZ), yet functions like
toupper() can return only 1 byte. Or just take the fact that the locale
API tries to define standard paper sizes (LC_PAPER) or telephone number
formatting (LC_TELEPHONE). Who the fuck uses this, or would ever use
this?

But the badness doesn't stop here. At some point, they invented threads.
And they put absolutely no thought into how threads should interact with
locales. So they kept locales as global state. Because obviously, you
want to be able to change the semantics of basic string processing
functions _while_ they're running, right? (Any thread can call
setlocale() at any time, and it's supposed to change the locale of all
other threads.)

At this point, how the fuck are you supposed to do anything correctly?
You can't even temporarily switch the locale with setlocale(), because
it would asynchronously fuckup the other threads. All you can do is to
enforce a convention not to set anything but the C local (this is what
mpv does), or to duplicate standard functions using code that doesn't
query locale (this is what e.g. libass does, a close dependency of mpv).

Imagine they had done this for certain other things. Like errno, with
all the brokenness of the locale API. This simply wouldn't have worked,
shit would just have been too broken. So they didn't. But locales give a
delicious sweet spot of brokenness, where things are broken enough to
cause neverending pain, but not broken enough that enough effort would
have spent to fix it completely.

On that note, standard C11 actually can't stringify an error value. It
does define strerror(), but it's not thread safe, even though C11
supports threads. The idiots could just have defined it to be thread
safe. Even if your libc is horrible enough that it can't return string
literals, it could just just some thread local buffer. Because C11 does
define thread local variables. But hey, why care about details, if you
can just create a shitty standard?

(POSIX defines strerror_r(), which "solves" this problem, while still
not making strerror() thread safe.)

Anyway, back to threads. The interaction of locales and threads makes no
sense. Why would you make locales process global? Who even wanted it to
work this way? Who decided that it should keep working this way, despite
being so broken (and certainly causing implementation difficulties in
libc)? Was it just a fucked up psychopath?

Several decades later, the moronic standard committees noticed that this
was (still is) kind of a bad situation. Instead of fixing the situation,
they added more garbage on top of it. (Probably for the sake of
"compatibility"). Now there is a set of new functions, which allow you
to override the locale for the current thread. This means you can
temporarily override and restore the local on all entrypoints of your
code (like you could with setlocale(), before threads were invented).

And of course not all operating systems or libcs implement this. For
example, I'm pretty sure Microsoft doesn't. (Microsoft got to fuck it up
as usual, and only provides _configthreadlocale(). This is shitfucked on
its own, because it's GLOBAL STATE to configure that GLOBAL STATE should
not be GLOBAL STATE, i.e. completely broken garbage, because it requires
agreement over all modules/libraries what behavior should be used. I
mean, sure, makign setlocale() affect only the current thread would have
been the reasonable behavior. Making this behavior configurable isn't,
because you can't rely on what behavior is active.)

POSIX showed some minor decency by at least introducing some variations
of standard functions, which have a locale argument (e.g. toupper_l()).
You just pass the locale which you want to be used, and don't have to do
the set locale/call function/restore locale nonense. But OF COURSE they
fucked this up too. In no less than 2 ways:

- There is no statically available handle for the C locale, so you have
  to initialize and store it somewhere, which makes it harder to make
  utility functions safe, that call locale-affected standard functions
  and expect C semantics. The easy solution, using pthread_once() and a
  global variable with the created locale, will not be easily accepted
  by pedantic assholes, because they'll worry about allocation failure,
  or leaking the locale when using this in library code (and then
  unloading the library). Or you could have complicated library
  init/uninit functions, which bring a big load of their own mess.
  Same for automagic DLL constructors/destructors.
- Not all functions have a variant that takes a locale argument, and
  they missed even some important ones, like snprintf() or strtod() WHAT
  THE FUCK WHAT THE FUCK WHAT THE FUCK WHAT THE FUCK WHAT THE FUCK WHAT
  THE FUCK WHAT THE FUCK WHAT THE FUCK WHAT THE FUCK

I would like to know why it took so long to standardize a half-assed
solution, that, apart from being conceptually half-assed, is even
incomplete and insufficient. The obvious way to fix this would have
been:

- deprecate the entire locale API and their use, and make it a NOP
- make UTF-8 the standard character type
- make the C locale behavior the default
- add new APIs that explicitly take locale objects
- provide an emulation layer, that can be used to transparently build
  legacy code without breaking them

But this wouldn't have been "compatible", and the apparently incompetent
standard committees would have never accepted this. As if anyone
actually used this legacy garbage, except other legacy garbage. Oh yeah,
and let's care a lot about legacy compatibility, and let's not care  at
all about modern code that either has to suffer from this, or subtly
breaks when the wrong locales are active.

Last but not least, the UTF-8 locale name is apparently not even
standardized. At the moment I'm trying to use "C.UTF-8", which is
apparently glibc _and_ Debian specific. Got to use every opportunity to
make correct usage of UTF-8 harder. What luck that this commit is only
for some optional relatively obscure mpv feature.

Why is the C locale not UTF-8? Why did POSIX not standardize an UTF-8
locale? Well, according to something I heard a few years ago, they're
considering disallowing UTF-8 as locale, because UTF-8 would violate
certain ivnariants expected by C or POSIX. (But I'm not sure if I
remember this correctly - probably better not to rage about it.)

Now, on to libarchive.

libarchive intentionally uses the locale API and all the broken crap
around it to "convert" UTF-8 or UTF-16 (as contained in reasonably sane
archive formats) to "char*". This is a good start!

Since glibc does not think that the C locale uses UTF-8, this fails for
mpv. So trying to use archive_entry_pathname() to get the archive entry
name fails if the name contains non-ASCII characters.

Maybe use archive_entry_pathname_utf8()? Surely that should return
UTF-8, since its name seems to indicate that it returns UTF-8. But of
fucking course it doesn't! libarchive's horribly convoluted code (that
is full of locale API usage and other legacy shit, as well as ifdefs and
OS specific code, including Windows and fucking Cygwin) somehow fucks up
and fails if the locale is not set to UTF-8. I made a PR fixing this in
libarchive almost 2 years ago, but it was ignored.

So, would archive_entry_pathname_w() as fallback work? No, why would it?
Of course this _also_ involves shitfucked code that calls shitfucked
standard functions (or OS specific ifdeffed shitfuck). The truth is that
at least glibc changes the meaning of wchar_t depending on the locale.
Unlike most people think, wchar_t is not standardized to be an UTF
variant (or even unicode) - it's an encoding that uses basic units that
can be larger than 8 bit. It's an implementation defined thing. Windows
defines it to 2 bytes and UTF-16, and glibc defines it to 4 bytes and
UTF-32, but only if an UTF-8 locale is set (apparently).

Yes. Every libarchive function dealing with strings has 3 variants:
plain, _utf8, and _w. And none of these work if the locale is not set.
I cannot fathom why they even have a wchar_t variant, because it's
redundant and fucking useless for any modern code.

Writing a UTF-16 to UTF-8 conversion routine is maybe 3 pages of code,
or a few lines if you use iconv. But libarchive uses all this glorious
bullshit, and ends up with 3 not working API functions, and with over
4000 lines of its own string abstraction code with gratuitous amounts of
ifdefs and OS dependent code that breaks in a fairly common use case.

So what we do is:

- Use the idiotic POSIX 2008 API (uselocale() etc.) (Too bad for users
  who try to build this on a system that doesn't have these - hopefully
  none are left in 2017. But if there are, torturing them with obscure
  build errors is probably justified. Might be bad for Windows though,
  which is a very popular platform except on phones.)
- Use the "C.UTF-8" locale, which is probably not 100% standards
  compliant, but works on my system, so it's fine.
- Guard every libarchive call with uselocale() + restoring the locale.
- Be lazy and skip some libarchive calls. Look forward to the unlikely
  and astonishingly stupid bugs this could produce.

We could also just set a C UTF-8 local in main (since that would have no
known negative effects on the rest of the code), but this won't work for
libmpv.

We assume that uselocale() never fails. In an unexplainable stroke of
luck, POSIX made the semantics of uselocale() nice enough that user code
can fail failures without introducing crash or security bugs, even if
there should be an implementation fucked up enough where it's actually
possible that uselocale() fails even with valid input.

With all this shitty ugliness added, it finally works, without fucking
up other parts of the player. This is still less bad than that time when
libquivi fucked up OpenGL rendering, because calling a libquvi function
would load some proxy abstraction library, which in turn loaded a KDE
plugin (even if KDE was not used), which in turn called setlocale()
because Qt does this, and consequently made the mpv GLSL shader
generation code emit "," instead of "." for numbers, and of course only
for users who had that KDE plugin installed, and lived in a part of the
world where "." is not used as decimal separator.

All in all, I believe this proves that software developers as a whole
and as a culture produce worse results than drug addicted butt fucked
monkeys randomly hacking on typewriters while inhaling the fumes of a
radioactive dumpster fire fueled by chinese platsic toys for children
and Elton John/Justin Bieber crossover CDs for all eternity.
2017-11-12 13:36:56 +01:00
wm4 1199c1e38a stream_libarchive: stop reading on ARCHIVE_FATAL
According to

https://github.com/libarchive/libarchive/pull/773#issuecomment-334892291

we're not allowed to "continue reading" (post above) or performing "more
operations" (comments in archive.h header), whatever that means. Assume
closing and freeing the archive is still ok.

Since the codec already includes logic for closing and reopening the
archive for seeking in unseekable archives, this probably isn't too bad.

Untested due to lack of crashing sample (I lost my original test case,
and as recently user-provided one didn't crash).
2017-11-02 18:47:05 +01:00
wm4 7163c95cfd cache: throttle wakeups
In the extreme case, reading 1 byte would wake up the cache to make the
cache thread read 1 byte. This would be extremely inefficient. This will
not normally happen in our cache implementation, but it's still present
to some lesser degree. Normally you'd set a predefined "cache too low"
boundary, after which you would restart reading. For some reason
something like this is already present using a hardcoded value
(FILL_LIMIT - I don't even know the deeper reason why this exists). So
use that to reduce wakeups.

This doesn't fix redundant wakeups on EOFs, which is especially visible
should something keep retrying reading on EOF (like in an endless loop).
2017-10-20 22:13:22 +02:00
wm4 14541ae258 Add checks for HAVE_GPL to various GPL-only source files
This should actually cover all of them, if you take into account that
some unchanged GPL source files include header files with such checks.
Also this was done already for the libaf derived code.

This is only for "safety" and to avoid misunderstandings.
2017-10-10 15:51:16 +02:00
Oliver Freyermuth 6b05c774a4 dvb: SYS_DVBC_ANNEX_B is now supported if ATSC is activated.
Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth de0c1dd4f5 dvb: Skip channel if ATSC device does not support cable / terr.
This matches what is done for the other multi-delivery-system
cards.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth add0cbea2a dvb: Implement parsing of modulation for VDR-style channels config.
This is required for ATSC cable / terrestrial support.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth e46338c66a dvb: Fixes for ATSC tuning.
ATSC is a mix of terrestrial and cable,
and depending on modulation is actually using
DVBC_ANNEX_B. Thus, we need to override the delivery
system depending on the modulation, channel by channel.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth 20381a5f5a stream_dvb: Multiply frequency and sample rate by 1000 for VDR.
These values are kept with a different unit in VDR style config
for all delivery systems, not only for DVB-S / DVB-S2.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth 668598e133 dvb_tune: Pull out DVBv5 raw tuning part, add verbosity.
Dump the complete raw tuning commands to allow for debugging
on low level.
Also, remove code duplication and some variable shadowing.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth b9af4409bc dvb: Explicitly clear via DVBv5 before reverting to DVBv3.
Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
Oliver Freyermuth 22442b421c dvb: Use more elaborate tuning for DVBv5 tuning.
Also, in case tuning fails with timeout even though the ioctl
was accepted by the device, fall back to DVBv3 tuning.
This may go wrong for multi-delivery-system cards,
so issue an error message in that case.

Signed-off-by: Oliver Freyermuth <o.freyermuth@googlemail.com>
2017-10-09 20:06:29 +02:00
wm4 158b69f04c build: switch preliminary LGPL mode from v3 to v2.1
iive agreed to relicense things that are still in mpv to LGPLv2.1. So
change the licenses of the affected files, and rename the configure
switch for LGPL mode to --enable-preliminary-lgpl2.

(The "preliminary" part will probably be removed from the configure
switch soon as well.)

Also player/main.c hasn't had GPL parts since a few commits ago.
2017-10-05 15:57:30 +02:00
wm4 449d9725c9 stream_lavf: use avio_read_partial()
Possibly improves latency and such things.
2017-09-01 17:59:03 +02:00
wm4 b9430309ec stream: add an assert() to an obscure seek case
This affects small seeks backwards while within the buffer. Demuxers
usually avoid this, so it's probably not triggered very often. (Although
demux_mkv.c potentially triggers it often, and it uses stream_peek() to
explicitly guarantee that it can use this code to seek back.) The
condition is complex enough to warrant an assertion.
2017-08-17 17:38:07 +02:00
Niklas Haas 345bb193fe
vo_opengl: support loading custom user textures
Parsing the texture data as raw strings makes the textures the most
portable and self-contained. In order to facilitate different types of
shaders, the parse_user_shader interaction has been changed to instead
have it loop through blocks and call the passed functions for each valid
block parsed. This is more modular and also cleaner, with better code
separation.

Closes #4586.
2017-07-27 23:51:05 +02:00
wm4 cd25d98bfa Avoid calling close(-1)
While this is perfectly OK on Unix, it causes annoying valgrind
warnings, and might be otherwise confusing to others.

On Windows, the runtime can actually abort the process if this is
called.

push.c part taken from a patch by Pedro Pombeiro.
2017-06-29 10:31:13 +02:00
wm4 4c17ed457d stream_bluray: change license to LGPL
While I'm not particularly attached to this, the history is pretty
simple, and all relevant authors have agreed.

2f004875: removed in 2c693a47, patch author was not asked.
1ef239a4: removed, author was not asked.
2017-06-26 19:25:22 +02:00
wm4 fcbcd1d3c0 demux_mf, stream_mf: change license to LGPL
cehoyos, who did not agree to the relicensing, added bcb5c78ce3. If
there was copyright, we consider it gone, because the table changed. It
does not map file extension to a FourCC anymore, and codecs.conf is
gone. The new mapping is a libavcodec codec name (happens to be the same
as the file extension).

The same applies to commits 60ecafec, b749836b, 5b3e3be1. None of these
authors were contacted. These were before the code was replaced with a
table (in d0326807). The parts outside of demux_mf.c were removed a long
time ago. Like in the previous comment, we don't think any copyright
applies at least to the new code (at least after the FourCC removal).

iive authored 0aa37a0d, which is probably still left in some form, and
makes demux_mf.c "LGPL 3 or later".

stream_avdevice.c (unrelated) has been marked as LGPL before.
2017-06-24 13:28:01 +02:00
wm4 ee21bd1baa stream: move cache option declarations to cache.c
If they are copyrightable, iive's changes (commits listed in cache.c)
would make them LGPL 3+. To avoid that options.c becoming LGPL 3, move
the option declarations to cache.c. struct mp_cache_opts is still in
options.h, but we consider that irrelevant, and options.h will become
LGPL 2.1+ later.
2017-06-23 13:03:50 +02:00
wm4 5c038e6999 build: simplify OSS checks and remove changes by "bugmen0t"
The user bugmen0t was apparently a shared github account with publicly
available login. Thus, we can't get LGPL relicensing permission from the
people who used this account. To relicense successfully, we have to
remove all their changes.

This commit should remove 20d1fc13, f26fb009, defbe48d. It also should
remove whatever test fragments were copied from the ancient configure,
as well as some configure logic (potentially that device path stuff).

I think this change still preserves the most important use-cases of OSS:
BSDs, and the Linux OSS emulation (the latter for testing only).
According to an OSS user, the 4front checks were probably broken anyway.
The SunAudio stuff was probably for (Open)Solaris, which is dead.

ao_oss.c itself will remain GPL, and still contains bugmen0t changes.
2017-06-22 13:17:14 +02:00
wm4 e0c50289d6 stream: change license to LGPL
All relevant authors have agreed.

There are two exceptions, patches by authors who could not be reached.
This commit tries to remove their copyright.

a0f08fbe: messes with the seeking code corner cases. The EOF flag logic
was changed at some point, and always had a flaky history (see e.g.
347cf972 50274ca3 70411f27 5999efb9 0d5e6084 ff08d0c3 2e2f77e3 de5566f0
9554a844, all which happened after that patch, MPlayer ones without that
patch). I claim that all of the copyright the patch might have added is
gone. Except the message in stream_seek(), which this commit removes.
The other code removed/changed in stream_seek() is probably not from
that patch, but it doesn't hurt to be sure, and also makes it more
readable. (It might change the behavior so that sometimes the eof flag
is set after a seek, but it doesn't matter here.)

2aa6acd9: it looks like the seek_forward() modified by this patch was
later moved to stream.c and renamed to stream_skip_read() in a790f2133.
(Looking closer at it, it was actually modified again a bunch of times,
fixing the logic.) I rewrote it in this commit. The code ended up rather
similar, which probably could lead to doubts whether this was done
properly, but I guess the reader of this will just have to believe me. I
knew what stream_skip_read() was supposed to do (which was reinforced
when I tried to replace it on the caller side), without reading the
pre-existing code in detail. I had to "relearn" the logic how buf_pos
and bug_len work - it was actually easy to see from stream_read_char()
how to skip the data, essentially by generalizing its logic from 1 byte
to N bytes. From the old code I only "used" the fact that it's obviously
a while(len>0) look, that has to call stream_fill_buffer repeatedly to
make progress. At first I actually didn't use stream_fill_buffer_by(),
but the variant without _by, but readded it when I checked why the old
code used it (see cd7ec016e7). This has to be good enough. In the end,
it's hard to argue that this could be implemented in a way not using
such a loop.

Other than this, I could add the usual remarks about how this code was
not modularized in the past, and how stream.c contained DVD code, and
how this was later modularized, moving the copyright to other files, and
so on. Also, if someone wrote a stream module, and was not asked about
LGPL relicensing, we don't consider the entry in stream_list[]
copyrightable.
2017-06-19 16:10:10 +02:00
wm4 b6d0b57e85 Drop/move img_fourcc.h
This file is an leftover from when img_format.h was changed from using
the ancient FourCCs (based on Microsoft multimedia conventions) for
pixel formats to a simple enum. The remaining cases still inherently
used FourCCs for whatever reasons.

Instead of worrying about residual copyrights in this file, just move it
into code we don't want to relicense (the ancient Linux TV code). We
have to fix some other code depending on it. For the most part, we just
replace the MP_FOURCC macro with libavutil's MKTAG (although the macro
definition is exactly the same). In demux_raw, we drop some pre-defined
FourCCs, but it's not like it matters. (Instead of
--demuxer-rawvideo-format use --demuxer-rawvideo-mp-format.)
2017-06-18 15:13:45 +02:00
sfan5 2a0028aa13 stream_file: option to close fd after use -> fdclose://
fdclose://123 will instruct mpv to close the file descriptor
when it is no longer needed (usually when playing finishes).
2017-06-16 22:48:44 +02:00
wm4 546ae3db4f stream_lavf: change license to LGPL
All authors agreed.

The author of 1ee8ce75 did not respond, but it was a mpv pull request,
and at this time DOCS/contribute.md and the "Copyright" file stated that
all contributions must include LGPL relicensing permission. But you
could claim that this was too "hidden". Sort of a corner case, I guess,
but not my problem.
2017-06-16 16:32:02 +02:00
wm4 3bbb6078a5 stream: rewrite url escaping/unescaping functions
The original functions come from 24c6f11c8b, which says that these
functions were copied from another project. This other project is GPL
and was written by an unknown author, so there is no hope to relicense
them to LGPL.

Replace the existing functions with code written by Avi Halachmi. He did
not see the old code, but wrote it based on the function signature and
an extended description of what they should do (http://sprunge.us/edia).
Some additional help was provided by me (in particular the function of
the "ok" parameter and how to implement it - not in the original
ASFRecorder code).

Some of the code is hilariously similar, but these are coincidences. The
name of the variable "c" probably "leaked" from me, but "o" is a true
coincidence.

The code was integrated by me - my only change is changing the function
names to the old ones, moving the order of the top-level declarations,
and changing "default_ok" to "url_default_ok", and changing the strings
from char* to char[].

The author of the new code is Avi Halachmi.
2017-06-13 19:57:00 +02:00
wm4 5f2c4d4799 cache: move duplicated condition to a function
While subtly duplicating such checks happens a lot in this file, this
particular case can be easily factored into a function.
2017-05-15 16:02:48 +02:00
Uoti Urpala 3f17b101ee cache: fix unnecessary seek blocking from f4d62dc4a0
Commit 374600cec0 ("cache: propagate seek failures") changed
stream-level seeks to be done in the calling thread so possible errors
could be reported. This commit included some rationale why doing the
stream-level seeks synchronously was not a big issue. However, the
following fixup commit f4d62dc4a0 changed the seek code to always
synchronize with the cache thread and do seek handling there. This is
a problem because it affects even seeks within already cached data
(which require no stream-level seek). With a network server that sends
data in bursts, the cache thread can be blocked in a read call for a
long time; the added synchronization means that seeking within already
downloaded data can have unnecessary long delays.

Change cache_seek() to check whether the seek is expected to result in
a stream-level seek, and skip synchronization if it is not. This means
that seeks within the cached portion of the file now again happen
immediately without possibly waiting for network.

Signed-off-by: wm4 <wm4@nowhere>
2017-05-15 15:47:20 +02:00
wm4 f2961425e7 cache: clarify that copyright will be changed to LGPL v2.1 if possible
Clearly the licensing situation isn't confusing enough.

I don't know why that guy insists on LGPLv3.
2017-05-11 17:11:01 +02:00
wm4 f38bd0f25a stream_smb: disable by default, mark as GPLv3
It seems libsmbclient has been GPLv3 for years. Also, it's certainly not
LGPL (unlike some of its support libs like talloc). Thus, mpv built with
Samba support is GPLv3.

Disable it by default, so we don't have to go through the trouble to
indicate the correct license in our output, and we don't trick people
into distributing stuff under the wrong license.
2017-05-11 08:19:02 +02:00
wm4 aac871deb4 stream_file: change license to LGPL
This has a messy history all back to the initial commit with multiple
refactors, but it seems almost all authors agreed.

Exceptions:

2aa6acd9747: patch by someone who could not be reached. Whether or not
this code is still in mpv is unknown, but the affected code was moved to
stream.c at one point anyway.

3859bbd9fef: not sure if this is a patch by the mentioned person (I
assume not) or the committer (who agreed to LGPL), but it seems the
change is too trivial to affect copyright. It seems even the FD check
can be dropped, which I'm doing in this commit.

58846451f0e: author doesn't reply. But reverting this and letting
someone who has never seen this commit before redo it would lead to
exactly the same code. So I'm claiming that the change is not
copyrightable.
2017-05-11 08:14:48 +02:00
wm4 a28cf44ebc cookies: change license to LGPL
All authors have agreed.

One minor exception is 21a9221e7b (patch by someone who wasn't asked),
but we just remove the added line again. It seems unneeded.
2017-05-11 07:29:01 +02:00
wm4 7eccb62f85 cache: change license to LGPL v3
All authors have agreed to the relicensing.

iive has insisted on "LGPL v3 or later", which makes the file LGPL v3.
His commits are the following: 84ec577508 9b0d8c680f. All other
contributions are LGPL v2.1. I hope we can remove these changes
completely one day to make this file LGPL v2.1.

iive also authored commit 3934b160a8, but this code is completely gone
today. (fork() and shared memory use was removed completely in favor of
threads.)
2017-05-08 12:56:29 +02:00
wm4 d89b4458cc stream_null: change license to LGPL 2017-05-08 12:45:50 +02:00
Ricardo Constantino 34e6a26f4d
wscript: decouple dvdnav check from dvdread
Reallows enabling dvdnav without enabling dvdread which was broken
in 77cbb3543 when they were both disabled by default.
Since dvdnav requires dvdread, we can enable dvdread:// even if
--enable-dvdread isn't passed.

Fixes #4290
2017-03-31 16:46:58 +01:00
Ricardo Constantino 4d07fce041
stream/stream_dvdnav: show list of titles on verbose
Same as stream_bluray, but only if no title is selected already.
2017-03-29 02:19:09 +01:00
Ricardo Constantino 7fe7583a7f
stream/stream_dvdnav: don't ignore setting title
Probably a typo in 5e30e7a04.
Fixes #4283
2017-03-29 02:18:53 +01:00
qrwyeui 50abbf76e6 stream_dvd: fix subs/audio detection on DVDs containing multi-PGC titles
On some DVDs, title number is not necessarily the same as the (first)
PGC number.  (Most often they are equal, since there's usually exactly
one PGC per title, which is likely why this issue wasn't noticed
before.)  When searching for audio/subtitle metadata, we want to look
at the actual PGC we're about to play.  See discussion in issue #4235.

Signed-off-by: wm4 <wm4@nowhere>
2017-03-15 02:54:18 +01:00
ivan-83 e40c41de19 dvb: add support for DVB-T2
Probably does much more:

+ add support DVB-T2
* DVB params set to AUTO by default
* MAX_CARDS: 4 -> 16
* DMX_SET_BUFFER_SIZE: 64kb -> 256kb
+ add DTV_CLEAR call before tune
+ add logic from https://github.com/olifre/mpv/commits/dvb-mixed-api-scan
* rename type to delsys
* single playlist per adapter
* card -> adapter
* fix channels order in playlist
* update internal api
* auto fallback to old DVB API on tune
* fix DELSYS_SUPP_MASK value
* remove tone - unused
* add channel mem zeroize in config parser
+ add code from libdvbv5 for detect delivery systems
* SYS_DVBC_ANNEX_AC replaced to SYS_DVBC_ANNEX_A + SYS_DVBC_ANNEX_C

Signed-off-by: wm4 <wm4@nowhere>
2017-03-06 16:12:27 +01:00
wm4 05f63edc7b Revert "dvb: add support for DVB-T2"
This reverts commit df91e492fd.

Multiple issues such as weird code with undefined behavior (like
(like conf_file*). The PR wasn't properly reviewed anyway (my error),
so this commit should be reviewed and then merged again.
2017-02-14 13:31:06 +01:00
ivan-83 df91e492fd dvb: add support for DVB-T2
Probably does much more:

+ add support DVB-T2
* DVB params set to AUTO by default
* MAX_CARDS: 4 -> 16
* DMX_SET_BUFFER_SIZE: 64kb -> 256kb
+ add DTV_CLEAR call before tune
+ add logic from https://github.com/olifre/mpv/commits/dvb-mixed-api-scan
* rename type to delsys
* single playlist per adapter
* card -> adapter
* fix channels order in playlist
* update internal api
* auto fallback to old DVB API on tune
* fix DELSYS_SUPP_MASK value
* remove tone - unused
* add channel mem zeroize in config parser
+ add code from libdvbv5 for detect delivery systems
* SYS_DVBC_ANNEX_AC replaced to SYS_DVBC_ANNEX_A + SYS_DVBC_ANNEX_C

Signed-off-by: wm4 <wm4@nowhere>
2017-02-13 11:17:51 +01:00
Thomas V 1672204dc5 dvb: move priv allocation to dvb_open
This fixes a crash when changing channels; previously stream->priv would not
be initialized when dvb_get_state reused the existing state.

Signed-off-by: Thomas VanSelus <tvanselus@diospyros.us>
2017-02-10 08:19:28 +01:00
Frédéric Brière aaad2d847e tv: Zero-out newly-allocated handle in tv_new_handle()
Some fields (notably tv_channel_list) were left uninitialized,
potentially causing problems later on.

Fixes #4096
2017-02-05 14:20:27 +01:00
wm4 fb9a32977d stream: get rid of streamtype enum
Because it's kind of dumb. (But not sure if it was worth the trouble.)

For stream_file.c, we add new explicit fields. The rest are rather
special uses and can be killed by comparing the stream impl. name.

The changes to DVD/BD/CD/TV are entirely untested.
2017-02-02 18:26:58 +01:00
wm4 e13a62fc34 stream: better method signal caching, rename weird uncached_stream field
"uncached_stream" is a pretty bad name. It could be mistaken for a
boolean, and then its meaning would be inverted. Rename it.

Also add a "caching" field, which signals that the stream is a cache or
reads from a cache. This is easier to understand and more flexible.
2017-02-02 18:03:29 +01:00
wm4 644e23a0f5 tvi_dummy: don't return bad dummy PTS
This makes the player spam timestamp warnings. Return NOPTS instead.
2017-02-02 08:51:40 +01:00
wm4 70411f2709 stream: minor cleanup to previous commit
This is almost cosmetic, but removes the duplicated EOF-setting.

Somewhat oddly, this will enter the reconnect path and exit it
immediately again - should be fine.
2017-01-27 09:03:14 +01:00
wm4 4e53f9e5b2 stream: set EOF if stream is canceled
Commit 7be495b3 added the cancellation test, but forgot to set the eof
flag. This could lead to demux_mkv.c not terminating if the stream was
cancelled in some code paths.

This function is what is supposed to set the EOF flag in the first
place, so just add the missing code.
2017-01-26 18:27:30 +01:00
Ricardo Constantino d303ebd9b6
stream_lavf: add support for data URIs
Only FFmpeg supports them and they need to be in the format data://
like other protocols or prefixed with ffmpeg:// or lavf://.

Closes #4058
2017-01-25 15:40:56 +00:00
wm4 7be495b369 stream: check for playback aborts on reading too
Benefits demux_mkv.c, or demux_lavf.c during probing. In particular
demux_lavf.c can sometimes get "stuck" when reading from a slow/blocking
source, and if probing needs more than a few iterations.

Since this is a read of an atomic variable with relaxed semantics, this
should have no impact on reading speed at all, not even theoretically.
2017-01-24 08:46:17 +01:00
wm4 73858bb0cc player: remove --stream-capture option/property
This was excessively useless, and I want my time back that was needed to
explain users why they don't want to use it.

It captured the byte stream only, and even for types of streams it was
designed for (like transport streams), it was rather questionable.

As part of the removal, un-inline demux_run_on_thread() (which has only
1 call-site now), and sort of reimplement --stream-dump to write the
data directly instead of using the removed capture code.

(--stream-dump is also very useless, and I struggled coming up with an
explanation for it in the manpage.)
2017-01-21 17:19:01 +01:00
Ricardo Constantino fb6481ecb5
stream_bluray: use proper 0-based idx
Even though the title list code was copied from FFmpeg/libbluray,
I didn't check that mpv used 0-based title indexing.

$ mpv bd://1 --bluray-device=. --msg-level=bd=v
[bd] Opening bd://
[bd] List of available titles:
[bd] idx:   1 duration: 00:00:36 (playlist: 00000.mpls)
[bd] idx:   2 duration: 01:31:30 (playlist: 00001.mpls)
[bd] idx:   3 duration: 00:00:50 (playlist: 00003.mpls)

bd://1 actually opens idx 2 from the list, not 1.
bd://mpls/1 opens playlist 00001.mpls as expected.

With this commit:
$ mpv bd://1 --bluray-device=. --msg-level=bd=v
[bd] Opening bd://
[bd] List of available titles:
[bd] idx:   0 duration: 00:00:36 (playlist: 00000.mpls)
[bd] idx:   1 duration: 01:31:30 (playlist: 00001.mpls)
[bd] idx:   2 duration: 00:00:50 (playlist: 00003.mpls)

should play the expected idx 1.
2017-01-16 16:03:15 +00:00
wm4 afcf3e154a cache: remove redundant free()
This code used to check/free multiple things, so the argument to free()
was not always NULL. After the code was simplified, the free() became
redundant.
2017-01-09 13:18:11 +01:00
wm4 ceb2e1026d demux, stream: add option to prevent opening referenced files
Quite irresponsibly hacked together. Sue me.
2016-12-04 23:15:31 +01:00
wm4 78f76bdddd tv: fix option type
It appears this makes it actually compatible with the property. It was
an ancient MPlayer artifact all along.
2016-11-22 15:54:45 +01:00
schnusch 68839e4e77 stream_bluray: check title index/playlist range
Blu-ray title index/playlist must be in the range 0-99999, otherwise
an error will be returned
2016-10-17 19:23:11 +02:00
schnusch 51dbb5607e stream_bluray: select title by playlist
Blu-ray titles can now be selected by playlist number like this:
    bd://mpls/[playlist]
2016-10-17 19:23:07 +02:00
wm4 a049a3240e stream_file: don't use poll() on directories
POSIX leaves poll() behavior on directories unspecified. While on
Linux, it seems to behave the same way as regular files (always
return immediately), this is not guaranteed. At least with OSX
10.12, it seems to wait, which essentially means that opening
directories will "hang".

Fixes #3530 and #3649.
2016-10-14 17:19:47 -06:00
wm4 e3a57272a7 stream_libarchive: add some more points at which reading can be stopped 2016-10-01 18:19:57 +02:00
wm4 45c97aea78 stream_lavf: check seekable flag correctly
AVIOContext.seekable is actually a bitfield. Currently, it has only
AVIO_SEEKABLE_NORMAL defined, but it might be extended with a hint for
non-byte seekability. Thus we should check it correctly.
2016-09-27 15:51:34 +02:00
wm4 0f110ad0e2 stream_lavf: fix determining seekability
demux_lavf.c forces seek to being determined as supported if
STREAM_CTRL_HAS_AVSEEK is returned as success. But it always succeeds
with current FFmpeg versions. (Seems like Libav commit cae448cf broke
this in early 2016.)

Now we can't determine via private API whether the underlying protocol
supports read_seek anymore. The affected protocols (mostly rtmp) also
set seekable=0, meaning they signal they're not seekable, even though
read_seek would work. (My guess is that this can't be fixed because even
though seekable is in theory a combination of elaborate flags [of which
only 1 is defined, AVIO_SEEKABLE_NORMAL], a seekable!=0 always means
it's byte-seekable in some way.)

So the FFmpeg API is being garbage _again_, and all what we can do is
determining this via protocol name and a whitelist.

Should fix the behavior reported in #1701.
2016-09-26 16:49:35 +02:00
RiCON 554c3a1bda stream/stream_lavf: user-agent option is deprecated
There was both user-agent and user_agent options, the former is deprecated in FFmpeg/FFmpeg@27714b462 master.
Libav uses both forms.

This avoids constant `[ffmpeg] http: the user-agent option is deprecated, please use user_agent option` warnings using ytdl_hook.
2016-09-18 11:31:11 +02:00
wm4 5ca654301b stream_cb: don't add "*://" to protocol list
--list-protocol was printing a *:// entry, which looked strange at best.
The "*" protocol was used to always match everything, so stream_cb.c
could hook in custom protocols with a prefix chosen by the API user.

Change it instead so that an empty protocol list means "match all",
which also gets rid of the special-cased "*" entry.
2016-09-10 15:35:22 +02:00
wm4 04320d26eb stream, demux, config: remove some dead/unneeded option-related code
This has all been made unnecessary recently. The change not to copy the
global option struct in particular can be made because now nothing
accesses the global options anymore in the demux and stream layers.

Some code that was accidentally added/changed in commit 5e30e7a0 is also
removed, because it was simply committed accidentally, and was never
used.
2016-09-09 17:54:57 +02:00
wm4 c157641019 stream_cdda: remove weird option parsing stuff
Mostly untested.

This is not compatible. It removes the URL fields for track range and
cdrom speed (what did this even do). The device is not not to be
prefixed with an additional "/" if it's put into the URL. I can't be
bothered to keep these things compatible, just rip your damn CDs
instead.
2016-09-09 17:54:35 +02:00
wm4 5324fb731f tv: remove weird option parsing stuff
Mostly untested.
2016-09-09 17:54:35 +02:00
wm4 9213db0d49 stream_dvb: remove weird option parsing stuff
Mostly untested.
2016-09-09 17:54:35 +02:00
wm4 5e30e7a041 stream_dvd, stream_dvdnav: remove weird option parsing stuff
Same deal as with stream_bluray.

Untested because I don't give a fuck about your shitty DVDs.
2016-09-08 21:46:48 +02:00
wm4 ca55a32922 stream_bluray: fix a minor memory leak 2016-09-08 20:59:24 +02:00
wm4 c8cc1f401b stream_bluray: remove weird option parsing stuff
Instead, parse manually. This is to get rid of the option API usages,
which seem unnecessary and shoehorned. (Just look at the URL pseudo
parsing and the dumb url_options map. They were pretty much artifacts
from refactoring old mplayer code.)
2016-09-08 20:59:13 +02:00
wm4 591e21a2eb osdep: rename atomics.h to atomic.h
The standard header is stdatomic.h, so the extra "s" freaks me out every
time I look at it.
2016-09-07 11:26:25 +02:00
wm4 d4d8b3a4fc demux: do not access global options
Don't access MPOpts directly, and always use the new m_config.h
functions for accessing them in a thread-safe way.

The goal is eventually removing the mpv_global.opts field, and the
demuxer/stream-layer specific hack that copies MPOpts to deal with
thread-safety issues.

This moves around a lot of options. For one, we often change the
physical storage location of options to make them more localized,
but these changes are not user-visible (or should not be). For
shared options on the other hand it's better to do messy direct
access, which is worrying as in that somehow renaming an option
or changing its type would break code reading them manually,
without causing a compilation error.
2016-09-06 20:09:56 +02:00
wm4 ec3c428e5f stream_cb: remove broken cast
seek_fn is supposed to return the new file offset, or a negative error
code. Our code doesn't use the offset, and only wants to know if any
errors happened. The int cast is completely broken and might treat a
successful seek as failed depending on whether the sign bit will be set.
2016-08-31 22:25:06 +02:00
wm4 b636b19058 cache: don't use a backbuffer if the cache is as large as the file
It's just wasted memory.

One corner case is when a file grows during playback, but this is rare
and usually happens on-disk only. The cache size was generally limited
before this change already, so no reason to care.

As an unrelated change, move the cache size info to the resize_cache()
function. There's really no reason not to do this, and it's slightly
more informative if the user changes the cache size at runtime.
2016-08-26 13:33:38 +02:00
wm4 cb9b60ef19 stream_memory: disable stream cache
Obviously makes no sense and just wastes resources.
2016-08-26 13:33:38 +02:00
Ricardo Constantino 5d74ba98ce stream/stream_bluray: display list of available titles on verbose
Based on similar code on FFmpeg and libbluray's list_titles example.
2016-08-11 10:02:46 +02:00
wm4 469666b75b stream: fix double-free if cache init fails
If the normal stream cache init fails, and a file cache was initialized
before, we free the file cache as well. But since the file cache is
chained to the real stream, the real stream will also be freed. This has
to be prevented by clearing the pointer to the original stream in the
uncached_stream field.

This could in particular be triggered by using --cache-initial=1000 and
aborting playback during loading. (Without that option, stream cache
init failure is far less likely.)
2016-08-08 11:32:55 +02:00
Aman Gupta 7ca4a453e0 client API: add stream_cb API for user-defined stream implementations
Based on #2630. Some heavy changes by committer.

Signed-off-by: wm4 <wm4@nowhere>
2016-08-07 19:33:20 +02:00
Ben Boeckel 0c4a73fa21 tvi_v4l2: fix style in the uninit function 2016-08-05 10:08:57 +02:00
Ben Boeckel fa7beaad1f tvi_v4l2: explicitly brace the code
It's fine either way, but this code is weirdly formatted. Make it more
explicit.
2016-08-05 10:08:52 +02:00
wm4 510c6a1be4 libarchive: sanitize non-UTF8 archive entries
Some client API users simply don't like such filenames. For their sake,
don't return them, but return a dummy filename instead. (Returning a
latin1-ized version would work too, but is slightly more work.)

Also remove the "\n" from the replacement dummy filename. This was
accidental.
2016-07-18 12:52:59 +02:00
wm4 fb8deb69a6 libarchive: unify entry iteration between stream/demux layers
No really good reason to duplicate this.
2016-07-18 12:44:56 +02:00
wm4 2d44dfaba9 cache: minor simplification
Every cache_wakeup_and_wait() caller has to deal with asynchronous
stream abort, so why not make it somehow part of the function.
2016-07-11 22:20:23 +02:00
wm4 f4d62dc4a0 cache: fix previous commit
The cache reader thread actually unlocks the mutex protecting the
underlying stream while reading from it. That's why other code goes out
of its way to run certain stream operations on the cache thread. Do the
same.

We could have this simpler by creating a mechanism that would "park" the
cache thread and make it wait for the lock (while we have it) in order
to gain exclusive access. This could be done in the future.
2016-07-11 22:16:06 +02:00
wm4 374600cec0 cache: propagate seek failures
Eagerly execute seeks to the underlying stream in the cache seek
entrypoint itself. While asynchronous execution is a goal of the cache,
it doesn't matter too much for seeks. They always were executed within
the lock, so the reader was blocked anyway. It's not necessary to ensure
async. execution here either, because seeks are relatively rare, and the
demuxer can just stay blocked for a while.

Fixes: mpv http://samples.mplayerhq.hu/V-codecs/DIV5/ayaneshk-test.avi
2016-07-11 20:52:30 +02:00
stepshal c5094206ce Fix misspellings 2016-06-26 13:47:21 +02:00
Niklas Haas 5b5db336e9 build: silence -Wunused-result
For clang, it's enough to just put (void) around usages we are
intentionally ignoring the result of.

Since GCC does not seem to want to respect this decision, we are forced
to disable the warning globally.
2016-06-07 14:12:33 +02:00
wm4 3deedef195 stream: separate posix/win32 cancellation code
This code evolved into an ifdef mess as support for cancellation on
Windows was added. Make the Windows-specific code completely separate.
It looks cleaner, and it also means that some of the posix code is not
uselessly enabled on Windows. The latter made msvcrt.dll output warnings
because it does not like -1 passed as FD to read/write. (The same would
be harmless on POSIX.)
2016-05-20 15:51:50 +02:00
wm4 5bd6b76f5c cache: simplify speed calculations
Remove the attempted cleverness; keep it dumb.

This strictly calculates the average speed over an at least 1 second
window (longer if I/O blocks it).

Since this doesn't reset the speed anymore when reading stops by going
idle, the results might actually be more accurate now.
2016-05-12 22:37:45 +02:00
wm4 013d63b081 stream_cdda: enable cache by default
Requested.
2016-05-10 11:17:52 +02:00
wm4 60664bc00b stream_memory: add hex:// protocol
Completely useless, expect for some special purposes.
2016-04-20 18:00:20 +02:00
wm4 da3489353b cache: disable useless "Cache is not responding" warning
Tuning it in a way to be actually useful is too much effort.

As alternative, there's the "buffering" detection, which operates on a
much higher level. The only disadvantage is that it's harder to guess
for the user whether this is a network problem, or if e.g. libavformat
is probing too much data when opening a stream. Maybe the cache-speed
property is helpful here.

For now, do not remove the associated code, but just silence the
warning.

Fixes #3019.
2016-04-03 19:45:09 +02:00
wm4 67888a41e7 build: make DVB test stricter
I got a report that the build on a recent aarch64 Linux kernel failed.
DVB support was detected, but errored on compilation:

In file included from ../stream/stream_dvb.c:57:0:

../stream/dvbin.h:72:5: error: unknown type name 'fe_bandwidth_t'

     fe_bandwidth_t bw;

Make the test stricter, which should take care of this. (I couldn't find
out what exactly triggered the failure, nor could I attempt to reproduce
it.)

The change in stream/dvbin.h is to make sure that this isn't caused by
incorrect header inclusion. It now includes the same files as the
configure test.
2016-04-02 20:51:39 +02:00
wm4 8d69731871 cache: fix incorrect EOF condition
Don't assume EOF if we didn't try to read anything in the first place.
Fixes regressions in particular with low cache sizes, which triggered
the other code paths more often.
2016-03-29 11:43:16 +02:00
wm4 57506b27ed cache: use a single STREAM_CTRL for various cache info
Instead of having a separate for each, which also requires separate
additional caching in the demuxer. (The demuxer adds an indirection,
since STREAM_CTRLs are not thread-safe.)

Since this includes the cache speed, this should fix #3003.
2016-03-29 11:29:52 +02:00
wm4 5f1ff78516 command: add cache-speed property
Should reflect I/O speed.

This could go into the terminal status line. But I'm not sure how to put
it there, since it already uses too much space, so it's not there yet.
2016-03-20 19:51:22 +01:00
wm4 3a7563a999 cache: remove unused STREAM_CTRL_RESUME_CACHE
Went way with DVD/BD menu support.
2016-03-03 10:08:00 +01:00
wm4 92ba630796 demux: remove relative seeking
Ever since a change in mplayer2 or so, relative seeks were translated to
absolute seeks before sending them to the demuxer in most cases. The
only exception in current mpv is DVD seeking.

Remove the SEEK_ABSOLUTE flag; it's not the implied default. SEEK_FACTOR
is kept, because it's sometimes slightly useful for seeking in things
like transport streams. (And maybe mkv files without duration set?)

DVD seeking is terrible because DVD and libdvdnav are terrible, but
mostly because libdvdnav is terrible. libdvdnav does not expose seeking
with seek tables. (Although I know xbmc/kodi use an undocumented API
that is not declared in the headers by dladdr()ing it - I think the
function is dvdnav_jump_to_sector_by_time().) With the current mpv
policy if not giving a shit about DVD, just revert our half-working seek
hacks and always use dvdnav_time_search(). Relative seeking might get
stuck sometimes; in this case --hr-seek=always is recommended.
2016-02-28 19:28:34 +01:00
wm4 337ad4fef4 stream_dvb: fix minor resource leaks
Fixes CID 1350062 and 1350061.

Just for the sake of shutting up Coverity.
2016-02-12 15:51:49 +01:00
wm4 8e4eee9a9a stream_dvb: remove dead code
Fixes CID 1350063.
2016-02-12 15:47:25 +01:00
Oliver Freyermuth 3c4f13c23a dvb: fix segmentation fault in case no valid configuration is found.
This was introduced in c55b242 .
2016-01-24 20:38:51 +01:00
wm4 2df448b1f3 dvb: remove trailing whitespace 2016-01-22 11:55:47 +01:00
wm4 ff4bd73fcb dvb: fix compilation with older Linux headers
At least DTV_ENUM_DELSYS is not available in older versions.

It's hard to tell when this identifier was introduced, but it appears it
was probably API version 5.5.
2016-01-22 11:54:37 +01:00
Oliver Freyermuth 9a2a0b0bba stream_dvb: add verbose output in non-DVBv5 querying.
May help in future debugging in case of old kernels
with modern / obscure devices.
2016-01-21 00:34:02 +01:00
Oliver Freyermuth b2a5c16a9d stream_dvb: use DVBv5 API also for DVB-C tuning.
Using the new API is a necessity for multiple-delivery-system
devices, since the old API does not offer a way to switch
the delivery system of the card.
This should in principle also be done for DVB-T / ATSC,
especially since most DVB-T devices also support DVB-C,
but I can not test such an implementation due to lack of hardware
(currently) so it seems better to leave the existing, tested code-path
in place for now.
2016-01-21 00:34:02 +01:00
Oliver Freyermuth 346cf7abf0 stream_dvb: improve messages on delivery-type detection.
No need use use all capital letters, and don't warn
if DVB-S2 is supported in addition since we handle that
in DVB-S case already.
Also, print the delivery system number for still unhandled
delivery systems to simplify debugging.
2016-01-21 00:34:02 +01:00
Oliver Freyermuth ab59c5f522 stream_dvb: don't requery tuner type, rely on initial query.
Saves one unnecessary additional ioctl per tuning
by just reusing existing information.
Should also fix the case of multiple supported delivery types
since we now rely on the initial query from the chosen
configuration after channel list parsing
instead of requerying the device.
2016-01-21 00:34:02 +01:00
Oliver Freyermuth e904129b79 stream_dvb: support frontends with multiple delivery systems.
Most common case would be DVB-C / DVB-T combination cards.
Cards with multiple delivery systems are only supported
starting from DVBv5 API (Kernel 2.6.38).
In this case, we loop over all delivery systems and
just treat them as different cards would be treated:
They all get their own TUNER-type, channel-list parsing etc.
2016-01-21 00:34:02 +01:00
wm4 8a9b64329c Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.

There are probably more files to which this applies, but I'm being
conservative here.

A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).

common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.

codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.

From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).

misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.

screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 18:36:06 +01:00
wm4 6f35d4df5a cache: add mechanism for disabling readahead
Will be used in a following commit.
2016-01-18 18:40:12 +01:00
Oliver Freyermuth 62acd315ad player, stream_dvb: implement dvb-channel-name property.
On read, it returns the name of the current DVB program,
on write, it triggers a channel-switch to the program
if it is found in the channel list of the currently active card.
Compared to the dvb-channel property which already exists
and is a pair of integers (card + channel number) this has the limitation
of not switching the card, but is probably of much more common use.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth c55b242b4e stream_dvb: global protection mutex and usage bit for global_dvb_state.
The mutex is used in dvbin_open and dvbin_close only since these are
the only entry / exit points to the stream.
When opening, it is first checked (mutexed) whether the state already exists
and is in use, then a STREAM_ERROR is returned,
since there may be only one stream_dvb active at a time.
State-creation itself is also protected by mutex.
In dvbin_close, the usage-bit is set to false (mutexed) in case
of channel switch.
In case of stream-teardown, the state is destructed
(also protected by mutex).
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 1e46bda0f8 stream_dvb: implement GET_METADATA and return program name.
Now title will be the current channel name also after channel switch.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 16723d4bb1 stream_dvb: persist state-information across channel-switches.
The state-structure is kept in a static pointer and reused on
recreation of the stream.
To not leak the state and the FDs within upon mpv shutdown,
the state-structure is still destructed gracefully in dvbin_close(),
unless a channel switch has been initiated directly before.
This fixes channel-switching for DVB which was broken since a609877.
2016-01-14 00:36:53 +01:00
Oliver Freyermuth 4c3f95708f dvb: rename dvb_config_t to dvb_state_t, keep config and state there.
The state-struct now contains everything which can be kept after initial initialization.
This includes the channel-lists, configuration, device-fds and also information like
current channel and current card.
The dvb_priv_t is kept containing the mp-options, a pointer to the state and to the logger.
After this restructuring, the state-struct contains all information which can be persisted
across channel switching.
2016-01-14 00:36:53 +01:00
wm4 cbda46370c stream: stream_read_complete() reads from current pos, not 0
(Well, I hope no caller really relied on this anyway.)
2016-01-12 23:50:17 +01:00
Dmitrij D. Czarkoff ea442fa047 mpv_talloc.h: rename from talloc.h
This change helps avoiding conflict with talloc.h from libtalloc.
2016-01-11 21:05:55 +01:00
wm4 f54ae2031e cache: remove useless return value
It was unused, and also returned the wrong value in some cases.
2016-01-11 20:34:34 +01:00
Oliver Freyermuth 2dd8982f73 dvb: cleanup dvb_params struct, remove some unneeded fds
One was just used as an alias, the other one (sec_fd) was not used at
all.

Signed-off-by: wm4 <wm4@nowhere>
2016-01-07 19:20:48 +01:00
James Ross-Gowan c19f634e6c win32: fix fd://
Windows definitely supports Unix-style fd inheritance. This mostly
worked when launched from mpv.exe, though mpv should change the file
mode to O_BINARY. When launched from mpv.com, the wrapper must pass the
list of handles (stored in the undocumented lpReserved2 and cbReserved2
fields) to the mpv process.
2016-01-07 23:37:06 +11:00
wm4 23a5329690 stream_lavf: remove tabs
Death to tabs.
2015-12-22 23:18:46 +01:00
Aman Gupta fccc3d3894 Fix some typos in code comments
Signed-off-by: wm4 <wm4@nowhere>
2015-12-21 22:28:12 +01:00
wm4 475fe453cc stream: drop PVR support
This is only for specific Hauppage cards. According to the comments in
who is actively using this feature. Get it out of the way.

Anyone who still wants to use this should complain. Keeping this code
would not cause terribly much additional work, and it could be restored
again. (But not if the request comes months later.)
2015-12-10 22:53:02 +01:00
Kevin Mitchell dd0c85679b stream_libarchive: make libarchive seek callback lazy
This fixes problems seeking http streams to their end.
2015-11-09 22:41:19 -08:00
Kevin Mitchell 4efadb2808 stream_libarchive: add multivolume support
This commit introduces logic to read other volumes from the same source
as the primary archive. Both .rar formats as well as 7z are supported for now.

It also changes the libarchive callback structure to be per-volume
consistent with the libarchive intenal client data array constructed
with archive_read_append_callback_data.

Added open, close and switch callbacks. Only the latter is strictly
required to make sure that the streams always start at position 0, but
leaving all volumes open can eat a lot of memory for archives with many
parts.
2015-11-09 22:41:19 -08:00
Kevin Mitchell cf5b117553 libarchive: remove redundant log prefix
"libarchive:" is already added by the logging system
2015-11-09 22:41:19 -08:00
wm4 05e39ec513 stream/audio: fix unchecked strdups
See #2435. It's literally a waste of time trying to fix minor memory
leaks in this old, unused, and crappy code.
2015-10-30 15:51:26 +01:00
Joschka Tillmanns 1ee8ce75f1 options: add support for client certificate authentication
Client certificates are supported by ffmpeg as documented here:

  > https://www.ffmpeg.org/ffmpeg-protocols.html#tls

Signed-off-by: wm4 <wm4@nowhere>
2015-10-20 22:55:27 +02:00
wm4 aff6e8e8da stream: minor cleanup to verbose logging
Don't print the URL that is opened twice. stream.c and stream_lavf.c
each printed it once. Remove the logging from stream_lavf.c, and move
the log call to a more interesting point.
2015-09-30 22:51:37 +02:00
wm4 2492b5f119 cache: do not include backbuffer size in total stream cache size
This causes weirdness with the "cache-size" property and option. Only
the read handler of the property included the backbuffer, while all
others did not. Make it consistent, and subtract the backbuffer size
from the cache size.

Fixes #2305.
2015-09-10 14:15:45 +02:00
wm4 5c3196d20b stream_libarchive: read tar only in "unsafe" mode
As expected, probing with libarchive is a disaster. Both libavformat and
libarchive are too eager to misdetect file formats just because files
"might" be of a specific type. In this case, it's mp3 vs. tar. To be
fair, neither file format has an actual header. I'm not sure why we'd
need tar support, but since libarchive provides it, and idiots on the
internet apparently pack media files in tar sometimes (really, idiots),
keep it for now, and probe tar last.
2015-08-22 22:13:20 +02:00
wm4 addbf8faae stream_libarchive: disable raw filter
Too many false positives (it accepts things like unspecific text files),
and also relatively useless.
2015-08-20 21:56:44 +02:00
wm4 1b93a7a895 stream_libarchive: fix libarchive callback signature
libarchive uses a quite confusing ifdeffery mess for some of the types
used in callbacks. Currently, archive_read_set_seek_callback() causes a
warning at least on Windows due to mismatching return type. The header
file uses __LA_INT64_T as return type, so I think the user is intended
to use int64_t.

(The ssize_t return type for the read_cb seems correct, on the other
hand.)
2015-08-20 11:08:22 +02:00
wm4 4427fa9900 stream_libarchive: restrict number of allowed formats
Most of what is not in this list is extremely obscure, or increases the
file format misdetection rate.
2015-08-18 23:26:40 +02:00
wm4 cf2fa9d3e5 stream: provide a stream_get_size() convenience function
And use it everywhere, instead of retrieving the size manually. Slight
simplification.
2015-08-18 00:10:54 +02:00
wm4 bf5eac8dd3 demux_libarchive: open flat compressed files
Things like .gz etc., which have no real file header. A mixed bag,
because it e.g. tends to misdetect mp3 files as compressed files or
something (of course it has no mp3 support - I don't know as what it
detects them). But requested by someone (or maybe not, I'm not sure
how to interpret that).
2015-08-17 23:59:55 +02:00
wm4 2b280f4522 stream: libarchive wrapper for reading compressed archives
This works similar to the existing .rar support, but uses libarchive.
libarchive supports a number of formats, including zip and (most of)
rar.

Unfortunately, seeking does not work too well. Most libarchive readers
do not support seeking, so it's emulated by skipping data until the
target position. On backwards seek, the file is reopened. This works
fine on a local machine (and if the file is not too large), but will
perform not so well over network connection.

This is disabled by default for now. One reason is that we try
libarchive on every file we open, before trying libavformat, and I'm not
sure if I trust libarchive that much yet. Another reason is that this
breaks multivolume rar support. While libarchive supports seeking in
rar, and (probably) supports multivolume archive, our support of
libarchive (probably) does not. I don't care about multivolume rar, but
vocal users do.
2015-08-17 00:55:26 +02:00
wm4 525ada8c7a stream: remove remaining DVD/BD menu definitions 2015-08-03 23:49:14 +02:00
wm4 c844d57489 stream_bluray: remove menu implementation 2015-08-03 23:49:14 +02:00
wm4 1ef7820e6e stream_dvdnav: rip out lower-level menu implementation
Separate because it might cause regressions.
2015-08-03 23:49:14 +02:00
wm4 41101c2996 win32: revert wchar_t changes
Revert "win32: more wchar_t -> WCHAR replacements"
Revert "win32: replace wchar_t with WCHAR"

Doing a "partial" port of this makes no sense anymore from my
perspective. Revert the changes, as they're confusing without
context, maintenance, and progress. These changes were a bit
premature anyway, and might actually cause other issues
(locale neutrality etc. as it was pointed out).
2015-08-01 21:09:11 +02:00
wm4 fefac2c941 win32: more wchar_t -> WCHAR replacements
This was essentially missing from commit 0b52ac8a.

Since L"..." string literals have the type wchar_t[], we can't use them
for UTF-16 strings. Use C11 u"..." string literals instead. These have
the type char16_t[], but we simply assume char16_t is the same
underlying type as WCHAR. In practice, they're both unsigned short.

For this reason use -std=c11 on Windows. Since Windows is a "special"
environment (we require either MinGW or Cygwin), we don't need to worry
too much about compiler compatibility.
2015-07-30 21:50:11 +02:00
wm4 55879a8c0f cache: make backbuffer size configurable
Allow setting an arbitrary amount, instead of the fixed 50%.

This is nto striclty backwards compatible. The defaults don't change,
but the --cache/--cache-default options now set the readahead portion.
So in practice, users who configured this until now will see the
double amount of cache being used, _plus_ the 75MB default backbuffer
will be in use.
2015-07-22 23:55:10 +02:00
wm4 63d112746d cache: fix backbuffer logic
Currently, this is perfectly equivalent, because back_size is hardcoded
to buffer_size/2. But this fixes the logic for the case the back_size
can be configured freely.
2015-07-22 23:30:05 +02:00
wm4 01ce203ed7 stream_file: remove an indirection
Remove the "fd" local variable, and always use "p->fd" directly.
2015-07-10 12:47:53 +02:00
wm4 4c04f74a50 stream_file: cosmetics: shorten variable name
Can't be bothered to type this much.
2015-07-10 12:45:49 +02:00
Ben Boeckel 731fc5b816 stream_file: initialize `fd`
Use the fd variable and delay assignment to priv->fd to mirror other
branches of the if/else tree.
2015-07-09 23:04:06 +02:00
wm4 d23d9dc394 stream_file: add fd:// protocol 2015-07-09 15:51:31 +02:00
wm4 3b3170aedb Disable DVD and BD menu support (to be removed)
DVD/BD menu support never worked right, and are a pain to maintain. In
particular, DVD menus never actually worked correctly, because
highlights were not rendered correctly. Fixing this requires major
effort, which I'm not interested to spend.

Most importantly, the requirement to switch streams without losing the
DVD/BD state caused major weirdness in the playback core. It was
implemented by somehow syncing the playback state to the DVD/BD
implementation (in stream_dvdnav.c etc.), and then reloading the demuxer
without destroying and recreating the stream. This caused a bunch of
special-cases which I'm looking forward to remove.

For now, don't just remove everything related to menu support and just
disable it. If someone volunteers, it can be restored (i.e. rewritten)
in a reasonable way. If nobody volunteers soon, it goes.
2015-06-26 23:37:30 +02:00
wm4 5bea966836 cache: limit readahead size to half the cache size at the beginning
Normally, the cache keeps 50% of the buffer for seeking backwards. Until
now, the cache just used the full buffer size at the beginning of a
file, because the 50% normally reserved for the backbuffer are unused.

This caused a problem: when streaming from http, the player would first
read about 150MB (default cache size), then stop until 75MB of the cache
has been played. (Until the 75MB position, the cache is fully used, so
nothing new can be read. After that, part of the backbuffer starts
getting unreserved, and can be used for readahead.) This long read pause
can cause the server to terminate the connection. Reconnecting may be
possible, but if youtube-dl is used, the media URL may have become
invalid.

Fix this by limiting readahead to 50% even if unnecessary. The only
exception is when the whole file would fit in the cache. In this case,
it won't matter if we can't reconnect, because the cache covers
everything anyway, and hopefully the cache will stay valid.

Likely fixes #2000.
2015-05-29 22:32:10 +02:00
Niklas Haas 4d6b9550fe
vo_opengl: add support for custom shaders 2015-05-27 11:09:41 +02:00
wm4 8054c034b8 command: add protocol-list property
Fixes #1972.
2015-05-23 15:26:55 +02:00