Commit Graph

1891 Commits

Author SHA1 Message Date
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